Skip to content

Commit 6d34180

Browse files
committed
fix
1 parent 884839f commit 6d34180

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

jail/linux.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ options timeout:2 attempts:2
197197
func (l *LinuxJail) setupIptables() error {
198198
// Enable IP forwarding
199199
cmd := exec.Command("sysctl", "-w", "net.ipv4.ip_forward=1")
200-
cmd.Run() // Ignore error
200+
_ = cmd.Run() // Ignore error
201201

202202
// NAT rules for outgoing traffic (MASQUERADE for return traffic)
203203
cmd = exec.Command("iptables", "-t", "nat", "-A", "POSTROUTING", "-s", "192.168.100.0/24", "-j", "MASQUERADE")
@@ -222,11 +222,19 @@ func (l *LinuxJail) setupIptables() error {
222222
func (l *LinuxJail) cleanupIptables() error {
223223
// Remove comprehensive TCP redirect rule
224224
cmd := exec.Command("iptables", "-t", "nat", "-D", "PREROUTING", "-i", l.vethHost, "-p", "tcp", "-j", "REDIRECT", "--to-ports", fmt.Sprintf("%d", l.httpProxyPort))
225-
cmd.Run() // Ignore errors during cleanup
225+
err := cmd.Run()
226+
if err != nil {
227+
l.logger.Error("Failed to remove TCP redirect rule", "error", err)
228+
// Continue with other cleanup even if this fails
229+
}
226230

227231
// Remove NAT rule
228232
cmd = exec.Command("iptables", "-t", "nat", "-D", "POSTROUTING", "-s", "192.168.100.0/24", "-j", "MASQUERADE")
229-
cmd.Run() // Ignore errors during cleanup
233+
err = cmd.Run()
234+
if err != nil {
235+
l.logger.Error("Failed to remove NAT rule", "error", err)
236+
// Continue with other cleanup even if this fails
237+
}
230238

231239
return nil
232240
}
@@ -262,4 +270,4 @@ func (l *LinuxJail) removeNamespace() error {
262270
return fmt.Errorf("failed to remove namespace: %v", err)
263271
}
264272
return nil
265-
}
273+
}

0 commit comments

Comments
 (0)