From ff1582b8e918c344974ff9737a99152c89be2463 Mon Sep 17 00:00:00 2001 From: Gus Esquivel Date: Tue, 8 May 2018 17:26:04 -0500 Subject: [PATCH] fix for down cmd unknown args error --- iptables/cmd.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/iptables/cmd.go b/iptables/cmd.go index 4512c3a..a8d2681 100644 --- a/iptables/cmd.go +++ b/iptables/cmd.go @@ -35,12 +35,13 @@ func LoadIPv4Rules(rules []byte, restoreCounters bool, persist bool) error { return err } - counterFlag := "" + var args []interface{} if restoreCounters { - counterFlag = "-c" + args = append(args, "-c") } + args = append(args, rulesFile.Name()) - err = sh.Command(ip4tablesRestore, counterFlag, rulesFile.Name()).Run() + err = sh.Command(ip4tablesRestore, args...).Run() if err != nil { return err } @@ -67,12 +68,13 @@ func LoadIPv6Rules(rules []byte, restoreCounters bool, persist bool) error { return err } - counterFlag := "" + var args []interface{} if restoreCounters { - counterFlag = "-c" + args = append(args, "-c") } + args = append(args, rulesFile.Name()) - err = sh.Command(ip6tablesRestore, counterFlag, rulesFile.Name()).Run() + err = sh.Command(ip6tablesRestore, args...).Run() if err != nil { return err }