chore(firewall/iptables): log restore data on failure to restore

This commit is contained in:
Quentin McGaw
2026-03-23 14:03:30 +00:00
parent 405a6f699d
commit 57cf276d31
+6 -2
View File
@@ -54,7 +54,7 @@ func (c *Config) saveAndRestoreIPv4(ctx context.Context) (restore func(context.C
cmd.Stdin = strings.NewReader(data)
output, err := c.runner.Run(cmd)
if err != nil {
c.logger.Warn(fmt.Sprintf("restoring IPv4 iptables failed: %v: %s", err, output))
c.logger.Warn(fmt.Sprintf("restoring IPv4 iptables failed: %s", makeRestoreErrorMessage(err, output, data)))
}
}
return restore, nil
@@ -78,8 +78,12 @@ func (c *Config) saveAndRestoreIPv6(ctx context.Context) (restore func(context.C
cmd.Stdin = strings.NewReader(data)
output, err := c.runner.Run(cmd)
if err != nil {
c.logger.Warn(fmt.Sprintf("restoring IPv6 iptables failed: %v: %s", err, output))
c.logger.Warn(fmt.Sprintf("restoring IPv6 iptables failed: %s", makeRestoreErrorMessage(err, output, data)))
}
}
return restore, nil
}
func makeRestoreErrorMessage(err error, output, data string) string {
return fmt.Sprintf("%s: %s: restoring from data:\n%s", err, output, data)
}