merged changes from RC_1_0

This commit is contained in:
Arvid Norberg 2015-06-02 01:14:52 +00:00
parent 3409c782f8
commit 5d6cba438d
4 changed files with 25 additions and 16 deletions

View File

@ -139,6 +139,11 @@ namespace libtorrent
struct queued_packet
{
queued_packet()
: hostname(NULL)
, flags(0)
{}
udp::endpoint ep;
char* hostname;
buffer buf;

View File

@ -188,7 +188,7 @@ void udp_socket::send(udp::endpoint const& ep, char const* p, int len
{
// send udp packets through SOCKS5 server
wrap(ep, p, len, ec);
return;
return;
}
if (m_queue_packets)
@ -556,13 +556,11 @@ void udp_socket::wrap(char const* hostname, int port, char const* p, int len, er
iovec[1] = asio::const_buffer(p, len);
#if TORRENT_USE_IPV6
if (m_udp_proxy_addr.address().is_v4() && m_ipv4_sock.is_open())
if (m_udp_proxy_addr.address().is_v6() && m_ipv6_sock.is_open())
m_ipv6_sock.send_to(iovec, m_udp_proxy_addr, 0, ec);
else
#endif
m_ipv4_sock.send_to(iovec, m_udp_proxy_addr, 0, ec);
#if TORRENT_USE_IPV6
else
m_ipv6_sock.send_to(iovec, m_udp_proxy_addr, 0, ec);
#endif
}
// unwrap the UDP packet from the SOCKS5 header
@ -767,7 +765,7 @@ void udp_socket::set_proxy_settings(proxy_settings const& ps)
error_code ec;
m_socks5_sock.close(ec);
m_tunnel_packets = false;
m_proxy_settings = ps;
if (m_abort) return;
@ -1269,7 +1267,7 @@ void udp_socket::connect2(error_code const& e)
drain_queue();
return;
}
m_tunnel_packets = true;
drain_queue();

View File

@ -10,10 +10,10 @@ import threading
import sys
def debug(s):
print >>sys.stderr, 'socks.py: ', s
print >>sys.stderr, 'socks.py: ', s
def error(s):
print >>sys.stderr, 'socks.py, ERROR: ', s
print >>sys.stderr, 'socks.py, ERROR: ', s
class MyTCPServer(ThreadingTCPServer):
allow_reuse_address = True
@ -27,6 +27,7 @@ VERSION = '\x05'
NOAUTH = '\x00'
USERPASS = '\x02'
CONNECT = '\x01'
UDP_ASSOCIATE = '\x03'
IPV4 = '\x01'
IPV6 = '\x04'
DOMAIN_NAME = '\x03'
@ -90,8 +91,8 @@ class SocksHandler(StreamRequestHandler):
if allow_v4 and version == '\x04':
cmd = self.read(1)
if cmd != CONNECT:
error('Only supports connect method not (%r) closing' % cmd)
if cmd != CONNECT and cmd != UDP_ASSOCIATE:
error('Only supports connect and udp-associate method not (%r) closing' % cmd)
self.close_request()
return
@ -160,8 +161,8 @@ class SocksHandler(StreamRequestHandler):
if version != '\x05':
error('Wrong version number (%r) closing...' % version)
self.close_request()
elif cmd != CONNECT:
error('Only supports connect method not (%r) closing' % cmd)
elif cmd != CONNECT and cmd != UDP_ASSOCIATE:
error('Only supports connect and udp-associate method not (%r) closing' % cmd)
self.close_request()
elif zero != '\x00':
error('Mangled request. Reserved field (%r) is not null' % zero)
@ -193,6 +194,11 @@ class SocksHandler(StreamRequestHandler):
except Exception, e:
print e
return
if cmd == UDP_ASSOCIATE:
debug("no UDP support yet, closing")
return;
debug("Creating forwarder connection to %s:%d" % (out_address[0], out_address[1]))
try:

View File

@ -142,7 +142,7 @@ void test_transfer(int proxy_type, settings_pack const& sett
fprintf(stderr, "\n\n ==== TESTING %s proxy ==== disk-full: %s\n\n\n"
, test_name[proxy_type], test_disk_full ? "true": "false");
// in case the previous run was terminated
error_code ec;
remove_all("tmp1_transfer", ec);
@ -381,7 +381,7 @@ TORRENT_TEST(transfer)
fprintf(stderr, "compact mode\n");
test_transfer(0, p, false, storage_mode_compact);
#endif
error_code ec;
remove_all("tmp1_transfer", ec);
remove_all("tmp2_transfer", ec);