diff --git a/RNS/Interfaces/KISSInterface.py b/RNS/Interfaces/KISSInterface.py index 3a12734..f39a36a 100644 --- a/RNS/Interfaces/KISSInterface.py +++ b/RNS/Interfaces/KISSInterface.py @@ -151,7 +151,7 @@ class KISSInterface(Interface): if written != len(kiss_command): raise IOError("Could not configure KISS interface slot time to "+str(slottime_ms)+" (command value "+str(slottime)+")") - def setFlowControl(self, flow_control): + def setFlowControl(self, flow_control): kiss_command = KISS.FEND+KISS.CMD_READY+chr(0x01)+KISS.FEND written = self.serial.write(kiss_command) if written != len(kiss_command): diff --git a/RNS/Reticulum.py b/RNS/Reticulum.py index 6c6cd8a..3e1b6a7 100755 --- a/RNS/Reticulum.py +++ b/RNS/Reticulum.py @@ -53,6 +53,7 @@ class Reticulum: RNS.Transport.start() + atexit.register(RNS.Transport.exitHandler) atexit.register(RNS.Identity.exitHandler) def applyConfig(self): diff --git a/RNS/Transport.py b/RNS/Transport.py index 805dfe6..b371c16 100755 --- a/RNS/Transport.py +++ b/RNS/Transport.py @@ -3,6 +3,7 @@ import RNS import time import threading from time import sleep +import vendor.umsgpack as umsgpack class Transport: # Constants @@ -42,6 +43,15 @@ class Transport: else: 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.setDaemon(True) @@ -288,3 +298,13 @@ class Transport: def transport_destination(): # TODO: implement this 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)