# -*- coding: utf-8 -*-
from setuptools import setup

packages = \
['rnsh']

package_data = \
{'': ['*']}

install_requires = \
['docopt>=0.6.2,<0.7.0', 'rns>=0.4.9,<0.5.0', 'tomli>=2.0.1,<3.0.0']

entry_points = \
{'console_scripts': ['rnsh = rnsh.rnsh:rnsh_cli']}

setup_kwargs = {
    'name': 'rnsh',
    'version': '0.0.10',
    'description': 'Shell over Reticulum',
    'long_description': '# `r n s h` \xa0Shell over Reticulum \n[![CI](https://github.com/acehoss/rnsh/actions/workflows/python-package.yml/badge.svg)](https://github.com/acehoss/rnsh/actions/workflows/python-package.yml)\xa0\n[![Release](https://github.com/acehoss/rnsh/actions/workflows/python-publish.yml/badge.svg)](https://github.com/acehoss/rnsh/actions/workflows/python-publish.yml)\xa0\n[![PyPI version](https://badge.fury.io/py/rnsh.svg)](https://badge.fury.io/py/rnsh) \xa0\n![PyPI - Downloads](https://img.shields.io/pypi/dw/rnsh?color=informational&label=Installs&logo=pypi)\n\n`rnsh` is a utility written in Python that facilitates shell \nsessions over [Reticulum](https://reticulum.network) networks. \nIt is based on the `rnx` utility that ships with Reticulum and\naims to provide a similar experience to SSH.\n\n## Contents\n\n- [Alpha Disclaimer](#reminder--alpha-software)\n- [Recent Changes](#recent-changes)\n- [Quickstart](#quickstart)\n- [Options](#options)\n- [How it works](#how-it-works)\n- [Roadmap](#roadmap)\n- [Active TODO](#todo)\n\n### Reminder: Alpha Software\nThese early versions will be buggy. There will sometimes be major\nbreaking changes to the command line parameters between releases.\nThere will sometimes be breaking changes in the protocol between\nreleases. Use at your own peril!\n\n## Recent Changes\n### v0.0.10\n- Rate limit window change events to prevent saturation of transport\n- Tweaked some loop timers to improve CPU utilization\n\n### v0.0.9\n- Switch to a new packet-based protocol\n- Bug fixes and dependency updates\n\n### v0.0.8\n- Improved test suite exposed several issues with the handling of\ncommand line arguments which are now fixed\n- Fixed a race condition that would cause remote characters to be \n  lost intermittently when running remote commands that finish\n  immediately.\n- Added automated testing that actually spins up a random listener\n  and initiator in a private Reticulum network and passes data\n  between them, uncovering more issues which are now fixed.\n- Fixed (hopefully) an issue where `rnsh` doesn\'t know what\n  version it is.\n\n### v0.0.7\nAdded `-A` command line option. This listener option causes the\nremote command line to be appended to the arguments list of the\nlaunched program. This allows the listener to jail connections\nto a particular executable while still allowing parameters.\n\n### v0.0.6\nMinor improvements in transport efficiency\n\n### v0.0.5\n#### Remote command line and pipe compatibility\nCommand line options have changed somewhat to allow the initiator\nto supply a command line. This allows `rnsh` to function similarly\nto SSH. You can pipe into or out of `rnsh` to send input through\nremote commands or remote command output through other commands.\n\nThis behavior can be blocked on the listener with the `-C` option.\n\nWhen the initiator does not supply a command, the listener uses\na default command specified on its command line. If a default\ncommand is not specified, the listener falls back to the shell\nof the user it is running under.\n\n## Quickstart\n\nTested (thus far) on Python 3.11 macOS 13.1 ARM64. Should\nrun on Python 3.6+ on Linux or Unix. WSL probably works. \nCygwin might work, too.\n\n- Activate a virtualenv\n- `pip3 install rnsh`\n  - Or from a `whl` release, `pip3 install /path/to/rnsh-0.0.1-py3-none-any.whl`\n- Configure Reticulum interfaces, check with `rnstatus`\n- Ready to run `rnsh`. The options are shown below.\n\n### Example: Shell server\n#### Setup\nBefore running the listener or initiator, you\'ll need to get the \nlistener destination hash and the initiator identity hash.\n```shell\n# On listener\nrnsh -l -p\n\n# On initiator\nrnsh -p\n```\nNote: if you are using a non-default identity or service name, be\nsure to supply these options with `-p` as the identity and \ndestination hashes will change depending on these settings.\n\n#### Listener\n- Listening for default service name ("default").\n- Using user\'s default Reticulum config dir (~/.reticulum).\n- Using default identity ($RNSCONFIGDIR/storage/identities/rnsh).\n- Allowing remote identity `6d47805065fa470852cf1b1ef417a1ac` to connect.\n- Launching `/bin/zsh` on authorized connect.\n```shell\nrnsh -l -a 6d47805065fa470852cf1b1ef417a1ac -- /bin/zsh\n```\n#### Initiator\n- Connecting to default service name ("default").\n- Using user\'s default Reticulum config dir (~/.reticulum).\n- Using default identity ($RNSCONFIGDIR/storage/identities/rnsh).\n- Connecting to destination `a5f72aefc2cb3cdba648f73f77c4e887`\n```shell\nrnsh a5f72aefc2cb3cdba648f73f77c4e887\n```\n\n## Options\n```\nUsage:\n    rnsh [--config <configdir>] [-i <identityfile>] [-s <service_name>] [-l] -p\n    rnsh -l [--config <configfile>] [-i <identityfile>] [-s <service_name>] \n         [-v... | -q...] [-b <period>] (-n | -a <identity_hash> [-a <identity_hash>] ...) \n         [-A | -C] [[--] <program> [<arg> ...]]\n    rnsh [--config <configfile>] [-i <identityfile>] [-s <service_name>] \n         [-v... | -q...] [-N] [-m] [-w <timeout>] <destination_hash> \n         [[--] <program> [<arg> ...]]\n    rnsh -h\n    rnsh --version\n\nOptions:\n    --config DIR                 Alternate Reticulum config directory to use\n    -i FILE --identity FILE      Specific identity file to use\n    -s NAME --service NAME       Listen on/connect to specific service name if not default\n    -p --print-identity          Print identity information and exit\n    -l --listen                  Listen (server) mode. If supplied, <program> <arg>...will \n                                   be used as the command line when the initiator does not\n                                   provide one or when remote command is disabled. If\n                                   <program> is not supplied, the default shell of the \n                                   user rnsh is running under will be used.\n    -b --announce PERIOD         Announce on startup and every PERIOD seconds\n                                 Specify 0 for PERIOD to announce on startup only.\n    -a HASH --allowed HASH       Specify identities allowed to connect\n    -n --no-auth                 Disable authentication\n    -N --no-id                   Disable identify on connect\n    -A --remote-command-as-args  Concatenate remote command to argument list of <program>/shell\n    -C --no-remote-command       Disable executing command line from remote\n    -m --mirror                  Client returns with code of remote process\n    -w TIME --timeout TIME       Specify client connect and request timeout in seconds\n    -q --quiet                   Increase quietness (move level up), multiple increases effect\n                                          DEFAULT LOGGING LEVEL\n                                                  CRITICAL (silent)\n                                    Initiator ->  ERROR\n                                                  WARNING\n                                     Listener ->  INFO\n                                                  DEBUG    (insane)\n    -v --verbose                 Increase verbosity (move level down), multiple increases effect\n    --version                    Show version\n    -h --help                    Show this help\n```\n\n## How it works\n### Listeners\nListener instances are the servers. Each listener is configured \nwith an RNS identity, and a service name. Together, RNS makes\nthese into a destination hash that can be used to connect to\nyour listener.\n   \nMultiple listeners can use the same identity. As long as \nthey are given different service names. They will have \ndifferent destination hashes and not conflict.\n\nListeners must be configured with a command line to run (at \nleast at this time). The identity hash string is set in the\nenvironment variable RNS_REMOTE_IDENTITY for use in child\nprograms.\n\nListeners are set up using the `-l` flag.\n   \n### Initiators\nInitiators are the clients. Each initiator has an identity\nhash which is used as an authentication mechanism on Reticulum.\nYou\'ll need this value to configure the listener to allow \nyour connection. It is possible to run the server without \nauthentication, but hopefully it\'s obvious that this is an\nadvanced use case. \n    \nTo get the identity hash, use the `-p` flag.\n    \nWith the initiator identity set up in the listener command\nline, and with the listener identity copied (you\'ll need to\ndo `-p` on the listener side, too), you can run the\ninitiator.\n    \nI recommend staying pretty vanilla to start with and\ntrying `/bin/zsh` or whatever your favorite shell is these \ndays. The shell should start in login mode. Ideally it\nworks just like an `ssh` shell session.\n\n### Protocol\nThe protocol is build on top of the Reticulum `Request` and\n`Packet` APIs.\n\n- After the initiator identifies on the connection, it enters\n  a request loop. \n- When idle, the initiator will periodically \n  poll the listener. \n- When the initiator has data available (i.e the user typed \n  some characters), the initiator will send that data to the\n  listener in a request, and the listener will respond with \n  any data available from the listener. \n- When the listener has new data available, it notifies the \n  initiator using a notification packet. The initiator then \n  makes a request to the listener to fetch the data.\n   \n## Roadmap\n1. Plan a better roadmap\n2. ?\n3. Keep my day job\n\n## TODO\n- [X] ~~Initial version~~\n- [X] ~~Pip package with command-line utility support~~\n- [X] ~~Publish to PyPI~~\n- [X] ~~Improve signal handling~~\n- [X] ~~Make it scriptable (currently requires a tty)~~\n- [X] ~~Protocol improvements (throughput!)~~\n- [X] ~~Documentation improvements~~\n- [ ] Test on several platforms\n- [ ] Fix issues that come up with testing\n- [ ] Fix issues with running `rnsh` in a binary pipeline, i.e. \n  piping the output of `tar` over `rsh`.\n- [ ] Beta release\n- [ ] Test and fix more issues\n- [ ] V1.0\n- [ ] Enhancement Ideas\n  - [ ] `authorized_keys` mode similar to SSH\n  - [ ] Git over `rnsh` (git remote helper)\n  - [ ] Sliding window acknowledgements for improved throughput\n\n## Miscellaneous\n\nBy piping into/out of `rnsh`, it should be possible to transfer\nfiles using the same method discussed in \n[this article](https://cromwell-intl.com/open-source/tar-and-ssh.html).\nI tested it just now and it doesn\'t work right. There\'s probably some\nsubtle garbling of the data at one end of the stream or the other.\n',
    'author': 'acehoss',
    'author_email': 'acehoss@acehoss.net',
    'maintainer': 'None',
    'maintainer_email': 'None',
    'url': 'None',
    'packages': packages,
    'package_data': package_data,
    'install_requires': install_requires,
    'entry_points': entry_points,
    'python_requires': '>=3.9,<4.0',
}


setup(**setup_kwargs)
