summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian May <bmay@unimelb.edu.au>2011-05-31 14:21:37 +1000
committerAvery Pennarun <apenwarr@gmail.com>2011-05-31 00:39:17 -0400
commitbd489b331974547d1d13f64b2aa5da51dd8a398a (patch)
tree5fa96923e9d1f5e0f8c6b4389d11d940ded446db
parent8ab5ef283df66ef99aa0c826d941e414407bf773 (diff)
Pass socket through to handlers. Required for IPv6 support.
-rw-r--r--client.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/client.py b/client.py
index 449a75a..008f8ba 100644
--- a/client.py
+++ b/client.py
@@ -255,17 +255,17 @@ def _main(listener, fw, ssh_cmd, remotename, python, latency_control,
fw.sethostip(name, ip)
mux.got_host_list = onhostlist
- def onaccept():
+ def onaccept(listener_sock):
global _extra_fd
try:
- sock,srcip = listener.accept()
+ sock,srcip = listener_sock.accept()
except socket.error, e:
if e.args[0] in [errno.EMFILE, errno.ENFILE]:
debug1('Rejected incoming connection: too many open files!\n')
# free up an fd so we can eat the connection
os.close(_extra_fd)
try:
- sock,srcip = listener.accept()
+ sock,srcip = listener_sock.accept()
sock.close()
finally:
_extra_fd = os.open('/dev/null', os.O_RDONLY)
@@ -287,7 +287,7 @@ def _main(listener, fw, ssh_cmd, remotename, python, latency_control,
mux.send(chan, ssnet.CMD_CONNECT, '%s,%s' % dstip)
outwrap = MuxWrapper(mux, chan)
handlers.append(Proxy(SockWrapper(sock, sock), outwrap))
- handlers.append(Handler([listener], onaccept))
+ handlers.append(Handler([listener], lambda: onaccept(listener)))
dnsreqs = {}
def dns_done(chan, data):
@@ -297,8 +297,8 @@ def _main(listener, fw, ssh_cmd, remotename, python, latency_control,
del dnsreqs[chan]
debug3('doing sendto %r\n' % (peer,))
dnslistener.sendto(data, peer)
- def ondns():
- pkt,peer = dnslistener.recvfrom(4096)
+ def ondns(listener_sock):
+ pkt,peer = listener_sock.recvfrom(4096)
now = time.time()
if pkt:
debug1('DNS request from %r: %d bytes\n' % (peer, len(pkt)))
@@ -311,7 +311,7 @@ def _main(listener, fw, ssh_cmd, remotename, python, latency_control,
del dnsreqs[chan]
debug3('Remaining DNS requests: %d\n' % len(dnsreqs))
if dnslistener:
- handlers.append(Handler([dnslistener], ondns))
+ handlers.append(Handler([dnslistener], lambda: ondns(dnslistener)))
if seed_hosts != None:
debug1('seed_hosts: %r\n' % seed_hosts)