Commit 88937e14 authored by Avery Pennarun's avatar Avery Pennarun

client.py: do DNS listener on the same port as the TCP listener.

UDP and TCP have separate port namespaces, so to make it easier to keep
track of what's going on, just use the same transproxy port number for both.
We still need two sockets, but now tcpdumps are easier to understand.
parent 7f3c522c
...@@ -330,8 +330,6 @@ def main(listenip, ssh_cmd, remotename, python, latency_control, dns, ...@@ -330,8 +330,6 @@ def main(listenip, ssh_cmd, remotename, python, latency_control, dns,
return 5 return 5
debug1('Starting sshuttle proxy.\n') debug1('Starting sshuttle proxy.\n')
listener = socket.socket()
listener.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
if listenip[1]: if listenip[1]:
ports = [listenip[1]] ports = [listenip[1]]
else: else:
...@@ -341,8 +339,13 @@ def main(listenip, ssh_cmd, remotename, python, latency_control, dns, ...@@ -341,8 +339,13 @@ def main(listenip, ssh_cmd, remotename, python, latency_control, dns,
debug2('Binding:') debug2('Binding:')
for port in ports: for port in ports:
debug2(' %d' % port) debug2(' %d' % port)
listener = socket.socket()
listener.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
dnslistener = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
dnslistener.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
try: try:
listener.bind((listenip[0], port)) listener.bind((listenip[0], port))
dnslistener.bind((listenip[0], port))
bound = True bound = True
break break
except socket.error, e: except socket.error, e:
...@@ -355,14 +358,14 @@ def main(listenip, ssh_cmd, remotename, python, latency_control, dns, ...@@ -355,14 +358,14 @@ def main(listenip, ssh_cmd, remotename, python, latency_control, dns,
listenip = listener.getsockname() listenip = listener.getsockname()
debug1('Listening on %r.\n' % (listenip,)) debug1('Listening on %r.\n' % (listenip,))
dnsport = 0
dnslistener = None
if dns: if dns:
dnslistener = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
dnslistener.bind((listenip[0], 0))
dnsip = dnslistener.getsockname() dnsip = dnslistener.getsockname()
debug1('DNS listening on %r.\n' % (dnsip,)) debug1('DNS listening on %r.\n' % (dnsip,))
dnsport = dnsip[1] dnsport = dnsip[1]
else:
dnsport = 0
dnslistener = None
dnslistener.bind((listenip[0], 0))
fw = FirewallClient(listenip[1], subnets_include, subnets_exclude, dnsport) fw = FirewallClient(listenip[1], subnets_include, subnets_exclude, dnsport)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment