|
|
@ -1109,8 +1109,8 @@ namespace transport |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
SSU2Server::SSU2Server (): |
|
|
|
SSU2Server::SSU2Server (): |
|
|
|
RunnableServiceWithWork ("SSU2"), m_ReceiveServiceV4 ("SSU2v4"), m_ReceiveServiceV6 ("SSU2v6"), |
|
|
|
RunnableServiceWithWork ("SSU2"), m_ReceiveService ("SSU2r"), |
|
|
|
m_SocketV4 (m_ReceiveServiceV4.GetService ()), m_SocketV6 (m_ReceiveServiceV6.GetService ()), |
|
|
|
m_SocketV4 (m_ReceiveService.GetService ()), m_SocketV6 (m_ReceiveService.GetService ()), |
|
|
|
m_TerminationTimer (GetService ()), m_ResendTimer (GetService ()) |
|
|
|
m_TerminationTimer (GetService ()), m_ResendTimer (GetService ()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
} |
|
|
|
} |
|
|
@ -1120,6 +1120,7 @@ namespace transport |
|
|
|
if (!IsRunning ()) |
|
|
|
if (!IsRunning ()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
StartIOService (); |
|
|
|
StartIOService (); |
|
|
|
|
|
|
|
bool found = false; |
|
|
|
auto& addresses = i2p::context.GetRouterInfo ().GetAddresses (); |
|
|
|
auto& addresses = i2p::context.GetRouterInfo ().GetAddresses (); |
|
|
|
for (const auto& address: addresses) |
|
|
|
for (const auto& address: addresses) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1141,9 +1142,9 @@ namespace transport |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (address->IsV4 ()) |
|
|
|
if (address->IsV4 ()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
m_ReceiveServiceV4.Start (); |
|
|
|
found = true; |
|
|
|
OpenSocket (boost::asio::ip::udp::endpoint (boost::asio::ip::udp::v4(), port)); |
|
|
|
OpenSocket (boost::asio::ip::udp::endpoint (boost::asio::ip::udp::v4(), port)); |
|
|
|
m_ReceiveServiceV4.GetService ().post( |
|
|
|
m_ReceiveService.GetService ().post( |
|
|
|
[this]() |
|
|
|
[this]() |
|
|
|
{ |
|
|
|
{ |
|
|
|
Receive (m_SocketV4); |
|
|
|
Receive (m_SocketV4); |
|
|
@ -1151,9 +1152,9 @@ namespace transport |
|
|
|
} |
|
|
|
} |
|
|
|
if (address->IsV6 ()) |
|
|
|
if (address->IsV6 ()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
m_ReceiveServiceV6.Start (); |
|
|
|
found = true; |
|
|
|
OpenSocket (boost::asio::ip::udp::endpoint (boost::asio::ip::udp::v6(), port)); |
|
|
|
OpenSocket (boost::asio::ip::udp::endpoint (boost::asio::ip::udp::v6(), port)); |
|
|
|
m_ReceiveServiceV6.GetService ().post( |
|
|
|
m_ReceiveService.GetService ().post( |
|
|
|
[this]() |
|
|
|
[this]() |
|
|
|
{ |
|
|
|
{ |
|
|
|
Receive (m_SocketV6); |
|
|
|
Receive (m_SocketV6); |
|
|
@ -1164,17 +1165,16 @@ namespace transport |
|
|
|
LogPrint (eLogError, "SSU2: Can't start server because port not specified"); |
|
|
|
LogPrint (eLogError, "SSU2: Can't start server because port not specified"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (found) |
|
|
|
|
|
|
|
m_ReceiveService.Start (); |
|
|
|
ScheduleTermination (); |
|
|
|
ScheduleTermination (); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SSU2Server::Stop () |
|
|
|
void SSU2Server::Stop () |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (context.SupportsV4 ()) |
|
|
|
if (context.SupportsV4 () || context.SupportsV6 ()) |
|
|
|
m_ReceiveServiceV4.Stop (); |
|
|
|
m_ReceiveService.Stop (); |
|
|
|
|
|
|
|
|
|
|
|
if (context.SupportsV6 ()) |
|
|
|
|
|
|
|
m_ReceiveServiceV6.Stop (); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (IsRunning ()) |
|
|
|
if (IsRunning ()) |
|
|
|
m_TerminationTimer.cancel (); |
|
|
|
m_TerminationTimer.cancel (); |
|
|
|