Fixed inadverdent AutoInterface multi-IF deque hit for resource transfer retries

This commit is contained in:
Mark Qvist 2023-09-14 22:14:31 +02:00
parent 95dec00c76
commit 9889b479d1
3 changed files with 16 additions and 4 deletions

View File

@ -51,7 +51,8 @@ class AutoInterface(Interface):
BITRATE_GUESS = 10*1000*1000
MULTI_IF_DEQUE_LEN = 64
MULTI_IF_DEQUE_LEN = 48
MULTI_IF_DEQUE_TTL = 0.75
def handler_factory(self, callback):
def create_handler(*args, **keys):
@ -93,6 +94,7 @@ class AutoInterface(Interface):
self.multicast_echoes = {}
self.timed_out_interfaces = {}
self.mif_deque = deque(maxlen=AutoInterface.MULTI_IF_DEQUE_LEN)
self.mif_deque_times = deque(maxlen=AutoInterface.MULTI_IF_DEQUE_LEN)
self.carrier_changed = False
self.outbound_udp_socket = None
@ -396,8 +398,16 @@ class AutoInterface(Interface):
def processIncoming(self, data):
data_hash = RNS.Identity.full_hash(data)
if not data_hash in self.mif_deque:
deque_hit = False
if data_hash in self.mif_deque:
for te in self.mif_deque_times:
if te[0] == data_hash and time.time() < te[1]+AutoInterface.MULTI_IF_DEQUE_TTL:
deque_hit = True
break
if not deque_hit:
self.mif_deque.append(data_hash)
self.mif_deque_times.append([data_hash, time.time()])
self.rxb += len(data)
self.owner.inbound(data, self)

View File

@ -662,6 +662,7 @@ class Resource:
for map_hash in self.hashmap[self.consecutive_completed_height:self.consecutive_completed_height+self.window]:
if map_hash == part_hash:
if self.parts[i] == None:
# Insert data into parts list
self.parts[i] = part_data
self.rtt_rxd_bytes += len(part_data)
@ -761,6 +762,7 @@ class Resource:
self.req_sent = self.last_activity
self.req_sent_bytes = len(request_packet.raw)
self.req_resp = None
except Exception as e:
RNS.log("Could not send resource request packet, cancelling resource", RNS.LOG_DEBUG)
RNS.log("The contained exception was: "+str(e), RNS.LOG_DEBUG)

View File

@ -1168,7 +1168,7 @@ class Transport:
# Also check that expected hop count matches
if packet.hops == link_entry[5]:
outbound_interface = link_entry[2]
if outbound_interface != None:
new_raw = packet.raw[0:1]
new_raw += struct.pack("!B", packet.hops)
@ -1494,7 +1494,7 @@ class Transport:
RNS.log("Error while processing external announce callback.", RNS.LOG_ERROR)
RNS.log("The contained exception was: "+str(e), RNS.LOG_ERROR)
# Handling for linkrequests to local destinations
# Handling for link requests to local destinations
elif packet.packet_type == RNS.Packet.LINKREQUEST:
if packet.transport_id == None or packet.transport_id == Transport.identity.hash:
for destination in Transport.destinations: