Browse Source

make sure only one I2P tunnel per local prot

pull/163/head
orignal 10 years ago
parent
commit
ed692ffba3
  1. 13
      ClientContext.cpp
  2. 4
      ClientContext.h

13
ClientContext.cpp

@ -54,9 +54,10 @@ namespace client @@ -54,9 +54,10 @@ namespace client
std::string ircKeys = i2p::util::config::GetArg("-irckeys", "");
if (ircKeys.length () > 0)
localDestination = LoadLocalDestination (ircKeys, false);
auto ircTunnel = new I2PClientTunnel (ircDestination, i2p::util::config::GetArg("-ircport", 6668), localDestination);
auto ircPort = i2p::util::config::GetArg("-ircport", 6668);
auto ircTunnel = new I2PClientTunnel (ircDestination, ircPort, localDestination);
ircTunnel->Start ();
m_ClientTunnels.push_back (std::unique_ptr<I2PClientTunnel>(ircTunnel));
m_ClientTunnels.insert (std::make_pair(ircPort, std::unique_ptr<I2PClientTunnel>(ircTunnel)));
LogPrint("IRC tunnel started");
}
std::string eepKeys = i2p::util::config::GetArg("-eepkeys", "");
@ -112,8 +113,8 @@ namespace client @@ -112,8 +113,8 @@ namespace client
LogPrint("SOCKS Proxy stopped");
for (auto& it: m_ClientTunnels)
{
it->Stop ();
LogPrint("I2P client tunnel stopped");
it.second->Stop ();
LogPrint("I2P client tunnel on port ", it.first, " stopped");
}
m_ClientTunnels.clear ();
if (m_ServerTunnel)
@ -287,8 +288,10 @@ namespace client @@ -287,8 +288,10 @@ namespace client
if (keys[i].length () > 0)
localDestination = LoadLocalDestination (keys[i], false);
auto clientTunnel = new I2PClientTunnel (destinations[i], ports[i], localDestination);
if (m_ClientTunnels.insert (std::make_pair (ports[i], std::unique_ptr<I2PClientTunnel>(clientTunnel))).second)
clientTunnel->Start ();
m_ClientTunnels.push_back (std::unique_ptr<I2PClientTunnel>(clientTunnel));
else
LogPrint (eLogError, "I2P client tunnel with port ", ports[i], " already exists");
}
LogPrint (eLogInfo, numClientTunnels, " I2P client tunnels created");
}

4
ClientContext.h

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
#ifndef CLIENT_CONTEXT_H__
#define CLIENT_CONTEXT_H__
#include <list>
#include <map>
#include <mutex>
#include <memory>
#include "Destination.h"
@ -58,7 +58,7 @@ namespace client @@ -58,7 +58,7 @@ namespace client
i2p::proxy::HTTPProxy * m_HttpProxy;
i2p::proxy::SOCKSProxy * m_SocksProxy;
std::list<std::unique_ptr<I2PClientTunnel> > m_ClientTunnels;
std::map<int, std::unique_ptr<I2PClientTunnel> > m_ClientTunnels; // port->tunnel
I2PServerTunnel * m_ServerTunnel;
SAMBridge * m_SamBridge;
BOBCommandChannel * m_BOBCommandChannel;

Loading…
Cancel
Save