|
|
@ -156,34 +156,36 @@ namespace i2p |
|
|
|
void Transports::PostMessage (const i2p::data::IdentHash& ident, i2p::I2NPMessage * msg) |
|
|
|
void Transports::PostMessage (const i2p::data::IdentHash& ident, i2p::I2NPMessage * msg) |
|
|
|
{ |
|
|
|
{ |
|
|
|
auto session = FindNTCPSession (ident); |
|
|
|
auto session = FindNTCPSession (ident); |
|
|
|
if (!session) |
|
|
|
if (session) |
|
|
|
|
|
|
|
session->SendI2NPMessage (msg); |
|
|
|
|
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
RouterInfo * r = netdb.FindRouter (ident); |
|
|
|
RouterInfo * r = netdb.FindRouter (ident); |
|
|
|
if (r) |
|
|
|
if (r) |
|
|
|
{ |
|
|
|
{ |
|
|
|
auto address = r->GetNTCPAddress (); |
|
|
|
auto ssuSession = m_SSUServer ? m_SSUServer->FindSession (r) : nullptr; |
|
|
|
if (address) |
|
|
|
if (ssuSession) |
|
|
|
{ |
|
|
|
ssuSession->SendI2NPMessage (msg); |
|
|
|
session = new i2p::ntcp::NTCPClient (m_Service, address->host, address->port, *r); |
|
|
|
|
|
|
|
AddNTCPSession (session); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
// SSU always have lower prioprity than NTCP
|
|
|
|
// existing session not found. create new
|
|
|
|
// TODO: it shouldn't
|
|
|
|
// try NTCP first
|
|
|
|
LogPrint ("No NTCP addresses available. Trying SSU"); |
|
|
|
auto address = r->GetNTCPAddress (); |
|
|
|
address = r->GetSSUAddress (); |
|
|
|
if (address) |
|
|
|
if (address && m_SSUServer) |
|
|
|
{ |
|
|
|
{ |
|
|
|
auto s = new i2p::ntcp::NTCPClient (m_Service, address->host, address->port, *r); |
|
|
|
auto s = m_SSUServer->GetSession (r); |
|
|
|
AddNTCPSession (s); |
|
|
|
|
|
|
|
s->SendI2NPMessage (msg); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// then SSU
|
|
|
|
|
|
|
|
auto s = m_SSUServer ? m_SSUServer->GetSession (r) : nullptr; |
|
|
|
if (s) |
|
|
|
if (s) |
|
|
|
{ |
|
|
|
|
|
|
|
s->SendI2NPMessage (msg); |
|
|
|
s->SendI2NPMessage (msg); |
|
|
|
return; |
|
|
|
else |
|
|
|
} |
|
|
|
LogPrint ("No NTCP and SSU addresses available"); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
|
|
|
|
LogPrint ("No SSU addresses available"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
@ -192,10 +194,6 @@ namespace i2p |
|
|
|
i2p::data::netdb.RequestDestination (ident); |
|
|
|
i2p::data::netdb.RequestDestination (ident); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (session) |
|
|
|
|
|
|
|
session->SendI2NPMessage (msg); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
LogPrint ("Session not found"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Transports::DetectExternalIP () |
|
|
|
void Transports::DetectExternalIP () |
|
|
|