|
|
@ -491,26 +491,26 @@ namespace transport |
|
|
|
else |
|
|
|
else |
|
|
|
peer.numAttempts = 2; // switch to SSU
|
|
|
|
peer.numAttempts = 2; // switch to SSU
|
|
|
|
} |
|
|
|
} |
|
|
|
if (peer.numAttempts == 2 || peer.numAttempts == 3) // SSU
|
|
|
|
if (peer.numAttempts == 2 || peer.numAttempts == 3) // SSU2, 2 - ipv6, 3 - ipv4
|
|
|
|
{ |
|
|
|
{ |
|
|
|
if (m_SSUServer) |
|
|
|
if (m_SSU2Server) |
|
|
|
{ |
|
|
|
{ |
|
|
|
std::shared_ptr<const RouterInfo::Address> address; |
|
|
|
std::shared_ptr<const RouterInfo::Address> address; |
|
|
|
if (peer.numAttempts == 2) // SSU ipv6
|
|
|
|
if (peer.numAttempts == 2) // SSU2 ipv6
|
|
|
|
{ |
|
|
|
{ |
|
|
|
if (context.GetRouterInfo ().IsSSUV6 () && peer.router->IsReachableBy (RouterInfo::eSSUV6)) |
|
|
|
if (context.GetRouterInfo ().IsSSU2V6 () && peer.router->IsReachableBy (RouterInfo::eSSU2V6)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
address = peer.router->GetSSUV6Address (); |
|
|
|
address = peer.router->GetSSU2V6Address (); |
|
|
|
if (address && m_CheckReserved && i2p::util::net::IsInReservedRange(address->host)) |
|
|
|
if (address && m_CheckReserved && i2p::util::net::IsInReservedRange(address->host)) |
|
|
|
address = nullptr; |
|
|
|
address = nullptr; |
|
|
|
} |
|
|
|
} |
|
|
|
peer.numAttempts++; |
|
|
|
peer.numAttempts++; |
|
|
|
} |
|
|
|
} |
|
|
|
if (!address && peer.numAttempts == 3) // SSU ipv4
|
|
|
|
if (!address && peer.numAttempts == 3) // SSU2 ipv4
|
|
|
|
{ |
|
|
|
{ |
|
|
|
if (context.GetRouterInfo ().IsSSU (true) && peer.router->IsReachableBy (RouterInfo::eSSUV4)) |
|
|
|
if (context.GetRouterInfo ().IsSSU2V4 () && peer.router->IsReachableBy (RouterInfo::eSSU2V4)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
address = peer.router->GetSSUAddress (true); |
|
|
|
address = peer.router->GetSSU2V4Address (); |
|
|
|
if (address && m_CheckReserved && i2p::util::net::IsInReservedRange(address->host)) |
|
|
|
if (address && m_CheckReserved && i2p::util::net::IsInReservedRange(address->host)) |
|
|
|
address = nullptr; |
|
|
|
address = nullptr; |
|
|
|
} |
|
|
|
} |
|
|
@ -518,12 +518,12 @@ namespace transport |
|
|
|
} |
|
|
|
} |
|
|
|
if (address && address->IsReachableSSU ()) |
|
|
|
if (address && address->IsReachableSSU ()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (m_SSUServer->CreateSession (peer.router, address)) |
|
|
|
if (m_SSU2Server->CreateSession (peer.router, address)) |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
peer.numAttempts += 2; // switch to Mesh
|
|
|
|
peer.numAttempts += 2; // switch to mesh
|
|
|
|
} |
|
|
|
} |
|
|
|
if (peer.numAttempts == 4) // Mesh
|
|
|
|
if (peer.numAttempts == 4) // Mesh
|
|
|
|
{ |
|
|
|
{ |
|
|
@ -539,26 +539,26 @@ namespace transport |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (peer.numAttempts == 5 || peer.numAttempts == 6) // SSU2
|
|
|
|
if (peer.numAttempts == 5 || peer.numAttempts == 6) // SSU, 5 - ipv6, 6 - ipv4
|
|
|
|
{ |
|
|
|
{ |
|
|
|
if (m_SSU2Server) |
|
|
|
if (m_SSUServer) |
|
|
|
{ |
|
|
|
{ |
|
|
|
std::shared_ptr<const RouterInfo::Address> address; |
|
|
|
std::shared_ptr<const RouterInfo::Address> address; |
|
|
|
if (peer.numAttempts == 5) // SSU2 ipv6
|
|
|
|
if (peer.numAttempts == 5) // SSU ipv6
|
|
|
|
{ |
|
|
|
{ |
|
|
|
if (context.GetRouterInfo ().IsSSU2V6 () && peer.router->IsReachableBy (RouterInfo::eSSU2V6)) |
|
|
|
if (context.GetRouterInfo ().IsSSUV6 () && peer.router->IsReachableBy (RouterInfo::eSSUV6)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
address = peer.router->GetSSU2V6Address (); |
|
|
|
address = peer.router->GetSSUV6Address (); |
|
|
|
if (address && m_CheckReserved && i2p::util::net::IsInReservedRange(address->host)) |
|
|
|
if (address && m_CheckReserved && i2p::util::net::IsInReservedRange(address->host)) |
|
|
|
address = nullptr; |
|
|
|
address = nullptr; |
|
|
|
} |
|
|
|
} |
|
|
|
peer.numAttempts++; |
|
|
|
peer.numAttempts++; |
|
|
|
} |
|
|
|
} |
|
|
|
if (!address && peer.numAttempts == 6) // SSU2 ipv4
|
|
|
|
if (!address && peer.numAttempts == 6) // SSU ipv4
|
|
|
|
{ |
|
|
|
{ |
|
|
|
if (context.GetRouterInfo ().IsSSU2V4 () && peer.router->IsReachableBy (RouterInfo::eSSU2V4)) |
|
|
|
if (context.GetRouterInfo ().IsSSU (true) && peer.router->IsReachableBy (RouterInfo::eSSUV4)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
address = peer.router->GetSSU2V4Address (); |
|
|
|
address = peer.router->GetSSUAddress (true); |
|
|
|
if (address && m_CheckReserved && i2p::util::net::IsInReservedRange(address->host)) |
|
|
|
if (address && m_CheckReserved && i2p::util::net::IsInReservedRange(address->host)) |
|
|
|
address = nullptr; |
|
|
|
address = nullptr; |
|
|
|
} |
|
|
|
} |
|
|
@ -566,7 +566,7 @@ namespace transport |
|
|
|
} |
|
|
|
} |
|
|
|
if (address && address->IsReachableSSU ()) |
|
|
|
if (address && address->IsReachableSSU ()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (m_SSU2Server->CreateSession (peer.router, address)) |
|
|
|
if (m_SSUServer->CreateSession (peer.router, address)) |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|