From eb0098552ab61a6a81b922ed6318cee23c4c9193 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Tue, 5 Jan 2021 21:50:16 +0100 Subject: [PATCH] Banned clients are not potential clients --- squinnondation/messages.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/squinnondation/messages.py b/squinnondation/messages.py index f8948c9..fad4f57 100644 --- a/squinnondation/messages.py +++ b/squinnondation/messages.py @@ -73,7 +73,7 @@ class Pad1TLV(TLV): return self.type.to_bytes(1, sys.byteorder) def handle(self, squirrel: Any, sender: Any) -> None: - if not sender.active or not sender.id: + if not sender.active or not sender.symmetric or not sender.id: # It doesn't say hello, we don't listen to it squirrel.send_packet(sender, Packet.construct(WarningTLV.construct( "You are not my neighbour, I don't listen to your Pad1TLV. Please say me Hello before."))) @@ -123,7 +123,7 @@ class PadNTLV(TLV): + self.mbz[:self.length] def handle(self, squirrel: Any, sender: Any) -> None: - if not sender.active or not sender.id: + if not sender.active or not sender.symmetric or not sender.id: # It doesn't say hello, we don't listen to it squirrel.send_packet(sender, Packet.construct(WarningTLV.construct( "You are not my neighbour, I don't listen to your PadNTLV. Please say me Hello before."))) @@ -239,7 +239,7 @@ class NeighbourTLV(TLV): self.port.to_bytes(2, sys.byteorder) def handle(self, squirrel: Any, sender: Any) -> None: - if not sender.active or not sender.id: + if not sender.active or not sender.symmetric or not sender.id: # It doesn't say hello, we don't listen to it squirrel.send_packet(sender, Packet.construct(WarningTLV.construct( "You are not my neighbour, I don't listen to your NeighbourTLV. Please say me Hello before."))) @@ -295,7 +295,7 @@ class DataTLV(TLV): """ A message has been sent. We log it. """ - if not sender.active or not sender.id: + if not sender.active or not sender.symmetric or not sender.id: # It doesn't say hello, we don't listen to it squirrel.send_packet(sender, Packet.construct(WarningTLV.construct( "You are not my neighbour, I don't listen to your DataTLV. Please say me Hello before."))) @@ -364,7 +364,7 @@ class AckTLV(TLV): """ When an AckTLV is received, we know that we do not have to inundate that neighbour anymore. """ - if not sender.active or not sender.id: + if not sender.active or not sender.symmetric or not sender.id: # It doesn't say hello, we don't listen to it squirrel.send_packet(sender, Packet.construct(WarningTLV.construct( "You are not my neighbour, I don't listen to your AckTLV. Please say me Hello before."))) @@ -409,7 +409,7 @@ class GoAwayTLV(TLV): self.message.encode("UTF-8")[:self.length - 1] def handle(self, squirrel: Any, sender: Any) -> None: - if not sender.active or not sender.id: + if not sender.active or not sender.symmetric or not sender.id: # It doesn't say hello, we don't listen to it squirrel.send_packet(sender, Packet.construct(WarningTLV.construct( "You are not my neighbour, I don't listen to your GoAwayTLV. Please say me Hello before.")))