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:
@ -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...
|
||||
|
Reference in New Issue
Block a user