Skip to content

Commit 7506027

Browse files
committed
auto-redirect: Fix iptables clean
1 parent 7c4975c commit 7506027

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

redirect_iptables.go

+8
Original file line numberDiff line numberDiff line change
@@ -235,18 +235,26 @@ func (r *autoRedirect) cleanupIPTables() {
235235
}
236236

237237
func (r *autoRedirect) cleanupIPTablesForFamily(iptablesPath string) {
238+
tableNameInput := r.tableName + "-input"
238239
tableNameOutput := r.tableName + "-output"
239240
tableNameForward := r.tableName + "-forward"
240241
tableNamePreRouteing := r.tableName + "-prerouting"
242+
241243
_ = r.runShell(iptablesPath, "-t nat -D OUTPUT -j", tableNameOutput)
242244
_ = r.runShell(iptablesPath, "-t nat -F", tableNameOutput)
243245
_ = r.runShell(iptablesPath, "-t nat -X", tableNameOutput)
244246
if runtime.GOOS == "android" {
245247
return
246248
}
249+
250+
_ = r.runShell(iptablesPath, "-D INPUT -j", tableNameInput)
251+
_ = r.runShell(iptablesPath, "-F", tableNameInput)
252+
_ = r.runShell(iptablesPath, "-X", tableNameInput)
253+
247254
_ = r.runShell(iptablesPath, "-D FORWARD -j", tableNameForward)
248255
_ = r.runShell(iptablesPath, "-F", tableNameForward)
249256
_ = r.runShell(iptablesPath, "-X", tableNameForward)
257+
250258
_ = r.runShell(iptablesPath, "-t nat -D PREROUTING -j", tableNamePreRouteing)
251259
_ = r.runShell(iptablesPath, "-t nat -F", tableNamePreRouteing)
252260
_ = r.runShell(iptablesPath, "-t nat -X", tableNamePreRouteing)

0 commit comments

Comments
 (0)