mirror of
https://github.com/sshuttle/sshuttle.git
synced 2025-04-30 22:24:55 +02:00
Pass socket through to handlers. Required for IPv6 support.
This commit is contained in:
parent
8ab5ef283d
commit
bd489b3319
14
client.py
14
client.py
@ -255,17 +255,17 @@ def _main(listener, fw, ssh_cmd, remotename, python, latency_control,
|
|||||||
fw.sethostip(name, ip)
|
fw.sethostip(name, ip)
|
||||||
mux.got_host_list = onhostlist
|
mux.got_host_list = onhostlist
|
||||||
|
|
||||||
def onaccept():
|
def onaccept(listener_sock):
|
||||||
global _extra_fd
|
global _extra_fd
|
||||||
try:
|
try:
|
||||||
sock,srcip = listener.accept()
|
sock,srcip = listener_sock.accept()
|
||||||
except socket.error, e:
|
except socket.error, e:
|
||||||
if e.args[0] in [errno.EMFILE, errno.ENFILE]:
|
if e.args[0] in [errno.EMFILE, errno.ENFILE]:
|
||||||
debug1('Rejected incoming connection: too many open files!\n')
|
debug1('Rejected incoming connection: too many open files!\n')
|
||||||
# free up an fd so we can eat the connection
|
# free up an fd so we can eat the connection
|
||||||
os.close(_extra_fd)
|
os.close(_extra_fd)
|
||||||
try:
|
try:
|
||||||
sock,srcip = listener.accept()
|
sock,srcip = listener_sock.accept()
|
||||||
sock.close()
|
sock.close()
|
||||||
finally:
|
finally:
|
||||||
_extra_fd = os.open('/dev/null', os.O_RDONLY)
|
_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)
|
mux.send(chan, ssnet.CMD_CONNECT, '%s,%s' % dstip)
|
||||||
outwrap = MuxWrapper(mux, chan)
|
outwrap = MuxWrapper(mux, chan)
|
||||||
handlers.append(Proxy(SockWrapper(sock, sock), outwrap))
|
handlers.append(Proxy(SockWrapper(sock, sock), outwrap))
|
||||||
handlers.append(Handler([listener], onaccept))
|
handlers.append(Handler([listener], lambda: onaccept(listener)))
|
||||||
|
|
||||||
dnsreqs = {}
|
dnsreqs = {}
|
||||||
def dns_done(chan, data):
|
def dns_done(chan, data):
|
||||||
@ -297,8 +297,8 @@ def _main(listener, fw, ssh_cmd, remotename, python, latency_control,
|
|||||||
del dnsreqs[chan]
|
del dnsreqs[chan]
|
||||||
debug3('doing sendto %r\n' % (peer,))
|
debug3('doing sendto %r\n' % (peer,))
|
||||||
dnslistener.sendto(data, peer)
|
dnslistener.sendto(data, peer)
|
||||||
def ondns():
|
def ondns(listener_sock):
|
||||||
pkt,peer = dnslistener.recvfrom(4096)
|
pkt,peer = listener_sock.recvfrom(4096)
|
||||||
now = time.time()
|
now = time.time()
|
||||||
if pkt:
|
if pkt:
|
||||||
debug1('DNS request from %r: %d bytes\n' % (peer, len(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]
|
del dnsreqs[chan]
|
||||||
debug3('Remaining DNS requests: %d\n' % len(dnsreqs))
|
debug3('Remaining DNS requests: %d\n' % len(dnsreqs))
|
||||||
if dnslistener:
|
if dnslistener:
|
||||||
handlers.append(Handler([dnslistener], ondns))
|
handlers.append(Handler([dnslistener], lambda: ondns(dnslistener)))
|
||||||
|
|
||||||
if seed_hosts != None:
|
if seed_hosts != None:
|
||||||
debug1('seed_hosts: %r\n' % seed_hosts)
|
debug1('seed_hosts: %r\n' % seed_hosts)
|
||||||
|
Loading…
Reference in New Issue
Block a user