fixed SOCKS5 bug for routing UDP packets

This commit is contained in:
Arvid Norberg
2010-07-25 01:31:15 +00:00
parent b0a3b2545b
commit ef48c92a4e
4 changed files with 46 additions and 9 deletions

View File

@@ -774,6 +774,8 @@ int main(int argc, char* argv[])
" -R <num blocks> number of blocks per read cache line\n"
" -O Disallow disk job reordering\n"
" -P <host:port> Use the specified SOCKS5 proxy\n"
" -L <user:passwd> Use the specified username and password for the\n"
" proxy specified by -P\n"
" -H Don't start DHT\n"
" -W <num peers> Set the max number of peers to keep in the peer list\n"
" "
@@ -794,6 +796,8 @@ int main(int argc, char* argv[])
settings.disk_cache_algorithm = session_settings::largest_contiguous;
settings.volatile_read_cache = true;
proxy_settings ps;
int refresh_delay = 1;
bool start_dht = true;
@@ -947,20 +951,28 @@ int main(int argc, char* argv[])
break;
}
*port++ = 0;
proxy_settings ps;
ps.hostname = arg;
ps.port = atoi(port);
if (ps.port == 0) {
fprintf(stderr, "invalid proxy port\n");
break;
}
ps.type = proxy_settings::socks5;
ses.set_peer_proxy(ps);
ses.set_web_seed_proxy(ps);
ses.set_tracker_proxy(ps);
#ifndef TORRENT_DISABLE_DHT
ses.set_dht_proxy(ps);
#endif
if (ps.type == proxy_settings::none)
ps.type = proxy_settings::socks5;
}
break;
case 'L':
{
char* pw = (char*) strchr(arg, ':');
if (pw == 0)
{
fprintf(stderr, "invalid proxy username and password specified\n");
break;
}
*pw++ = 0;
ps.username = arg;
ps.password = pw;
ps.type = proxy_settings::socks5_pw;
}
break;
case 'I': outgoing_interface = arg; break;
@@ -968,6 +980,13 @@ int main(int argc, char* argv[])
++i; // skip the argument
}
ses.set_peer_proxy(ps);
ses.set_web_seed_proxy(ps);
ses.set_tracker_proxy(ps);
#ifndef TORRENT_DISABLE_DHT
ses.set_dht_proxy(ps);
#endif
ses.listen_on(std::make_pair(listen_port, listen_port + 10)
, bind_to_interface.c_str());