Browse Source

close connection to first hop of declined tunnel

pull/93/head
orignal 10 years ago
parent
commit
8801a144a0
  1. 1
      I2NPProtocol.cpp
  2. 17
      Transports.cpp
  3. 2
      Transports.h
  4. 4
      Tunnel.cpp

1
I2NPProtocol.cpp

@ -359,6 +359,7 @@ namespace i2p @@ -359,6 +359,7 @@ namespace i2p
else
{
LogPrint ("Outbound tunnel ", tunnel->GetTunnelID (), " has been declined");
i2p::transports.CloseSession (tunnel->GetTunnelConfig ()->GetFirstHop ()->router);
delete tunnel;
}
}

17
Transports.cpp

@ -263,6 +263,23 @@ namespace i2p @@ -263,6 +263,23 @@ namespace i2p
}
}
void Transports::CloseSession (const i2p::data::RouterInfo * router)
{
if (!router) return;
m_Service.post (boost::bind (&Transports::PostCloseSession, this, router));
}
void Transports::PostCloseSession (const i2p::data::RouterInfo * router)
{
auto ssuSession = m_SSUServer ? m_SSUServer->FindSession (router) : nullptr;
if (ssuSession) // try SSU first
{
m_SSUServer->DeleteSession (ssuSession);
LogPrint ("SSU session closed");
}
// TODO: delete NTCP
}
void Transports::DetectExternalIP ()
{
for (int i = 0; i < 5; i ++)

2
Transports.h

@ -63,12 +63,14 @@ namespace i2p @@ -63,12 +63,14 @@ namespace i2p
i2p::ntcp::NTCPSession * FindNTCPSession (const i2p::data::IdentHash& ident);
void SendMessage (const i2p::data::IdentHash& ident, i2p::I2NPMessage * msg);
void CloseSession (const i2p::data::RouterInfo * router);
private:
void Run ();
void HandleAccept (i2p::ntcp::NTCPServerConnection * conn, const boost::system::error_code& error);
void PostMessage (const i2p::data::IdentHash& ident, i2p::I2NPMessage * msg);
void PostCloseSession (const i2p::data::RouterInfo * router);
void DetectExternalIP ();

4
Tunnel.cpp

@ -361,10 +361,12 @@ namespace tunnel @@ -361,10 +361,12 @@ namespace tunnel
void Tunnels::ManageTunnels ()
{
// check pending tunnel. if something is still there, wipe it out
// because it wouldn't be reponded anyway
// because it wouldn't be responded anyway
for (auto& it : m_PendingTunnels)
{
LogPrint ("Pending tunnel build request ", it.first, " has not been responded. Deleted");
if (it.second->GetTunnelConfig ()->GetFirstHop ()->isGateway) // outbound
i2p::transports.CloseSession (it.second->GetTunnelConfig ()->GetFirstHop ()->router);
delete it.second;
}
m_PendingTunnels.clear ();

Loading…
Cancel
Save