fixed an issue where if the machine had an IPv4 interface, it could sometime crash while checking if an address is local
This commit is contained in:
parent
cef9cea12c
commit
88f1c4cba4
1 changed files with 14 additions and 4 deletions
|
@ -242,11 +242,21 @@ class CommunicationManager:
|
||||||
for interface in self.get_local_addresses():
|
for interface in self.get_local_addresses():
|
||||||
# unpack the interface information
|
# unpack the interface information
|
||||||
interface_family, _, _, _, interface_address = interface
|
interface_family, _, _, _, interface_address = interface
|
||||||
interface_host, _, _, interface_scope = interface_address
|
|
||||||
|
|
||||||
# check if it matches the address interface
|
match interface_family:
|
||||||
if host == interface_host and scope == interface_scope:
|
case socket.AF_INET:
|
||||||
return True
|
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
|
# no matching interfaces have been found
|
||||||
return False
|
return False
|
||||||
|
|
Loading…
Reference in a new issue