Improved shared instance and local client handling

This commit is contained in:
Mark Qvist 2021-10-03 15:23:12 +02:00
parent 4c6ba97dca
commit 75c3180933
4 changed files with 45 additions and 41 deletions

View File

@ -527,7 +527,7 @@ class Link:
else: else:
response_resource = RNS.Resource(packed_response, self, request_id = request_id, is_response = True) response_resource = RNS.Resource(packed_response, self, request_id = request_id, is_response = True)
else: else:
identity_string = RNS.prettyhexrep(self.get_remote_identity()) if self.get_remote_identity() != None else "<Unknown>" identity_string = str(self.get_remote_identity()) if self.get_remote_identity() != None else "<Unknown>"
RNS.log("Request "+RNS.prettyhexrep(request_id)+" from "+identity_string+" not allowed for: "+str(path), RNS.LOG_DEBUG) RNS.log("Request "+RNS.prettyhexrep(request_id)+" from "+identity_string+" not allowed for: "+str(path), RNS.LOG_DEBUG)
def handle_response(self, request_id, response_data, response_size, response_transfer_size): def handle_response(self, request_id, response_data, response_size, response_transfer_size):

View File

@ -193,6 +193,7 @@ class Reticulum:
self.is_shared_instance = False self.is_shared_instance = False
self.is_standalone_instance = False self.is_standalone_instance = False
self.is_connected_to_shared_instance = True self.is_connected_to_shared_instance = True
Reticulum.__transport_enabled = False
RNS.log("Connected to local shared instance via: "+str(interface), RNS.LOG_DEBUG) RNS.log("Connected to local shared instance via: "+str(interface), RNS.LOG_DEBUG)
except Exception as e: except Exception as e:
RNS.log("Local shared instance appears to be running, but it could not be connected", RNS.LOG_ERROR) RNS.log("Local shared instance appears to be running, but it could not be connected", RNS.LOG_ERROR)

View File

@ -831,6 +831,7 @@ class Transport:
# If the announce is from a local client, # If the announce is from a local client,
# we announce it immediately, but only one # we announce it immediately, but only one
# time. # time.
if Transport.from_local_client(packet): if Transport.from_local_client(packet):
retransmit_timeout = now retransmit_timeout = now
retries = Transport.PATHFINDER_R retries = Transport.PATHFINDER_R
@ -858,8 +859,8 @@ class Transport:
announce_data = packet.data announce_data = packet.data
if Transport.from_local_client(packet) and packet.context == RNS.Packet.PATH_RESPONSE: if Transport.from_local_client(packet) and packet.context == RNS.Packet.PATH_RESPONSE:
for interface in Transport.interfaces: for local_interface in Transport.local_client_interfaces:
if packet.receiving_interface != interface: if packet.receiving_interface != local_interface:
new_announce = RNS.Packet( new_announce = RNS.Packet(
announce_destination, announce_destination,
announce_data, announce_data,
@ -868,7 +869,7 @@ class Transport:
header_type = RNS.Packet.HEADER_2, header_type = RNS.Packet.HEADER_2,
transport_type = Transport.TRANSPORT, transport_type = Transport.TRANSPORT,
transport_id = Transport.identity.hash, transport_id = Transport.identity.hash,
attached_interface = interface attached_interface = local_interface
) )
new_announce.hops = packet.hops new_announce.hops = packet.hops
@ -876,6 +877,7 @@ class Transport:
else: else:
for local_interface in Transport.local_client_interfaces: for local_interface in Transport.local_client_interfaces:
if packet.receiving_interface != local_interface:
new_announce = RNS.Packet( new_announce = RNS.Packet(
announce_destination, announce_destination,
announce_data, announce_data,
@ -906,6 +908,7 @@ class Transport:
# Call externally registered callbacks from apps # Call externally registered callbacks from apps
# wanting to know when an announce arrives # wanting to know when an announce arrives
if packet.context != RNS.Packet.PATH_RESPONSE:
for handler in Transport.announce_handlers: for handler in Transport.announce_handlers:
try: try:
# Check that the announced destination matches # Check that the announced destination matches
@ -1353,7 +1356,7 @@ class Transport:
RNS.log("Destination is local to this system, announcing", RNS.LOG_DEBUG) RNS.log("Destination is local to this system, announcing", RNS.LOG_DEBUG)
local_destination.announce(path_response=True) local_destination.announce(path_response=True)
elif (RNS.Reticulum.transport_enabled() or is_from_local_client) and destination_hash in Transport.destination_table: elif (RNS.Reticulum.transport_enabled() or is_from_local_client or len(Transport.local_client_interfaces) > 0) and destination_hash in Transport.destination_table:
RNS.log("Path found, inserting announce for transmission", RNS.LOG_DEBUG) RNS.log("Path found, inserting announce for transmission", RNS.LOG_DEBUG)
packet = Transport.destination_table[destination_hash][6] packet = Transport.destination_table[destination_hash][6]
received_from = Transport.destination_table[destination_hash][5] received_from = Transport.destination_table[destination_hash][5]

View File

@ -1 +1 @@
__version__ = "0.2.6" __version__ = "0.2.7"