mirror of
https://github.com/markqvist/NomadNet.git
synced 2025-12-17 14:54:26 +01:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0df8b56d58 | ||
|
|
112a45f270 | ||
|
|
03a02a9ebc | ||
|
|
e755641dbe | ||
|
|
5392275782 | ||
|
|
1bbfacee94 | ||
|
|
0135de3e0e | ||
|
|
76cb1f73f5 |
@@ -27,6 +27,13 @@ class Conversation:
|
|||||||
if Conversation.created_callback != None:
|
if Conversation.created_callback != None:
|
||||||
Conversation.created_callback()
|
Conversation.created_callback()
|
||||||
|
|
||||||
|
# This reformats the new v0.5.0 announce data back to the expected format
|
||||||
|
# for nomadnets storage and other handling functions.
|
||||||
|
dn = LXMF.display_name_from_app_data(app_data)
|
||||||
|
app_data = b""
|
||||||
|
if dn != None:
|
||||||
|
app_data = dn.encode("utf-8")
|
||||||
|
|
||||||
# Add the announce to the directory announce
|
# Add the announce to the directory announce
|
||||||
# stream logger
|
# stream logger
|
||||||
app.directory.lxmf_announce_received(destination_hash, app_data)
|
app.directory.lxmf_announce_received(destination_hash, app_data)
|
||||||
@@ -95,7 +102,7 @@ class Conversation:
|
|||||||
unread = True
|
unread = True
|
||||||
|
|
||||||
if display_name == None and app_data:
|
if display_name == None and app_data:
|
||||||
display_name = app_data.decode("utf-8")
|
display_name = LXMF.display_name_from_app_data(app_data)
|
||||||
|
|
||||||
if display_name == None:
|
if display_name == None:
|
||||||
sort_name = ""
|
sort_name = ""
|
||||||
@@ -210,7 +217,11 @@ class Conversation:
|
|||||||
if self.app.message_router.get_outbound_propagation_node() != None:
|
if self.app.message_router.get_outbound_propagation_node() != None:
|
||||||
desired_method = LXMF.LXMessage.PROPAGATED
|
desired_method = LXMF.LXMessage.PROPAGATED
|
||||||
|
|
||||||
lxm = LXMF.LXMessage(dest, source, content, title=title, desired_method=desired_method)
|
dest_is_trusted = False
|
||||||
|
if self.app.directory.trust_level(dest.hash) == DirectoryEntry.TRUSTED:
|
||||||
|
dest_is_trusted = True
|
||||||
|
|
||||||
|
lxm = LXMF.LXMessage(dest, source, content, title=title, desired_method=desired_method, include_ticket=dest_is_trusted)
|
||||||
lxm.register_delivery_callback(self.message_notification)
|
lxm.register_delivery_callback(self.message_notification)
|
||||||
lxm.register_failed_callback(self.message_notification)
|
lxm.register_failed_callback(self.message_notification)
|
||||||
|
|
||||||
@@ -281,13 +292,17 @@ class Conversation:
|
|||||||
|
|
||||||
def message_notification(self, message):
|
def message_notification(self, message):
|
||||||
if message.state == LXMF.LXMessage.FAILED and hasattr(message, "try_propagation_on_fail") and message.try_propagation_on_fail:
|
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)
|
if hasattr(message, "stamp_generation_failed") and message.stamp_generation_failed == True:
|
||||||
message.try_propagation_on_fail = None
|
RNS.log(f"Could not send {message} due to a stamp generation failure", RNS.LOG_ERROR)
|
||||||
message.delivery_attempts = 0
|
else:
|
||||||
del message.next_delivery_attempt
|
RNS.log("Direct delivery of "+str(message)+" failed. Retrying as propagated message.", RNS.LOG_VERBOSE)
|
||||||
message.packed = None
|
message.try_propagation_on_fail = None
|
||||||
message.desired_method = LXMF.LXMessage.PROPAGATED
|
message.delivery_attempts = 0
|
||||||
self.app.message_router.handle_outbound(message)
|
if hasattr(message, "next_delivery_attempt"):
|
||||||
|
del message.next_delivery_attempt
|
||||||
|
message.packed = None
|
||||||
|
message.desired_method = LXMF.LXMessage.PROPAGATED
|
||||||
|
self.app.message_router.handle_outbound(message)
|
||||||
else:
|
else:
|
||||||
message_path = Conversation.ingest(message, self.app, originator=True)
|
message_path = Conversation.ingest(message, self.app, originator=True)
|
||||||
|
|
||||||
@@ -318,12 +333,17 @@ class ConversationMessage:
|
|||||||
self.timestamp = self.lxm.timestamp
|
self.timestamp = self.lxm.timestamp
|
||||||
self.sort_timestamp = os.path.getmtime(self.file_path)
|
self.sort_timestamp = os.path.getmtime(self.file_path)
|
||||||
|
|
||||||
if self.lxm.state > LXMF.LXMessage.DRAFT and self.lxm.state < LXMF.LXMessage.SENT:
|
if self.lxm.state > LXMF.LXMessage.GENERATING and self.lxm.state < LXMF.LXMessage.SENT:
|
||||||
found = False
|
found = False
|
||||||
|
|
||||||
for pending in nomadnet.NomadNetworkApp.get_shared_instance().message_router.pending_outbound:
|
for pending in nomadnet.NomadNetworkApp.get_shared_instance().message_router.pending_outbound:
|
||||||
if pending.hash == self.lxm.hash:
|
if pending.hash == self.lxm.hash:
|
||||||
found = True
|
found = True
|
||||||
|
|
||||||
|
for pending_id in nomadnet.NomadNetworkApp.get_shared_instance().message_router.pending_deferred_stamps:
|
||||||
|
if pending_id == self.lxm.hash:
|
||||||
|
found = True
|
||||||
|
|
||||||
if not found:
|
if not found:
|
||||||
self.lxm.state = LXMF.LXMessage.FAILED
|
self.lxm.state = LXMF.LXMessage.FAILED
|
||||||
|
|
||||||
|
|||||||
@@ -134,6 +134,10 @@ class NomadNetworkApp:
|
|||||||
self.lxmf_sync_interval = 360*60
|
self.lxmf_sync_interval = 360*60
|
||||||
self.lxmf_sync_limit = 8
|
self.lxmf_sync_limit = 8
|
||||||
self.compact_stream = False
|
self.compact_stream = False
|
||||||
|
|
||||||
|
self.required_stamp_cost = None
|
||||||
|
self.accept_invalid_stamps = False
|
||||||
|
|
||||||
|
|
||||||
if not os.path.isdir(self.storagepath):
|
if not os.path.isdir(self.storagepath):
|
||||||
os.makedirs(self.storagepath)
|
os.makedirs(self.storagepath)
|
||||||
@@ -296,8 +300,9 @@ class NomadNetworkApp:
|
|||||||
for destination_hash in self.ignored_list:
|
for destination_hash in self.ignored_list:
|
||||||
self.message_router.ignore_destination(destination_hash)
|
self.message_router.ignore_destination(destination_hash)
|
||||||
|
|
||||||
self.lxmf_destination = self.message_router.register_delivery_identity(self.identity, display_name=self.peer_settings["display_name"])
|
self.lxmf_destination = self.message_router.register_delivery_identity(self.identity, display_name=self.peer_settings["display_name"], stamp_cost=self.required_stamp_cost)
|
||||||
self.lxmf_destination.set_default_app_data(self.get_display_name_bytes)
|
if not self.accept_invalid_stamps:
|
||||||
|
self.message_router.enforce_stamps()
|
||||||
|
|
||||||
RNS.Identity.remember(
|
RNS.Identity.remember(
|
||||||
packet_hash=None,
|
packet_hash=None,
|
||||||
@@ -492,7 +497,9 @@ class NomadNetworkApp:
|
|||||||
self.message_router.cancel_propagation_node_requests()
|
self.message_router.cancel_propagation_node_requests()
|
||||||
|
|
||||||
def announce_now(self):
|
def announce_now(self):
|
||||||
self.lxmf_destination.announce()
|
self.message_router.set_inbound_stamp_cost(self.lxmf_destination.hash, self.required_stamp_cost)
|
||||||
|
self.lxmf_destination.display_name = self.peer_settings["display_name"]
|
||||||
|
self.message_router.announce(self.lxmf_destination.hash)
|
||||||
self.peer_settings["last_announce"] = time.time()
|
self.peer_settings["last_announce"] = time.time()
|
||||||
self.save_peer_settings()
|
self.save_peer_settings()
|
||||||
|
|
||||||
@@ -738,6 +745,24 @@ class NomadNetworkApp:
|
|||||||
else:
|
else:
|
||||||
self.lxmf_sync_limit = None
|
self.lxmf_sync_limit = None
|
||||||
|
|
||||||
|
if option == "required_stamp_cost":
|
||||||
|
value = self.config["client"][option]
|
||||||
|
if value.lower() == "none":
|
||||||
|
self.required_stamp_cost = None
|
||||||
|
else:
|
||||||
|
value = self.config["client"].as_int(option)
|
||||||
|
|
||||||
|
if value > 0:
|
||||||
|
if value > 255:
|
||||||
|
value = 255
|
||||||
|
self.required_stamp_cost = value
|
||||||
|
else:
|
||||||
|
self.required_stamp_cost = None
|
||||||
|
|
||||||
|
if option == "accept_invalid_stamps":
|
||||||
|
value = self.config["client"].as_bool(option)
|
||||||
|
self.accept_invalid_stamps = value
|
||||||
|
|
||||||
if option == "max_accepted_size":
|
if option == "max_accepted_size":
|
||||||
value = self.config["client"].as_float(option)
|
value = self.config["client"].as_float(option)
|
||||||
|
|
||||||
@@ -1017,6 +1042,24 @@ lxmf_sync_interval = 360
|
|||||||
# the limit, and download everything every time.
|
# the limit, and download everything every time.
|
||||||
lxmf_sync_limit = 8
|
lxmf_sync_limit = 8
|
||||||
|
|
||||||
|
# You can specify a required stamp cost for
|
||||||
|
# inbound messages to be accepted. Specifying
|
||||||
|
# a stamp cost will require untrusted senders
|
||||||
|
# that message you to include a cryptographic
|
||||||
|
# stamp in their messages. Performing this
|
||||||
|
# operation takes the sender an amount of time
|
||||||
|
# proportional to the stamp cost. As a rough
|
||||||
|
# estimate, a stamp cost of 8 will take less
|
||||||
|
# than a second to compute, and a stamp cost
|
||||||
|
# of 20 could take several minutes, even on
|
||||||
|
# a fast computer.
|
||||||
|
required_stamp_cost = None
|
||||||
|
|
||||||
|
# You can signal stamp requirements to senders,
|
||||||
|
# but still accept messages with invalid stamps
|
||||||
|
# by setting this option to True.
|
||||||
|
accept_invalid_stamps = False
|
||||||
|
|
||||||
# The maximum accepted unpacked size for mes-
|
# The maximum accepted unpacked size for mes-
|
||||||
# sages received directly from other peers,
|
# sages received directly from other peers,
|
||||||
# specified in kilobytes. Messages larger than
|
# specified in kilobytes. Messages larger than
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
__version__ = "0.5.0"
|
__version__ = "0.5.3"
|
||||||
|
|||||||
@@ -521,6 +521,18 @@ The number of minutes between each automatic sync. The default is equal to 6 hou
|
|||||||
On low-bandwidth networks, it can be useful to limit the amount of messages downloaded in each sync. The default is 8. Set to 0 to download all available messages every time a sync occurs.
|
On low-bandwidth networks, it can be useful to limit the amount of messages downloaded in each sync. The default is 8. Set to 0 to download all available messages every time a sync occurs.
|
||||||
<
|
<
|
||||||
|
|
||||||
|
>>>
|
||||||
|
`!required_stamp_cost = None`!
|
||||||
|
>>>>
|
||||||
|
You can specify a required stamp cost for inbound messages to be accepted. Specifying a stamp cost will require untrusted senders that message you to include a cryptographic stamp in their messages. Performing this operation takes the sender an amount of time proportional to the stamp cost. As a rough estimate, a stamp cost of 8 will take less than a second to compute, and a stamp cost of 20 could take several minutes, even on a fast computer.
|
||||||
|
<
|
||||||
|
|
||||||
|
>>>
|
||||||
|
`!accept_invalid_stamps = False`!
|
||||||
|
>>>>
|
||||||
|
You can signal stamp requirements to senders, but still accept messages with invalid stamps by setting this option to True.
|
||||||
|
<
|
||||||
|
|
||||||
>>>
|
>>>
|
||||||
`!max_accepted_size = 500`!
|
`!max_accepted_size = 500`!
|
||||||
>>>>
|
>>>>
|
||||||
@@ -739,12 +751,11 @@ If you have Internet access, and just want to get started experimenting, you are
|
|||||||
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:
|
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 Zurich]]
|
[[RNS Testnet Dublin]]
|
||||||
type = TCPClientInterface
|
type = TCPClientInterface
|
||||||
interface_enabled = yes
|
enabled = yes
|
||||||
outgoing = True
|
target_host = dublin.connect.reticulum.network
|
||||||
target_host = zurich.connect.reticulum.network
|
target_port = 4965
|
||||||
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:
|
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:
|
||||||
|
|||||||
2
setup.py
2
setup.py
@@ -30,6 +30,6 @@ setuptools.setup(
|
|||||||
entry_points= {
|
entry_points= {
|
||||||
'console_scripts': ['nomadnet=nomadnet.nomadnet:main']
|
'console_scripts': ['nomadnet=nomadnet.nomadnet:main']
|
||||||
},
|
},
|
||||||
install_requires=["rns>=0.7.6", "lxmf>=0.4.5", "urwid>=2.4.4", "qrcode"],
|
install_requires=["rns>=0.7.8", "lxmf>=0.5.2", "urwid>=2.4.4", "qrcode"],
|
||||||
python_requires=">=3.6",
|
python_requires=">=3.6",
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user