From 00f1398f7a8543e2448723635d93ea6ddf1eaadb Mon Sep 17 00:00:00 2001 From: "Guillaume J. Charmes" Date: Wed, 6 Nov 2013 07:37:43 -0800 Subject: [PATCH] Add debug to iptables --- iptables/iptables.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/iptables/iptables.go b/iptables/iptables.go index 8139b9881..82ecf8bb5 100644 --- a/iptables/iptables.go +++ b/iptables/iptables.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "net" + "os" "os/exec" "strconv" "strings" @@ -122,10 +123,12 @@ func Raw(args ...string) ([]byte, error) { if err != nil { return nil, ErrIptablesNotFound } + if os.Getenv("DEBUG") != "" { + fmt.Printf("[DEBUG] [iptables]: %s, %v\n", path, args) + } output, err := exec.Command(path, args...).CombinedOutput() if err != nil { return nil, fmt.Errorf("iptables failed: iptables %v: %s (%s)", strings.Join(args, " "), output, err) } return output, err - }