mirror of
https://github.com/sshuttle/sshuttle.git
synced 2024-11-26 01:43:29 +01:00
Send DNS request back on same sock we received it on.
This commit is contained in:
parent
bd489b3319
commit
4bfcd7091d
@ -291,22 +291,22 @@ def _main(listener, fw, ssh_cmd, remotename, python, latency_control,
|
|||||||
|
|
||||||
dnsreqs = {}
|
dnsreqs = {}
|
||||||
def dns_done(chan, data):
|
def dns_done(chan, data):
|
||||||
peer,timeout = dnsreqs.get(chan) or (None,None)
|
peer,sock,timeout = dnsreqs.get(chan) or (None,None,None)
|
||||||
debug3('dns_done: channel=%r peer=%r\n' % (chan, peer))
|
debug3('dns_done: channel=%r peer=%r\n' % (chan, peer))
|
||||||
if peer:
|
if peer:
|
||||||
del dnsreqs[chan]
|
del dnsreqs[chan]
|
||||||
debug3('doing sendto %r\n' % (peer,))
|
debug3('doing sendto %r\n' % (peer,))
|
||||||
dnslistener.sendto(data, peer)
|
sock.sendto(data, peer)
|
||||||
def ondns(listener_sock):
|
def ondns(listener_sock):
|
||||||
pkt,peer = listener_sock.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)))
|
||||||
chan = mux.next_channel()
|
chan = mux.next_channel()
|
||||||
dnsreqs[chan] = peer,now+30
|
dnsreqs[chan] = peer,listener_sock,now+30
|
||||||
mux.send(chan, ssnet.CMD_DNS_REQ, pkt)
|
mux.send(chan, ssnet.CMD_DNS_REQ, pkt)
|
||||||
mux.channels[chan] = lambda cmd,data: dns_done(chan,data)
|
mux.channels[chan] = lambda cmd,data: dns_done(chan,data)
|
||||||
for chan,(peer,timeout) in dnsreqs.items():
|
for chan,(peer,sock,timeout) in dnsreqs.items():
|
||||||
if timeout < now:
|
if timeout < now:
|
||||||
del dnsreqs[chan]
|
del dnsreqs[chan]
|
||||||
debug3('Remaining DNS requests: %d\n' % len(dnsreqs))
|
debug3('Remaining DNS requests: %d\n' % len(dnsreqs))
|
||||||
|
Loading…
Reference in New Issue
Block a user