|
@@ -18,7 +18,7 @@ func NewIPTables() (*IPTables, error) {
|
|
return &IPTables{path}, nil
|
|
return &IPTables{path}, nil
|
|
}
|
|
}
|
|
|
|
|
|
-func (ipt *IPTables) Exists(table string, args... string) (bool, error) {
|
|
|
|
|
|
+func (ipt *IPTables) Exists(table string, args ...string) (bool, error) {
|
|
cmd := append([]string{"-t", table, "-C"}, args...)
|
|
cmd := append([]string{"-t", table, "-C"}, args...)
|
|
err := exec.Command(ipt.path, cmd...).Run()
|
|
err := exec.Command(ipt.path, cmd...).Run()
|
|
|
|
|
|
@@ -32,13 +32,13 @@ func (ipt *IPTables) Exists(table string, args... string) (bool, error) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-func (ipt *IPTables) Append(table string, args... string) error {
|
|
|
|
|
|
+func (ipt *IPTables) Append(table string, args ...string) error {
|
|
cmd := append([]string{"-t", table, "-A"}, args...)
|
|
cmd := append([]string{"-t", table, "-A"}, args...)
|
|
return exec.Command(ipt.path, cmd...).Run()
|
|
return exec.Command(ipt.path, cmd...).Run()
|
|
}
|
|
}
|
|
|
|
|
|
// AppendUnique acts like Append except that it won't add a duplicate
|
|
// AppendUnique acts like Append except that it won't add a duplicate
|
|
-func (ipt *IPTables) AppendUnique(table string, args... string) error {
|
|
|
|
|
|
+func (ipt *IPTables) AppendUnique(table string, args ...string) error {
|
|
exists, err := ipt.Exists(table, args...)
|
|
exists, err := ipt.Exists(table, args...)
|
|
if err != nil {
|
|
if err != nil {
|
|
return err
|
|
return err
|
|
@@ -66,4 +66,3 @@ func (ipt *IPTables) ClearChain(table, chain string) error {
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|