Merge branch 'SebastianObi:main' into main

This commit is contained in:
Swissbandit 2022-12-08 15:12:27 +01:00 committed by GitHub
commit 7f49d516e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 1653 additions and 65 deletions

View File

@ -99,7 +99,7 @@ class lxmf_connection:
message_notification_failed_callback = None
def __init__(self, storage_path=None, identity_file="identity", identity=None, destination_name="lxmf", destination_type="delivery", display_name="", send_delay=0, desired_method="direct", propagation_node=None, try_propagation_on_fail=False, announce_startup=False, announce_startup_delay=0, announce_periodic=False, announce_periodic_interval=360, sync_startup=False, sync_startup_delay=0, sync_limit=8, sync_periodic=False, sync_periodic_interval=360):
def __init__(self, storage_path=None, identity_file="identity", identity=None, destination_name="lxmf", destination_type="delivery", display_name="", announce_data=None, send_delay=0, desired_method="direct", propagation_node=None, try_propagation_on_fail=False, announce_startup=False, announce_startup_delay=0, announce_periodic=False, announce_periodic_interval=360, sync_startup=False, sync_startup_delay=0, sync_limit=8, sync_periodic=False, sync_periodic_interval=360):
self.storage_path = storage_path
self.identity_file = identity_file
@ -111,6 +111,7 @@ class lxmf_connection:
self.aspect_filter = self.destination_name + "." + self.destination_type
self.display_name = display_name
self.announce_data = announce_data
self.send_delay = int(send_delay)
@ -166,9 +167,11 @@ class lxmf_connection:
self.message_router = LXMF.LXMRouter(identity=self.identity, storagepath=self.storage_path)
self.destination = self.message_router.register_delivery_identity(self.identity, display_name=self.display_name)
self.message_router.register_delivery_callback(self.process_lxmf_message_propagated)
if self.destination_name == "lxmf" and self.destination_type == "delivery":
self.destination = self.message_router.register_delivery_identity(self.identity, display_name=self.display_name)
self.message_router.register_delivery_callback(self.process_lxmf_message_propagated)
else:
self.destination = RNS.Destination(self.identity, RNS.Destination.IN, RNS.Destination.SINGLE, self.destination_name, self.destination_type)
if self.display_name == "":
self.display_name = RNS.prettyhexrep(self.destination_hash())
@ -368,8 +371,19 @@ class lxmf_connection:
def announce_now(self, app_data=None):
if app_data:
self.destination.announce(app_data.encode("utf-8"))
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) + ":" + app_data, LOG_DEBUG)
if isinstance(app_data, str):
self.destination.announce(app_data.encode("utf-8"))
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) +":" + announce_data, LOG_DEBUG)
else:
self.destination.announce(app_data)
log("LMF - Announced: " + RNS.prettyhexrep(self.destination_hash()), LOG_DEBUG)
elif self.announce_data:
if isinstance(self.announce_data, str):
self.destination.announce(self.announce_data.encode("utf-8"))
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) +":" + self.announce_data, LOG_DEBUG)
else:
self.destination.announce(self.announce_data)
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()), LOG_DEBUG)
else:
self.destination.announce()
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) + ": " + self.display_name, LOG_DEBUG)

View File

@ -97,7 +97,7 @@ class lxmf_connection:
message_notification_failed_callback = None
def __init__(self, storage_path=None, identity_file="identity", identity=None, destination_name="lxmf", destination_type="delivery", display_name="", send_delay=0, desired_method="direct", propagation_node=None, try_propagation_on_fail=False, announce_startup=False, announce_startup_delay=0, announce_periodic=False, announce_periodic_interval=360, sync_startup=False, sync_startup_delay=0, sync_limit=8, sync_periodic=False, sync_periodic_interval=360):
def __init__(self, storage_path=None, identity_file="identity", identity=None, destination_name="lxmf", destination_type="delivery", display_name="", announce_data=None, send_delay=0, desired_method="direct", propagation_node=None, try_propagation_on_fail=False, announce_startup=False, announce_startup_delay=0, announce_periodic=False, announce_periodic_interval=360, sync_startup=False, sync_startup_delay=0, sync_limit=8, sync_periodic=False, sync_periodic_interval=360):
self.storage_path = storage_path
self.identity_file = identity_file
@ -109,6 +109,7 @@ class lxmf_connection:
self.aspect_filter = self.destination_name + "." + self.destination_type
self.display_name = display_name
self.announce_data = announce_data
self.send_delay = int(send_delay)
@ -164,9 +165,11 @@ class lxmf_connection:
self.message_router = LXMF.LXMRouter(identity=self.identity, storagepath=self.storage_path)
self.destination = self.message_router.register_delivery_identity(self.identity, display_name=self.display_name)
self.message_router.register_delivery_callback(self.process_lxmf_message_propagated)
if self.destination_name == "lxmf" and self.destination_type == "delivery":
self.destination = self.message_router.register_delivery_identity(self.identity, display_name=self.display_name)
self.message_router.register_delivery_callback(self.process_lxmf_message_propagated)
else:
self.destination = RNS.Destination(self.identity, RNS.Destination.IN, RNS.Destination.SINGLE, self.destination_name, self.destination_type)
if self.display_name == "":
self.display_name = RNS.prettyhexrep(self.destination_hash())
@ -366,8 +369,19 @@ class lxmf_connection:
def announce_now(self, app_data=None):
if app_data:
self.destination.announce(app_data.encode("utf-8"))
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) + ":" + app_data, LOG_DEBUG)
if isinstance(app_data, str):
self.destination.announce(app_data.encode("utf-8"))
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) +":" + announce_data, LOG_DEBUG)
else:
self.destination.announce(app_data)
log("LMF - Announced: " + RNS.prettyhexrep(self.destination_hash()), LOG_DEBUG)
elif self.announce_data:
if isinstance(self.announce_data, str):
self.destination.announce(self.announce_data.encode("utf-8"))
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) +":" + self.announce_data, LOG_DEBUG)
else:
self.destination.announce(self.announce_data)
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()), LOG_DEBUG)
else:
self.destination.announce()
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) + ": " + self.display_name, LOG_DEBUG)

View File

@ -95,7 +95,7 @@ class lxmf_connection:
message_notification_failed_callback = None
def __init__(self, storage_path=None, identity_file="identity", identity=None, destination_name="lxmf", destination_type="delivery", display_name="", send_delay=0, desired_method="direct", propagation_node=None, try_propagation_on_fail=False, announce_startup=False, announce_startup_delay=0, announce_periodic=False, announce_periodic_interval=360, sync_startup=False, sync_startup_delay=0, sync_limit=8, sync_periodic=False, sync_periodic_interval=360):
def __init__(self, storage_path=None, identity_file="identity", identity=None, destination_name="lxmf", destination_type="delivery", display_name="", announce_data=None, send_delay=0, desired_method="direct", propagation_node=None, try_propagation_on_fail=False, announce_startup=False, announce_startup_delay=0, announce_periodic=False, announce_periodic_interval=360, sync_startup=False, sync_startup_delay=0, sync_limit=8, sync_periodic=False, sync_periodic_interval=360):
self.storage_path = storage_path
self.identity_file = identity_file
@ -107,6 +107,7 @@ class lxmf_connection:
self.aspect_filter = self.destination_name + "." + self.destination_type
self.display_name = display_name
self.announce_data = announce_data
self.send_delay = int(send_delay)
@ -162,9 +163,11 @@ class lxmf_connection:
self.message_router = LXMF.LXMRouter(identity=self.identity, storagepath=self.storage_path)
self.destination = self.message_router.register_delivery_identity(self.identity, display_name=self.display_name)
self.message_router.register_delivery_callback(self.process_lxmf_message_propagated)
if self.destination_name == "lxmf" and self.destination_type == "delivery":
self.destination = self.message_router.register_delivery_identity(self.identity, display_name=self.display_name)
self.message_router.register_delivery_callback(self.process_lxmf_message_propagated)
else:
self.destination = RNS.Destination(self.identity, RNS.Destination.IN, RNS.Destination.SINGLE, self.destination_name, self.destination_type)
if self.display_name == "":
self.display_name = RNS.prettyhexrep(self.destination_hash())
@ -364,8 +367,19 @@ class lxmf_connection:
def announce_now(self, app_data=None):
if app_data:
self.destination.announce(app_data.encode("utf-8"))
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) + ":" + app_data, LOG_DEBUG)
if isinstance(app_data, str):
self.destination.announce(app_data.encode("utf-8"))
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) +":" + announce_data, LOG_DEBUG)
else:
self.destination.announce(app_data)
log("LMF - Announced: " + RNS.prettyhexrep(self.destination_hash()), LOG_DEBUG)
elif self.announce_data:
if isinstance(self.announce_data, str):
self.destination.announce(self.announce_data.encode("utf-8"))
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) +":" + self.announce_data, LOG_DEBUG)
else:
self.destination.announce(self.announce_data)
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()), LOG_DEBUG)
else:
self.destination.announce()
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) + ": " + self.display_name, LOG_DEBUG)

View File

@ -106,7 +106,7 @@ class lxmf_connection:
message_notification_failed_callback = None
def __init__(self, storage_path=None, identity_file="identity", identity=None, destination_name="lxmf", destination_type="delivery", display_name="", send_delay=0, desired_method="direct", propagation_node=None, try_propagation_on_fail=False, announce_startup=False, announce_startup_delay=0, announce_periodic=False, announce_periodic_interval=360, sync_startup=False, sync_startup_delay=0, sync_limit=8, sync_periodic=False, sync_periodic_interval=360):
def __init__(self, storage_path=None, identity_file="identity", identity=None, destination_name="lxmf", destination_type="delivery", display_name="", announce_data=None, send_delay=0, desired_method="direct", propagation_node=None, try_propagation_on_fail=False, announce_startup=False, announce_startup_delay=0, announce_periodic=False, announce_periodic_interval=360, sync_startup=False, sync_startup_delay=0, sync_limit=8, sync_periodic=False, sync_periodic_interval=360):
self.storage_path = storage_path
self.identity_file = identity_file
@ -118,6 +118,7 @@ class lxmf_connection:
self.aspect_filter = self.destination_name + "." + self.destination_type
self.display_name = display_name
self.announce_data = announce_data
self.send_delay = int(send_delay)
@ -173,9 +174,11 @@ class lxmf_connection:
self.message_router = LXMF.LXMRouter(identity=self.identity, storagepath=self.storage_path)
self.destination = self.message_router.register_delivery_identity(self.identity, display_name=self.display_name)
self.message_router.register_delivery_callback(self.process_lxmf_message_propagated)
if self.destination_name == "lxmf" and self.destination_type == "delivery":
self.destination = self.message_router.register_delivery_identity(self.identity, display_name=self.display_name)
self.message_router.register_delivery_callback(self.process_lxmf_message_propagated)
else:
self.destination = RNS.Destination(self.identity, RNS.Destination.IN, RNS.Destination.SINGLE, self.destination_name, self.destination_type)
if self.display_name == "":
self.display_name = RNS.prettyhexrep(self.destination_hash())
@ -375,8 +378,19 @@ class lxmf_connection:
def announce_now(self, app_data=None):
if app_data:
self.destination.announce(app_data.encode("utf-8"))
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) + ":" + app_data, LOG_DEBUG)
if isinstance(app_data, str):
self.destination.announce(app_data.encode("utf-8"))
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) +":" + announce_data, LOG_DEBUG)
else:
self.destination.announce(app_data)
log("LMF - Announced: " + RNS.prettyhexrep(self.destination_hash()), LOG_DEBUG)
elif self.announce_data:
if isinstance(self.announce_data, str):
self.destination.announce(self.announce_data.encode("utf-8"))
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) +":" + self.announce_data, LOG_DEBUG)
else:
self.destination.announce(self.announce_data)
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()), LOG_DEBUG)
else:
self.destination.announce()
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) + ": " + self.display_name, LOG_DEBUG)
@ -655,11 +669,19 @@ class rns_connection:
def announce_now(self, app_data=None):
if app_data:
self.destination.announce(app_data.encode("utf-8"))
log("RNS - Announced: " + RNS.prettyhexrep(self.destination_hash()) + ":" + app_data, LOG_DEBUG)
if isinstance(app_data, str):
self.destination.announce(app_data.encode("utf-8"))
log("RNS - Announced: " + RNS.prettyhexrep(self.destination_hash()) +":" + announce_data, LOG_DEBUG)
else:
self.destination.announce(app_data)
log("RNS - Announced: " + RNS.prettyhexrep(self.destination_hash()), LOG_DEBUG)
else:
self.destination.announce(self.announce_data.encode("utf-8"))
log("RNS - Announced: " + RNS.prettyhexrep(self.destination_hash()) +":" + self.announce_data, LOG_DEBUG)
if isinstance(self.announce_data, str):
self.destination.announce(self.announce_data.encode("utf-8"))
log("RNS - Announced: " + RNS.prettyhexrep(self.destination_hash()) +":" + self.announce_data, LOG_DEBUG)
else:
self.destination.announce(self.announce_data)
log("RNS - Announced: " + RNS.prettyhexrep(self.destination_hash()), LOG_DEBUG)
##############################################################################################################
@ -731,11 +753,16 @@ def lxmf_message_received_callback(message):
content = message.content.decode('utf-8')
content = content.strip()
if content == "":
if CONFIG["message"].getboolean("fields") and message.fields:
pass
elif content == "":
return
title = message.title.decode('utf-8')
title = title.strip()
if CONFIG["message"].getboolean("title"):
title = message.title.decode('utf-8')
title = title.strip()
else:
title = ""
fields = message.fields
@ -805,6 +832,15 @@ def lxmf_message_received_callback(message):
else:
timestamp = time.time()
if CONFIG["message"].getboolean("fields"):
if message.fields:
fields = message.fields
else:
fields = {}
else:
fields = {}
fields["type"] = CONFIG["lxmf"]["destination_type_conv"]
if CONFIG["statistic"].getboolean("enabled") and CONFIG["statistic"].getboolean("cluster"):
statistic("add", "cluster_in_" + message.desired_method_str)
@ -813,7 +849,7 @@ def lxmf_message_received_callback(message):
if "receive_cluster" in config_get(CONFIG, "rights", section).split(","):
for (key, val) in DATA.items(section):
if key != source_hash:
LXMF_CONNECTION.send(key, content, title, {"type": CONFIG["lxmf"]["destination_type_conv"]}, timestamp, "cluster_send")
LXMF_CONNECTION.send(key, content, title, fields, timestamp, "cluster_send")
elif fields["m_t"] == "pin":
delimiter = CONFIG["interface"]["delimiter_output"]
@ -840,7 +876,7 @@ def lxmf_message_received_callback(message):
if "receive_cluster_pin_add" in config_get(CONFIG, "rights", section).split(","):
for (key, val) in DATA.items(section):
if key != source_hash:
LXMF_CONNECTION.send(key, content_group, "", {"type": CONFIG["lxmf"]["destination_type_conv"]}, None, "cluster_send")
LXMF_CONNECTION.send(key, content_group, "", fields, None, "cluster_send")
if CONFIG["main"].getboolean("auto_save_data"):
DATA.remove_option("main", "unsaved")
@ -849,7 +885,7 @@ def lxmf_message_received_callback(message):
else:
DATA["main"]["unsaved"] = "True"
return
return
if source_right == "" and DATA["main"].getboolean("auto_add_user"):
if CONFIG["lxmf"].getboolean("signature_validated_new") and not message.signature_validated:
@ -1053,7 +1089,13 @@ def lxmf_message_received_callback(message):
if search != "":
content = re.sub(search, config_get(CONFIG, "message", "cluster_send_regex_replace"), content)
fields = defaultdict(dict)
if CONFIG["message"].getboolean("fields"):
if message.fields:
fields = message.fields
else:
fields = {}
else:
fields = {}
fields["c_n"] = CONFIG["cluster"]["name"]
fields["c_t"] = CONFIG["cluster"]["type"]
@ -1087,11 +1129,20 @@ def lxmf_message_received_callback(message):
if destination in config_get(CONFIG, "cluster", "display_name", "", lng_key).split("/"):
cluster_loop = True
if CONFIG["message"].getboolean("fields"):
if message.fields:
fields = message.fields
else:
fields = {}
else:
fields = {}
fields["type"] = CONFIG["lxmf"]["destination_type_conv"]
for section in sections:
if "receive_cluster_send" in config_get(CONFIG, "rights", section).split(",") or (cluster_loop and "receive_cluster_loop" in config_get(CONFIG, "rights", section).split(",")):
for (key, val) in DATA.items(section):
if key != source_hash:
LXMF_CONNECTION.send(key, content, title, {"type": CONFIG["lxmf"]["destination_type_conv"]}, timestamp, "local_send")
LXMF_CONNECTION.send(key, content, title, fields, timestamp, "local_send")
return
@ -1136,6 +1187,15 @@ def lxmf_message_received_callback(message):
content = content_prefix + content + content_suffix
if CONFIG["message"].getboolean("fields"):
if message.fields:
fields = message.fields
else:
fields = {}
else:
fields = {}
fields["type"] = CONFIG["lxmf"]["destination_type_conv"]
if config_get(CONFIG, "message", "timestamp", "", lng_key) == "client":
timestamp = message.timestamp
else:
@ -1153,7 +1213,7 @@ def lxmf_message_received_callback(message):
if "receive_local" in config_get(CONFIG, "rights", section).split(","):
for (key, val) in DATA.items(section):
if key != source_hash:
LXMF_CONNECTION.send(key, content, title, {"type": CONFIG["lxmf"]["destination_type_conv"]}, timestamp, "local_send")
LXMF_CONNECTION.send(key, content, title, fields, timestamp, "local_send")
return
else:
log("LXMF - Source " + RNS.prettyhexrep(message.source_hash) + " 'send' not allowed", LOG_DEBUG)
@ -3861,6 +3921,10 @@ pin_id = %%y%%m%%d-%%H%%M%%S
# Define which message timestamp should be used.
timestamp = client #client/server
# Use title/fields.
title = Yes
fields = Yes

View File

@ -93,7 +93,7 @@ class lxmf_connection:
message_notification_failed_callback = None
def __init__(self, storage_path=None, identity_file="identity", identity=None, destination_name="lxmf", destination_type="delivery", display_name="", send_delay=0, desired_method="direct", propagation_node=None, try_propagation_on_fail=False, announce_startup=False, announce_startup_delay=0, announce_periodic=False, announce_periodic_interval=360, sync_startup=False, sync_startup_delay=0, sync_limit=8, sync_periodic=False, sync_periodic_interval=360):
def __init__(self, storage_path=None, identity_file="identity", identity=None, destination_name="lxmf", destination_type="delivery", display_name="", announce_data=None, send_delay=0, desired_method="direct", propagation_node=None, try_propagation_on_fail=False, announce_startup=False, announce_startup_delay=0, announce_periodic=False, announce_periodic_interval=360, sync_startup=False, sync_startup_delay=0, sync_limit=8, sync_periodic=False, sync_periodic_interval=360):
self.storage_path = storage_path
self.identity_file = identity_file
@ -105,6 +105,7 @@ class lxmf_connection:
self.aspect_filter = self.destination_name + "." + self.destination_type
self.display_name = display_name
self.announce_data = announce_data
self.send_delay = int(send_delay)
@ -160,9 +161,11 @@ class lxmf_connection:
self.message_router = LXMF.LXMRouter(identity=self.identity, storagepath=self.storage_path)
self.destination = self.message_router.register_delivery_identity(self.identity, display_name=self.display_name)
self.message_router.register_delivery_callback(self.process_lxmf_message_propagated)
if self.destination_name == "lxmf" and self.destination_type == "delivery":
self.destination = self.message_router.register_delivery_identity(self.identity, display_name=self.display_name)
self.message_router.register_delivery_callback(self.process_lxmf_message_propagated)
else:
self.destination = RNS.Destination(self.identity, RNS.Destination.IN, RNS.Destination.SINGLE, self.destination_name, self.destination_type)
if self.display_name == "":
self.display_name = RNS.prettyhexrep(self.destination_hash())
@ -362,8 +365,19 @@ class lxmf_connection:
def announce_now(self, app_data=None):
if app_data:
self.destination.announce(app_data.encode("utf-8"))
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) + ":" + app_data, LOG_DEBUG)
if isinstance(app_data, str):
self.destination.announce(app_data.encode("utf-8"))
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) +":" + announce_data, LOG_DEBUG)
else:
self.destination.announce(app_data)
log("LMF - Announced: " + RNS.prettyhexrep(self.destination_hash()), LOG_DEBUG)
elif self.announce_data:
if isinstance(self.announce_data, str):
self.destination.announce(self.announce_data.encode("utf-8"))
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) +":" + self.announce_data, LOG_DEBUG)
else:
self.destination.announce(self.announce_data)
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()), LOG_DEBUG)
else:
self.destination.announce()
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) + ": " + self.display_name, LOG_DEBUG)
@ -538,8 +552,16 @@ def lxmf_message_received_callback(message):
if content == "":
return
title = message.title.decode('utf-8')
title = title.strip()
if CONFIG["message"].getboolean("title"):
title = message.title.decode('utf-8')
title = title.strip()
else:
title = ""
if CONFIG["message"].getboolean("fields"):
fields = message.fields
else:
fields = None
source_hash = RNS.hexrep(message.source_hash, False)
source_name = ""
@ -617,7 +639,7 @@ def lxmf_message_received_callback(message):
if "receive" in section:
for (key, val) in DATA.items(section):
if key != source_hash:
LXMF_CONNECTION.send(key, content, title, None, timestamp)
LXMF_CONNECTION.send(key, content, title, fields, timestamp)
return
else:
log("LXMF - Source " + RNS.prettyhexrep(message.source_hash) + " 'send' not allowed", LOG_DEBUG)
@ -1267,6 +1289,10 @@ send_length_max = 0 #0=any length
# Define which message timestamp should be used.
timestamp = client #client/server
# Use title/fields.
title = Yes
fields = Yes
'''

View File

@ -91,7 +91,7 @@ class lxmf_connection:
message_notification_failed_callback = None
def __init__(self, storage_path=None, identity_file="identity", identity=None, destination_name="lxmf", destination_type="delivery", display_name="", send_delay=0, desired_method="direct", propagation_node=None, try_propagation_on_fail=False, announce_startup=False, announce_startup_delay=0, announce_periodic=False, announce_periodic_interval=360, sync_startup=False, sync_startup_delay=0, sync_limit=8, sync_periodic=False, sync_periodic_interval=360):
def __init__(self, storage_path=None, identity_file="identity", identity=None, destination_name="lxmf", destination_type="delivery", display_name="", announce_data=None, send_delay=0, desired_method="direct", propagation_node=None, try_propagation_on_fail=False, announce_startup=False, announce_startup_delay=0, announce_periodic=False, announce_periodic_interval=360, sync_startup=False, sync_startup_delay=0, sync_limit=8, sync_periodic=False, sync_periodic_interval=360):
self.storage_path = storage_path
self.identity_file = identity_file
@ -103,6 +103,7 @@ class lxmf_connection:
self.aspect_filter = self.destination_name + "." + self.destination_type
self.display_name = display_name
self.announce_data = announce_data
self.send_delay = int(send_delay)
@ -158,9 +159,11 @@ class lxmf_connection:
self.message_router = LXMF.LXMRouter(identity=self.identity, storagepath=self.storage_path)
self.destination = self.message_router.register_delivery_identity(self.identity, display_name=self.display_name)
self.message_router.register_delivery_callback(self.process_lxmf_message_propagated)
if self.destination_name == "lxmf" and self.destination_type == "delivery":
self.destination = self.message_router.register_delivery_identity(self.identity, display_name=self.display_name)
self.message_router.register_delivery_callback(self.process_lxmf_message_propagated)
else:
self.destination = RNS.Destination(self.identity, RNS.Destination.IN, RNS.Destination.SINGLE, self.destination_name, self.destination_type)
if self.display_name == "":
self.display_name = RNS.prettyhexrep(self.destination_hash())
@ -360,8 +363,19 @@ class lxmf_connection:
def announce_now(self, app_data=None):
if app_data:
self.destination.announce(app_data.encode("utf-8"))
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) + ":" + app_data, LOG_DEBUG)
if isinstance(app_data, str):
self.destination.announce(app_data.encode("utf-8"))
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) +":" + announce_data, LOG_DEBUG)
else:
self.destination.announce(app_data)
log("LMF - Announced: " + RNS.prettyhexrep(self.destination_hash()), LOG_DEBUG)
elif self.announce_data:
if isinstance(self.announce_data, str):
self.destination.announce(self.announce_data.encode("utf-8"))
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) +":" + self.announce_data, LOG_DEBUG)
else:
self.destination.announce(self.announce_data)
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()), LOG_DEBUG)
else:
self.destination.announce()
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) + ": " + self.display_name, LOG_DEBUG)
@ -581,7 +595,18 @@ def lxmf_message_received_callback(message):
content = content_prefix + content + content_suffix
LXMF_CONNECTION.send(message.source_hash, content, message.title.decode('utf-8').strip())
if CONFIG["message"].getboolean("title"):
title = message.title.decode('utf-8')
title = title.strip()
else:
title = ""
if CONFIG["message"].getboolean("fields"):
fields = message.fields
else:
fields = None
LXMF_CONNECTION.send(message.source_hash, content, title, fields)
else:
log("LXMF - Source " + RNS.prettyhexrep(message.source_hash) + " not allowed", LOG_DEBUG)
return
@ -1106,6 +1131,10 @@ send_regex_replace =
send_length_min = 0 #0=any length
send_length_max = 0 #0=any length
# Use title/fields.
title = Yes
fields = Yes

View File

@ -92,7 +92,7 @@ class lxmf_connection:
message_notification_failed_callback = None
def __init__(self, storage_path=None, identity_file="identity", identity=None, destination_name="lxmf", destination_type="delivery", display_name="", send_delay=0, desired_method="direct", propagation_node=None, try_propagation_on_fail=False, announce_startup=False, announce_startup_delay=0, announce_periodic=False, announce_periodic_interval=360, sync_startup=False, sync_startup_delay=0, sync_limit=8, sync_periodic=False, sync_periodic_interval=360):
def __init__(self, storage_path=None, identity_file="identity", identity=None, destination_name="lxmf", destination_type="delivery", display_name="", announce_data=None, send_delay=0, desired_method="direct", propagation_node=None, try_propagation_on_fail=False, announce_startup=False, announce_startup_delay=0, announce_periodic=False, announce_periodic_interval=360, sync_startup=False, sync_startup_delay=0, sync_limit=8, sync_periodic=False, sync_periodic_interval=360):
self.storage_path = storage_path
self.identity_file = identity_file
@ -104,6 +104,7 @@ class lxmf_connection:
self.aspect_filter = self.destination_name + "." + self.destination_type
self.display_name = display_name
self.announce_data = announce_data
self.send_delay = int(send_delay)
@ -159,9 +160,11 @@ class lxmf_connection:
self.message_router = LXMF.LXMRouter(identity=self.identity, storagepath=self.storage_path)
self.destination = self.message_router.register_delivery_identity(self.identity, display_name=self.display_name)
self.message_router.register_delivery_callback(self.process_lxmf_message_propagated)
if self.destination_name == "lxmf" and self.destination_type == "delivery":
self.destination = self.message_router.register_delivery_identity(self.identity, display_name=self.display_name)
self.message_router.register_delivery_callback(self.process_lxmf_message_propagated)
else:
self.destination = RNS.Destination(self.identity, RNS.Destination.IN, RNS.Destination.SINGLE, self.destination_name, self.destination_type)
if self.display_name == "":
self.display_name = RNS.prettyhexrep(self.destination_hash())
@ -361,8 +364,19 @@ class lxmf_connection:
def announce_now(self, app_data=None):
if app_data:
self.destination.announce(app_data.encode("utf-8"))
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) + ":" + app_data, LOG_DEBUG)
if isinstance(app_data, str):
self.destination.announce(app_data.encode("utf-8"))
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) +":" + announce_data, LOG_DEBUG)
else:
self.destination.announce(app_data)
log("LMF - Announced: " + RNS.prettyhexrep(self.destination_hash()), LOG_DEBUG)
elif self.announce_data:
if isinstance(self.announce_data, str):
self.destination.announce(self.announce_data.encode("utf-8"))
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) +":" + self.announce_data, LOG_DEBUG)
else:
self.destination.announce(self.announce_data)
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()), LOG_DEBUG)
else:
self.destination.announce()
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) + ": " + self.display_name, LOG_DEBUG)

View File

261
lxmf_provisioning/README.md Normal file
View File

@ -0,0 +1,261 @@
# lxmf_provisioning
This program offers the possibility of provisioning clients. This includes, for example: The announcement of software updates. Registration of new users. Saving telemetry data that the clients send to the server. The data is stored in a PostgreSQL database. The source code can of course be customized to store the data in a different way.
For more information, see the configuration options (at the end of the program files). Everything else is briefly documented there. After the first start this configuration will be created as default config in the corresponding file.
### Features
- Announcement of the server and software versions
- User registration
- Collection of telemetry data
- Storage of data in PostgreSQL, ...
## Examples of use
### General info how the messages/data are transported
All announcements are transmitted unencrypted with their own type/name which is not shown in the Nomadnet/Sideband announcement list.
All messages between client<->server are transported as single 1:1 messages in the LXMF/Reticulum network.
Accordingly, encryption takes place between these end points.
## Current Status
It should currently be considered beta software and still work in progress.
All core features are implemented and functioning, but additions will probably occur as real-world use is explored.
There may be errors or the compatibility after an update is no longer guaranteed.
The full documentation is not yet available. Due to lack of time I can also not say when this will be further processed.
## Screenshots / Usage examples
## Installation manual
### Install:
- Install all required prerequisites. (Default Reticulum installation. Only necessary if reticulum is not yet installed.)
```bash
apt update
apt upgrade
apt install python3-pip
pip install pip --upgrade
reboot
pip3 install rns
pip3 install pyserial netifaces
pip3 install lxmf
```
- Change the Reticulum configuration to suit your needs and use-case.
```bash
nano /.reticulum/config
```
- Download the [file](lxmf_provisioning.py) from this repository.
```bash
wget https://raw.githubusercontent.com/SebastianObi/LXMF-Tools/main/lxmf_provisioning/lxmf_provisioning.py
```
- Make it executable with the following command
```bash
chmod +x lxmf_provisioning.py
```
### Start:
- Start it
```bash
./lxmf_provisioning.py
```
- After the first start edit the configuration file to suit your needs and use-case. The file location is displayed.
- Example minimal configuration (override of the default config `config.cfg`). These are the most relevant settings that need to be adjusted. All other settings are in `config.cfg`
```bash
nano /root/.lxmf_provisioning/config.cfg.owr
```
```bash
```
- Start it again. Finished!
```bash
./lxmf_provisioning.py
```
### Run as a system service/deamon:
- Create a service file.
```bash
nano /etc/systemd/system/lxmf_provisioning.service
```
- Copy and edit the following content to your own needs.
```bash
[Unit]
Description=LXMF Provisioning Daemon
After=multi-user.target
[Service]
# ExecStartPre=/bin/sleep 10
Type=simple
Restart=always
RestartSec=3
User=root
ExecStart=/root/lxmf_provisioning.py
[Install]
WantedBy=multi-user.target
```
- Enable the service.
```bash
systemctl enable lxmf_provisioning
```
- Start the service.
```bash
systemctl start lxmf_provisioning
```
### Start/Stop service:
```bash
systemctl start lxmf_provisioning
systemctl stop lxmf_provisioning
```
### Enable/Disable service:
```bash
systemctl enable lxmf_provisioning
systemctl disable lxmf_provisioning
```
### Run several instances (To copy the same application):
- Run the program with a different configuration path.
```bash
./lxmf_provisioning.py -p /root/.lxmf_provisioning_2nd
./lxmf_provisioning.py -p /root/.lxmf_provisioning_3nd
```
- After the first start edit the configuration file to suit your needs and use-case. The file location is displayed.
### First usage:
- With a manual start via the console, the own LXMF address is displayed:
```
[] ...............................................................................
[] LXMF - Address: <801f48d54bc71cb3e0886944832aaf8d>
[] ...............................................................................`
```
- This address is also annouced at startup in the default setting.
- This provisioning server address must be added to the clients.
- Now the software can be used.
### Startup parameters:
```bash
usage: lxmf_provisioning.py [-h] [-p PATH] [-pr PATH_RNS] [-pl PATH_LOG] [-l LOGLEVEL] [-s] [--exampleconfig] [--exampleconfigoverride]
LXMF Provisioning Server -
optional arguments:
-h, --help show this help message and exit
-p PATH, --path PATH Path to alternative config directory
-pr PATH_RNS, --path_rns PATH_RNS
Path to alternative Reticulum config directory
-pl PATH_LOG, --path_log PATH_LOG
Path to alternative log directory
-l LOGLEVEL, --loglevel LOGLEVEL
-s, --service Running as a service and should log to file
--exampleconfig Print verbose configuration example to stdout and exit
--exampleconfigoverride
Print verbose configuration example to stdout and exit
```
### Config/data files:
- config.cfg
This is the default config file.
- config.cfg.owr
This is the user configuration file to override the default configuration file.
All settings made here have precedence.
This file can be used to clearly summarize all settings that deviate from the default.
This also has the advantage that all changed settings can be kept when updating the program.
## Configuration manual (Examples)
The configurations shown here are only a part of the total configuration.
It only serves to show the configuration that is necessary and adapted for the respective function.
All configurations must be made in the file `config.cfg.owr`.
All possible settings can be seen in the default configuration file `config.cfg`.
### Standard function (Announce versions, user registration, telemetry):
- `config.cfg.owr`
```
[lxmf]
announce_periodic = Yes
announce_periodic_interval = 15 #Minutes
[database]
host = 127.0.0.1
port = 5432
user = postgres
password = password
database = test
table_registration = tbl_account
table_telemetry = tbl_telemetry
[features]
announce_versions = True
registration = True
telemetry = True
[data]
v_s = 0.1.4 #Version software
v_c = 2022-11-29 20:00 #Version config
v_d = 2022-11-29 20:00 #Version data
v_a = 2022-11-29 20:00 #Version auth
u_s = https:// #URL Software
```
### Custom function (Announce versions):
- `config.cfg.owr`
```
[lxmf]
announce_periodic = Yes
announce_periodic_interval = 15 #Minutes
[database]
host = 127.0.0.1
port = 5432
user = postgres
password = password
database = test
table_registration = tbl_account
table_telemetry = tbl_telemetry
[features]
announce_versions = True
registration = False
telemetry = False
[data]
v_s = 0.1.4 #Version software
v_c = 2022-11-29 20:00 #Version config
v_d = 2022-11-29 20:00 #Version data
v_a = 2022-11-29 20:00 #Version auth
u_s = https:// #URL Software
```
## Admin manual
This guide applies to all admins. Here are briefly explained the administative possibilities.
## User manual
This guide applies to users or admins. Here are briefly explained the normal possibilities of the software.
## FAQ
### How do I start with the software?
You should read the `Installation manual` section. There everything is explained briefly. Just work through everything from top to bottom :)

File diff suppressed because it is too large Load Diff

View File

@ -195,7 +195,7 @@ class lxmf_connection:
message_notification_failed_callback = None
def __init__(self, storage_path=None, identity_file="identity", identity=None, destination_name="lxmf", destination_type="delivery", display_name="", send_delay=0, desired_method="direct", propagation_node=None, try_propagation_on_fail=False, announce_startup=False, announce_startup_delay=0, announce_periodic=False, announce_periodic_interval=360, sync_startup=False, sync_startup_delay=0, sync_limit=8, sync_periodic=False, sync_periodic_interval=360):
def __init__(self, storage_path=None, identity_file="identity", identity=None, destination_name="lxmf", destination_type="delivery", display_name="", announce_data=None, send_delay=0, desired_method="direct", propagation_node=None, try_propagation_on_fail=False, announce_startup=False, announce_startup_delay=0, announce_periodic=False, announce_periodic_interval=360, sync_startup=False, sync_startup_delay=0, sync_limit=8, sync_periodic=False, sync_periodic_interval=360):
self.storage_path = storage_path
self.identity_file = identity_file
@ -207,6 +207,7 @@ class lxmf_connection:
self.aspect_filter = self.destination_name + "." + self.destination_type
self.display_name = display_name
self.announce_data = announce_data
self.send_delay = int(send_delay)
@ -262,9 +263,11 @@ class lxmf_connection:
self.message_router = LXMF.LXMRouter(identity=self.identity, storagepath=self.storage_path)
self.destination = self.message_router.register_delivery_identity(self.identity, display_name=self.display_name)
self.message_router.register_delivery_callback(self.process_lxmf_message_propagated)
if self.destination_name == "lxmf" and self.destination_type == "delivery":
self.destination = self.message_router.register_delivery_identity(self.identity, display_name=self.display_name)
self.message_router.register_delivery_callback(self.process_lxmf_message_propagated)
else:
self.destination = RNS.Destination(self.identity, RNS.Destination.IN, RNS.Destination.SINGLE, self.destination_name, self.destination_type)
if self.display_name == "":
self.display_name = RNS.prettyhexrep(self.destination_hash())
@ -464,8 +467,19 @@ class lxmf_connection:
def announce_now(self, app_data=None):
if app_data:
self.destination.announce(app_data.encode("utf-8"))
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) + ":" + app_data, LOG_DEBUG)
if isinstance(app_data, str):
self.destination.announce(app_data.encode("utf-8"))
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) +":" + announce_data, LOG_DEBUG)
else:
self.destination.announce(app_data)
log("LMF - Announced: " + RNS.prettyhexrep(self.destination_hash()), LOG_DEBUG)
elif self.announce_data:
if isinstance(self.announce_data, str):
self.destination.announce(self.announce_data.encode("utf-8"))
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) +":" + self.announce_data, LOG_DEBUG)
else:
self.destination.announce(self.announce_data)
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()), LOG_DEBUG)
else:
self.destination.announce()
log("LXMF - Announced: " + RNS.prettyhexrep(self.destination_hash()) + ": " + self.display_name, LOG_DEBUG)