Compare commits

..

No commits in common. "main" and "1.5.0" have entirely different histories.
main ... 1.5.0

14 changed files with 129 additions and 522 deletions

1
.gitignore vendored
View file

@ -33,4 +33,3 @@ dist
docs/build
sideband*.egg-info
sbapp*.egg-info
LXST

View file

@ -1,3 +0,0 @@
liberapay: Reticulum
ko_fi: markqvist
custom: "https://unsigned.io/donate"

View file

@ -1,7 +1,7 @@
Sideband <img align="right" src="https://img.shields.io/badge/License-CC%20BY--NC--SA%204.0-lightgrey.svg"/>
=========
Sideband is an extensible LXMF messaging and LXST telephony client, situational awareness tracker and remote control and monitoring system for Android, Linux, macOS and Windows. It allows you to communicate with other people or LXMF-compatible systems over Reticulum networks using LoRa, Packet Radio, WiFi, I2P, Encrypted QR Paper Messages, or anything else Reticulum supports.
Sideband is an extensible LXMF messaging client, situational awareness tracker and remote control and monitoring system for Android, Linux, macOS and Windows. It allows you to communicate with other people or LXMF-compatible systems over Reticulum networks using LoRa, Packet Radio, WiFi, I2P, Encrypted QR Paper Messages, or anything else Reticulum supports.
![Screenshot](https://github.com/markqvist/Sideband/raw/main/docs/screenshots/devices_small.webp)
@ -13,11 +13,10 @@ This also means that Sideband operates differently than what you might be used t
Sideband provides many useful and interesting functions, such as:
- **Secure** and **self-sovereign** messaging and voice calls using the LXMF and LXST protocols over Reticulum.
- **Secure** and **self-sovereign** messaging using the LXMF protocol over Reticulum.
- **Image** and **file transfers** over all supported mediums.
- **Audio messages** that work even over **LoRa** and **radio links**, thanks to [Codec2](https://github.com/drowe67/codec2/) and [Opus](https://github.com/xiph/opus) encoding.
- Secure and direct P2P **telemetry and location sharing**. No third parties or servers ever have your data.
- The telemetry system is **completely extensible** via [simple plugins](#creating-plugins).
- Situation display on both online and **locally stored offline maps**.
- Geospatial awareness calculations.
- Exchanging messages through **encrypted QR-codes on paper**, or through messages embedded directly in **lxm://** links.
@ -40,7 +39,7 @@ Sideband can run on most computing devices, but installation methods vary by dev
## On Android
For your Android devices, you can download an [APK on the latest release page](https://github.com/markqvist/Sideband/releases/latest).
For your Android devices, you can install Sideband through F-Droid, by adding the [Between the Borders Repo](https://reticulum.betweentheborders.com/fdroid/repo/), or you can download an [APK on the latest release page](https://github.com/markqvist/Sideband/releases/latest). Both sources are signed with the same release keys, and can be used interchangably.
After the application is installed on your Android device, it is also possible to pull updates directly through the **Repository** section of the application.
@ -48,8 +47,9 @@ After the application is installed on your Android device, it is also possible t
On all Linux-based operating systems, Sideband is available as a `pipx`/`pip` package. This installation method **includes desktop integration**, so that Sideband will show up in your applications menu and launchers. Below are install steps for the most common recent Linux distros. For Debian 11, see the end of this section.
#### Basic Installation
You will first need to install a few dependencies for voice calls, audio messaging and Codec2 support to work:
**Please note!** The very latest Python release, Python 3.13 is currently **not** compatible with the Kivy framework, that Sideband uses to render its user interface. If your Linux distribution uses Python 3.13 as its default Python installation, you will need to install an earlier version as well. Using [the latest release of Python 3.12](https://www.python.org/downloads/release/python-3127/) is recommended.
You will first need to install a few dependencies for audio messaging and Codec2 support to work:
```bash
# For Debian (12+), Ubuntu (22.04+) and derivatives
@ -68,6 +68,10 @@ Once those are installed, install the Sideband application itself:
```bash
# Finally, install Sideband using pipx:
pipx install sbapp
# If you need to specify a specific Python version,
# use something like the following:
pipx install sbapp --python python3.12
```
After installation, you can now run Sideband in a number of different ways:
@ -80,10 +84,7 @@ After installation, you can now run Sideband in a number of different ways:
pipx ensurepath
# The first time you run Sideband, you will need to do it
# from the terminal, for the application launcher item to
# show up. On some distros you may also need to log out
# and back in again, or simply reboot the machine for the
# application entry to show up in your menu.
# from the terminal:
sideband
# At the first launch, it will add an application icon
@ -100,9 +101,6 @@ sideband --daemon
sideband -v
```
If you do not already have Reticulum connectivity set up on your computer or local network, you will probably want to edit the Reticulum configuration file at `~/.reticulum/config` and [add any interfaces](https://reticulum.network/manual/interfaces.html) you need for connectivity.
#### Advanced Installation
You can also install Sideband in various alternative ways:
```bash
@ -137,17 +135,17 @@ You can install Sideband on all Raspberry Pi models that support 64-bit operatin
Aditionally, the `pycodec2` package needs to be installed manually. I have provided a pre-built version, that you can download and install with a single command, or if you don't want to trust my pre-built version, you can [build and install it from source yourself](https://github.com/gregorias/pycodec2/blob/main/DEV.md).
The install instructions below assume that you are installing Sideband on 64-bit Raspberry Pi OS (based on Debian Bookworm or later). If you're running something else on your Pi, you might need to modify some commands slightly. To install Sideband on Raspberry Pi with full support for voice calls, audio messages and Codec2, follow these steps:
The install instructions below assume that you are installing Sideband on 64-bit Raspberry Pi OS (based on Debian Bookworm). If you're running something else on your Pi, you might need to modify some commands slightly. To install Sideband on Raspberry Pi, follow these steps:
```bash
# First of all, install the required dependencies:
sudo apt install python3-pip python3-pyaudio python3-dev python3-cryptography build-essential libopusfile0 libsdl2-dev libavcodec-dev libavdevice-dev libavfilter-dev portaudio19-dev codec2 libcodec2-1.0 xclip xsel
# If you don't want to compile pycodec2 yourself,
# download the pre-compiled package provided here:
# download the pre-compiled package provided here
wget https://raw.githubusercontent.com/markqvist/Sideband/main/docs/utilities/pycodec2-3.0.1-cp311-cp311-linux_aarch64.whl
# And install it:
# Install it:
pip install ./pycodec2-3.0.1-cp311-cp311-linux_aarch64.whl --break-system-packages
# You can now install Sideband
@ -161,8 +159,6 @@ sudo reboot
sideband
```
If you do not already have Reticulum connectivity set up on your computer or local network, you will probably want to edit the Reticulum configuration file at `~/.reticulum/config` and [add any interfaces](https://reticulum.network/manual/interfaces.html) you need for connectivity.
## On macOS
To install Sideband on macOS, you have two options available:
@ -189,8 +185,6 @@ pip3 install rns --break-system-packages
If you do not have Python and `pip` available, [download and install it](https://www.python.org/downloads/) first.
If you do not already have Reticulum connectivity set up on your computer or local network, you will probably want to edit the Reticulum configuration file at `~/.reticulum/config` and [add any interfaces](https://reticulum.network/manual/interfaces.html) you need for connectivity.
#### Source Package Install
For more advanced setups, including the ability to run Sideband in headless daemon mode, enable debug logging output, configuration import and export and more, you may want to install it from the source package via `pip` instead.
@ -244,8 +238,6 @@ Simply download the packaged Windows ZIP file from the [latest release page](htt
When running Sideband for the first time, a default Reticulum configuration file will be created, if you don't already have one. If you don't have any existing Reticulum connectivity available locally, you may want to edit the file, located at `C:\Users\USERNAME\.reticulum\config` and manually add an interface that provides connectivity to a wider network. If you just want to connect over the Internet, you can add one of the public hubs on the [Reticulum Testnet](https://reticulum.network/connect.html).
#### Installing Reticulum Utilities
Though the ZIP file contains everything necessary to run Sideband, it is also recommended to install the Reticulum command line utilities separately, so that you can use commands like `rnstatus` and `rnsd` from the command line. This will make it easier to manage Reticulum connectivity on your system. If you do not already have Python installed on your system, [download and install it](https://www.python.org/downloads/) first.
**Important!** When asked by the installer, make sure to add the Python program to your `PATH` environment variables. If you don't do this, you will not be able to use the `pip` installer, or run any of the installed commands. When Python has been installed, you can open a command prompt and install the Reticulum package via `pip`:
@ -270,28 +262,6 @@ The Sideband application can now be launched by running the command `sideband` i
Since this installation method automatically installs the `rns` and `lxmf` packages as well, you will also have access to using all the included RNS and LXMF utilities like `rnstatus`, `rnsd` and `lxmd` on your system.
# Creating Plugins
Sideband features a flexible and extensible plugin system, that allows you to hook all kinds of control, status reporting, command execution and telemetry collection into the LXMF messaging system. Plugins can be created as either *Telemetry*, *Command* or *Service* plugins, for different use-cases.
To create plugins for Sideband, you can find a variety of [code examples](https://github.com/markqvist/Sideband/tree/main/docs/example_plugins) in this repository, that you can use as a basis for writing your own plugins. The example plugins include:
- [Custom telemetry](https://github.com/markqvist/Sideband/blob/main/docs/example_plugins/telemetry.py)
- [Getting BME280 temperature, humidity and pressure](https://github.com/markqvist/Sideband/blob/main/docs/example_plugins/bme280_telemetry.py)
- [Basic commands](https://github.com/markqvist/Sideband/blob/main/docs/example_plugins/basic.py)
- [Location telemetry from GPSd on Linux](https://github.com/markqvist/Sideband/blob/main/docs/example_plugins/gpsd_location.py)
- [Location telemetry from Windows Location Provider](https://github.com/markqvist/Sideband/blob/main/docs/example_plugins/windows_location.py)
- [Getting statistics from your LXMF propagation node](https://github.com/markqvist/Sideband/blob/main/docs/example_plugins/lxmd_telemetry.py)
- [Viewing cameras and streams](https://github.com/markqvist/Sideband/blob/main/docs/example_plugins/view.py)
- [Fetching an XKCD comic](https://github.com/markqvist/Sideband/blob/main/docs/example_plugins/comic.py)
- [Creating a service plugin](https://github.com/markqvist/Sideband/blob/main/docs/example_plugins/service.py)
For creating telemetry plugins, Sideband includes 20+ built-in sensor types to chose from, for representing all kinds telemetry data. If none of those fit your needs, there is a `Custom` sensor type, that can include any kind of data.
Command plugins allow you to define any kind of action or command to be run when receiving command messages from other LXMF clients. In the example directory, you will find various command plugin templates, for example for viewing security cameras or webcams through Sideband.
Service plugins allow you to integrate any kind of service, bridge or other system into Sideband, and have that react to events or state changes in Sideband itself.
# Paper Messaging Example
You can try out the paper messaging functionality by using the following QR-code. It is a paper message sent to the LXMF address `6b3362bd2c1dbf87b66a85f79a8d8c75`. To be able to decrypt and read the message, you will need to import the following base32-encoded Reticulum Identity into the app:
@ -315,21 +285,38 @@ You can help support the continued development of open, free and private communi
```
84FpY1QbxHcgdseePYNmhTHcrgMX4nFfBYtz2GKYToqHVVhJp8Eaw1Z1EedRnKD19b3B8NiLCGVxzKV17UMmmeEsCrPyA5w
```
- Bitcoin
```
bc1p4a6axuvl7n9hpapfj8sv5reqj8kz6uxa67d5en70vzrttj0fmcusgxsfk5
```
- Ethereum
```
0xae89F3B94fC4AD6563F0864a55F9a697a90261ff
0xFDabC71AC4c0C78C95aDDDe3B4FA19d6273c5E73
```
- Bitcoin
```
35G9uWVzrpJJibzUwpNUQGQNFzLirhrYAH
```
- Liberapay: https://liberapay.com/Reticulum/
- Ko-Fi: https://ko-fi.com/markqvist
<br/>
# Planned Features
- <s>Secure and private location and telemetry sharing</s>
- <s>Including images in messages</s>
- <s>Sending file attachments</s>
- <s>Offline and online maps</s>
- <s>Paper messages</s>
- <s>Using Sideband as a Reticulum Transport Instance</s>
- <s>Encryption keys export and import</s>
- <s>Plugin support for commands, services and telemetry</s>
- <s>Sending voice messages (using Codec2 and Opus)</s>
- <s>Adding a Linux desktop integration</s>
- <s>Adding prebuilt Windows binaries to the releases</s>
- <s>Adding prebuilt macOS binaries to the releases</s>
- <s>A debug log viewer</s>
- Adding a Nomad Net page browser
- LXMF sneakernet functionality
- Network visualisation and test tools
- Better message sorting mechanism
# License
Unless otherwise noted, this work is licensed under a [Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License][cc-by-nc-sa].

View file

@ -1,88 +0,0 @@
# Windows Location Provider plugin example, provided by @haplo-dev
import RNS
import time
import threading
import asyncio
from winsdk.windows.devices import geolocation
class WindowsLocationPlugin(SidebandTelemetryPlugin):
plugin_name = "windows_location"
def __init__(self, sideband_core):
self.update_interval = 5.0
self.should_run = False
self.latitude = None
self.longitude = None
self.altitude = None
self.speed = None
self.bearing = None
self.accuracy = None
self.last_update = None
super().__init__(sideband_core)
def start(self):
RNS.log("Starting Windows Location provider plugin...")
self.should_run = True
update_thread = threading.Thread(target=self.update_job, daemon=True)
update_thread.start()
super().start()
def stop(self):
self.should_run = False
super().stop()
def update_job(self):
while self.should_run:
RNS.log("Updating location from Windows Geolocation...", RNS.LOG_DEBUG)
try:
asyncio.run(self.get_location())
except Exception as e:
RNS.log(f"Error getting location: {str(e)}", RNS.LOG_ERROR)
time.sleep(self.update_interval)
async def get_location(self):
geolocator = geolocation.Geolocator()
position = await geolocator.get_geoposition_async()
self.last_update = time.time()
self.latitude = position.coordinate.latitude
self.longitude = position.coordinate.longitude
self.altitude = position.coordinate.altitude
self.accuracy = position.coordinate.accuracy
# Note: Windows Geolocation doesn't provide speed and bearing directly
# You might need to calculate these from successive position updates
self.speed = None
self.bearing = None
def has_location(self):
return all([self.latitude, self.longitude, self.altitude, self.accuracy]) is not None
def update_telemetry(self, telemeter):
if self.is_running() and telemeter is not None:
if self.has_location():
RNS.log("Updating location from Windows Geolocation", RNS.LOG_DEBUG)
if "location" not in telemeter.sensors:
telemeter.synthesize("location")
telemeter.sensors["location"].latitude = self.latitude
telemeter.sensors["location"].longitude = self.longitude
telemeter.sensors["location"].altitude = self.altitude
telemeter.sensors["location"].speed = self.speed
telemeter.sensors["location"].bearing = self.bearing
telemeter.sensors["location"].accuracy = self.accuracy
telemeter.sensors["location"].stale_time = 5
telemeter.sensors["location"].set_update_time(self.last_update)
else:
RNS.log("No location from Windows Geolocation yet", RNS.LOG_DEBUG)
# Finally, tell Sideband what class in this
# file is the actual plugin class.
plugin_class = WindowsLocationPlugin

View file

@ -10,7 +10,7 @@ source.exclude_patterns = app_storage/*,venv/*,Makefile,./Makefil*,requirements,
version.regex = __version__ = ['"](.*)['"]
version.filename = %(source.dir)s/main.py
android.numeric_version = 20250327
android.numeric_version = 20250220
requirements = kivy==2.3.0,libbz2,pillow==10.2.0,qrcode==7.3.1,usb4a,usbserial4a,able_recipe,libwebp,libogg,libopus,opusfile,numpy,cryptography,ffpyplayer,codec2,pycodec2,sh,pynacl,typing-extensions,mistune>=3.0.2,beautifulsoup4

View file

@ -1,6 +1,6 @@
__debug_build__ = False
__disable_shaders__ = False
__version__ = "1.6.1"
__version__ = "1.5.0"
__variant__ = ""
import sys
@ -8,9 +8,7 @@ import argparse
parser = argparse.ArgumentParser(description="Sideband LXMF Client")
parser.add_argument("-v", "--verbose", action='store_true', default=False, help="increase logging verbosity")
parser.add_argument("-c", "--config", action='store', default=None, help="specify path of config directory")
parser.add_argument("-r", "--rnsconfig", action='store', default=None, help="specify path of RNS config directory")
parser.add_argument("-d", "--daemon", action='store_true', default=False, help="run as a daemon, without user interface")
parser.add_argument("-i", "--interactive", action='store_true', default=False, help="connect interactive console after daemon init")
parser.add_argument("--export-settings", action='store', default=None, help="export application settings to file")
parser.add_argument("--import-settings", action='store', default=None, help="import application settings from file")
parser.add_argument("--version", action="version", version="sideband {version}".format(version=__version__))
@ -347,7 +345,7 @@ class SidebandApp(MDApp):
if RNS.vendor.platformutils.get_platform() == "android":
self.sideband = SidebandCore(self, config_path=self.config_path, is_client=True, android_app_dir=self.app_dir, verbose=__debug_build__)
else:
self.sideband = SidebandCore(self, config_path=self.config_path, is_client=False, verbose=(args.verbose or __debug_build__),rns_config_path=args.rnsconfig)
self.sideband = SidebandCore(self, config_path=self.config_path, is_client=False, verbose=(args.verbose or __debug_build__))
self.sideband.version_str = "v"+__version__+" "+__variant__
@ -1703,12 +1701,14 @@ class SidebandApp(MDApp):
if self.outbound_mode_command:
return
def cb(dt): self.message_send_dispatch(sender)
def cb(dt):
self.message_send_dispatch(sender)
Clock.schedule_once(cb, 0.20)
def message_send_dispatch(self, sender=None):
self.messages_view.ids.message_send_button.disabled = True
def cb(dt): self.messages_view.ids.message_send_button.disabled = False
def cb(dt):
self.messages_view.ids.message_send_button.disabled = False
Clock.schedule_once(cb, 0.5)
if self.root.ids.screen_manager.current == "messages_screen":
@ -2858,7 +2858,7 @@ class SidebandApp(MDApp):
self.information_screen.ids.information_scrollview.effect_cls = ScrollEffect
self.information_screen.ids.information_logo.icon = self.sideband.asset_dir+"/rns_256.png"
str_comps = " - [b]Reticulum[/b] (Reticulum License)\n - [b]LXMF[/b] (Reticulum License)\n - [b]KivyMD[/b] (MIT License)"
str_comps = " - [b]Reticulum[/b] (MIT License)\n - [b]LXMF[/b] (MIT License)\n - [b]KivyMD[/b] (MIT License)"
str_comps += "\n - [b]Kivy[/b] (MIT License)\n - [b]Codec2[/b] (LGPL License)\n - [b]PyCodec2[/b] (BSD-3 License)"
str_comps += "\n - [b]PyDub[/b] (MIT License)\n - [b]PyOgg[/b] (Public Domain)\n - [b]FFmpeg[/b] (GPL3 License)"
str_comps += "\n - [b]GeoidHeight[/b] (LGPL License)\n - [b]Paho MQTT[/b] (EPL2 License)\n - [b]Python[/b] (PSF License)"
@ -3540,7 +3540,6 @@ class SidebandApp(MDApp):
def save_connectivity(sender=None, event=None):
self.sideband.config["connect_transport"] = self.connectivity_screen.ids.connectivity_enable_transport.active
self.sideband.config["connect_share_instance"] = self.connectivity_screen.ids.connectivity_share_instance.active
self.sideband.config["connect_local"] = self.connectivity_screen.ids.connectivity_use_local.active
self.sideband.config["connect_local_groupid"] = self.connectivity_screen.ids.connectivity_local_groupid.text
self.sideband.config["connect_local_ifac_netname"] = self.connectivity_screen.ids.connectivity_local_ifac_netname.text
@ -3698,10 +3697,6 @@ class SidebandApp(MDApp):
self.connectivity_screen.ids.connectivity_enable_transport.active = self.sideband.config["connect_transport"]
con_collapse_transport(collapse=not self.sideband.config["connect_transport"])
self.connectivity_screen.ids.connectivity_enable_transport.bind(active=save_connectivity)
self.connectivity_screen.ids.connectivity_share_instance.active = self.sideband.config["connect_share_instance"]
self.connectivity_screen.ids.connectivity_share_instance.bind(active=save_connectivity)
self.connectivity_screen.ids.connectivity_local_ifmode.text = self.sideband.config["connect_ifmode_local"].capitalize()
self.connectivity_screen.ids.connectivity_tcp_ifmode.text = self.sideband.config["connect_ifmode_tcp"].capitalize()
self.connectivity_screen.ids.connectivity_i2p_ifmode.text = self.sideband.config["connect_ifmode_i2p"].capitalize()
@ -3781,8 +3776,7 @@ class SidebandApp(MDApp):
dialog.dismiss()
yes_button.bind(on_release=dl_yes)
rpc_string = "shared_instance_type = tcp\n"
rpc_string += "rpc_key = "+RNS.hexrep(self.sideband.reticulum.rpc_key, delimit=False)
rpc_string = "rpc_key = "+RNS.hexrep(self.sideband.reticulum.rpc_key, delimit=False)
Clipboard.copy(rpc_string)
dialog.open()
@ -5470,7 +5464,7 @@ class SidebandApp(MDApp):
self.telemetry_info_dialog.dismiss()
ok_button.bind(on_release=dl_ok)
result = self.sideband.request_latest_telemetry(from_addr=self.sideband.config["telemetry_collector"], is_collector_request=True)
result = self.sideband.request_latest_telemetry(from_addr=self.sideband.config["telemetry_collector"])
if result == "no_address":
title_str = "Invalid Address"
@ -5480,10 +5474,10 @@ class SidebandApp(MDApp):
info_str = "No keys known for the destination. Connected reticules have been queried for the keys. Try again when an announce for the destination has arrived."
elif result == "in_progress":
title_str = "Transfer In Progress"
info_str = "There is already a telemetry request transfer in progress to the collector."
info_str = "There is already a telemetry request transfer in progress for this peer."
elif result == "sent":
title_str = "Request Sent"
info_str = "A telemetry request was sent to the collector. The collector should send any available telemetry shortly."
info_str = "A telemetry request was sent to the peer. The peer should send any available telemetry shortly."
elif result == "not_sent":
title_str = "Not Sent"
info_str = "A telemetry request could not be sent."
@ -6449,21 +6443,13 @@ def run():
config_path=args.config,
is_client=False,
verbose=(args.verbose or __debug_build__),
quiet=(args.interactive and not args.verbose),
is_daemon=True,
rns_config_path=args.rnsconfig,
is_daemon=True
)
sideband.version_str = "v"+__version__+" "+__variant__
sideband.start()
if args.interactive:
while not sideband.getstate("core.started") == True: time.sleep(0.1)
from .sideband import console
console.attach(sideband)
else:
while True: time.sleep(5)
while True:
time.sleep(5)
else:
ExceptionManager.add_handler(SidebandExceptionHandler())
SidebandApp().run()

View file

@ -1,103 +0,0 @@
import os
import RNS
import threading
from prompt_toolkit.application import Application
from prompt_toolkit.document import Document
from prompt_toolkit.key_binding import KeyBindings
from prompt_toolkit.layout.containers import HSplit, Window
from prompt_toolkit.layout.layout import Layout
from prompt_toolkit.styles import Style
from prompt_toolkit.widgets import SearchToolbar, TextArea
sideband = None
application = None
output_document = Document(text="", cursor_position=0)
output_field = None
def attach(target_core):
global sideband
sideband = target_core
RNS.logdest = RNS.LOG_CALLBACK
RNS.logcall = receive_output
console()
def parse(uin):
args = uin.split(" ")
cmd = args[0]
if cmd == "q" or cmd == "quit": quit_action()
elif cmd == "clear": cmd_clear(args)
elif cmd == "raw": cmd_raw(args, uin.replace("raw ", ""))
elif cmd == "log": cmd_log(args)
else: receive_output(f"Unknown command: {cmd}")
def cmd_clear(args):
output_document = output_document = Document(text="", cursor_position=0)
output_field.buffer.document = output_document
def cmd_raw(args, expr):
if expr != "" and expr != "raw":
try: receive_output(eval(expr))
except Exception as e: receive_output(str(e))
def cmd_log(args):
try:
if len(args) == 1: receive_output(f"Current loglevel is {RNS.loglevel}")
else: RNS.loglevel = int(args[1]); receive_output(f"Loglevel set to {RNS.loglevel}")
except Exception as e:
receive_output("Invalid loglevel: {e}")
def set_log(level=None):
if level: RNS.loglevel = level
if RNS.loglevel == 0: receive_output("Logging squelched. Use log command to print output to console.")
def quit_action():
receive_output("Shutting down Sideband...")
sideband.should_persist_data()
application.exit()
def receive_output(msg):
global output_document, output_field
content = f"{output_field.text}\n{msg}"
output_document = output_document = Document(text=content, cursor_position=len(content))
output_field.buffer.document = output_document
def console():
global output_document, output_field, application
search_field = SearchToolbar()
output_field = TextArea(style="class:output-field", text="Sideband console ready")
input_field = TextArea(
height=1,
prompt="> ",
style="class:input-field",
multiline=False,
wrap_lines=False,
search_field=search_field)
container = HSplit([
output_field,
Window(height=1, char="-", style="class:line"),
input_field,
search_field])
def accept(buff): parse(input_field.text)
input_field.accept_handler = accept
kb = KeyBindings()
@kb.add("c-c")
@kb.add("c-q")
def _(event): quit_action()
style = Style([
("line", "#004444"),
])
application = Application(
layout=Layout(container, focused_element=input_field),
key_bindings=kb,
style=style,
mouse_support=True,
full_screen=False)
set_log()
application.run()

View file

@ -8,7 +8,6 @@ import sqlite3
import random
import shlex
import re
import gc
import RNS.vendor.umsgpack as msgpack
import RNS.Interfaces.Interface as Interface
@ -148,7 +147,7 @@ class SidebandCore():
self.log_announce(destination_hash, app_data, dest_type=SidebandCore.aspect_filter, stamp_cost=sc, link_stats=link_stats)
def __init__(self, owner_app, config_path = None, is_service=False, is_client=False, android_app_dir=None, verbose=False, quiet=False, owner_service=None, service_context=None, is_daemon=False, load_config_only=False, rns_config_path=None):
def __init__(self, owner_app, config_path = None, is_service=False, is_client=False, android_app_dir=None, verbose=False, owner_service=None, service_context=None, is_daemon=False, load_config_only=False):
self.is_service = is_service
self.is_client = is_client
self.is_daemon = is_daemon
@ -164,20 +163,17 @@ class SidebandCore():
else:
self.is_standalone = False
self.log_verbose = (verbose and not quiet)
self.log_quiet = quiet
self.log_verbose = verbose
self.log_deque = deque(maxlen=self.LOG_DEQUE_MAXLEN)
self.owner_app = owner_app
self.reticulum = None
self.webshare_server = None
self.voice_running = False
self.telephone = None
self.telemeter = None
self.telemetry_running = False
self.latest_telemetry = None
self.latest_packed_telemetry = None
self.telemetry_changes = 0
self.telemetry_response_excluded = []
self.pending_telemetry_send = False
self.pending_telemetry_send_try = 0
self.pending_telemetry_send_maxtries = 2
@ -210,7 +206,7 @@ class SidebandCore():
self.cache_dir = self.app_dir+"/cache"
self.rns_configdir = rns_config_path
self.rns_configdir = None
core_path = os.path.abspath(__file__)
if "core.pyc" in core_path:
@ -254,15 +250,13 @@ class SidebandCore():
if not os.path.isdir(self.app_dir+"/app_storage"):
os.makedirs(self.app_dir+"/app_storage")
self.config_path = self.app_dir+"/app_storage/sideband_config"
self.identity_path = self.app_dir+"/app_storage/primary_identity"
self.db_path = self.app_dir+"/app_storage/sideband.db"
self.lxmf_storage = self.app_dir+"/app_storage/"
self.log_dir = self.app_dir+"/app_storage/"
self.tmp_dir = self.app_dir+"/app_storage/tmp"
self.exports_dir = self.app_dir+"/exports"
self.telemetry_exclude_path = self.app_dir+"/app_storage/collector_response_excluded"
self.config_path = self.app_dir+"/app_storage/sideband_config"
self.identity_path = self.app_dir+"/app_storage/primary_identity"
self.db_path = self.app_dir+"/app_storage/sideband.db"
self.lxmf_storage = self.app_dir+"/app_storage/"
self.log_dir = self.app_dir+"/app_storage/"
self.tmp_dir = self.app_dir+"/app_storage/tmp"
self.exports_dir = self.app_dir+"/exports"
if RNS.vendor.platformutils.is_android():
self.webshare_dir = "./share/"
else:
@ -273,7 +267,6 @@ class SidebandCore():
self.webshare_ssl_cert_path = self.app_dir+"/app_storage/ssl_cert.pem"
self.mqtt = None
self.mqtt_handle_lock = threading.Lock()
self.first_run = True
self.saving_configuration = False
@ -575,36 +568,11 @@ class SidebandCore():
self.save_configuration()
def __load_telemetry_collector_excluded(self):
if not os.path.isfile(self.telemetry_exclude_path):
try:
file = open(self.telemetry_exclude_path, "wb")
file.write("# To exclude destinations from telemetry\n# collector responses, add them to this\n# file with one destination hash per line\n".encode("utf-8"))
file.close()
except Exception as e:
RNS.log(f"Could not create telemetry collector exclude file at {self.telemetry_exclude_path}", RNS.LOG_ERROR)
try:
with open(self.telemetry_exclude_path, "rb") as file:
data = file.read().decode("utf-8")
for line in data.splitlines():
if not line.startswith("#"):
if len(line) >= RNS.Reticulum.TRUNCATED_HASHLENGTH//8*2:
try:
destination_hash = bytes.fromhex(line[:RNS.Reticulum.TRUNCATED_HASHLENGTH//8*2])
self.telemetry_response_excluded.append(destination_hash)
except Exception as e:
RNS.log(f"Invalid destination hash {line} in telemetry response exclude file: {e}", RNS.LOG_ERROR)
except Exception as e:
RNS.log(f"Error while loading telemetry collector response excludes: {e}", RNS.LOG_ERROR)
def __load_config(self):
RNS.log("Loading Sideband identity...", RNS.LOG_DEBUG)
self.identity = RNS.Identity.from_file(self.identity_path)
self.rpc_addr = f"\0sideband/rpc"
self.rpc_addr = ("127.0.0.1", 48165)
self.rpc_key = RNS.Identity.full_hash(self.identity.get_private_key())
RNS.log("Loading Sideband configuration... "+str(self.config_path), RNS.LOG_DEBUG)
@ -663,8 +631,6 @@ class SidebandCore():
self.config["config_template"] = None
if not "connect_transport" in self.config:
self.config["connect_transport"] = False
if not "connect_share_instance" in self.config:
self.config["connect_share_instance"] = False
if not "connect_rnode" in self.config:
self.config["connect_rnode"] = False
if not "connect_rnode_ifac_netname" in self.config:
@ -900,8 +866,6 @@ class SidebandCore():
self._db_upgradetables()
self.__db_indices()
self.__load_telemetry_collector_excluded()
def __reload_config(self):
RNS.log("Reloading Sideband configuration... ", RNS.LOG_DEBUG)
with open(self.config_path, "rb") as config_file:
@ -1403,13 +1367,13 @@ class SidebandCore():
else:
self.setstate(f"telemetry.{RNS.hexrep(message.destination_hash, delimit=False)}.request_sending", False)
def _service_request_latest_telemetry(self, from_addr=None, is_collector_request=False):
def _service_request_latest_telemetry(self, from_addr=None):
if not RNS.vendor.platformutils.is_android():
return False
else:
if self.is_client:
try:
return self.service_rpc_request({"request_latest_telemetry": {"from_addr": from_addr, "is_collector_request": is_collector_request}})
return self.service_rpc_request({"request_latest_telemetry": {"from_addr": from_addr}})
except Exception as e:
RNS.log("Error while requesting latest telemetry over RPC: "+str(e), RNS.LOG_DEBUG)
@ -1418,10 +1382,10 @@ class SidebandCore():
else:
return False
def request_latest_telemetry(self, from_addr=None, is_livetrack=False, is_collector_request=False):
def request_latest_telemetry(self, from_addr=None, is_livetrack=False):
if self.allow_service_dispatch and self.is_client:
try:
return self._service_request_latest_telemetry(from_addr, is_collector_request=is_collector_request)
return self._service_request_latest_telemetry(from_addr)
except Exception as e:
RNS.log("Error requesting latest telemetry: "+str(e), RNS.LOG_ERROR)
@ -1460,7 +1424,7 @@ class SidebandCore():
request_timebase = self.getpersistent(f"telemetry.{RNS.hexrep(from_addr, delimit=False)}.timebase") or now - self.telemetry_request_max_history
lxm_fields = { LXMF.FIELD_COMMANDS: [
{Commands.TELEMETRY_REQUEST: [request_timebase, is_collector_request]},
{Commands.TELEMETRY_REQUEST: request_timebase},
]}
lxm = LXMF.LXMessage(dest, source, "", desired_method=desired_method, fields = lxm_fields, include_ticket=True)
@ -1556,7 +1520,7 @@ class SidebandCore():
else:
return False
def send_latest_telemetry(self, to_addr=None, stream=None, is_authorized_telemetry_request=False, is_collector_response=False):
def send_latest_telemetry(self, to_addr=None, stream=None, is_authorized_telemetry_request=False):
if self.allow_service_dispatch and self.is_client:
try:
return self._service_send_latest_telemetry(to_addr, stream, is_authorized_telemetry_request)
@ -1598,7 +1562,7 @@ class SidebandCore():
else:
desired_method = LXMF.LXMessage.DIRECT
lxm_fields = self.get_message_fields(to_addr, is_authorized_telemetry_request=is_authorized_telemetry_request, signal_already_sent=True, is_collector_response=is_collector_response)
lxm_fields = self.get_message_fields(to_addr, is_authorized_telemetry_request=is_authorized_telemetry_request, signal_already_sent=True)
if lxm_fields == False and stream == None:
return "already_sent"
@ -1823,7 +1787,7 @@ class SidebandCore():
try:
with self.rpc_lock:
if self.rpc_connection == None:
self.rpc_connection = multiprocessing.connection.Client(self.rpc_addr, family="AF_UNIX", authkey=self.rpc_key)
self.rpc_connection = multiprocessing.connection.Client(self.rpc_addr, authkey=self.rpc_key)
self.rpc_connection.send(request)
response = self.rpc_connection.recv()
return response
@ -1896,12 +1860,12 @@ class SidebandCore():
mr = self.message_router
oh = destination_hash
ol = None
if oh in mr.direct_links and mr.direct_links[oh].status == RNS.Link.ACTIVE:
if oh in mr.direct_links:
ol = mr.direct_links[oh]
elif oh in mr.backchannel_links:
ol = mr.backchannel_links[oh]
if ol != None and ol.status == RNS.Link.ACTIVE:
if ol != None:
ler = ol.get_establishment_rate()
if ler:
return ler
@ -1931,12 +1895,12 @@ class SidebandCore():
mr = self.message_router
oh = destination_hash
ol = None
if oh in mr.direct_links and mr.direct_links[oh].status == RNS.Link.ACTIVE:
if oh in mr.direct_links:
ol = mr.direct_links[oh]
elif oh in mr.backchannel_links:
ol = mr.backchannel_links[oh]
if ol != None and ol.status == RNS.Link.ACTIVE:
if ol != None:
return ol.get_mtu()
return None
@ -1964,12 +1928,12 @@ class SidebandCore():
mr = self.message_router
oh = destination_hash
ol = None
if oh in mr.direct_links and mr.direct_links[oh].status == RNS.Link.ACTIVE:
if oh in mr.direct_links:
ol = mr.direct_links[oh]
elif oh in mr.backchannel_links:
ol = mr.backchannel_links[oh]
if ol != None and ol.status == RNS.Link.ACTIVE:
if ol != None:
return ol.get_expected_rate()
return None
@ -1992,47 +1956,15 @@ class SidebandCore():
RNS.log(ed, RNS.LOG_DEBUG)
return None
def _get_destination_lmd(self, destination_hash):
try:
mr = self.message_router
oh = destination_hash
ol = None
if oh in mr.direct_links and mr.direct_links[oh].status == RNS.Link.ACTIVE:
ol = mr.direct_links[oh]
elif oh in mr.backchannel_links:
ol = mr.backchannel_links[oh]
if ol != None and ol.status == RNS.Link.ACTIVE: return ol.get_mode()
return None
except Exception as e:
RNS.trace_exception(e)
return None
def get_destination_lmd(self, destination_hash):
if not RNS.vendor.platformutils.is_android():
return self._get_destination_lmd(destination_hash)
else:
if self.is_service:
return self._get_destination_lmd(destination_hash)
else:
try:
return self.service_rpc_request({"get_destination_lmd": destination_hash})
except Exception as e:
ed = "Error while getting destination link mode over RPC: "+str(e)
RNS.log(ed, RNS.LOG_DEBUG)
return None
def __start_rpc_listener(self):
try:
RNS.log("Starting RPC listener", RNS.LOG_DEBUG)
self.rpc_listener = multiprocessing.connection.Listener(self.rpc_addr, family="AF_UNIX", authkey=self.rpc_key)
self.rpc_listener = multiprocessing.connection.Listener(self.rpc_addr, authkey=self.rpc_key)
thread = threading.Thread(target=self.__rpc_loop)
thread.daemon = True
thread.start()
except Exception as e:
RNS.log("Could not start RPC listener on @"+str(self.rpc_addr[1:])+". Terminating now. Clear up anything using the port and try again.", RNS.LOG_ERROR)
RNS.log("Could not start RPC listener on "+str(self.rpc_addr)+". Terminating now. Clear up anything using the port and try again.", RNS.LOG_ERROR)
RNS.panic()
def __rpc_loop(self):
@ -2072,8 +2004,6 @@ class SidebandCore():
connection.send(self._get_destination_mtu(call["get_destination_mtu"]))
elif "get_destination_edr" in call:
connection.send(self._get_destination_edr(call["get_destination_edr"]))
elif "get_destination_lmd" in call:
connection.send(self._get_destination_lmd(call["get_destination_lmd"]))
elif "send_message" in call:
args = call["send_message"]
send_result = self.send_message(
@ -2099,7 +2029,7 @@ class SidebandCore():
connection.send(send_result)
elif "request_latest_telemetry" in call:
args = call["request_latest_telemetry"]
send_result = self.request_latest_telemetry(args["from_addr"], is_collector_request=args["is_collector_request"])
send_result = self.request_latest_telemetry(args["from_addr"])
connection.send(send_result)
elif "send_latest_telemetry" in call:
args = call["send_latest_telemetry"]
@ -2210,7 +2140,6 @@ class SidebandCore():
dbc = db.cursor()
dbc.execute("CREATE TABLE IF NOT EXISTS telemetry (id INTEGER PRIMARY KEY, dest_context BLOB, ts INTEGER, data BLOB)")
dbc.execute("CREATE INDEX IF NOT EXISTS idx_telemetry_ts ON telemetry(ts)")
db.commit()
def _db_upgradetables(self):
@ -3180,7 +3109,6 @@ class SidebandCore():
tpacked = telemetry_entry[2]
appearance = telemetry_entry[3]
max_timebase = max(max_timebase, ttstamp)
if self._db_save_telemetry(tsource, tpacked, via = context_dest):
RNS.log("Saved telemetry stream entry from "+RNS.prettyhexrep(tsource), RNS.LOG_DEBUG)
if appearance != None:
@ -3340,37 +3268,12 @@ class SidebandCore():
self.setstate("app.flags.last_telemetry", time.time())
def mqtt_handle_telemetry(self, context_dest, telemetry):
with self.mqtt_handle_lock:
# TODO: Remove debug
if hasattr(self, "last_mqtt_recycle") and time.time() > self.last_mqtt_recycle + 60*4:
# RNS.log("Recycling MQTT handler", RNS.LOG_DEBUG)
self.mqtt.stop()
self.mqtt.client = None
self.mqtt = None
gc.collect()
if self.mqtt == None:
self.mqtt = MQTT()
if self.mqtt == None:
self.mqtt = MQTT()
self.last_mqtt_recycle = time.time()
self.mqtt.set_server(self.config["telemetry_mqtt_host"], self.config["telemetry_mqtt_port"])
self.mqtt.set_auth(self.config["telemetry_mqtt_user"], self.config["telemetry_mqtt_pass"])
self.mqtt.handle(context_dest, telemetry)
# TODO: Remove debug
# if not hasattr(self, "memtr"):
# from pympler import muppy
# from pympler import summary
# import resource
# self.res = resource
# self.ms = summary; self.mp = muppy
# self.memtr = self.ms.summarize(self.mp.get_objects())
# RNS.log(f"RSS: {RNS.prettysize(self.res.getrusage(self.res.RUSAGE_SELF).ru_maxrss*1000)}")
# else:
# memsum = self.ms.summarize(self.mp.get_objects())
# memdiff = self.ms.get_diff(self.memtr, memsum)
# self.ms.print_(memdiff)
# RNS.log(f"RSS: {RNS.prettysize(self.res.getrusage(self.res.RUSAGE_SELF).ru_maxrss*1000)}")
self.mqtt.set_server(self.config["telemetry_mqtt_host"], self.config["telemetry_mqtt_port"])
self.mqtt.set_auth(self.config["telemetry_mqtt_user"], self.config["telemetry_mqtt_pass"])
self.mqtt.handle(context_dest, telemetry)
def update_telemetry(self):
try:
@ -3839,7 +3742,7 @@ class SidebandCore():
if now > last_request_timebase+request_interval:
try:
RNS.log("Initiating telemetry request to collector", RNS.LOG_DEBUG)
self.request_latest_telemetry(from_addr=self.config["telemetry_collector"], is_collector_request=True)
self.request_latest_telemetry(from_addr=self.config["telemetry_collector"])
except Exception as e:
RNS.log("An error occurred while requesting a telemetry update from collector. The contained exception was: "+str(e), RNS.LOG_ERROR)
@ -4091,9 +3994,10 @@ class SidebandCore():
def _reticulum_log_debug(self, debug=False):
self.log_verbose = debug
if self.log_quiet: selected_level = 0
elif self.log_verbose: selected_level = 6
else: selected_level = 2
if self.log_verbose:
selected_level = 6
else:
selected_level = 2
RNS.loglevel = selected_level
if self.is_client:
@ -4108,9 +4012,7 @@ class SidebandCore():
return "\n".join(self.log_deque)
def __start_jobs_immediate(self):
if self.log_quiet:
selected_level = 0
elif self.log_verbose:
if self.log_verbose:
selected_level = 6
else:
selected_level = 2
@ -4118,11 +4020,7 @@ class SidebandCore():
self.setstate("init.loadingstate", "Substantiating Reticulum")
try:
if RNS.vendor.platformutils.is_android() and self.config["connect_share_instance"] == True:
self.reticulum = RNS.Reticulum(configdir=self.rns_configdir, loglevel=selected_level, logdest=self._log_handler, shared_instance_type="tcp")
else:
self.reticulum = RNS.Reticulum(configdir=self.rns_configdir, loglevel=selected_level, logdest=self._log_handler)
self.reticulum = RNS.Reticulum(configdir=self.rns_configdir, loglevel=selected_level, logdest=self._log_handler)
if RNS.vendor.platformutils.is_android():
if self.is_service:
if os.path.isfile(self.rns_configdir+"/config_template_invalid"):
@ -4188,13 +4086,13 @@ class SidebandCore():
ifac_size = None
interface_config = {
"name": "TCP Client",
"name": "TCPClientInterface",
"target_host": tcp_host,
"target_port": tcp_port,
"kiss_framing": False,
"i2p_tunneled": False,
}
tcpinterface = RNS.Interfaces.BackboneInterface.BackboneClientInterface(RNS.Transport, interface_config)
tcpinterface = RNS.Interfaces.TCPInterface.TCPClientInterface(RNS.Transport, interface_config)
tcpinterface.OUT = True
if RNS.Reticulum.transport_enabled():
@ -4467,7 +4365,7 @@ class SidebandCore():
except Exception as e:
RNS.log("Error while setting last successul telemetry timebase for "+RNS.prettyhexrep(message.destination_hash), RNS.LOG_DEBUG)
def get_message_fields(self, context_dest, telemetry_update=False, is_authorized_telemetry_request=False, signal_already_sent=False, is_collector_response=False):
def get_message_fields(self, context_dest, telemetry_update=False, is_authorized_telemetry_request=False, signal_already_sent=False):
fields = {}
send_telemetry = (telemetry_update == True) or (self.should_send_telemetry(context_dest) or is_authorized_telemetry_request)
send_appearance = self.config["telemetry_send_appearance"] or send_telemetry
@ -4476,10 +4374,7 @@ class SidebandCore():
telemeter = Telemeter.from_packed(self.latest_packed_telemetry)
telemetry_timebase = telemeter.read_all()["time"]["utc"]
last_success_tb = (self.getpersistent(f"telemetry.{RNS.hexrep(context_dest, delimit=False)}.last_send_success_timebase") or 0)
if is_collector_response and self.lxmf_destination.hash in self.telemetry_response_excluded:
RNS.log("Not embedding own telemetry collector response since own destination hash is excluded", RNS.LOG_DEBUG)
send_telemetry = False
elif telemetry_timebase > last_success_tb:
if telemetry_timebase > last_success_tb:
RNS.log("Embedding own telemetry in message since current telemetry is newer than latest successful timebase", RNS.LOG_DEBUG)
else:
RNS.log("Not embedding own telemetry in message since current telemetry timebase ("+str(telemetry_timebase)+") is not newer than latest successful timebase ("+str(last_success_tb)+")", RNS.LOG_DEBUG)
@ -5242,19 +5137,11 @@ class SidebandCore():
RNS.log("Handling commands from "+RNS.prettyhexrep(context_dest), RNS.LOG_DEBUG)
for command in commands:
if Commands.TELEMETRY_REQUEST in command:
if type(command[Commands.TELEMETRY_REQUEST]) == list:
command_timebase = command[Commands.TELEMETRY_REQUEST][0]
enable_collector_request = command[Commands.TELEMETRY_REQUEST][1]
else:
# Handle old request format
command_timebase = command[Commands.TELEMETRY_REQUEST]
enable_collector_request = True
timebase = int(command_timebase)
timebase = int(command[Commands.TELEMETRY_REQUEST])
RNS.log("Handling telemetry request with timebase "+str(timebase), RNS.LOG_DEBUG)
if self.config["telemetry_collector_enabled"] and enable_collector_request:
if self.config["telemetry_collector_enabled"]:
RNS.log(f"Collector requests enabled, returning complete telemetry response for all known objects since {timebase}", RNS.LOG_DEBUG)
self.create_telemetry_collector_response(to_addr=context_dest, timebase=timebase, is_authorized_telemetry_request=True, is_collector_response=True)
self.create_telemetry_collector_response(to_addr=context_dest, timebase=timebase, is_authorized_telemetry_request=True)
else:
RNS.log("Responding with own latest telemetry", RNS.LOG_DEBUG)
self.send_latest_telemetry(to_addr=context_dest)
@ -5290,7 +5177,7 @@ class SidebandCore():
except Exception as e:
RNS.log("Error while handling commands: "+str(e), RNS.LOG_ERROR)
def create_telemetry_collector_response(self, to_addr, timebase, is_authorized_telemetry_request=False, is_collector_response=False):
def create_telemetry_collector_response(self, to_addr, timebase, is_authorized_telemetry_request=False):
if self.getstate(f"telemetry.{RNS.hexrep(to_addr, delimit=False)}.update_sending") == True:
RNS.log("Not sending new telemetry collector response, since an earlier transfer is already in progress", RNS.LOG_DEBUG)
return "in_progress"
@ -5302,23 +5189,20 @@ class SidebandCore():
elements = 0; added = 0
telemetry_stream = []
for source in sources:
if source in self.telemetry_response_excluded:
RNS.log(f"Excluding {RNS.prettyhexrep(source)} from collector response", RNS.LOG_DEBUG)
else:
if source != to_addr:
for entry in sources[source]:
elements += 1
timestamp = entry[0]; packed_telemetry = entry[1]
appearance = self._db_get_appearance(source, raw=True)
te = [source, timestamp, packed_telemetry, appearance]
if only_latest:
if not source in added_sources:
added_sources[source] = True
telemetry_stream.append(te)
added += 1
else:
if source != to_addr:
for entry in sources[source]:
elements += 1
timestamp = entry[0]; packed_telemetry = entry[1]
appearance = self._db_get_appearance(source, raw=True)
te = [source, timestamp, packed_telemetry, appearance]
if only_latest:
if not source in added_sources:
added_sources[source] = True
telemetry_stream.append(te)
added += 1
else:
telemetry_stream.append(te)
added += 1
if len(telemetry_stream) == 0:
RNS.log(f"No new telemetry for request with timebase {timebase}", RNS.LOG_DEBUG)
@ -5326,8 +5210,7 @@ class SidebandCore():
return self.send_latest_telemetry(
to_addr=to_addr,
stream=telemetry_stream,
is_authorized_telemetry_request=is_authorized_telemetry_request,
is_collector_response=is_collector_response,
is_authorized_telemetry_request=is_authorized_telemetry_request
)

View file

@ -44,14 +44,11 @@ class MQTT():
RNS.log("All MQTT messages processed", RNS.LOG_DEBUG)
except Exception as e:
RNS.log(f"An error occurred while running MQTT scheduler jobs: {e}", RNS.LOG_ERROR)
RNS.log("An error occurred while running MQTT scheduler jobs: {e}", RNS.LOG_ERROR)
RNS.trace_exception(e)
time.sleep(MQTT.SCHEDULER_SLEEP)
try: self.disconnect()
except Exception as e: RNS.log(f"An error occurred while disconnecting MQTT server: {e}", RNS.LOG_ERROR)
RNS.log("Stopped MQTT scheduler", RNS.LOG_DEBUG)
def connect_failed(self, client, userdata):

View file

@ -120,11 +120,9 @@ class Telemeter():
def stop_all(self):
if not self.from_packed:
sensors = self.sensors.copy()
for sensor in sensors:
for sensor in self.sensors:
if not sensor == "time":
self.sensors[sensor].stop()
del sensors
def read(self, sensor):
if not self.from_packed:
@ -139,38 +137,31 @@ class Telemeter():
def read_all(self):
readings = {}
sensors = self.sensors.copy()
for sensor in sensors:
for sensor in self.sensors:
if self.sensors[sensor].active:
if not self.from_packed:
readings[sensor] = self.sensors[sensor].data
else:
readings[sensor] = self.sensors[sensor]._data
del sensors
return readings
def packed(self):
packed = {}
packed[Sensor.SID_TIME] = int(time.time())
sensors = self.sensors.copy()
for sensor in sensors:
for sensor in self.sensors:
if self.sensors[sensor].active:
packed[self.sensors[sensor].sid] = self.sensors[sensor].pack()
del sensors
return umsgpack.packb(packed)
def render(self, relative_to=None):
rendered = []
sensors = self.sensors.copy()
for sensor in sensors:
for sensor in self.sensors:
s = self.sensors[sensor]
if s.active:
r = s.render(relative_to)
if r: rendered.append(r)
del sensors
return rendered
def check_permission(self, permission):

View file

@ -641,33 +641,15 @@ MDScreen:
# font_size: dp(24)
# # disabled: True
# MDLabel:
# text: "Shared Instance Access\\n"
# id: connectivity_shared_access_label
# font_style: "H5"
MDBoxLayout:
orientation: "horizontal"
padding: [0,0,dp(24),0]
size_hint_y: None
height: dp(24)
MDLabel:
id: connectivity_shared_access_label
text: "Share Reticulum Instance"
font_style: "H6"
# disabled: True
MDSwitch:
id: connectivity_share_instance
active: False
pos_hint: {"center_y": 0.3}
# disabled: True
MDLabel:
text: "Shared Instance Access\\n"
id: connectivity_shared_access_label
font_style: "H5"
MDLabel:
id: connectivity_shared_access
markup: True
text: "You can make the Reticulum instance launched by Sideband 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\\nPlease note! [b]It is not necessary[/b] to enable Reticulum Transport for this to work!\\n\\n"
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\\nPlease note! [b]It is not necessary[/b] to enable Reticulum Transport for this to work!\\n\\n"
size_hint_y: None
text_size: self.width, None
height: self.texture_size[1]

View file

@ -319,19 +319,6 @@ class Messages():
prgstr = ""
sphrase = "Sending"
prg = self.app.sideband.get_lxm_progress(msg["hash"])
if not hasattr(w, "last_prg_update"):
w.last_prg_update = time.time()
w.last_prg = prg
speed = None
else:
now = time.time()
size = msg["lxm"].packed_size
td = now - w.last_prg_update
if td == 0 or prg == None or w.last_prg == None: speed = None
else:
bd = prg*size - w.last_prg*size
speed = (bd/td)*8
if prg != None:
prgstr = ", "+str(round(prg*100, 1))+"% done"
if prg <= 0.00:
@ -349,7 +336,6 @@ class Messages():
sphrase = "Link established"
elif prg >= 0.05:
sphrase = "Sending"
if speed != None: prgstr += f", {RNS.prettyspeed(speed)}"
if msg["title"]:
titlestr = "[b]Title[/b] "+msg["title"].decode("utf-8")+"\n"
@ -1464,10 +1450,7 @@ Builder.load_string("""
id: heading_text
markup: True
text: root.heading
size_hint_y: None
height: self.texture_size[1]
# adaptive_size: True
adaptive_size: True
# theme_text_color: 'Custom'
# text_color: rgba(255,255,255,100)
pos: 0, root.height - (self.height + root.padding[0] + dp(8))

View file

@ -830,19 +830,12 @@ class RVDetails(MDRecycleView):
ler = self.delegate.app.sideband.get_destination_establishment_rate(self.delegate.object_hash)
mtu = self.delegate.app.sideband.get_destination_mtu(self.delegate.object_hash) or RNS.Reticulum.MTU
edr = self.delegate.app.sideband.get_destination_edr(self.delegate.object_hash)
lmd = self.delegate.app.sideband.get_destination_lmd(self.delegate.object_hash)
if ler:
lers = RNS.prettyspeed(ler, "b")
mtus = RNS.prettysize(mtu)
edrs = f"{RNS.prettyspeed(edr)}" if edr != None else ""
self.entries.append({"icon": "lock-check-outline", "text": f"Link established, LER is [b]{lers}[/b], MTU is [b]{mtus}[/b]", "on_release": pass_job})
if edr: self.entries.append({"icon": "approximately-equal", "text": f"Expected data rate is [b]{edrs}[/b]", "on_release": pass_job})
if lmd != None:
if lmd in RNS.Link.MODE_DESCRIPTIONS: lmds = RNS.Link.MODE_DESCRIPTIONS[lmd]
else: lmds = "unknown"
if lmds == "AES_128_CBC": lmds = "X25519/AES128"
elif lmds == "AES_256_CBC": lmds = "X25519/AES256"
self.entries.append({"icon": "link-lock", "text": f"Link mode is [b]{lmds}[/b]", "on_release": pass_job})
except Exception as e:
RNS.trace_exception(e)

View file

@ -114,8 +114,8 @@ setuptools.setup(
]
},
install_requires=[
"rns>=0.9.6",
"lxmf>=0.7.1",
"rns>=0.9.3",
"lxmf>=0.6.2",
"kivy>=2.3.0",
"pillow>=10.2.0",
"qrcode",
@ -123,7 +123,7 @@ setuptools.setup(
"ffpyplayer",
"sh",
"numpy<=1.26.4",
"lxst>=0.3.0",
"lxst>=0.2.7",
"mistune>=3.0.2",
"beautifulsoup4",
"pycodec2;sys.platform!='Windows' and sys.platform!='win32' and sys.platform!='darwin'",