Skip to content

Commit f3d04ba

Browse files
committed
Improved AutoInterface handling on Android
1 parent 1d2564c commit f3d04ba

File tree

2 files changed

+35
-25
lines changed

2 files changed

+35
-25
lines changed

RNS/Interfaces/AutoInterface.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class AutoInterface(Interface):
2222
PEERING_TIMEOUT = 6.0
2323

2424
DARWIN_IGNORE_IFS = ["awdl0", "llw0", "lo0", "en5"]
25+
ANDROID_IGNORE_IFS = ["dummy0", "lo", "tun0"]
2526

2627
def __init__(self, owner, name, group_id=None, discovery_scope=None, discovery_port=None, data_port=None, allowed_interfaces=None, ignored_interfaces=None):
2728
import importlib
@@ -101,10 +102,12 @@ def __init__(self, owner, name, group_id=None, discovery_scope=None, discovery_p
101102

102103
suitable_interfaces = 0
103104
for ifname in self.netifaces.interfaces():
104-
if RNS.vendor.platformutils.get_platform() == "darwin" and ifname in AutoInterface.DARWIN_IGNORE_IFS:
105+
if RNS.vendor.platformutils.is_darwin() and ifname in AutoInterface.DARWIN_IGNORE_IFS and not ifname in self.allowed_interfaces:
105106
RNS.log(str(self)+" skipping Darwin AWDL or tethering interface "+str(ifname), RNS.LOG_EXTREME)
106-
elif RNS.vendor.platformutils.get_platform() == "darwin" and ifname == "lo0":
107+
elif RNS.vendor.platformutils.is_darwin() and ifname == "lo0":
107108
RNS.log(str(self)+" skipping Darwin loopback interface "+str(ifname), RNS.LOG_EXTREME)
109+
elif RNS.vendor.platformutils.is_android() and ifname in AutoInterface.ANDROID_IGNORE_IFS and not ifname in self.allowed_interfaces:
110+
RNS.log(str(self)+" skipping Android system interface "+str(ifname), RNS.LOG_EXTREME)
108111
elif ifname in self.ignored_interfaces:
109112
RNS.log(str(self)+" ignoring disallowed interface "+str(ifname), RNS.LOG_EXTREME)
110113
else:

RNS/Reticulum.py

+30-23
Original file line numberDiff line numberDiff line change
@@ -281,30 +281,35 @@ def __apply_config(self):
281281
try:
282282
if ("interface_enabled" in c) and c.as_bool("interface_enabled") == True:
283283
if c["type"] == "AutoInterface":
284-
group_id = c["group_id"] if "group_id" in c else None
285-
discovery_scope = c["discovery_scope"] if "discovery_scope" in c else None
286-
discovery_port = int(c["discovery_port"]) if "discovery_port" in c else None
287-
data_port = int(c["data_port"]) if "data_port" in c else None
288-
allowed_interfaces = c.as_list("devices") if "devices" in c else None
289-
ignored_interfaces = c.as_list("ignored_devices") if "ignored_devices" in c else None
290-
291-
interface = AutoInterface.AutoInterface(
292-
RNS.Transport,
293-
name,
294-
group_id,
295-
discovery_scope,
296-
discovery_port,
297-
data_port,
298-
allowed_interfaces,
299-
ignored_interfaces
300-
)
301-
302-
if "outgoing" in c and c.as_bool("outgoing") == True:
303-
interface.OUT = True
284+
if not RNS.vendor.platformutils.is_windows():
285+
group_id = c["group_id"] if "group_id" in c else None
286+
discovery_scope = c["discovery_scope"] if "discovery_scope" in c else None
287+
discovery_port = int(c["discovery_port"]) if "discovery_port" in c else None
288+
data_port = int(c["data_port"]) if "data_port" in c else None
289+
allowed_interfaces = c.as_list("devices") if "devices" in c else None
290+
ignored_interfaces = c.as_list("ignored_devices") if "ignored_devices" in c else None
291+
292+
interface = AutoInterface.AutoInterface(
293+
RNS.Transport,
294+
name,
295+
group_id,
296+
discovery_scope,
297+
discovery_port,
298+
data_port,
299+
allowed_interfaces,
300+
ignored_interfaces
301+
)
302+
303+
if "outgoing" in c and c.as_bool("outgoing") == True:
304+
interface.OUT = True
305+
else:
306+
interface.OUT = False
307+
308+
RNS.Transport.interfaces.append(interface)
304309
else:
305-
interface.OUT = False
306-
307-
RNS.Transport.interfaces.append(interface)
310+
RNS.log("AutoInterface is not currently supported on Windows, disabling interface.", RNS.LOG_ERROR);
311+
RNS.log("Please remove this AutoInterface instance from your configuration file.", RNS.LOG_ERROR);
312+
RNS.log("You will have to manually configure other interfaces for connectivity.", RNS.LOG_ERROR);
308313

309314

310315
if c["type"] == "UDPInterface":
@@ -536,6 +541,8 @@ def __apply_config(self):
536541
except Exception as e:
537542
RNS.log("The interface \""+name+"\" could not be created. Check your configuration file for errors!", RNS.LOG_ERROR)
538543
RNS.log("The contained exception was: "+str(e), RNS.LOG_ERROR)
544+
# TODO: Remove
545+
raise e
539546
RNS.panic()
540547
else:
541548
RNS.log("The interface name \""+name+"\" was already used. Check your configuration file for errors!", RNS.LOG_ERROR)

0 commit comments

Comments
 (0)