Added I2P connectivity. Added android/desktop awareness for connectivity settings.

This commit is contained in:
Mark Qvist 2022-07-06 13:07:11 +02:00
parent 163df580c0
commit 40cd0b54ab
3 changed files with 81 additions and 32 deletions

49
main.py
View File

@ -484,6 +484,27 @@ class SidebandApp(MDApp):
### Connectivity screen ### Connectivity screen
###################################### ######################################
def connectivity_action(self, sender=None): def connectivity_action(self, sender=None):
def con_hide_settings():
self.widget_hide(self.root.ids.connectivity_use_local)
self.widget_hide(self.root.ids.connectivity_local_groupid)
self.widget_hide(self.root.ids.connectivity_local_ifac_netname)
self.widget_hide(self.root.ids.connectivity_local_ifac_passphrase)
self.widget_hide(self.root.ids.connectivity_use_tcp)
self.widget_hide(self.root.ids.connectivity_tcp_host)
self.widget_hide(self.root.ids.connectivity_tcp_port)
self.widget_hide(self.root.ids.connectivity_tcp_ifac_netname)
self.widget_hide(self.root.ids.connectivity_tcp_ifac_passphrase)
self.widget_hide(self.root.ids.connectivity_use_i2p)
self.widget_hide(self.root.ids.connectivity_i2p_b32)
self.widget_hide(self.root.ids.connectivity_i2p_ifac_netname)
self.widget_hide(self.root.ids.connectivity_i2p_ifac_passphrase)
self.widget_hide(self.root.ids.connectivity_tcp_label)
self.widget_hide(self.root.ids.connectivity_local_label)
self.widget_hide(self.root.ids.connectivity_i2p_label)
self.widget_hide(self.root.ids.connectivity_rnode_label)
self.widget_hide(self.root.ids.connectivity_use_rnode)
self.widget_hide(self.root.ids.connectivity_rnode_cid)
def save_connectivity(sender=None, event=None): def save_connectivity(sender=None, event=None):
RNS.log("Save connectivity") RNS.log("Save connectivity")
self.sideband.config["connect_local"] = self.root.ids.connectivity_use_local.active self.sideband.config["connect_local"] = self.root.ids.connectivity_use_local.active
@ -501,8 +522,16 @@ class SidebandApp(MDApp):
self.sideband.config["connect_i2p_ifac_passphrase"] = self.root.ids.connectivity_i2p_ifac_passphrase.text self.sideband.config["connect_i2p_ifac_passphrase"] = self.root.ids.connectivity_i2p_ifac_passphrase.text
self.sideband.save_configuration() self.sideband.save_configuration()
info = "By default, sideband will try to discover and connect to any available Reticulum network via active WiFi and/or Ethernet interfaces. If any Reticulum Transport Instances are found, Sideband will use these to connect to wider Reticulum networks. You can disable this behaviour if you don't want it.\n\n" if RNS.vendor.platformutils.get_platform() == "android":
info += "You can connect also connect to a network via a remote or local Reticulum instance using TCP or I2P. [b]Please Note![/b] Connecting via I2P requires that you already have I2P running on your device, and the SAM API enabled.\n\n" if self.sideband.reticulum.is_connected_to_shared_instance:
info = "Sideband is connected via a shared Reticulum instance running on this system.\n\n"
info += "To configure connectivity, edit the relevant configuration file for the instance."
self.root.ids.connectivity_info.text = info
con_hide_settings()
else:
info = "By default, Sideband will try to discover and connect to any available Reticulum networks via active WiFi and/or Ethernet interfaces. If any Reticulum Transport Instances are found, Sideband will use these to connect to wider Reticulum networks. You can disable this behaviour if you don't want it.\n\n"
info += "You can also connect to a network via a remote or local Reticulum instance using TCP or I2P. [b]Please Note![/b] Connecting via I2P requires that you already have I2P running on your device, and that the SAM API is enabled.\n\n"
info += "For changes to connectivity to take effect, you must shut down and restart Sideband." info += "For changes to connectivity to take effect, you must shut down and restart Sideband."
self.root.ids.connectivity_info.text = info self.root.ids.connectivity_info.text = info
@ -536,6 +565,22 @@ class SidebandApp(MDApp):
self.root.ids.connectivity_i2p_ifac_netname.bind(on_text_validate=save_connectivity) self.root.ids.connectivity_i2p_ifac_netname.bind(on_text_validate=save_connectivity)
self.root.ids.connectivity_i2p_ifac_passphrase.bind(on_text_validate=save_connectivity) self.root.ids.connectivity_i2p_ifac_passphrase.bind(on_text_validate=save_connectivity)
else:
info = ""
if self.sideband.reticulum.is_connected_to_shared_instance:
info = "Sideband is connected via a shared Reticulum instance running on this system.\n\n"
info += "To configure connectivity, edit the configuration file located at:\n\n"
info += str(RNS.Reticulum.configpath)
else:
info = "Sideband is currently running a standalone or master Reticulum instance on this system.\n\n"
info += "To configure connectivity, edit the configuration file located at:\n\n"
info += str(RNS.Reticulum.configpath)
self.root.ids.connectivity_info.text = info
con_hide_settings()
self.root.ids.screen_manager.transition.direction = "left" self.root.ids.screen_manager.transition.direction = "left"
self.root.ids.screen_manager.current = "connectivity_screen" self.root.ids.screen_manager.current = "connectivity_screen"
self.root.ids.nav_drawer.set_state("closed") self.root.ids.nav_drawer.set_state("closed")

View File

@ -791,11 +791,11 @@ class SidebandCore():
else: else:
ifac_netkey = self.config["connect_i2p_ifac_passphrase"] ifac_netkey = self.config["connect_i2p_ifac_passphrase"]
i2pinterface = I2PInterface.I2PInterface( i2pinterface = RNS.Interfaces.I2PInterface.I2PInterface(
RNS.Transport, RNS.Transport,
"I2PInterface", "I2PInterface",
RNS.Reticulum.storagepath, RNS.Reticulum.storagepath,
self.config["connect_i2p_b32"], [self.config["connect_i2p_b32"]],
connectable = False, connectable = False,
) )

View File

@ -175,6 +175,7 @@ MDNavigationLayout:
height: dp(48) height: dp(48)
MDLabel: MDLabel:
id: connectivity_local_label
text: "Connect via local WiFi/Ethernet" text: "Connect via local WiFi/Ethernet"
font_style: "H6" font_style: "H6"
@ -214,6 +215,7 @@ MDNavigationLayout:
height: dp(48) height: dp(48)
MDLabel: MDLabel:
id: connectivity_tcp_label
text: "Connect via TCP" text: "Connect via TCP"
font_style: "H6" font_style: "H6"
@ -255,6 +257,7 @@ MDNavigationLayout:
height: dp(48) height: dp(48)
MDLabel: MDLabel:
id: connectivity_i2p_label
text: "Connect via I2P" text: "Connect via I2P"
font_style: "H6" font_style: "H6"
@ -290,6 +293,7 @@ MDNavigationLayout:
height: dp(48) height: dp(48)
MDLabel: MDLabel:
id: connectivity_rnode_label
text: "Connect via RNode" text: "Connect via RNode"
font_style: "H6" font_style: "H6"
disabled: True disabled: True