From 81fc920bdfa9d60c927376a5f77dc9580854d321 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Wed, 19 Oct 2022 11:57:09 +0200 Subject: [PATCH] Fixed AutoInterface peering hashes on WiFi devices that employ MAC address randomisation on reconnects and roaming --- RNS/Interfaces/AutoInterface.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/RNS/Interfaces/AutoInterface.py b/RNS/Interfaces/AutoInterface.py index 848c8e2..6a30c47 100644 --- a/RNS/Interfaces/AutoInterface.py +++ b/RNS/Interfaces/AutoInterface.py @@ -267,6 +267,22 @@ class AutoInterface(Interface): RNS.log(str(self)+" removed peer "+str(peer_addr)+" on "+str(removed_peer[0]), RNS.LOG_DEBUG) for ifname in self.adopted_interfaces: + # Check that the link-local address has not changed + try: + addresses = self.netifaces.ifaddresses(ifname) + if self.netifaces.AF_INET6 in addresses: + link_local_addr = None + for address in addresses[self.netifaces.AF_INET6]: + if "addr" in address: + if address["addr"].startswith("fe80:"): + link_local_addr = address["addr"].split("%")[0] + if link_local_addr != self.adopted_interfaces[ifname]: + self.adopted_interfaces[ifname] = link_local_addr + + except Exception as e: + RNS.log("Could not get device information while updating link-local addresses for "+str(self)+". The contained exception was: "+str(e), RNS.LOG_ERROR) + + # Check multicast echo timeouts last_multicast_echo = 0 if ifname in self.multicast_echoes: last_multicast_echo = self.multicast_echoes[ifname]