Skip to content

Commit

Permalink
Merge pull request #281 from anonimal/master
Browse files Browse the repository at this point in the history
Catch exception in SSUServer that would dump core.
  • Loading branch information
EinMByte committed Oct 14, 2015
2 parents e4f1971 + 6ae5f20 commit 45d27f8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion core/RouterInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ namespace data

void RouterInfo::CreateBuffer (const PrivateKeys& privateKeys)
{
m_Timestamp = i2p::util::GetMillisecondsSinceEpoch (); // refresh timstamp
m_Timestamp = i2p::util::GetMillisecondsSinceEpoch (); // refresh timestamp
std::stringstream s;
uint8_t ident[1024];
auto identLen = privateKeys.GetPublic ().ToBuffer (ident, 1024);
Expand Down
16 changes: 12 additions & 4 deletions core/transport/SSU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,19 @@ namespace transport

void SSUServer::Send (const uint8_t * buf, size_t len, const boost::asio::ip::udp::endpoint& to)
{
if (to.protocol () == boost::asio::ip::udp::v4())
m_Socket.send_to (boost::asio::buffer (buf, len), to);
if (to.protocol () == boost::asio::ip::udp::v4())
try {
m_Socket.send_to (boost::asio::buffer (buf, len), to);
} catch (const std::exception& ex) {
LogPrint (eLogError, "SSUServer send error: ", ex.what());
}
else
m_SocketV6.send_to (boost::asio::buffer (buf, len), to);
}
try {
m_SocketV6.send_to (boost::asio::buffer (buf, len), to);
} catch (const std::exception& ex) {
LogPrint (eLogError, "SSUServer V6 send error: ", ex.what());
}
}

void SSUServer::Receive ()
{
Expand Down

0 comments on commit 45d27f8

Please sign in to comment.