Compare commits

...

13 Commits
0.1.8 ... 0.1.9

Author SHA1 Message Date
Mark Qvist
8ef9e55a22 Updated readme 2022-06-22 17:41:11 +02:00
Mark Qvist
0a0de599dd Updated guide 2022-06-17 15:27:31 +02:00
Mark Qvist
2767e35a9f Added storage limit and priorities to configuration 2022-06-17 15:19:32 +02:00
Mark Qvist
2b3943eeba Update version and dependencies 2022-06-17 14:36:18 +02:00
Mark Qvist
7a625d677d Added handling for authenticated propagation nodes 2022-06-17 13:43:38 +02:00
Mark Qvist
2354ba3412 Fixed missing dictionary initialisations 2022-06-11 15:03:43 +02:00
Mark Qvist
fa2382e34a Updated readme 2022-05-18 16:53:17 +02:00
Mark Qvist
7814712118 Added log to console option for daemon mode 2022-05-18 16:33:28 +02:00
Mark Qvist
a6eac0d7ce Configure python for unbuffered stdout in Docker images 2022-05-18 16:18:13 +02:00
Mark Qvist
f9259b8173 Merge branch 'master' of github.com:markqvist/NomadNet 2022-05-18 14:00:24 +02:00
Mark Qvist
d65d03fe89 Added argument for text ui 2022-05-18 14:00:13 +02:00
markqvist
acb5da89fb Merge pull request #6 from jphastings/patch-1
Move --daemon to CMD from ENTRYPOINT
2022-05-18 12:15:06 +02:00
JP Hastings-Spital
3fc321e804 Move --daemon to CMD from ENTRYPOINT
I've moved the `--daemon` command from `ENTRYPOINT` to `CMD` to allow users of the dockerfile some flexibility 

The executable and/or arguments in `CMD` can be overridden easily by users of the container, but `ENTRYPOINT` is intended as a "this is always at the start of the command". ([reference](https://docs.docker.com/engine/reference/builder/#cmd))

For example, with the change in this commit:
- `docker run ghcr.io/markqvist/nomadnet:master --help` will output the same as `nomadnet --help`
- `docker run ghcr.io/markqvist/nomadnet:master` will run `nomadnet --daemon`
- `docker run ghcr.io/markqvist/nomadnet:master ""` will run `nomadnet` (if we wanted this to be a little more self-explaining, there could be a `--ui` flag which runs the UI and is default-on, so `docker run ghcr.io/markqvist/nomadnet:master --ui` would work)
2022-05-18 08:56:45 +01:00
9 changed files with 144 additions and 36 deletions

View File

@@ -16,9 +16,11 @@ FROM python:3.11-rc-alpine3.14
LABEL org.opencontainers.image.documentation="https://github.com/markqvist/NomadNet#nomad-network-daemon-with-docker" LABEL org.opencontainers.image.documentation="https://github.com/markqvist/NomadNet#nomad-network-daemon-with-docker"
ENV PATH="/opt/venv/bin:$PATH" ENV PATH="/opt/venv/bin:$PATH"
ENV PYTHONUNBUFFERED="yes"
COPY --from=build /opt/venv /opt/venv COPY --from=build /opt/venv /opt/venv
VOLUME /root/.reticulum VOLUME /root/.reticulum
VOLUME /root/.nomadnetwork VOLUME /root/.nomadnetwork
ENTRYPOINT ["nomadnet", "--daemon"] ENTRYPOINT ["nomadnet"]
CMD ["--daemon"]

View File

@@ -59,26 +59,36 @@ You can install Nomad Network on Android using Termux, but there's a few more co
For a native Android application with a graphical user interface, have a look at [Sideband](https://unsigned.io/sideband). For a native Android application with a graphical user interface, have a look at [Sideband](https://unsigned.io/sideband).
### Nomad Network Daemon with Docker ### Docker Images
Nomad Network is automatically published as a docker image on Github Packages. Image tags are one of either `master` (for the latest release) or the version number (eg `0.1.7`) for the specified version number (as tagged in this git repo).
Nomad Network is automatically published as a docker image on Github Packages. Image tags are one of either `master` (for the very latest commit) or the version number (eg `0.1.8`) for a specific release.
```sh ```sh
$ docker pull ghcr.io/markqvist/nomadnet:master $ docker pull ghcr.io/markqvist/nomadnet:master
# Run nomadnet interactively without installing it (with default config) # Run nomadnet interactively in a container
$ docker run -it ghcr.io/markqvist/nomadnet:master $ docker run -it ghcr.io/markqvist/nomadnet:master --textui
# Run nomadnet as a daemon, using config stored on the host machine in specific # Run nomadnet as a daemon, using config stored on the host machine in specified
# directories, and allowing access to specific numbered ports openned by nomadnet # directories, and connect the containers network to the host network (which will
# on the host machine on the same port numbers. # allow the default AutoInterface to automatically peer with other discovered
# Reticulum instances).
$ docker run -d \ $ docker run -d \
-v /local/path/nomadnetconfig/:/root/.nomadnetwork/ \ -v /local/path/nomadnetconfigdir/:/root/.nomadnetwork/ \
-v /local/path/reticulumconfig/:/root/.reticulum/ \ -v /local/path/reticulumconfigdir/:/root/.reticulum/ \
-p 37428:37428 \ --network host
-p 37429:37429 \
ghcr.io/markqvist/nomadnet:master ghcr.io/markqvist/nomadnet:master
# You can also keep the network of the container isolated from the host, but you
# will need to manually configure one or more Reticulum interfaces to reach other
# nodes in a network, by editing the Reticulum configuration file.
$ docker run -d \
-v /local/path/nomadnetconfigdir/:/root/.nomadnetwork/ \
-v /local/path/reticulumconfigdir/:/root/.reticulum/ \
ghcr.io/markqvist/nomadnet:master
# Send daemon log output to console instead of file
$ docker run -i ghcr.io/markqvist/nomadnet:master --daemon --console
``` ```
## Help & Discussion ## Help & Discussion
@@ -88,8 +98,20 @@ For help requests, discussion, sharing ideas or anything else related to Nomad N
## Support Nomad Network ## Support Nomad Network
You can help support the continued development of open, free and private communications systems by donating via one of the following channels: You can help support the continued development of open, free and private communications systems by donating via one of the following channels:
- Ethereum: 0x81F7B979fEa6134bA9FD5c701b3501A2e61E897a - Monero:
- Bitcoin: 3CPmacGm34qYvR6XWLVEJmi2aNe3PZqUuq ```
84FpY1QbxHcgdseePYNmhTHcrgMX4nFf
BYtz2GKYToqHVVhJp8Eaw1Z1EedRnKD1
9b3B8NiLCGVxzKV17UMmmeEsCrPyA5w
```
- Ethereum
```
0x81F7B979fEa6134bA9FD5c701b3501A2e61E897a
```
- Bitcoin
```
3CPmacGm34qYvR6XWLVEJmi2aNe3PZqUuq
```
- Ko-Fi: https://ko-fi.com/markqvist - Ko-Fi: https://ko-fi.com/markqvist
## Caveat Emptor ## Caveat Emptor

View File

@@ -46,7 +46,7 @@ class NomadNetworkApp:
if issubclass(e_type, KeyboardInterrupt): if issubclass(e_type, KeyboardInterrupt):
sys.__excepthook__(e_type, e_value, e_traceback) sys.__excepthook__(e_type, e_value, e_traceback)
def __init__(self, configdir = None, rnsconfigdir = None, daemon = False): def __init__(self, configdir = None, rnsconfigdir = None, daemon = False, force_console = False):
self.version = __version__ self.version = __version__
self.enable_client = False self.enable_client = False
self.enable_node = False self.enable_node = False
@@ -59,6 +59,11 @@ class NomadNetworkApp:
else: else:
self.configdir = configdir self.configdir = configdir
if force_console:
self.force_console_log = True
else:
self.force_console_log = False
if NomadNetworkApp._shared_instance == None: if NomadNetworkApp._shared_instance == None:
NomadNetworkApp._shared_instance = self NomadNetworkApp._shared_instance = self
@@ -195,6 +200,9 @@ class NomadNetworkApp:
"node_last_announce": None, "node_last_announce": None,
"propagation_node": None, "propagation_node": None,
"last_lxmf_sync": 0, "last_lxmf_sync": 0,
"node_connects": 0,
"served_page_requests": 0,
"served_file_requests": 0
} }
self.save_peer_settings() self.save_peer_settings()
RNS.log("Created new peer settings file") RNS.log("Created new peer settings file")
@@ -246,7 +254,18 @@ class NomadNetworkApp:
RNS.log("LXMF Router ready to receive on: "+RNS.prettyhexrep(self.lxmf_destination.hash)) RNS.log("LXMF Router ready to receive on: "+RNS.prettyhexrep(self.lxmf_destination.hash))
if self.enable_node: if self.enable_node:
self.message_router.set_message_storage_limit(gigabytes=self.message_storage_limit)
for dest_str in self.prioritised_lxmf_destinations:
try:
dest_hash = bytes.fromhex(dest_str)
if len(dest_hash) == RNS.Reticulum.TRUNCATED_HASHLENGTH//8:
self.message_router.prioritise(dest_hash)
except Exception as e:
RNS.log("Cannot prioritise "+str(dest_str)+", it is not a valid destination hash", RNS.LOG_ERROR)
self.message_router.enable_propagation() self.message_router.enable_propagation()
RNS.log("LXMF Propagation Node started on: "+RNS.prettyhexrep(self.message_router.propagation_destination.hash)) RNS.log("LXMF Propagation Node started on: "+RNS.prettyhexrep(self.message_router.propagation_destination.hash))
self.node = nomadnet.Node(self) self.node = nomadnet.Node(self)
else: else:
@@ -344,6 +363,10 @@ class NomadNetworkApp:
return "Done, no new messages" return "Done, no new messages"
else: else:
return "Downloaded "+str(new_msgs)+" new messages" return "Downloaded "+str(new_msgs)+" new messages"
elif self.message_router.propagation_transfer_state == LXMF.LXMRouter.PR_NO_IDENTITY_RCVD:
return "Node did not receive identification"
elif self.message_router.propagation_transfer_state == LXMF.LXMRouter.PR_NO_ACCESS:
return "Node did not allow request"
else: else:
return "Unknown" return "Unknown"
@@ -371,7 +394,7 @@ class NomadNetworkApp:
return self.message_router.propagation_transfer_progress return self.message_router.propagation_transfer_progress
def request_lxmf_sync(self, limit = None): def request_lxmf_sync(self, limit = None):
if self.message_router.propagation_transfer_state == LXMF.LXMRouter.PR_IDLE or self.message_router.propagation_transfer_state == LXMF.LXMRouter.PR_COMPLETE: if self.message_router.propagation_transfer_state == LXMF.LXMRouter.PR_IDLE or self.message_router.propagation_transfer_state >= LXMF.LXMRouter.PR_COMPLETE:
self.peer_settings["last_lxmf_sync"] = time.time() self.peer_settings["last_lxmf_sync"] = time.time()
self.save_peer_settings() self.save_peer_settings()
self.message_router.request_messages_from_propagation_node(self.identity, max_messages = limit) self.message_router.request_messages_from_propagation_node(self.identity, max_messages = limit)
@@ -490,7 +513,7 @@ class NomadNetworkApp:
if RNS.loglevel > 7: if RNS.loglevel > 7:
RNS.loglevel = 7 RNS.loglevel = 7
if option == "destination": if option == "destination":
if value.lower() == "file": if value.lower() == "file" and not self.force_console_log:
RNS.logdest = RNS.LOG_FILE RNS.logdest = RNS.LOG_FILE
if "logfile" in self.config["logging"]: if "logfile" in self.config["logging"]:
self.logfilepath = self.config["logging"]["logfile"] self.logfilepath = self.config["logging"]["logfile"]
@@ -641,6 +664,19 @@ class NomadNetworkApp:
if "files_path" in self.config["node"]: if "files_path" in self.config["node"]:
self.filespath = self.config["node"]["files_path"] self.filespath = self.config["node"]["files_path"]
if "prioritise_destinations" in self.config["node"]:
self.prioritised_lxmf_destinations = self.config["node"].as_list("prioritise_destinations")
else:
self.prioritised_lxmf_destinations = []
if not "message_storage_limit" in self.config["node"]:
self.message_storage_limit = 2
else:
value = self.config["node"].as_float("message_storage_limit")
if value < 0.064:
value = 0.064
self.message_storage_limit = value
@staticmethod @staticmethod
def get_shared_instance(): def get_shared_instance():
@@ -751,28 +787,43 @@ editor = editor
# If you don't want the Guide section to # If you don't want the Guide section to
# show up in the menu, you can disable it. # show up in the menu, you can disable it.
hide_guide = no hide_guide = no
[node] [node]
# Whether to enable node hosting # Whether to enable node hosting
enable_node = no enable_node = no
# The node name will be visible to other # The node name will be visible to other
# peers on the network, and included in # peers on the network, and included in
# announces. # announces.
node_name = None node_name = None
# Automatic announce interval in minutes. # Automatic announce interval in minutes.
# 6 hours by default. # 6 hours by default.
announce_interval = 360 announce_interval = 360
# Whether to announce when the node starts # Whether to announce when the node starts.
announce_at_start = Yes announce_at_start = Yes
# The maximum amount of storage to use for
# the LXMF Propagation Node message store,
# specified in gigabytes. When this limit
# is reached, LXMF will periodically remove
# messages in its message store. By default,
# LXMF prioritises keeping messages that are
# new and small. Large and old messages will
# be removed first. This setting is optional
# and defaults to 2 gigabytes.
# message_storage_limit = 2
# You can tell the LXMF message router to
# prioritise storage for one or more
# destinations. If the message store reaches
# the specified limit, LXMF will prioritise
# keeping messages for destinations specified
# with this option. This setting is optional,
# and generally you do not need to use it.
# prioritise_destinations = 10bc7624c27032a18639, ba780a6dff4cc1391db8
'''.splitlines() '''.splitlines()

View File

@@ -1 +1 @@
__version__ = "0.1.8" __version__ = "0.1.9"

View File

@@ -7,15 +7,22 @@ import argparse
import nomadnet import nomadnet
def program_setup(configdir, rnsconfigdir, daemon): def program_setup(configdir, rnsconfigdir, daemon, console):
app = nomadnet.NomadNetworkApp(configdir = configdir, rnsconfigdir = rnsconfigdir, daemon = daemon) app = nomadnet.NomadNetworkApp(
configdir = configdir,
rnsconfigdir = rnsconfigdir,
daemon = daemon,
force_console = console,
)
def main(): def main():
try: try:
parser = argparse.ArgumentParser(description="Nomad Network Client") parser = argparse.ArgumentParser(description="Nomad Network Client")
parser.add_argument("--config", action="store", default=None, help="path to alternative Nomad Network config directory", type=str) parser.add_argument("--config", action="store", default=None, help="path to alternative Nomad Network config directory", type=str)
parser.add_argument("--rnsconfig", action="store", default=None, help="path to alternative Reticulum config directory", type=str) parser.add_argument("--rnsconfig", action="store", default=None, help="path to alternative Reticulum config directory", type=str)
parser.add_argument("-t", "--textui", action="store_true", default=False, help="run Nomad Network in text-UI mode")
parser.add_argument("-d", "--daemon", action="store_true", default=False, help="run Nomad Network in daemon mode") parser.add_argument("-d", "--daemon", action="store_true", default=False, help="run Nomad Network in daemon mode")
parser.add_argument("-c", "--console", action="store_true", default=False, help="in daemon mode, log to console instead of file")
parser.add_argument("--version", action="version", version="Nomad Network Client {version}".format(version=__version__)) parser.add_argument("--version", action="version", version="Nomad Network Client {version}".format(version=__version__))
args = parser.parse_args() args = parser.parse_args()
@@ -30,7 +37,18 @@ def main():
else: else:
rnsconfigarg = None rnsconfigarg = None
program_setup(configarg, rnsconfigarg, args.daemon) console = False
if args.daemon:
daemon = True
if args.console:
console = True
else:
daemon = False
if args.textui:
daemon = False
program_setup(configarg, rnsconfigarg, daemon, console)
except KeyboardInterrupt: except KeyboardInterrupt:
print("") print("")

View File

@@ -10,7 +10,10 @@ class NoneUI:
self.app = NomadNetworkApp.get_shared_instance() self.app = NomadNetworkApp.get_shared_instance()
self.app.ui = self self.app.ui = self
RNS.log("Nomad Network started in daemon mode, all further messages are logged to "+str(self.app.logfilepath), RNS.LOG_INFO, _override_destination=True) if not self.app.force_console_log:
RNS.log("Nomad Network started in daemon mode, all further messages are logged to "+str(self.app.logfilepath), RNS.LOG_INFO, _override_destination=True)
else:
RNS.log("Nomad Network daemon started", RNS.LOG_INFO)
while True: while True:
time.sleep(1) time.sleep(1)

View File

@@ -334,7 +334,7 @@ class ConversationsDisplay():
self.dialog_open = False self.dialog_open = False
self.sync_dialog = None self.sync_dialog = None
self.update_conversation_list() self.update_conversation_list()
if self.app.message_router.propagation_transfer_state == LXMF.LXMRouter.PR_COMPLETE: if self.app.message_router.propagation_transfer_state >= LXMF.LXMRouter.PR_COMPLETE:
self.app.cancel_lxmf_sync() self.app.cancel_lxmf_sync()
max_messages_group = [] max_messages_group = []
@@ -360,7 +360,7 @@ class ConversationsDisplay():
real_sync_button = urwid.Button("Sync Now", on_press=sync_now) real_sync_button = urwid.Button("Sync Now", on_press=sync_now)
hidden_sync_button = urwid.Button("Cancel Sync", on_press=cancel_sync) hidden_sync_button = urwid.Button("Cancel Sync", on_press=cancel_sync)
if self.app.get_sync_status() == "Idle" or self.app.message_router.propagation_transfer_state == LXMF.LXMRouter.PR_COMPLETE: if self.app.get_sync_status() == "Idle" or self.app.message_router.propagation_transfer_state >= LXMF.LXMRouter.PR_COMPLETE:
sync_button = real_sync_button sync_button = real_sync_button
else: else:
sync_button = hidden_sync_button sync_button = hidden_sync_button
@@ -423,7 +423,7 @@ class ConversationsDisplay():
if self.dialog_open and self.sync_dialog != None: if self.dialog_open and self.sync_dialog != None:
self.sync_dialog.sync_progress.set_completion(self.app.get_sync_progress()) self.sync_dialog.sync_progress.set_completion(self.app.get_sync_progress())
if self.app.get_sync_status() == "Idle" or self.app.message_router.propagation_transfer_state == LXMF.LXMRouter.PR_COMPLETE: if self.app.get_sync_status() == "Idle" or self.app.message_router.propagation_transfer_state >= LXMF.LXMRouter.PR_COMPLETE:
self.sync_dialog.bc.contents[0] = (self.sync_dialog.real_sync_button, self.sync_dialog.bc.options("weight", 0.45)) self.sync_dialog.bc.contents[0] = (self.sync_dialog.real_sync_button, self.sync_dialog.bc.options("weight", 0.45))
else: else:
self.sync_dialog.bc.contents[0] = (self.sync_dialog.hidden_sync_button, self.sync_dialog.bc.options("weight", 0.45)) self.sync_dialog.bc.contents[0] = (self.sync_dialog.hidden_sync_button, self.sync_dialog.bc.options("weight", 0.45))

View File

@@ -514,12 +514,12 @@ What color theme to use. Set it to match your terminal theme. Can be either `!da
>> Node Section >> Node Section
This section holds configuration directives related to the node hosting. It is delimited by the `![node]`! header in the configuration file. Available directives, along with their default values, are as follows: This section holds configuration directives related to the node hosting. It is delimited by the `![node]`! header in the configuration file. Available directives, along with example values, are as follows:
>>> >>>
`!enable_node = yes`! `!enable_node = no`!
>>>> >>>>
Determines whether the node server should be started on launch. Must be a boolean value. Determines whether the node server should be started on launch. Must be a boolean value, and is turned off by default.
< <
>>> >>>
@@ -552,6 +552,18 @@ Determines where the node server will look for hosted pages. Must be a readable
Determines where the node server will look for downloadable files. Must be a readable filesystem path. Determines where the node server will look for downloadable files. Must be a readable filesystem path.
< <
>>>
`!message_storage_limit = 2`!
>>>>
Configures the maximum amount of storage, in gigabytes, the LXMF Propagation Node will use to store messages.
<
>>>
`!prioritise_destinations = 10bc7624c27032a18639, ba780a6dff4cc1391db8`!
>>>>
Configures the LXMF Propagation Node to prioritise storing messages for certain destinations. If the message store reaches the specified limit, LXMF will prioritise keeping messages for destinations specified with this option. This setting is optional, and generally you do not need to use it.
<
>Ignoring Destinations >Ignoring Destinations
If you encounter peers or nodes on the network, that you would rather not see in your client, you can add them to the `!~/.nomadnetwork/ignored`! file. To ignore nodes or peers, add one 20-character hexadecimal destination hash per line to the file. To unignore one again, simply remove the corresponding entry from the file and restart Nomad Network. If you encounter peers or nodes on the network, that you would rather not see in your client, you can add them to the `!~/.nomadnetwork/ignored`! file. To ignore nodes or peers, add one 20-character hexadecimal destination hash per line to the file. To unignore one again, simply remove the corresponding entry from the file and restart Nomad Network.

View File

@@ -23,6 +23,6 @@ setuptools.setup(
entry_points= { entry_points= {
'console_scripts': ['nomadnet=nomadnet.nomadnet:main'] 'console_scripts': ['nomadnet=nomadnet.nomadnet:main']
}, },
install_requires=['rns>=0.3.6', 'lxmf>=0.1.6', 'urwid>=2.1.2'], install_requires=['rns>=0.3.8', 'lxmf>=0.1.7', 'urwid>=2.1.2'],
python_requires='>=3.6', python_requires='>=3.6',
) )