Depenancy upgrades and movign to dep. (#8630)
Этот коммит содержится в:
коммит произвёл
Joram Wilander
родитель
bf24f51c4e
Коммит
6e2cb00008
94
vendor/github.com/hashicorp/errwrap/errwrap_test.go
сгенерированный
поставляемый
94
vendor/github.com/hashicorp/errwrap/errwrap_test.go
сгенерированный
поставляемый
@@ -1,94 +0,0 @@
|
||||
package errwrap
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestWrappedError_impl(t *testing.T) {
|
||||
var _ error = new(wrappedError)
|
||||
}
|
||||
|
||||
func TestGetAll(t *testing.T) {
|
||||
cases := []struct {
|
||||
Err error
|
||||
Msg string
|
||||
Len int
|
||||
}{
|
||||
{},
|
||||
{
|
||||
fmt.Errorf("foo"),
|
||||
"foo",
|
||||
1,
|
||||
},
|
||||
{
|
||||
fmt.Errorf("bar"),
|
||||
"foo",
|
||||
0,
|
||||
},
|
||||
{
|
||||
Wrapf("bar", fmt.Errorf("foo")),
|
||||
"foo",
|
||||
1,
|
||||
},
|
||||
{
|
||||
Wrapf("{{err}}", fmt.Errorf("foo")),
|
||||
"foo",
|
||||
2,
|
||||
},
|
||||
{
|
||||
Wrapf("bar", Wrapf("baz", fmt.Errorf("foo"))),
|
||||
"foo",
|
||||
1,
|
||||
},
|
||||
}
|
||||
|
||||
for i, tc := range cases {
|
||||
actual := GetAll(tc.Err, tc.Msg)
|
||||
if len(actual) != tc.Len {
|
||||
t.Fatalf("%d: bad: %#v", i, actual)
|
||||
}
|
||||
for _, v := range actual {
|
||||
if v.Error() != tc.Msg {
|
||||
t.Fatalf("%d: bad: %#v", i, actual)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetAllType(t *testing.T) {
|
||||
cases := []struct {
|
||||
Err error
|
||||
Type interface{}
|
||||
Len int
|
||||
}{
|
||||
{},
|
||||
{
|
||||
fmt.Errorf("foo"),
|
||||
"foo",
|
||||
0,
|
||||
},
|
||||
{
|
||||
fmt.Errorf("bar"),
|
||||
fmt.Errorf("foo"),
|
||||
1,
|
||||
},
|
||||
{
|
||||
Wrapf("bar", fmt.Errorf("foo")),
|
||||
fmt.Errorf("baz"),
|
||||
2,
|
||||
},
|
||||
{
|
||||
Wrapf("bar", Wrapf("baz", fmt.Errorf("foo"))),
|
||||
Wrapf("", nil),
|
||||
0,
|
||||
},
|
||||
}
|
||||
|
||||
for i, tc := range cases {
|
||||
actual := GetAllType(tc.Err, tc.Type)
|
||||
if len(actual) != tc.Len {
|
||||
t.Fatalf("%d: bad: %#v", i, actual)
|
||||
}
|
||||
}
|
||||
}
|
||||
1531
vendor/github.com/hashicorp/go-immutable-radix/iradix_test.go
сгенерированный
поставляемый
1531
vendor/github.com/hashicorp/go-immutable-radix/iradix_test.go
сгенерированный
поставляемый
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
14
vendor/github.com/hashicorp/go-msgpack/README.md
сгенерированный
поставляемый
14
vendor/github.com/hashicorp/go-msgpack/README.md
сгенерированный
поставляемый
@@ -1,14 +0,0 @@
|
||||
# go
|
||||
|
||||
Collection of Open-Source Go libraries and tools.
|
||||
|
||||
## Codec
|
||||
|
||||
[Codec](https://github.com/ugorji/go/tree/master/codec#readme) is a High Performance and Feature-Rich Idiomatic encode/decode and rpc library for [msgpack](http://msgpack.org) and [Binc](https://github.com/ugorji/binc).
|
||||
|
||||
Online documentation is at [http://godoc.org/github.com/ugorji/go/codec].
|
||||
|
||||
Install using:
|
||||
|
||||
go get github.com/ugorji/go/codec
|
||||
|
||||
319
vendor/github.com/hashicorp/go-msgpack/codec/bench_test.go
сгенерированный
поставляемый
319
vendor/github.com/hashicorp/go-msgpack/codec/bench_test.go
сгенерированный
поставляемый
@@ -1,319 +0,0 @@
|
||||
// Copyright (c) 2012, 2013 Ugorji Nwoke. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license found in the LICENSE file.
|
||||
|
||||
package codec
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/gob"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Sample way to run:
|
||||
// go test -bi -bv -bd=1 -benchmem -bench=.
|
||||
|
||||
var (
|
||||
_ = fmt.Printf
|
||||
benchTs *TestStruc
|
||||
|
||||
approxSize int
|
||||
|
||||
benchDoInitBench bool
|
||||
benchVerify bool
|
||||
benchUnscientificRes bool = false
|
||||
//depth of 0 maps to ~400bytes json-encoded string, 1 maps to ~1400 bytes, etc
|
||||
//For depth>1, we likely trigger stack growth for encoders, making benchmarking unreliable.
|
||||
benchDepth int
|
||||
benchInitDebug bool
|
||||
benchCheckers []benchChecker
|
||||
)
|
||||
|
||||
type benchEncFn func(interface{}) ([]byte, error)
|
||||
type benchDecFn func([]byte, interface{}) error
|
||||
type benchIntfFn func() interface{}
|
||||
|
||||
type benchChecker struct {
|
||||
name string
|
||||
encodefn benchEncFn
|
||||
decodefn benchDecFn
|
||||
}
|
||||
|
||||
func benchInitFlags() {
|
||||
flag.BoolVar(&benchInitDebug, "bg", false, "Bench Debug")
|
||||
flag.IntVar(&benchDepth, "bd", 1, "Bench Depth: If >1, potential unreliable results due to stack growth")
|
||||
flag.BoolVar(&benchDoInitBench, "bi", false, "Run Bench Init")
|
||||
flag.BoolVar(&benchVerify, "bv", false, "Verify Decoded Value during Benchmark")
|
||||
flag.BoolVar(&benchUnscientificRes, "bu", false, "Show Unscientific Results during Benchmark")
|
||||
}
|
||||
|
||||
func benchInit() {
|
||||
benchTs = newTestStruc(benchDepth, true)
|
||||
approxSize = approxDataSize(reflect.ValueOf(benchTs))
|
||||
bytesLen := 1024 * 4 * (benchDepth + 1) * (benchDepth + 1)
|
||||
if bytesLen < approxSize {
|
||||
bytesLen = approxSize
|
||||
}
|
||||
|
||||
benchCheckers = append(benchCheckers,
|
||||
benchChecker{"msgpack", fnMsgpackEncodeFn, fnMsgpackDecodeFn},
|
||||
benchChecker{"binc-nosym", fnBincNoSymEncodeFn, fnBincNoSymDecodeFn},
|
||||
benchChecker{"binc-sym", fnBincSymEncodeFn, fnBincSymDecodeFn},
|
||||
benchChecker{"simple", fnSimpleEncodeFn, fnSimpleDecodeFn},
|
||||
benchChecker{"gob", fnGobEncodeFn, fnGobDecodeFn},
|
||||
benchChecker{"json", fnJsonEncodeFn, fnJsonDecodeFn},
|
||||
)
|
||||
if benchDoInitBench {
|
||||
runBenchInit()
|
||||
}
|
||||
}
|
||||
|
||||
func runBenchInit() {
|
||||
logT(nil, "..............................................")
|
||||
logT(nil, "BENCHMARK INIT: %v", time.Now())
|
||||
logT(nil, "To run full benchmark comparing encodings (MsgPack, Binc, Simple, JSON, GOB, etc), "+
|
||||
"use: \"go test -bench=.\"")
|
||||
logT(nil, "Benchmark: ")
|
||||
logT(nil, "\tStruct recursive Depth: %d", benchDepth)
|
||||
if approxSize > 0 {
|
||||
logT(nil, "\tApproxDeepSize Of benchmark Struct: %d bytes", approxSize)
|
||||
}
|
||||
if benchUnscientificRes {
|
||||
logT(nil, "Benchmark One-Pass Run (with Unscientific Encode/Decode times): ")
|
||||
} else {
|
||||
logT(nil, "Benchmark One-Pass Run:")
|
||||
}
|
||||
for _, bc := range benchCheckers {
|
||||
doBenchCheck(bc.name, bc.encodefn, bc.decodefn)
|
||||
}
|
||||
logT(nil, "..............................................")
|
||||
if benchInitDebug {
|
||||
logT(nil, "<<<<====>>>> depth: %v, ts: %#v\n", benchDepth, benchTs)
|
||||
}
|
||||
}
|
||||
|
||||
func fnBenchNewTs() interface{} {
|
||||
return new(TestStruc)
|
||||
}
|
||||
|
||||
func doBenchCheck(name string, encfn benchEncFn, decfn benchDecFn) {
|
||||
runtime.GC()
|
||||
tnow := time.Now()
|
||||
buf, err := encfn(benchTs)
|
||||
if err != nil {
|
||||
logT(nil, "\t%10s: **** Error encoding benchTs: %v", name, err)
|
||||
}
|
||||
encDur := time.Now().Sub(tnow)
|
||||
encLen := len(buf)
|
||||
runtime.GC()
|
||||
if !benchUnscientificRes {
|
||||
logT(nil, "\t%10s: len: %d bytes\n", name, encLen)
|
||||
return
|
||||
}
|
||||
tnow = time.Now()
|
||||
if err = decfn(buf, new(TestStruc)); err != nil {
|
||||
logT(nil, "\t%10s: **** Error decoding into new TestStruc: %v", name, err)
|
||||
}
|
||||
decDur := time.Now().Sub(tnow)
|
||||
logT(nil, "\t%10s: len: %d bytes, encode: %v, decode: %v\n", name, encLen, encDur, decDur)
|
||||
}
|
||||
|
||||
func fnBenchmarkEncode(b *testing.B, encName string, ts interface{}, encfn benchEncFn) {
|
||||
runtime.GC()
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
_, err := encfn(ts)
|
||||
if err != nil {
|
||||
logT(b, "Error encoding benchTs: %s: %v", encName, err)
|
||||
b.FailNow()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func fnBenchmarkDecode(b *testing.B, encName string, ts interface{},
|
||||
encfn benchEncFn, decfn benchDecFn, newfn benchIntfFn,
|
||||
) {
|
||||
buf, err := encfn(ts)
|
||||
if err != nil {
|
||||
logT(b, "Error encoding benchTs: %s: %v", encName, err)
|
||||
b.FailNow()
|
||||
}
|
||||
runtime.GC()
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
ts = newfn()
|
||||
if err = decfn(buf, ts); err != nil {
|
||||
logT(b, "Error decoding into new TestStruc: %s: %v", encName, err)
|
||||
b.FailNow()
|
||||
}
|
||||
if benchVerify {
|
||||
if vts, vok := ts.(*TestStruc); vok {
|
||||
verifyTsTree(b, vts)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func verifyTsTree(b *testing.B, ts *TestStruc) {
|
||||
var ts0, ts1m, ts2m, ts1s, ts2s *TestStruc
|
||||
ts0 = ts
|
||||
|
||||
if benchDepth > 0 {
|
||||
ts1m, ts1s = verifyCheckAndGet(b, ts0)
|
||||
}
|
||||
|
||||
if benchDepth > 1 {
|
||||
ts2m, ts2s = verifyCheckAndGet(b, ts1m)
|
||||
}
|
||||
for _, tsx := range []*TestStruc{ts0, ts1m, ts2m, ts1s, ts2s} {
|
||||
if tsx != nil {
|
||||
verifyOneOne(b, tsx)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func verifyCheckAndGet(b *testing.B, ts0 *TestStruc) (ts1m *TestStruc, ts1s *TestStruc) {
|
||||
// if len(ts1m.Ms) <= 2 {
|
||||
// logT(b, "Error: ts1m.Ms len should be > 2. Got: %v", len(ts1m.Ms))
|
||||
// b.FailNow()
|
||||
// }
|
||||
if len(ts0.Its) == 0 {
|
||||
logT(b, "Error: ts0.Islice len should be > 0. Got: %v", len(ts0.Its))
|
||||
b.FailNow()
|
||||
}
|
||||
ts1m = ts0.Mtsptr["0"]
|
||||
ts1s = ts0.Its[0]
|
||||
if ts1m == nil || ts1s == nil {
|
||||
logT(b, "Error: At benchDepth 1, No *TestStruc found")
|
||||
b.FailNow()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func verifyOneOne(b *testing.B, ts *TestStruc) {
|
||||
if ts.I64slice[2] != int64(3) {
|
||||
logT(b, "Error: Decode failed by checking values")
|
||||
b.FailNow()
|
||||
}
|
||||
}
|
||||
|
||||
func fnMsgpackEncodeFn(ts interface{}) (bs []byte, err error) {
|
||||
err = NewEncoderBytes(&bs, testMsgpackH).Encode(ts)
|
||||
return
|
||||
}
|
||||
|
||||
func fnMsgpackDecodeFn(buf []byte, ts interface{}) error {
|
||||
return NewDecoderBytes(buf, testMsgpackH).Decode(ts)
|
||||
}
|
||||
|
||||
func fnBincEncodeFn(ts interface{}, sym AsSymbolFlag) (bs []byte, err error) {
|
||||
tSym := testBincH.AsSymbols
|
||||
testBincH.AsSymbols = sym
|
||||
err = NewEncoderBytes(&bs, testBincH).Encode(ts)
|
||||
testBincH.AsSymbols = tSym
|
||||
return
|
||||
}
|
||||
|
||||
func fnBincDecodeFn(buf []byte, ts interface{}, sym AsSymbolFlag) (err error) {
|
||||
tSym := testBincH.AsSymbols
|
||||
testBincH.AsSymbols = sym
|
||||
err = NewDecoderBytes(buf, testBincH).Decode(ts)
|
||||
testBincH.AsSymbols = tSym
|
||||
return
|
||||
}
|
||||
|
||||
func fnBincNoSymEncodeFn(ts interface{}) (bs []byte, err error) {
|
||||
return fnBincEncodeFn(ts, AsSymbolNone)
|
||||
}
|
||||
|
||||
func fnBincNoSymDecodeFn(buf []byte, ts interface{}) error {
|
||||
return fnBincDecodeFn(buf, ts, AsSymbolNone)
|
||||
}
|
||||
|
||||
func fnBincSymEncodeFn(ts interface{}) (bs []byte, err error) {
|
||||
return fnBincEncodeFn(ts, AsSymbolAll)
|
||||
}
|
||||
|
||||
func fnBincSymDecodeFn(buf []byte, ts interface{}) error {
|
||||
return fnBincDecodeFn(buf, ts, AsSymbolAll)
|
||||
}
|
||||
|
||||
func fnSimpleEncodeFn(ts interface{}) (bs []byte, err error) {
|
||||
err = NewEncoderBytes(&bs, testSimpleH).Encode(ts)
|
||||
return
|
||||
}
|
||||
|
||||
func fnSimpleDecodeFn(buf []byte, ts interface{}) error {
|
||||
return NewDecoderBytes(buf, testSimpleH).Decode(ts)
|
||||
}
|
||||
|
||||
func fnGobEncodeFn(ts interface{}) ([]byte, error) {
|
||||
bbuf := new(bytes.Buffer)
|
||||
err := gob.NewEncoder(bbuf).Encode(ts)
|
||||
return bbuf.Bytes(), err
|
||||
}
|
||||
|
||||
func fnGobDecodeFn(buf []byte, ts interface{}) error {
|
||||
return gob.NewDecoder(bytes.NewBuffer(buf)).Decode(ts)
|
||||
}
|
||||
|
||||
func fnJsonEncodeFn(ts interface{}) ([]byte, error) {
|
||||
return json.Marshal(ts)
|
||||
}
|
||||
|
||||
func fnJsonDecodeFn(buf []byte, ts interface{}) error {
|
||||
return json.Unmarshal(buf, ts)
|
||||
}
|
||||
|
||||
func Benchmark__Msgpack____Encode(b *testing.B) {
|
||||
fnBenchmarkEncode(b, "msgpack", benchTs, fnMsgpackEncodeFn)
|
||||
}
|
||||
|
||||
func Benchmark__Msgpack____Decode(b *testing.B) {
|
||||
fnBenchmarkDecode(b, "msgpack", benchTs, fnMsgpackEncodeFn, fnMsgpackDecodeFn, fnBenchNewTs)
|
||||
}
|
||||
|
||||
func Benchmark__Binc_NoSym_Encode(b *testing.B) {
|
||||
fnBenchmarkEncode(b, "binc", benchTs, fnBincNoSymEncodeFn)
|
||||
}
|
||||
|
||||
func Benchmark__Binc_NoSym_Decode(b *testing.B) {
|
||||
fnBenchmarkDecode(b, "binc", benchTs, fnBincNoSymEncodeFn, fnBincNoSymDecodeFn, fnBenchNewTs)
|
||||
}
|
||||
|
||||
func Benchmark__Binc_Sym___Encode(b *testing.B) {
|
||||
fnBenchmarkEncode(b, "binc", benchTs, fnBincSymEncodeFn)
|
||||
}
|
||||
|
||||
func Benchmark__Binc_Sym___Decode(b *testing.B) {
|
||||
fnBenchmarkDecode(b, "binc", benchTs, fnBincSymEncodeFn, fnBincSymDecodeFn, fnBenchNewTs)
|
||||
}
|
||||
|
||||
func Benchmark__Simple____Encode(b *testing.B) {
|
||||
fnBenchmarkEncode(b, "simple", benchTs, fnSimpleEncodeFn)
|
||||
}
|
||||
|
||||
func Benchmark__Simple____Decode(b *testing.B) {
|
||||
fnBenchmarkDecode(b, "simple", benchTs, fnSimpleEncodeFn, fnSimpleDecodeFn, fnBenchNewTs)
|
||||
}
|
||||
|
||||
func Benchmark__Gob________Encode(b *testing.B) {
|
||||
fnBenchmarkEncode(b, "gob", benchTs, fnGobEncodeFn)
|
||||
}
|
||||
|
||||
func Benchmark__Gob________Decode(b *testing.B) {
|
||||
fnBenchmarkDecode(b, "gob", benchTs, fnGobEncodeFn, fnGobDecodeFn, fnBenchNewTs)
|
||||
}
|
||||
|
||||
func Benchmark__Json_______Encode(b *testing.B) {
|
||||
fnBenchmarkEncode(b, "json", benchTs, fnJsonEncodeFn)
|
||||
}
|
||||
|
||||
func Benchmark__Json_______Decode(b *testing.B) {
|
||||
fnBenchmarkDecode(b, "json", benchTs, fnJsonEncodeFn, fnJsonDecodeFn, fnBenchNewTs)
|
||||
}
|
||||
1002
vendor/github.com/hashicorp/go-msgpack/codec/codecs_test.go
сгенерированный
поставляемый
1002
vendor/github.com/hashicorp/go-msgpack/codec/codecs_test.go
сгенерированный
поставляемый
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
75
vendor/github.com/hashicorp/go-msgpack/codec/ext_dep_test.go
сгенерированный
поставляемый
75
vendor/github.com/hashicorp/go-msgpack/codec/ext_dep_test.go
сгенерированный
поставляемый
@@ -1,75 +0,0 @@
|
||||
// //+build ignore
|
||||
|
||||
// Copyright (c) 2012, 2013 Ugorji Nwoke. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license found in the LICENSE file.
|
||||
|
||||
package codec
|
||||
|
||||
// This file includes benchmarks which have dependencies on 3rdparty
|
||||
// packages (bson and vmihailenco/msgpack) which must be installed locally.
|
||||
//
|
||||
// To run the benchmarks including these 3rdparty packages, first
|
||||
// - Uncomment first line in this file (put // // in front of it)
|
||||
// - Get those packages:
|
||||
// go get github.com/vmihailenco/msgpack
|
||||
// go get labix.org/v2/mgo/bson
|
||||
// - Run:
|
||||
// go test -bi -bench=.
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
vmsgpack "gopkg.in/vmihailenco/msgpack.v2"
|
||||
"labix.org/v2/mgo/bson"
|
||||
)
|
||||
|
||||
func init() {
|
||||
benchCheckers = append(benchCheckers,
|
||||
benchChecker{"v-msgpack", fnVMsgpackEncodeFn, fnVMsgpackDecodeFn},
|
||||
benchChecker{"bson", fnBsonEncodeFn, fnBsonDecodeFn},
|
||||
)
|
||||
}
|
||||
|
||||
func fnVMsgpackEncodeFn(ts interface{}) ([]byte, error) {
|
||||
return vmsgpack.Marshal(ts)
|
||||
}
|
||||
|
||||
func fnVMsgpackDecodeFn(buf []byte, ts interface{}) error {
|
||||
return vmsgpack.Unmarshal(buf, ts)
|
||||
}
|
||||
|
||||
func fnBsonEncodeFn(ts interface{}) ([]byte, error) {
|
||||
return bson.Marshal(ts)
|
||||
}
|
||||
|
||||
func fnBsonDecodeFn(buf []byte, ts interface{}) error {
|
||||
return bson.Unmarshal(buf, ts)
|
||||
}
|
||||
|
||||
func Benchmark__Bson_______Encode(b *testing.B) {
|
||||
fnBenchmarkEncode(b, "bson", benchTs, fnBsonEncodeFn)
|
||||
}
|
||||
|
||||
func Benchmark__Bson_______Decode(b *testing.B) {
|
||||
fnBenchmarkDecode(b, "bson", benchTs, fnBsonEncodeFn, fnBsonDecodeFn, fnBenchNewTs)
|
||||
}
|
||||
|
||||
func Benchmark__VMsgpack___Encode(b *testing.B) {
|
||||
fnBenchmarkEncode(b, "v-msgpack", benchTs, fnVMsgpackEncodeFn)
|
||||
}
|
||||
|
||||
func Benchmark__VMsgpack___Decode(b *testing.B) {
|
||||
fnBenchmarkDecode(b, "v-msgpack", benchTs, fnVMsgpackEncodeFn, fnVMsgpackDecodeFn, fnBenchNewTs)
|
||||
}
|
||||
|
||||
func TestMsgpackPythonGenStreams(t *testing.T) {
|
||||
doTestMsgpackPythonGenStreams(t)
|
||||
}
|
||||
|
||||
func TestMsgpackRpcSpecGoClientToPythonSvc(t *testing.T) {
|
||||
doTestMsgpackRpcSpecGoClientToPythonSvc(t)
|
||||
}
|
||||
|
||||
func TestMsgpackRpcSpecPythonClientToGoSvc(t *testing.T) {
|
||||
doTestMsgpackRpcSpecPythonClientToGoSvc(t)
|
||||
}
|
||||
103
vendor/github.com/hashicorp/go-msgpack/codec/z_helper_test.go
сгенерированный
поставляемый
103
vendor/github.com/hashicorp/go-msgpack/codec/z_helper_test.go
сгенерированный
поставляемый
@@ -1,103 +0,0 @@
|
||||
// Copyright (c) 2012, 2013 Ugorji Nwoke. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license found in the LICENSE file.
|
||||
|
||||
package codec
|
||||
|
||||
// All non-std package dependencies related to testing live in this file,
|
||||
// so porting to different environment is easy (just update functions).
|
||||
//
|
||||
// Also, this file is called z_helper_test, to give a "hint" to compiler
|
||||
// that its init() function should be called last. (not guaranteed by spec)
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"reflect"
|
||||
"flag"
|
||||
"testing"
|
||||
)
|
||||
|
||||
var (
|
||||
testLogToT = true
|
||||
failNowOnFail = true
|
||||
)
|
||||
|
||||
func init() {
|
||||
testInitFlags()
|
||||
benchInitFlags()
|
||||
flag.Parse()
|
||||
testInit()
|
||||
benchInit()
|
||||
}
|
||||
|
||||
func checkErrT(t *testing.T, err error) {
|
||||
if err != nil {
|
||||
logT(t, err.Error())
|
||||
failT(t)
|
||||
}
|
||||
}
|
||||
|
||||
func checkEqualT(t *testing.T, v1 interface{}, v2 interface{}, desc string) (err error) {
|
||||
if err = deepEqual(v1, v2); err != nil {
|
||||
logT(t, "Not Equal: %s: %v. v1: %v, v2: %v", desc, err, v1, v2)
|
||||
failT(t)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func logT(x interface{}, format string, args ...interface{}) {
|
||||
if t, ok := x.(*testing.T); ok && t != nil && testLogToT {
|
||||
t.Logf(format, args...)
|
||||
} else if b, ok := x.(*testing.B); ok && b != nil && testLogToT {
|
||||
b.Logf(format, args...)
|
||||
} else {
|
||||
debugf(format, args...)
|
||||
}
|
||||
}
|
||||
|
||||
func failT(t *testing.T) {
|
||||
if failNowOnFail {
|
||||
t.FailNow()
|
||||
} else {
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func deepEqual(v1, v2 interface{}) (err error) {
|
||||
if !reflect.DeepEqual(v1, v2) {
|
||||
err = errors.New("Not Match")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func approxDataSize(rv reflect.Value) (sum int) {
|
||||
switch rk := rv.Kind(); rk {
|
||||
case reflect.Invalid:
|
||||
case reflect.Ptr, reflect.Interface:
|
||||
sum += int(rv.Type().Size())
|
||||
sum += approxDataSize(rv.Elem())
|
||||
case reflect.Slice:
|
||||
sum += int(rv.Type().Size())
|
||||
for j := 0; j < rv.Len(); j++ {
|
||||
sum += approxDataSize(rv.Index(j))
|
||||
}
|
||||
case reflect.String:
|
||||
sum += int(rv.Type().Size())
|
||||
sum += rv.Len()
|
||||
case reflect.Map:
|
||||
sum += int(rv.Type().Size())
|
||||
for _, mk := range rv.MapKeys() {
|
||||
sum += approxDataSize(mk)
|
||||
sum += approxDataSize(rv.MapIndex(mk))
|
||||
}
|
||||
case reflect.Struct:
|
||||
//struct size already includes the full data size.
|
||||
//sum += int(rv.Type().Size())
|
||||
for j := 0; j < rv.NumField(); j++ {
|
||||
sum += approxDataSize(rv.Field(j))
|
||||
}
|
||||
default:
|
||||
//pure value types
|
||||
sum += int(rv.Type().Size())
|
||||
}
|
||||
return
|
||||
}
|
||||
47
vendor/github.com/hashicorp/go-msgpack/msgpack.org.md
сгенерированный
поставляемый
47
vendor/github.com/hashicorp/go-msgpack/msgpack.org.md
сгенерированный
поставляемый
@@ -1,47 +0,0 @@
|
||||
**MessagePack and [Binc](http://github.com/ugorji/binc) Codec for [Go](http://golang.org) Language.**
|
||||
|
||||
*A High Performance, Feature-Rich, Idiomatic encode/decode and rpc library*.
|
||||
|
||||
To install:
|
||||
|
||||
go get github.com/ugorji/go/codec
|
||||
|
||||
Source: [http://github.com/ugorji/go]
|
||||
Online documentation: [http://godoc.org/github.com/ugorji/go/codec]
|
||||
|
||||
Typical usage:
|
||||
|
||||
```go
|
||||
// create and use decoder/encoder
|
||||
var (
|
||||
v interface{} // value to decode/encode into
|
||||
r io.Reader
|
||||
w io.Writer
|
||||
b []byte
|
||||
mh codec.MsgpackHandle
|
||||
)
|
||||
|
||||
dec = codec.NewDecoder(r, &mh)
|
||||
dec = codec.NewDecoderBytes(b, &mh)
|
||||
err = dec.Decode(&v)
|
||||
|
||||
enc = codec.NewEncoder(w, &mh)
|
||||
enc = codec.NewEncoderBytes(&b, &mh)
|
||||
err = enc.Encode(v)
|
||||
|
||||
//RPC Server
|
||||
go func() {
|
||||
for {
|
||||
conn, err := listener.Accept()
|
||||
rpcCodec := codec.GoRpc.ServerCodec(conn, h)
|
||||
//OR rpcCodec := codec.MsgpackSpecRpc.ServerCodec(conn, h)
|
||||
rpc.ServeCodec(rpcCodec)
|
||||
}
|
||||
}()
|
||||
|
||||
//RPC Communication (client side)
|
||||
conn, err = net.Dial("tcp", "localhost:5555")
|
||||
rpcCodec := codec.GoRpc.ClientCodec(conn, h)
|
||||
//OR rpcCodec := codec.MsgpackSpecRpc.ClientCodec(conn, h)
|
||||
client := rpc.NewClientWithCodec(rpcCodec)
|
||||
```
|
||||
82
vendor/github.com/hashicorp/go-multierror/append_test.go
сгенерированный
поставляемый
82
vendor/github.com/hashicorp/go-multierror/append_test.go
сгенерированный
поставляемый
@@ -1,82 +0,0 @@
|
||||
package multierror
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestAppend_Error(t *testing.T) {
|
||||
original := &Error{
|
||||
Errors: []error{errors.New("foo")},
|
||||
}
|
||||
|
||||
result := Append(original, errors.New("bar"))
|
||||
if len(result.Errors) != 2 {
|
||||
t.Fatalf("wrong len: %d", len(result.Errors))
|
||||
}
|
||||
|
||||
original = &Error{}
|
||||
result = Append(original, errors.New("bar"))
|
||||
if len(result.Errors) != 1 {
|
||||
t.Fatalf("wrong len: %d", len(result.Errors))
|
||||
}
|
||||
|
||||
// Test when a typed nil is passed
|
||||
var e *Error
|
||||
result = Append(e, errors.New("baz"))
|
||||
if len(result.Errors) != 1 {
|
||||
t.Fatalf("wrong len: %d", len(result.Errors))
|
||||
}
|
||||
|
||||
// Test flattening
|
||||
original = &Error{
|
||||
Errors: []error{errors.New("foo")},
|
||||
}
|
||||
|
||||
result = Append(original, Append(nil, errors.New("foo"), errors.New("bar")))
|
||||
if len(result.Errors) != 3 {
|
||||
t.Fatalf("wrong len: %d", len(result.Errors))
|
||||
}
|
||||
}
|
||||
|
||||
func TestAppend_NilError(t *testing.T) {
|
||||
var err error
|
||||
result := Append(err, errors.New("bar"))
|
||||
if len(result.Errors) != 1 {
|
||||
t.Fatalf("wrong len: %d", len(result.Errors))
|
||||
}
|
||||
}
|
||||
|
||||
func TestAppend_NilErrorArg(t *testing.T) {
|
||||
var err error
|
||||
var nilErr *Error
|
||||
result := Append(err, nilErr)
|
||||
if len(result.Errors) != 0 {
|
||||
t.Fatalf("wrong len: %d", len(result.Errors))
|
||||
}
|
||||
}
|
||||
|
||||
func TestAppend_NilErrorIfaceArg(t *testing.T) {
|
||||
var err error
|
||||
var nilErr error
|
||||
result := Append(err, nilErr)
|
||||
if len(result.Errors) != 0 {
|
||||
t.Fatalf("wrong len: %d", len(result.Errors))
|
||||
}
|
||||
}
|
||||
|
||||
func TestAppend_NonError(t *testing.T) {
|
||||
original := errors.New("foo")
|
||||
result := Append(original, errors.New("bar"))
|
||||
if len(result.Errors) != 2 {
|
||||
t.Fatalf("wrong len: %d", len(result.Errors))
|
||||
}
|
||||
}
|
||||
|
||||
func TestAppend_NonError_Error(t *testing.T) {
|
||||
original := errors.New("foo")
|
||||
result := Append(original, Append(nil, errors.New("bar")))
|
||||
if len(result.Errors) != 2 {
|
||||
t.Fatalf("wrong len: %d", len(result.Errors))
|
||||
}
|
||||
}
|
||||
48
vendor/github.com/hashicorp/go-multierror/flatten_test.go
сгенерированный
поставляемый
48
vendor/github.com/hashicorp/go-multierror/flatten_test.go
сгенерированный
поставляемый
@@ -1,48 +0,0 @@
|
||||
package multierror
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestFlatten(t *testing.T) {
|
||||
original := &Error{
|
||||
Errors: []error{
|
||||
errors.New("one"),
|
||||
&Error{
|
||||
Errors: []error{
|
||||
errors.New("two"),
|
||||
&Error{
|
||||
Errors: []error{
|
||||
errors.New("three"),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
expected := strings.TrimSpace(`
|
||||
3 errors occurred:
|
||||
|
||||
* one
|
||||
* two
|
||||
* three
|
||||
`)
|
||||
actual := fmt.Sprintf("%s", Flatten(original))
|
||||
|
||||
if expected != actual {
|
||||
t.Fatalf("expected: %s, got: %s", expected, actual)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFlatten_nonError(t *testing.T) {
|
||||
err := errors.New("foo")
|
||||
actual := Flatten(err)
|
||||
if !reflect.DeepEqual(actual, err) {
|
||||
t.Fatalf("bad: %#v", actual)
|
||||
}
|
||||
}
|
||||
38
vendor/github.com/hashicorp/go-multierror/format_test.go
сгенерированный
поставляемый
38
vendor/github.com/hashicorp/go-multierror/format_test.go
сгенерированный
поставляемый
@@ -1,38 +0,0 @@
|
||||
package multierror
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestListFormatFuncSingle(t *testing.T) {
|
||||
expected := `1 error occurred:
|
||||
|
||||
* foo`
|
||||
|
||||
errors := []error{
|
||||
errors.New("foo"),
|
||||
}
|
||||
|
||||
actual := ListFormatFunc(errors)
|
||||
if actual != expected {
|
||||
t.Fatalf("bad: %#v", actual)
|
||||
}
|
||||
}
|
||||
|
||||
func TestListFormatFuncMultiple(t *testing.T) {
|
||||
expected := `2 errors occurred:
|
||||
|
||||
* foo
|
||||
* bar`
|
||||
|
||||
errors := []error{
|
||||
errors.New("foo"),
|
||||
errors.New("bar"),
|
||||
}
|
||||
|
||||
actual := ListFormatFunc(errors)
|
||||
if actual != expected {
|
||||
t.Fatalf("bad: %#v", actual)
|
||||
}
|
||||
}
|
||||
70
vendor/github.com/hashicorp/go-multierror/multierror_test.go
сгенерированный
поставляемый
70
vendor/github.com/hashicorp/go-multierror/multierror_test.go
сгенерированный
поставляемый
@@ -1,70 +0,0 @@
|
||||
package multierror
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestError_Impl(t *testing.T) {
|
||||
var _ error = new(Error)
|
||||
}
|
||||
|
||||
func TestErrorError_custom(t *testing.T) {
|
||||
errors := []error{
|
||||
errors.New("foo"),
|
||||
errors.New("bar"),
|
||||
}
|
||||
|
||||
fn := func(es []error) string {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
multi := &Error{Errors: errors, ErrorFormat: fn}
|
||||
if multi.Error() != "foo" {
|
||||
t.Fatalf("bad: %s", multi.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func TestErrorError_default(t *testing.T) {
|
||||
expected := `2 errors occurred:
|
||||
|
||||
* foo
|
||||
* bar`
|
||||
|
||||
errors := []error{
|
||||
errors.New("foo"),
|
||||
errors.New("bar"),
|
||||
}
|
||||
|
||||
multi := &Error{Errors: errors}
|
||||
if multi.Error() != expected {
|
||||
t.Fatalf("bad: %s", multi.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func TestErrorErrorOrNil(t *testing.T) {
|
||||
err := new(Error)
|
||||
if err.ErrorOrNil() != nil {
|
||||
t.Fatalf("bad: %#v", err.ErrorOrNil())
|
||||
}
|
||||
|
||||
err.Errors = []error{errors.New("foo")}
|
||||
if v := err.ErrorOrNil(); v == nil {
|
||||
t.Fatal("should not be nil")
|
||||
} else if !reflect.DeepEqual(v, err) {
|
||||
t.Fatalf("bad: %#v", v)
|
||||
}
|
||||
}
|
||||
|
||||
func TestErrorWrappedErrors(t *testing.T) {
|
||||
errors := []error{
|
||||
errors.New("foo"),
|
||||
errors.New("bar"),
|
||||
}
|
||||
|
||||
multi := &Error{Errors: errors}
|
||||
if !reflect.DeepEqual(multi.Errors, multi.WrappedErrors()) {
|
||||
t.Fatalf("bad: %s", multi.WrappedErrors())
|
||||
}
|
||||
}
|
||||
33
vendor/github.com/hashicorp/go-multierror/prefix_test.go
сгенерированный
поставляемый
33
vendor/github.com/hashicorp/go-multierror/prefix_test.go
сгенерированный
поставляемый
@@ -1,33 +0,0 @@
|
||||
package multierror
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestPrefix_Error(t *testing.T) {
|
||||
original := &Error{
|
||||
Errors: []error{errors.New("foo")},
|
||||
}
|
||||
|
||||
result := Prefix(original, "bar")
|
||||
if result.(*Error).Errors[0].Error() != "bar foo" {
|
||||
t.Fatalf("bad: %s", result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPrefix_NilError(t *testing.T) {
|
||||
var err error
|
||||
result := Prefix(err, "bar")
|
||||
if result != nil {
|
||||
t.Fatalf("bad: %#v", result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPrefix_NonError(t *testing.T) {
|
||||
original := errors.New("foo")
|
||||
result := Prefix(original, "bar")
|
||||
if result.Error() != "bar foo" {
|
||||
t.Fatalf("bad: %s", result)
|
||||
}
|
||||
}
|
||||
54
vendor/github.com/hashicorp/go-multierror/scripts/deps.sh
сгенерированный
поставляемый
54
vendor/github.com/hashicorp/go-multierror/scripts/deps.sh
сгенерированный
поставляемый
@@ -1,54 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# This script updates dependencies using a temporary directory. This is required
|
||||
# to avoid any auxillary dependencies that sneak into GOPATH.
|
||||
set -e
|
||||
|
||||
# Get the parent directory of where this script is.
|
||||
SOURCE="${BASH_SOURCE[0]}"
|
||||
while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done
|
||||
DIR="$(cd -P "$(dirname "$SOURCE")/.." && pwd)"
|
||||
|
||||
# Change into that directory
|
||||
cd "$DIR"
|
||||
|
||||
# Get the name from the directory
|
||||
NAME=${NAME:-"$(basename $(pwd))"}
|
||||
|
||||
# Announce
|
||||
echo "==> Updating dependencies..."
|
||||
|
||||
echo "--> Making tmpdir..."
|
||||
tmpdir=$(mktemp -d)
|
||||
function cleanup {
|
||||
rm -rf "${tmpdir}"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
export GOPATH="${tmpdir}"
|
||||
export PATH="${tmpdir}/bin:$PATH"
|
||||
|
||||
mkdir -p "${tmpdir}/src/github.com/hashicorp"
|
||||
pushd "${tmpdir}/src/github.com/hashicorp" &>/dev/null
|
||||
|
||||
echo "--> Copying ${NAME}..."
|
||||
cp -R "$DIR" "${tmpdir}/src/github.com/hashicorp/${NAME}"
|
||||
pushd "${tmpdir}/src/github.com/hashicorp/${NAME}" &>/dev/null
|
||||
rm -rf vendor/
|
||||
|
||||
echo "--> Installing dependency manager..."
|
||||
go get -u github.com/kardianos/govendor
|
||||
govendor init
|
||||
|
||||
echo "--> Installing all dependencies (may take some time)..."
|
||||
govendor fetch -v +outside
|
||||
|
||||
echo "--> Vendoring..."
|
||||
govendor add +external
|
||||
|
||||
echo "--> Moving into place..."
|
||||
vpath="${tmpdir}/src/github.com/hashicorp/${NAME}/vendor"
|
||||
popd &>/dev/null
|
||||
popd &>/dev/null
|
||||
rm -rf vendor/
|
||||
cp -R "${vpath}" .
|
||||
354
vendor/github.com/hashicorp/go-multierror/vendor/github.com/hashicorp/errwrap/LICENSE
сгенерированный
поставляемый
354
vendor/github.com/hashicorp/go-multierror/vendor/github.com/hashicorp/errwrap/LICENSE
сгенерированный
поставляемый
@@ -1,354 +0,0 @@
|
||||
Mozilla Public License, version 2.0
|
||||
|
||||
1. Definitions
|
||||
|
||||
1.1. “Contributor”
|
||||
|
||||
means each individual or legal entity that creates, contributes to the
|
||||
creation of, or owns Covered Software.
|
||||
|
||||
1.2. “Contributor Version”
|
||||
|
||||
means the combination of the Contributions of others (if any) used by a
|
||||
Contributor and that particular Contributor’s Contribution.
|
||||
|
||||
1.3. “Contribution”
|
||||
|
||||
means Covered Software of a particular Contributor.
|
||||
|
||||
1.4. “Covered Software”
|
||||
|
||||
means Source Code Form to which the initial Contributor has attached the
|
||||
notice in Exhibit A, the Executable Form of such Source Code Form, and
|
||||
Modifications of such Source Code Form, in each case including portions
|
||||
thereof.
|
||||
|
||||
1.5. “Incompatible With Secondary Licenses”
|
||||
means
|
||||
|
||||
a. that the initial Contributor has attached the notice described in
|
||||
Exhibit B to the Covered Software; or
|
||||
|
||||
b. that the Covered Software was made available under the terms of version
|
||||
1.1 or earlier of the License, but not also under the terms of a
|
||||
Secondary License.
|
||||
|
||||
1.6. “Executable Form”
|
||||
|
||||
means any form of the work other than Source Code Form.
|
||||
|
||||
1.7. “Larger Work”
|
||||
|
||||
means a work that combines Covered Software with other material, in a separate
|
||||
file or files, that is not Covered Software.
|
||||
|
||||
1.8. “License”
|
||||
|
||||
means this document.
|
||||
|
||||
1.9. “Licensable”
|
||||
|
||||
means having the right to grant, to the maximum extent possible, whether at the
|
||||
time of the initial grant or subsequently, any and all of the rights conveyed by
|
||||
this License.
|
||||
|
||||
1.10. “Modifications”
|
||||
|
||||
means any of the following:
|
||||
|
||||
a. any file in Source Code Form that results from an addition to, deletion
|
||||
from, or modification of the contents of Covered Software; or
|
||||
|
||||
b. any new file in Source Code Form that contains any Covered Software.
|
||||
|
||||
1.11. “Patent Claims” of a Contributor
|
||||
|
||||
means any patent claim(s), including without limitation, method, process,
|
||||
and apparatus claims, in any patent Licensable by such Contributor that
|
||||
would be infringed, but for the grant of the License, by the making,
|
||||
using, selling, offering for sale, having made, import, or transfer of
|
||||
either its Contributions or its Contributor Version.
|
||||
|
||||
1.12. “Secondary License”
|
||||
|
||||
means either the GNU General Public License, Version 2.0, the GNU Lesser
|
||||
General Public License, Version 2.1, the GNU Affero General Public
|
||||
License, Version 3.0, or any later versions of those licenses.
|
||||
|
||||
1.13. “Source Code Form”
|
||||
|
||||
means the form of the work preferred for making modifications.
|
||||
|
||||
1.14. “You” (or “Your”)
|
||||
|
||||
means an individual or a legal entity exercising rights under this
|
||||
License. For legal entities, “You” includes any entity that controls, is
|
||||
controlled by, or is under common control with You. For purposes of this
|
||||
definition, “control” means (a) the power, direct or indirect, to cause
|
||||
the direction or management of such entity, whether by contract or
|
||||
otherwise, or (b) ownership of more than fifty percent (50%) of the
|
||||
outstanding shares or beneficial ownership of such entity.
|
||||
|
||||
|
||||
2. License Grants and Conditions
|
||||
|
||||
2.1. Grants
|
||||
|
||||
Each Contributor hereby grants You a world-wide, royalty-free,
|
||||
non-exclusive license:
|
||||
|
||||
a. under intellectual property rights (other than patent or trademark)
|
||||
Licensable by such Contributor to use, reproduce, make available,
|
||||
modify, display, perform, distribute, and otherwise exploit its
|
||||
Contributions, either on an unmodified basis, with Modifications, or as
|
||||
part of a Larger Work; and
|
||||
|
||||
b. under Patent Claims of such Contributor to make, use, sell, offer for
|
||||
sale, have made, import, and otherwise transfer either its Contributions
|
||||
or its Contributor Version.
|
||||
|
||||
2.2. Effective Date
|
||||
|
||||
The licenses granted in Section 2.1 with respect to any Contribution become
|
||||
effective for each Contribution on the date the Contributor first distributes
|
||||
such Contribution.
|
||||
|
||||
2.3. Limitations on Grant Scope
|
||||
|
||||
The licenses granted in this Section 2 are the only rights granted under this
|
||||
License. No additional rights or licenses will be implied from the distribution
|
||||
or licensing of Covered Software under this License. Notwithstanding Section
|
||||
2.1(b) above, no patent license is granted by a Contributor:
|
||||
|
||||
a. for any code that a Contributor has removed from Covered Software; or
|
||||
|
||||
b. for infringements caused by: (i) Your and any other third party’s
|
||||
modifications of Covered Software, or (ii) the combination of its
|
||||
Contributions with other software (except as part of its Contributor
|
||||
Version); or
|
||||
|
||||
c. under Patent Claims infringed by Covered Software in the absence of its
|
||||
Contributions.
|
||||
|
||||
This License does not grant any rights in the trademarks, service marks, or
|
||||
logos of any Contributor (except as may be necessary to comply with the
|
||||
notice requirements in Section 3.4).
|
||||
|
||||
2.4. Subsequent Licenses
|
||||
|
||||
No Contributor makes additional grants as a result of Your choice to
|
||||
distribute the Covered Software under a subsequent version of this License
|
||||
(see Section 10.2) or under the terms of a Secondary License (if permitted
|
||||
under the terms of Section 3.3).
|
||||
|
||||
2.5. Representation
|
||||
|
||||
Each Contributor represents that the Contributor believes its Contributions
|
||||
are its original creation(s) or it has sufficient rights to grant the
|
||||
rights to its Contributions conveyed by this License.
|
||||
|
||||
2.6. Fair Use
|
||||
|
||||
This License is not intended to limit any rights You have under applicable
|
||||
copyright doctrines of fair use, fair dealing, or other equivalents.
|
||||
|
||||
2.7. Conditions
|
||||
|
||||
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in
|
||||
Section 2.1.
|
||||
|
||||
|
||||
3. Responsibilities
|
||||
|
||||
3.1. Distribution of Source Form
|
||||
|
||||
All distribution of Covered Software in Source Code Form, including any
|
||||
Modifications that You create or to which You contribute, must be under the
|
||||
terms of this License. You must inform recipients that the Source Code Form
|
||||
of the Covered Software is governed by the terms of this License, and how
|
||||
they can obtain a copy of this License. You may not attempt to alter or
|
||||
restrict the recipients’ rights in the Source Code Form.
|
||||
|
||||
3.2. Distribution of Executable Form
|
||||
|
||||
If You distribute Covered Software in Executable Form then:
|
||||
|
||||
a. such Covered Software must also be made available in Source Code Form,
|
||||
as described in Section 3.1, and You must inform recipients of the
|
||||
Executable Form how they can obtain a copy of such Source Code Form by
|
||||
reasonable means in a timely manner, at a charge no more than the cost
|
||||
of distribution to the recipient; and
|
||||
|
||||
b. You may distribute such Executable Form under the terms of this License,
|
||||
or sublicense it under different terms, provided that the license for
|
||||
the Executable Form does not attempt to limit or alter the recipients’
|
||||
rights in the Source Code Form under this License.
|
||||
|
||||
3.3. Distribution of a Larger Work
|
||||
|
||||
You may create and distribute a Larger Work under terms of Your choice,
|
||||
provided that You also comply with the requirements of this License for the
|
||||
Covered Software. If the Larger Work is a combination of Covered Software
|
||||
with a work governed by one or more Secondary Licenses, and the Covered
|
||||
Software is not Incompatible With Secondary Licenses, this License permits
|
||||
You to additionally distribute such Covered Software under the terms of
|
||||
such Secondary License(s), so that the recipient of the Larger Work may, at
|
||||
their option, further distribute the Covered Software under the terms of
|
||||
either this License or such Secondary License(s).
|
||||
|
||||
3.4. Notices
|
||||
|
||||
You may not remove or alter the substance of any license notices (including
|
||||
copyright notices, patent notices, disclaimers of warranty, or limitations
|
||||
of liability) contained within the Source Code Form of the Covered
|
||||
Software, except that You may alter any license notices to the extent
|
||||
required to remedy known factual inaccuracies.
|
||||
|
||||
3.5. Application of Additional Terms
|
||||
|
||||
You may choose to offer, and to charge a fee for, warranty, support,
|
||||
indemnity or liability obligations to one or more recipients of Covered
|
||||
Software. However, You may do so only on Your own behalf, and not on behalf
|
||||
of any Contributor. You must make it absolutely clear that any such
|
||||
warranty, support, indemnity, or liability obligation is offered by You
|
||||
alone, and You hereby agree to indemnify every Contributor for any
|
||||
liability incurred by such Contributor as a result of warranty, support,
|
||||
indemnity or liability terms You offer. You may include additional
|
||||
disclaimers of warranty and limitations of liability specific to any
|
||||
jurisdiction.
|
||||
|
||||
4. Inability to Comply Due to Statute or Regulation
|
||||
|
||||
If it is impossible for You to comply with any of the terms of this License
|
||||
with respect to some or all of the Covered Software due to statute, judicial
|
||||
order, or regulation then You must: (a) comply with the terms of this License
|
||||
to the maximum extent possible; and (b) describe the limitations and the code
|
||||
they affect. Such description must be placed in a text file included with all
|
||||
distributions of the Covered Software under this License. Except to the
|
||||
extent prohibited by statute or regulation, such description must be
|
||||
sufficiently detailed for a recipient of ordinary skill to be able to
|
||||
understand it.
|
||||
|
||||
5. Termination
|
||||
|
||||
5.1. The rights granted under this License will terminate automatically if You
|
||||
fail to comply with any of its terms. However, if You become compliant,
|
||||
then the rights granted under this License from a particular Contributor
|
||||
are reinstated (a) provisionally, unless and until such Contributor
|
||||
explicitly and finally terminates Your grants, and (b) on an ongoing basis,
|
||||
if such Contributor fails to notify You of the non-compliance by some
|
||||
reasonable means prior to 60 days after You have come back into compliance.
|
||||
Moreover, Your grants from a particular Contributor are reinstated on an
|
||||
ongoing basis if such Contributor notifies You of the non-compliance by
|
||||
some reasonable means, this is the first time You have received notice of
|
||||
non-compliance with this License from such Contributor, and You become
|
||||
compliant prior to 30 days after Your receipt of the notice.
|
||||
|
||||
5.2. If You initiate litigation against any entity by asserting a patent
|
||||
infringement claim (excluding declaratory judgment actions, counter-claims,
|
||||
and cross-claims) alleging that a Contributor Version directly or
|
||||
indirectly infringes any patent, then the rights granted to You by any and
|
||||
all Contributors for the Covered Software under Section 2.1 of this License
|
||||
shall terminate.
|
||||
|
||||
5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user
|
||||
license agreements (excluding distributors and resellers) which have been
|
||||
validly granted by You or Your distributors under this License prior to
|
||||
termination shall survive termination.
|
||||
|
||||
6. Disclaimer of Warranty
|
||||
|
||||
Covered Software is provided under this License on an “as is” basis, without
|
||||
warranty of any kind, either expressed, implied, or statutory, including,
|
||||
without limitation, warranties that the Covered Software is free of defects,
|
||||
merchantable, fit for a particular purpose or non-infringing. The entire
|
||||
risk as to the quality and performance of the Covered Software is with You.
|
||||
Should any Covered Software prove defective in any respect, You (not any
|
||||
Contributor) assume the cost of any necessary servicing, repair, or
|
||||
correction. This disclaimer of warranty constitutes an essential part of this
|
||||
License. No use of any Covered Software is authorized under this License
|
||||
except under this disclaimer.
|
||||
|
||||
7. Limitation of Liability
|
||||
|
||||
Under no circumstances and under no legal theory, whether tort (including
|
||||
negligence), contract, or otherwise, shall any Contributor, or anyone who
|
||||
distributes Covered Software as permitted above, be liable to You for any
|
||||
direct, indirect, special, incidental, or consequential damages of any
|
||||
character including, without limitation, damages for lost profits, loss of
|
||||
goodwill, work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses, even if such party shall have been
|
||||
informed of the possibility of such damages. This limitation of liability
|
||||
shall not apply to liability for death or personal injury resulting from such
|
||||
party’s negligence to the extent applicable law prohibits such limitation.
|
||||
Some jurisdictions do not allow the exclusion or limitation of incidental or
|
||||
consequential damages, so this exclusion and limitation may not apply to You.
|
||||
|
||||
8. Litigation
|
||||
|
||||
Any litigation relating to this License may be brought only in the courts of
|
||||
a jurisdiction where the defendant maintains its principal place of business
|
||||
and such litigation shall be governed by laws of that jurisdiction, without
|
||||
reference to its conflict-of-law provisions. Nothing in this Section shall
|
||||
prevent a party’s ability to bring cross-claims or counter-claims.
|
||||
|
||||
9. Miscellaneous
|
||||
|
||||
This License represents the complete agreement concerning the subject matter
|
||||
hereof. If any provision of this License is held to be unenforceable, such
|
||||
provision shall be reformed only to the extent necessary to make it
|
||||
enforceable. Any law or regulation which provides that the language of a
|
||||
contract shall be construed against the drafter shall not be used to construe
|
||||
this License against a Contributor.
|
||||
|
||||
|
||||
10. Versions of the License
|
||||
|
||||
10.1. New Versions
|
||||
|
||||
Mozilla Foundation is the license steward. Except as provided in Section
|
||||
10.3, no one other than the license steward has the right to modify or
|
||||
publish new versions of this License. Each version will be given a
|
||||
distinguishing version number.
|
||||
|
||||
10.2. Effect of New Versions
|
||||
|
||||
You may distribute the Covered Software under the terms of the version of
|
||||
the License under which You originally received the Covered Software, or
|
||||
under the terms of any subsequent version published by the license
|
||||
steward.
|
||||
|
||||
10.3. Modified Versions
|
||||
|
||||
If you create software not governed by this License, and you want to
|
||||
create a new license for such software, you may create and use a modified
|
||||
version of this License if you rename the license and remove any
|
||||
references to the name of the license steward (except to note that such
|
||||
modified license differs from this License).
|
||||
|
||||
10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses
|
||||
If You choose to distribute Source Code Form that is Incompatible With
|
||||
Secondary Licenses under the terms of this version of the License, the
|
||||
notice described in Exhibit B of this License must be attached.
|
||||
|
||||
Exhibit A - Source Code Form License Notice
|
||||
|
||||
This Source Code Form is subject to the
|
||||
terms of the Mozilla Public License, v.
|
||||
2.0. If a copy of the MPL was not
|
||||
distributed with this file, You can
|
||||
obtain one at
|
||||
http://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a relevant
|
||||
directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
|
||||
Exhibit B - “Incompatible With Secondary Licenses” Notice
|
||||
|
||||
This Source Code Form is “Incompatible
|
||||
With Secondary Licenses”, as defined by
|
||||
the Mozilla Public License, v. 2.0.
|
||||
|
||||
89
vendor/github.com/hashicorp/go-multierror/vendor/github.com/hashicorp/errwrap/README.md
сгенерированный
поставляемый
89
vendor/github.com/hashicorp/go-multierror/vendor/github.com/hashicorp/errwrap/README.md
сгенерированный
поставляемый
@@ -1,89 +0,0 @@
|
||||
# errwrap
|
||||
|
||||
`errwrap` is a package for Go that formalizes the pattern of wrapping errors
|
||||
and checking if an error contains another error.
|
||||
|
||||
There is a common pattern in Go of taking a returned `error` value and
|
||||
then wrapping it (such as with `fmt.Errorf`) before returning it. The problem
|
||||
with this pattern is that you completely lose the original `error` structure.
|
||||
|
||||
Arguably the _correct_ approach is that you should make a custom structure
|
||||
implementing the `error` interface, and have the original error as a field
|
||||
on that structure, such [as this example](http://golang.org/pkg/os/#PathError).
|
||||
This is a good approach, but you have to know the entire chain of possible
|
||||
rewrapping that happens, when you might just care about one.
|
||||
|
||||
`errwrap` formalizes this pattern (it doesn't matter what approach you use
|
||||
above) by giving a single interface for wrapping errors, checking if a specific
|
||||
error is wrapped, and extracting that error.
|
||||
|
||||
## Installation and Docs
|
||||
|
||||
Install using `go get github.com/hashicorp/errwrap`.
|
||||
|
||||
Full documentation is available at
|
||||
http://godoc.org/github.com/hashicorp/errwrap
|
||||
|
||||
## Usage
|
||||
|
||||
#### Basic Usage
|
||||
|
||||
Below is a very basic example of its usage:
|
||||
|
||||
```go
|
||||
// A function that always returns an error, but wraps it, like a real
|
||||
// function might.
|
||||
func tryOpen() error {
|
||||
_, err := os.Open("/i/dont/exist")
|
||||
if err != nil {
|
||||
return errwrap.Wrapf("Doesn't exist: {{err}}", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
err := tryOpen()
|
||||
|
||||
// We can use the Contains helpers to check if an error contains
|
||||
// another error. It is safe to do this with a nil error, or with
|
||||
// an error that doesn't even use the errwrap package.
|
||||
if errwrap.Contains(err, ErrNotExist) {
|
||||
// Do something
|
||||
}
|
||||
if errwrap.ContainsType(err, new(os.PathError)) {
|
||||
// Do something
|
||||
}
|
||||
|
||||
// Or we can use the associated `Get` functions to just extract
|
||||
// a specific error. This would return nil if that specific error doesn't
|
||||
// exist.
|
||||
perr := errwrap.GetType(err, new(os.PathError))
|
||||
}
|
||||
```
|
||||
|
||||
#### Custom Types
|
||||
|
||||
If you're already making custom types that properly wrap errors, then
|
||||
you can get all the functionality of `errwraps.Contains` and such by
|
||||
implementing the `Wrapper` interface with just one function. Example:
|
||||
|
||||
```go
|
||||
type AppError {
|
||||
Code ErrorCode
|
||||
Err error
|
||||
}
|
||||
|
||||
func (e *AppError) WrappedErrors() []error {
|
||||
return []error{e.Err}
|
||||
}
|
||||
```
|
||||
|
||||
Now this works:
|
||||
|
||||
```go
|
||||
err := &AppError{Err: fmt.Errorf("an error")}
|
||||
if errwrap.ContainsType(err, fmt.Errorf("")) {
|
||||
// This will work!
|
||||
}
|
||||
```
|
||||
169
vendor/github.com/hashicorp/go-multierror/vendor/github.com/hashicorp/errwrap/errwrap.go
сгенерированный
поставляемый
169
vendor/github.com/hashicorp/go-multierror/vendor/github.com/hashicorp/errwrap/errwrap.go
сгенерированный
поставляемый
@@ -1,169 +0,0 @@
|
||||
// Package errwrap implements methods to formalize error wrapping in Go.
|
||||
//
|
||||
// All of the top-level functions that take an `error` are built to be able
|
||||
// to take any error, not just wrapped errors. This allows you to use errwrap
|
||||
// without having to type-check and type-cast everywhere.
|
||||
package errwrap
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"reflect"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// WalkFunc is the callback called for Walk.
|
||||
type WalkFunc func(error)
|
||||
|
||||
// Wrapper is an interface that can be implemented by custom types to
|
||||
// have all the Contains, Get, etc. functions in errwrap work.
|
||||
//
|
||||
// When Walk reaches a Wrapper, it will call the callback for every
|
||||
// wrapped error in addition to the wrapper itself. Since all the top-level
|
||||
// functions in errwrap use Walk, this means that all those functions work
|
||||
// with your custom type.
|
||||
type Wrapper interface {
|
||||
WrappedErrors() []error
|
||||
}
|
||||
|
||||
// Wrap defines that outer wraps inner, returning an error type that
|
||||
// can be cleanly used with the other methods in this package, such as
|
||||
// Contains, GetAll, etc.
|
||||
//
|
||||
// This function won't modify the error message at all (the outer message
|
||||
// will be used).
|
||||
func Wrap(outer, inner error) error {
|
||||
return &wrappedError{
|
||||
Outer: outer,
|
||||
Inner: inner,
|
||||
}
|
||||
}
|
||||
|
||||
// Wrapf wraps an error with a formatting message. This is similar to using
|
||||
// `fmt.Errorf` to wrap an error. If you're using `fmt.Errorf` to wrap
|
||||
// errors, you should replace it with this.
|
||||
//
|
||||
// format is the format of the error message. The string '{{err}}' will
|
||||
// be replaced with the original error message.
|
||||
func Wrapf(format string, err error) error {
|
||||
outerMsg := "<nil>"
|
||||
if err != nil {
|
||||
outerMsg = err.Error()
|
||||
}
|
||||
|
||||
outer := errors.New(strings.Replace(
|
||||
format, "{{err}}", outerMsg, -1))
|
||||
|
||||
return Wrap(outer, err)
|
||||
}
|
||||
|
||||
// Contains checks if the given error contains an error with the
|
||||
// message msg. If err is not a wrapped error, this will always return
|
||||
// false unless the error itself happens to match this msg.
|
||||
func Contains(err error, msg string) bool {
|
||||
return len(GetAll(err, msg)) > 0
|
||||
}
|
||||
|
||||
// ContainsType checks if the given error contains an error with
|
||||
// the same concrete type as v. If err is not a wrapped error, this will
|
||||
// check the err itself.
|
||||
func ContainsType(err error, v interface{}) bool {
|
||||
return len(GetAllType(err, v)) > 0
|
||||
}
|
||||
|
||||
// Get is the same as GetAll but returns the deepest matching error.
|
||||
func Get(err error, msg string) error {
|
||||
es := GetAll(err, msg)
|
||||
if len(es) > 0 {
|
||||
return es[len(es)-1]
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetType is the same as GetAllType but returns the deepest matching error.
|
||||
func GetType(err error, v interface{}) error {
|
||||
es := GetAllType(err, v)
|
||||
if len(es) > 0 {
|
||||
return es[len(es)-1]
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetAll gets all the errors that might be wrapped in err with the
|
||||
// given message. The order of the errors is such that the outermost
|
||||
// matching error (the most recent wrap) is index zero, and so on.
|
||||
func GetAll(err error, msg string) []error {
|
||||
var result []error
|
||||
|
||||
Walk(err, func(err error) {
|
||||
if err.Error() == msg {
|
||||
result = append(result, err)
|
||||
}
|
||||
})
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// GetAllType gets all the errors that are the same type as v.
|
||||
//
|
||||
// The order of the return value is the same as described in GetAll.
|
||||
func GetAllType(err error, v interface{}) []error {
|
||||
var result []error
|
||||
|
||||
var search string
|
||||
if v != nil {
|
||||
search = reflect.TypeOf(v).String()
|
||||
}
|
||||
Walk(err, func(err error) {
|
||||
var needle string
|
||||
if err != nil {
|
||||
needle = reflect.TypeOf(err).String()
|
||||
}
|
||||
|
||||
if needle == search {
|
||||
result = append(result, err)
|
||||
}
|
||||
})
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// Walk walks all the wrapped errors in err and calls the callback. If
|
||||
// err isn't a wrapped error, this will be called once for err. If err
|
||||
// is a wrapped error, the callback will be called for both the wrapper
|
||||
// that implements error as well as the wrapped error itself.
|
||||
func Walk(err error, cb WalkFunc) {
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
|
||||
switch e := err.(type) {
|
||||
case *wrappedError:
|
||||
cb(e.Outer)
|
||||
Walk(e.Inner, cb)
|
||||
case Wrapper:
|
||||
cb(err)
|
||||
|
||||
for _, err := range e.WrappedErrors() {
|
||||
Walk(err, cb)
|
||||
}
|
||||
default:
|
||||
cb(err)
|
||||
}
|
||||
}
|
||||
|
||||
// wrappedError is an implementation of error that has both the
|
||||
// outer and inner errors.
|
||||
type wrappedError struct {
|
||||
Outer error
|
||||
Inner error
|
||||
}
|
||||
|
||||
func (w *wrappedError) Error() string {
|
||||
return w.Outer.Error()
|
||||
}
|
||||
|
||||
func (w *wrappedError) WrappedErrors() []error {
|
||||
return []error{w.Outer, w.Inner}
|
||||
}
|
||||
13
vendor/github.com/hashicorp/go-multierror/vendor/vendor.json
сгенерированный
поставляемый
13
vendor/github.com/hashicorp/go-multierror/vendor/vendor.json
сгенерированный
поставляемый
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"comment": "",
|
||||
"ignore": "test",
|
||||
"package": [
|
||||
{
|
||||
"checksumSHA1": "cdOCt0Yb+hdErz8NAQqayxPmRsY=",
|
||||
"path": "github.com/hashicorp/errwrap",
|
||||
"revision": "7554cd9344cec97297fa6649b055a8c98c2a1e55",
|
||||
"revisionTime": "2014-10-28T05:47:10Z"
|
||||
}
|
||||
],
|
||||
"rootPath": "github.com/hashicorp/go-multierror"
|
||||
}
|
||||
2
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/.gitignore
сгенерированный
поставляемый
2
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/.gitignore
сгенерированный
поставляемый
@@ -1,2 +0,0 @@
|
||||
/sockaddr
|
||||
/bin/
|
||||
29
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/GNUmakefile
сгенерированный
поставляемый
29
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/GNUmakefile
сгенерированный
поставляемый
@@ -1,29 +0,0 @@
|
||||
BIN:=sockaddr
|
||||
SRCS:=$(shell find . -name '*.go' ! -path '*/vendor/*')
|
||||
|
||||
.DEFAULT_GOAL := dev
|
||||
|
||||
.PHONY: dev
|
||||
dev: $(BIN)
|
||||
@install $(BIN) ${GOPATH}/bin/
|
||||
|
||||
$(BIN): $(SRCS)
|
||||
go build -o $@
|
||||
|
||||
.PHONY: clean
|
||||
clean::
|
||||
rm -f $(BIN) bin/* regression/*.diff
|
||||
rmdir bin/ || true
|
||||
|
||||
.PHONY: install
|
||||
install:: $(BIN)
|
||||
install sockaddr ${GOPATH}/bin/
|
||||
|
||||
.PHONY: test
|
||||
test:: $(BIN)
|
||||
@$(MAKE) -C regression
|
||||
|
||||
.PHONY: world
|
||||
world::
|
||||
mkdir -p bin
|
||||
gox -os="solaris darwin freebsd linux windows" -arch="386 amd64 arm" -output="bin/sockaddr_{{.OS}}_{{.Arch}}" .
|
||||
239
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/README.md
сгенерированный
поставляемый
239
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/README.md
сгенерированный
поставляемый
@@ -1,239 +0,0 @@
|
||||
# `sockaddr(1)`
|
||||
|
||||
`sockaddr` is a CLI utility that wraps and exposes `go-sockaddr` functionality
|
||||
from the command line.
|
||||
|
||||
```text
|
||||
$ go get -u github.com/hashicorp/go-sockaddr/cmd/sockaddr
|
||||
```
|
||||
|
||||
```text
|
||||
% sockaddr -h
|
||||
usage: sockaddr [--version] [--help] <command> [<args>]
|
||||
|
||||
Available commands are:
|
||||
dump Parses IP addresses
|
||||
eval Evaluates a sockaddr template
|
||||
rfc Test to see if an IP is part of a known RFC
|
||||
version Prints the sockaddr version
|
||||
```
|
||||
|
||||
## `sockaddr dump`
|
||||
|
||||
```text
|
||||
Usage: sockaddr dump [options] input [...]
|
||||
|
||||
Parse address(es) or interface and dumps various output.
|
||||
|
||||
Options:
|
||||
|
||||
-4 Parse the input as IPv4 only
|
||||
-6 Parse the input as IPv6 only
|
||||
-H Machine readable output
|
||||
-I Parse the argument as an interface name
|
||||
-i Parse the input as IP address (either IPv4 or IPv6)
|
||||
-n Show only the value
|
||||
-o Name of an attribute to pass through
|
||||
-u Parse the input as a UNIX Socket only
|
||||
```
|
||||
|
||||
### `sockaddr dump` example output
|
||||
|
||||
By default it prints out all available information unless the `-o` flag is
|
||||
specified.
|
||||
|
||||
```text
|
||||
% sockaddr dump 127.0.0.2/8
|
||||
Attribute Value
|
||||
type IPv4
|
||||
string 127.0.0.2/8
|
||||
host 127.0.0.2
|
||||
address 127.0.0.2
|
||||
port 0
|
||||
netmask 255.0.0.0
|
||||
network 127.0.0.0/8
|
||||
mask_bits 8
|
||||
binary 01111111000000000000000000000010
|
||||
hex 7f000002
|
||||
first_usable 127.0.0.1
|
||||
last_usable 127.255.255.254
|
||||
octets 127 0 0 2
|
||||
size 16777216
|
||||
broadcast 127.255.255.255
|
||||
uint32 2130706434
|
||||
DialPacket "udp4" ""
|
||||
DialStream "tcp4" ""
|
||||
ListenPacket "udp4" ""
|
||||
ListenStream "tcp4" ""
|
||||
$ sockaddr dump -H -o host,address,port -o mask_bits 127.0.0.3:8600
|
||||
host 127.0.0.3:8600
|
||||
address 127.0.0.3
|
||||
port 8600
|
||||
mask_bits 32
|
||||
$ sockaddr dump -H -n -o host,address,port -o mask_bits 127.0.0.3:8600
|
||||
127.0.0.3:8600
|
||||
127.0.0.3
|
||||
8600
|
||||
32
|
||||
$ sockaddr dump -o type,address,hex,network '[2001:db8::3/32]'
|
||||
Attribute Value
|
||||
type IPv6
|
||||
address 2001:db8::3
|
||||
network 2001:db8::/32
|
||||
hex 20010db8000000000000000000000003
|
||||
$ sockaddr dump /tmp/example.sock
|
||||
Attribute Value
|
||||
type UNIX
|
||||
string "/tmp/example.sock"
|
||||
path /tmp/example.sock
|
||||
DialPacket "unixgram" "/tmp/example.sock"
|
||||
DialStream "unix" "/tmp/example.sock"
|
||||
ListenPacket "unixgram" "/tmp/example.sock"
|
||||
ListenStream "unix" "/tmp/example.sock"
|
||||
```
|
||||
|
||||
## `sockaddr eval`
|
||||
|
||||
```text
|
||||
Usage: sockaddr eval [options] [template ...]
|
||||
|
||||
Parse the sockaddr template and evaluates the output.
|
||||
|
||||
The `sockaddr` library has the potential to be very complex,
|
||||
which is why the `sockaddr` command supports an `eval`
|
||||
subcommand in order to test configurations from the command
|
||||
line. The `eval` subcommand automatically wraps its input
|
||||
with the `{{` and `}}` template delimiters unless the `-r`
|
||||
command is specified, in which case `eval` parses the raw
|
||||
input. If the `template` argument passed to `eval` is a
|
||||
dash (`-`), then `sockaddr eval` will read from stdin and
|
||||
automatically sets the `-r` flag.
|
||||
|
||||
Options:
|
||||
|
||||
-d Debug output
|
||||
-n Suppress newlines between args
|
||||
-r Suppress wrapping the input with {{ }} delimiters
|
||||
```
|
||||
|
||||
Here are a few impractical examples to get you started:
|
||||
|
||||
```text
|
||||
$ sockaddr eval 'GetAllInterfaces | include "flags" "forwardable" | include "up" | sort "default,type,size" | include "RFC" "6890" | attr "address"'
|
||||
172.14.6.167
|
||||
$ sockaddr eval 'GetDefaultInterfaces | sort "type,size" | include "RFC" "6890" | limit 1 | join "address" " "'
|
||||
172.14.6.167
|
||||
$ sockaddr eval 'GetPublicIP'
|
||||
203.0.113.4
|
||||
$ sockaddr eval 'GetPrivateIP'
|
||||
172.14.6.167
|
||||
$ sockaddr eval 'GetInterfaceIP "eth0"'
|
||||
172.14.6.167
|
||||
$ sockaddr eval 'GetAllInterfaces | include "network" "172.14.6.0/24" | attr "address"'
|
||||
172.14.6.167
|
||||
$ sockaddr eval 'GetPrivateInterfaces | join "type" " "'
|
||||
IPv4 IPv6
|
||||
$ sockaddr eval 'GetAllInterfaces | include "flags" "forwardable" | join "address" " "'
|
||||
203.0.113.4 2001:0DB8::1
|
||||
$ sockaddr eval 'GetAllInterfaces | include "name" "lo0" | include "type" "IPv6" | sort "address" | join "address" " "'
|
||||
100:: fe80::1
|
||||
$ sockaddr eval '. | include "rfc" "1918" | print | len | lt 2'
|
||||
true
|
||||
$ sockaddr eval -r '{{with $ifSet := include "name" "lo0" . }}{{ range include "type" "IPv6" $ifSet | sort "address" | reverse}}{{ . }} {{end}}{{end}}'
|
||||
fe80::1/64 {1 16384 lo0 up|loopback|multicast} 100:: {1 16384 lo0 up|loopback|multicast}
|
||||
$ sockaddr eval '. | include "name" "lo0" | include "type" "IPv6" | sort "address" | join "address" " "'
|
||||
100:: fe80::1
|
||||
$ cat <<'EOF' | sockaddr eval -
|
||||
{{. | include "name" "lo0" | include "type" "IPv6" | sort "address" | join "address" " "}}
|
||||
EOF
|
||||
100:: fe80::1
|
||||
$ sockaddr eval 'GetPrivateInterfaces | include "flags" "forwardable|up" | include "type" "IPv4" | math "network" "+2" | attr "address"'
|
||||
172.14.6.2
|
||||
$ cat <<'EOF' | sudo tee -a /etc/profile
|
||||
export CONSUL_HTTP_ADDR="http://`sockaddr eval 'GetInterfaceIP \"eth0\"'`:8500"
|
||||
EOF
|
||||
```
|
||||
|
||||
## `sockaddr rfc`
|
||||
|
||||
```text
|
||||
$ sockaddr rfc
|
||||
Usage: sockaddr rfc [RFC Number] [IP Address]
|
||||
|
||||
Tests a given IP address to see if it is part of a known
|
||||
RFC. If the IP address belongs to a known RFC, return exit
|
||||
code 0 and print the status. If the IP does not belong to
|
||||
an RFC, return 1. If the RFC is not known, return 2.
|
||||
|
||||
Options:
|
||||
|
||||
-s Silent, only return different exit codes
|
||||
$ sockaddr rfc 1918 192.168.1.10
|
||||
192.168.1.10 is part of RFC 1918
|
||||
$ sockaddr rfc 6890 '[::1]'
|
||||
100:: is part of RFC 6890
|
||||
$ sockaddr rfc list
|
||||
919
|
||||
1112
|
||||
1122
|
||||
1918
|
||||
2544
|
||||
2765
|
||||
2928
|
||||
3056
|
||||
3068
|
||||
3171
|
||||
3330
|
||||
3849
|
||||
3927
|
||||
4038
|
||||
4193
|
||||
4291
|
||||
4380
|
||||
4773
|
||||
4843
|
||||
5180
|
||||
5735
|
||||
5737
|
||||
6052
|
||||
6333
|
||||
6598
|
||||
6666
|
||||
6890
|
||||
7335
|
||||
```
|
||||
|
||||
## `sockaddr tech-support`
|
||||
|
||||
If one of the helper methods that derives its output from `GetDefaultInterfaces`
|
||||
is misbehaving, submit the output from this command as an issue along with
|
||||
any miscellaneous details that are specific to your environment.
|
||||
|
||||
```text
|
||||
Usage: sockaddr tech-support [options]
|
||||
|
||||
Print out network diagnostic information that can be used by
|
||||
support.
|
||||
|
||||
The `sockaddr` library relies on OS-specific commands and
|
||||
output which can potentially be brittle. The `tech-support`
|
||||
subcommand emits all of the platform-specific network
|
||||
details required to debug why a given `sockaddr` API call is
|
||||
behaving differently than expected. The `-output` flag
|
||||
controls the output format. The default output mode is
|
||||
Markdown (`md`) however a raw mode (`raw`) is available to
|
||||
obtain the original output.
|
||||
|
||||
Options:
|
||||
|
||||
-output Encode the output using one of Markdown ("md") or Raw ("raw")
|
||||
```
|
||||
|
||||
## `sockaddr version`
|
||||
|
||||
The lowly version stub.
|
||||
|
||||
```text
|
||||
$ sockaddr version
|
||||
sockaddr 0.1.0-dev
|
||||
```
|
||||
121
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/command/autohelp.go
сгенерированный
поставляемый
121
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/command/autohelp.go
сгенерированный
поставляемый
@@ -1,121 +0,0 @@
|
||||
package command
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
wordwrap "github.com/mitchellh/go-wordwrap"
|
||||
"github.com/ryanuber/columnize"
|
||||
)
|
||||
|
||||
// AutoHelp specifies the necessary methods required to have their help
|
||||
// completely generated for them.
|
||||
type AutoHelp interface {
|
||||
Usage() string
|
||||
Description() string
|
||||
InitOpts()
|
||||
VisitAllFlags(func(f *flag.Flag))
|
||||
}
|
||||
|
||||
// MakeHelp generates a help string based on the capabilities of the Command
|
||||
func MakeHelp(c AutoHelp) string {
|
||||
usageText := c.Usage()
|
||||
|
||||
// If the length of Usage() is zero, then assume this is a hidden
|
||||
// command.
|
||||
if len(usageText) == 0 {
|
||||
return ""
|
||||
}
|
||||
|
||||
descriptionText := wordwrap.WrapString(c.Description(), 60)
|
||||
descrLines := strings.Split(descriptionText, "\n")
|
||||
prefixedLines := make([]string, len(descrLines))
|
||||
for i := range descrLines {
|
||||
prefixedLines[i] = " " + descrLines[i]
|
||||
}
|
||||
descriptionText = strings.Join(prefixedLines, "\n")
|
||||
|
||||
c.InitOpts()
|
||||
flags := []*flag.Flag{}
|
||||
c.VisitAllFlags(func(f *flag.Flag) {
|
||||
flags = append(flags, f)
|
||||
})
|
||||
optionsText := OptionsHelpOutput(flags)
|
||||
|
||||
var helpOutput string
|
||||
switch {
|
||||
case len(optionsText) == 0 && len(descriptionText) == 0:
|
||||
helpOutput = usageText
|
||||
case len(optionsText) == 0:
|
||||
helpOutput = fmt.Sprintf(`Usage: %s
|
||||
|
||||
%s`,
|
||||
usageText, descriptionText)
|
||||
case len(descriptionText) == 0 && len(optionsText) > 0:
|
||||
helpOutput = fmt.Sprintf(`Usage: %s
|
||||
|
||||
Options:
|
||||
|
||||
%s`,
|
||||
usageText, optionsText)
|
||||
default:
|
||||
helpOutput = fmt.Sprintf(`Usage: %s
|
||||
|
||||
%s
|
||||
|
||||
Options:
|
||||
|
||||
%s`,
|
||||
usageText, descriptionText, optionsText)
|
||||
}
|
||||
|
||||
return strings.TrimSpace(helpOutput)
|
||||
}
|
||||
|
||||
// ByOptName implements sort.Interface for flag.Flag based on the Name field.
|
||||
type ByName []*flag.Flag
|
||||
|
||||
func (a ByName) Len() int { return len(a) }
|
||||
func (a ByName) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
||||
func (a ByName) Less(i, j int) bool {
|
||||
// Bubble up single-char args to the top of the list
|
||||
switch {
|
||||
case len(a[i].Name) == 1 && len(a[j].Name) != 1:
|
||||
return true
|
||||
case len(a[i].Name) != 1 && len(a[j].Name) == 1:
|
||||
return false
|
||||
default:
|
||||
// Case-insensitive sort. Use case as a tie breaker, however.
|
||||
a1 := strings.ToLower(a[i].Name)
|
||||
a2 := strings.ToLower(a[j].Name)
|
||||
if a1 == a2 {
|
||||
return a[i].Name < a[j].Name
|
||||
} else {
|
||||
return a1 < a2
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// OptionsHelpOutput returns a string of formatted options
|
||||
func OptionsHelpOutput(flags []*flag.Flag) string {
|
||||
sort.Sort(ByName(flags))
|
||||
|
||||
var output []string
|
||||
for _, f := range flags {
|
||||
if len(f.Usage) == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
output = append(output, fmt.Sprintf("-%s | %s", f.Name, f.Usage))
|
||||
}
|
||||
|
||||
optionsOutput := columnize.Format(output, &columnize.Config{
|
||||
Delim: "|",
|
||||
Glue: " ",
|
||||
Prefix: " ",
|
||||
Empty: "",
|
||||
})
|
||||
return optionsOutput
|
||||
}
|
||||
274
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/command/dump.go
сгенерированный
поставляемый
274
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/command/dump.go
сгенерированный
поставляемый
@@ -1,274 +0,0 @@
|
||||
package command
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
|
||||
"github.com/hashicorp/errwrap"
|
||||
sockaddr "github.com/hashicorp/go-sockaddr"
|
||||
"github.com/mitchellh/cli"
|
||||
"github.com/ryanuber/columnize"
|
||||
)
|
||||
|
||||
type DumpCommand struct {
|
||||
Ui cli.Ui
|
||||
|
||||
// attrNames is a list of attribute names to include in the output
|
||||
attrNames []string
|
||||
|
||||
// flags is a list of options belonging to this command
|
||||
flags *flag.FlagSet
|
||||
|
||||
// machineMode changes the output format to be machine friendly
|
||||
// (i.e. tab-separated values).
|
||||
machineMode bool
|
||||
|
||||
// valueOnly changes the output format to include only values
|
||||
valueOnly bool
|
||||
|
||||
// ifOnly parses the input as an interface name
|
||||
ifOnly bool
|
||||
|
||||
// ipOnly parses the input as an IP address (either IPv4 or IPv6)
|
||||
ipOnly bool
|
||||
|
||||
// v4Only parses the input exclusively as an IPv4 address
|
||||
v4Only bool
|
||||
|
||||
// v6Only parses the input exclusively as an IPv6 address
|
||||
v6Only bool
|
||||
|
||||
// unixOnly parses the input exclusively as a UNIX Socket
|
||||
unixOnly bool
|
||||
}
|
||||
|
||||
// Description is the long-form command help.
|
||||
func (c *DumpCommand) Description() string {
|
||||
return `Parse address(es) or interface and dumps various output.`
|
||||
}
|
||||
|
||||
// Help returns the full help output expected by `sockaddr -h cmd`
|
||||
func (c *DumpCommand) Help() string {
|
||||
return MakeHelp(c)
|
||||
}
|
||||
|
||||
// InitOpts is responsible for setup of this command's configuration via the
|
||||
// command line. InitOpts() does not parse the arguments (see parseOpts()).
|
||||
func (c *DumpCommand) InitOpts() {
|
||||
c.flags = flag.NewFlagSet("dump", flag.ContinueOnError)
|
||||
c.flags.Usage = func() { c.Ui.Output(c.Help()) }
|
||||
c.flags.BoolVar(&c.machineMode, "H", false, "Machine readable output")
|
||||
c.flags.BoolVar(&c.valueOnly, "n", false, "Show only the value")
|
||||
c.flags.BoolVar(&c.v4Only, "4", false, "Parse the input as IPv4 only")
|
||||
c.flags.BoolVar(&c.v6Only, "6", false, "Parse the input as IPv6 only")
|
||||
c.flags.BoolVar(&c.ifOnly, "I", false, "Parse the argument as an interface name")
|
||||
c.flags.BoolVar(&c.ipOnly, "i", false, "Parse the input as IP address (either IPv4 or IPv6)")
|
||||
c.flags.BoolVar(&c.unixOnly, "u", false, "Parse the input as a UNIX Socket only")
|
||||
c.flags.Var((*MultiArg)(&c.attrNames), "o", "Name of an attribute to pass through")
|
||||
}
|
||||
|
||||
// Run executes this command.
|
||||
func (c *DumpCommand) Run(args []string) int {
|
||||
if len(args) == 0 {
|
||||
c.Ui.Error(c.Help())
|
||||
return 1
|
||||
}
|
||||
|
||||
c.InitOpts()
|
||||
addrs, err := c.parseOpts(args)
|
||||
if err != nil {
|
||||
if errwrap.Contains(err, "flag: help requested") {
|
||||
return 0
|
||||
}
|
||||
return 1
|
||||
}
|
||||
for _, addr := range addrs {
|
||||
var sa sockaddr.SockAddr
|
||||
var ifAddrs sockaddr.IfAddrs
|
||||
var err error
|
||||
switch {
|
||||
case c.v4Only:
|
||||
sa, err = sockaddr.NewIPv4Addr(addr)
|
||||
case c.v6Only:
|
||||
sa, err = sockaddr.NewIPv6Addr(addr)
|
||||
case c.unixOnly:
|
||||
sa, err = sockaddr.NewUnixSock(addr)
|
||||
case c.ipOnly:
|
||||
sa, err = sockaddr.NewIPAddr(addr)
|
||||
case c.ifOnly:
|
||||
ifAddrs, err = sockaddr.GetAllInterfaces()
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
|
||||
ifAddrs, _, err = sockaddr.IfByName(addr, ifAddrs)
|
||||
default:
|
||||
sa, err = sockaddr.NewSockAddr(addr)
|
||||
}
|
||||
if err != nil {
|
||||
c.Ui.Error(fmt.Sprintf("Unable to parse %+q: %v", addr, err))
|
||||
return 1
|
||||
}
|
||||
if sa != nil {
|
||||
c.dumpSockAddr(sa)
|
||||
} else if ifAddrs != nil {
|
||||
c.dumpIfAddrs(ifAddrs)
|
||||
} else {
|
||||
panic("bad")
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// Synopsis returns a terse description used when listing sub-commands.
|
||||
func (c *DumpCommand) Synopsis() string {
|
||||
return `Parses input as an IP or interface name(s) and dumps various information`
|
||||
}
|
||||
|
||||
// Usage is the one-line usage description
|
||||
func (c *DumpCommand) Usage() string {
|
||||
return `sockaddr dump [options] input [...]`
|
||||
}
|
||||
|
||||
// VisitAllFlags forwards the visitor function to the FlagSet
|
||||
func (c *DumpCommand) VisitAllFlags(fn func(*flag.Flag)) {
|
||||
c.flags.VisitAll(fn)
|
||||
}
|
||||
|
||||
func (c *DumpCommand) dumpIfAddrs(ifAddrs sockaddr.IfAddrs) {
|
||||
for _, ifAddr := range ifAddrs {
|
||||
c.dumpSockAddr(ifAddr.SockAddr)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *DumpCommand) dumpSockAddr(sa sockaddr.SockAddr) {
|
||||
reservedAttrs := []sockaddr.AttrName{"Attribute"}
|
||||
const maxNumAttrs = 32
|
||||
|
||||
output := make([]string, 0, maxNumAttrs+len(reservedAttrs))
|
||||
allowedAttrs := make(map[sockaddr.AttrName]struct{}, len(c.attrNames)+len(reservedAttrs))
|
||||
for _, attr := range reservedAttrs {
|
||||
allowedAttrs[attr] = struct{}{}
|
||||
}
|
||||
for _, attr := range c.attrNames {
|
||||
allowedAttrs[sockaddr.AttrName(attr)] = struct{}{}
|
||||
}
|
||||
|
||||
// allowedAttr returns true if the attribute is allowed to be appended
|
||||
// to the output.
|
||||
allowedAttr := func(k sockaddr.AttrName) bool {
|
||||
if len(allowedAttrs) == len(reservedAttrs) {
|
||||
return true
|
||||
}
|
||||
|
||||
_, found := allowedAttrs[k]
|
||||
return found
|
||||
}
|
||||
|
||||
// outFmt is a small helper function to reduce the tedium below. outFmt
|
||||
// returns a new slice and expects the value to already be a string.
|
||||
outFmt := func(o []string, k sockaddr.AttrName, v interface{}) []string {
|
||||
if !allowedAttr(k) {
|
||||
return o
|
||||
}
|
||||
switch {
|
||||
case c.valueOnly:
|
||||
return append(o, fmt.Sprintf("%s", v))
|
||||
case !c.valueOnly && c.machineMode:
|
||||
return append(o, fmt.Sprintf("%s\t%s", k, v))
|
||||
case !c.valueOnly && !c.machineMode:
|
||||
fallthrough
|
||||
default:
|
||||
return append(o, fmt.Sprintf("%s | %s", k, v))
|
||||
}
|
||||
}
|
||||
|
||||
if !c.machineMode {
|
||||
output = outFmt(output, "Attribute", "Value")
|
||||
}
|
||||
|
||||
// Attributes for all SockAddr types
|
||||
for _, attr := range sockaddr.SockAddrAttrs() {
|
||||
output = outFmt(output, attr, sockaddr.SockAddrAttr(sa, attr))
|
||||
}
|
||||
|
||||
// Attributes for all IP types (both IPv4 and IPv6)
|
||||
if sa.Type()&sockaddr.TypeIP != 0 {
|
||||
ip := *sockaddr.ToIPAddr(sa)
|
||||
for _, attr := range sockaddr.IPAttrs() {
|
||||
output = outFmt(output, attr, sockaddr.IPAddrAttr(ip, attr))
|
||||
}
|
||||
}
|
||||
|
||||
if sa.Type() == sockaddr.TypeIPv4 {
|
||||
ipv4 := *sockaddr.ToIPv4Addr(sa)
|
||||
for _, attr := range sockaddr.IPv4Attrs() {
|
||||
output = outFmt(output, attr, sockaddr.IPv4AddrAttr(ipv4, attr))
|
||||
}
|
||||
}
|
||||
|
||||
if sa.Type() == sockaddr.TypeIPv6 {
|
||||
ipv6 := *sockaddr.ToIPv6Addr(sa)
|
||||
for _, attr := range sockaddr.IPv6Attrs() {
|
||||
output = outFmt(output, attr, sockaddr.IPv6AddrAttr(ipv6, attr))
|
||||
}
|
||||
}
|
||||
|
||||
if sa.Type() == sockaddr.TypeUnix {
|
||||
us := *sockaddr.ToUnixSock(sa)
|
||||
for _, attr := range sockaddr.UnixSockAttrs() {
|
||||
output = outFmt(output, attr, sockaddr.UnixSockAttr(us, attr))
|
||||
}
|
||||
}
|
||||
|
||||
// Developer-focused arguments
|
||||
{
|
||||
arg1, arg2 := sa.DialPacketArgs()
|
||||
output = outFmt(output, "DialPacket", fmt.Sprintf("%+q %+q", arg1, arg2))
|
||||
}
|
||||
{
|
||||
arg1, arg2 := sa.DialStreamArgs()
|
||||
output = outFmt(output, "DialStream", fmt.Sprintf("%+q %+q", arg1, arg2))
|
||||
}
|
||||
{
|
||||
arg1, arg2 := sa.ListenPacketArgs()
|
||||
output = outFmt(output, "ListenPacket", fmt.Sprintf("%+q %+q", arg1, arg2))
|
||||
}
|
||||
{
|
||||
arg1, arg2 := sa.ListenStreamArgs()
|
||||
output = outFmt(output, "ListenStream", fmt.Sprintf("%+q %+q", arg1, arg2))
|
||||
}
|
||||
|
||||
result := columnize.SimpleFormat(output)
|
||||
c.Ui.Output(result)
|
||||
}
|
||||
|
||||
// parseOpts is responsible for parsing the options set in InitOpts(). Returns
|
||||
// a list of non-parsed flags.
|
||||
func (c *DumpCommand) parseOpts(args []string) ([]string, error) {
|
||||
if err := c.flags.Parse(args); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
conflictingOptsCount := 0
|
||||
if c.v4Only {
|
||||
conflictingOptsCount++
|
||||
}
|
||||
if c.v6Only {
|
||||
conflictingOptsCount++
|
||||
}
|
||||
if c.unixOnly {
|
||||
conflictingOptsCount++
|
||||
}
|
||||
if c.ifOnly {
|
||||
conflictingOptsCount++
|
||||
}
|
||||
if c.ipOnly {
|
||||
conflictingOptsCount++
|
||||
}
|
||||
if conflictingOptsCount > 1 {
|
||||
return nil, fmt.Errorf("Conflicting options specified, only one parsing mode may be specified at a time")
|
||||
}
|
||||
|
||||
return c.flags.Args(), nil
|
||||
}
|
||||
158
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/command/eval.go
сгенерированный
поставляемый
158
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/command/eval.go
сгенерированный
поставляемый
@@ -1,158 +0,0 @@
|
||||
package command
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/errwrap"
|
||||
"github.com/hashicorp/go-sockaddr/template"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
|
||||
type EvalCommand struct {
|
||||
Ui cli.Ui
|
||||
|
||||
// debugOutput emits framed output vs raw output.
|
||||
debugOutput bool
|
||||
|
||||
// flags is a list of options belonging to this command
|
||||
flags *flag.FlagSet
|
||||
|
||||
// rawInput disables wrapping the string in the text/template {{ }}
|
||||
// handlebars.
|
||||
rawInput bool
|
||||
|
||||
// suppressNewline changes whether or not there's a newline between each
|
||||
// arg passed to the eval subcommand.
|
||||
suppressNewline bool
|
||||
}
|
||||
|
||||
// Description is the long-form command help.
|
||||
func (c *EvalCommand) Description() string {
|
||||
return `Parse the sockaddr template and evaluates the output.
|
||||
|
||||
` + "The `sockaddr` library has the potential to be very complex, which is why the " +
|
||||
"`sockaddr` command supports an `eval` subcommand in order to test configurations " +
|
||||
"from the command line. The `eval` subcommand automatically wraps its input with " +
|
||||
"the `{{` and `}}` template delimiters unless the `-r` command is specified, in " +
|
||||
"which case `eval` parses the raw input. If the `template` argument passed to " +
|
||||
"`eval` is a dash (`-`), then `sockaddr eval` will read from stdin and " +
|
||||
"automatically sets the `-r` flag."
|
||||
|
||||
}
|
||||
|
||||
// Help returns the full help output expected by `sockaddr -h cmd`
|
||||
func (c *EvalCommand) Help() string {
|
||||
return MakeHelp(c)
|
||||
}
|
||||
|
||||
// InitOpts is responsible for setup of this command's configuration via the
|
||||
// command line. InitOpts() does not parse the arguments (see parseOpts()).
|
||||
func (c *EvalCommand) InitOpts() {
|
||||
c.flags = flag.NewFlagSet("eval", flag.ContinueOnError)
|
||||
c.flags.Usage = func() { c.Ui.Output(c.Help()) }
|
||||
c.flags.BoolVar(&c.debugOutput, "d", false, "Debug output")
|
||||
c.flags.BoolVar(&c.suppressNewline, "n", false, "Suppress newlines between args")
|
||||
c.flags.BoolVar(&c.rawInput, "r", false, "Suppress wrapping the input with {{ }} delimiters")
|
||||
}
|
||||
|
||||
// Run executes this command.
|
||||
func (c *EvalCommand) Run(args []string) int {
|
||||
if len(args) == 0 {
|
||||
c.Ui.Error(c.Help())
|
||||
return 1
|
||||
}
|
||||
|
||||
c.InitOpts()
|
||||
tmpls, err := c.parseOpts(args)
|
||||
if err != nil {
|
||||
if errwrap.Contains(err, "flag: help requested") {
|
||||
return 0
|
||||
}
|
||||
return 1
|
||||
}
|
||||
inputs, outputs := make([]string, len(tmpls)), make([]string, len(tmpls))
|
||||
var rawInput, readStdin bool
|
||||
for i, in := range tmpls {
|
||||
if readStdin {
|
||||
break
|
||||
}
|
||||
|
||||
rawInput = c.rawInput
|
||||
if in == "-" {
|
||||
rawInput = true
|
||||
var f io.Reader = os.Stdin
|
||||
var buf bytes.Buffer
|
||||
if _, err := io.Copy(&buf, f); err != nil {
|
||||
c.Ui.Error(fmt.Sprintf("[ERROR]: Error reading from stdin: %v", err))
|
||||
return 1
|
||||
}
|
||||
in = buf.String()
|
||||
if len(in) == 0 {
|
||||
return 0
|
||||
}
|
||||
readStdin = true
|
||||
}
|
||||
inputs[i] = in
|
||||
|
||||
if !rawInput {
|
||||
in = `{{` + in + `}}`
|
||||
inputs[i] = in
|
||||
}
|
||||
|
||||
out, err := template.Parse(in)
|
||||
if err != nil {
|
||||
c.Ui.Error(fmt.Sprintf("ERROR[%d] in: %q\n[%d] msg: %v\n", i, in, i, err))
|
||||
return 1
|
||||
}
|
||||
outputs[i] = out
|
||||
}
|
||||
|
||||
if c.debugOutput {
|
||||
for i, out := range outputs {
|
||||
c.Ui.Output(fmt.Sprintf("[%d] in: %q\n[%d] out: %q\n", i, inputs[i], i, out))
|
||||
if i != len(outputs)-1 {
|
||||
if c.debugOutput {
|
||||
c.Ui.Output(fmt.Sprintf("---\n"))
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sep := "\n"
|
||||
if c.suppressNewline {
|
||||
sep = ""
|
||||
}
|
||||
c.Ui.Output(strings.Join(outputs, sep))
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
// Synopsis returns a terse description used when listing sub-commands.
|
||||
func (c *EvalCommand) Synopsis() string {
|
||||
return `Evaluates a sockaddr template`
|
||||
}
|
||||
|
||||
// Usage is the one-line usage description
|
||||
func (c *EvalCommand) Usage() string {
|
||||
return `sockaddr eval [options] [template ...]`
|
||||
}
|
||||
|
||||
// VisitAllFlags forwards the visitor function to the FlagSet
|
||||
func (c *EvalCommand) VisitAllFlags(fn func(*flag.Flag)) {
|
||||
c.flags.VisitAll(fn)
|
||||
}
|
||||
|
||||
// parseOpts is responsible for parsing the options set in InitOpts(). Returns
|
||||
// a list of non-parsed flags.
|
||||
func (c *EvalCommand) parseOpts(args []string) ([]string, error) {
|
||||
if err := c.flags.Parse(args); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return c.flags.Args(), nil
|
||||
}
|
||||
17
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/command/multi_arg.go
сгенерированный
поставляемый
17
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/command/multi_arg.go
сгенерированный
поставляемый
@@ -1,17 +0,0 @@
|
||||
package command
|
||||
|
||||
import "regexp"
|
||||
|
||||
type MultiArg []string
|
||||
|
||||
func (v *MultiArg) String() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (v *MultiArg) Set(raw string) error {
|
||||
parts := regexp.MustCompile(`[\s]*,[\s]*`).Split(raw, -1)
|
||||
for _, part := range parts {
|
||||
*v = append(*v, part)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
121
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/command/rfc.go
сгенерированный
поставляемый
121
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/command/rfc.go
сгенерированный
поставляемый
@@ -1,121 +0,0 @@
|
||||
package command
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/hashicorp/errwrap"
|
||||
sockaddr "github.com/hashicorp/go-sockaddr"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
|
||||
type RFCCommand struct {
|
||||
Ui cli.Ui
|
||||
|
||||
// flags is a list of options belonging to this command
|
||||
flags *flag.FlagSet
|
||||
|
||||
// silentMode prevents any output and only returns exit code 1 when the
|
||||
// IP address is NOT a member of the known RFC. Unknown RFCs return a
|
||||
// status code of 2.
|
||||
silentMode bool
|
||||
}
|
||||
|
||||
// Description is the long-form command help.
|
||||
func (c *RFCCommand) Description() string {
|
||||
return `Tests a given IP address to see if it is part of a known RFC. If the IP address belongs to a known RFC, return exit code 0 and print the status. If the IP does not belong to an RFC, return 1. If the RFC is not known, return 2.`
|
||||
}
|
||||
|
||||
// Help returns the full help output expected by `sockaddr -h cmd`
|
||||
func (c *RFCCommand) Help() string {
|
||||
return MakeHelp(c)
|
||||
}
|
||||
|
||||
// InitOpts is responsible for setup of this command's configuration via the
|
||||
// command line. InitOpts() does not parse the arguments (see parseOpts()).
|
||||
func (c *RFCCommand) InitOpts() {
|
||||
c.flags = flag.NewFlagSet("rfc", flag.ContinueOnError)
|
||||
c.flags.Usage = func() { c.Ui.Output(c.Help()) }
|
||||
c.flags.BoolVar(&c.silentMode, "s", false, "Silent, only return different exit codes")
|
||||
}
|
||||
|
||||
// Run executes this command.
|
||||
func (c *RFCCommand) Run(args []string) int {
|
||||
if len(args) == 0 {
|
||||
c.Ui.Error(c.Help())
|
||||
return 1
|
||||
}
|
||||
|
||||
c.InitOpts()
|
||||
unprocessedArgs, err := c.parseOpts(args)
|
||||
if err != nil {
|
||||
if errwrap.Contains(err, "flag: help requested") {
|
||||
return 0
|
||||
}
|
||||
return 1
|
||||
}
|
||||
|
||||
switch numArgs := len(unprocessedArgs); {
|
||||
case numArgs != 2 && numArgs != 0:
|
||||
c.Ui.Error(`ERROR: Need an RFC Number and an IP address to test.`)
|
||||
c.Ui.Error(c.Help())
|
||||
fallthrough
|
||||
case numArgs == 0:
|
||||
return 1
|
||||
}
|
||||
|
||||
// Parse the RFC Number
|
||||
rfcNum, err := strconv.ParseUint(unprocessedArgs[0], 10, 32)
|
||||
if err != nil {
|
||||
c.Ui.Error(fmt.Sprintf("ERROR: Invalid RFC Number %+q: %v", unprocessedArgs[0], err))
|
||||
return 2
|
||||
}
|
||||
|
||||
// Parse the IP address
|
||||
ipAddr, err := sockaddr.NewIPAddr(unprocessedArgs[1])
|
||||
if err != nil {
|
||||
c.Ui.Error(fmt.Sprintf("ERROR: Invalid IP address %+q: %v", unprocessedArgs[1], err))
|
||||
return 3
|
||||
}
|
||||
|
||||
switch inRFC := sockaddr.IsRFC(uint(rfcNum), ipAddr); {
|
||||
case inRFC && !c.silentMode:
|
||||
c.Ui.Output(fmt.Sprintf("%s is part of RFC %d", ipAddr, rfcNum))
|
||||
fallthrough
|
||||
case inRFC:
|
||||
return 0
|
||||
case !inRFC && !c.silentMode:
|
||||
c.Ui.Output(fmt.Sprintf("%s is not part of RFC %d", ipAddr, rfcNum))
|
||||
fallthrough
|
||||
case !inRFC:
|
||||
return 1
|
||||
default:
|
||||
panic("bad")
|
||||
}
|
||||
}
|
||||
|
||||
// Synopsis returns a terse description used when listing sub-commands.
|
||||
func (c *RFCCommand) Synopsis() string {
|
||||
return `Test to see if an IP is part of a known RFC`
|
||||
}
|
||||
|
||||
// Usage is the one-line usage description
|
||||
func (c *RFCCommand) Usage() string {
|
||||
return `sockaddr rfc [RFC Number] [IP Address]`
|
||||
}
|
||||
|
||||
// VisitAllFlags forwards the visitor function to the FlagSet
|
||||
func (c *RFCCommand) VisitAllFlags(fn func(*flag.Flag)) {
|
||||
c.flags.VisitAll(fn)
|
||||
}
|
||||
|
||||
// parseOpts is responsible for parsing the options set in InitOpts(). Returns
|
||||
// a list of non-parsed flags.
|
||||
func (c *RFCCommand) parseOpts(args []string) ([]string, error) {
|
||||
if err := c.flags.Parse(args); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return c.flags.Args(), nil
|
||||
}
|
||||
94
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/command/rfc_list.go
сгенерированный
поставляемый
94
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/command/rfc_list.go
сгенерированный
поставляемый
@@ -1,94 +0,0 @@
|
||||
package command
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"sort"
|
||||
|
||||
"github.com/hashicorp/errwrap"
|
||||
sockaddr "github.com/hashicorp/go-sockaddr"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
|
||||
type RFCListCommand struct {
|
||||
Ui cli.Ui
|
||||
|
||||
// flags is a list of options belonging to this command
|
||||
flags *flag.FlagSet
|
||||
}
|
||||
|
||||
// Description is the long-form command help.
|
||||
func (c *RFCListCommand) Description() string {
|
||||
return `Lists all known RFCs.`
|
||||
}
|
||||
|
||||
// Help returns the full help output expected by `sockaddr -h cmd`
|
||||
func (c *RFCListCommand) Help() string {
|
||||
return MakeHelp(c)
|
||||
}
|
||||
|
||||
// InitOpts is responsible for setup of this command's configuration via the
|
||||
// command line. InitOpts() does not parse the arguments (see parseOpts()).
|
||||
func (c *RFCListCommand) InitOpts() {
|
||||
c.flags = flag.NewFlagSet("list", flag.ContinueOnError)
|
||||
c.flags.Usage = func() { c.Ui.Output(c.Help()) }
|
||||
}
|
||||
|
||||
type rfcNums []uint
|
||||
|
||||
func (s rfcNums) Len() int { return len(s) }
|
||||
func (s rfcNums) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
|
||||
func (s rfcNums) Less(i, j int) bool { return s[i] < s[j] }
|
||||
|
||||
// Run executes this command.
|
||||
func (c *RFCListCommand) Run(args []string) int {
|
||||
if len(args) != 0 {
|
||||
c.Ui.Error(c.Help())
|
||||
return 1
|
||||
}
|
||||
|
||||
c.InitOpts()
|
||||
_, err := c.parseOpts(args)
|
||||
if err != nil {
|
||||
if errwrap.Contains(err, "flag: help requested") {
|
||||
return 0
|
||||
}
|
||||
return 1
|
||||
}
|
||||
|
||||
var rfcs rfcNums
|
||||
sockaddr.VisitAllRFCs(func(rfcNum uint, sas sockaddr.SockAddrs) {
|
||||
rfcs = append(rfcs, rfcNum)
|
||||
})
|
||||
|
||||
sort.Sort(rfcs)
|
||||
|
||||
for _, rfcNum := range rfcs {
|
||||
c.Ui.Output(fmt.Sprintf("%d", rfcNum))
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
// Synopsis returns a terse description used when listing sub-commands.
|
||||
func (c *RFCListCommand) Synopsis() string {
|
||||
return `Lists all known RFCs`
|
||||
}
|
||||
|
||||
// Usage is the one-line usage description
|
||||
func (c *RFCListCommand) Usage() string {
|
||||
return `sockaddr rfc list`
|
||||
}
|
||||
|
||||
// VisitAllFlags forwards the visitor function to the FlagSet
|
||||
func (c *RFCListCommand) VisitAllFlags(fn func(*flag.Flag)) {
|
||||
c.flags.VisitAll(fn)
|
||||
}
|
||||
|
||||
func (c *RFCListCommand) parseOpts(args []string) ([]string, error) {
|
||||
if err := c.flags.Parse(args); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return c.flags.Args(), nil
|
||||
}
|
||||
216
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/command/tech_support.go
сгенерированный
поставляемый
216
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/command/tech_support.go
сгенерированный
поставляемый
@@ -1,216 +0,0 @@
|
||||
package command
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"net"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
|
||||
"github.com/hashicorp/errwrap"
|
||||
sockaddr "github.com/hashicorp/go-sockaddr"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
|
||||
type TechSupportCommand struct {
|
||||
Ui cli.Ui
|
||||
|
||||
// outputMode controls the type of output encoding.
|
||||
outputMode string
|
||||
|
||||
// flags is a list of options belonging to this command
|
||||
flags *flag.FlagSet
|
||||
}
|
||||
|
||||
// Description is the long-form command help.
|
||||
func (c *TechSupportCommand) Description() string {
|
||||
return `Print out network diagnostic information that can be used by support.
|
||||
|
||||
` + "The `sockaddr` library relies on OS-specific commands and output which can potentially be " +
|
||||
"brittle. The `tech-support` subcommand emits all of the platform-specific " +
|
||||
"network details required to debug why a given `sockaddr` API call is behaving " +
|
||||
"differently than expected. The `-output` flag controls the output format. " +
|
||||
"The default output mode is Markdown (`md`) however a raw mode (`raw`) is " +
|
||||
"available to obtain the original output."
|
||||
}
|
||||
|
||||
// Help returns the full help output expected by `sockaddr -h cmd`
|
||||
func (c *TechSupportCommand) Help() string {
|
||||
return MakeHelp(c)
|
||||
}
|
||||
|
||||
// InitOpts is responsible for setup of this command's configuration via the
|
||||
// command line. InitOpts() does not parse the arguments (see parseOpts()).
|
||||
func (c *TechSupportCommand) InitOpts() {
|
||||
c.flags = flag.NewFlagSet("tech-support", flag.ContinueOnError)
|
||||
c.flags.Usage = func() { c.Ui.Output(c.Help()) }
|
||||
c.flags.StringVar(&c.outputMode, "output", "md", `Encode the output using one of Markdown ("md") or Raw ("raw")`)
|
||||
}
|
||||
|
||||
// Run executes this command.
|
||||
func (c *TechSupportCommand) Run(args []string) int {
|
||||
c.InitOpts()
|
||||
rest, err := c.parseOpts(args)
|
||||
if err != nil {
|
||||
if errwrap.Contains(err, "flag: help requested") {
|
||||
return 0
|
||||
}
|
||||
return 1
|
||||
}
|
||||
if len(rest) != 0 {
|
||||
c.Ui.Error(c.Help())
|
||||
return 1
|
||||
}
|
||||
|
||||
ri, err := sockaddr.NewRouteInfo()
|
||||
if err != nil {
|
||||
c.Ui.Error(fmt.Sprintf("error loading route information: %v", err))
|
||||
return 1
|
||||
}
|
||||
|
||||
const initNumCmds = 4
|
||||
type cmdResult struct {
|
||||
cmd []string
|
||||
out string
|
||||
}
|
||||
output := make(map[string]cmdResult, initNumCmds)
|
||||
ri.VisitCommands(func(name string, cmd []string) {
|
||||
out, err := exec.Command(cmd[0], cmd[1:]...).Output()
|
||||
if err != nil {
|
||||
out = []byte(fmt.Sprintf("ERROR: command %q failed: %v", name, err))
|
||||
}
|
||||
|
||||
output[name] = cmdResult{
|
||||
cmd: cmd,
|
||||
out: string(out),
|
||||
}
|
||||
})
|
||||
|
||||
out := c.rowWriterOutputFactory()
|
||||
|
||||
for cmdName, result := range output {
|
||||
switch c.outputMode {
|
||||
case "md":
|
||||
c.Ui.Output(fmt.Sprintf("## cmd: `%s`", cmdName))
|
||||
c.Ui.Output("")
|
||||
c.Ui.Output(fmt.Sprintf("Command: `%#v`", result.cmd))
|
||||
c.Ui.Output("```")
|
||||
c.Ui.Output(result.out)
|
||||
c.Ui.Output("```")
|
||||
c.Ui.Output("")
|
||||
case "raw":
|
||||
c.Ui.Output(fmt.Sprintf("cmd: %q: %#v", cmdName, result.cmd))
|
||||
c.Ui.Output("")
|
||||
c.Ui.Output(result.out)
|
||||
c.Ui.Output("")
|
||||
default:
|
||||
c.Ui.Error(fmt.Sprintf("Unsupported output type: %q", c.outputMode))
|
||||
return 1
|
||||
}
|
||||
|
||||
out("s", "GOOS", runtime.GOOS)
|
||||
out("s", "GOARCH", runtime.GOARCH)
|
||||
out("s", "Compiler", runtime.Compiler)
|
||||
out("s", "Version", runtime.Version())
|
||||
ifs, err := net.Interfaces()
|
||||
if err != nil {
|
||||
out("v", "net.Interfaces", err)
|
||||
} else {
|
||||
for i, intf := range ifs {
|
||||
out("s", fmt.Sprintf("net.Interfaces[%d].Name", i), intf.Name)
|
||||
out("s", fmt.Sprintf("net.Interfaces[%d].Flags", i), intf.Flags)
|
||||
out("+v", fmt.Sprintf("net.Interfaces[%d].Raw", i), intf)
|
||||
addrs, err := intf.Addrs()
|
||||
if err != nil {
|
||||
out("v", fmt.Sprintf("net.Interfaces[%d].Addrs", i), err)
|
||||
} else {
|
||||
for j, addr := range addrs {
|
||||
out("s", fmt.Sprintf("net.Interfaces[%d].Addrs[%d]", i, j), addr)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
// Synopsis returns a terse description used when listing sub-commands.
|
||||
func (c *TechSupportCommand) Synopsis() string {
|
||||
return `Dumps diagnostic information about a platform's network`
|
||||
}
|
||||
|
||||
// Usage is the one-line usage description
|
||||
func (c *TechSupportCommand) Usage() string {
|
||||
return `sockaddr tech-support [options]`
|
||||
}
|
||||
|
||||
// VisitAllFlags forwards the visitor function to the FlagSet
|
||||
func (c *TechSupportCommand) VisitAllFlags(fn func(*flag.Flag)) {
|
||||
c.flags.VisitAll(fn)
|
||||
}
|
||||
|
||||
// parseOpts is responsible for parsing the options set in InitOpts(). Returns
|
||||
// a list of non-parsed flags.
|
||||
func (c *TechSupportCommand) parseOpts(args []string) ([]string, error) {
|
||||
if err := c.flags.Parse(args); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
switch c.outputMode {
|
||||
case "md", "markdown":
|
||||
c.outputMode = "md"
|
||||
case "raw":
|
||||
default:
|
||||
return nil, fmt.Errorf(`Invalid output mode %q, supported output types are "md" (default) and "raw"`, c.outputMode)
|
||||
}
|
||||
return c.flags.Args(), nil
|
||||
}
|
||||
|
||||
func (c *TechSupportCommand) rowWriterOutputFactory() func(valueVerb, key string, val interface{}) {
|
||||
type _Fmt string
|
||||
type _Verb string
|
||||
var lineNoFmt string
|
||||
var keyVerb _Verb
|
||||
var fmtMap map[_Verb]_Fmt
|
||||
switch c.outputMode {
|
||||
case "md":
|
||||
lineNoFmt = "%02d."
|
||||
keyVerb = "s"
|
||||
fmtMap = map[_Verb]_Fmt{
|
||||
"s": "`%s`",
|
||||
"-s": "%s",
|
||||
"v": "`%v`",
|
||||
"+v": "`%#v`",
|
||||
}
|
||||
case "raw":
|
||||
lineNoFmt = "%02d:"
|
||||
keyVerb = "-s"
|
||||
fmtMap = map[_Verb]_Fmt{
|
||||
"s": "%q",
|
||||
"-s": "%s",
|
||||
"v": "%v",
|
||||
"+v": "%#v",
|
||||
}
|
||||
default:
|
||||
panic(fmt.Sprintf("Unsupported output type: %q", c.outputMode))
|
||||
}
|
||||
|
||||
var count int
|
||||
return func(valueVerb, key string, val interface{}) {
|
||||
count++
|
||||
|
||||
keyFmt, ok := fmtMap[keyVerb]
|
||||
if !ok {
|
||||
panic(fmt.Sprintf("Invalid key verb: %q", keyVerb))
|
||||
}
|
||||
|
||||
valFmt, ok := fmtMap[_Verb(valueVerb)]
|
||||
if !ok {
|
||||
panic(fmt.Sprintf("Invalid value verb: %q", valueVerb))
|
||||
}
|
||||
|
||||
outputModeFmt := fmt.Sprintf("%s %s:\t%s", lineNoFmt, keyFmt, valFmt)
|
||||
c.Ui.Output(fmt.Sprintf(outputModeFmt, count, key, val))
|
||||
}
|
||||
}
|
||||
27
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/command/version.go
сгенерированный
поставляемый
27
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/command/version.go
сгенерированный
поставляемый
@@ -1,27 +0,0 @@
|
||||
package command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
|
||||
// VersionCommand is a Command implementation prints the version.
|
||||
type VersionCommand struct {
|
||||
HumanVersion string
|
||||
Ui cli.Ui
|
||||
}
|
||||
|
||||
func (c *VersionCommand) Help() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (c *VersionCommand) Run(_ []string) int {
|
||||
c.Ui.Output(fmt.Sprintf("sockaddr %s", c.HumanVersion))
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
func (c *VersionCommand) Synopsis() string {
|
||||
return "Prints the sockaddr version"
|
||||
}
|
||||
49
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/commands.go
сгенерированный
поставляемый
49
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/commands.go
сгенерированный
поставляемый
@@ -1,49 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/hashicorp/go-sockaddr/cmd/sockaddr/command"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
|
||||
// Commands is the mapping of all the available CLI commands.
|
||||
var Commands map[string]cli.CommandFactory
|
||||
|
||||
func init() {
|
||||
ui := &cli.BasicUi{Writer: os.Stdout}
|
||||
|
||||
Commands = map[string]cli.CommandFactory{
|
||||
"dump": func() (cli.Command, error) {
|
||||
return &command.DumpCommand{
|
||||
Ui: ui,
|
||||
}, nil
|
||||
},
|
||||
"eval": func() (cli.Command, error) {
|
||||
return &command.EvalCommand{
|
||||
Ui: ui,
|
||||
}, nil
|
||||
},
|
||||
"rfc": func() (cli.Command, error) {
|
||||
return &command.RFCCommand{
|
||||
Ui: ui,
|
||||
}, nil
|
||||
},
|
||||
"rfc list": func() (cli.Command, error) {
|
||||
return &command.RFCListCommand{
|
||||
Ui: ui,
|
||||
}, nil
|
||||
},
|
||||
"tech-support": func() (cli.Command, error) {
|
||||
return &command.TechSupportCommand{
|
||||
Ui: ui,
|
||||
}, nil
|
||||
},
|
||||
"version": func() (cli.Command, error) {
|
||||
return &command.VersionCommand{
|
||||
HumanVersion: GetHumanVersion(),
|
||||
Ui: ui,
|
||||
}, nil
|
||||
},
|
||||
}
|
||||
}
|
||||
47
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/main.go
сгенерированный
поставляемый
47
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/main.go
сгенерированный
поставляемый
@@ -1,47 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
|
||||
func main() {
|
||||
os.Exit(realMain())
|
||||
}
|
||||
|
||||
func realMain() int {
|
||||
log.SetOutput(ioutil.Discard)
|
||||
|
||||
// Get the command line args. We shortcut "--version" and "-v" to just
|
||||
// show the version.
|
||||
args := os.Args[1:]
|
||||
for _, arg := range args {
|
||||
if arg == "--" {
|
||||
break
|
||||
}
|
||||
if arg == "-v" || arg == "--version" {
|
||||
newArgs := make([]string, len(args)+1)
|
||||
newArgs[0] = "version"
|
||||
copy(newArgs[1:], args)
|
||||
args = newArgs
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
cli := &cli.CLI{
|
||||
Args: args,
|
||||
Commands: Commands,
|
||||
HelpFunc: cli.BasicHelpFunc("sockaddr"),
|
||||
}
|
||||
exitCode, err := cli.Run()
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error executing CLI: %s\n", err.Error())
|
||||
return 1
|
||||
}
|
||||
|
||||
return exitCode
|
||||
}
|
||||
1
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/.gitignore
сгенерированный
поставляемый
1
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/.gitignore
сгенерированный
поставляемый
@@ -1 +0,0 @@
|
||||
/*.diff
|
||||
10
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/GNUmakefile
сгенерированный
поставляемый
10
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/GNUmakefile
сгенерированный
поставляемый
@@ -1,10 +0,0 @@
|
||||
.DEFAULT_GOAL := test
|
||||
|
||||
clean::
|
||||
rm -f *.diff *.out
|
||||
|
||||
test::
|
||||
@rm -f *.diff
|
||||
@./run_all.sh
|
||||
@printf "All tests ran successfully.\n"
|
||||
|
||||
9
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr.out
сгенерированный
поставляемый
9
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr.out
сгенерированный
поставляемый
@@ -1,9 +0,0 @@
|
||||
Usage: sockaddr [--version] [--help] <command> [<args>]
|
||||
|
||||
Available commands are:
|
||||
dump Parses input as an IP or interface name(s) and dumps various information
|
||||
eval Evaluates a sockaddr template
|
||||
rfc Test to see if an IP is part of a known RFC
|
||||
tech-support Dumps diagnostic information about a platform's network
|
||||
version Prints the sockaddr version
|
||||
|
||||
1
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_-v.out
сгенерированный
поставляемый
1
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_-v.out
сгенерированный
поставляемый
@@ -1 +0,0 @@
|
||||
sockaddr 0.1.0-dev
|
||||
14
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_dump-00-help.out
сгенерированный
поставляемый
14
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_dump-00-help.out
сгенерированный
поставляемый
@@ -1,14 +0,0 @@
|
||||
Usage: sockaddr dump [options] input [...]
|
||||
|
||||
Parse address(es) or interface and dumps various output.
|
||||
|
||||
Options:
|
||||
|
||||
-4 Parse the input as IPv4 only
|
||||
-6 Parse the input as IPv6 only
|
||||
-H Machine readable output
|
||||
-I Parse the argument as an interface name
|
||||
-i Parse the input as IP address (either IPv4 or IPv6)
|
||||
-n Show only the value
|
||||
-o Name of an attribute to pass through
|
||||
-u Parse the input as a UNIX Socket only
|
||||
21
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_dump-01.out
сгенерированный
поставляемый
21
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_dump-01.out
сгенерированный
поставляемый
@@ -1,21 +0,0 @@
|
||||
Attribute Value
|
||||
type IPv4
|
||||
string 127.0.0.1
|
||||
host 127.0.0.1
|
||||
address 127.0.0.1
|
||||
port 0
|
||||
netmask 255.255.255.255
|
||||
network 127.0.0.1
|
||||
mask_bits 32
|
||||
binary 01111111000000000000000000000001
|
||||
hex 7f000001
|
||||
first_usable 127.0.0.1
|
||||
last_usable 127.0.0.1
|
||||
octets 127 0 0 1
|
||||
size 1
|
||||
broadcast 127.0.0.1
|
||||
uint32 2130706433
|
||||
DialPacket "udp4" ""
|
||||
DialStream "tcp4" ""
|
||||
ListenPacket "udp4" "127.0.0.1:0"
|
||||
ListenStream "tcp4" "127.0.0.1:0"
|
||||
21
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_dump-02.out
сгенерированный
поставляемый
21
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_dump-02.out
сгенерированный
поставляемый
@@ -1,21 +0,0 @@
|
||||
Attribute Value
|
||||
type IPv4
|
||||
string 127.0.0.2/8
|
||||
host 127.0.0.2
|
||||
address 127.0.0.2
|
||||
port 0
|
||||
netmask 255.0.0.0
|
||||
network 127.0.0.0
|
||||
mask_bits 8
|
||||
binary 01111111000000000000000000000010
|
||||
hex 7f000002
|
||||
first_usable 127.0.0.1
|
||||
last_usable 127.255.255.254
|
||||
octets 127 0 0 2
|
||||
size 16777216
|
||||
broadcast 127.255.255.255
|
||||
uint32 2130706434
|
||||
DialPacket "udp4" ""
|
||||
DialStream "tcp4" ""
|
||||
ListenPacket "udp4" ""
|
||||
ListenStream "tcp4" ""
|
||||
20
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_dump-03.out
сгенерированный
поставляемый
20
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_dump-03.out
сгенерированный
поставляемый
@@ -1,20 +0,0 @@
|
||||
Attribute Value
|
||||
type IPv6
|
||||
string 2001:db8::3
|
||||
host 2001:db8::3
|
||||
address 2001:db8::3
|
||||
port 0
|
||||
netmask ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
|
||||
network 2001:db8::3
|
||||
mask_bits 128
|
||||
binary 00100000000000010000110110111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011
|
||||
hex 20010db8000000000000000000000003
|
||||
first_usable 2001:db8::3
|
||||
last_usable 2001:db8::3
|
||||
octets 32 1 13 184 0 0 0 0 0 0 0 0 0 0 0 3
|
||||
size 1
|
||||
uint128 42540766411282592856903984951653826563
|
||||
DialPacket "udp6" ""
|
||||
DialStream "tcp6" ""
|
||||
ListenPacket "udp6" "[2001:db8::3]:0"
|
||||
ListenStream "tcp6" "[2001:db8::3]:0"
|
||||
20
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_dump-04.out
сгенерированный
поставляемый
20
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_dump-04.out
сгенерированный
поставляемый
@@ -1,20 +0,0 @@
|
||||
Attribute Value
|
||||
type IPv6
|
||||
string 2001:db8::4/64
|
||||
host 2001:db8::4
|
||||
address 2001:db8::4
|
||||
port 0
|
||||
netmask ffff:ffff:ffff:ffff::
|
||||
network 2001:db8::
|
||||
mask_bits 64
|
||||
binary 00100000000000010000110110111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100
|
||||
hex 20010db8000000000000000000000004
|
||||
first_usable 2001:db8::
|
||||
last_usable 2001:db8::ffff:ffff:ffff:ffff
|
||||
octets 32 1 13 184 0 0 0 0 0 0 0 0 0 0 0 4
|
||||
size 18446744073709551616
|
||||
uint128 42540766411282592856903984951653826564
|
||||
DialPacket "udp6" ""
|
||||
DialStream "tcp6" ""
|
||||
ListenPacket "udp6" ""
|
||||
ListenStream "tcp6" ""
|
||||
8
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_dump-05.out
сгенерированный
поставляемый
8
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_dump-05.out
сгенерированный
поставляемый
@@ -1,8 +0,0 @@
|
||||
Attribute Value
|
||||
type UNIX
|
||||
string "/tmp/example"
|
||||
path /tmp/example
|
||||
DialPacket "unixgram" "/tmp/example"
|
||||
DialStream "unix" "/tmp/example"
|
||||
ListenPacket "unixgram" "/tmp/example"
|
||||
ListenStream "unix" "/tmp/example"
|
||||
20
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_dump-06.out
сгенерированный
поставляемый
20
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_dump-06.out
сгенерированный
поставляемый
@@ -1,20 +0,0 @@
|
||||
Attribute Value
|
||||
type IPv6
|
||||
string [2001:db8::6]:22
|
||||
host [2001:db8::6]:22
|
||||
address 2001:db8::6
|
||||
port 22
|
||||
netmask ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
|
||||
network 2001:db8::6
|
||||
mask_bits 128
|
||||
binary 00100000000000010000110110111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000110
|
||||
hex 20010db8000000000000000000000006
|
||||
first_usable 2001:db8::6
|
||||
last_usable 2001:db8::6
|
||||
octets 32 1 13 184 0 0 0 0 0 0 0 0 0 0 0 6
|
||||
size 1
|
||||
uint128 42540766411282592856903984951653826566
|
||||
DialPacket "udp6" "[2001:db8::6]:22"
|
||||
DialStream "tcp6" "[2001:db8::6]:22"
|
||||
ListenPacket "udp6" "[2001:db8::6]:22"
|
||||
ListenStream "tcp6" "[2001:db8::6]:22"
|
||||
19
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_dump-07.out
сгенерированный
поставляемый
19
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_dump-07.out
сгенерированный
поставляемый
@@ -1,19 +0,0 @@
|
||||
type IPv6
|
||||
string [2001:db8::7]:22
|
||||
host [2001:db8::7]:22
|
||||
address 2001:db8::7
|
||||
port 22
|
||||
netmask ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
|
||||
network 2001:db8::7
|
||||
mask_bits 128
|
||||
binary 00100000000000010000110110111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111
|
||||
hex 20010db8000000000000000000000007
|
||||
first_usable 2001:db8::7
|
||||
last_usable 2001:db8::7
|
||||
octets 32 1 13 184 0 0 0 0 0 0 0 0 0 0 0 7
|
||||
size 1
|
||||
uint128 42540766411282592856903984951653826567
|
||||
DialPacket "udp6" "[2001:db8::7]:22"
|
||||
DialStream "tcp6" "[2001:db8::7]:22"
|
||||
ListenPacket "udp6" "[2001:db8::7]:22"
|
||||
ListenStream "tcp6" "[2001:db8::7]:22"
|
||||
3
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_dump-08.out
сгенерированный
поставляемый
3
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_dump-08.out
сгенерированный
поставляемый
@@ -1,3 +0,0 @@
|
||||
Attribute Value
|
||||
type IPv6
|
||||
string [2001:db8::8]:22
|
||||
3
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_dump-09.out
сгенерированный
поставляемый
3
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_dump-09.out
сгенерированный
поставляемый
@@ -1,3 +0,0 @@
|
||||
Value
|
||||
IPv6
|
||||
[2001:db8::8]:22
|
||||
2
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_dump-10.out
сгенерированный
поставляемый
2
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_dump-10.out
сгенерированный
поставляемый
@@ -1,2 +0,0 @@
|
||||
IPv6
|
||||
[2001:db8::8]:22
|
||||
63
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_dump-11.out
сгенерированный
поставляемый
63
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_dump-11.out
сгенерированный
поставляемый
@@ -1,63 +0,0 @@
|
||||
Attribute Value
|
||||
type IPv4
|
||||
string 192.168.0.1
|
||||
host 192.168.0.1
|
||||
address 192.168.0.1
|
||||
port 0
|
||||
netmask 255.255.255.255
|
||||
network 192.168.0.1
|
||||
mask_bits 32
|
||||
binary 11000000101010000000000000000001
|
||||
hex c0a80001
|
||||
first_usable 192.168.0.1
|
||||
last_usable 192.168.0.1
|
||||
octets 192 168 0 1
|
||||
size 1
|
||||
broadcast 192.168.0.1
|
||||
uint32 3232235521
|
||||
DialPacket "udp4" ""
|
||||
DialStream "tcp4" ""
|
||||
ListenPacket "udp4" "192.168.0.1:0"
|
||||
ListenStream "tcp4" "192.168.0.1:0"
|
||||
Attribute Value
|
||||
type IPv4
|
||||
string 192.168.0.1
|
||||
host 192.168.0.1
|
||||
address 192.168.0.1
|
||||
port 0
|
||||
netmask 255.255.255.255
|
||||
network 192.168.0.1
|
||||
mask_bits 32
|
||||
binary 11000000101010000000000000000001
|
||||
hex c0a80001
|
||||
first_usable 192.168.0.1
|
||||
last_usable 192.168.0.1
|
||||
octets 192 168 0 1
|
||||
size 1
|
||||
broadcast 192.168.0.1
|
||||
uint32 3232235521
|
||||
DialPacket "udp4" ""
|
||||
DialStream "tcp4" ""
|
||||
ListenPacket "udp4" "192.168.0.1:0"
|
||||
ListenStream "tcp4" "192.168.0.1:0"
|
||||
Attribute Value
|
||||
type IPv4
|
||||
string 192.168.0.1
|
||||
host 192.168.0.1
|
||||
address 192.168.0.1
|
||||
port 0
|
||||
netmask 255.255.255.255
|
||||
network 192.168.0.1
|
||||
mask_bits 32
|
||||
binary 11000000101010000000000000000001
|
||||
hex c0a80001
|
||||
first_usable 192.168.0.1
|
||||
last_usable 192.168.0.1
|
||||
octets 192 168 0 1
|
||||
size 1
|
||||
broadcast 192.168.0.1
|
||||
uint32 3232235521
|
||||
DialPacket "udp4" ""
|
||||
DialStream "tcp4" ""
|
||||
ListenPacket "udp4" "192.168.0.1:0"
|
||||
ListenStream "tcp4" "192.168.0.1:0"
|
||||
63
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_dump-12.out
сгенерированный
поставляемый
63
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_dump-12.out
сгенерированный
поставляемый
@@ -1,63 +0,0 @@
|
||||
Attribute Value
|
||||
type IPv4
|
||||
string 192.168.0.1/16
|
||||
host 192.168.0.1
|
||||
address 192.168.0.1
|
||||
port 0
|
||||
netmask 255.255.0.0
|
||||
network 192.168.0.0
|
||||
mask_bits 16
|
||||
binary 11000000101010000000000000000001
|
||||
hex c0a80001
|
||||
first_usable 192.168.0.1
|
||||
last_usable 192.168.255.254
|
||||
octets 192 168 0 1
|
||||
size 65536
|
||||
broadcast 192.168.255.255
|
||||
uint32 3232235521
|
||||
DialPacket "udp4" ""
|
||||
DialStream "tcp4" ""
|
||||
ListenPacket "udp4" ""
|
||||
ListenStream "tcp4" ""
|
||||
Attribute Value
|
||||
type IPv4
|
||||
string 192.168.0.1/16
|
||||
host 192.168.0.1
|
||||
address 192.168.0.1
|
||||
port 0
|
||||
netmask 255.255.0.0
|
||||
network 192.168.0.0
|
||||
mask_bits 16
|
||||
binary 11000000101010000000000000000001
|
||||
hex c0a80001
|
||||
first_usable 192.168.0.1
|
||||
last_usable 192.168.255.254
|
||||
octets 192 168 0 1
|
||||
size 65536
|
||||
broadcast 192.168.255.255
|
||||
uint32 3232235521
|
||||
DialPacket "udp4" ""
|
||||
DialStream "tcp4" ""
|
||||
ListenPacket "udp4" ""
|
||||
ListenStream "tcp4" ""
|
||||
Attribute Value
|
||||
type IPv4
|
||||
string 192.168.0.1/16
|
||||
host 192.168.0.1
|
||||
address 192.168.0.1
|
||||
port 0
|
||||
netmask 255.255.0.0
|
||||
network 192.168.0.0
|
||||
mask_bits 16
|
||||
binary 11000000101010000000000000000001
|
||||
hex c0a80001
|
||||
first_usable 192.168.0.1
|
||||
last_usable 192.168.255.254
|
||||
octets 192 168 0 1
|
||||
size 65536
|
||||
broadcast 192.168.255.255
|
||||
uint32 3232235521
|
||||
DialPacket "udp4" ""
|
||||
DialStream "tcp4" ""
|
||||
ListenPacket "udp4" ""
|
||||
ListenStream "tcp4" ""
|
||||
62
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_dump-13.out
сгенерированный
поставляемый
62
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_dump-13.out
сгенерированный
поставляемый
@@ -1,62 +0,0 @@
|
||||
Attribute Value
|
||||
type IPv4
|
||||
string 0.0.0.0/1
|
||||
host 0.0.0.0
|
||||
address 0.0.0.0
|
||||
port 0
|
||||
netmask 128.0.0.0
|
||||
network 0.0.0.0
|
||||
mask_bits 1
|
||||
binary 00000000000000000000000000000000
|
||||
hex 00000000
|
||||
first_usable 0.0.0.1
|
||||
last_usable 127.255.255.254
|
||||
octets 0 0 0 0
|
||||
size 2147483648
|
||||
broadcast 127.255.255.255
|
||||
uint32 0
|
||||
DialPacket "udp4" ""
|
||||
DialStream "tcp4" ""
|
||||
ListenPacket "udp4" ""
|
||||
ListenStream "tcp4" ""
|
||||
Unable to parse "0:0:0:0:0:0::/97": Unable to convert 0:0:0:0:0:0::/97 to an IPv4 address
|
||||
Attribute Value
|
||||
type IPv6
|
||||
string ::/97
|
||||
host ::
|
||||
address ::
|
||||
port 0
|
||||
netmask ffff:ffff:ffff:ffff:ffff:ffff:8000:0
|
||||
network ::
|
||||
mask_bits 97
|
||||
binary 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
hex 00000000000000000000000000000000
|
||||
first_usable ::
|
||||
last_usable ::7fff:ffff
|
||||
octets 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
size 2147483648
|
||||
uint128 0
|
||||
DialPacket "udp6" ""
|
||||
DialStream "tcp6" ""
|
||||
ListenPacket "udp6" ""
|
||||
ListenStream "tcp6" ""
|
||||
Attribute Value
|
||||
type IPv6
|
||||
string ::/97
|
||||
host ::
|
||||
address ::
|
||||
port 0
|
||||
netmask ffff:ffff:ffff:ffff:ffff:ffff:8000:0
|
||||
network ::
|
||||
mask_bits 97
|
||||
binary 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
hex 00000000000000000000000000000000
|
||||
first_usable ::
|
||||
last_usable ::7fff:ffff
|
||||
octets 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
size 2147483648
|
||||
uint128 0
|
||||
DialPacket "udp6" ""
|
||||
DialStream "tcp6" ""
|
||||
ListenPacket "udp6" ""
|
||||
ListenStream "tcp6" ""
|
||||
1
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_dump-14.out
сгенерированный
поставляемый
1
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_dump-14.out
сгенерированный
поставляемый
@@ -1 +0,0 @@
|
||||
Unable to parse "::c0a8:1": Unable to string convert "::c0a8:1" to an IPv4 address
|
||||
19
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_eval-00-help.out
сгенерированный
поставляемый
19
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_eval-00-help.out
сгенерированный
поставляемый
@@ -1,19 +0,0 @@
|
||||
Usage: sockaddr eval [options] [template ...]
|
||||
|
||||
Parse the sockaddr template and evaluates the output.
|
||||
|
||||
The `sockaddr` library has the potential to be very complex,
|
||||
which is why the `sockaddr` command supports an `eval`
|
||||
subcommand in order to test configurations from the command
|
||||
line. The `eval` subcommand automatically wraps its input
|
||||
with the `{{` and `}}` template delimiters unless the `-r`
|
||||
command is specified, in which case `eval` parses the raw
|
||||
input. If the `template` argument passed to `eval` is a
|
||||
dash (`-`), then `sockaddr eval` will read from stdin and
|
||||
automatically sets the `-r` flag.
|
||||
|
||||
Options:
|
||||
|
||||
-d Debug output
|
||||
-n Suppress newlines between args
|
||||
-r Suppress wrapping the input with {{ }} delimiters
|
||||
1
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_eval-01.out
сгенерированный
поставляемый
1
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_eval-01.out
сгенерированный
поставляемый
@@ -1 +0,0 @@
|
||||
[127.0.0.1/8 {1 16384 lo0 up|loopback|multicast} ::1 {1 16384 lo0 up|loopback|multicast} fe80::1/64 {1 16384 lo0 up|loopback|multicast}]
|
||||
2
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_eval-02.out
сгенерированный
поставляемый
2
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_eval-02.out
сгенерированный
поставляемый
@@ -1,2 +0,0 @@
|
||||
[127.0.0.1/8 {1 16384 lo0 up|loopback|multicast} ::1 {1 16384 lo0 up|loopback|multicast} fe80::1/64 {1 16384 lo0 up|loopback|multicast}]
|
||||
[127.0.0.1/8 {1 16384 lo0 up|loopback|multicast} ::1 {1 16384 lo0 up|loopback|multicast} fe80::1/64 {1 16384 lo0 up|loopback|multicast}]
|
||||
1
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_eval-03.out
сгенерированный
поставляемый
1
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_eval-03.out
сгенерированный
поставляемый
@@ -1 +0,0 @@
|
||||
::1 fe80::1
|
||||
2
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_eval-04.out
сгенерированный
поставляемый
2
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_eval-04.out
сгенерированный
поставляемый
@@ -1,2 +0,0 @@
|
||||
[127.0.0.1/8 {1 16384 lo0 up|loopback|multicast} ::1 {1 16384 lo0 up|loopback|multicast} fe80::1/64 {1 16384 lo0 up|loopback|multicast}]
|
||||
|
||||
1
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_eval-05.out
сгенерированный
поставляемый
1
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_eval-05.out
сгенерированный
поставляемый
@@ -1 +0,0 @@
|
||||
up|broadcast|multicast
|
||||
13
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_rfc-00.out
сгенерированный
поставляемый
13
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_rfc-00.out
сгенерированный
поставляемый
@@ -1,13 +0,0 @@
|
||||
Usage: sockaddr rfc [RFC Number] [IP Address]
|
||||
|
||||
Tests a given IP address to see if it is part of a known
|
||||
RFC. If the IP address belongs to a known RFC, return exit
|
||||
code 0 and print the status. If the IP does not belong to
|
||||
an RFC, return 1. If the RFC is not known, return 2.
|
||||
|
||||
Options:
|
||||
|
||||
-s Silent, only return different exit codes
|
||||
|
||||
Subcommands:
|
||||
list Lists all known RFCs
|
||||
13
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_rfc-01.out
сгенерированный
поставляемый
13
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_rfc-01.out
сгенерированный
поставляемый
@@ -1,13 +0,0 @@
|
||||
Usage: sockaddr rfc [RFC Number] [IP Address]
|
||||
|
||||
Tests a given IP address to see if it is part of a known
|
||||
RFC. If the IP address belongs to a known RFC, return exit
|
||||
code 0 and print the status. If the IP does not belong to
|
||||
an RFC, return 1. If the RFC is not known, return 2.
|
||||
|
||||
Options:
|
||||
|
||||
-s Silent, only return different exit codes
|
||||
|
||||
Subcommands:
|
||||
list Lists all known RFCs
|
||||
3
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_rfc_list-00.out
сгенерированный
поставляемый
3
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_rfc_list-00.out
сгенерированный
поставляемый
@@ -1,3 +0,0 @@
|
||||
Usage: sockaddr rfc list
|
||||
|
||||
Lists all known RFCs.
|
||||
28
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_rfc_list-01.out
сгенерированный
поставляемый
28
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_rfc_list-01.out
сгенерированный
поставляемый
@@ -1,28 +0,0 @@
|
||||
919
|
||||
1112
|
||||
1122
|
||||
1918
|
||||
2544
|
||||
2765
|
||||
2928
|
||||
3056
|
||||
3068
|
||||
3171
|
||||
3330
|
||||
3849
|
||||
3927
|
||||
4038
|
||||
4193
|
||||
4291
|
||||
4380
|
||||
4773
|
||||
4843
|
||||
5180
|
||||
5735
|
||||
5737
|
||||
6052
|
||||
6333
|
||||
6598
|
||||
6666
|
||||
6890
|
||||
7335
|
||||
3
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_rfc_list-02.out
сгенерированный
поставляемый
3
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_rfc_list-02.out
сгенерированный
поставляемый
@@ -1,3 +0,0 @@
|
||||
Usage: sockaddr rfc list
|
||||
|
||||
Lists all known RFCs.
|
||||
1
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_version-00.out
сгенерированный
поставляемый
1
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_version-00.out
сгенерированный
поставляемый
@@ -1 +0,0 @@
|
||||
sockaddr 0.1.0-dev
|
||||
1
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_version-01.out
сгенерированный
поставляемый
1
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/expected/sockaddr_version-01.out
сгенерированный
поставляемый
@@ -1 +0,0 @@
|
||||
sockaddr 0.1.0-dev
|
||||
23
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/run_all.sh
сгенерированный
поставляемый
23
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/run_all.sh
сгенерированный
поставляемый
@@ -1,23 +0,0 @@
|
||||
#!/bin/sh --
|
||||
|
||||
FIND=`/usr/bin/which 2> /dev/null gfind find | /usr/bin/grep -v ^no | /usr/bin/head -n 1`
|
||||
XARGS=`/usr/bin/which 2> /dev/null gxargs xargs | /usr/bin/grep -v ^no | /usr/bin/head -n 1`
|
||||
set -e
|
||||
set -u
|
||||
|
||||
num_cpus=$(getconf NPROCESSORS_ONLN)
|
||||
set +e
|
||||
${FIND} . -maxdepth 1 -name 'test_*.sh' -print0 | ${XARGS} -0 -n1 -P${num_cpus} ./run_one.sh
|
||||
set -e
|
||||
|
||||
# rune_one.sh generates the .diff files
|
||||
diffs=$(find . -name '*.diff')
|
||||
if [ -z "${diffs}" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
printf "The following tests failed (check the respective .diff file for details):\n\n"
|
||||
for d in ${diffs}; do
|
||||
printf "\t%s\n" "$(basename ${d} .diff)"
|
||||
done
|
||||
exit 1
|
||||
66
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/run_one.sh
сгенерированный
поставляемый
66
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/run_one.sh
сгенерированный
поставляемый
@@ -1,66 +0,0 @@
|
||||
#!/bin/sh -e -u --
|
||||
|
||||
set -e
|
||||
set -u
|
||||
|
||||
verbose=""
|
||||
if [ "$1" = "-v" ]; then
|
||||
verbose="true"
|
||||
shift
|
||||
fi
|
||||
|
||||
if [ $# -ne 1 ]; then
|
||||
printf "Usage: %s [ test script ]\n\n" "$(basename $0)"
|
||||
printf "ERROR: Need a single test script to execute\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# chdir(2) to the directory where the script resides
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
exact_name="$(basename ${1} .sh)"
|
||||
test_name="$(echo ${exact_name} | sed -e s@^test_@@)"
|
||||
test_script="${exact_name}.sh"
|
||||
test_out="${test_name}.out"
|
||||
expected_out="expected/${test_name}.out"
|
||||
|
||||
if [ ! -r "${test_script}" ]; then
|
||||
printf "ERROR: Test script %s does not exist\n" "${test_script}"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if [ -n "${verbose}" ]; then
|
||||
cat "${test_script}" | tail -n 1
|
||||
fi
|
||||
|
||||
set +e
|
||||
"./${test_script}" > "${test_out}" 2>&1
|
||||
|
||||
if [ ! -r "${expected_out}" ]; then
|
||||
printf "ERROR: Expected test output (%s) does not exist\n" "${expected_out}"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
cmp -s "${expected_out}" "${test_out}"
|
||||
result=$?
|
||||
set -e
|
||||
|
||||
if [ "${result}" -eq 0 ]; then
|
||||
if [ -n "${verbose}" ]; then
|
||||
cat "${test_out}"
|
||||
fi
|
||||
rm -f "${test_out}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
diff_out="${test_name}.diff"
|
||||
set +e
|
||||
diff -u "${test_out}" "${expected_out}" > "${diff_out}"
|
||||
set -e
|
||||
|
||||
# If run as an interactive TTY, pass along the diff to the caller
|
||||
if [ -t 0 -o -n "${verbose}" ]; then
|
||||
cat "${diff_out}"
|
||||
fi
|
||||
|
||||
exit 1
|
||||
5
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr.sh
сгенерированный
поставляемый
5
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr.sh
сгенерированный
поставляемый
@@ -1,5 +0,0 @@
|
||||
#!/bin/sh --
|
||||
|
||||
set -e
|
||||
exec 2>&1
|
||||
exec ../sockaddr
|
||||
5
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_dump-00-help.sh
сгенерированный
поставляемый
5
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_dump-00-help.sh
сгенерированный
поставляемый
@@ -1,5 +0,0 @@
|
||||
#!/bin/sh --
|
||||
|
||||
set -e
|
||||
exec 2>&1
|
||||
exec ../sockaddr dump
|
||||
5
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_dump-01.sh
сгенерированный
поставляемый
5
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_dump-01.sh
сгенерированный
поставляемый
@@ -1,5 +0,0 @@
|
||||
#!/bin/sh --
|
||||
|
||||
set -e
|
||||
exec 2>&1
|
||||
exec ../sockaddr dump 127.0.0.1
|
||||
5
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_dump-02.sh
сгенерированный
поставляемый
5
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_dump-02.sh
сгенерированный
поставляемый
@@ -1,5 +0,0 @@
|
||||
#!/bin/sh --
|
||||
|
||||
set -e
|
||||
exec 2>&1
|
||||
exec ../sockaddr dump 127.0.0.2/8
|
||||
5
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_dump-03.sh
сгенерированный
поставляемый
5
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_dump-03.sh
сгенерированный
поставляемый
@@ -1,5 +0,0 @@
|
||||
#!/bin/sh --
|
||||
|
||||
set -e
|
||||
exec 2>&1
|
||||
exec ../sockaddr dump '[2001:db8::3]'
|
||||
5
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_dump-04.sh
сгенерированный
поставляемый
5
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_dump-04.sh
сгенерированный
поставляемый
@@ -1,5 +0,0 @@
|
||||
#!/bin/sh --
|
||||
|
||||
set -e
|
||||
exec 2>&1
|
||||
exec ../sockaddr dump '2001:db8::4/64'
|
||||
5
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_dump-05.sh
сгенерированный
поставляемый
5
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_dump-05.sh
сгенерированный
поставляемый
@@ -1,5 +0,0 @@
|
||||
#!/bin/sh --
|
||||
|
||||
set -e
|
||||
exec 2>&1
|
||||
exec ../sockaddr dump /tmp/example
|
||||
5
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_dump-06.sh
сгенерированный
поставляемый
5
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_dump-06.sh
сгенерированный
поставляемый
@@ -1,5 +0,0 @@
|
||||
#!/bin/sh --
|
||||
|
||||
set -e
|
||||
exec 2>&1
|
||||
exec ../sockaddr dump '[2001:db8::6]:22'
|
||||
5
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_dump-07.sh
сгенерированный
поставляемый
5
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_dump-07.sh
сгенерированный
поставляемый
@@ -1,5 +0,0 @@
|
||||
#!/bin/sh --
|
||||
|
||||
set -e
|
||||
exec 2>&1
|
||||
exec ../sockaddr dump -H '[2001:db8::7]:22'
|
||||
5
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_dump-08.sh
сгенерированный
поставляемый
5
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_dump-08.sh
сгенерированный
поставляемый
@@ -1,5 +0,0 @@
|
||||
#!/bin/sh --
|
||||
|
||||
set -e
|
||||
exec 2>&1
|
||||
exec ../sockaddr dump -o string,type '[2001:db8::8]:22'
|
||||
5
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_dump-09.sh
сгенерированный
поставляемый
5
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_dump-09.sh
сгенерированный
поставляемый
@@ -1,5 +0,0 @@
|
||||
#!/bin/sh --
|
||||
|
||||
set -e
|
||||
exec 2>&1
|
||||
exec ../sockaddr dump -n -o string,type '[2001:db8::8]:22'
|
||||
5
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_dump-10.sh
сгенерированный
поставляемый
5
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_dump-10.sh
сгенерированный
поставляемый
@@ -1,5 +0,0 @@
|
||||
#!/bin/sh --
|
||||
|
||||
set -e
|
||||
exec 2>&1
|
||||
exec ../sockaddr dump -H -n -o string,type '[2001:db8::8]:22'
|
||||
8
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_dump-11.sh
сгенерированный
поставляемый
8
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_dump-11.sh
сгенерированный
поставляемый
@@ -1,8 +0,0 @@
|
||||
#!/bin/sh --
|
||||
|
||||
set -e
|
||||
exec 2>&1
|
||||
# Verified via: cat sockaddr_dump-11.out | sort | uniq -c
|
||||
../sockaddr dump '192.168.0.1'
|
||||
../sockaddr dump '::ffff:192.168.0.1'
|
||||
../sockaddr dump '0:0:0:0:0:ffff:192.168.0.1'
|
||||
8
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_dump-12.sh
сгенерированный
поставляемый
8
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_dump-12.sh
сгенерированный
поставляемый
@@ -1,8 +0,0 @@
|
||||
#!/bin/sh --
|
||||
|
||||
set -e
|
||||
exec 2>&1
|
||||
# Verified via: cat sockaddr_dump-12.out | sort | uniq -c
|
||||
../sockaddr dump '192.168.0.1/16'
|
||||
../sockaddr dump '::ffff:192.168.0.1/112'
|
||||
../sockaddr dump '0:0:0:0:0:ffff:192.168.0.1/112'
|
||||
12
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_dump-13.sh
сгенерированный
поставляемый
12
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_dump-13.sh
сгенерированный
поставляемый
@@ -1,12 +0,0 @@
|
||||
#!/bin/sh --
|
||||
|
||||
exec 2>&1
|
||||
# This should succeed because it is a mapped address
|
||||
../sockaddr dump -4 '0:0:0:0:0:ffff::/97'
|
||||
|
||||
# This should fail even though it is an IPv4 compatible address
|
||||
../sockaddr dump -4 '0:0:0:0:0:0::/97'
|
||||
|
||||
# These should succeed as an IPv6 addresses
|
||||
../sockaddr dump -6 '0:0:0:0:0:0::/97'
|
||||
../sockaddr dump -i '0:0:0:0:0:0::/97'
|
||||
12
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_dump-14.sh
сгенерированный
поставляемый
12
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_dump-14.sh
сгенерированный
поставляемый
@@ -1,12 +0,0 @@
|
||||
#!/bin/sh --
|
||||
|
||||
set -e
|
||||
exec 2>&1
|
||||
../sockaddr dump -4 '::c0a8:1'
|
||||
../sockaddr dump -6 '::c0a8:1'
|
||||
../sockaddr dump -4 '::c0a8:1/112'
|
||||
../sockaddr dump -6 '::c0a8:1/112'
|
||||
../sockaddr dump -4 '0:0:0:0:0:ffff:c0a8:1/112'
|
||||
../sockaddr dump -6 '0:0:0:0:0:ffff:c0a8:1/112'
|
||||
../sockaddr dump -4 '[0:0:0:0:0:ffff:c0a8:1/112]'
|
||||
../sockaddr dump -6 '[0:0:0:0:0:ffff:c0a8:1/112]'
|
||||
5
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_eval-00-help.sh
сгенерированный
поставляемый
5
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_eval-00-help.sh
сгенерированный
поставляемый
@@ -1,5 +0,0 @@
|
||||
#!/bin/sh --
|
||||
|
||||
set -e
|
||||
exec 2>&1
|
||||
exec ../sockaddr eval
|
||||
5
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_eval-01.sh
сгенерированный
поставляемый
5
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_eval-01.sh
сгенерированный
поставляемый
@@ -1,5 +0,0 @@
|
||||
#!/bin/sh --
|
||||
|
||||
set -e
|
||||
exec 2>&1
|
||||
exec ../sockaddr eval 'GetAllInterfaces | include "name" "lo0" | printf "%v"'
|
||||
5
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_eval-02.sh
сгенерированный
поставляемый
5
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_eval-02.sh
сгенерированный
поставляемый
@@ -1,5 +0,0 @@
|
||||
#!/bin/sh --
|
||||
|
||||
set -e
|
||||
exec 2>&1
|
||||
exec ../sockaddr eval 'GetAllInterfaces | include "name" "lo0" | printf "%v"' 'GetAllInterfaces | include "name" "lo0" | printf "%v"'
|
||||
5
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_eval-03.sh
сгенерированный
поставляемый
5
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_eval-03.sh
сгенерированный
поставляемый
@@ -1,5 +0,0 @@
|
||||
#!/bin/sh --
|
||||
|
||||
set -e
|
||||
exec 2>&1
|
||||
exec ../sockaddr eval '. | include "name" "lo0" | include "type" "IPv6" | sort "address" | join "address" " "'
|
||||
7
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_eval-04.sh
сгенерированный
поставляемый
7
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_eval-04.sh
сгенерированный
поставляемый
@@ -1,7 +0,0 @@
|
||||
#!/bin/sh --
|
||||
|
||||
set -e
|
||||
exec 2>&1
|
||||
cat <<'EOF' | exec ../sockaddr eval -
|
||||
{{GetAllInterfaces | include "name" "lo0" | printf "%v"}}
|
||||
EOF
|
||||
5
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_eval-05.sh
сгенерированный
поставляемый
5
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_eval-05.sh
сгенерированный
поставляемый
@@ -1,5 +0,0 @@
|
||||
#!/bin/sh --
|
||||
|
||||
set -e
|
||||
exec 2>&1
|
||||
../sockaddr eval 'GetPrivateInterfaces | include "flags" "up|multicast" | attr "flags"'
|
||||
5
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_rfc-00.sh
сгенерированный
поставляемый
5
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_rfc-00.sh
сгенерированный
поставляемый
@@ -1,5 +0,0 @@
|
||||
#!/bin/sh --
|
||||
|
||||
set -e
|
||||
exec 2>&1
|
||||
exec ../sockaddr -h rfc
|
||||
5
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_rfc-01.sh
сгенерированный
поставляемый
5
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_rfc-01.sh
сгенерированный
поставляемый
@@ -1,5 +0,0 @@
|
||||
#!/bin/sh --
|
||||
|
||||
set -e
|
||||
exec 2>&1
|
||||
exec ../sockaddr rfc -h list
|
||||
5
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_rfc_list-00.sh
сгенерированный
поставляемый
5
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_rfc_list-00.sh
сгенерированный
поставляемый
@@ -1,5 +0,0 @@
|
||||
#!/bin/sh --
|
||||
|
||||
set -e
|
||||
exec 2>&1
|
||||
exec ../sockaddr -h rfc list
|
||||
5
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_rfc_list-01.sh
сгенерированный
поставляемый
5
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_rfc_list-01.sh
сгенерированный
поставляемый
@@ -1,5 +0,0 @@
|
||||
#!/bin/sh --
|
||||
|
||||
set -e
|
||||
exec 2>&1
|
||||
exec ../sockaddr rfc list
|
||||
5
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_rfc_list-02.sh
сгенерированный
поставляемый
5
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_rfc_list-02.sh
сгенерированный
поставляемый
@@ -1,5 +0,0 @@
|
||||
#!/bin/sh --
|
||||
|
||||
set -e
|
||||
exec 2>&1
|
||||
exec ../sockaddr rfc list -h
|
||||
5
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_version-00.sh
сгенерированный
поставляемый
5
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_version-00.sh
сгенерированный
поставляемый
@@ -1,5 +0,0 @@
|
||||
#!/bin/sh --
|
||||
|
||||
set -e
|
||||
exec 2>&1
|
||||
exec ../sockaddr version
|
||||
5
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_version-01.sh
сгенерированный
поставляемый
5
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/regression/test_sockaddr_version-01.sh
сгенерированный
поставляемый
@@ -1,5 +0,0 @@
|
||||
#!/bin/sh --
|
||||
|
||||
set -e
|
||||
exec 2>&1
|
||||
exec ../sockaddr version
|
||||
20
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/vendor/github.com/armon/go-radix/LICENSE
сгенерированный
поставляемый
20
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/vendor/github.com/armon/go-radix/LICENSE
сгенерированный
поставляемый
@@ -1,20 +0,0 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Armon Dadgar
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
38
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/vendor/github.com/armon/go-radix/README.md
сгенерированный
поставляемый
38
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/vendor/github.com/armon/go-radix/README.md
сгенерированный
поставляемый
@@ -1,38 +0,0 @@
|
||||
go-radix [](https://travis-ci.org/armon/go-radix)
|
||||
=========
|
||||
|
||||
Provides the `radix` package that implements a [radix tree](http://en.wikipedia.org/wiki/Radix_tree).
|
||||
The package only provides a single `Tree` implementation, optimized for sparse nodes.
|
||||
|
||||
As a radix tree, it provides the following:
|
||||
* O(k) operations. In many cases, this can be faster than a hash table since
|
||||
the hash function is an O(k) operation, and hash tables have very poor cache locality.
|
||||
* Minimum / Maximum value lookups
|
||||
* Ordered iteration
|
||||
|
||||
For an immutable variant, see [go-immutable-radix](https://github.com/hashicorp/go-immutable-radix).
|
||||
|
||||
Documentation
|
||||
=============
|
||||
|
||||
The full documentation is available on [Godoc](http://godoc.org/github.com/armon/go-radix).
|
||||
|
||||
Example
|
||||
=======
|
||||
|
||||
Below is a simple example of usage
|
||||
|
||||
```go
|
||||
// Create a tree
|
||||
r := radix.New()
|
||||
r.Insert("foo", 1)
|
||||
r.Insert("bar", 2)
|
||||
r.Insert("foobar", 2)
|
||||
|
||||
// Find the longest prefix match
|
||||
m, _, _ := r.LongestPrefix("foozip")
|
||||
if m != "foo" {
|
||||
panic("should be foo")
|
||||
}
|
||||
```
|
||||
|
||||
496
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/vendor/github.com/armon/go-radix/radix.go
сгенерированный
поставляемый
496
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/vendor/github.com/armon/go-radix/radix.go
сгенерированный
поставляемый
@@ -1,496 +0,0 @@
|
||||
package radix
|
||||
|
||||
import (
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// WalkFn is used when walking the tree. Takes a
|
||||
// key and value, returning if iteration should
|
||||
// be terminated.
|
||||
type WalkFn func(s string, v interface{}) bool
|
||||
|
||||
// leafNode is used to represent a value
|
||||
type leafNode struct {
|
||||
key string
|
||||
val interface{}
|
||||
}
|
||||
|
||||
// edge is used to represent an edge node
|
||||
type edge struct {
|
||||
label byte
|
||||
node *node
|
||||
}
|
||||
|
||||
type node struct {
|
||||
// leaf is used to store possible leaf
|
||||
leaf *leafNode
|
||||
|
||||
// prefix is the common prefix we ignore
|
||||
prefix string
|
||||
|
||||
// Edges should be stored in-order for iteration.
|
||||
// We avoid a fully materialized slice to save memory,
|
||||
// since in most cases we expect to be sparse
|
||||
edges edges
|
||||
}
|
||||
|
||||
func (n *node) isLeaf() bool {
|
||||
return n.leaf != nil
|
||||
}
|
||||
|
||||
func (n *node) addEdge(e edge) {
|
||||
n.edges = append(n.edges, e)
|
||||
n.edges.Sort()
|
||||
}
|
||||
|
||||
func (n *node) replaceEdge(e edge) {
|
||||
num := len(n.edges)
|
||||
idx := sort.Search(num, func(i int) bool {
|
||||
return n.edges[i].label >= e.label
|
||||
})
|
||||
if idx < num && n.edges[idx].label == e.label {
|
||||
n.edges[idx].node = e.node
|
||||
return
|
||||
}
|
||||
panic("replacing missing edge")
|
||||
}
|
||||
|
||||
func (n *node) getEdge(label byte) *node {
|
||||
num := len(n.edges)
|
||||
idx := sort.Search(num, func(i int) bool {
|
||||
return n.edges[i].label >= label
|
||||
})
|
||||
if idx < num && n.edges[idx].label == label {
|
||||
return n.edges[idx].node
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n *node) delEdge(label byte) {
|
||||
num := len(n.edges)
|
||||
idx := sort.Search(num, func(i int) bool {
|
||||
return n.edges[i].label >= label
|
||||
})
|
||||
if idx < num && n.edges[idx].label == label {
|
||||
copy(n.edges[idx:], n.edges[idx+1:])
|
||||
n.edges[len(n.edges)-1] = edge{}
|
||||
n.edges = n.edges[:len(n.edges)-1]
|
||||
}
|
||||
}
|
||||
|
||||
type edges []edge
|
||||
|
||||
func (e edges) Len() int {
|
||||
return len(e)
|
||||
}
|
||||
|
||||
func (e edges) Less(i, j int) bool {
|
||||
return e[i].label < e[j].label
|
||||
}
|
||||
|
||||
func (e edges) Swap(i, j int) {
|
||||
e[i], e[j] = e[j], e[i]
|
||||
}
|
||||
|
||||
func (e edges) Sort() {
|
||||
sort.Sort(e)
|
||||
}
|
||||
|
||||
// Tree implements a radix tree. This can be treated as a
|
||||
// Dictionary abstract data type. The main advantage over
|
||||
// a standard hash map is prefix-based lookups and
|
||||
// ordered iteration,
|
||||
type Tree struct {
|
||||
root *node
|
||||
size int
|
||||
}
|
||||
|
||||
// New returns an empty Tree
|
||||
func New() *Tree {
|
||||
return NewFromMap(nil)
|
||||
}
|
||||
|
||||
// NewFromMap returns a new tree containing the keys
|
||||
// from an existing map
|
||||
func NewFromMap(m map[string]interface{}) *Tree {
|
||||
t := &Tree{root: &node{}}
|
||||
for k, v := range m {
|
||||
t.Insert(k, v)
|
||||
}
|
||||
return t
|
||||
}
|
||||
|
||||
// Len is used to return the number of elements in the tree
|
||||
func (t *Tree) Len() int {
|
||||
return t.size
|
||||
}
|
||||
|
||||
// longestPrefix finds the length of the shared prefix
|
||||
// of two strings
|
||||
func longestPrefix(k1, k2 string) int {
|
||||
max := len(k1)
|
||||
if l := len(k2); l < max {
|
||||
max = l
|
||||
}
|
||||
var i int
|
||||
for i = 0; i < max; i++ {
|
||||
if k1[i] != k2[i] {
|
||||
break
|
||||
}
|
||||
}
|
||||
return i
|
||||
}
|
||||
|
||||
// Insert is used to add a newentry or update
|
||||
// an existing entry. Returns if updated.
|
||||
func (t *Tree) Insert(s string, v interface{}) (interface{}, bool) {
|
||||
var parent *node
|
||||
n := t.root
|
||||
search := s
|
||||
for {
|
||||
// Handle key exhaution
|
||||
if len(search) == 0 {
|
||||
if n.isLeaf() {
|
||||
old := n.leaf.val
|
||||
n.leaf.val = v
|
||||
return old, true
|
||||
}
|
||||
|
||||
n.leaf = &leafNode{
|
||||
key: s,
|
||||
val: v,
|
||||
}
|
||||
t.size++
|
||||
return nil, false
|
||||
}
|
||||
|
||||
// Look for the edge
|
||||
parent = n
|
||||
n = n.getEdge(search[0])
|
||||
|
||||
// No edge, create one
|
||||
if n == nil {
|
||||
e := edge{
|
||||
label: search[0],
|
||||
node: &node{
|
||||
leaf: &leafNode{
|
||||
key: s,
|
||||
val: v,
|
||||
},
|
||||
prefix: search,
|
||||
},
|
||||
}
|
||||
parent.addEdge(e)
|
||||
t.size++
|
||||
return nil, false
|
||||
}
|
||||
|
||||
// Determine longest prefix of the search key on match
|
||||
commonPrefix := longestPrefix(search, n.prefix)
|
||||
if commonPrefix == len(n.prefix) {
|
||||
search = search[commonPrefix:]
|
||||
continue
|
||||
}
|
||||
|
||||
// Split the node
|
||||
t.size++
|
||||
child := &node{
|
||||
prefix: search[:commonPrefix],
|
||||
}
|
||||
parent.replaceEdge(edge{
|
||||
label: search[0],
|
||||
node: child,
|
||||
})
|
||||
|
||||
// Restore the existing node
|
||||
child.addEdge(edge{
|
||||
label: n.prefix[commonPrefix],
|
||||
node: n,
|
||||
})
|
||||
n.prefix = n.prefix[commonPrefix:]
|
||||
|
||||
// Create a new leaf node
|
||||
leaf := &leafNode{
|
||||
key: s,
|
||||
val: v,
|
||||
}
|
||||
|
||||
// If the new key is a subset, add to to this node
|
||||
search = search[commonPrefix:]
|
||||
if len(search) == 0 {
|
||||
child.leaf = leaf
|
||||
return nil, false
|
||||
}
|
||||
|
||||
// Create a new edge for the node
|
||||
child.addEdge(edge{
|
||||
label: search[0],
|
||||
node: &node{
|
||||
leaf: leaf,
|
||||
prefix: search,
|
||||
},
|
||||
})
|
||||
return nil, false
|
||||
}
|
||||
}
|
||||
|
||||
// Delete is used to delete a key, returning the previous
|
||||
// value and if it was deleted
|
||||
func (t *Tree) Delete(s string) (interface{}, bool) {
|
||||
var parent *node
|
||||
var label byte
|
||||
n := t.root
|
||||
search := s
|
||||
for {
|
||||
// Check for key exhaution
|
||||
if len(search) == 0 {
|
||||
if !n.isLeaf() {
|
||||
break
|
||||
}
|
||||
goto DELETE
|
||||
}
|
||||
|
||||
// Look for an edge
|
||||
parent = n
|
||||
label = search[0]
|
||||
n = n.getEdge(label)
|
||||
if n == nil {
|
||||
break
|
||||
}
|
||||
|
||||
// Consume the search prefix
|
||||
if strings.HasPrefix(search, n.prefix) {
|
||||
search = search[len(n.prefix):]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
return nil, false
|
||||
|
||||
DELETE:
|
||||
// Delete the leaf
|
||||
leaf := n.leaf
|
||||
n.leaf = nil
|
||||
t.size--
|
||||
|
||||
// Check if we should delete this node from the parent
|
||||
if parent != nil && len(n.edges) == 0 {
|
||||
parent.delEdge(label)
|
||||
}
|
||||
|
||||
// Check if we should merge this node
|
||||
if n != t.root && len(n.edges) == 1 {
|
||||
n.mergeChild()
|
||||
}
|
||||
|
||||
// Check if we should merge the parent's other child
|
||||
if parent != nil && parent != t.root && len(parent.edges) == 1 && !parent.isLeaf() {
|
||||
parent.mergeChild()
|
||||
}
|
||||
|
||||
return leaf.val, true
|
||||
}
|
||||
|
||||
func (n *node) mergeChild() {
|
||||
e := n.edges[0]
|
||||
child := e.node
|
||||
n.prefix = n.prefix + child.prefix
|
||||
n.leaf = child.leaf
|
||||
n.edges = child.edges
|
||||
}
|
||||
|
||||
// Get is used to lookup a specific key, returning
|
||||
// the value and if it was found
|
||||
func (t *Tree) Get(s string) (interface{}, bool) {
|
||||
n := t.root
|
||||
search := s
|
||||
for {
|
||||
// Check for key exhaution
|
||||
if len(search) == 0 {
|
||||
if n.isLeaf() {
|
||||
return n.leaf.val, true
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
// Look for an edge
|
||||
n = n.getEdge(search[0])
|
||||
if n == nil {
|
||||
break
|
||||
}
|
||||
|
||||
// Consume the search prefix
|
||||
if strings.HasPrefix(search, n.prefix) {
|
||||
search = search[len(n.prefix):]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
return nil, false
|
||||
}
|
||||
|
||||
// LongestPrefix is like Get, but instead of an
|
||||
// exact match, it will return the longest prefix match.
|
||||
func (t *Tree) LongestPrefix(s string) (string, interface{}, bool) {
|
||||
var last *leafNode
|
||||
n := t.root
|
||||
search := s
|
||||
for {
|
||||
// Look for a leaf node
|
||||
if n.isLeaf() {
|
||||
last = n.leaf
|
||||
}
|
||||
|
||||
// Check for key exhaution
|
||||
if len(search) == 0 {
|
||||
break
|
||||
}
|
||||
|
||||
// Look for an edge
|
||||
n = n.getEdge(search[0])
|
||||
if n == nil {
|
||||
break
|
||||
}
|
||||
|
||||
// Consume the search prefix
|
||||
if strings.HasPrefix(search, n.prefix) {
|
||||
search = search[len(n.prefix):]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
if last != nil {
|
||||
return last.key, last.val, true
|
||||
}
|
||||
return "", nil, false
|
||||
}
|
||||
|
||||
// Minimum is used to return the minimum value in the tree
|
||||
func (t *Tree) Minimum() (string, interface{}, bool) {
|
||||
n := t.root
|
||||
for {
|
||||
if n.isLeaf() {
|
||||
return n.leaf.key, n.leaf.val, true
|
||||
}
|
||||
if len(n.edges) > 0 {
|
||||
n = n.edges[0].node
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
return "", nil, false
|
||||
}
|
||||
|
||||
// Maximum is used to return the maximum value in the tree
|
||||
func (t *Tree) Maximum() (string, interface{}, bool) {
|
||||
n := t.root
|
||||
for {
|
||||
if num := len(n.edges); num > 0 {
|
||||
n = n.edges[num-1].node
|
||||
continue
|
||||
}
|
||||
if n.isLeaf() {
|
||||
return n.leaf.key, n.leaf.val, true
|
||||
}
|
||||
break
|
||||
}
|
||||
return "", nil, false
|
||||
}
|
||||
|
||||
// Walk is used to walk the tree
|
||||
func (t *Tree) Walk(fn WalkFn) {
|
||||
recursiveWalk(t.root, fn)
|
||||
}
|
||||
|
||||
// WalkPrefix is used to walk the tree under a prefix
|
||||
func (t *Tree) WalkPrefix(prefix string, fn WalkFn) {
|
||||
n := t.root
|
||||
search := prefix
|
||||
for {
|
||||
// Check for key exhaution
|
||||
if len(search) == 0 {
|
||||
recursiveWalk(n, fn)
|
||||
return
|
||||
}
|
||||
|
||||
// Look for an edge
|
||||
n = n.getEdge(search[0])
|
||||
if n == nil {
|
||||
break
|
||||
}
|
||||
|
||||
// Consume the search prefix
|
||||
if strings.HasPrefix(search, n.prefix) {
|
||||
search = search[len(n.prefix):]
|
||||
|
||||
} else if strings.HasPrefix(n.prefix, search) {
|
||||
// Child may be under our search prefix
|
||||
recursiveWalk(n, fn)
|
||||
return
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// WalkPath is used to walk the tree, but only visiting nodes
|
||||
// from the root down to a given leaf. Where WalkPrefix walks
|
||||
// all the entries *under* the given prefix, this walks the
|
||||
// entries *above* the given prefix.
|
||||
func (t *Tree) WalkPath(path string, fn WalkFn) {
|
||||
n := t.root
|
||||
search := path
|
||||
for {
|
||||
// Visit the leaf values if any
|
||||
if n.leaf != nil && fn(n.leaf.key, n.leaf.val) {
|
||||
return
|
||||
}
|
||||
|
||||
// Check for key exhaution
|
||||
if len(search) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
// Look for an edge
|
||||
n = n.getEdge(search[0])
|
||||
if n == nil {
|
||||
return
|
||||
}
|
||||
|
||||
// Consume the search prefix
|
||||
if strings.HasPrefix(search, n.prefix) {
|
||||
search = search[len(n.prefix):]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// recursiveWalk is used to do a pre-order walk of a node
|
||||
// recursively. Returns true if the walk should be aborted
|
||||
func recursiveWalk(n *node, fn WalkFn) bool {
|
||||
// Visit the leaf values if any
|
||||
if n.leaf != nil && fn(n.leaf.key, n.leaf.val) {
|
||||
return true
|
||||
}
|
||||
|
||||
// Recurse on the children
|
||||
for _, e := range n.edges {
|
||||
if recursiveWalk(e.node, fn) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// ToMap is used to walk the tree and convert it into a map
|
||||
func (t *Tree) ToMap() map[string]interface{} {
|
||||
out := make(map[string]interface{}, t.size)
|
||||
t.Walk(func(k string, v interface{}) bool {
|
||||
out[k] = v
|
||||
return false
|
||||
})
|
||||
return out
|
||||
}
|
||||
201
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/vendor/github.com/bgentry/speakeasy/LICENSE_WINDOWS
сгенерированный
поставляемый
201
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/vendor/github.com/bgentry/speakeasy/LICENSE_WINDOWS
сгенерированный
поставляемый
@@ -1,201 +0,0 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [2013] [the CloudFoundry Authors]
|
||||
|
||||
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.
|
||||
30
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/vendor/github.com/bgentry/speakeasy/Readme.md
сгенерированный
поставляемый
30
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/vendor/github.com/bgentry/speakeasy/Readme.md
сгенерированный
поставляемый
@@ -1,30 +0,0 @@
|
||||
# Speakeasy
|
||||
|
||||
This package provides cross-platform Go (#golang) helpers for taking user input
|
||||
from the terminal while not echoing the input back (similar to `getpasswd`). The
|
||||
package uses syscalls to avoid any dependence on cgo, and is therefore
|
||||
compatible with cross-compiling.
|
||||
|
||||
[][godoc]
|
||||
|
||||
## Unicode
|
||||
|
||||
Multi-byte unicode characters work successfully on Mac OS X. On Windows,
|
||||
however, this may be problematic (as is UTF in general on Windows). Other
|
||||
platforms have not been tested.
|
||||
|
||||
## License
|
||||
|
||||
The code herein was not written by me, but was compiled from two separate open
|
||||
source packages. Unix portions were imported from [gopass][gopass], while
|
||||
Windows portions were imported from the [CloudFoundry Go CLI][cf-cli]'s
|
||||
[Windows terminal helpers][cf-ui-windows].
|
||||
|
||||
The [license for the windows portion](./LICENSE_WINDOWS) has been copied exactly
|
||||
from the source (though I attempted to fill in the correct owner in the
|
||||
boilerplate copyright notice).
|
||||
|
||||
[cf-cli]: https://github.com/cloudfoundry/cli "CloudFoundry Go CLI"
|
||||
[cf-ui-windows]: https://github.com/cloudfoundry/cli/blob/master/src/cf/terminal/ui_windows.go "CloudFoundry Go CLI Windows input helpers"
|
||||
[godoc]: https://godoc.org/github.com/bgentry/speakeasy "speakeasy on Godoc.org"
|
||||
[gopass]: https://code.google.com/p/gopass "gopass"
|
||||
49
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/vendor/github.com/bgentry/speakeasy/speakeasy.go
сгенерированный
поставляемый
49
vendor/github.com/hashicorp/go-sockaddr/cmd/sockaddr/vendor/github.com/bgentry/speakeasy/speakeasy.go
сгенерированный
поставляемый
@@ -1,49 +0,0 @@
|
||||
package speakeasy
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Ask the user to enter a password with input hidden. prompt is a string to
|
||||
// display before the user's input. Returns the provided password, or an error
|
||||
// if the command failed.
|
||||
func Ask(prompt string) (password string, err error) {
|
||||
return FAsk(os.Stdout, prompt)
|
||||
}
|
||||
|
||||
// FAsk is the same as Ask, except it is possible to specify the file to write
|
||||
// the prompt to. If 'nil' is passed as the writer, no prompt will be written.
|
||||
func FAsk(wr io.Writer, prompt string) (password string, err error) {
|
||||
if wr != nil && prompt != "" {
|
||||
fmt.Fprint(wr, prompt) // Display the prompt.
|
||||
}
|
||||
password, err = getPassword()
|
||||
|
||||
// Carriage return after the user input.
|
||||
if wr != nil {
|
||||
fmt.Fprintln(wr, "")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func readline() (value string, err error) {
|
||||
var valb []byte
|
||||
var n int
|
||||
b := make([]byte, 1)
|
||||
for {
|
||||
// read one byte at a time so we don't accidentally read extra bytes
|
||||
n, err = os.Stdin.Read(b)
|
||||
if err != nil && err != io.EOF {
|
||||
return "", err
|
||||
}
|
||||
if n == 0 || b[0] == '\n' {
|
||||
break
|
||||
}
|
||||
valb = append(valb, b[0])
|
||||
}
|
||||
|
||||
return strings.TrimSuffix(string(valb), "\r"), nil
|
||||
}
|
||||
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Ссылка в новой задаче
Block a user