Merge branch 'SebastianObi:main' into main

This commit is contained in:
Swissbandit 2023-06-07 02:40:49 +02:00 committed by GitHub
commit 576e824860
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 2775 additions and 177 deletions

View file

@ -99,6 +99,7 @@ The full documentation is not yet available. Due to lack of time I can also not
Restart=always
RestartSec=3
User=root
Group=root
ExecStart=/root/lxmf_terminal.py
[Install]
WantedBy=multi-user.target

View file

@ -384,13 +384,13 @@ class lxmf_connection:
if len(destination) != ((RNS.Reticulum.TRUNCATED_HASHLENGTH//8)*2):
log("LXMF - Destination length is invalid", LOG_ERROR)
return
return None
try:
destination = bytes.fromhex(destination)
except Exception as e:
log("LXMF - Destination is invalid", LOG_ERROR)
return
return None
if destination_name == None:
destination_name = self.destination_name
@ -399,7 +399,7 @@ class lxmf_connection:
destination_identity = RNS.Identity.recall(destination)
destination = RNS.Destination(destination_identity, RNS.Destination.OUT, RNS.Destination.SINGLE, destination_name, destination_type)
self.send_message(destination, self.destination, content, title, fields, timestamp, app_data)
return self.send_message(destination, self.destination, content, title, fields, timestamp, app_data)
def send_message(self, destination, source, content="", title="", fields=None, timestamp=None, app_data=""):
@ -430,10 +430,11 @@ class lxmf_connection:
try:
self.message_router.handle_outbound(message)
time.sleep(self.send_delay)
return message.hash
except Exception as e:
log("LXMF - Could not send message " + str(message), LOG_ERROR)
log("LXMF - The contained exception was: " + str(e), LOG_ERROR)
return
return None
def message_notification(self, message):
@ -728,8 +729,18 @@ class lxmf_announce_callback:
@staticmethod
def received_announce(destination_hash, announced_identity, app_data):
if app_data != None:
log("LXMF - Received an announce from " + RNS.prettyhexrep(destination_hash) + ": " + app_data.decode("utf-8"), LOG_INFO)
if app_data == None:
return
if len(app_data) == 0:
return
try:
app_data = app_data.decode("utf-8").strip()
except:
return
log("LXMF - Received an announce from " + RNS.prettyhexrep(destination_hash) + ": " + app_data, LOG_INFO)
@ -746,7 +757,36 @@ def lxmf_message_received_callback(message):
if TERMINAL:
SESSION["source"] = message.source_hash
content = message.content.decode('utf-8')
title = message.title.decode('utf-8').strip()
denys = config_get(CONFIG, "message", "deny_title")
if denys != "":
denys = denys.split(",")
if "*" in denys:
return
for deny in denys:
if deny in title:
return
content = message.content.decode('utf-8').strip()
denys = config_get(CONFIG, "message", "deny_content")
if denys != "":
denys = denys.split(",")
if "*" in denys:
return
for deny in denys:
if deny in title:
return
if message.fields:
denys = config_get(CONFIG, "message", "deny_fields")
if denys != "":
denys = denys.split(",")
if "*" in denys:
return
for deny in denys:
if deny in message.fields:
return
length = config_getint(CONFIG, "message", "receive_length_min", 0)
if length> 0:
@ -1064,6 +1104,19 @@ def val_to_bool(val, fallback_true=True, fallback_false=False):
return fallback_false
def val_to_val(val):
if val.isdigit():
return int(val)
elif val.isnumeric():
return float(val)
elif val.lower() == "true":
return True
elif val.lower() == "false":
return False
else:
return val
##############################################################################################################
# Log
@ -1429,6 +1482,13 @@ interval = 5 #Seconds
#### Message settings ####
[message]
# Deny message if the title/content/fields contains the following content.
# Comma-separated list with text or field keys.
# *=any
deny_title =
deny_content =
deny_fields =
# Text is added.
receive_prefix =
receive_suffix =