MCPcopy Index your code
hub / github.com/sshuttle/sshuttle / UdpProxy

Class UdpProxy

sshuttle/server.py:256–284  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

254
255
256class UdpProxy(Handler):
257
258 def __init__(self, mux, chan, family):
259 sock = socket.socket(family, socket.SOCK_DGRAM)
260 Handler.__init__(self, [sock])
261 self.timeout = time.time() + 30
262 self.mux = mux
263 self.chan = chan
264 self.sock = sock
265
266 def send(self, dstip, data):
267 debug2('UDP: sending to %r port %d' % dstip)
268 try:
269 self.sock.sendto(data, dstip)
270 except socket.error:
271 _, e = sys.exc_info()[:2]
272 log('UDP send to %r port %d: %s' % (dstip[0], dstip[1], e))
273 return
274
275 def callback(self, sock):
276 try:
277 data, peer = sock.recvfrom(4096)
278 except socket.error:
279 _, e = sys.exc_info()[:2]
280 log('UDP recv from %r port %d: %s' % (peer[0], peer[1], e))
281 return
282 debug2('UDP response: %d bytes' % len(data))
283 hdr = b("%s,%r," % (peer[0], peer[1]))
284 self.mux.send(self.chan, ssnet.CMD_UDP_DATA, hdr + data)
285
286
287def main(latency_control, latency_buffer_size, auto_hosts, to_nameserver,

Callers 1

udp_openFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected