Drop caddy from vendor (#700)

* Removed caddy

* new stuff

* Now need to go get caddy

* Duh
This commit is contained in:
Miek Gieben 2017-06-03 08:27:41 +01:00 committed by GitHub
parent 18bc52b5e0
commit 30217a4cb2
269 changed files with 32812 additions and 29134 deletions

View file

@ -33,6 +33,8 @@ type IPVSBackendStatus struct {
LocalAddress net.IP
// The local (virtual) port.
LocalPort uint16
// The local firewall mark
LocalMark string
// The transport protocol (TCP, UDP).
Proto string
// The remote (real) IP address.
@ -142,6 +144,7 @@ func parseIPVSBackendStatus(file io.Reader) ([]IPVSBackendStatus, error) {
status []IPVSBackendStatus
scanner = bufio.NewScanner(file)
proto string
localMark string
localAddress net.IP
localPort uint16
err error
@ -160,10 +163,19 @@ func parseIPVSBackendStatus(file io.Reader) ([]IPVSBackendStatus, error) {
continue
}
proto = fields[0]
localMark = ""
localAddress, localPort, err = parseIPPort(fields[1])
if err != nil {
return nil, err
}
case fields[0] == "FWM":
if len(fields) < 2 {
continue
}
proto = fields[0]
localMark = fields[1]
localAddress = nil
localPort = 0
case fields[0] == "->":
if len(fields) < 6 {
continue
@ -187,6 +199,7 @@ func parseIPVSBackendStatus(file io.Reader) ([]IPVSBackendStatus, error) {
status = append(status, IPVSBackendStatus{
LocalAddress: localAddress,
LocalPort: localPort,
LocalMark: localMark,
RemoteAddress: remoteAddress,
RemotePort: remotePort,
Proto: proto,
@ -200,22 +213,31 @@ func parseIPVSBackendStatus(file io.Reader) ([]IPVSBackendStatus, error) {
}
func parseIPPort(s string) (net.IP, uint16, error) {
tmp := strings.SplitN(s, ":", 2)
var (
ip net.IP
err error
)
if len(tmp) != 2 {
return nil, 0, fmt.Errorf("invalid IP:Port: %s", s)
switch len(s) {
case 13:
ip, err = hex.DecodeString(s[0:8])
if err != nil {
return nil, 0, err
}
case 46:
ip = net.ParseIP(s[1:40])
if ip == nil {
return nil, 0, fmt.Errorf("invalid IPv6 address: %s", s[1:40])
}
default:
return nil, 0, fmt.Errorf("unexpected IP:Port: %s", s)
}
if len(tmp[0]) != 8 && len(tmp[0]) != 32 {
return nil, 0, fmt.Errorf("invalid IP: %s", tmp[0])
portString := s[len(s)-4:]
if len(portString) != 4 {
return nil, 0, fmt.Errorf("unexpected port string format: %s", portString)
}
ip, err := hex.DecodeString(tmp[0])
if err != nil {
return nil, 0, err
}
port, err := strconv.ParseUint(tmp[1], 16, 16)
port, err := strconv.ParseUint(portString, 16, 16)
if err != nil {
return nil, 0, err
}

View file

@ -94,6 +94,54 @@ var (
ActiveConn: 0,
InactConn: 0,
},
{
LocalAddress: net.ParseIP("2620::1"),
LocalPort: 80,
RemoteAddress: net.ParseIP("2620::2"),
RemotePort: 80,
Proto: "TCP",
Weight: 1,
ActiveConn: 0,
InactConn: 0,
},
{
LocalAddress: net.ParseIP("2620::1"),
LocalPort: 80,
RemoteAddress: net.ParseIP("2620::3"),
RemotePort: 80,
Proto: "TCP",
Weight: 1,
ActiveConn: 0,
InactConn: 0,
},
{
LocalAddress: net.ParseIP("2620::1"),
LocalPort: 80,
RemoteAddress: net.ParseIP("2620::4"),
RemotePort: 80,
Proto: "TCP",
Weight: 1,
ActiveConn: 1,
InactConn: 1,
},
{
LocalMark: "10001000",
RemoteAddress: net.ParseIP("192.168.50.26"),
RemotePort: 3306,
Proto: "FWM",
Weight: 0,
ActiveConn: 0,
InactConn: 1,
},
{
LocalMark: "10001000",
RemoteAddress: net.ParseIP("192.168.50.21"),
RemotePort: 3306,
Proto: "FWM",
Weight: 0,
ActiveConn: 0,
InactConn: 2,
},
}
)
@ -142,14 +190,13 @@ func TestParseIPPortIPv6(t *testing.T) {
ip := net.ParseIP("dead:beef::1")
port := uint16(8080)
gotIP, gotPort, err := parseIPPort("DEADBEEF000000000000000000000001:1F90")
gotIP, gotPort, err := parseIPPort("[DEAD:BEEF:0000:0000:0000:0000:0000:0001]:1F90")
if err != nil {
t.Fatal(err)
}
if !(gotIP.Equal(ip) && port == gotPort) {
t.Errorf("want %s:%d, have %s:%d", ip, port, gotIP, gotPort)
}
}
func TestIPVSBackendStatus(t *testing.T) {

187
vendor/github.com/prometheus/procfs/xfrm.go generated vendored Normal file
View file

@ -0,0 +1,187 @@
// Copyright 2017 Prometheus Team
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package procfs
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)
// XfrmStat models the contents of /proc/net/xfrm_stat.
type XfrmStat struct {
// All errors which are not matched by other
XfrmInError int
// No buffer is left
XfrmInBufferError int
// Header Error
XfrmInHdrError int
// No state found
// i.e. either inbound SPI, address, or IPSEC protocol at SA is wrong
XfrmInNoStates int
// Transformation protocol specific error
// e.g. SA Key is wrong
XfrmInStateProtoError int
// Transformation mode specific error
XfrmInStateModeError int
// Sequence error
// e.g. sequence number is out of window
XfrmInStateSeqError int
// State is expired
XfrmInStateExpired int
// State has mismatch option
// e.g. UDP encapsulation type is mismatched
XfrmInStateMismatch int
// State is invalid
XfrmInStateInvalid int
// No matching template for states
// e.g. Inbound SAs are correct but SP rule is wrong
XfrmInTmplMismatch int
// No policy is found for states
// e.g. Inbound SAs are correct but no SP is found
XfrmInNoPols int
// Policy discards
XfrmInPolBlock int
// Policy error
XfrmInPolError int
// All errors which are not matched by others
XfrmOutError int
// Bundle generation error
XfrmOutBundleGenError int
// Bundle check error
XfrmOutBundleCheckError int
// No state was found
XfrmOutNoStates int
// Transformation protocol specific error
XfrmOutStateProtoError int
// Transportation mode specific error
XfrmOutStateModeError int
// Sequence error
// i.e sequence number overflow
XfrmOutStateSeqError int
// State is expired
XfrmOutStateExpired int
// Policy discads
XfrmOutPolBlock int
// Policy is dead
XfrmOutPolDead int
// Policy Error
XfrmOutPolError int
XfrmFwdHdrError int
XfrmOutStateInvalid int
XfrmAcquireError int
}
// NewXfrmStat reads the xfrm_stat statistics.
func NewXfrmStat() (XfrmStat, error) {
fs, err := NewFS(DefaultMountPoint)
if err != nil {
return XfrmStat{}, err
}
return fs.NewXfrmStat()
}
// NewXfrmStat reads the xfrm_stat statistics from the 'proc' filesystem.
func (fs FS) NewXfrmStat() (XfrmStat, error) {
file, err := os.Open(fs.Path("net/xfrm_stat"))
if err != nil {
return XfrmStat{}, err
}
defer file.Close()
var (
x = XfrmStat{}
s = bufio.NewScanner(file)
)
for s.Scan() {
fields := strings.Fields(s.Text())
if len(fields) != 2 {
return XfrmStat{}, fmt.Errorf(
"couldnt parse %s line %s", file.Name(), s.Text())
}
name := fields[0]
value, err := strconv.Atoi(fields[1])
if err != nil {
return XfrmStat{}, err
}
switch name {
case "XfrmInError":
x.XfrmInError = value
case "XfrmInBufferError":
x.XfrmInBufferError = value
case "XfrmInHdrError":
x.XfrmInHdrError = value
case "XfrmInNoStates":
x.XfrmInNoStates = value
case "XfrmInStateProtoError":
x.XfrmInStateProtoError = value
case "XfrmInStateModeError":
x.XfrmInStateModeError = value
case "XfrmInStateSeqError":
x.XfrmInStateSeqError = value
case "XfrmInStateExpired":
x.XfrmInStateExpired = value
case "XfrmInStateInvalid":
x.XfrmInStateInvalid = value
case "XfrmInTmplMismatch":
x.XfrmInTmplMismatch = value
case "XfrmInNoPols":
x.XfrmInNoPols = value
case "XfrmInPolBlock":
x.XfrmInPolBlock = value
case "XfrmInPolError":
x.XfrmInPolError = value
case "XfrmOutError":
x.XfrmOutError = value
case "XfrmInStateMismatch":
x.XfrmInStateMismatch = value
case "XfrmOutBundleGenError":
x.XfrmOutBundleGenError = value
case "XfrmOutBundleCheckError":
x.XfrmOutBundleCheckError = value
case "XfrmOutNoStates":
x.XfrmOutNoStates = value
case "XfrmOutStateProtoError":
x.XfrmOutStateProtoError = value
case "XfrmOutStateModeError":
x.XfrmOutStateModeError = value
case "XfrmOutStateSeqError":
x.XfrmOutStateSeqError = value
case "XfrmOutStateExpired":
x.XfrmOutStateExpired = value
case "XfrmOutPolBlock":
x.XfrmOutPolBlock = value
case "XfrmOutPolDead":
x.XfrmOutPolDead = value
case "XfrmOutPolError":
x.XfrmOutPolError = value
case "XfrmFwdHdrError":
x.XfrmFwdHdrError = value
case "XfrmOutStateInvalid":
x.XfrmOutStateInvalid = value
case "XfrmAcquireError":
x.XfrmAcquireError = value
}
}
return x, s.Err()
}

66
vendor/github.com/prometheus/procfs/xfrm_test.go generated vendored Normal file
View file

@ -0,0 +1,66 @@
// Copyright 2017 Prometheus Team
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package procfs
import (
"testing"
)
func TestXfrmStats(t *testing.T) {
xfrmStats, err := FS("fixtures").NewXfrmStat()
if err != nil {
t.Fatal(err)
}
for _, test := range []struct {
name string
want int
got int
}{
{name: "XfrmInError", want: 1, got: xfrmStats.XfrmInError},
{name: "XfrmInBufferError", want: 2, got: xfrmStats.XfrmInBufferError},
{name: "XfrmInHdrError", want: 4, got: xfrmStats.XfrmInHdrError},
{name: "XfrmInNoStates", want: 3, got: xfrmStats.XfrmInNoStates},
{name: "XfrmInStateProtoError", want: 40, got: xfrmStats.XfrmInStateProtoError},
{name: "XfrmInStateModeError", want: 100, got: xfrmStats.XfrmInStateModeError},
{name: "XfrmInStateSeqError", want: 6000, got: xfrmStats.XfrmInStateSeqError},
{name: "XfrmInStateExpired", want: 4, got: xfrmStats.XfrmInStateExpired},
{name: "XfrmInStateMismatch", want: 23451, got: xfrmStats.XfrmInStateMismatch},
{name: "XfrmInStateInvalid", want: 55555, got: xfrmStats.XfrmInStateInvalid},
{name: "XfrmInTmplMismatch", want: 51, got: xfrmStats.XfrmInTmplMismatch},
{name: "XfrmInNoPols", want: 65432, got: xfrmStats.XfrmInNoPols},
{name: "XfrmInPolBlock", want: 100, got: xfrmStats.XfrmInPolBlock},
{name: "XfrmInPolError", want: 10000, got: xfrmStats.XfrmInPolError},
{name: "XfrmOutError", want: 1000000, got: xfrmStats.XfrmOutError},
{name: "XfrmOutBundleGenError", want: 43321, got: xfrmStats.XfrmOutBundleGenError},
{name: "XfrmOutBundleCheckError", want: 555, got: xfrmStats.XfrmOutBundleCheckError},
{name: "XfrmOutNoStates", want: 869, got: xfrmStats.XfrmOutNoStates},
{name: "XfrmOutStateProtoError", want: 4542, got: xfrmStats.XfrmOutStateProtoError},
{name: "XfrmOutStateModeError", want: 4, got: xfrmStats.XfrmOutStateModeError},
{name: "XfrmOutStateSeqError", want: 543, got: xfrmStats.XfrmOutStateSeqError},
{name: "XfrmOutStateExpired", want: 565, got: xfrmStats.XfrmOutStateExpired},
{name: "XfrmOutPolBlock", want: 43456, got: xfrmStats.XfrmOutPolBlock},
{name: "XfrmOutPolDead", want: 7656, got: xfrmStats.XfrmOutPolDead},
{name: "XfrmOutPolError", want: 1454, got: xfrmStats.XfrmOutPolError},
{name: "XfrmFwdHdrError", want: 6654, got: xfrmStats.XfrmFwdHdrError},
{name: "XfrmOutStateInvaliad", want: 28765, got: xfrmStats.XfrmOutStateInvalid},
{name: "XfrmAcquireError", want: 24532, got: xfrmStats.XfrmAcquireError},
{name: "XfrmInStateInvalid", want: 55555, got: xfrmStats.XfrmInStateInvalid},
{name: "XfrmOutError", want: 1000000, got: xfrmStats.XfrmOutError},
} {
if test.want != test.got {
t.Errorf("Want %s %d, have %d", test.name, test.want, test.got)
}
}
}