Implemented the fourth phase of neighbour management (the type of addresses sometimes changes in the cide, this should be addressed, there also remains a lot of debugging printing)

This commit is contained in:
eichhornchen
2020-12-28 11:48:44 +01:00
parent b7a495eb11
commit c4e03ed427
2 changed files with 20 additions and 10 deletions

View File

@ -158,9 +158,9 @@ class HelloTLV(TLV):
def handle(self, squirrel: Any, sender: Any) -> None:
timeH = time.time()
timeHL = None
if not squirrel.is_active(sender) :
sender.id = self.source_id #The sender we are given misses an id
timeHL = time.time()
else :
timeHL = squirrel.activehazelnuts[(str(sender.address), sender.port)]
if self.is_long and self.dest_id == squirrel.id :
@ -211,12 +211,12 @@ class NeighbourTLV(TLV):
self.port.to_bytes(2, sys.byteorder)
def handle(self, squirrel: Any, sender: Any) -> None:
if not (ip_address,port) in squirrel.activehazelnuts and not (ip_address,port) in squirrel.potentialhazelnuts:
squirrel.potentialhazelnuts[(ip_address, port)] = squirrel.new_hazel(ip_address, port)
if not (str(self.ip_address),self.port) in squirrel.activehazelnuts and not (str(self.ip_address),self.port) in squirrel.potentialhazelnuts:
squirrel.potentialhazelnuts[(str(self.ip_address), self.port)] = squirrel.new_hazel(self.ip_address, self.port)
squirrel.add_system_message(f"New potential friend {self.ip_address}:{self.port}!")
@staticmethod
def construct(address: IPv6Address, port: int) -> "Pad1TLV":
def construct(address: IPv6Address, port: int) -> "NeighbourTLV":
tlv = NeighbourTLV()
tlv.type = 3
tlv.length = 18 #A priori...