A hazelut is either active or potential

This commit is contained in:
Yohann D'ANELLO 2021-01-05 18:25:55 +01:00
parent 95a2501e49
commit 5ffe0d21c3
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
2 changed files with 8 additions and 4 deletions

View File

@ -25,7 +25,6 @@ class Hazelnut:
self.last_long_hello_time = 0
self.symmetric = False
self.active = False
self.potential = False
try:
# Resolve DNS as an IPv6
@ -39,6 +38,14 @@ class Hazelnut:
self.address = address # IPv6Address(address)
self.port = port
@property
def potential(self) -> bool:
return not self.active
@potential.setter
def potential(self, value: bool) -> None:
self.active = not value
class Squirrel(Hazelnut):
"""
@ -648,7 +655,6 @@ class Squirrel(Hazelnut):
pkt = Packet().construct(gatlv)
self.send_packet(hazelnut, pkt)
hazelnut.active = False
hazelnut.potential = True
self.update_hazelnut_table(hazelnut)
self.refresh_lock.release()

View File

@ -171,7 +171,6 @@ class HelloTLV(TLV):
sender.last_hello_time = time_h
sender.last_long_hello_time = time_hl
sender.symmetric = True
sender.potential = False
sender.active = True
squirrel.update_hazelnut_table(sender)
squirrel.nbNS += 1
@ -376,7 +375,6 @@ class GoAwayTLV(TLV):
def handle(self, squirrel: Any, sender: Any) -> None:
if sender.active:
sender.active = False
sender.potential = True
squirrel.update_hazelnut_table(sender)
squirrel.add_system_message("Some told me that he went away : " + self.message)