Browse Source

Add debug to iptables

Guillaume J. Charmes 11 years ago
parent
commit
00f1398f7a
1 changed files with 4 additions and 1 deletions
  1. 4 1
      iptables/iptables.go

+ 4 - 1
iptables/iptables.go

@@ -4,6 +4,7 @@ import (
 	"errors"
 	"errors"
 	"fmt"
 	"fmt"
 	"net"
 	"net"
+	"os"
 	"os/exec"
 	"os/exec"
 	"strconv"
 	"strconv"
 	"strings"
 	"strings"
@@ -122,10 +123,12 @@ func Raw(args ...string) ([]byte, error) {
 	if err != nil {
 	if err != nil {
 		return nil, ErrIptablesNotFound
 		return nil, ErrIptablesNotFound
 	}
 	}
+	if os.Getenv("DEBUG") != "" {
+		fmt.Printf("[DEBUG] [iptables]: %s, %v\n", path, args)
+	}
 	output, err := exec.Command(path, args...).CombinedOutput()
 	output, err := exec.Command(path, args...).CombinedOutput()
 	if err != nil {
 	if err != nil {
 		return nil, fmt.Errorf("iptables failed: iptables %v: %s (%s)", strings.Join(args, " "), output, err)
 		return nil, fmt.Errorf("iptables failed: iptables %v: %s (%s)", strings.Join(args, " "), output, err)
 	}
 	}
 	return output, err
 	return output, err
-
 }
 }