From a26bda516172f3b67bb1eb58f4fff249a73bbdf3 Mon Sep 17 00:00:00 2001 From: Domingo Dirutigliano Date: Thu, 10 Sep 2026 09:24:47 +0200 Subject: [PATCH] fixup packet been dropped in the first connection --- backend/modules/services/nftables.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/backend/modules/services/nftables.py b/backend/modules/services/nftables.py index 8b06571..be1d91c 100644 --- a/backend/modules/services/nftables.py +++ b/backend/modules/services/nftables.py @@ -268,8 +268,28 @@ class FiregexTables(NFTableManager): ], ) + def reset(self): + super().reset() + import subprocess + try: + subprocess.run(["ip", "rule", "del", "fwmark", "0x1339", "lookup", "1339"], check=False, stderr=subprocess.DEVNULL) + subprocess.run(["ip", "-6", "rule", "del", "fwmark", "0x1339", "lookup", "1339"], check=False, stderr=subprocess.DEVNULL) + # Route rules are often automatically deleted when the rule goes or don't error out if missing, but let's be explicit + except Exception: + pass + def init(self): super().init() + import subprocess + # Configure ip rules for proxy transparent return path + try: + # We don't care about errors if rules already exist etc, but we'll try to add them + subprocess.run(["ip", "rule", "add", "fwmark", "0x1339", "lookup", "1339"], check=False, stderr=subprocess.DEVNULL) + subprocess.run(["ip", "-6", "rule", "add", "fwmark", "0x1339", "lookup", "1339"], check=False, stderr=subprocess.DEVNULL) + subprocess.run(["ip", "route", "add", "local", "default", "dev", "lo", "table", "1339"], check=False, stderr=subprocess.DEVNULL) + subprocess.run(["ip", "-6", "route", "add", "local", "default", "dev", "lo", "table", "1339"], check=False, stderr=subprocess.DEVNULL) + except Exception as e: + print("Failed to configure ip rules for transparent proxy:", e) # --- rule fragments -------------------------------------------------------