Browse Source

Merge pull request #2 from eyakubovich/master

added NewChain method
Eugene Yakubovich 10 năm trước cách đây
mục cha
commit
80a020bab1
1 tập tin đã thay đổi với 5 bổ sung1 xóa
  1. 5 1
      iptables/iptables.go

+ 5 - 1
iptables/iptables.go

@@ -132,10 +132,14 @@ func (ipt *IPTables) List(table, chain string) ([]string, error) {
 	return rules, nil
 	return rules, nil
 }
 }
 
 
+func (ipt *IPTables) NewChain(table, chain string) error {
+	return ipt.run("-t", table, "-N", chain)
+}
+
 // ClearChain flushed (deletes all rules) in the specifed table/chain.
 // ClearChain flushed (deletes all rules) in the specifed table/chain.
 // If the chain does not exist, new one will be created
 // If the chain does not exist, new one will be created
 func (ipt *IPTables) ClearChain(table, chain string) error {
 func (ipt *IPTables) ClearChain(table, chain string) error {
-	err := ipt.run("-t", table, "-N", chain)
+	err := ipt.NewChain(table, chain)
 
 
 	switch {
 	switch {
 	case err == nil:
 	case err == nil: