mirror of
https://github.com/markqvist/Reticulum.git
synced 2024-11-22 21:50:18 +00:00
Compare commits
3 Commits
7375ff1d36
...
60c0aab5d2
Author | SHA1 | Date | |
---|---|---|---|
|
60c0aab5d2 | ||
|
fe054fd03c | ||
|
5c6ee07d66 |
@ -213,7 +213,7 @@ class Identity:
|
|||||||
Get a SHA-256 hash of passed data.
|
Get a SHA-256 hash of passed data.
|
||||||
|
|
||||||
:param data: Data to be hashed as *bytes*.
|
:param data: Data to be hashed as *bytes*.
|
||||||
:returns: SHA-256 hash as *bytes*
|
:returns: SHA-256 hash as *bytes*.
|
||||||
"""
|
"""
|
||||||
return RNS.Cryptography.sha256(data)
|
return RNS.Cryptography.sha256(data)
|
||||||
|
|
||||||
@ -223,7 +223,7 @@ class Identity:
|
|||||||
Get a truncated SHA-256 hash of passed data.
|
Get a truncated SHA-256 hash of passed data.
|
||||||
|
|
||||||
:param data: Data to be hashed as *bytes*.
|
:param data: Data to be hashed as *bytes*.
|
||||||
:returns: Truncated SHA-256 hash as *bytes*
|
:returns: Truncated SHA-256 hash as *bytes*.
|
||||||
"""
|
"""
|
||||||
return Identity.full_hash(data)[:(Identity.TRUNCATED_HASHLENGTH//8)]
|
return Identity.full_hash(data)[:(Identity.TRUNCATED_HASHLENGTH//8)]
|
||||||
|
|
||||||
@ -233,10 +233,24 @@ class Identity:
|
|||||||
Get a random SHA-256 hash.
|
Get a random SHA-256 hash.
|
||||||
|
|
||||||
:param data: Data to be hashed as *bytes*.
|
:param data: Data to be hashed as *bytes*.
|
||||||
:returns: Truncated SHA-256 hash of random data as *bytes*
|
:returns: Truncated SHA-256 hash of random data as *bytes*.
|
||||||
"""
|
"""
|
||||||
return Identity.truncated_hash(os.urandom(Identity.TRUNCATED_HASHLENGTH//8))
|
return Identity.truncated_hash(os.urandom(Identity.TRUNCATED_HASHLENGTH//8))
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def current_ratchet_id(destination_hash):
|
||||||
|
"""
|
||||||
|
Get the ID of the currently used ratchet key for a given destination hash
|
||||||
|
|
||||||
|
:param destination_hash: A destination hash as *bytes*.
|
||||||
|
:returns: A ratchet ID as *bytes* or *None*.
|
||||||
|
"""
|
||||||
|
ratchet = Identity.get_ratchet(destination_hash)
|
||||||
|
if ratchet == None:
|
||||||
|
return None
|
||||||
|
else:
|
||||||
|
return Identity.truncated_hash(ratchet)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _ratchet_public_bytes(ratchet):
|
def _ratchet_public_bytes(ratchet):
|
||||||
return X25519PrivateKey.from_private_bytes(ratchet).public_key().public_bytes()
|
return X25519PrivateKey.from_private_bytes(ratchet).public_key().public_bytes()
|
||||||
|
@ -200,7 +200,7 @@ class TCPClientInterface(Interface):
|
|||||||
if initial:
|
if initial:
|
||||||
RNS.log("Establishing TCP connection for "+str(self)+"...", RNS.LOG_DEBUG)
|
RNS.log("Establishing TCP connection for "+str(self)+"...", RNS.LOG_DEBUG)
|
||||||
|
|
||||||
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
self.socket = socket.socket(socket.AF_INET|socket.AF_INET6, socket.SOCK_STREAM)
|
||||||
self.socket.settimeout(TCPClientInterface.INITIAL_CONNECT_TIMEOUT)
|
self.socket.settimeout(TCPClientInterface.INITIAL_CONNECT_TIMEOUT)
|
||||||
self.socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
|
self.socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
|
||||||
self.socket.connect((self.target_ip, self.target_port))
|
self.socket.connect((self.target_ip, self.target_port))
|
||||||
|
@ -1709,6 +1709,7 @@ class Transport:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
RNS.log("Error while processing external announce callback.", RNS.LOG_ERROR)
|
RNS.log("Error while processing external announce callback.", RNS.LOG_ERROR)
|
||||||
RNS.log("The contained exception was: "+str(e), RNS.LOG_ERROR)
|
RNS.log("The contained exception was: "+str(e), RNS.LOG_ERROR)
|
||||||
|
RNS.trace_exception(e)
|
||||||
|
|
||||||
# Handling for link requests to local destinations
|
# Handling for link requests to local destinations
|
||||||
elif packet.packet_type == RNS.Packet.LINKREQUEST:
|
elif packet.packet_type == RNS.Packet.LINKREQUEST:
|
||||||
|
Loading…
Reference in New Issue
Block a user