Add I2P support
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#include "params.h"
|
||||
#include "stratum_server.h"
|
||||
#include "p2p_server.h"
|
||||
#include "i2p.h"
|
||||
#include <fstream>
|
||||
|
||||
#ifdef WITH_GRPC
|
||||
@@ -59,6 +60,15 @@ Params::Params(const std::vector<std::vector<std::string>>& args)
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_i2pAddress.empty()) {
|
||||
m_i2pDestinationHash = from_i2p_b32(m_i2pAddress);
|
||||
|
||||
if (m_i2pDestinationHash.empty()) {
|
||||
LOGERR(1, "Failed to parse \"" << m_i2pAddress << '"');
|
||||
throw std::exception();
|
||||
}
|
||||
}
|
||||
|
||||
auto invalid_host = [](const Host& h)
|
||||
{
|
||||
if (!h.valid()) {
|
||||
@@ -180,6 +190,10 @@ Params::Params(const std::vector<std::vector<std::string>>& args)
|
||||
m_socks5ProxyType = ProxyType::TOR;
|
||||
break;
|
||||
|
||||
case 4447:
|
||||
m_socks5ProxyType = ProxyType::I2P;
|
||||
break;
|
||||
|
||||
default:
|
||||
m_socks5ProxyType = ProxyType::PLAIN;
|
||||
break;
|
||||
@@ -460,6 +474,16 @@ bool Params::process_arg(const std::vector<std::string>& arg)
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((arg[0] == "i2p-address") && has1(arg)) {
|
||||
m_i2pAddress = arg[1];
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((arg[0] == "sam-port") && has1(arg)) {
|
||||
m_samPort = static_cast<int32_t>(std::min(std::max(strtoul(arg[1].c_str(), nullptr, 10), 1UL), 65535UL));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (arg[0] == "no-clearnet-p2p") {
|
||||
m_noClearnetP2P = true;
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user