@@ -197,7 +197,7 @@ options timeout:2 attempts:2
197
197
func (l * LinuxJail ) setupIptables () error {
198
198
// Enable IP forwarding
199
199
cmd := exec .Command ("sysctl" , "-w" , "net.ipv4.ip_forward=1" )
200
- cmd .Run () // Ignore error
200
+ _ = cmd .Run () // Ignore error
201
201
202
202
// NAT rules for outgoing traffic (MASQUERADE for return traffic)
203
203
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 {
222
222
func (l * LinuxJail ) cleanupIptables () error {
223
223
// Remove comprehensive TCP redirect rule
224
224
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
+ }
226
230
227
231
// Remove NAT rule
228
232
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
+ }
230
238
231
239
return nil
232
240
}
@@ -262,4 +270,4 @@ func (l *LinuxJail) removeNamespace() error {
262
270
return fmt .Errorf ("failed to remove namespace: %v" , err )
263
271
}
264
272
return nil
265
- }
273
+ }
0 commit comments