Added ability to export RPC keys for use with other instances, primarily on Termux/Android.

This commit is contained in:
Mark Qvist 2023-10-07 12:59:59 +02:00
parent 9d0ba490c7
commit a4ecfb12b9
2 changed files with 52 additions and 0 deletions

View File

@ -1680,6 +1680,29 @@ class SidebandApp(MDApp):
def close_connectivity_action(self, sender=None): def close_connectivity_action(self, sender=None):
self.open_conversations(direction="right") self.open_conversations(direction="right")
def rpc_copy_action(self, sender=None):
c_yes_button = MDRectangleFlatButton(text="Yes",font_size=dp(18), theme_text_color="Custom", line_color=self.color_reject, text_color=self.color_reject)
c_no_button = MDRectangleFlatButton(text="No, go back",font_size=dp(18))
c_dialog = MDDialog(text="[b]Caution![/b]\n\nA configuration line containing your Reticulum RPC key will be copied to the system clipboard.\n\nWhile the key can only be used by other programs running locally on this system, it is still recommended to take care in not exposing it to unwanted programs.\n\nAre you sure that you wish to proceed?", buttons=[ c_no_button, c_yes_button ])
def c_dl_no(s):
c_dialog.dismiss()
def c_dl_yes(s):
c_dialog.dismiss()
yes_button = MDRectangleFlatButton(text="OK")
dialog = MDDialog(text="The RPC configuration was copied to the system clipboard. Paste in into the [b][reticulum][/b] section of the relevant Reticulum configuration file to allow access to this instance.", buttons=[ yes_button ])
def dl_yes(s):
dialog.dismiss()
yes_button.bind(on_release=dl_yes)
rpc_string = "rpc_key = "+RNS.hexrep(self.sideband.reticulum.rpc_key, delimit=False)
Clipboard.copy(rpc_string)
dialog.open()
c_yes_button.bind(on_release=c_dl_yes)
c_no_button.bind(on_release=c_dl_no)
c_dialog.open()
### Repository screen ### Repository screen
###################################### ######################################

View File

@ -523,6 +523,35 @@ MDNavigationLayout:
# font_size: dp(24) # font_size: dp(24)
# # disabled: True # # disabled: True
MDLabel:
text: "Shared Instance Access\\n"
font_style: "H6"
MDLabel:
id: connectivity_shared_access
markup: True
text: "The Reticulum instance launched by Sideband will be available for other programs on this system. By default, this grants connectivity to other local Reticulum-based programs, but no access to management, interface status and path information.\\n\\nIf you want to allow full functionality and ability to manage the running instance, you will need to configure other programs to use the correct RPC key for this instance.\\n\\nThis can be very useful for using other tools related to Reticulum, for example via command-line programs running in Termux. To do this, use the button below to copy the RPC key configuration line, and paste it into the Reticulum configuration file within the Termux environment, or other program.\\n\\n"
size_hint_y: None
text_size: self.width, None
height: self.texture_size[1]
MDBoxLayout:
id: connectivity_serial_fields
orientation: "vertical"
size_hint_y: None
height: self.minimum_height
padding: [0, 0, 0, dp(32)]
MDRectangleFlatIconButton:
id: rpc_keys_copy
icon: "file-key"
text: "Copy RPC Config To Clipboard"
padding: [dp(0), dp(14), dp(0), dp(14)]
icon_size: dp(24)
font_size: dp(16)
size_hint: [1.0, None]
on_release: root.ids.screen_manager.app.rpc_copy_action(self)
MDBoxLayout: MDBoxLayout:
orientation: "horizontal" orientation: "horizontal"
padding: [0,0,dp(24),0] padding: [0,0,dp(24),0]