mirror of
https://github.com/markqvist/Reticulum.git
synced 2024-11-05 13:50:14 +00:00
Packet hashlist save to disk
This commit is contained in:
parent
eed78798f2
commit
0c49ca8458
@ -53,6 +53,7 @@ class Reticulum:
|
|||||||
|
|
||||||
RNS.Transport.start()
|
RNS.Transport.start()
|
||||||
|
|
||||||
|
atexit.register(RNS.Transport.exitHandler)
|
||||||
atexit.register(RNS.Identity.exitHandler)
|
atexit.register(RNS.Identity.exitHandler)
|
||||||
|
|
||||||
def applyConfig(self):
|
def applyConfig(self):
|
||||||
|
@ -3,6 +3,7 @@ import RNS
|
|||||||
import time
|
import time
|
||||||
import threading
|
import threading
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
import vendor.umsgpack as umsgpack
|
||||||
|
|
||||||
class Transport:
|
class Transport:
|
||||||
# Constants
|
# Constants
|
||||||
@ -42,6 +43,15 @@ class Transport:
|
|||||||
else:
|
else:
|
||||||
RNS.log("Loaded Transport Identity from disk", RNS.LOG_VERBOSE)
|
RNS.log("Loaded Transport Identity from disk", RNS.LOG_VERBOSE)
|
||||||
|
|
||||||
|
packet_hashlist_path = RNS.Reticulum.configdir+"/packet_hashlist"
|
||||||
|
if os.path.isfile(packet_hashlist_path):
|
||||||
|
try:
|
||||||
|
file = open(packet_hashlist_path, "r")
|
||||||
|
Transport.packet_hashlist = umsgpack.unpackb(file.read())
|
||||||
|
file.close()
|
||||||
|
except Exception as e:
|
||||||
|
RNS.log("Could not load packet hashlist from disk, the contained exception was: "+str(e), RNS.LOG_ERROR)
|
||||||
|
|
||||||
|
|
||||||
thread = threading.Thread(target=Transport.jobloop)
|
thread = threading.Thread(target=Transport.jobloop)
|
||||||
thread.setDaemon(True)
|
thread.setDaemon(True)
|
||||||
@ -288,3 +298,13 @@ class Transport:
|
|||||||
def transport_destination():
|
def transport_destination():
|
||||||
# TODO: implement this
|
# TODO: implement this
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def exitHandler():
|
||||||
|
try:
|
||||||
|
packet_hashlist_path = RNS.Reticulum.configdir+"/packet_hashlist"
|
||||||
|
file = open(packet_hashlist_path, "w")
|
||||||
|
file.write(umsgpack.packb(Transport.packet_hashlist))
|
||||||
|
file.close()
|
||||||
|
except Exception as e:
|
||||||
|
RNS.log("Could not save packet hashlist to disk, the contained exception was: "+str(e), RNS.LOG_ERROR)
|
||||||
|
Loading…
Reference in New Issue
Block a user