diff --git a/go.mod b/go.mod index e75eb9097..40711979e 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module k8s.io/ingress-nginx go 1.13 require ( - github.com/armon/go-proxyproto v0.0.0-20190211145416-68259f75880e + github.com/armon/go-proxyproto v0.0.0-20200108142055-f0b8253b1507 github.com/eapache/channels v1.1.0 github.com/eapache/queue v1.1.0 // indirect github.com/fullsailor/pkcs7 v0.0.0-20190404230743-d7302db945fa // indirect @@ -11,7 +11,7 @@ require ( github.com/imdario/mergo v0.3.7 github.com/json-iterator/go v1.1.9 github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348 - github.com/mitchellh/go-ps v0.0.0-20170309133038-4fdf99ab2936 + github.com/mitchellh/go-ps v1.0.0 github.com/mitchellh/hashstructure v1.0.0 github.com/mitchellh/mapstructure v1.1.2 github.com/moul/pb v0.0.0-20180404114147-54bdd96e6a52 @@ -20,8 +20,7 @@ require ( github.com/onsi/gomega v1.8.1 github.com/opencontainers/runc v1.0.0-rc9 github.com/parnurzeal/gorequest v0.2.16 - github.com/paultag/sniff v0.0.0-20200207005214-cf7e4d167732 - github.com/pkg/errors v0.8.1 + github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.4.0 github.com/prometheus/client_model v0.2.0 github.com/prometheus/common v0.9.1 @@ -46,7 +45,7 @@ require ( k8s.io/klog v1.0.0 k8s.io/kubernetes v1.17.2 moul.io/http2curl v1.0.0 // indirect - pault.ag/go/sniff v0.0.0-20200207005214-cf7e4d167732 // indirect + pault.ag/go/sniff v0.0.0-20200207005214-cf7e4d167732 sigs.k8s.io/controller-runtime v0.4.0 ) diff --git a/go.sum b/go.sum index 68d2adf4f..51de75f6c 100644 --- a/go.sum +++ b/go.sum @@ -51,8 +51,8 @@ github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= -github.com/armon/go-proxyproto v0.0.0-20190211145416-68259f75880e h1:h0gP0hBU6DsA5IQduhLWGOEfIUKzJS5hhXQBSgHuF/g= -github.com/armon/go-proxyproto v0.0.0-20190211145416-68259f75880e/go.mod h1:QmP9hvJ91BbJmGVGSbutW19IC0Q9phDCLGaomwTJbgU= +github.com/armon/go-proxyproto v0.0.0-20200108142055-f0b8253b1507 h1:dmVRVC/MmuwC2edm/P6oWIP+9n+p9IgVgK0lq9mBQjU= +github.com/armon/go-proxyproto v0.0.0-20200108142055-f0b8253b1507/go.mod h1:QmP9hvJ91BbJmGVGSbutW19IC0Q9phDCLGaomwTJbgU= github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= github.com/auth0/go-jwt-middleware v0.0.0-20170425171159-5493cabe49f7/go.mod h1:LWMyo4iOLWXHGdBki7NIht1kHru/0wM179h+d3g8ATM= @@ -427,6 +427,8 @@ github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrk github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-ps v0.0.0-20170309133038-4fdf99ab2936 h1:kw1v0NlnN+GZcU8Ma8CLF2Zzgjfx95gs3/GN3vYAPpo= github.com/mitchellh/go-ps v0.0.0-20170309133038-4fdf99ab2936/go.mod h1:r1VsdOzOPt1ZSrGZWFoNhsAedKnEd6r9Np1+5blZCWk= +github.com/mitchellh/go-ps v1.0.0 h1:i6ampVEEF4wQFF+bkYfwYgY+F/uYJDktmvLPf7qIgjc= +github.com/mitchellh/go-ps v1.0.0/go.mod h1:J4lOc8z8yJs6vUwklHw2XEIiT4z4C40KtWVN3nvg8Pg= github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= github.com/mitchellh/hashstructure v1.0.0 h1:ZkRJX1CyOoTkar7p/mLS5TZU4nJ1Rn/F8u9dGS02Q3Y= github.com/mitchellh/hashstructure v1.0.0/go.mod h1:QjSHrPWS+BGUVBYkbTZWEnOh3G1DutKwClXU/ABz6AQ= @@ -494,10 +496,6 @@ github.com/opencontainers/runtime-spec v1.0.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/ github.com/opencontainers/selinux v1.3.1-0.20190929122143-5215b1806f52/go.mod h1:+BLncwf63G4dgOzykXAxcmnFlUaOlkDdmw/CqsW6pjs= github.com/parnurzeal/gorequest v0.2.16 h1:T/5x+/4BT+nj+3eSknXmCTnEVGSzFzPGdpqmUVVZXHQ= github.com/parnurzeal/gorequest v0.2.16/go.mod h1:3Kh2QUMJoqw3icWAecsyzkpY7UzRfDhbRdTjtNwNiUE= -github.com/paultag/sniff v0.0.0-20170624152000-87325c3dddf4 h1:bOK8V55gl1AEWE9KiXSZ0fzARvVBehdmYZOTFcQ5kUo= -github.com/paultag/sniff v0.0.0-20170624152000-87325c3dddf4/go.mod h1:J3XXNGJINXLa4yIivdUT0Ad/srv2q0pSOWbbm6El2EY= -github.com/paultag/sniff v0.0.0-20200207005214-cf7e4d167732 h1:nkseUkzjazCNyGhkRwnJ1OiHSwMXazsJQx+Ci+oVLEM= -github.com/paultag/sniff v0.0.0-20200207005214-cf7e4d167732/go.mod h1:J3XXNGJINXLa4yIivdUT0Ad/srv2q0pSOWbbm6El2EY= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/pelletier/go-toml v1.1.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= @@ -506,6 +504,7 @@ github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= diff --git a/internal/ingress/controller/tcp.go b/internal/ingress/controller/tcp.go index ea029718e..db0ee776a 100644 --- a/internal/ingress/controller/tcp.go +++ b/internal/ingress/controller/tcp.go @@ -23,7 +23,7 @@ import ( "k8s.io/klog" - "github.com/paultag/sniff/parser" + "pault.ag/go/sniff/parser" ) // TCPServer describes a server that works in passthrough mode. diff --git a/vendor/github.com/armon/go-proxyproto/protocol.go b/vendor/github.com/armon/go-proxyproto/protocol.go index 9df25e9a0..917ee621b 100644 --- a/vendor/github.com/armon/go-proxyproto/protocol.go +++ b/vendor/github.com/armon/go-proxyproto/protocol.go @@ -49,6 +49,7 @@ type Listener struct { Listener net.Listener ProxyHeaderTimeout time.Duration SourceCheck SourceChecker + UnknownOK bool // allow PROXY UNKNOWN } // Conn is used to wrap and underlying connection which @@ -62,6 +63,7 @@ type Conn struct { useConnAddr bool once sync.Once proxyHeaderTimeout time.Duration + unknownOK bool } // Accept waits for and returns the next connection to the listener. @@ -83,6 +85,7 @@ func (p *Listener) Accept() (net.Conn, error) { } newConn := NewConn(conn, p.ProxyHeaderTimeout) newConn.useConnAddr = useConnAddr + newConn.unknownOK = p.UnknownOK return newConn, nil } @@ -119,6 +122,22 @@ func (p *Conn) Read(b []byte) (int, error) { return p.bufReader.Read(b) } +func (p *Conn) ReadFrom(r io.Reader) (int64, error) { + if rf, ok := p.conn.(io.ReaderFrom); ok { + return rf.ReadFrom(r) + } + return io.Copy(p.conn, r) +} + +func (p *Conn) WriteTo(w io.Writer) (int64, error) { + var err error + p.once.Do(func() { err = p.checkPrefix() }) + if err != nil { + return 0, err + } + return p.bufReader.WriteTo(w) +} + func (p *Conn) Write(b []byte) (int, error) { return p.conn.Write(b) } @@ -209,13 +228,20 @@ func (p *Conn) checkPrefix() error { // Split on spaces, should be (PROXY ) parts := strings.Split(header, " ") - if len(parts) != 6 { + if len(parts) < 2 { p.conn.Close() return fmt.Errorf("Invalid header line: %s", header) } // Verify the type is known switch parts[1] { + case "UNKNOWN": + if !p.unknownOK || len(parts) != 2 { + p.conn.Close() + return fmt.Errorf("Invalid UNKNOWN header line: %s", header) + } + p.useConnAddr = true + return nil case "TCP4": case "TCP6": default: @@ -223,6 +249,11 @@ func (p *Conn) checkPrefix() error { return fmt.Errorf("Unhandled address type: %s", parts[1]) } + if len(parts) != 6 { + p.conn.Close() + return fmt.Errorf("Invalid header line: %s", header) + } + // Parse out the source address ip := net.ParseIP(parts[2]) if ip == nil { diff --git a/vendor/github.com/mitchellh/go-ps/README.md b/vendor/github.com/mitchellh/go-ps/README.md index 8e8baf9d2..4e3d0e146 100644 --- a/vendor/github.com/mitchellh/go-ps/README.md +++ b/vendor/github.com/mitchellh/go-ps/README.md @@ -1,4 +1,4 @@ -# Process List Library for Go +# Process List Library for Go [![GoDoc](https://godoc.org/github.com/mitchellh/go-ps?status.png)](https://godoc.org/github.com/mitchellh/go-ps) go-ps is a library for Go that implements OS-specific APIs to list and manipulate processes in a platform-safe way. The library can find and diff --git a/vendor/github.com/mitchellh/go-ps/go.mod b/vendor/github.com/mitchellh/go-ps/go.mod new file mode 100644 index 000000000..034327975 --- /dev/null +++ b/vendor/github.com/mitchellh/go-ps/go.mod @@ -0,0 +1,3 @@ +module github.com/mitchellh/go-ps + +go 1.13 diff --git a/vendor/github.com/mitchellh/go-ps/process_freebsd.go b/vendor/github.com/mitchellh/go-ps/process_freebsd.go index 0212b66ac..130acbe6c 100644 --- a/vendor/github.com/mitchellh/go-ps/process_freebsd.go +++ b/vendor/github.com/mitchellh/go-ps/process_freebsd.go @@ -1,4 +1,4 @@ -// +build freebsd,amd64 +// +build freebsd package ps diff --git a/vendor/github.com/mitchellh/go-ps/process_unix.go b/vendor/github.com/mitchellh/go-ps/process_unix.go index 3b733cec4..cd217a80f 100644 --- a/vendor/github.com/mitchellh/go-ps/process_unix.go +++ b/vendor/github.com/mitchellh/go-ps/process_unix.go @@ -56,7 +56,7 @@ func processes() ([]Process, error) { results := make([]Process, 0, 50) for { - fis, err := d.Readdir(10) + names, err := d.Readdirnames(10) if err == io.EOF { break } @@ -64,14 +64,8 @@ func processes() ([]Process, error) { return nil, err } - for _, fi := range fis { - // We only care about directories, since all pids are dirs - if !fi.IsDir() { - continue - } - + for _, name := range names { // We only care if the name starts with a numeric - name := fi.Name() if name[0] < '0' || name[0] > '9' { continue } diff --git a/vendor/github.com/pkg/errors/.travis.yml b/vendor/github.com/pkg/errors/.travis.yml index d4b92663b..9159de03e 100644 --- a/vendor/github.com/pkg/errors/.travis.yml +++ b/vendor/github.com/pkg/errors/.travis.yml @@ -1,15 +1,10 @@ language: go go_import_path: github.com/pkg/errors go: - - 1.4.x - - 1.5.x - - 1.6.x - - 1.7.x - - 1.8.x - - 1.9.x - - 1.10.x - 1.11.x + - 1.12.x + - 1.13.x - tip script: - - go test -v ./... + - make check diff --git a/vendor/github.com/pkg/errors/Makefile b/vendor/github.com/pkg/errors/Makefile new file mode 100644 index 000000000..ce9d7cded --- /dev/null +++ b/vendor/github.com/pkg/errors/Makefile @@ -0,0 +1,44 @@ +PKGS := github.com/pkg/errors +SRCDIRS := $(shell go list -f '{{.Dir}}' $(PKGS)) +GO := go + +check: test vet gofmt misspell unconvert staticcheck ineffassign unparam + +test: + $(GO) test $(PKGS) + +vet: | test + $(GO) vet $(PKGS) + +staticcheck: + $(GO) get honnef.co/go/tools/cmd/staticcheck + staticcheck -checks all $(PKGS) + +misspell: + $(GO) get github.com/client9/misspell/cmd/misspell + misspell \ + -locale GB \ + -error \ + *.md *.go + +unconvert: + $(GO) get github.com/mdempsky/unconvert + unconvert -v $(PKGS) + +ineffassign: + $(GO) get github.com/gordonklaus/ineffassign + find $(SRCDIRS) -name '*.go' | xargs ineffassign + +pedantic: check errcheck + +unparam: + $(GO) get mvdan.cc/unparam + unparam ./... + +errcheck: + $(GO) get github.com/kisielk/errcheck + errcheck $(PKGS) + +gofmt: + @echo Checking code is gofmted + @test -z "$(shell gofmt -s -l -d -e $(SRCDIRS) | tee /dev/stderr)" diff --git a/vendor/github.com/pkg/errors/README.md b/vendor/github.com/pkg/errors/README.md index 6483ba2af..54dfdcb12 100644 --- a/vendor/github.com/pkg/errors/README.md +++ b/vendor/github.com/pkg/errors/README.md @@ -41,11 +41,18 @@ default: [Read the package documentation for more information](https://godoc.org/github.com/pkg/errors). +## Roadmap + +With the upcoming [Go2 error proposals](https://go.googlesource.com/proposal/+/master/design/go2draft.md) this package is moving into maintenance mode. The roadmap for a 1.0 release is as follows: + +- 0.9. Remove pre Go 1.9 and Go 1.10 support, address outstanding pull requests (if possible) +- 1.0. Final release. + ## Contributing -We welcome pull requests, bug fixes and issue reports. With that said, the bar for adding new symbols to this package is intentionally set high. +Because of the Go2 errors changes, this package is not accepting proposals for new functionality. With that said, we welcome pull requests, bug fixes and issue reports. -Before proposing a change, please discuss your change by raising an issue. +Before sending a PR, please discuss your change by raising an issue. ## License diff --git a/vendor/github.com/pkg/errors/errors.go b/vendor/github.com/pkg/errors/errors.go index 7421f326f..161aea258 100644 --- a/vendor/github.com/pkg/errors/errors.go +++ b/vendor/github.com/pkg/errors/errors.go @@ -82,7 +82,7 @@ // // if err, ok := err.(stackTracer); ok { // for _, f := range err.StackTrace() { -// fmt.Printf("%+s:%d", f) +// fmt.Printf("%+s:%d\n", f, f) // } // } // @@ -159,6 +159,9 @@ type withStack struct { func (w *withStack) Cause() error { return w.error } +// Unwrap provides compatibility for Go 1.13 error chains. +func (w *withStack) Unwrap() error { return w.error } + func (w *withStack) Format(s fmt.State, verb rune) { switch verb { case 'v': @@ -241,6 +244,9 @@ type withMessage struct { func (w *withMessage) Error() string { return w.msg + ": " + w.cause.Error() } func (w *withMessage) Cause() error { return w.cause } +// Unwrap provides compatibility for Go 1.13 error chains. +func (w *withMessage) Unwrap() error { return w.cause } + func (w *withMessage) Format(s fmt.State, verb rune) { switch verb { case 'v': diff --git a/vendor/github.com/pkg/errors/go113.go b/vendor/github.com/pkg/errors/go113.go new file mode 100644 index 000000000..be0d10d0c --- /dev/null +++ b/vendor/github.com/pkg/errors/go113.go @@ -0,0 +1,38 @@ +// +build go1.13 + +package errors + +import ( + stderrors "errors" +) + +// Is reports whether any error in err's chain matches target. +// +// The chain consists of err itself followed by the sequence of errors obtained by +// repeatedly calling Unwrap. +// +// An error is considered to match a target if it is equal to that target or if +// it implements a method Is(error) bool such that Is(target) returns true. +func Is(err, target error) bool { return stderrors.Is(err, target) } + +// As finds the first error in err's chain that matches target, and if so, sets +// target to that error value and returns true. +// +// The chain consists of err itself followed by the sequence of errors obtained by +// repeatedly calling Unwrap. +// +// An error matches target if the error's concrete value is assignable to the value +// pointed to by target, or if the error has a method As(interface{}) bool such that +// As(target) returns true. In the latter case, the As method is responsible for +// setting target. +// +// As will panic if target is not a non-nil pointer to either a type that implements +// error, or to any interface type. As returns false if err is nil. +func As(err error, target interface{}) bool { return stderrors.As(err, target) } + +// Unwrap returns the result of calling the Unwrap method on err, if err's +// type contains an Unwrap method returning error. +// Otherwise, Unwrap returns nil. +func Unwrap(err error) error { + return stderrors.Unwrap(err) +} diff --git a/vendor/github.com/pkg/errors/stack.go b/vendor/github.com/pkg/errors/stack.go index 2874a048c..779a8348f 100644 --- a/vendor/github.com/pkg/errors/stack.go +++ b/vendor/github.com/pkg/errors/stack.go @@ -5,10 +5,13 @@ import ( "io" "path" "runtime" + "strconv" "strings" ) // Frame represents a program counter inside a stack frame. +// For historical reasons if Frame is interpreted as a uintptr +// its value represents the program counter + 1. type Frame uintptr // pc returns the program counter for this frame; @@ -37,6 +40,15 @@ func (f Frame) line() int { return line } +// name returns the name of this function, if known. +func (f Frame) name() string { + fn := runtime.FuncForPC(f.pc()) + if fn == nil { + return "unknown" + } + return fn.Name() +} + // Format formats the frame according to the fmt.Formatter interface. // // %s source file @@ -54,22 +66,16 @@ func (f Frame) Format(s fmt.State, verb rune) { case 's': switch { case s.Flag('+'): - pc := f.pc() - fn := runtime.FuncForPC(pc) - if fn == nil { - io.WriteString(s, "unknown") - } else { - file, _ := fn.FileLine(pc) - fmt.Fprintf(s, "%s\n\t%s", fn.Name(), file) - } + io.WriteString(s, f.name()) + io.WriteString(s, "\n\t") + io.WriteString(s, f.file()) default: io.WriteString(s, path.Base(f.file())) } case 'd': - fmt.Fprintf(s, "%d", f.line()) + io.WriteString(s, strconv.Itoa(f.line())) case 'n': - name := runtime.FuncForPC(f.pc()).Name() - io.WriteString(s, funcname(name)) + io.WriteString(s, funcname(f.name())) case 'v': f.Format(s, 's') io.WriteString(s, ":") @@ -77,6 +83,16 @@ func (f Frame) Format(s fmt.State, verb rune) { } } +// MarshalText formats a stacktrace Frame as a text string. The output is the +// same as that of fmt.Sprintf("%+v", f), but without newlines or tabs. +func (f Frame) MarshalText() ([]byte, error) { + name := f.name() + if name == "unknown" { + return []byte(name), nil + } + return []byte(fmt.Sprintf("%s %s:%d", name, f.file(), f.line())), nil +} + // StackTrace is stack of Frames from innermost (newest) to outermost (oldest). type StackTrace []Frame @@ -94,18 +110,32 @@ func (st StackTrace) Format(s fmt.State, verb rune) { switch { case s.Flag('+'): for _, f := range st { - fmt.Fprintf(s, "\n%+v", f) + io.WriteString(s, "\n") + f.Format(s, verb) } case s.Flag('#'): fmt.Fprintf(s, "%#v", []Frame(st)) default: - fmt.Fprintf(s, "%v", []Frame(st)) + st.formatSlice(s, verb) } case 's': - fmt.Fprintf(s, "%s", []Frame(st)) + st.formatSlice(s, verb) } } +// formatSlice will format this StackTrace into the given buffer as a slice of +// Frame, only valid when called with '%s' or '%v'. +func (st StackTrace) formatSlice(s fmt.State, verb rune) { + io.WriteString(s, "[") + for i, f := range st { + if i > 0 { + io.WriteString(s, " ") + } + f.Format(s, verb) + } + io.WriteString(s, "]") +} + // stack represents a stack of program counters. type stack []uintptr diff --git a/vendor/modules.txt b/vendor/modules.txt index 14fb26260..61e8f1b12 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -17,7 +17,7 @@ github.com/BurntSushi/toml github.com/PuerkitoBio/purell # github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 github.com/PuerkitoBio/urlesc -# github.com/armon/go-proxyproto v0.0.0-20190211145416-68259f75880e +# github.com/armon/go-proxyproto v0.0.0-20200108142055-f0b8253b1507 github.com/armon/go-proxyproto # github.com/beorn7/perks v1.0.1 github.com/beorn7/perks/quantile @@ -127,7 +127,7 @@ github.com/mailru/easyjson/jlexer github.com/mailru/easyjson/jwriter # github.com/matttproud/golang_protobuf_extensions v1.0.1 github.com/matttproud/golang_protobuf_extensions/pbutil -# github.com/mitchellh/go-ps v0.0.0-20170309133038-4fdf99ab2936 +# github.com/mitchellh/go-ps v1.0.0 github.com/mitchellh/go-ps # github.com/mitchellh/hashstructure v1.0.0 github.com/mitchellh/hashstructure @@ -191,11 +191,9 @@ github.com/opencontainers/runc/libcontainer/configs github.com/opencontainers/runtime-spec/specs-go # github.com/parnurzeal/gorequest v0.2.16 github.com/parnurzeal/gorequest -# github.com/paultag/sniff v0.0.0-20170624152000-87325c3dddf4 -github.com/paultag/sniff/parser # github.com/peterbourgon/diskv v2.0.1+incompatible github.com/peterbourgon/diskv -# github.com/pkg/errors v0.8.1 +# github.com/pkg/errors v0.9.1 github.com/pkg/errors # github.com/prometheus/client_golang v1.4.0 github.com/prometheus/client_golang/prometheus @@ -803,6 +801,8 @@ k8s.io/utils/pointer k8s.io/utils/trace # moul.io/http2curl v1.0.0 moul.io/http2curl +# pault.ag/go/sniff v0.0.0-20200207005214-cf7e4d167732 +pault.ag/go/sniff/parser # sigs.k8s.io/controller-runtime v0.4.0 sigs.k8s.io/controller-runtime/pkg/client/config sigs.k8s.io/controller-runtime/pkg/envtest diff --git a/vendor/github.com/paultag/sniff/LICENSE b/vendor/pault.ag/go/sniff/LICENSE similarity index 100% rename from vendor/github.com/paultag/sniff/LICENSE rename to vendor/pault.ag/go/sniff/LICENSE diff --git a/vendor/github.com/paultag/sniff/parser/parser.go b/vendor/pault.ag/go/sniff/parser/parser.go similarity index 88% rename from vendor/github.com/paultag/sniff/parser/parser.go rename to vendor/pault.ag/go/sniff/parser/parser.go index edc75ef44..f5d4ac4da 100644 --- a/vendor/github.com/paultag/sniff/parser/parser.go +++ b/vendor/pault.ag/go/sniff/parser/parser.go @@ -44,6 +44,14 @@ func GetHostname(data []byte) (string, error) { return string(sni), nil } +/* Return the length computed from the two octets starting at index */ +func lengthFromData(data []byte, index int) int { + b1 := int(data[index]) + b2 := int(data[index+1]) + + return (b1 << 8) + b2 +} + /* Given a Server Name TLS Extension block, parse out and return the SNI * (Server Name Indication) payload */ func GetSNIBlock(data []byte) ([]byte, error) { @@ -53,11 +61,11 @@ func GetSNIBlock(data []byte) ([]byte, error) { if index >= len(data) { break } - length := int((data[index] << 8) + data[index+1]) + length := lengthFromData(data, index) endIndex := index + 2 + length if data[index+2] == 0x00 { /* SNI */ sni := data[index+3:] - sniLength := int((sni[0] << 8) + sni[1]) + sniLength := lengthFromData(sni, 0) return sni[2 : sniLength+2], nil } index = endIndex @@ -75,17 +83,17 @@ func GetSNBlock(data []byte) ([]byte, error) { return []byte{}, fmt.Errorf("Not enough bytes to be an SN block") } - extensionLength := int((data[index] << 8) + data[index+1]) + extensionLength := lengthFromData(data, index) if extensionLength+2 > len(data) { return []byte{}, fmt.Errorf("Extension looks bonkers") } data = data[2 : extensionLength+2] for { - if index+3 >= len(data) { + if index+4 >= len(data) { break } - length := int((data[index+2] << 8) + data[index+3]) + length := lengthFromData(data, index+2) endIndex := index + 4 + length if data[index] == 0x00 && data[index+1] == 0x00 { return data[index+4 : endIndex], nil @@ -121,7 +129,7 @@ func GetExtensionBlock(data []byte) ([]byte, error) { } /* Index is at Cipher List Length bits */ - if newIndex := (index + 2 + int((data[index]<<8)+data[index+1])); (newIndex + 1) < len(data) { + if newIndex := (index + 2 + lengthFromData(data, index)); (newIndex + 1) < len(data) { index = newIndex } else { return []byte{}, fmt.Errorf("Not enough bytes for the Cipher List")