def start_flows(self): with self.rwlock.rlock(): snapshot = self.flows[:] for flow in snapshot: Trace.trace("hub: starting flow {}", flow.name) flow.start() Trace.debug("hub: started flow {}", flow.name)
def handle_read(self): data = self.dispatcher.recv(4096) if not data: self.connection_lost() return Trace.trace("{} received {}", self.link.name, repr(data)) self.on_receive(data)
def stop_flows(self): with self.rwlock.rlock(): snapshot = self.flows[::-1] for flow in snapshot: try: Trace.trace("hub: stopping flow {}", flow.name) flow.stop() Trace.debug("hub: stopped flow {}", flow.name) except: pass
def init_handshake(self): challenge_length = self.key_size_in_bytes + self.block_size_in_bytes challenge = Random.new().read(challenge_length) Trace.trace("challenge: {}", repr(challenge)) n = self.key_size_in_bytes key = challenge[:n] iv = challenge[n:n + self.block_size_in_bytes] self.encryptor = AES.new(key, AES.MODE_CBC, iv) self.encryption_key = key self.encryption_iv = iv encrypted = self._rsa_encrypt(challenge) Trace.trace("encrypted challenge: {}", repr(encrypted)) return encrypted
def _send(self, data): Trace.trace("{} sending {}", self.link.name, data) self.transport.write(data)
def data_received(self, data): if not data: self.connection_lost(self.transport) return Trace.trace("{} received {}", self.link.name, data) self.on_receive(data)
def _send(self, data): Trace.trace("{} sending {}", self.link.name, repr(data)) self.dispatcher.send(data)