Implemented resources

This commit is contained in:
Mark Qvist
2018-04-18 23:31:17 +02:00
parent 19d9b1a4a5
commit de8d9cf722
10 changed files with 1891 additions and 183 deletions
+7 -8
View File
@@ -4,7 +4,7 @@ import os
import RNS
import time
import atexit
import cPickle
import vendor.umsgpack as umsgpack
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import serialization
@@ -61,7 +61,7 @@ class Identity:
def saveKnownDestinations():
RNS.log("Saving known destinations to storage...", RNS.LOG_VERBOSE)
file = open(RNS.Reticulum.storagepath+"/known_destinations","w")
cPickle.dump(Identity.known_destinations, file)
umsgpack.dump(Identity.known_destinations, file)
file.close()
RNS.log("Done saving known destinations to storage", RNS.LOG_VERBOSE)
@@ -69,7 +69,7 @@ class Identity:
def loadKnownDestinations():
if os.path.isfile(RNS.Reticulum.storagepath+"/known_destinations"):
file = open(RNS.Reticulum.storagepath+"/known_destinations","r")
Identity.known_destinations = cPickle.load(file)
Identity.known_destinations = umsgpack.load(file)
file.close()
RNS.log("Loaded "+str(len(Identity.known_destinations))+" known destinations from storage", RNS.LOG_VERBOSE)
else:
@@ -89,6 +89,10 @@ class Identity:
return digest.finalize()[:10]
@staticmethod
def getRandomHash():
return Identity.truncatedHash(os.urandom(10))
@staticmethod
def validateAnnounce(packet):
if packet.packet_type == RNS.Packet.ANNOUNCE:
@@ -276,8 +280,3 @@ class Identity:
proof = RNS.Packet(destination, proof_data, RNS.Packet.PROOF)
proof.send()
def getRandomHash(self):
return self.truncatedHash(os.urandom(10))