A hazelut is either active or potential
This commit is contained in:
parent
95a2501e49
commit
5ffe0d21c3
|
@ -25,7 +25,6 @@ class Hazelnut:
|
||||||
self.last_long_hello_time = 0
|
self.last_long_hello_time = 0
|
||||||
self.symmetric = False
|
self.symmetric = False
|
||||||
self.active = False
|
self.active = False
|
||||||
self.potential = False
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Resolve DNS as an IPv6
|
# Resolve DNS as an IPv6
|
||||||
|
@ -39,6 +38,14 @@ class Hazelnut:
|
||||||
self.address = address # IPv6Address(address)
|
self.address = address # IPv6Address(address)
|
||||||
self.port = port
|
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):
|
class Squirrel(Hazelnut):
|
||||||
"""
|
"""
|
||||||
|
@ -648,7 +655,6 @@ class Squirrel(Hazelnut):
|
||||||
pkt = Packet().construct(gatlv)
|
pkt = Packet().construct(gatlv)
|
||||||
self.send_packet(hazelnut, pkt)
|
self.send_packet(hazelnut, pkt)
|
||||||
hazelnut.active = False
|
hazelnut.active = False
|
||||||
hazelnut.potential = True
|
|
||||||
self.update_hazelnut_table(hazelnut)
|
self.update_hazelnut_table(hazelnut)
|
||||||
|
|
||||||
self.refresh_lock.release()
|
self.refresh_lock.release()
|
||||||
|
|
|
@ -171,7 +171,6 @@ class HelloTLV(TLV):
|
||||||
sender.last_hello_time = time_h
|
sender.last_hello_time = time_h
|
||||||
sender.last_long_hello_time = time_hl
|
sender.last_long_hello_time = time_hl
|
||||||
sender.symmetric = True
|
sender.symmetric = True
|
||||||
sender.potential = False
|
|
||||||
sender.active = True
|
sender.active = True
|
||||||
squirrel.update_hazelnut_table(sender)
|
squirrel.update_hazelnut_table(sender)
|
||||||
squirrel.nbNS += 1
|
squirrel.nbNS += 1
|
||||||
|
@ -376,7 +375,6 @@ class GoAwayTLV(TLV):
|
||||||
def handle(self, squirrel: Any, sender: Any) -> None:
|
def handle(self, squirrel: Any, sender: Any) -> None:
|
||||||
if sender.active:
|
if sender.active:
|
||||||
sender.active = False
|
sender.active = False
|
||||||
sender.potential = True
|
|
||||||
squirrel.update_hazelnut_table(sender)
|
squirrel.update_hazelnut_table(sender)
|
||||||
squirrel.add_system_message("Some told me that he went away : " + self.message)
|
squirrel.add_system_message("Some told me that he went away : " + self.message)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue