From 88d974c5629d443827c082dc9a6790936ae9e634 Mon Sep 17 00:00:00 2001 From: Stefan Junker Date: Thu, 31 Mar 2016 17:33:50 +0200 Subject: [PATCH] vendoring: bump coreos/go-iptables to 0.1.0 --- Godeps/Godeps.json | 3 ++- .../coreos/go-iptables/iptables/iptables.go | 25 ++++++++----------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index aad45d93..d0ace65d 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -7,7 +7,8 @@ "Deps": [ { "ImportPath": "github.com/coreos/go-iptables/iptables", - "Rev": "90456be57fcb8185b264b77ce42a9539df42df25" + "Comment": "v0.1.0", + "Rev": "fbb73372b87f6e89951c2b6b31470c2c9d5cfae3" }, { "ImportPath": "github.com/coreos/go-systemd/activation", diff --git a/vendor/github.com/coreos/go-iptables/iptables/iptables.go b/vendor/github.com/coreos/go-iptables/iptables/iptables.go index ea9fedf0..4b2f2f2f 100644 --- a/vendor/github.com/coreos/go-iptables/iptables/iptables.go +++ b/vendor/github.com/coreos/go-iptables/iptables/iptables.go @@ -18,7 +18,6 @@ import ( "bytes" "fmt" "io" - "log" "os/exec" "regexp" "strconv" @@ -44,8 +43,6 @@ type IPTables struct { path string hasCheck bool hasWait bool - - fmu *fileLock } func New() (*IPTables, error) { @@ -55,21 +52,13 @@ func New() (*IPTables, error) { } checkPresent, waitPresent, err := getIptablesCommandSupport() if err != nil { - log.Printf("Error checking iptables version, assuming version at least 1.4.20: %v", err) - checkPresent = true - waitPresent = true + return nil, fmt.Errorf("error checking iptables version: %v", err) } ipt := IPTables{ path: path, hasCheck: checkPresent, hasWait: waitPresent, } - if !waitPresent { - ipt.fmu, err = newXtablesFileLock() - if err != nil { - return nil, err - } - } return &ipt, nil } @@ -81,10 +70,11 @@ func (ipt *IPTables) Exists(table, chain string, rulespec ...string) (bool, erro } cmd := append([]string{"-t", table, "-C", chain}, rulespec...) err := ipt.run(cmd...) + eerr, eok := err.(*Error) switch { case err == nil: return true, nil - case err.(*Error).ExitStatus() == 1: + case eok && eerr.ExitStatus() == 1: return false, nil default: return false, err @@ -148,10 +138,11 @@ func (ipt *IPTables) NewChain(table, chain string) error { func (ipt *IPTables) ClearChain(table, chain string) error { err := ipt.NewChain(table, chain) + eerr, eok := err.(*Error) switch { case err == nil: return nil - case err.(*Error).ExitStatus() == 1: + case eok && eerr.ExitStatus() == 1: // chain already exists. Flush (clear) it. return ipt.run("-t", table, "-F", chain) default: @@ -183,7 +174,11 @@ func (ipt *IPTables) runWithOutput(args []string, stdout io.Writer) error { if ipt.hasWait { args = append(args, "--wait") } else { - ul, err := ipt.fmu.tryLock() + fmu, err := newXtablesFileLock() + if err != nil { + return err + } + ul, err := fmu.tryLock() if err != nil { return err }