Skip to content

Commit

Permalink
Send DNS request back on same sock we received it on.
Browse files Browse the repository at this point in the history
  • Loading branch information
brianmay authored and apenwarr committed May 31, 2011
1 parent bd489b3 commit 4bfcd70
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions client.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,22 +291,22 @@ def onaccept(listener_sock):

dnsreqs = {}
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))
if peer:
del dnsreqs[chan]
debug3('doing sendto %r\n' % (peer,))
dnslistener.sendto(data, peer)
sock.sendto(data, peer)
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)))
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.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:
del dnsreqs[chan]
debug3('Remaining DNS requests: %d\n' % len(dnsreqs))
Expand Down

0 comments on commit 4bfcd70

Please sign in to comment.