From aa0293136475e24d07129f55722ba85d92713dcf Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Sun, 16 May 2021 13:02:46 +0200 Subject: [PATCH] Refactored and documented Reticulum class --- RNS/Identity.py | 2 +- RNS/Reticulum.py | 19 +++++++++++++++++-- RNS/Transport.py | 2 +- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/RNS/Identity.py b/RNS/Identity.py index 170ef18..f65e720 100644 --- a/RNS/Identity.py +++ b/RNS/Identity.py @@ -128,7 +128,7 @@ class Identity: return False @staticmethod - def exitHandler(): + def exit_handler(): Identity.saveKnownDestinations() diff --git a/RNS/Reticulum.py b/RNS/Reticulum.py index 645bd32..dff8884 100755 --- a/RNS/Reticulum.py +++ b/RNS/Reticulum.py @@ -36,6 +36,13 @@ class Reticulum: other programs to use on demand. """ + # The default RNS MTU is 500 bytes. This number has been chosen as + # a balance between compatibility with existing hardware devices + # on one hand, and the ability to use sufficiently high cryptographic + # key sizes on the other. In custom RNS network implementations, it + # is possible to raise this value, but doing so will completely break + # compatibility with all other RNS networks. An identical MTU is a + # prerequisite for peers to communicate in the same network. MTU = 500 HEADER_MAXSIZE = 23 MDU = MTU - HEADER_MAXSIZE @@ -43,6 +50,8 @@ class Reticulum: router = None config = None + # The default configuration path will be expanded to a directory + # named ".reticulum" inside the current users home directory configdir = os.path.expanduser("~")+"/.reticulum" configpath = "" storagepath = "" @@ -50,8 +59,14 @@ class Reticulum: @staticmethod def exit_handler(): - RNS.Transport.exitHandler() - RNS.Identity.exitHandler() + """ + This exit handler is called whenever Reticulum is asked to + shut down, and will in turn call exit handlers in other + classes, saving necessary information to disk and carrying + out cleanup operations. + """ + RNS.Transport.exit_handler() + RNS.Identity.exit_handler() def __init__(self,configdir=None): """ diff --git a/RNS/Transport.py b/RNS/Transport.py index 803bc8f..2e5287e 100755 --- a/RNS/Transport.py +++ b/RNS/Transport.py @@ -1116,7 +1116,7 @@ class Transport: return False @staticmethod - def exitHandler(): + def exit_handler(): RNS.log("Saving packet hashlist to storage...", RNS.LOG_VERBOSE) try: packet_hashlist_path = RNS.Reticulum.storagepath+"/packet_hashlist"