diff --git a/NTCPSession.cpp b/NTCPSession.cpp index 7eb1614a..e21e8d18 100644 --- a/NTCPSession.cpp +++ b/NTCPSession.cpp @@ -56,11 +56,19 @@ namespace ntcp { m_IsEstablished = false; m_Socket.close (); + i2p::transports.RemoveNTCPSession (this); + int numDelayed = 0; for (auto it :m_DelayedMessages) - delete it; + { + // 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 - i2p::transports.RemoveNTCPSession (this); + delete this; LogPrint ("NTCP session terminated"); } @@ -327,6 +335,7 @@ namespace ntcp if (ecode) { LogPrint ("Phase 4 read error: ", ecode.message ()); + GetRemoteRouterInfo ().SetUnreachable (true); // this router doesn't like us Terminate (); } else diff --git a/Transports.cpp b/Transports.cpp index 6c326e72..10c27afd 100644 --- a/Transports.cpp +++ b/Transports.cpp @@ -239,7 +239,7 @@ namespace i2p // existing session not found. create new // try NTCP first auto address = r->GetNTCPAddress (); - if (address) + if (address && !r->IsUnreachable ()) { auto s = new i2p::ntcp::NTCPClient (m_Service, address->host, address->port, *r); AddNTCPSession (s);