Added a fix to avoid becoming one's own neighbour.
This commit is contained in:
parent
ab554bb3fe
commit
15917bfb32
|
@ -176,6 +176,9 @@ class HelloTLV(TLV):
|
||||||
f"the id {self.source_id}.")
|
f"the id {self.source_id}.")
|
||||||
sender.id = self.source_id
|
sender.id = self.source_id
|
||||||
|
|
||||||
|
if self.source_id == user.id:
|
||||||
|
sender.marked_as_banned = True
|
||||||
|
|
||||||
if not sender.active:
|
if not sender.active:
|
||||||
sender.id = self.source_id # The sender we are given misses an id
|
sender.id = self.source_id # The sender we are given misses an id
|
||||||
time_hl = time.time()
|
time_hl = time.time()
|
||||||
|
|
|
@ -26,6 +26,7 @@ class Peer:
|
||||||
self.symmetric = False
|
self.symmetric = False
|
||||||
self.active = False
|
self.active = False
|
||||||
self.errors = 0
|
self.errors = 0
|
||||||
|
self.marked_as_banned = False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Resolve DNS as an IPv6
|
# 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.
|
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):
|
def __repr__(self):
|
||||||
return self.nickname or str(self.id) or str(self.main_address)
|
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(self.addresses)
|
||||||
self.addresses.update(other.addresses)
|
self.addresses.update(other.addresses)
|
||||||
self.id = self.id if self.id > 0 else other.id
|
self.id = self.id if self.id > 0 else other.id
|
||||||
|
self.marked_as_banned = other.marked_as_banned
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue