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

Method got_packet

sshuttle/ssnet.py:401–446  ·  view source on GitHub ↗
(self, channel, cmd, data)

Source from the content-addressed store, hash-verified

399 self.fullness += len(data)
400
401 def got_packet(self, channel, cmd, data):
402 debug2('< channel=%d cmd=%s len=%d'
403 % (channel, cmd_to_name.get(cmd, hex(cmd)), len(data)))
404 # debug3('<<< data: %r' % data)
405 if cmd == CMD_PING:
406 self.send(0, CMD_PONG, data)
407 elif cmd == CMD_PONG:
408 debug2('received PING response')
409 self.too_full = False
410 self.fullness = 0
411 elif cmd == CMD_EXIT:
412 self.ok = False
413 elif cmd == CMD_TCP_CONNECT:
414 assert not self.channels.get(channel)
415 if self.new_channel:
416 self.new_channel(channel, data)
417 elif cmd == CMD_DNS_REQ:
418 assert not self.channels.get(channel)
419 if self.got_dns_req:
420 self.got_dns_req(channel, data)
421 elif cmd == CMD_UDP_OPEN:
422 assert not self.channels.get(channel)
423 if self.got_udp_open:
424 self.got_udp_open(channel, data)
425 elif cmd == CMD_ROUTES:
426 if self.got_routes:
427 self.got_routes(data)
428 else:
429 raise Exception('got CMD_ROUTES without got_routes?')
430 elif cmd == CMD_HOST_REQ:
431 if self.got_host_req:
432 self.got_host_req(data)
433 else:
434 raise Exception('got CMD_HOST_REQ without got_host_req?')
435 elif cmd == CMD_HOST_LIST:
436 if self.got_host_list:
437 self.got_host_list(data)
438 else:
439 raise Exception('got CMD_HOST_LIST without got_host_list?')
440 else:
441 callback = self.channels.get(channel)
442 if not callback:
443 log('warning: closed channel %d got cmd=%s len=%d'
444 % (channel, cmd_to_name.get(cmd, hex(cmd)), len(data)))
445 else:
446 callback(cmd, data)
447
448 def flush(self):
449 set_non_blocking_io(self.wfile.fileno())

Callers 1

handleMethod · 0.95

Calls 4

sendMethod · 0.95
debug2Function · 0.90
logFunction · 0.90
getMethod · 0.80

Tested by

no test coverage detected