mirror of https://github.com/aria2/aria2
Setup BT UDP SOCKS5 proxy on demand
parent
2806da3298
commit
f2a66a68b3
|
@ -114,7 +114,10 @@ DHTSetup::setup(DownloadEngine* e, int family)
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t port;
|
uint16_t port;
|
||||||
auto connection = make_unique<DHTConnectionSocksProxyImpl>(family);
|
const std::string& proxyUri = e->getOption()->get(PREF_BT_UDP_SOCKS_PROXY);
|
||||||
|
auto connection = proxyUri.empty()
|
||||||
|
? make_unique<DHTConnectionImpl>(family)
|
||||||
|
: make_unique<DHTConnectionSocksProxyImpl>(family);
|
||||||
{
|
{
|
||||||
port = e->getBtRegistry()->getUdpPort();
|
port = e->getBtRegistry()->getUdpPort();
|
||||||
const std::string& addr = e->getOption()->get(
|
const std::string& addr = e->getOption()->get(
|
||||||
|
@ -140,18 +143,18 @@ DHTSetup::setup(DownloadEngine* e, int family)
|
||||||
}
|
}
|
||||||
A2_LOG_DEBUG(fmt("Initialized local node ID=%s",
|
A2_LOG_DEBUG(fmt("Initialized local node ID=%s",
|
||||||
util::toHex(localNode->getID(), DHT_ID_LENGTH).c_str()));
|
util::toHex(localNode->getID(), DHT_ID_LENGTH).c_str()));
|
||||||
{
|
if (!proxyUri.empty()) {
|
||||||
|
auto c = static_cast<DHTConnectionSocksProxyImpl*>(connection.get());
|
||||||
const std::string& user =
|
const std::string& user =
|
||||||
e->getOption()->get(PREF_BT_UDP_SOCKS_PROXY_USER);
|
e->getOption()->get(PREF_BT_UDP_SOCKS_PROXY_USER);
|
||||||
const std::string& passwd =
|
const std::string& passwd =
|
||||||
e->getOption()->get(PREF_BT_UDP_SOCKS_PROXY_PASSWD);
|
e->getOption()->get(PREF_BT_UDP_SOCKS_PROXY_PASSWD);
|
||||||
uri::UriStruct us;
|
uri::UriStruct us;
|
||||||
uri::parse(us, e->getOption()->get(PREF_BT_UDP_SOCKS_PROXY));
|
uri::parse(us, proxyUri);
|
||||||
const std::string& host = us.host;
|
const std::string& host = us.host;
|
||||||
uint16_t port = us.port;
|
uint16_t port = us.port;
|
||||||
if (!connection->startProxy(host, port, user, passwd,
|
if (!c->startProxy(host, port, user, passwd, localNode->getIPAddress(),
|
||||||
localNode->getIPAddress(),
|
localNode->getPort())) {
|
||||||
localNode->getPort())) {
|
|
||||||
throw DL_ABORT_EX("Error occurred while connecting to SOCKS5 relay "
|
throw DL_ABORT_EX("Error occurred while connecting to SOCKS5 relay "
|
||||||
"server for UDP proxy for DHT and UDP trackers");
|
"server for UDP proxy for DHT and UDP trackers");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue