Added better handling on Windows of interfaces that are non-adoptable for AutoInterface
This commit is contained in:
parent
4b07e30b9d
commit
444ae0206b
@ -181,6 +181,7 @@ class AutoInterface(Interface):
|
|||||||
|
|
||||||
suitable_interfaces = 0
|
suitable_interfaces = 0
|
||||||
for ifname in self.list_interfaces():
|
for ifname in self.list_interfaces():
|
||||||
|
try:
|
||||||
if RNS.vendor.platformutils.is_darwin() and ifname in AutoInterface.DARWIN_IGNORE_IFS and not ifname in self.allowed_interfaces:
|
if RNS.vendor.platformutils.is_darwin() and ifname in AutoInterface.DARWIN_IGNORE_IFS and not ifname in self.allowed_interfaces:
|
||||||
RNS.log(str(self)+" skipping Darwin AWDL or tethering interface "+str(ifname), RNS.LOG_EXTREME)
|
RNS.log(str(self)+" skipping Darwin AWDL or tethering interface "+str(ifname), RNS.LOG_EXTREME)
|
||||||
elif RNS.vendor.platformutils.is_darwin() and ifname == "lo0":
|
elif RNS.vendor.platformutils.is_darwin() and ifname == "lo0":
|
||||||
@ -205,7 +206,11 @@ class AutoInterface(Interface):
|
|||||||
self.link_local_addresses.append(link_local_addr)
|
self.link_local_addresses.append(link_local_addr)
|
||||||
self.adopted_interfaces[ifname] = link_local_addr
|
self.adopted_interfaces[ifname] = link_local_addr
|
||||||
self.multicast_echoes[ifname] = time.time()
|
self.multicast_echoes[ifname] = time.time()
|
||||||
RNS.log(str(self)+" Selecting link-local address "+str(link_local_addr)+" for interface "+str(ifname), RNS.LOG_EXTREME)
|
nice_name = self.netinfo.interface_name_to_nice_name(ifname)
|
||||||
|
if nice_name != None and nice_name != ifname:
|
||||||
|
RNS.log(f"{self} Selecting link-local address {link_local_addr} for interface {nice_name} / {ifname}", RNS.LOG_EXTREME)
|
||||||
|
else:
|
||||||
|
RNS.log(f"{self} Selecting link-local address {link_local_addr} for interface {ifname}", RNS.LOG_EXTREME)
|
||||||
|
|
||||||
if link_local_addr == None:
|
if link_local_addr == None:
|
||||||
RNS.log(str(self)+" No link-local IPv6 address configured for "+str(ifname)+", skipping interface", RNS.LOG_EXTREME)
|
RNS.log(str(self)+" No link-local IPv6 address configured for "+str(ifname)+", skipping interface", RNS.LOG_EXTREME)
|
||||||
@ -254,6 +259,13 @@ class AutoInterface(Interface):
|
|||||||
|
|
||||||
suitable_interfaces += 1
|
suitable_interfaces += 1
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
nice_name = self.netinfo.interface_name_to_nice_name(ifname)
|
||||||
|
if nice_name != None and nice_name != ifname:
|
||||||
|
RNS.log(f"Could not configure the system interface {nice_name} / {ifname} for use with {self}, skipping it. The contained exception was: {e}", RNS.LOG_ERROR)
|
||||||
|
else:
|
||||||
|
RNS.log(f"Could not configure the system interface {ifname} for use with {self}, skipping it. The contained exception was: {e}", RNS.LOG_ERROR)
|
||||||
|
|
||||||
if suitable_interfaces == 0:
|
if suitable_interfaces == 0:
|
||||||
RNS.log(str(self)+" could not autoconfigure. This interface currently provides no connectivity.", RNS.LOG_WARNING)
|
RNS.log(str(self)+" could not autoconfigure. This interface currently provides no connectivity.", RNS.LOG_WARNING)
|
||||||
else:
|
else:
|
||||||
|
12
RNS/vendor/ifaddr/niwrapper.py
vendored
12
RNS/vendor/ifaddr/niwrapper.py
vendored
@ -18,6 +18,18 @@ def interface_names_to_indexes() -> dict:
|
|||||||
results[adapter.name] = adapter.index
|
results[adapter.name] = adapter.index
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
def interface_name_to_nice_name(ifname) -> str:
|
||||||
|
try:
|
||||||
|
adapters = RNS.vendor.ifaddr.get_adapters(include_unconfigured=True)
|
||||||
|
for adapter in adapters:
|
||||||
|
if adapter.name == ifname:
|
||||||
|
if hasattr(adapter, "nice_name"):
|
||||||
|
return adapter.nice_name
|
||||||
|
except:
|
||||||
|
return None
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
def ifaddresses(ifname) -> dict:
|
def ifaddresses(ifname) -> dict:
|
||||||
adapters = RNS.vendor.ifaddr.get_adapters(include_unconfigured=True)
|
adapters = RNS.vendor.ifaddr.get_adapters(include_unconfigured=True)
|
||||||
ifa = {}
|
ifa = {}
|
||||||
|
Loading…
Reference in New Issue
Block a user