|
|
@ -42,10 +42,18 @@ namespace client |
|
|
|
std::string proxyKeys = i2p::util::config::GetArg("-proxykeys", ""); |
|
|
|
std::string proxyKeys = i2p::util::config::GetArg("-proxykeys", ""); |
|
|
|
if (proxyKeys.length () > 0) |
|
|
|
if (proxyKeys.length () > 0) |
|
|
|
localDestination = LoadLocalDestination (proxyKeys, false); |
|
|
|
localDestination = LoadLocalDestination (proxyKeys, false); |
|
|
|
m_HttpProxy = new i2p::proxy::HTTPProxy(i2p::util::config::GetArg("-httpproxyport", 4446), localDestination); |
|
|
|
m_HttpProxy = new i2p::proxy::HTTPProxy( |
|
|
|
|
|
|
|
i2p::util::config::GetArg("-httpproxyaddress", "127.0.0.1"), |
|
|
|
|
|
|
|
i2p::util::config::GetArg("-httpproxyport", 4446), |
|
|
|
|
|
|
|
localDestination |
|
|
|
|
|
|
|
); |
|
|
|
m_HttpProxy->Start(); |
|
|
|
m_HttpProxy->Start(); |
|
|
|
LogPrint("HTTP Proxy started"); |
|
|
|
LogPrint("HTTP Proxy started"); |
|
|
|
m_SocksProxy = new i2p::proxy::SOCKSProxy(i2p::util::config::GetArg("-socksproxyport", 4447), localDestination); |
|
|
|
m_SocksProxy = new i2p::proxy::SOCKSProxy( |
|
|
|
|
|
|
|
i2p::util::config::GetArg("-socksproxyaddress", "127.0.0.1"), |
|
|
|
|
|
|
|
i2p::util::config::GetArg("-socksproxyport", 4447), |
|
|
|
|
|
|
|
localDestination |
|
|
|
|
|
|
|
); |
|
|
|
m_SocksProxy->Start(); |
|
|
|
m_SocksProxy->Start(); |
|
|
|
LogPrint("SOCKS Proxy Started"); |
|
|
|
LogPrint("SOCKS Proxy Started"); |
|
|
|
|
|
|
|
|
|
|
@ -58,9 +66,15 @@ namespace client |
|
|
|
if (ircKeys.length () > 0) |
|
|
|
if (ircKeys.length () > 0) |
|
|
|
localDestination = LoadLocalDestination (ircKeys, false); |
|
|
|
localDestination = LoadLocalDestination (ircKeys, false); |
|
|
|
auto ircPort = i2p::util::config::GetArg("-ircport", 6668); |
|
|
|
auto ircPort = i2p::util::config::GetArg("-ircport", 6668); |
|
|
|
auto ircTunnel = new I2PClientTunnel (ircDestination, ircPort, localDestination); |
|
|
|
auto ircTunnel = new I2PClientTunnel( |
|
|
|
|
|
|
|
ircDestination, i2p::util::config::GetArg("-ircaddress", "127.0.0.1"), |
|
|
|
|
|
|
|
ircPort, localDestination |
|
|
|
|
|
|
|
); |
|
|
|
ircTunnel->Start (); |
|
|
|
ircTunnel->Start (); |
|
|
|
m_ClientTunnels.insert (std::make_pair(ircPort, std::unique_ptr<I2PClientTunnel>(ircTunnel))); |
|
|
|
// TODO: allow muliple tunnels on the same port (but on a different address)
|
|
|
|
|
|
|
|
m_ClientTunnels.insert(std::make_pair( |
|
|
|
|
|
|
|
ircPort, std::unique_ptr<I2PClientTunnel>(ircTunnel) |
|
|
|
|
|
|
|
)); |
|
|
|
LogPrint("IRC tunnel started"); |
|
|
|
LogPrint("IRC tunnel started"); |
|
|
|
} |
|
|
|
} |
|
|
|
std::string eepKeys = i2p::util::config::GetArg("-eepkeys", ""); |
|
|
|
std::string eepKeys = i2p::util::config::GetArg("-eepkeys", ""); |
|
|
@ -79,7 +93,9 @@ namespace client |
|
|
|
int samPort = i2p::util::config::GetArg("-samport", 0); |
|
|
|
int samPort = i2p::util::config::GetArg("-samport", 0); |
|
|
|
if (samPort) |
|
|
|
if (samPort) |
|
|
|
{ |
|
|
|
{ |
|
|
|
m_SamBridge = new SAMBridge (samPort); |
|
|
|
m_SamBridge = new SAMBridge( |
|
|
|
|
|
|
|
i2p::util::config::GetArg("-samaddress", "127.0.0.1"), samPort |
|
|
|
|
|
|
|
); |
|
|
|
m_SamBridge->Start (); |
|
|
|
m_SamBridge->Start (); |
|
|
|
LogPrint("SAM bridge started"); |
|
|
|
LogPrint("SAM bridge started"); |
|
|
|
} |
|
|
|
} |
|
|
@ -88,17 +104,21 @@ namespace client |
|
|
|
int bobPort = i2p::util::config::GetArg("-bobport", 0); |
|
|
|
int bobPort = i2p::util::config::GetArg("-bobport", 0); |
|
|
|
if (bobPort) |
|
|
|
if (bobPort) |
|
|
|
{ |
|
|
|
{ |
|
|
|
m_BOBCommandChannel = new BOBCommandChannel (bobPort); |
|
|
|
m_BOBCommandChannel = new BOBCommandChannel( |
|
|
|
|
|
|
|
i2p::util::config::GetArg("-bobaddress", "127.0.0.1"), bobPort |
|
|
|
|
|
|
|
); |
|
|
|
m_BOBCommandChannel->Start (); |
|
|
|
m_BOBCommandChannel->Start (); |
|
|
|
LogPrint("BOB command channel started"); |
|
|
|
LogPrint("BOB command channel started"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// I2P Control
|
|
|
|
// I2P Control
|
|
|
|
int i2pcontrolPort = i2p::util::config::GetArg("-i2pcontrolport", 0); |
|
|
|
int i2pcontrolPort = i2p::util::config::GetArg("-i2pcontrolport", 0); |
|
|
|
if (i2pcontrolPort) |
|
|
|
if(i2pcontrolPort) { |
|
|
|
{ |
|
|
|
m_I2PControlService = new I2PControlService( |
|
|
|
m_I2PControlService = new I2PControlService (i2pcontrolPort); |
|
|
|
i2p::util::config::GetArg("-i2pcontroladdress", "127.0.0.1"), |
|
|
|
m_I2PControlService->Start (); |
|
|
|
i2pcontrolPort |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
m_I2PControlService->Start(); |
|
|
|
LogPrint("I2PControl started"); |
|
|
|
LogPrint("I2PControl started"); |
|
|
|
} |
|
|
|
} |
|
|
|
m_AddressBook.Start (); |
|
|
|
m_AddressBook.Start (); |
|
|
@ -259,43 +279,46 @@ namespace client |
|
|
|
void ClientContext::ReadTunnels () |
|
|
|
void ClientContext::ReadTunnels () |
|
|
|
{ |
|
|
|
{ |
|
|
|
boost::property_tree::ptree pt; |
|
|
|
boost::property_tree::ptree pt; |
|
|
|
try |
|
|
|
try { |
|
|
|
{ |
|
|
|
boost::property_tree::read_ini( |
|
|
|
boost::property_tree::read_ini (i2p::util::filesystem::GetFullPath (TUNNELS_CONFIG_FILENAME), pt); |
|
|
|
i2p::util::filesystem::GetFullPath(TUNNELS_CONFIG_FILENAME), |
|
|
|
} |
|
|
|
pt |
|
|
|
catch (std::exception& ex) |
|
|
|
); |
|
|
|
{ |
|
|
|
} catch(const std::exception& ex) { |
|
|
|
LogPrint (eLogWarning, "Can't read ", TUNNELS_CONFIG_FILENAME, ": ", ex.what ()); |
|
|
|
LogPrint(eLogWarning, "Can't read ", TUNNELS_CONFIG_FILENAME, ": ", ex.what ()); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int numClientTunnels = 0, numServerTunnels = 0; |
|
|
|
int numClientTunnels = 0, numServerTunnels = 0; |
|
|
|
for (auto& section: pt) |
|
|
|
for(auto& section: pt) { |
|
|
|
{ |
|
|
|
|
|
|
|
std::string name = section.first; |
|
|
|
std::string name = section.first; |
|
|
|
try |
|
|
|
try { |
|
|
|
{ |
|
|
|
|
|
|
|
std::string type = section.second.get<std::string> (I2P_TUNNELS_SECTION_TYPE); |
|
|
|
std::string type = section.second.get<std::string> (I2P_TUNNELS_SECTION_TYPE); |
|
|
|
if (type == I2P_TUNNELS_SECTION_TYPE_CLIENT) |
|
|
|
if(type == I2P_TUNNELS_SECTION_TYPE_CLIENT) { |
|
|
|
{ |
|
|
|
|
|
|
|
// mandatory params
|
|
|
|
// mandatory params
|
|
|
|
std::string dest = section.second.get<std::string> (I2P_CLIENT_TUNNEL_DESTINATION); |
|
|
|
std::string dest = section.second.get<std::string> (I2P_CLIENT_TUNNEL_DESTINATION); |
|
|
|
int port = section.second.get<int> (I2P_CLIENT_TUNNEL_PORT); |
|
|
|
int port = section.second.get<int> (I2P_CLIENT_TUNNEL_PORT); |
|
|
|
// optional params
|
|
|
|
// optional params
|
|
|
|
std::string keys = section.second.get (I2P_CLIENT_TUNNEL_KEYS, ""); |
|
|
|
std::string address = section.second.get( |
|
|
|
int destinationPort = section.second.get (I2P_CLIENT_TUNNEL_DESTINATION_PORT, 0); |
|
|
|
I2P_CLIENT_TUNNEL_ADDRESS, "127.0.0.1" |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
std::string keys = section.second.get(I2P_CLIENT_TUNNEL_KEYS, ""); |
|
|
|
|
|
|
|
int destinationPort = section.second.get(I2P_CLIENT_TUNNEL_DESTINATION_PORT, 0); |
|
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<ClientDestination> localDestination = nullptr; |
|
|
|
std::shared_ptr<ClientDestination> localDestination = nullptr; |
|
|
|
if (keys.length () > 0) |
|
|
|
if(keys.length () > 0) |
|
|
|
localDestination = LoadLocalDestination (keys, false); |
|
|
|
localDestination = LoadLocalDestination (keys, false); |
|
|
|
auto clientTunnel = new I2PClientTunnel (dest, port, localDestination, destinationPort); |
|
|
|
|
|
|
|
if (m_ClientTunnels.insert (std::make_pair (port, std::unique_ptr<I2PClientTunnel>(clientTunnel))).second) |
|
|
|
auto clientTunnel = new I2PClientTunnel( |
|
|
|
|
|
|
|
dest, address, port, localDestination, destinationPort |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
// TODO: allow muliple tunnels on the same port (but on a different address)
|
|
|
|
|
|
|
|
if(m_ClientTunnels.insert(std::make_pair(port, std::unique_ptr<I2PClientTunnel>(clientTunnel))).second) |
|
|
|
clientTunnel->Start (); |
|
|
|
clientTunnel->Start (); |
|
|
|
else |
|
|
|
else |
|
|
|
LogPrint (eLogError, "I2P client tunnel with port ", port, " already exists"); |
|
|
|
LogPrint (eLogError, "I2P client tunnel with port ", port, " already exists"); |
|
|
|
numClientTunnels++; |
|
|
|
numClientTunnels++; |
|
|
|
} |
|
|
|
} else if(type == I2P_TUNNELS_SECTION_TYPE_SERVER || type == I2P_TUNNELS_SECTION_TYPE_HTTP) |
|
|
|
else if (type == I2P_TUNNELS_SECTION_TYPE_SERVER || type == I2P_TUNNELS_SECTION_TYPE_HTTP) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
// mandatory params
|
|
|
|
// mandatory params
|
|
|
|
std::string host = section.second.get<std::string> (I2P_SERVER_TUNNEL_HOST); |
|
|
|
std::string host = section.second.get<std::string> (I2P_SERVER_TUNNEL_HOST); |
|
|
@ -307,19 +330,16 @@ namespace client |
|
|
|
|
|
|
|
|
|
|
|
auto localDestination = LoadLocalDestination (keys, true); |
|
|
|
auto localDestination = LoadLocalDestination (keys, true); |
|
|
|
I2PServerTunnel * serverTunnel = (type == I2P_TUNNELS_SECTION_TYPE_HTTP) ? new I2PServerTunnelHTTP (host, port, localDestination, inPort) : new I2PServerTunnel (host, port, localDestination, inPort); |
|
|
|
I2PServerTunnel * serverTunnel = (type == I2P_TUNNELS_SECTION_TYPE_HTTP) ? new I2PServerTunnelHTTP (host, port, localDestination, inPort) : new I2PServerTunnel (host, port, localDestination, inPort); |
|
|
|
if (accessList.length () > 0) |
|
|
|
if (accessList.length () > 0) { |
|
|
|
{ |
|
|
|
|
|
|
|
std::set<i2p::data::IdentHash> idents; |
|
|
|
std::set<i2p::data::IdentHash> idents; |
|
|
|
size_t pos = 0, comma; |
|
|
|
size_t pos = 0, comma; |
|
|
|
do |
|
|
|
do { |
|
|
|
{ |
|
|
|
|
|
|
|
comma = accessList.find (',', pos); |
|
|
|
comma = accessList.find (',', pos); |
|
|
|
i2p::data::IdentHash ident; |
|
|
|
i2p::data::IdentHash ident; |
|
|
|
ident.FromBase32 (accessList.substr (pos, comma != std::string::npos ? comma - pos : std::string::npos)); |
|
|
|
ident.FromBase32 (accessList.substr (pos, comma != std::string::npos ? comma - pos : std::string::npos)); |
|
|
|
idents.insert (ident); |
|
|
|
idents.insert (ident); |
|
|
|
pos = comma + 1; |
|
|
|
pos = comma + 1; |
|
|
|
} |
|
|
|
} while (comma != std::string::npos); |
|
|
|
while (comma != std::string::npos); |
|
|
|
|
|
|
|
serverTunnel->SetAccessList (idents); |
|
|
|
serverTunnel->SetAccessList (idents); |
|
|
|
} |
|
|
|
} |
|
|
|
if (m_ServerTunnels.insert (std::make_pair (localDestination->GetIdentHash (), std::unique_ptr<I2PServerTunnel>(serverTunnel))).second) |
|
|
|
if (m_ServerTunnels.insert (std::make_pair (localDestination->GetIdentHash (), std::unique_ptr<I2PServerTunnel>(serverTunnel))).second) |
|
|
@ -327,13 +347,10 @@ namespace client |
|
|
|
else |
|
|
|
else |
|
|
|
LogPrint (eLogError, "I2P server tunnel for destination ", m_AddressBook.ToAddress(localDestination->GetIdentHash ()), " already exists"); |
|
|
|
LogPrint (eLogError, "I2P server tunnel for destination ", m_AddressBook.ToAddress(localDestination->GetIdentHash ()), " already exists"); |
|
|
|
numServerTunnels++; |
|
|
|
numServerTunnels++; |
|
|
|
} |
|
|
|
} else |
|
|
|
else |
|
|
|
|
|
|
|
LogPrint (eLogWarning, "Unknown section type=", type, " of ", name, " in ", TUNNELS_CONFIG_FILENAME); |
|
|
|
LogPrint (eLogWarning, "Unknown section type=", type, " of ", name, " in ", TUNNELS_CONFIG_FILENAME); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} catch (const std::exception& ex) { |
|
|
|
catch (std::exception& ex) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
LogPrint (eLogError, "Can't read tunnel ", name, " params: ", ex.what ()); |
|
|
|
LogPrint (eLogError, "Can't read tunnel ", name, " params: ", ex.what ()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|