From 5ffe0d21c365a1feccedbe526e8fb7863d81d6de Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Tue, 5 Jan 2021 18:25:55 +0100 Subject: [PATCH] A hazelut is either active or potential --- squinnondation/hazel.py | 10 ++++++++-- squinnondation/messages.py | 2 -- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/squinnondation/hazel.py b/squinnondation/hazel.py index a09f1c0..06f4ad8 100644 --- a/squinnondation/hazel.py +++ b/squinnondation/hazel.py @@ -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() diff --git a/squinnondation/messages.py b/squinnondation/messages.py index faaa7ad..2b94af8 100644 --- a/squinnondation/messages.py +++ b/squinnondation/messages.py @@ -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)