1
0
mirror of https://github.com/PurpleI2P/i2pd.git synced 2025-01-31 13:14:13 +00:00

keep SSU2 socket open even if failed to bind

This commit is contained in:
orignal 2024-02-09 18:08:51 -05:00
parent d96803a290
commit 36dbc15bca

View File

@ -258,13 +258,22 @@ namespace transport
socket.set_option (boost::asio::ip::v6_only (true)); socket.set_option (boost::asio::ip::v6_only (true));
socket.set_option (boost::asio::socket_base::receive_buffer_size (SSU2_SOCKET_RECEIVE_BUFFER_SIZE)); socket.set_option (boost::asio::socket_base::receive_buffer_size (SSU2_SOCKET_RECEIVE_BUFFER_SIZE));
socket.set_option (boost::asio::socket_base::send_buffer_size (SSU2_SOCKET_SEND_BUFFER_SIZE)); socket.set_option (boost::asio::socket_base::send_buffer_size (SSU2_SOCKET_SEND_BUFFER_SIZE));
}
catch (std::exception& ex )
{
LogPrint (eLogCritical, "SSU2: Failed to open socket on ", localEndpoint.address (), ": ", ex.what());
ThrowFatal ("Unable to start SSU2 transport on ", localEndpoint.address (), ": ", ex.what ());
return socket;
}
try
{
socket.bind (localEndpoint); socket.bind (localEndpoint);
LogPrint (eLogInfo, "SSU2: Start listening on ", localEndpoint); LogPrint (eLogInfo, "SSU2: Start listening on ", localEndpoint);
} }
catch (std::exception& ex ) catch (std::exception& ex )
{ {
LogPrint (eLogCritical, "SSU2: Failed to bind to ", localEndpoint, ": ", ex.what()); LogPrint (eLogWarning, "SSU2: Failed to bind to ", localEndpoint, ": ", ex.what(), ". Actual endpoint is ", socket.local_endpoint ());
ThrowFatal ("Unable to start SSU2 transport on ", localEndpoint, ": ", ex.what ()); // we can continue without binding being firewalled
} }
return socket; return socket;
} }