Skip to content

Interface Management #70

Merged
markqvist merged 7 commits intomarkqvist:masterfrom
RFnexus:interface-management
May 11, 2025
Merged

Interface Management #70
markqvist merged 7 commits intomarkqvist:masterfrom
RFnexus:interface-management

Conversation

@RFnexus
Copy link
Copy Markdown
Contributor

@RFnexus RFnexus commented Mar 9, 2025

This PR adds comprehensive interface management to NomadNet. It allows the user to create, edit, disable / enable, and monitor interfaces in realtime under the [ Interfaces ] tab. Currently it's submitted as a draft for review and feedback.

Screenshot from 2025-03-09 15-30-43

Adding interfaces

Ctrl + A lets the user add a new interface. The user selects in a dialog the interface type, then proceeds to the AddInterfaceView. The INTERFACE_FIELDS dict defines the behavior for how input is validated and transformed based interface on type. Common interface fields are defined in COMMON_INTERFACE_OPTIONS which display under "Show more options" in the add dialog.

A set of Urwid form widget classes has been added in FormWidgets.py for this purpose. This can also be extended to allow the user to edit the NomadNet, LXMF, or RNS config interactively from the application itself.

image

image

Certain interface types will have custom options inside of the Add and Edit views. For example, interfaces with a port field have an interactive port picker with the option to refresh ports and when pyserial is available. The RNodeInterface has a built in on-air parameter calculator that updates as the fields are changed, showing bitrate and link budget calculations.
image

Each interface type in INTERFACE_FIELDS can have additional_options which are shown undre "Show more options".

All fields are validated based on an array of set rules, for example ['required', 'float']. Any validation errors will be shown to the user. The behavior of the values from each FormWidget input is described in the transform key. For example, on the RNodeInterface frequency is entered in MHz as opposed to Hz for ease of use. The transform key is: "transform": lambda x: int(float(x.strip()) * 1000000)

Viewing interfaces

Pressing "Enter" on the selected interface will bring you to the ShowInterface view. This view contains the Interface information and interactive charts that display the RX and TX traffic over a set history length.
image

From here the interface can be enabled / disabled, and edited. The shortcuts are displayed below in the shortcut bar.

The chart system is derived from pyasciichart and supports both unicode and plain characters. It is also supported on lower-width terminals. Pressing v will toggle a vertical view, while pressing h will toggle a horizontal view. This may be expanded in the future to contain more interactive charts, such as noise floor and channel capacity for RNodes.

image

Editing interfaces

Editing interfaces is identical to adding interfaces, except the fields are automatically populated. EditInterfaceView is a child of AddInterfaceView

image

Interfaces can also be edited and removed directly from the list using keyboard shortcuts when they are selected.
image

Remaining Tasks:

  • RNodeMultiInterface
  • CustomInterface
  • BackboneInterface
  • support AutoInterface sub peer stats for RNS 0.9.3 (future)
  • Add guide entry under "Interfaces" section
  • Open config in text editor option
  • Automatically determine history length for charts based on terminal columns
  • Cleanup and testing

If there are any features you want added or changed, let me know. Thanks!

@kevinelliott
Copy link
Copy Markdown

This is looking great so far!

@markqvist
Copy link
Copy Markdown
Owner

This looks fantastic @RFnexus! Amazing piece of work! The comprehensive interface editing is just brilliant, and the live graphs is terminal eye-candy, in addition to being very useful.

Here's a few issues I came across when testing it:

  • On the interface overview page and interface detail page, the total traffic counters show traffic amount correctly up until 999 bytes, but after that the total traffic is displayed as bytes per second. This should probably be change to just KB/MB/GB, etc.
  • Focus will not be passed back up to the menu bar in the top of the window, if the "up" key is pressed when the topmost element in the interfaces pane is selected. As far as I remember, this is a quirk in Urwid, and something I had to solve "manually" in the other panes. It should be relatively easy to handle, here's an example of how the network pane does it
  • Along the same lines, it also seems that arrow key navigation doesn't allow selecting the "Back", "Disable" and "Edit" buttons when an interface detail page is open.
  • When nomadnet is running the primary/master RNS instance on the system, everything works smoothly and correctly (even with lots of interfaces added). However, when

Minor/personal comments:

  • Maybe it would be nice if clicking on an interface with the mouse directly opens the interface page. Right now, you have to click it and then press the enter key to open. Having the "enter", "ctrl-a", "ctrl-e" and "ctrl-x" shortcuts for keyboard operation makes a lot of sense though, so that shoul definitely stay.
  • In addition to the total traffic counters, it would be nice to also have the current instantaneous transfer rate displayed in bits per second (or kilobits/s, megabits/s, etc.)

@markqvist
Copy link
Copy Markdown
Owner

Oh, and also: If nomadnet is connected to a master RNS instance, and that instance disappears (ie., program is closed, rnsd restarts, or something like that), nomadnet will crash if the interfaces page has been opened. There's probably just a "try/except" statement missing somewhere, but this should ideally be handled such that the master instance can disappear/reappear on rnsd restart, etc.

@RFnexus RFnexus marked this pull request as ready for review April 20, 2025 13:23
@RFnexus
Copy link
Copy Markdown
Contributor Author

RFnexus commented Apr 20, 2025

I've worked through the list of feedback and have completed the outstanding tasks.

  • Navigation is now consistent with the rest of the program in how it handles arrow keys.
  • Error handling for disconnected shared instance
  • BackboneInterface from RNS 0.9.4 was added
  • CustomInterfaces of any type and RNodeMultiInterface are now supported
  • Initial guide entry under "Interfaces" section.
  • Open manual text editor through Ctrl + W
  • Fixes / cleanup

I've now marked the PR as ready for review

@markqvist markqvist merged commit 0889d4e into markqvist:master May 11, 2025
@markqvist
Copy link
Copy Markdown
Owner

Thank you so much @RFnexus! Merged now :) I fixed some minor stuff (urwid Screen object being initialised many times, leading to weird issues over time) and added formatted labels to the charts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants