def decodePacket(self, addr, data): sessionKey=self.makeSession(addr, False) # Don't introduce yourself when you receive a packet from an unknown host, that's not the protocol if sessionKey: # Must be a data packet packet=DataPacket() packet.decodeDataPacket(sessionKey, data) if packet.checkMac() and packet.checkTimestamp(): return packet else: print('Integrity failed', packet.checkMac(), packet.checkTimestamp()) return None else: # Must be an intro packet print('Unknown address', addr) if self.introducer: intro=self.introducer.acceptIntroduction(data, addr) if intro: return intro else: return None
def decodePacket(self, addr, data): sessionKey = self.makeSession( addr, False ) # Don't introduce yourself when you receive a packet from an unknown host, that's not the protocol if sessionKey: # Must be a data packet packet = DataPacket() packet.decodeDataPacket(sessionKey, data) if packet.checkMac() and packet.checkTimestamp(): return packet else: print('Integrity failed', packet.checkMac(), packet.checkTimestamp()) return None else: # Must be an intro packet print('Unknown address', addr) if self.introducer: intro = self.introducer.acceptIntroduction(data, addr) if intro: return intro else: return None