Don't reference interface instances in tunnel path lists

This commit is contained in:
Mark Qvist 2025-04-08 13:20:02 +02:00
parent 13b4291840
commit 9f0a4bfe69
3 changed files with 14 additions and 13 deletions

View File

@ -173,16 +173,20 @@ class BackboneInterface(Interface):
@staticmethod
def register_in(fileno):
# TODO: Remove debug
# RNS.log(f"Registering EPOLL_IN for {fileno}", RNS.LOG_DEBUG)
if fileno < 0:
RNS.log(f"Attempt to register invalid file descriptor {fileno}", RNS.LOG_ERROR)
return
try: BackboneInterface.epoll.register(fileno, select.EPOLLIN)
except Exception as e:
RNS.log(f"An error occurred while registering EPOLL_IN for file descriptor {fileno}: {e}", RNS.LOG_ERROR)
@staticmethod
def deregister_fileno(fileno):
# TODO: Remove debug
# RNS.log(f"Deregistering {fileno}", RNS.LOG_DEBUG)
if fileno < 0:
RNS.log(f"Attempt to deregister invalid file descriptor {fileno}", RNS.LOG_ERROR)
return
try: BackboneInterface.epoll.unregister(fileno)
except Exception as e:
RNS.log(f"An error occurred while deregistering file descriptor {fileno}: {e}", RNS.LOG_DEBUG)
@ -223,7 +227,7 @@ class BackboneInterface(Interface):
spawned_interface = BackboneInterface.spawned_interface_filenos[fileno]
client_socket = spawned_interface.socket
if client_socket and fileno == client_socket.fileno() and (event & select.EPOLLIN):
try: received_bytes = client_socket.recv(4096)
try: received_bytes = client_socket.recv(spawned_interface.HW_MTU)
except Exception as e:
RNS.log(f"Error while reading from {spawned_interface}: {e}", RNS.LOG_DEBUG)
received_bytes = b""
@ -647,9 +651,6 @@ class BackboneClientInterface(Interface):
def __str__(self):
if ":" in self.target_ip:
ip_str = f"[{self.target_ip}]"
else:
ip_str = f"{self.target_ip}"
if ":" in self.target_ip: ip_str = f"[{self.target_ip}]"
else: ip_str = f"{self.target_ip}"
return "BackboneInterface["+str(self.name)+"/"+ip_str+":"+str(self.target_port)+"]"

View File

@ -128,7 +128,7 @@ class Interface:
def optimise_mtu(self):
if self.AUTOCONFIGURE_MTU:
if self.bitrate > 500_000_000:
self.HW_MTU = 1048576
self.HW_MTU = 524288
elif self.bitrate > 16_000_000:
self.HW_MTU = 262144
elif self.bitrate > 8_000_000:

View File

@ -1744,7 +1744,7 @@ class Transport:
if hasattr(packet.receiving_interface, "tunnel_id") and packet.receiving_interface.tunnel_id != None:
tunnel_entry = Transport.tunnels[packet.receiving_interface.tunnel_id]
paths = tunnel_entry[IDX_TT_PATHS]
paths[packet.destination_hash] = path_table_entry
paths[packet.destination_hash] = [now, received_from, announce_hops, expires, random_blobs, None, packet.packet_hash]
expires = time.time() + Transport.DESTINATION_TIMEOUT
tunnel_entry[IDX_TT_EXPIRES] = expires
RNS.log("Path to "+RNS.prettyhexrep(packet.destination_hash)+" associated with tunnel "+RNS.prettyhexrep(packet.receiving_interface.tunnel_id), RNS.LOG_DEBUG)
@ -2045,7 +2045,7 @@ class Transport:
received_from = path_entry[1]
announce_hops = path_entry[2]
expires = path_entry[3]
random_blobs = path_entry[4]
random_blobs = list(set(path_entry[4]))
receiving_interface = interface
packet_hash = path_entry[6]
new_entry = [time.time(), received_from, announce_hops, expires, random_blobs, receiving_interface, packet_hash]