Skip to content
This repository has been archived by the owner on May 27, 2020. It is now read-only.

Commit

Permalink
Fix UDP bugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
brianmay committed Jul 19, 2011
1 parent 89dcedf commit ca6e4d9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions client.py
Expand Up @@ -96,7 +96,7 @@ def recv_udp(listener, bufsize):
ip = socket.inet_ntop(family, a.cmsg_data[start:start+length])
dstip = (ip, port)
break
return (srcip, dstip, data)
return (srcip, dstip, data[0])
else:
def recv_udp(listener, bufsize):
debug3('Accept UDP using recvfrom.\n')
Expand Down Expand Up @@ -381,7 +381,7 @@ def udp_done(chan, data, method, family, dstip):
srcip = (src,int(srcport))
debug3('doing send from %r to %r\n' % (srcip,dstip,))

sender = socket.socket(sock.family, socket.SOCK_DGRAM)
sender = socket.socket(family, socket.SOCK_DGRAM)
sender.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sender.setsockopt(socket.SOL_IP, IP_TRANSPARENT, 1)
sender.bind(srcip)
Expand All @@ -400,12 +400,12 @@ def onaccept_udp(listener, method, mux, handlers):
chan,timeout = udp_by_src[srcip]
else:
chan = mux.next_channel()
mux.channels[chan] = lambda cmd,data: udp_done(chan, data, method, listener, dstip=srcip)
mux.channels[chan] = lambda cmd,data: udp_done(chan, data, method, listener.family, dstip=srcip)
mux.send(chan, ssnet.CMD_UDP_OPEN, listener.family)
udp_by_src[srcip] = chan,now+30

hdr = "%s,%r,"%(dstip[0], dstip[1])
mux.send(chan, ssnet.CMD_UDP_DATA, hdr+data[0])
mux.send(chan, ssnet.CMD_UDP_DATA, hdr+data)

expire_connections(now, mux)

Expand Down

0 comments on commit ca6e4d9

Please sign in to comment.