mirror of
https://github.com/liberatedsystems/openCom-Companion.git
synced 2024-12-28 13:08:39 +01:00
Validate propagation node data before logging it
This commit is contained in:
parent
c14699151d
commit
46450098b4
@ -10,6 +10,7 @@ import shlex
|
|||||||
|
|
||||||
import RNS.vendor.umsgpack as msgpack
|
import RNS.vendor.umsgpack as msgpack
|
||||||
import RNS.Interfaces.Interface as Interface
|
import RNS.Interfaces.Interface as Interface
|
||||||
|
from LXMF import pn_announce_data_is_valid
|
||||||
|
|
||||||
import multiprocessing.connection
|
import multiprocessing.connection
|
||||||
|
|
||||||
@ -46,6 +47,7 @@ class PropagationNodeDetector():
|
|||||||
def received_announce(self, destination_hash, announced_identity, app_data):
|
def received_announce(self, destination_hash, announced_identity, app_data):
|
||||||
try:
|
try:
|
||||||
if app_data != None and len(app_data) > 0:
|
if app_data != None and len(app_data) > 0:
|
||||||
|
if pn_announce_data_is_valid(app_data):
|
||||||
unpacked = msgpack.unpackb(app_data)
|
unpacked = msgpack.unpackb(app_data)
|
||||||
node_active = unpacked[0]
|
node_active = unpacked[0]
|
||||||
emitted = unpacked[1]
|
emitted = unpacked[1]
|
||||||
@ -62,7 +64,7 @@ class PropagationNodeDetector():
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
RNS.log("Detected active propagation node "+RNS.prettyhexrep(destination_hash)+" emission "+str(age)+" seconds ago, "+str(hops)+" hops away")
|
RNS.log("Detected active propagation node "+RNS.prettyhexrep(destination_hash)+" emission "+str(age)+" seconds ago, "+str(hops)+" hops away")
|
||||||
self.owner.log_announce(destination_hash, RNS.prettyhexrep(destination_hash).encode("utf-8"), dest_type=PropagationNodeDetector.aspect_filter)
|
self.owner.log_announce(destination_hash, app_data, dest_type=PropagationNodeDetector.aspect_filter)
|
||||||
|
|
||||||
if self.owner.config["lxmf_propagation_node"] == None:
|
if self.owner.config["lxmf_propagation_node"] == None:
|
||||||
if self.owner.active_propagation_node == None:
|
if self.owner.active_propagation_node == None:
|
||||||
@ -76,6 +78,12 @@ class PropagationNodeDetector():
|
|||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
else:
|
||||||
|
RNS.log(f"Received malformed propagation node announce from {RNS.prettyhexrep(destination_hash)} with data: {app_data}", RNS.LOG_DEBUG)
|
||||||
|
|
||||||
|
else:
|
||||||
|
RNS.log(f"Received malformed propagation node announce from {RNS.prettyhexrep(destination_hash)} with data: {app_data}", RNS.LOG_DEBUG)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
RNS.log("Error while processing received propagation node announce: "+str(e))
|
RNS.log("Error while processing received propagation node announce: "+str(e))
|
||||||
|
|
||||||
@ -910,6 +918,7 @@ class SidebandCore():
|
|||||||
try:
|
try:
|
||||||
if app_data == None:
|
if app_data == None:
|
||||||
app_data = b""
|
app_data = b""
|
||||||
|
if type(app_data) != bytes:
|
||||||
app_data = msgpack.packb([app_data, stamp_cost])
|
app_data = msgpack.packb([app_data, stamp_cost])
|
||||||
RNS.log("Received "+str(dest_type)+" announce for "+RNS.prettyhexrep(dest)+" with data: "+str(app_data), RNS.LOG_DEBUG)
|
RNS.log("Received "+str(dest_type)+" announce for "+RNS.prettyhexrep(dest)+" with data: "+str(app_data), RNS.LOG_DEBUG)
|
||||||
self._db_save_announce(dest, app_data, dest_type)
|
self._db_save_announce(dest, app_data, dest_type)
|
||||||
|
Loading…
Reference in New Issue
Block a user