mirror of
https://github.com/markqvist/NomadNet.git
synced 2025-12-17 14:54:26 +01:00
Compare commits
56 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f4e3f1cb46 | ||
|
|
6aca6d671a | ||
|
|
681295a818 | ||
|
|
a4f5b28707 | ||
|
|
e5ec9af77b | ||
|
|
d19fc081f1 | ||
|
|
02a15f1503 | ||
|
|
570b99d814 | ||
|
|
f37ce14822 | ||
|
|
8a1cb25403 | ||
|
|
16ca15c82c | ||
|
|
365a027f9b | ||
|
|
e3074830d6 | ||
|
|
71ff0f9bcd | ||
|
|
78106b3f8c | ||
|
|
dc64ab26d4 | ||
|
|
a8d337a94e | ||
|
|
c1cbc56459 | ||
|
|
7cb53fe170 | ||
|
|
fea602bbcb | ||
|
|
9e9dd2a481 | ||
|
|
ed3596b89a | ||
|
|
84ea13acbd | ||
|
|
bd631f6f5f | ||
|
|
5bcb4a3cec | ||
|
|
1913dff3fd | ||
|
|
0a5663b985 | ||
|
|
0ebdb9c826 | ||
|
|
52dfebcfa2 | ||
|
|
29feb1cab1 | ||
|
|
73fffe519a | ||
|
|
22f18324fc | ||
|
|
0affe9f283 | ||
|
|
dfd87a2119 | ||
|
|
c2f0f969fb | ||
|
|
9244f00e21 | ||
|
|
b1b2a2a302 | ||
|
|
b08ae0cf02 | ||
|
|
730c17c981 | ||
|
|
15a4ec2af9 | ||
|
|
08a9225cc9 | ||
|
|
6a8a146d6a | ||
|
|
70d0b0a32a | ||
|
|
fe0437a2fd | ||
|
|
4fcf37ac86 | ||
|
|
fe257a63c0 | ||
|
|
72cfab3bd2 | ||
|
|
c276c29cd0 | ||
|
|
a7ffd2101b | ||
|
|
d5e3809ba5 | ||
|
|
0cbdb2c395 | ||
|
|
29269de3ab | ||
|
|
cb672565e4 | ||
|
|
10501f6712 | ||
|
|
094a604dd6 | ||
|
|
583b4307fc |
41
README.md
41
README.md
@@ -1,5 +1,4 @@
|
||||
Nomad Network - Communicate Freely
|
||||
==========
|
||||
# Nomad Network - Communicate Freely
|
||||
|
||||
Off-grid, resilient mesh communication with strong encryption, forward secrecy and extreme privacy.
|
||||
|
||||
@@ -26,11 +25,6 @@ If you'd rather want to use an LXMF client with a graphical user interface, you
|
||||
## Current Status
|
||||
The current version of the program should be considered a beta release. The program works well, but there will most probably be bugs and possibly sub-optimal performance in some scenarios. On the other hand, this is the ideal time to have an influence on the direction of the development of Nomad Network. To do so, join the discussion, report bugs and request features here on the GitHub project.
|
||||
|
||||
### Feature roadmap
|
||||
- Network-wide propagated bulletins and discussion threads
|
||||
- Collaborative maps and geospatial information sharing
|
||||
- Facilitation of trade and barter
|
||||
|
||||
## How do I get started?
|
||||
The easiest way to install Nomad Network is via pip:
|
||||
|
||||
@@ -48,23 +42,23 @@ nomadnet --daemon
|
||||
nomadnet --help
|
||||
```
|
||||
|
||||
**Please Note**: If this is the very first time you use pip to install a program on your system, you might need to reboot your system for the program to become available. If you get a "command not found" error or similar when running the program, reboot your system and try again.
|
||||
|
||||
The first time the program is running, you will be presented with the **Guide section**, which contains all the information you need to start using Nomad Network.
|
||||
|
||||
To use Nomad Network on packet radio or LoRa, you will need to configure your Reticulum installation to use any relevant packet radio TNCs or LoRa devices on your system. See the [Reticulum documentation](https://markqvist.github.io/Reticulum/manual/interfaces.html) for info. For a general introduction on how to set up such a system, take a look at [this post](https://unsigned.io/private-messaging-over-lora/).
|
||||
|
||||
If you want to try Nomad Network without building your own physical network, you can connect to the [Unsigned.io RNS Testnet](https://github.com/markqvist/Reticulum#public-testnet) over the Internet, where there is already some Nomad Network and LXMF activity. If you connect to the testnet, you can leave nomadnet running for a while and wait for it to receive announces from other nodes on the network that host pages or services, or you can try connecting directly to some nodes listed here:
|
||||
|
||||
- `464ddc8cd323648ef919a638923b4916` Dublin Hub Testnet Node
|
||||
- `5cda089fc42675bdd904c6d06db87d49` Frankfurt Hub Testnet Node
|
||||
- `abb3ebcd03cb2388a838e70c001291f9` Dublin Hub Testnet Node
|
||||
- `ea6a715f814bdc37e56f80c34da6ad51` Frankfurt Hub Testnet Node
|
||||
|
||||
To browse pages on a node that is not currently known, open the URL dialog in the `Network` section of the program by pressing `Ctrl+U`, paste or enter the address and select `Go` or press enter. Nomadnet will attempt to discover and connect to the requested node.
|
||||
|
||||
**Please Note**: If this is the very first time you use pip to install a program on your system, you might need to reboot your system for the program to become available. If you get a "command not found" error or similar when running the program, reboot your system and try again.
|
||||
|
||||
### Install on Android
|
||||
You can install Nomad Network on Android using Termux, but there's a few more commands involved than the above one-liner. The process is documented in the [Android Installation](https://markqvist.github.io/Reticulum/manual/gettingstartedfast.html#reticulum-on-android) section of the Reticulum Manual. Once the Reticulum has been installed according to the linked documentation, Nomad Network can be installed as usual with pip.
|
||||
|
||||
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://github.com/markqvist/Sideband).
|
||||
|
||||
### Docker Images
|
||||
|
||||
@@ -119,6 +113,29 @@ You can help support the continued development of open, free and private communi
|
||||
```
|
||||
- Ko-Fi: https://ko-fi.com/markqvist
|
||||
|
||||
## Development Roadmap
|
||||
|
||||
- New major features
|
||||
- Network-wide propagated bulletins and discussion threads
|
||||
- Collaborative maps and geospatial information sharing
|
||||
- Facilitation of trade and barter
|
||||
- Minor improvements and fixes
|
||||
- Link status (RSSI and SNR) in conversation or conv list
|
||||
- Ctrl-M shorcut for jumping to menu
|
||||
- Share node with other users / send node info to user
|
||||
- Fix internal editor failing on some OSes with no "editor" alias
|
||||
- Possibly add a required-width header
|
||||
- Improve browser handling of remote link close
|
||||
- Better navigation handling when requests fail (also because of closed links)
|
||||
- Retry failed messages mechanism
|
||||
- Re-arrange buttons to be more consistent
|
||||
- Input field for pages
|
||||
- Post mechanism
|
||||
- Term compatibility notice in readme
|
||||
- Selected icon in conversation list
|
||||
- Possibly a Search Local Nodes function
|
||||
- Possibly add via entry in node info box, next to distance
|
||||
|
||||
## Caveat Emptor
|
||||
Nomad Network is beta software, and should be considered as such. While it has been built with cryptography best-practices very foremost in mind, it _has not_ been externally security audited, and there could very well be privacy-breaking bugs. If you want to help out, or help sponsor an audit, please do get in touch.
|
||||
|
||||
|
||||
@@ -227,6 +227,35 @@ class Conversation:
|
||||
RNS.log("Destination is not known, cannot create LXMF Message.", RNS.LOG_VERBOSE)
|
||||
return False
|
||||
|
||||
def paper_output(self, content="", title=""):
|
||||
if self.send_destination:
|
||||
try:
|
||||
dest = self.send_destination
|
||||
source = self.app.lxmf_destination
|
||||
desired_method = LXMF.LXMessage.PAPER
|
||||
|
||||
lxm = LXMF.LXMessage(dest, source, content, title=title, desired_method=desired_method)
|
||||
qr_code = lxm.as_qr()
|
||||
qr_tmp_path = self.app.tmpfilespath+"/"+str(RNS.hexrep(lxm.hash, delimit=False))
|
||||
qr_code.save(qr_tmp_path)
|
||||
|
||||
print_result = self.app.print_file(qr_tmp_path)
|
||||
os.unlink(qr_tmp_path)
|
||||
|
||||
if print_result:
|
||||
message_path = Conversation.ingest(lxm, self.app, originator=True)
|
||||
self.messages.append(ConversationMessage(message_path))
|
||||
|
||||
return print_result
|
||||
|
||||
except Exception as e:
|
||||
RNS.log("An error occurred while generating paper message, the contained exception was: "+str(e), RNS.LOG_ERROR)
|
||||
return False
|
||||
|
||||
else:
|
||||
RNS.log("Destination is not known, cannot create LXMF Message.", RNS.LOG_VERBOSE)
|
||||
return False
|
||||
|
||||
def message_notification(self, message):
|
||||
if message.state == LXMF.LXMessage.FAILED and hasattr(message, "try_propagation_on_fail") and message.try_propagation_on_fail:
|
||||
RNS.log("Direct delivery of "+str(message)+" failed. Retrying as propagated message.", RNS.LOG_VERBOSE)
|
||||
|
||||
@@ -5,6 +5,29 @@ import time
|
||||
import nomadnet
|
||||
import RNS.vendor.umsgpack as msgpack
|
||||
|
||||
class PNAnnounceHandler:
|
||||
def __init__(self, owner):
|
||||
self.aspect_filter = "lxmf.propagation"
|
||||
self.owner = owner
|
||||
|
||||
def received_announce(self, destination_hash, announced_identity, app_data):
|
||||
try:
|
||||
if type(app_data) == bytes:
|
||||
data = msgpack.unpackb(app_data)
|
||||
|
||||
if data[0] == True:
|
||||
RNS.log("Received active propagation node announce from "+RNS.prettyhexrep(destination_hash))
|
||||
|
||||
associated_peer = RNS.Destination.hash_from_name_and_identity("lxmf.delivery", announced_identity)
|
||||
associated_node = RNS.Destination.hash_from_name_and_identity("nomadnetwork.node", announced_identity)
|
||||
|
||||
self.owner.app.directory.pn_announce_received(destination_hash, app_data, associated_peer, associated_node)
|
||||
self.owner.app.autoselect_propagation_node()
|
||||
|
||||
except Exception as e:
|
||||
RNS.log("Error while evaluating propagation node announce, ignoring announce.", RNS.LOG_DEBUG)
|
||||
RNS.log("The contained exception was: "+str(e), RNS.LOG_DEBUG)
|
||||
|
||||
class Directory:
|
||||
ANNOUNCE_STREAM_MAXLENGTH = 64
|
||||
|
||||
@@ -14,8 +37,6 @@ class Directory:
|
||||
app = nomadnet.NomadNetworkApp.get_shared_instance()
|
||||
|
||||
if not destination_hash in app.ignored_list:
|
||||
destination_hash_text = RNS.hexrep(destination_hash, delimit=False)
|
||||
|
||||
associated_peer = RNS.Destination.hash_from_name_and_identity("lxmf.delivery", announced_identity)
|
||||
|
||||
app.directory.node_announce_received(destination_hash, app_data, associated_peer)
|
||||
@@ -31,6 +52,9 @@ class Directory:
|
||||
self.app = app
|
||||
self.load_from_disk()
|
||||
|
||||
self.pn_announce_handler = PNAnnounceHandler(self)
|
||||
RNS.Transport.register_announce_handler(self.pn_announce_handler)
|
||||
|
||||
|
||||
def save_to_disk(self):
|
||||
try:
|
||||
@@ -90,7 +114,7 @@ class Directory:
|
||||
def lxmf_announce_received(self, source_hash, app_data):
|
||||
if app_data != None:
|
||||
timestamp = time.time()
|
||||
self.announce_stream.insert(0, (timestamp, source_hash, app_data, False))
|
||||
self.announce_stream.insert(0, (timestamp, source_hash, app_data, "peer"))
|
||||
while len(self.announce_stream) > Directory.ANNOUNCE_STREAM_MAXLENGTH:
|
||||
self.announce_stream.pop()
|
||||
|
||||
@@ -100,7 +124,7 @@ class Directory:
|
||||
def node_announce_received(self, source_hash, app_data, associated_peer):
|
||||
if app_data != None:
|
||||
timestamp = time.time()
|
||||
self.announce_stream.insert(0, (timestamp, source_hash, app_data, True))
|
||||
self.announce_stream.insert(0, (timestamp, source_hash, app_data, "node"))
|
||||
while len(self.announce_stream) > Directory.ANNOUNCE_STREAM_MAXLENGTH:
|
||||
self.announce_stream.pop()
|
||||
|
||||
@@ -113,6 +137,27 @@ class Directory:
|
||||
if hasattr(self.app.ui, "main_display"):
|
||||
self.app.ui.main_display.sub_displays.network_display.directory_change_callback()
|
||||
|
||||
def pn_announce_received(self, source_hash, app_data, associated_peer, associated_node):
|
||||
found_node = None
|
||||
for sh in self.directory_entries:
|
||||
if sh == associated_node:
|
||||
found_node = True
|
||||
break
|
||||
|
||||
for e in self.announce_stream:
|
||||
if e[1] == associated_node:
|
||||
found_node = True
|
||||
break
|
||||
|
||||
if not found_node:
|
||||
timestamp = time.time()
|
||||
self.announce_stream.insert(0, (timestamp, source_hash, app_data, "pn"))
|
||||
while len(self.announce_stream) > Directory.ANNOUNCE_STREAM_MAXLENGTH:
|
||||
self.announce_stream.pop()
|
||||
|
||||
if hasattr(self.app.ui, "main_display"):
|
||||
self.app.ui.main_display.sub_displays.network_display.directory_change_callback()
|
||||
|
||||
def remove_announce_with_timestamp(self, timestamp):
|
||||
selected_announce = None
|
||||
for announce in self.announce_stream:
|
||||
@@ -250,11 +295,6 @@ class DirectoryEntry:
|
||||
def __init__(self, source_hash, display_name=None, trust_level=UNKNOWN, hosts_node=False, preferred_delivery=None, identify_on_connect=False):
|
||||
if len(source_hash) == RNS.Identity.TRUNCATED_HASHLENGTH//8:
|
||||
self.source_hash = source_hash
|
||||
|
||||
# TODO: Clean
|
||||
# if display_name == None:
|
||||
# display_name = source_hash
|
||||
|
||||
self.display_name = display_name
|
||||
|
||||
if preferred_delivery == None:
|
||||
|
||||
@@ -98,6 +98,7 @@ class NomadNetworkApp:
|
||||
self.ignoredpath = self.configdir+"/ignored"
|
||||
self.logfilepath = self.configdir+"/logfile"
|
||||
self.errorfilepath = self.configdir+"/errors"
|
||||
self.pnannouncedpath = self.configdir+"/pnannounced"
|
||||
self.storagepath = self.configdir+"/storage"
|
||||
self.identitypath = self.configdir+"/storage/identity"
|
||||
self.cachepath = self.configdir+"/storage/cache"
|
||||
@@ -105,10 +106,12 @@ class NomadNetworkApp:
|
||||
self.conversationpath = self.configdir+"/storage/conversations"
|
||||
self.directorypath = self.configdir+"/storage/directory"
|
||||
self.peersettingspath = self.configdir+"/storage/peersettings"
|
||||
self.tmpfilespath = self.configdir+"/storage/tmp"
|
||||
|
||||
self.pagespath = self.configdir+"/storage/pages"
|
||||
self.filespath = self.configdir+"/storage/files"
|
||||
self.cachepath = self.configdir+"/storage/cache"
|
||||
self.examplespath = self.configdir+"/examples"
|
||||
|
||||
self.downloads_path = os.path.expanduser("~/Downloads")
|
||||
|
||||
@@ -145,6 +148,11 @@ class NomadNetworkApp:
|
||||
if not os.path.isdir(self.cachepath):
|
||||
os.makedirs(self.cachepath)
|
||||
|
||||
if not os.path.isdir(self.tmpfilespath):
|
||||
os.makedirs(self.tmpfilespath)
|
||||
else:
|
||||
self.clear_tmp_dir()
|
||||
|
||||
if os.path.isfile(self.configpath):
|
||||
try:
|
||||
self.config = ConfigObj(self.configpath)
|
||||
@@ -160,6 +168,16 @@ class NomadNetworkApp:
|
||||
RNS.log("Check your configuration file for errors!", RNS.LOG_ERROR)
|
||||
nomadnet.panic()
|
||||
else:
|
||||
if not os.path.isdir(self.examplespath):
|
||||
try:
|
||||
import shutil
|
||||
examplespath = os.path.join(os.path.dirname(__file__), "examples")
|
||||
shutil.copytree(examplespath, self.examplespath, ignore=shutil.ignore_patterns("__pycache__"))
|
||||
|
||||
except Exception as e:
|
||||
RNS.log("Could not copy examples into the "+self.examplespath+" directory.", RNS.LOG_ERROR)
|
||||
RNS.log("The contained exception was: "+str(e), RNS.LOG_ERROR)
|
||||
|
||||
RNS.log("Could not load config file, creating default configuration file...")
|
||||
self.createDefaultConfig()
|
||||
self.firstrun = True
|
||||
@@ -256,7 +274,7 @@ class NomadNetworkApp:
|
||||
RNS.log("The contained exception was: "+str(e), RNS.LOG_DEBUG)
|
||||
|
||||
except Exception as e:
|
||||
RNS.log("Error while fetching loading list of ignored destinations: "+str(e), RNS.LOG_ERROR)
|
||||
RNS.log("Error while loading list of ignored destinations: "+str(e), RNS.LOG_ERROR)
|
||||
|
||||
self.directory = nomadnet.Directory(self)
|
||||
|
||||
@@ -290,11 +308,24 @@ class NomadNetworkApp:
|
||||
RNS.log("Cannot prioritise "+str(dest_str)+", it is not a valid destination hash", RNS.LOG_ERROR)
|
||||
|
||||
self.message_router.enable_propagation()
|
||||
try:
|
||||
with open(self.pnannouncedpath, "wb") as pnf:
|
||||
pnf.write(msgpack.packb(time.time()))
|
||||
pnf.close()
|
||||
except Exception as e:
|
||||
RNS.log("An error ocurred while writing Propagation Node announce timestamp. The contained exception was: "+str(e), RNS.LOG_ERROR)
|
||||
|
||||
RNS.log("LXMF Propagation Node started on: "+RNS.prettyhexrep(self.message_router.propagation_destination.hash))
|
||||
self.node = nomadnet.Node(self)
|
||||
else:
|
||||
self.node = None
|
||||
if os.path.isfile(self.pnannouncedpath):
|
||||
try:
|
||||
RNS.log("Sending indication to peered LXMF Propagation Node that this node is no longer participating", RNS.LOG_DEBUG)
|
||||
self.message_router.disable_propagation()
|
||||
os.unlink(self.pnannouncedpath)
|
||||
except Exception as e:
|
||||
RNS.log("An error ocurred while indicating that this LXMF Propagation Node is no longer participating. The contained exception was: "+str(e), RNS.LOG_ERROR)
|
||||
|
||||
RNS.Transport.register_announce_handler(nomadnet.Conversation)
|
||||
RNS.Transport.register_announce_handler(nomadnet.Directory)
|
||||
@@ -436,8 +467,8 @@ class NomadNetworkApp:
|
||||
def autoselect_propagation_node(self):
|
||||
selected_node = None
|
||||
|
||||
if "propagation_node" in self.peer_settings and self.directory.find(self.peer_settings["propagation_node"]):
|
||||
selected_node = self.directory.find(self.peer_settings["propagation_node"])
|
||||
if "propagation_node" in self.peer_settings and self.peer_settings["propagation_node"] != None:
|
||||
selected_node = self.peer_settings["propagation_node"]
|
||||
else:
|
||||
nodes = self.directory.known_nodes()
|
||||
trusted_nodes = []
|
||||
@@ -450,19 +481,14 @@ class NomadNetworkApp:
|
||||
|
||||
if hops < best_hops:
|
||||
best_hops = hops
|
||||
selected_node = node
|
||||
selected_node = node.source_hash
|
||||
|
||||
if selected_node == None:
|
||||
RNS.log("Could not autoselect a propagation node! LXMF propagation will not be available until a trusted node announces on the network.", RNS.LOG_WARNING)
|
||||
RNS.log("Could not autoselect a propagation node! LXMF propagation will not be available until a trusted node announces on the network, or a propagation node is manually selected.", RNS.LOG_WARNING)
|
||||
else:
|
||||
node_identity = RNS.Identity.recall(selected_node.source_hash)
|
||||
if node_identity != None:
|
||||
propagation_hash = RNS.Destination.hash_from_name_and_identity("lxmf.propagation", node_identity)
|
||||
RNS.log("Selecting "+selected_node.display_name+" "+RNS.prettyhexrep(propagation_hash)+" as default LXMF propagation node", RNS.LOG_INFO)
|
||||
self.message_router.set_outbound_propagation_node(propagation_hash)
|
||||
else:
|
||||
RNS.log("Could not recall identity for autoselected LXMF propagation node "+RNS.prettyhexrep(selected_node.source_hash), RNS.LOG_WARNING)
|
||||
RNS.log("LXMF propagation will not be available until a trusted node announces on the network.", RNS.LOG_WARNING)
|
||||
pn_name_str = ""
|
||||
RNS.log("Selecting "+RNS.prettyhexrep(selected_node)+pn_name_str+" as default LXMF propagation node", RNS.LOG_INFO)
|
||||
self.message_router.set_outbound_propagation_node(selected_node)
|
||||
|
||||
def get_user_selected_propagation_node(self):
|
||||
if "propagation_node" in self.peer_settings:
|
||||
@@ -518,6 +544,26 @@ class NomadNetworkApp:
|
||||
|
||||
return False
|
||||
|
||||
def print_file(self, filename):
|
||||
print_command = self.print_command+" "+filename
|
||||
|
||||
try:
|
||||
return_code = subprocess.call(shlex.split(print_command), stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
|
||||
except Exception as e:
|
||||
RNS.log("An error occurred while executing print command: "+str(print_command), RNS.LOG_ERROR)
|
||||
RNS.log("The contained exception was: "+str(e), RNS.LOG_ERROR)
|
||||
return False
|
||||
|
||||
if return_code == 0:
|
||||
RNS.log("Successfully printed "+str(filename)+" using print command: "+print_command, RNS.LOG_DEBUG)
|
||||
return True
|
||||
|
||||
else:
|
||||
RNS.log("Printing "+str(filename)+" failed using print command: "+print_command, RNS.LOG_DEBUG)
|
||||
return False
|
||||
|
||||
|
||||
def print_message(self, message, received = None):
|
||||
try:
|
||||
template = self.printing_template_msg
|
||||
@@ -551,8 +597,7 @@ class NomadNetworkApp:
|
||||
f.write(output.encode("utf-8"))
|
||||
f.close()
|
||||
|
||||
print_command = "lp -d thermal -o cpi=16 -o lpi=8 "+filename
|
||||
return_code = subprocess.call(shlex.split(print_command), stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
self.print_file(filename)
|
||||
|
||||
os.unlink(filename)
|
||||
|
||||
@@ -580,6 +625,12 @@ class NomadNetworkApp:
|
||||
if os.path.isfile(self.conversationpath + "/" + source_hash + "/unread"):
|
||||
os.unlink(self.conversationpath + "/" + source_hash + "/unread")
|
||||
|
||||
def clear_tmp_dir(self):
|
||||
if os.path.isdir(self.tmpfilespath):
|
||||
for file in os.listdir(self.tmpfilespath):
|
||||
fpath = self.tmpfilespath+"/"+file
|
||||
os.unlink(fpath)
|
||||
|
||||
def createDefaultConfig(self):
|
||||
self.config = ConfigObj(__default_nomadnet_config__)
|
||||
self.config.filename = self.configpath
|
||||
@@ -665,7 +716,7 @@ class NomadNetworkApp:
|
||||
self.config["textui"]["intro_text"] = "Nomad Network"
|
||||
|
||||
if not "editor" in self.config["textui"]:
|
||||
self.config["textui"]["editor"] = "editor"
|
||||
self.config["textui"]["editor"] = "nano"
|
||||
|
||||
if not "glyphs" in self.config["textui"]:
|
||||
self.config["textui"]["glyphs"] = "unicode"
|
||||
@@ -917,10 +968,8 @@ glyphs = unicode
|
||||
# application. On by default.
|
||||
mouse_enabled = True
|
||||
|
||||
# What editor to use for editing text. By
|
||||
# default the operating systems "editor"
|
||||
# alias will be used.
|
||||
editor = editor
|
||||
# What editor to use for editing text.
|
||||
editor = nano
|
||||
|
||||
# If you don't want the Guide section to
|
||||
# show up in the menu, you can disable it.
|
||||
|
||||
@@ -1 +1 @@
|
||||
__version__ = "0.2.2"
|
||||
__version__ = "0.3.3"
|
||||
|
||||
18
nomadnet/examples/messageboard/README.md
Normal file
18
nomadnet/examples/messageboard/README.md
Normal file
@@ -0,0 +1,18 @@
|
||||
# lxmf_messageboard
|
||||
Simple message board that can be hosted on a NomadNet node, messages can be posted by 'conversing' with a unique peer, all messages are then forwarded to the message board.
|
||||
|
||||
## How Do I Use It?
|
||||
A user can submit messages to the message board by initiating a chat with the message board peer, they are assigned a username (based on the first 5 characters of their address) and their messages are added directly to the message board. The message board can be viewed on a page hosted by a NomadNet node.
|
||||
|
||||
An example message board can be found on the reticulum testnet hosted on the SolarExpress Node `<d16df67bff870a8eaa2af6957c5a2d7d>` and the message board peer `<ad713cd3fedf36cc190f0cb89c4be1ff>`
|
||||
|
||||
## How Does It Work?
|
||||
The message board page itself is hosted on a NomadNet node, you can place the message_board.mu into the pages directory. You can then run the message_board.py script which provides the peer that the users can send messages to. The two parts are joined together using umsgpack and a flat file system similar to NomadNet and Reticulum and runs in the background.
|
||||
|
||||
## How Do I Set It Up?
|
||||
* Turn on node hosting in NomadNet
|
||||
* Put the `message_board.mu` file into `pages` directory in the config file for `NomadNet`. Edit the file to customise from the default page.
|
||||
* Run the `message_board.py` script (`python3 message_board.py` either in a `screen` or as a system service), this script uses `NomadNet` and `RNS` libraries and has no additional libraries that need to be installed. Take a note of the message boards address, it is printed on starting the board, you can then place this address in `message_board.mu` file to make it easier for users to interact the board.
|
||||
|
||||
## Credits
|
||||
* This example application was written and contributed by @chengtripp
|
||||
41
nomadnet/examples/messageboard/messageboard.mu
Normal file
41
nomadnet/examples/messageboard/messageboard.mu
Normal file
@@ -0,0 +1,41 @@
|
||||
#!/bin/python3
|
||||
import time
|
||||
import os
|
||||
import RNS.vendor.umsgpack as msgpack
|
||||
|
||||
message_board_peer = 'please_replace'
|
||||
userdir = os.path.expanduser("~")
|
||||
|
||||
if os.path.isdir("/etc/nomadmb") and os.path.isfile("/etc/nomadmb/config"):
|
||||
configdir = "/etc/nomadmb"
|
||||
elif os.path.isdir(userdir+"/.config/nomadmb") and os.path.isfile(userdir+"/.config/nomadmb/config"):
|
||||
configdir = userdir+"/.config/nomadmb"
|
||||
else:
|
||||
configdir = userdir+"/.nomadmb"
|
||||
|
||||
storagepath = configdir+"/storage"
|
||||
if not os.path.isdir(storagepath):
|
||||
os.makedirs(storagepath)
|
||||
|
||||
boardpath = configdir+"/storage/board"
|
||||
|
||||
print('`!`F222`Bddd`cNomadNet Message Board')
|
||||
|
||||
print('-')
|
||||
print('`a`b`f')
|
||||
print("")
|
||||
print("To add a message to the board just converse with the NomadNet Message Board at `[lxmf@{}]".format(message_board_peer))
|
||||
time_string = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time()))
|
||||
print("Last Updated: {}".format(time_string))
|
||||
print("")
|
||||
print('>Messages')
|
||||
print(" Date Time Username Message")
|
||||
f = open(boardpath, "rb")
|
||||
board_contents = msgpack.unpack(f)
|
||||
board_contents.reverse()
|
||||
|
||||
for content in board_contents:
|
||||
print("`a{}".format(content.rstrip()))
|
||||
print("")
|
||||
|
||||
f.close()
|
||||
187
nomadnet/examples/messageboard/messageboard.py
Normal file
187
nomadnet/examples/messageboard/messageboard.py
Normal file
@@ -0,0 +1,187 @@
|
||||
# Simple message board that can be hosted on a NomadNet node, messages can be posted by 'conversing' with a unique peer, all messages are then forwarded to the message board.
|
||||
# https://github.com/chengtripp/lxmf_messageboard
|
||||
|
||||
import RNS
|
||||
import LXMF
|
||||
import os, time
|
||||
from queue import Queue
|
||||
import RNS.vendor.umsgpack as msgpack
|
||||
|
||||
display_name = "NomadNet Message Board"
|
||||
max_messages = 20
|
||||
|
||||
def setup_lxmf():
|
||||
if os.path.isfile(identitypath):
|
||||
identity = RNS.Identity.from_file(identitypath)
|
||||
RNS.log('Loaded identity from file', RNS.LOG_INFO)
|
||||
else:
|
||||
RNS.log('No Primary Identity file found, creating new...', RNS.LOG_INFO)
|
||||
identity = RNS.Identity()
|
||||
identity.to_file(identitypath)
|
||||
|
||||
return identity
|
||||
|
||||
def lxmf_delivery(message):
|
||||
# Do something here with a received message
|
||||
RNS.log("A message was received: "+str(message.content.decode('utf-8')))
|
||||
|
||||
message_content = message.content.decode('utf-8')
|
||||
source_hash_text = RNS.hexrep(message.source_hash, delimit=False)
|
||||
|
||||
#Create username (just first 5 char of your addr)
|
||||
username = source_hash_text[0:5]
|
||||
|
||||
RNS.log('Username: {}'.format(username), RNS.LOG_INFO)
|
||||
|
||||
time_string = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(message.timestamp))
|
||||
new_message = '{} {}: {}\n'.format(time_string, username, message_content)
|
||||
|
||||
# Push message to board
|
||||
# First read message board (if it exists
|
||||
if os.path.isfile(boardpath):
|
||||
f = open(boardpath, "rb")
|
||||
message_board = msgpack.unpack(f)
|
||||
f.close()
|
||||
else:
|
||||
message_board = []
|
||||
|
||||
#Check we aren't doubling up (this can sometimes happen if there is an error initially and it then gets fixed)
|
||||
if new_message not in message_board:
|
||||
# Append our new message to the list
|
||||
message_board.append(new_message)
|
||||
|
||||
# Prune the message board if needed
|
||||
while len(message_board) > max_messages:
|
||||
RNS.log('Pruning Message Board')
|
||||
message_board.pop(0)
|
||||
|
||||
# Now open the board and write the updated list
|
||||
f = open(boardpath, "wb")
|
||||
msgpack.pack(message_board, f)
|
||||
f.close()
|
||||
|
||||
# Send reply
|
||||
message_reply = '{}_{}_Your message has been added to the messageboard'.format(source_hash_text, time.time())
|
||||
q.put(message_reply)
|
||||
|
||||
def announce_now(lxmf_destination):
|
||||
lxmf_destination.announce()
|
||||
|
||||
def send_message(destination_hash, message_content):
|
||||
try:
|
||||
# Make a binary destination hash from a hexadecimal string
|
||||
destination_hash = bytes.fromhex(destination_hash)
|
||||
|
||||
except Exception as e:
|
||||
RNS.log("Invalid destination hash", RNS.LOG_ERROR)
|
||||
return
|
||||
|
||||
# Check that size is correct
|
||||
if not len(destination_hash) == RNS.Reticulum.TRUNCATED_HASHLENGTH//8:
|
||||
RNS.log("Invalid destination hash length", RNS.LOG_ERROR)
|
||||
|
||||
else:
|
||||
# Length of address was correct, let's try to recall the
|
||||
# corresponding Identity
|
||||
destination_identity = RNS.Identity.recall(destination_hash)
|
||||
|
||||
if destination_identity == None:
|
||||
# No path/identity known, we'll have to abort or request one
|
||||
RNS.log("Could not recall an Identity for the requested address. You have probably never received an announce from it. Try requesting a path from the network first. In fact, let's do this now :)", RNS.LOG_ERROR)
|
||||
RNS.Transport.request_path(destination_hash)
|
||||
RNS.log("OK, a path was requested. If the network knows a path, you will receive an announce with the Identity data shortly.", RNS.LOG_INFO)
|
||||
|
||||
else:
|
||||
# We know the identity for the destination hash, let's
|
||||
# reconstruct a destination object.
|
||||
lxmf_destination = RNS.Destination(destination_identity, RNS.Destination.OUT, RNS.Destination.SINGLE, "lxmf", "delivery")
|
||||
|
||||
# Create a new message object
|
||||
lxm = LXMF.LXMessage(lxmf_destination, local_lxmf_destination, message_content, title="Reply", desired_method=LXMF.LXMessage.DIRECT)
|
||||
|
||||
# You can optionally tell LXMF to try to send the message
|
||||
# as a propagated message if a direct link fails
|
||||
lxm.try_propagation_on_fail = True
|
||||
|
||||
# Send it
|
||||
message_router.handle_outbound(lxm)
|
||||
|
||||
def announce_check():
|
||||
if os.path.isfile(announcepath):
|
||||
f = open(announcepath, "r")
|
||||
announce = int(f.readline())
|
||||
f.close()
|
||||
else:
|
||||
RNS.log('failed to open announcepath', RNS.LOG_DEBUG)
|
||||
announce = 1
|
||||
|
||||
if announce > int(time.time()):
|
||||
RNS.log('Recent announcement', RNS.LOG_DEBUG)
|
||||
else:
|
||||
f = open(announcepath, "w")
|
||||
next_announce = int(time.time()) + 1800
|
||||
f.write(str(next_announce))
|
||||
f.close()
|
||||
announce_now(local_lxmf_destination)
|
||||
RNS.log('Announcement sent, expr set 1800 seconds', RNS.LOG_INFO)
|
||||
|
||||
#Setup Paths and Config Files
|
||||
userdir = os.path.expanduser("~")
|
||||
|
||||
if os.path.isdir("/etc/nomadmb") and os.path.isfile("/etc/nomadmb/config"):
|
||||
configdir = "/etc/nomadmb"
|
||||
elif os.path.isdir(userdir+"/.config/nomadmb") and os.path.isfile(userdir+"/.config/nomadmb/config"):
|
||||
configdir = userdir+"/.config/nomadmb"
|
||||
else:
|
||||
configdir = userdir+"/.nomadmb"
|
||||
|
||||
storagepath = configdir+"/storage"
|
||||
if not os.path.isdir(storagepath):
|
||||
os.makedirs(storagepath)
|
||||
|
||||
identitypath = configdir+"/storage/identity"
|
||||
announcepath = configdir+"/storage/announce"
|
||||
boardpath = configdir+"/storage/board"
|
||||
|
||||
# Message Queue
|
||||
q = Queue(maxsize = 5)
|
||||
|
||||
# Start Reticulum and print out all the debug messages
|
||||
reticulum = RNS.Reticulum(loglevel=RNS.LOG_VERBOSE)
|
||||
|
||||
# Create a Identity.
|
||||
current_identity = setup_lxmf()
|
||||
|
||||
# Init the LXMF router
|
||||
message_router = LXMF.LXMRouter(identity = current_identity, storagepath = configdir)
|
||||
|
||||
# Register a delivery destination (for yourself)
|
||||
# In this example we use the same Identity as we used
|
||||
# to instantiate the LXMF router. It could be a different one,
|
||||
# but it can also just be the same, depending on what you want.
|
||||
local_lxmf_destination = message_router.register_delivery_identity(current_identity, display_name=display_name)
|
||||
|
||||
# Set a callback for when a message is received
|
||||
message_router.register_delivery_callback(lxmf_delivery)
|
||||
|
||||
# Announce node properties
|
||||
|
||||
RNS.log('LXMF Router ready to receive on: {}'.format(RNS.prettyhexrep(local_lxmf_destination.hash)), RNS.LOG_INFO)
|
||||
announce_check()
|
||||
|
||||
while True:
|
||||
|
||||
# Work through internal message queue
|
||||
for i in list(q.queue):
|
||||
message_id = q.get()
|
||||
split_message = message_id.split('_')
|
||||
destination_hash = split_message[0]
|
||||
message = split_message[2]
|
||||
RNS.log('{} {}'.format(destination_hash, message), RNS.LOG_INFO)
|
||||
send_message(destination_hash, message)
|
||||
|
||||
# Check whether we need to make another announcement
|
||||
announce_check()
|
||||
|
||||
#Sleep
|
||||
time.sleep(10)
|
||||
@@ -121,7 +121,9 @@ GLYPHS = {
|
||||
("decoration_menu", " +", " +", " \uf93a"),
|
||||
("unread_menu", " !", " \u2709", urm_char),
|
||||
("globe", "", "", "\uf484"),
|
||||
("sent", "/\\", "\u2191", "\ufbf4")
|
||||
("sent", "/\\", "\u2191", "\ufbf4"),
|
||||
("papermsg", "P", "\u25a4", "\uf719"),
|
||||
("qrcode", "QR", "\u25a4", "\uf029"),
|
||||
}
|
||||
|
||||
class TextUI:
|
||||
|
||||
@@ -26,13 +26,32 @@ class BrowserFrame(urwid.Frame):
|
||||
elif key == "ctrl g":
|
||||
nomadnet.NomadNetworkApp.get_shared_instance().ui.main_display.sub_displays.network_display.toggle_fullscreen()
|
||||
elif self.get_focus() == "body":
|
||||
if key == "down" or key == "up":
|
||||
try:
|
||||
if hasattr(self.delegate, "page_pile") and self.delegate.page_pile:
|
||||
def df(loop, user_data):
|
||||
st = None
|
||||
nf = self.delegate.page_pile.get_focus()
|
||||
if hasattr(nf, "key_timeout"):
|
||||
st = nf
|
||||
elif hasattr(nf, "original_widget"):
|
||||
no = nf.original_widget
|
||||
if hasattr(no, "original_widget"):
|
||||
st = no.original_widget
|
||||
else:
|
||||
if hasattr(no, "key_timeout"):
|
||||
st = no
|
||||
|
||||
if st and hasattr(st, "key_timeout") and hasattr(st, "keypress") and callable(st.keypress):
|
||||
st.keypress(None, None)
|
||||
|
||||
nomadnet.NomadNetworkApp.get_shared_instance().ui.loop.set_alarm_in(0.25, df)
|
||||
|
||||
except Exception as e:
|
||||
RNS.log("Error while setting up cursor timeout. The contained exception was: "+str(e), RNS.LOG_ERROR)
|
||||
|
||||
return super(BrowserFrame, self).keypress(size, key)
|
||||
# if key == "up" and self.delegate.messagelist.top_is_visible:
|
||||
# nomadnet.NomadNetworkApp.get_shared_instance().ui.main_display.frame.set_focus("header")
|
||||
# elif key == "down" and self.delegate.messagelist.bottom_is_visible:
|
||||
# self.set_focus("footer")
|
||||
# else:
|
||||
# return super(ConversationFrame, self).keypress(size, key)
|
||||
|
||||
else:
|
||||
return super(BrowserFrame, self).keypress(size, key)
|
||||
|
||||
@@ -80,6 +99,7 @@ class Browser:
|
||||
self.link_target = None
|
||||
self.frame = None
|
||||
self.attr_maps = []
|
||||
self.page_pile = None
|
||||
self.build_display()
|
||||
|
||||
self.history = []
|
||||
@@ -155,6 +175,7 @@ class Browser:
|
||||
if destination_type == "nomadnetwork.node":
|
||||
if self.status >= Browser.DISCONECTED:
|
||||
RNS.log("Browser handling link to: "+str(link_target), RNS.LOG_DEBUG)
|
||||
self.browser_footer = urwid.Text("Opening link to: "+str(link_target))
|
||||
try:
|
||||
self.retrieve_url(link_target)
|
||||
except Exception as e:
|
||||
@@ -219,6 +240,7 @@ class Browser:
|
||||
self.browser_header = urwid.Text("")
|
||||
self.browser_footer = urwid.Text("")
|
||||
|
||||
self.page_pile = None
|
||||
self.browser_body = urwid.Filler(urwid.Text("Disconnected\n"+self.g["arrow_l"]+" "+self.g["arrow_r"], align="center"), "middle")
|
||||
|
||||
self.frame = BrowserFrame(self.browser_body, header=self.browser_header, footer=self.browser_footer)
|
||||
@@ -266,6 +288,7 @@ class Browser:
|
||||
def update_display(self):
|
||||
if self.status == Browser.DISCONECTED:
|
||||
self.display_widget.set_attr_map({None: "inactive_text"})
|
||||
self.page_pile = None
|
||||
self.browser_body = urwid.Filler(urwid.Text("Disconnected\n"+self.g["arrow_l"]+" "+self.g["arrow_r"], align="center"), "middle")
|
||||
self.browser_footer = urwid.Text("")
|
||||
self.browser_header = urwid.Text("")
|
||||
@@ -314,6 +337,8 @@ class Browser:
|
||||
|
||||
def update_page_display(self):
|
||||
pile = urwid.Pile(self.attr_maps)
|
||||
pile.automove_cursor_on_scroll = True
|
||||
self.page_pile = pile
|
||||
self.browser_body = urwid.AttrMap(ScrollBar(Scrollable(pile, force_forward_keypress=True), thumb_char="\u2503", trough_char=" "), "scrollbar")
|
||||
|
||||
def identify(self):
|
||||
|
||||
@@ -14,13 +14,13 @@ class ConversationListDisplayShortcuts():
|
||||
def __init__(self, app):
|
||||
self.app = app
|
||||
|
||||
self.widget = urwid.AttrMap(urwid.Text("[C-e] Peer Info [C-x] Delete [C-r] Sync [C-n] New [C-g] Fullscreen"), "shortcutbar")
|
||||
self.widget = urwid.AttrMap(urwid.Text("[C-e] Peer Info [C-x] Delete [C-r] Sync [C-n] New [C-u] Ingest URI [C-g] Fullscreen"), "shortcutbar")
|
||||
|
||||
class ConversationDisplayShortcuts():
|
||||
def __init__(self, app):
|
||||
self.app = app
|
||||
|
||||
self.widget = urwid.AttrMap(urwid.Text("[C-d] Send [C-k] Clear [C-w] Close [C-t] Title [C-p] Purge [C-x] Clear History [C-o] Sort"), "shortcutbar")
|
||||
self.widget = urwid.AttrMap(urwid.Text("[C-d] Send [C-p] Paper Msg [C-t] Title [C-k] Clear [C-w] Close [C-u] Purge [C-x] Clear History [C-o] Sort"), "shortcutbar")
|
||||
|
||||
class ConversationsArea(urwid.LineBox):
|
||||
def keypress(self, size, key):
|
||||
@@ -30,6 +30,8 @@ class ConversationsArea(urwid.LineBox):
|
||||
self.delegate.delete_selected_conversation()
|
||||
elif key == "ctrl n":
|
||||
self.delegate.new_conversation()
|
||||
elif key == "ctrl u":
|
||||
self.delegate.ingest_lxm_uri()
|
||||
elif key == "ctrl r":
|
||||
self.delegate.sync_conversations()
|
||||
elif key == "ctrl g":
|
||||
@@ -330,6 +332,110 @@ class ConversationsDisplay():
|
||||
options = self.columns_widget.options("given", ConversationsDisplay.given_list_width)
|
||||
self.columns_widget.contents[0] = (overlay, options)
|
||||
|
||||
def ingest_lxm_uri(self):
|
||||
self.dialog_open = True
|
||||
lxm_uri = ""
|
||||
e_uri = urwid.Edit(caption="URI : ",edit_text=lxm_uri)
|
||||
|
||||
def dismiss_dialog(sender):
|
||||
self.update_conversation_list()
|
||||
self.dialog_open = False
|
||||
|
||||
def confirmed(sender):
|
||||
try:
|
||||
local_delivery_signal = "local_delivery_occurred"
|
||||
duplicate_signal = "duplicate_lxm"
|
||||
lxm_uri = e_uri.get_edit_text()
|
||||
|
||||
ingest_result = self.app.message_router.ingest_lxm_uri(
|
||||
lxm_uri,
|
||||
signal_local_delivery=local_delivery_signal,
|
||||
signal_duplicate=duplicate_signal
|
||||
)
|
||||
|
||||
if ingest_result == False:
|
||||
raise ValueError("The URI contained no decodable messages")
|
||||
|
||||
elif ingest_result == local_delivery_signal:
|
||||
rdialog_pile = urwid.Pile([
|
||||
urwid.Text("Message was decoded, decrypted successfully, and added to your conversation list."),
|
||||
urwid.Text(""),
|
||||
urwid.Columns([("weight", 0.6, urwid.Text("")), ("weight", 0.4, urwid.Button("OK", on_press=dismiss_dialog))])
|
||||
])
|
||||
rdialog_pile.error_display = False
|
||||
|
||||
rdialog = DialogLineBox(rdialog_pile, title="Ingest message URI")
|
||||
rdialog.delegate = self
|
||||
bottom = self.listbox
|
||||
|
||||
roverlay = urwid.Overlay(rdialog, bottom, align="center", width=("relative", 100), valign="middle", height="pack", left=2, right=2)
|
||||
|
||||
options = self.columns_widget.options("given", ConversationsDisplay.given_list_width)
|
||||
self.columns_widget.contents[0] = (roverlay, options)
|
||||
|
||||
elif ingest_result == duplicate_signal:
|
||||
rdialog_pile = urwid.Pile([
|
||||
urwid.Text("The decoded message has already been processed by the LXMF Router, and will not be ingested again."),
|
||||
urwid.Text(""),
|
||||
urwid.Columns([("weight", 0.6, urwid.Text("")), ("weight", 0.4, urwid.Button("OK", on_press=dismiss_dialog))])
|
||||
])
|
||||
rdialog_pile.error_display = False
|
||||
|
||||
rdialog = DialogLineBox(rdialog_pile, title="Ingest message URI")
|
||||
rdialog.delegate = self
|
||||
bottom = self.listbox
|
||||
|
||||
roverlay = urwid.Overlay(rdialog, bottom, align="center", width=("relative", 100), valign="middle", height="pack", left=2, right=2)
|
||||
|
||||
options = self.columns_widget.options("given", ConversationsDisplay.given_list_width)
|
||||
self.columns_widget.contents[0] = (roverlay, options)
|
||||
|
||||
else:
|
||||
if self.app.enable_node:
|
||||
propagation_text = "The decoded message was not addressed to this LXMF address, but has been added to the propagation node queues, and will be distributed on the propagation network."
|
||||
else:
|
||||
propagation_text = "The decoded message was not addressed to this LXMF address, and has been discarded."
|
||||
|
||||
rdialog_pile = urwid.Pile([
|
||||
urwid.Text(propagation_text),
|
||||
urwid.Text(""),
|
||||
urwid.Columns([("weight", 0.6, urwid.Text("")), ("weight", 0.4, urwid.Button("OK", on_press=dismiss_dialog))])
|
||||
])
|
||||
rdialog_pile.error_display = False
|
||||
|
||||
rdialog = DialogLineBox(rdialog_pile, title="Ingest message URI")
|
||||
rdialog.delegate = self
|
||||
bottom = self.listbox
|
||||
|
||||
roverlay = urwid.Overlay(rdialog, bottom, align="center", width=("relative", 100), valign="middle", height="pack", left=2, right=2)
|
||||
|
||||
options = self.columns_widget.options("given", ConversationsDisplay.given_list_width)
|
||||
self.columns_widget.contents[0] = (roverlay, options)
|
||||
|
||||
except Exception as e:
|
||||
RNS.log("Could not ingest LXM URI. The contained exception was: "+str(e), RNS.LOG_VERBOSE)
|
||||
if not dialog_pile.error_display:
|
||||
dialog_pile.error_display = True
|
||||
options = dialog_pile.options(height_type="pack")
|
||||
dialog_pile.contents.append((urwid.Text(""), options))
|
||||
dialog_pile.contents.append((urwid.Text(("error_text", "Could ingest LXM from URI data. Check your input."), align="center"), options))
|
||||
|
||||
dialog_pile = urwid.Pile([
|
||||
e_uri,
|
||||
urwid.Text(""),
|
||||
urwid.Columns([("weight", 0.45, urwid.Button("Ingest", on_press=confirmed)), ("weight", 0.1, urwid.Text("")), ("weight", 0.45, urwid.Button("Back", on_press=dismiss_dialog))])
|
||||
])
|
||||
dialog_pile.error_display = False
|
||||
|
||||
dialog = DialogLineBox(dialog_pile, title="Ingest message URI")
|
||||
dialog.delegate = self
|
||||
bottom = self.listbox
|
||||
|
||||
overlay = urwid.Overlay(dialog, bottom, align="center", width=("relative", 100), valign="middle", height="pack", left=2, right=2)
|
||||
|
||||
options = self.columns_widget.options("given", ConversationsDisplay.given_list_width)
|
||||
self.columns_widget.contents[0] = (overlay, options)
|
||||
|
||||
def delete_conversation(self, source_hash):
|
||||
if source_hash in ConversationsDisplay.cached_conversation_widgets:
|
||||
conversation = ConversationsDisplay.cached_conversation_widgets[source_hash]
|
||||
@@ -398,10 +504,15 @@ class ConversationsDisplay():
|
||||
if pn_ident != None:
|
||||
node_hash = RNS.Destination.hash_from_name_and_identity("nomadnetwork.node", pn_ident)
|
||||
pn_entry = self.app.directory.find(node_hash)
|
||||
pn_display_str = " "
|
||||
if pn_entry != None:
|
||||
pn_display_str += " "+str(pn_entry.display_name)
|
||||
else:
|
||||
pn_display_str += " "+RNS.prettyhexrep(pn_hash)
|
||||
|
||||
dialog = DialogLineBox(
|
||||
urwid.Pile([
|
||||
urwid.Text(""+g["node"]+" "+str(pn_entry.display_name), align="center"),
|
||||
urwid.Text(""+g["node"]+pn_display_str, align="center"),
|
||||
urwid.Divider(g["divider1"]),
|
||||
sync_progress,
|
||||
urwid.Divider(g["divider1"]),
|
||||
@@ -417,7 +528,7 @@ class ConversationsDisplay():
|
||||
urwid.Pile([
|
||||
urwid.Text(""),
|
||||
urwid.Text("No trusted nodes found, cannot sync!\n", align="center"),
|
||||
urwid.Text("To syncronise messages from the network, one or more nodes must be marked as trusted in the Known Nodes list. Nomad Network will then automatically sync from the nearest trusted node.", align="left"),
|
||||
urwid.Text("To syncronise messages from the network, one or more nodes must be marked as trusted in the Known Nodes list, or a node must manually be selected as the default propagation node. Nomad Network will then automatically sync from the nearest trusted node, or the manually selected one.", align="left"),
|
||||
urwid.Text(""),
|
||||
button_columns
|
||||
]), title="Message Sync"
|
||||
@@ -631,6 +742,8 @@ class MessageEdit(urwid.Edit):
|
||||
def keypress(self, size, key):
|
||||
if key == "ctrl d":
|
||||
self.delegate.send_message()
|
||||
elif key == "ctrl p":
|
||||
self.delegate.paper_message()
|
||||
elif key == "ctrl k":
|
||||
self.delegate.clear_editor()
|
||||
elif key == "up":
|
||||
@@ -795,7 +908,7 @@ class ConversationWidget(urwid.WidgetWrap):
|
||||
self.toggle_focus_area()
|
||||
elif key == "ctrl w":
|
||||
self.close()
|
||||
elif key == "ctrl p":
|
||||
elif key == "ctrl u":
|
||||
self.conversation.purge_failed()
|
||||
self.conversation_changed(None)
|
||||
elif key == "ctrl t":
|
||||
@@ -855,6 +968,34 @@ class ConversationWidget(urwid.WidgetWrap):
|
||||
else:
|
||||
pass
|
||||
|
||||
def paper_message(self):
|
||||
content = self.content_editor.get_edit_text()
|
||||
title = self.title_editor.get_edit_text()
|
||||
if not content == "":
|
||||
if self.conversation.paper_output(content, title):
|
||||
self.clear_editor()
|
||||
else:
|
||||
self.paper_message_failed()
|
||||
|
||||
def paper_message_failed(self):
|
||||
def dismiss_dialog(sender):
|
||||
self.dialog_open = False
|
||||
self.conversation_changed(None)
|
||||
|
||||
dialog = DialogLineBox(
|
||||
urwid.Pile([
|
||||
urwid.Text("Could not output paper message,\ncheck your settings. See the log\nfile for any error messages.\n", align="center"),
|
||||
urwid.Columns([("weight", 0.6, urwid.Text("")), ("weight", 0.4, urwid.Button("OK", on_press=dismiss_dialog))])
|
||||
]), title="!"
|
||||
)
|
||||
dialog.delegate = self
|
||||
bottom = self.messagelist
|
||||
|
||||
overlay = urwid.Overlay(dialog, bottom, align="center", width=34, valign="middle", height="pack", left=2, right=2)
|
||||
|
||||
self.frame.contents["body"] = (overlay, self.frame.options())
|
||||
self.frame.set_focus("body")
|
||||
|
||||
def close(self):
|
||||
self.delegate.close_conversation(self)
|
||||
|
||||
@@ -885,6 +1026,9 @@ class LXMessageWidget(urwid.WidgetWrap):
|
||||
elif message.lxm.method == LXMF.LXMessage.PROPAGATED and message.lxm.state == LXMF.LXMessage.SENT:
|
||||
header_style = "msg_header_propagated"
|
||||
title_string = g["sent"]+" "+title_string
|
||||
elif message.lxm.method == LXMF.LXMessage.PAPER and message.lxm.state == LXMF.LXMessage.PAPER:
|
||||
header_style = "msg_header_propagated"
|
||||
title_string = g["papermsg"]+" "+title_string
|
||||
elif message.lxm.state == LXMF.LXMessage.SENT:
|
||||
header_style = "msg_header_sent"
|
||||
title_string = g["sent"]+" "+title_string
|
||||
|
||||
@@ -272,7 +272,7 @@ In the `![ Conversations ]`! part of the program you can view and interact with
|
||||
|
||||
By default, Nomad Network will attempt to deliver messages to a peer directly. This happens by first establishing an encrypted link directly to the peer, and then delivering the message over it.
|
||||
|
||||
If the desired peer is not available because it has disconnected from the network, this method will obviously fail. In this case, Nomad Network will attempt to deliver the message to a node, which will store and forward it over the network, for later retrieval by the destination peer. The message is encrypted with an ephemeral key before being transmitted to the network, and is only readable by the intended recipient.
|
||||
If the desired peer is not available because it has disconnected from the network, this method will obviously fail. In this case, Nomad Network will attempt to deliver the message to a node, which will store and forward it over the network, for later retrieval by the destination peer. The message is encrypted before being transmitted to the network, and is only readable by the intended recipient.
|
||||
|
||||
For propagated delivery to work, one or more nodes must be available on the network. If one or more trusted nodes are available, Nomad Network will automatically select the most suitable node to send the message via, but you can also manually specify what node to use.
|
||||
|
||||
@@ -312,14 +312,22 @@ The distributed message store is resilient to intermittency, and will remain fun
|
||||
|
||||
>>Pages
|
||||
|
||||
Nomad Network nodes can host pages similar to web pages, that other peers can read and interact with. Pages are written in a compact markup language called `*micron`*. To learn how to write formatted pages with micron, see the `*Markup`* section of this guide (which is, itself, written in micron). Pages can be linked arbitrarily with hyperlinks, that can also link to pages (or other resources) on other nodes.
|
||||
Nomad Network nodes can host pages similar to web pages, that other peers can read and interact with. Pages are written in a compact markup language called `*micron`*. To learn how to write formatted pages with micron, see the `*Markup`* section of this guide (which is, itself, written in micron). Pages can be linked together with hyperlinks, that can also link to pages (or other resources) on other nodes.
|
||||
|
||||
To add pages to your node, place micron files in the `*pages`* directory of your Nomad Network programs `*storage`* directory. By default, the path to this will be `!~/.nomadnetwork/storage/pages`!. You should probably create the file `!index.mu`! first, as this is the page that will get served by default to a connecting peer.
|
||||
|
||||
You can control how long a peer will cache your pages by including the cache header in a page. To do so, the first line of your page must start with `!#!c=X`!, where `!X`! is the cache time in seconds. To tell the peer to always load the page from your node, and never cache it, set the cache time to zero. You should only do this if there is a real need, for example if your page displays dynamic content that `*must`* be updated at every page view. The default caching time is 12 hours. In most cases, you should not need to include the cache control header in your pages.
|
||||
|
||||
>> Dynamic Pages
|
||||
|
||||
You can use a preprocessor such as PHP, bash, Python (or whatever you prefer) to generate dynamic pages. To do so, just set executable permissions on the relevant page file, and be sure to include the interpreter at the beginning of the file, for example `!#!/usr/bin/python3`!.
|
||||
|
||||
In the `!examples`! directory, you can find various small examples for the use of this feature. The currently included examples are:
|
||||
|
||||
- A messageboard that receives messages over LXMF, contributed by trippcheng
|
||||
|
||||
By default, you can find the examples in `!~/.nomadnetwork/examples`!. If you build something neat, that you feel would fit here, you are more than welcome to contribute it.
|
||||
|
||||
>>Authenticating Users
|
||||
|
||||
Sometimes, you don't want everyone to be able to view certain pages or execute certain scripts. In such cases, you can use `*authentication`* to control who gets to run certain requests.
|
||||
@@ -330,9 +338,9 @@ For each user allowed to access the page, add a line to this file, containing th
|
||||
|
||||
`Faaa
|
||||
`=
|
||||
24c2dc2248953e0a3c21
|
||||
564a476410f4fca2ae93
|
||||
8bb864743f12f53395a1
|
||||
d454bcdac0e64fb68ba8e267543ae110
|
||||
2b9ff3fb5902c9ca5ff97bdfb239ef50
|
||||
7106d5abbc7208bfb171f2dd84b36490
|
||||
`=
|
||||
``
|
||||
|
||||
@@ -348,7 +356,7 @@ Like pages, you can place files you want to make available in the `!~/.nomadnetw
|
||||
|
||||
Links to pages and resources in Nomad Network use a simple URL format. Here is an example:
|
||||
|
||||
`!1385edace36466a6b3dd:/page/index.mu`!
|
||||
`!18176ffddcc8cce1ddf8e3f72068f4a6:/page/index.mu`!
|
||||
|
||||
The first part is the 10 byte destination address of the node (represented as readable hexadecimal), followed by the `!:`! character. Everything after the `!:`! represents the request path.
|
||||
|
||||
@@ -670,25 +678,25 @@ For future reference, you can download the Reticulum Manual in PDF format here:
|
||||
|
||||
It might be nice to keep that handy when you are not connected to the Internet, as it is full of information and examples that are also very relevant to Nomad Network.
|
||||
|
||||
>The Unsigned.io Testnet
|
||||
>The Reticulum Testnet
|
||||
|
||||
If you have Internet access, and just want to get started experimenting, you are welcome to join the Unsigned.io RNS Testnet. The testnet is just that, an informal network for testing and experimenting. It will be up most of the time, and anyone can join, but it also means that there's no guarantees for service availability.
|
||||
|
||||
The Testnet also runs the latest version of Reticulum, often even a short while before it is publicly released, which means strange behaviour might occur. If none of that scares you, add the following interface to your Reticulum configuration file to join:
|
||||
|
||||
>>
|
||||
[[RNS Testnet Frankfurt]]
|
||||
[[RNS Testnet Zurich]]
|
||||
type = TCPClientInterface
|
||||
interface_enabled = yes
|
||||
outgoing = True
|
||||
target_host = frankfurt.rns.unsigned.io
|
||||
target_port = 4965
|
||||
target_host = zurich.connect.reticulum.network
|
||||
target_port = 4242
|
||||
<
|
||||
|
||||
If you connect to the testnet, you can leave nomadnet running for a while and wait for it to receive announces from other nodes on the network that host pages or services, or you can try connecting directly to some nodes listed here:
|
||||
|
||||
- Dublin Hub Testnet Node : `!`[464ddc8cd323648ef919a638923b4916]`!
|
||||
- Frankfurt Hub Testnet Node : `!`[5cda089fc42675bdd904c6d06db87d49]`!
|
||||
- Dublin Hub Testnet Node : `!`[abb3ebcd03cb2388a838e70c001291f9]`!
|
||||
- Frankfurt Hub Testnet Node : `!`[ea6a715f814bdc37e56f80c34da6ad51]`!
|
||||
|
||||
To browse pages on a node that is not currently known, open the URL dialog in the `![ Network ]`! section of the program by pressing `!Ctrl+U`!, paste or enter the address and select `!< Go >`! or press enter. Nomadnet will attempt to discover and connect to the requested node. You can save the currently connected node by pressing `!Ctrl+S`!.
|
||||
'''
|
||||
|
||||
@@ -140,6 +140,15 @@ class MainDisplay():
|
||||
self.menu_display.start()
|
||||
|
||||
def quit(self, sender=None):
|
||||
logterm_pid = None
|
||||
if True or RNS.vendor.platformutils.is_android():
|
||||
if self.sub_displays.log_display != None and self.sub_displays.log_display.log_term != None:
|
||||
if self.sub_displays.log_display.log_term.log_term != None:
|
||||
logterm_pid = self.sub_displays.log_display.log_term.log_term.pid
|
||||
if logterm_pid != None:
|
||||
import os, signal
|
||||
os.kill(logterm_pid, signal.SIGKILL)
|
||||
|
||||
raise urwid.ExitMainLoop
|
||||
|
||||
|
||||
|
||||
@@ -480,7 +480,11 @@ def make_output(state, line, url_delegate):
|
||||
|
||||
elif mode == "text":
|
||||
if c == "\\":
|
||||
escape = True
|
||||
if escape:
|
||||
part += c
|
||||
escape = False
|
||||
else:
|
||||
escape = True
|
||||
elif c == "`":
|
||||
if escape:
|
||||
part += c
|
||||
|
||||
@@ -71,11 +71,17 @@ class AnnounceInfo(urwid.WidgetWrap):
|
||||
trust_str = ""
|
||||
display_str = self.app.directory.simplest_display_str(source_hash)
|
||||
addr_str = "<"+RNS.hexrep(source_hash, delimit=False)+">"
|
||||
is_node = announce[3]
|
||||
info_type = announce[3]
|
||||
|
||||
if is_node:
|
||||
type_string = "Node " + g["node"]
|
||||
else:
|
||||
is_node = False
|
||||
is_pn = False
|
||||
if info_type == "node" or info_type == True:
|
||||
type_string = "Nomad Network Node " + g["node"]
|
||||
is_node = True
|
||||
elif info_type == "pn":
|
||||
type_string = "LXMF Propagation Node " + g["sent"]
|
||||
is_pn = True
|
||||
elif info_type == "peer" or info_type == False:
|
||||
type_string = "Peer " + g["peer"]
|
||||
|
||||
try:
|
||||
@@ -174,10 +180,20 @@ class AnnounceInfo(urwid.WidgetWrap):
|
||||
except Exception as e:
|
||||
RNS.log("Error while starting conversation from announce. The contained exception was: "+str(e), RNS.LOG_ERROR)
|
||||
|
||||
def use_pn(sender):
|
||||
show_announce_stream(None)
|
||||
try:
|
||||
self.app.set_user_selected_propagation_node(source_hash)
|
||||
except Exception as e:
|
||||
RNS.log("Error while setting active propagation node from announce. The contained exception was: "+str(e), RNS.LOG_ERROR)
|
||||
|
||||
if is_node:
|
||||
type_button = ("weight", 0.45, urwid.Button("Connect", on_press=connect))
|
||||
msg_button = ("weight", 0.45, urwid.Button("Msg Op", on_press=msg_op))
|
||||
save_button = ("weight", 0.45, urwid.Button("Save", on_press=save_node))
|
||||
elif is_pn:
|
||||
type_button = ("weight", 0.45, urwid.Button("Use as default", on_press=use_pn))
|
||||
save_button = None
|
||||
else:
|
||||
type_button = ("weight", 0.45, urwid.Button("Converse", on_press=converse))
|
||||
save_button = None
|
||||
@@ -187,21 +203,33 @@ class AnnounceInfo(urwid.WidgetWrap):
|
||||
else:
|
||||
button_columns = urwid.Columns([("weight", 0.45, urwid.Button("Back", on_press=show_announce_stream)), ("weight", 0.1, urwid.Text("")), type_button])
|
||||
|
||||
pile_widgets = [
|
||||
urwid.Text("Time : "+ts_string, align="left"),
|
||||
urwid.Text("Addr : "+addr_str, align="left"),
|
||||
urwid.Text("Type : "+type_string, align="left"),
|
||||
urwid.Text("Name : "+display_str, align="left"),
|
||||
urwid.Text(["Trust : ", (style, trust_str)], align="left"),
|
||||
urwid.Divider(g["divider1"]),
|
||||
urwid.Text(["Announce Data: \n", (data_style, data_str)], align="left"),
|
||||
urwid.Divider(g["divider1"]),
|
||||
button_columns
|
||||
]
|
||||
pile_widgets = []
|
||||
|
||||
if is_node:
|
||||
operator_entry = urwid.Text("Oprtr : "+op_str, align="left")
|
||||
pile_widgets.insert(4, operator_entry)
|
||||
if is_pn:
|
||||
pile_widgets = [
|
||||
urwid.Text("Time : "+ts_string, align="left"),
|
||||
urwid.Text("Addr : "+addr_str, align="left"),
|
||||
urwid.Text("Type : "+type_string, align="left"),
|
||||
urwid.Divider(g["divider1"]),
|
||||
button_columns
|
||||
]
|
||||
|
||||
else:
|
||||
pile_widgets = [
|
||||
urwid.Text("Time : "+ts_string, align="left"),
|
||||
urwid.Text("Addr : "+addr_str, align="left"),
|
||||
urwid.Text("Type : "+type_string, align="left"),
|
||||
urwid.Text("Name : "+display_str, align="left"),
|
||||
urwid.Text(["Trust : ", (style, trust_str)], align="left"),
|
||||
urwid.Divider(g["divider1"]),
|
||||
urwid.Text(["Announce Data: \n", (data_style, data_str)], align="left"),
|
||||
urwid.Divider(g["divider1"]),
|
||||
button_columns
|
||||
]
|
||||
|
||||
if is_node:
|
||||
operator_entry = urwid.Text("Oprtr : "+op_str, align="left")
|
||||
pile_widgets.insert(4, operator_entry)
|
||||
|
||||
pile = urwid.Pile(pile_widgets)
|
||||
|
||||
@@ -211,7 +239,7 @@ class AnnounceInfo(urwid.WidgetWrap):
|
||||
|
||||
|
||||
class AnnounceStreamEntry(urwid.WidgetWrap):
|
||||
def __init__(self, app, announce):
|
||||
def __init__(self, app, announce, delegate):
|
||||
full_time_format = "%Y-%m-%d %H:%M:%S"
|
||||
date_time_format = "%Y-%m-%d"
|
||||
time_time_format = "%H:%M:%S"
|
||||
@@ -220,8 +248,9 @@ class AnnounceStreamEntry(urwid.WidgetWrap):
|
||||
|
||||
timestamp = announce[0]
|
||||
source_hash = announce[1]
|
||||
is_node = announce[3]
|
||||
announce_type = announce[3]
|
||||
self.app = app
|
||||
self.delegate = delegate
|
||||
self.timestamp = timestamp
|
||||
time_format = app.time_format
|
||||
dt = datetime.fromtimestamp(self.timestamp)
|
||||
@@ -257,10 +286,12 @@ class AnnounceStreamEntry(urwid.WidgetWrap):
|
||||
style = "list_untrusted"
|
||||
focus_style = "list_focus_untrusted"
|
||||
|
||||
if is_node:
|
||||
if announce_type == "node" or announce_type == True:
|
||||
type_symbol = g["node"]
|
||||
else:
|
||||
elif announce_type == "peer" or announce_type == False:
|
||||
type_symbol = g["peer"]
|
||||
elif announce_type == "pn":
|
||||
type_symbol = g["sent"]
|
||||
|
||||
widget = ListEntry(ts_string+" "+type_symbol+" "+display_str)
|
||||
urwid.connect_signal(widget, "click", self.display_announce, announce)
|
||||
@@ -269,10 +300,46 @@ class AnnounceStreamEntry(urwid.WidgetWrap):
|
||||
urwid.WidgetWrap.__init__(self, self.display_widget)
|
||||
|
||||
def display_announce(self, event, announce):
|
||||
try:
|
||||
parent = self.app.ui.main_display.sub_displays.network_display
|
||||
info_widget = AnnounceInfo(announce, parent, self.app)
|
||||
options = parent.left_pile.options(height_type="weight", height_amount=1)
|
||||
parent.left_pile.contents[0] = (info_widget, options)
|
||||
|
||||
except KeyError as e:
|
||||
def dismiss_dialog(sender):
|
||||
self.delegate.parent.close_list_dialogs()
|
||||
|
||||
def confirmed(sender):
|
||||
def close_req(sender):
|
||||
self.delegate.parent.close_list_dialogs()
|
||||
|
||||
dialog_pile.contents[0] = (urwid.Text("\nKeys requested from network\n", align="center"), options)
|
||||
RNS.Transport.request_path(announce[1])
|
||||
|
||||
confirmed_button = urwid.Button("Request keys", on_press=confirmed)
|
||||
|
||||
dialog_pile = urwid.Pile([
|
||||
urwid.Text("The keys for the announced destination could not be recalled. You can wait for an announce to arrive, or request the keys from the network.\n", align="center"),
|
||||
urwid.Columns([
|
||||
("weight", 0.45, confirmed_button),
|
||||
("weight", 0.1, urwid.Text("")),
|
||||
("weight", 0.45, urwid.Button("Close", on_press=dismiss_dialog)),
|
||||
])
|
||||
])
|
||||
|
||||
dialog = ListDialogLineBox(
|
||||
dialog_pile,
|
||||
title="Keys Unknown"
|
||||
)
|
||||
confirmed_button.dialog_pile = dialog_pile
|
||||
dialog.delegate = self.delegate.parent
|
||||
bottom = self.delegate
|
||||
|
||||
overlay = urwid.Overlay(dialog, bottom, align="center", width=("relative", 100), valign="middle", height="pack", left=2, right=2)
|
||||
|
||||
options = self.delegate.parent.left_pile.options("weight", 1)
|
||||
self.delegate.parent.left_pile.contents[0] = (overlay, options)
|
||||
|
||||
def timestamp(self):
|
||||
return self.timestamp
|
||||
@@ -328,7 +395,7 @@ class AnnounceStream(urwid.WidgetWrap):
|
||||
new_entries.insert(0, e)
|
||||
|
||||
for e in new_entries:
|
||||
nw = AnnounceStreamEntry(self.app, e)
|
||||
nw = AnnounceStreamEntry(self.app, e, self)
|
||||
nw.timestamp = e[0]
|
||||
self.widget_list.insert(0, nw)
|
||||
|
||||
@@ -425,13 +492,15 @@ class KnownNodeInfo(urwid.WidgetWrap):
|
||||
if display_str == None:
|
||||
display_str = addr_str
|
||||
|
||||
pn_hash = RNS.Destination.hash_from_name_and_identity("lxmf.propagation", node_ident)
|
||||
|
||||
if node_ident != None:
|
||||
lxmf_addr_str = g["sent"]+" LXMF Propagation Node Address is "+RNS.prettyhexrep(RNS.Destination.hash_from_name_and_identity("lxmf.propagation", node_ident))
|
||||
lxmf_addr_str = g["sent"]+" LXMF Propagation Node Address is "+RNS.prettyhexrep(pn_hash)
|
||||
else:
|
||||
lxmf_addr_str = "No associated Propagation Node known"
|
||||
|
||||
|
||||
type_string = "Node " + g["node"]
|
||||
type_string = "Nomad Network Node " + g["node"]
|
||||
|
||||
if trust_level == DirectoryEntry.UNTRUSTED:
|
||||
trust_str = "Untrusted"
|
||||
@@ -525,7 +594,7 @@ class KnownNodeInfo(urwid.WidgetWrap):
|
||||
def save_node(sender):
|
||||
if self.pn_changed:
|
||||
if propagation_node_checkbox.get_state():
|
||||
self.app.set_user_selected_propagation_node(source_hash)
|
||||
self.app.set_user_selected_propagation_node(pn_hash)
|
||||
else:
|
||||
self.app.set_user_selected_propagation_node(None)
|
||||
|
||||
@@ -541,6 +610,10 @@ class KnownNodeInfo(urwid.WidgetWrap):
|
||||
node_entry = DirectoryEntry(source_hash, display_name=display_str, trust_level=trust_level, hosts_node=True, identify_on_connect=connect_identify_checkbox.get_state())
|
||||
self.app.directory.remember(node_entry)
|
||||
self.app.ui.main_display.sub_displays.network_display.directory_change_callback()
|
||||
|
||||
if trust_level == DirectoryEntry.TRUSTED:
|
||||
self.app.autoselect_propagation_node()
|
||||
|
||||
show_known_nodes(None)
|
||||
|
||||
back_button = ("weight", 0.2, urwid.Button("Back", on_press=show_known_nodes))
|
||||
@@ -635,7 +708,7 @@ class KnownNodes(urwid.WidgetWrap):
|
||||
else:
|
||||
self.no_content = True
|
||||
widget_style = "inactive_text"
|
||||
self.pile = urwid.Pile([urwid.Text(("warning_text", g["info"]+"\n"), align="center"), SelectText(("warning_text", "Currently, no nodes are known\n\n"), align="center")])
|
||||
self.pile = urwid.Pile([urwid.Text(("warning_text", g["info"]+"\n"), align="center"), SelectText(("warning_text", "Currently, no nodes are saved\n\nCtrl+L to view the announce stream\n\n"), align="center")])
|
||||
self.display_widget = urwid.Filler(self.pile, valign="top", height="pack")
|
||||
|
||||
urwid.WidgetWrap.__init__(self, urwid.AttrMap(urwid.LineBox(self.display_widget, title="Saved Nodes"), widget_style))
|
||||
@@ -862,7 +935,7 @@ class NodeActiveConnections(urwid.WidgetWrap):
|
||||
if self.app.node != None:
|
||||
self.stat_string = str(len(self.app.node.destination.links))
|
||||
|
||||
self.display_widget.set_text("Conneced Now : "+self.stat_string)
|
||||
self.display_widget.set_text("Connected Now : "+self.stat_string)
|
||||
|
||||
def update_stat_callback(self, loop=None, user_data=None):
|
||||
self.update_stat()
|
||||
@@ -1466,10 +1539,6 @@ class NetworkDisplay():
|
||||
self.local_peer_display.start()
|
||||
self.node_info_display.start()
|
||||
self.network_stats_display.start()
|
||||
# There seems to be an intermittent memory leak somewhere
|
||||
# in the periodic updating here. The periodic updater should
|
||||
# not be needed anymore, so dis
|
||||
#self.announce_stream_display.start()
|
||||
|
||||
def shortcuts(self):
|
||||
return self.shortcuts_display
|
||||
@@ -1572,7 +1641,14 @@ class LXMFPeerEntry(urwid.WidgetWrap):
|
||||
style = "list_unknown"
|
||||
focus_style = "list_focus"
|
||||
|
||||
widget = ListEntry(sym+" "+display_str+"\n "+str(len(peer.unhandled_messages))+" unhandled LXMs - "+"Last heard "+pretty_date(int(peer.last_heard)))
|
||||
alive_string = "Unknown"
|
||||
if hasattr(peer, "alive"):
|
||||
if peer.alive:
|
||||
alive_string = "Available"
|
||||
else:
|
||||
alive_string = "Unresponsive"
|
||||
|
||||
widget = ListEntry(sym+" "+display_str+"\n "+alive_string+", last heard "+pretty_date(int(peer.last_heard))+"\n "+str(len(peer.unhandled_messages))+" unhandled LXMs")
|
||||
# urwid.connect_signal(widget, "click", delegate.connect_node, node)
|
||||
|
||||
self.display_widget = urwid.AttrMap(widget, style, focus_style)
|
||||
|
||||
45
nomadnet/vendor/Scrollable.py
vendored
45
nomadnet/vendor/Scrollable.py
vendored
@@ -107,6 +107,51 @@ class Scrollable(urwid.WidgetDecoration):
|
||||
if canv_full.cursor is not None:
|
||||
# Full canvas contains the cursor, but scrolled out of view
|
||||
self._forward_keypress = False
|
||||
|
||||
# Reset cursor position on page/up down scrolling
|
||||
try:
|
||||
if hasattr(ow, "automove_cursor_on_scroll") and ow.automove_cursor_on_scroll:
|
||||
pwi = 0
|
||||
ch = 0
|
||||
last_hidden = False
|
||||
first_visible = False
|
||||
for w,o in ow.contents:
|
||||
wcanv = w.render((maxcol,))
|
||||
wh = wcanv.rows()
|
||||
if wh:
|
||||
ch += wh
|
||||
|
||||
if not last_hidden and ch >= self._trim_top:
|
||||
last_hidden = True
|
||||
|
||||
elif last_hidden:
|
||||
if not first_visible:
|
||||
first_visible = True
|
||||
|
||||
if w.selectable():
|
||||
ow.focus_item = pwi
|
||||
|
||||
st = None
|
||||
nf = ow.get_focus()
|
||||
if hasattr(nf, "key_timeout"):
|
||||
st = nf
|
||||
elif hasattr(nf, "original_widget"):
|
||||
no = nf.original_widget
|
||||
if hasattr(no, "original_widget"):
|
||||
st = no.original_widget
|
||||
else:
|
||||
if hasattr(no, "key_timeout"):
|
||||
st = no
|
||||
|
||||
if st and hasattr(st, "key_timeout") and hasattr(st, "keypress") and callable(st.keypress):
|
||||
st.keypress(None, None)
|
||||
|
||||
break
|
||||
|
||||
pwi += 1
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
else:
|
||||
# Original widget does not have a cursor, but may be selectable
|
||||
|
||||
|
||||
1
nomadnet/vendor/quotes.py
vendored
1
nomadnet/vendor/quotes.py
vendored
@@ -3,4 +3,5 @@ quotes = [
|
||||
("That's enough entropy for you my friend", "Unknown"),
|
||||
("Any time two people connect online, it's financed by a third person who believes they can manipulate the first two", "Jaron Lanier"),
|
||||
("The landscape of the future is set, but how one will march across it is not determined", "Terence McKenna")
|
||||
("Freedom originates in the division of power, despotism in its concentration.", "John Acton")
|
||||
]
|
||||
11
setup.py
11
setup.py
@@ -5,6 +5,12 @@ exec(open("nomadnet/_version.py", "r").read())
|
||||
with open("README.md", "r") as fh:
|
||||
long_description = fh.read()
|
||||
|
||||
package_data = {
|
||||
"": [
|
||||
"examples/messageboard/*",
|
||||
]
|
||||
}
|
||||
|
||||
setuptools.setup(
|
||||
name="nomadnet",
|
||||
version=__version__,
|
||||
@@ -15,6 +21,7 @@ setuptools.setup(
|
||||
long_description_content_type="text/markdown",
|
||||
url="https://github.com/markqvist/nomadnet",
|
||||
packages=setuptools.find_packages(),
|
||||
package_data=package_data,
|
||||
classifiers=[
|
||||
"Programming Language :: Python :: 3",
|
||||
"License :: OSI Approved :: MIT License",
|
||||
@@ -23,6 +30,6 @@ setuptools.setup(
|
||||
entry_points= {
|
||||
'console_scripts': ['nomadnet=nomadnet.nomadnet:main']
|
||||
},
|
||||
install_requires=['rns>=0.3.12', 'lxmf>=0.1.8', 'urwid>=2.1.2'],
|
||||
python_requires='>=3.6',
|
||||
install_requires=["rns>=0.4.8", "lxmf>=0.3.0", "urwid>=2.1.2", "qrcode"],
|
||||
python_requires=">=3.6",
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user