if NTCP failed, try to send through SSU

This commit is contained in:
orignal 2014-04-05 15:44:12 -04:00
parent fb2a89cbea
commit ff9f14d7a6
2 changed files with 14 additions and 5 deletions

View File

@ -56,11 +56,19 @@ namespace ntcp
{ {
m_IsEstablished = false; m_IsEstablished = false;
m_Socket.close (); m_Socket.close ();
for (auto it :m_DelayedMessages)
delete it;
m_DelayedMessages.clear ();
// TODO: notify tunnels
i2p::transports.RemoveNTCPSession (this); i2p::transports.RemoveNTCPSession (this);
int numDelayed = 0;
for (auto it :m_DelayedMessages)
{
// try to send them again
i2p::transports.SendMessage (m_RemoteRouterInfo.GetIdentHash (), it);
numDelayed++;
}
m_DelayedMessages.clear ();
if (numDelayed > 0)
LogPrint ("NTCP session ", numDelayed, " not sent");
// TODO: notify tunnels
delete this; delete this;
LogPrint ("NTCP session terminated"); LogPrint ("NTCP session terminated");
} }
@ -327,6 +335,7 @@ namespace ntcp
if (ecode) if (ecode)
{ {
LogPrint ("Phase 4 read error: ", ecode.message ()); LogPrint ("Phase 4 read error: ", ecode.message ());
GetRemoteRouterInfo ().SetUnreachable (true); // this router doesn't like us
Terminate (); Terminate ();
} }
else else

View File

@ -239,7 +239,7 @@ namespace i2p
// existing session not found. create new // existing session not found. create new
// try NTCP first // try NTCP first
auto address = r->GetNTCPAddress (); auto address = r->GetNTCPAddress ();
if (address) if (address && !r->IsUnreachable ())
{ {
auto s = new i2p::ntcp::NTCPClient (m_Service, address->host, address->port, *r); auto s = new i2p::ntcp::NTCPClient (m_Service, address->host, address->port, *r);
AddNTCPSession (s); AddNTCPSession (s);