Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
 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)
Ejemplo n.º 3
0
 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
Ejemplo n.º 4
0
    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
Ejemplo n.º 5
0
 def _send(self, data):
     Trace.trace("{} sending {}", self.link.name, data)
     self.transport.write(data)
Ejemplo n.º 6
0
 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)
Ejemplo n.º 7
0
 def _send(self, data):
     Trace.trace("{} sending {}", self.link.name, repr(data))
     self.dispatcher.send(data)