Skip to content

Commit

Permalink
auto-redirect: Fix iptables clean
Browse files Browse the repository at this point in the history
  • Loading branch information
nekohasekai committed Jul 3, 2024
1 parent 7c4975c commit 7506027
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions redirect_iptables.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7506027

Please sign in to comment.