diff --git a/squinnondation/messages.py b/squinnondation/messages.py index 4cc6488..5b8c4f8 100644 --- a/squinnondation/messages.py +++ b/squinnondation/messages.py @@ -176,6 +176,9 @@ class HelloTLV(TLV): f"the id {self.source_id}.") sender.id = self.source_id + if self.source_id == user.id: + sender.marked_as_banned = True + if not sender.active: sender.id = self.source_id # The sender we are given misses an id time_hl = time.time() diff --git a/squinnondation/peers.py b/squinnondation/peers.py index 8d37222..584b86f 100644 --- a/squinnondation/peers.py +++ b/squinnondation/peers.py @@ -26,6 +26,7 @@ class Peer: self.symmetric = False self.active = False self.errors = 0 + self.marked_as_banned = False try: # Resolve DNS as an IPv6 @@ -60,7 +61,7 @@ class Peer: """ If a client send more than 5 invalid packets, we don't trust it anymore. """ - return self.errors >= 5 + return self.errors >= 5 or self.marked_as_banned def __repr__(self): return self.nickname or str(self.id) or str(self.main_address) @@ -79,6 +80,7 @@ class Peer: self.addresses.update(self.addresses) self.addresses.update(other.addresses) self.id = self.id if self.id > 0 else other.id + self.marked_as_banned = other.marked_as_banned return self