MCPcopy Create free account
hub / github.com/apenwarr/sshuttle / got_packet

Method got_packet

ssnet.py:366–406  ·  view source on GitHub ↗
(self, channel, cmd, data)

Source from the content-addressed store, hash-verified

364 self.fullness += len(data)
365
366 def got_packet(self, channel, cmd, data):
367 debug2('< channel=%d cmd=%s len=%d\n'
368 % (channel, cmd_to_name.get(cmd,hex(cmd)), len(data)))
369 if cmd == CMD_PING:
370 self.send(0, CMD_PONG, data)
371 elif cmd == CMD_PONG:
372 debug2('received PING response\n')
373 self.too_full = False
374 self.fullness = 0
375 elif cmd == CMD_EXIT:
376 self.ok = False
377 elif cmd == CMD_CONNECT:
378 assert(not self.channels.get(channel))
379 if self.new_channel:
380 self.new_channel(channel, data)
381 elif cmd == CMD_DNS_REQ:
382 assert(not self.channels.get(channel))
383 if self.got_dns_req:
384 self.got_dns_req(channel, data)
385 elif cmd == CMD_ROUTES:
386 if self.got_routes:
387 self.got_routes(data)
388 else:
389 raise Exception('got CMD_ROUTES without got_routes?')
390 elif cmd == CMD_HOST_REQ:
391 if self.got_host_req:
392 self.got_host_req(data)
393 else:
394 raise Exception('got CMD_HOST_REQ without got_host_req?')
395 elif cmd == CMD_HOST_LIST:
396 if self.got_host_list:
397 self.got_host_list(data)
398 else:
399 raise Exception('got CMD_HOST_LIST without got_host_list?')
400 else:
401 callback = self.channels.get(channel)
402 if not callback:
403 log('warning: closed channel %d got cmd=%s len=%d\n'
404 % (channel, cmd_to_name.get(cmd,hex(cmd)), len(data)))
405 else:
406 callback(cmd, data)
407
408 def flush(self):
409 self.wsock.setblocking(False)

Callers 1

handleMethod · 0.95

Calls 3

sendMethod · 0.95
debug2Function · 0.85
logFunction · 0.85

Tested by

no test coverage detected