This commit is contained in:
Mark Qvist 2026-08-25 01:44:50 +02:00
parent f111709902
commit 17e980ff79
No known key found for this signature in database

View file

@ -134,7 +134,6 @@ class Transport:
PATH_REQUEST_RG = 1.5 # Extra grace time for roaming-mode interfaces to allow more suitable peers to respond first
PATH_REQUEST_MI = 20 # Minimum interval in seconds for automated path requests
USE_FP_CACHE = True
USE_INBOUND_QUEUE = True
USE_OUTBOUND_QUEUE = False
INBOUND_DA_QUEUE_LENGTH = 4096
@ -1797,34 +1796,6 @@ class Transport:
packet.receiving_interface = interface
packet.hops += 1
if Transport.USE_FP_CACHE:
fp_entry = Transport.link_fp_cache.get(packet.destination_hash, None)
if fp_entry:
fp_hops = packet.hops
if len(Transport.local_client_interfaces) > 0:
if Transport.is_local_client_interface(packet.receiving_interface): fp_hops -= 1
elif Transport.interface_to_shared_instance(packet.receiving_interface): fp_hops -= 1
if fp_entry[0] and (fp_hops == fp_entry[1] or fp_hops == fp_entry[2]): outbound_interface = fp_entry[3]
elif packet.receiving_interface == fp_entry[3] and fp_hops == fp_entry[1]: outbound_interface = fp_entry[4]
elif packet.receiving_interface == fp_entry[4] and fp_hops == fp_entry[2]: outbound_interface = fp_entry[3]
else: outbound_interface = None
if outbound_interface:
nhops = fp_hops if not fp_entry[5] or fp_entry[5] != outbound_interface else Transport.local_hops_delta
# RNS.log(f"{packet.receiving_interface} -> {outbound_interface} {nhops}")
Transport.add_packet_hash(packet.packet_hash)
new_raw = packet.raw[0:1]
new_raw += struct.pack("!B", nhops)
new_raw += packet.raw[2:]
Transport.transmit(outbound_interface, new_raw)
Transport.link_table[packet.destination_hash][IDX_LT_TIMESTAMP] = time.time()
# RNS.log(f"FP CACHE HIT", RNS.LOG_CRITICAL)
return
# else: RNS.log(f"FP CACHE MISS", RNS.LOG_CRITICAL)
# RNS.log(f"FP CACHE OUTBOUND MISS {packet.hops} {packet.receiving_interface}\n{fp_entry}")
# Ingress limit announces early
if packet.packet_type == RNS.Packet.ANNOUNCE:
if not tc: traffic_class = Transport.TC_ANNOUNCE
@ -2158,13 +2129,11 @@ class Transport:
# the same for this link, direction doesn't
# matter, and we simply repeat the packet.
outbound_interface = None
same_iface = False
if link_entry[IDX_LT_NH_IF] == link_entry[IDX_LT_RCVD_IF]:
# But check that taken hops matches one
# of the expectede values.
if packet.hops == link_entry[IDX_LT_REM_HOPS] or packet.hops == link_entry[IDX_LT_HOPS]:
outbound_interface = link_entry[IDX_LT_NH_IF]
same_iface = True
else:
# If interfaces differ, we transmit on
# the opposite interface of what the
@ -2190,18 +2159,6 @@ class Transport:
Transport.transmit(outbound_interface, new_raw)
Transport.link_table[packet.destination_hash][IDX_LT_TIMESTAMP] = time.time()
if Transport.USE_FP_CACHE and not packet.destination_hash in Transport.link_fp_cache:
if from_local_client and not instance_local_link and Transport.local_hops_delta != 0: mangle_to = outbound_interface
elif to_local_client and not instance_local_link and Transport.local_hops_delta != 0: mangle_to = link_entry[IDX_LT_NH_IF] if outbound_interface != link_entry[IDX_LT_NH_IF] else link_entry[IDX_LT_RCVD_IF]
else: mangle_to = None
RNS.log(f"MANGLING TO: {mangle_to}")
Transport.link_fp_cache[packet.destination_hash] = (same_iface, link_entry[IDX_LT_HOPS], link_entry[IDX_LT_REM_HOPS],
link_entry[IDX_LT_RCVD_IF], link_entry[IDX_LT_NH_IF],
mangle_to)
RNS.log(f"FP-CACHED {RNS.prettyhexrep(packet.destination_hash)}")
else:
RNS.log(f"No-outbound return on link packet from {packet.receiving_interface}", RNS.LOG_WARNING) # TODO: Remove