From 7506027b5a4d29d1653e45e8c2d0d8febdf6fc4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Wed, 3 Jul 2024 22:57:54 +0800 Subject: [PATCH] auto-redirect: Fix iptables clean --- redirect_iptables.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/redirect_iptables.go b/redirect_iptables.go index f7df428..08cacae 100644 --- a/redirect_iptables.go +++ b/redirect_iptables.go @@ -235,18 +235,26 @@ func (r *autoRedirect) cleanupIPTables() { } func (r *autoRedirect) cleanupIPTablesForFamily(iptablesPath string) { + tableNameInput := r.tableName + "-input" tableNameOutput := r.tableName + "-output" tableNameForward := r.tableName + "-forward" tableNamePreRouteing := r.tableName + "-prerouting" + _ = r.runShell(iptablesPath, "-t nat -D OUTPUT -j", tableNameOutput) _ = r.runShell(iptablesPath, "-t nat -F", tableNameOutput) _ = r.runShell(iptablesPath, "-t nat -X", tableNameOutput) if runtime.GOOS == "android" { return } + + _ = r.runShell(iptablesPath, "-D INPUT -j", tableNameInput) + _ = r.runShell(iptablesPath, "-F", tableNameInput) + _ = r.runShell(iptablesPath, "-X", tableNameInput) + _ = r.runShell(iptablesPath, "-D FORWARD -j", tableNameForward) _ = r.runShell(iptablesPath, "-F", tableNameForward) _ = r.runShell(iptablesPath, "-X", tableNameForward) + _ = r.runShell(iptablesPath, "-t nat -D PREROUTING -j", tableNamePreRouteing) _ = r.runShell(iptablesPath, "-t nat -F", tableNamePreRouteing) _ = r.runShell(iptablesPath, "-t nat -X", tableNamePreRouteing)