コード例 #1
0
 def on_service_data(self, peer_id, message):
     """demand to establish connection from peer that failed to
     connect through TCP"""
     if self.peers.assert_id(peer_id):
         try:
             message = Message.create_message(message)
             if message.command != MESSAGE_HELLO:
                 SecurityAlert(peer_id,
                               "unvalid message '%s' from %s"\
                               % (str(message), peer_id))
             else:
                 self.peers.set_peer(peer_id, message)
         except ValueError, err:
             SecurityAlert(peer_id, str(err))
コード例 #2
0
 def wrap_message(self, command, data=None):
     message = Message(command)
     message.ip = self.ip
     message.port = self.port
     message.data = data
     return message