diff --git a/squinnondation/hazel.py b/squinnondation/hazel.py index 8ebec48..d11aeea 100644 --- a/squinnondation/hazel.py +++ b/squinnondation/hazel.py @@ -709,7 +709,6 @@ class Worm(Thread): while True: try: pkt, hazelnut = self.squirrel.receive_packet() - pkt.validate_data() except ValueError as error: self.squirrel.add_system_message("An error occurred while receiving a packet: {}".format(error)) else: diff --git a/squinnondation/messages.py b/squinnondation/messages.py index 2cf0fb4..55b43c0 100644 --- a/squinnondation/messages.py +++ b/squinnondation/messages.py @@ -75,7 +75,7 @@ class Pad1TLV(TLV): def handle(self, squirrel: Any, sender: Any) -> None: # TODO Add some easter eggs - squirrel.add_system_message("For each byte in the packet that I received, you will die today. And eat cookies.") + squirrel.add_system_message("I received a Pad1TLV, how disapointing.") def __len__(self) -> int: """ @@ -120,7 +120,7 @@ class PadNTLV(TLV): def handle(self, squirrel: Any, sender: Any) -> None: # TODO Add some easter eggs - squirrel.add_system_message(f"I received {self.length} zeros, am I so a bad guy ? :cold_sweat:") + squirrel.add_system_message(f"I received {self.length} zeros.") @staticmethod def construct(length: int) -> "PadNTLV": @@ -173,7 +173,7 @@ class HelloTLV(TLV): # Add entry to/actualize the active hazelnuts dictionnary squirrel.activehazelnuts[(sender.address, sender.port)] = [sender, time_h, time_hl, True] squirrel.nbNS += 1 - # squirrel.add_system_message(f"Aaaawwww, {self.source_id} spoke to me and said me Hello " + # squirrel.add_system_message(f"Aaaawwww, {self.source_id} spoke to me and said Hello " # + ("long" if self.is_long else "short")) @property @@ -219,6 +219,9 @@ class NeighbourTLV(TLV): self.port.to_bytes(2, sys.byteorder) def handle(self, squirrel: Any, sender: Any) -> None: + if squirrel.address == str(self.ip_address) and squirrel.port == self.port : + #This case should never happen (and in our protocol it is not possible), but we include this test as a security measure. + return if not (str(self.ip_address), self.port) in squirrel.activehazelnuts \ and not (str(self.ip_address), self.port) in squirrel.potentialhazelnuts: squirrel.potentialhazelnuts[(str(self.ip_address), self.port)] = \ @@ -271,7 +274,7 @@ class DataTLV(TLV): squirrel.send_packet(sender, Packet.construct(AckTLV.construct(self.sender_id, self.nonce))) if not squirrel.receive_message_from(self, msg, self.sender_id, self.nonce, sender): - # The message was already received, do not print it + # The message was already received, do not print it on screen squirrel.add_system_message(f"I was inundated a message which I already knew {self.sender_id, self.nonce}") return