From 88f1c4cba4a09aa8efb34fda45d3a608b8918f1a Mon Sep 17 00:00:00 2001 From: study-faraphel Date: Tue, 7 Jan 2025 10:17:16 +0100 Subject: [PATCH] fixed an issue where if the machine had an IPv4 interface, it could sometime crash while checking if an address is local --- source/managers/CommunicationManager.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/source/managers/CommunicationManager.py b/source/managers/CommunicationManager.py index b358ae8..5aeb224 100644 --- a/source/managers/CommunicationManager.py +++ b/source/managers/CommunicationManager.py @@ -242,11 +242,21 @@ class CommunicationManager: for interface in self.get_local_addresses(): # unpack the interface information interface_family, _, _, _, interface_address = interface - interface_host, _, _, interface_scope = interface_address - # check if it matches the address interface - if host == interface_host and scope == interface_scope: - return True + match interface_family: + case socket.AF_INET: + interface_host, interface_port = interface_address + + # check if it matches the address interface + if host == interface_host: + return True + + case socket.AF_INET6: + interface_host, interface_port, interface_flowinfo, interface_scope = interface_address + + # check if it matches the address interface + if host == interface_host and scope == interface_scope: + return True # no matching interfaces have been found return False