Skip to content

Commit

Permalink
Remove service name from aspects #12; minor tweaks
Browse files Browse the repository at this point in the history
- Remove service name from RNS destination aspects. Service name
  now selects a suffix for the identity file and should only be
  supplied on the listener. The initiator only needs the destination
  hash of the listener to connect.
- Show a spinner during link establishment on tty sessions
- Attempt to catch and beautify exceptions on initiator
  • Loading branch information
acehoss committed Feb 23, 2023
1 parent bd12efd commit a07ce53
Show file tree
Hide file tree
Showing 7 changed files with 200 additions and 111 deletions.
98 changes: 43 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ There will sometimes be breaking changes in the protocol between
releases. Use at your own peril!

## Recent Changes
### v0.0.12
- Remove service name from RNS destination aspects. Service name
now selects a suffix for the identity file and should only be
supplied on the listener. The initiator only needs the destination
hash of the listener to connect.
- Show a spinner during link establishment on tty sessions
- Attempt to catch and beautify exceptions on initiator

### v0.0.11
- Event loop bursting improves throughput and CPU utilization on
both listener and initiator.
Expand All @@ -40,41 +48,6 @@ releases. Use at your own peril!
- Switch to a new packet-based protocol
- Bug fixes and dependency updates

### v0.0.8
- Improved test suite exposed several issues with the handling of
command line arguments which are now fixed
- Fixed a race condition that would cause remote characters to be
lost intermittently when running remote commands that finish
immediately.
- Added automated testing that actually spins up a random listener
and initiator in a private Reticulum network and passes data
between them, uncovering more issues which are now fixed.
- Fixed (hopefully) an issue where `rnsh` doesn't know what
version it is.

### v0.0.7
Added `-A` command line option. This listener option causes the
remote command line to be appended to the arguments list of the
launched program. This allows the listener to jail connections
to a particular executable while still allowing parameters.

### v0.0.6
Minor improvements in transport efficiency

### v0.0.5
#### Remote command line and pipe compatibility
Command line options have changed somewhat to allow the initiator
to supply a command line. This allows `rnsh` to function similarly
to SSH. You can pipe into or out of `rnsh` to send input through
remote commands or remote command output through other commands.

This behavior can be blocked on the listener with the `-C` option.

When the initiator does not supply a command, the listener uses
a default command specified on its command line. If a default
command is not specified, the listener falls back to the shell
of the user it is running under.

## Quickstart

Tested (thus far) on Python 3.11 macOS 13.1 ARM64. Should
Expand All @@ -98,9 +71,8 @@ rnsh -l -p
# On initiator
rnsh -p
```
Note: if you are using a non-default identity or service name, be
sure to supply these options with `-p` as the identity and
destination hashes will change depending on these settings.
Note: service name no longer is supplied on initiator. The destination
hash encapsulates this information.

#### Listener
- Listening for default service name ("default").
Expand All @@ -123,20 +95,20 @@ rnsh a5f72aefc2cb3cdba648f73f77c4e887
## Options
```
Usage:
rnsh [--config <configdir>] [-i <identityfile>] [-s <service_name>] [-l] -p
rnsh -l [--config <configfile>] [-i <identityfile>] [-s <service_name>]
[-v... | -q...] [-b <period>] (-n | -a <identity_hash> [-a <identity_hash>] ...)
[-A | -C] [[--] <program> [<arg> ...]]
rnsh [--config <configfile>] [-i <identityfile>] [-s <service_name>]
[-v... | -q...] [-N] [-m] [-w <timeout>] <destination_hash>
[[--] <program> [<arg> ...]]
rnsh -l [-c <configdir>] [-i <identityfile> | -s <service_name>] [-v... | -q...] -p
rnsh -l [-c <configdir>] [-i <identityfile> | -s <service_name>] [-v... | -q...]
[-b <period>] (-n | -a <identity_hash> [-a <identity_hash>] ...) [-A | -C]
[[--] <program> [<arg> ...]]
rnsh [-c <configdir>] [-i <identityfile>] [-v... | -q...] -p
rnsh [-c <configdir>] [-i <identityfile>] [-v... | -q...] [-N] [-m] [-w <timeout>]
<destination_hash> [[--] <program> [<arg> ...]]
rnsh -h
rnsh --version
Options:
--config DIR Alternate Reticulum config directory to use
-c DIR --config DIR Alternate Reticulum config directory to use
-i FILE --identity FILE Specific identity file to use
-s NAME --service NAME Listen on/connect to specific service name if not default
-s NAME --service NAME Service name for identity file if not default
-p --print-identity Print identity information and exit
-l --listen Listen (server) mode. If supplied, <program> <arg>...will
be used as the command line when the initiator does not
Expand Down Expand Up @@ -171,14 +143,30 @@ with an RNS identity, and a service name. Together, RNS makes
these into a destination hash that can be used to connect to
your listener.

Multiple listeners can use the same identity. As long as
they are given different service names. They will have
different destination hashes and not conflict.

Listeners must be configured with a command line to run (at
least at this time). The identity hash string is set in the
environment variable RNS_REMOTE_IDENTITY for use in child
programs.
Each listener must use a unique identity. The `-s` parameter
can be used to specify a service name, which creates a unique
identity file.

Listeners can be configured with a command line to run on
connect. Initiators can supply a command line as well. There
are several different options for the way the command line
is handled:

- `-C` no initiator command line is allowed; the connection will
be terminated if one is supplied.
- `-A` initiator-supplied command line is appended to listener-
configured command line
- With neither of these options, the listener will use the first
valid command line from this list:
1. Initiator-supplied command line
2. Listener command line argument
3. Default shell of user listener is running under


If the `-n` option is not set on the listener, the initiator
is required to identify before starting a command. The program
will be started with the initiator's identity hash string is set
in the environment variable `RNS_REMOTE_IDENTITY`.

Listeners are set up using the `-l` flag.

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "rnsh"
version = "0.0.11"
version = "0.0.12"
description = "Shell over Reticulum"
authors = ["acehoss <[email protected]>"]
license = "MIT"
Expand Down
25 changes: 14 additions & 11 deletions rnsh/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ def _split_array_at(arr: [_T], at: _T) -> ([_T], [_T]):
usage = \
'''
Usage:
rnsh [--config <configdir>] [-i <identityfile>] [-s <service_name>] [-l] -p
rnsh -l [--config <configfile>] [-i <identityfile>] [-s <service_name>]
[-v... | -q...] [-b <period>] (-n | -a <identity_hash> [-a <identity_hash>] ...)
[-A | -C] [[--] <program> [<arg> ...]]
rnsh [--config <configfile>] [-i <identityfile>] [-s <service_name>]
[-v... | -q...] [-N] [-m] [-w <timeout>] <destination_hash>
[[--] <program> [<arg> ...]]
rnsh -l [-c <configdir>] [-i <identityfile> | -s <service_name>] [-v... | -q...] -p
rnsh -l [-c <configdir>] [-i <identityfile> | -s <service_name>] [-v... | -q...]
[-b <period>] (-n | -a <identity_hash> [-a <identity_hash>] ...) [-A | -C]
[[--] <program> [<arg> ...]]
rnsh [-c <configdir>] [-i <identityfile>] [-v... | -q...] -p
rnsh [-c <configdir>] [-i <identityfile>] [-v... | -q...] [-N] [-m] [-w <timeout>]
<destination_hash> [[--] <program> [<arg> ...]]
rnsh -h
rnsh --version
Options:
--config DIR Alternate Reticulum config directory to use
-c DIR --config DIR Alternate Reticulum config directory to use
-i FILE --identity FILE Specific identity file to use
-s NAME --service NAME Listen on/connect to specific service name if not default
-s NAME --service NAME Service name for identity file if not default
-p --print-identity Print identity information and exit
-l --listen Listen (server) mode. If supplied, <program> <arg>...will
be used as the command line when the initiator does not
Expand Down Expand Up @@ -59,6 +59,7 @@ def _split_array_at(arr: [_T], at: _T) -> ([_T], [_T]):
-h --help Show this help
'''

DEFAULT_SERVICE_NAME = "default"

class Args:
def __init__(self, argv: [str]):
Expand All @@ -75,9 +76,11 @@ def __init__(self, argv: [str]):

args = docopt.docopt(usage, argv=self.docopts_argv[1:], version=f"rnsh {rnsh.__version__}")
# json.dump(args, sys.stdout)

self.service_name = args.get("--service", None) or "default"

self.listen = args.get("--listen", None) or False
self.service_name = args.get("--service", None)
if self.listen and (self.service_name is None or len(self.service_name) > 0):
self.service_name = DEFAULT_SERVICE_NAME
self.identity = args.get("--identity", None)
self.config = args.get("--config", None)
self.print_identity = args.get("--print-identity", None) or False
Expand Down
Loading

0 comments on commit a07ce53

Please sign in to comment.