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

Class MuxWrapper

sshuttle/ssnet.py:505–579  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

503
504
505class MuxWrapper(SockWrapper):
506
507 def __init__(self, mux, channel):
508 SockWrapper.__init__(self, mux.rfile, mux.wfile)
509 self.mux = mux
510 self.channel = channel
511 self.mux.channels[channel] = self.got_packet
512 self.socks = []
513 debug2('new channel: %d' % channel)
514
515 def __del__(self):
516 self.nowrite()
517 SockWrapper.__del__(self)
518
519 def __repr__(self):
520 return 'SW%r:Mux#%d' % (self.peername, self.channel)
521
522 def noread(self):
523 if not self.shut_read:
524 self.mux.send(self.channel, CMD_TCP_STOP_SENDING, b(''))
525 self.setnoread()
526
527 def setnoread(self):
528 if not self.shut_read:
529 debug2('%r: done reading' % self)
530 self.shut_read = True
531 self.maybe_close()
532
533 def nowrite(self):
534 if not self.shut_write:
535 self.mux.send(self.channel, CMD_TCP_EOF, b(''))
536 self.setnowrite()
537
538 def setnowrite(self):
539 if not self.shut_write:
540 debug2('%r: done writing' % self)
541 self.shut_write = True
542 self.maybe_close()
543
544 def maybe_close(self):
545 if self.shut_read and self.shut_write:
546 debug2('%r: closing connection' % self)
547 # remove the mux's reference to us. The python garbage collector
548 # will then be able to reap our object.
549 self.mux.channels[self.channel] = None
550
551 def too_full(self):
552 return self.mux.too_full
553
554 def uwrite(self, buf):
555 if self.mux.too_full:
556 return 0 # too much already enqueued
557 if len(buf) > 2048:
558 buf = buf[:2048]
559 self.mux.send(self.channel, CMD_TCP_DATA, buf)
560 return len(buf)
561
562 def uread(self):

Callers 2

onaccept_tcpFunction · 0.90
new_channelFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected