diff --git a/Gopkg.lock b/Gopkg.lock index 09cfa2f6..94730634 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -23,7 +23,7 @@ branch = "master" name = "github.com/aead/chacha20" packages = ["chacha"] - revision = "e0d4ab3067da29fbce5b60445bed6d54c41c3c62" + revision = "c1766ed472dff2392a1a13de7b82e8f5a64ab11d" [[projects]] branch = "master" @@ -121,8 +121,8 @@ [[projects]] name = "github.com/k-sone/critbitgo" packages = ["."] - revision = "1b44ffc7fc9ad8dea28251e340eadb04093c8af3" - version = "v1.1.0" + revision = "658116ef1e826b72c603cfe2091b12503f9bca43" + version = "v1.2.0" [[projects]] branch = "master" @@ -154,7 +154,7 @@ "poly1305", "salsa20/salsa" ] - revision = "d6449816ce06963d9d136eee5a56fca5b0616e7e" + revision = "b0697eccbea9adec5b7ba8008f4c33d98d733388" [[projects]] branch = "master" @@ -171,7 +171,7 @@ "ipv6", "lex/httplex" ] - revision = "d41e8174641f662c5a2d1c7a5f9e828788eb8706" + revision = "5f9ae10d9af5b1c89ae6904293b14b064d4ada23" [[projects]] branch = "master" @@ -183,7 +183,7 @@ "windows/svc/eventlog", "windows/svc/mgr" ] - revision = "b126b21c05a91c856b027c16779c12e3bf236954" + revision = "79b0c6888797020a994db17c8510466c72fe75d9" [[projects]] name = "golang.org/x/text" diff --git a/vendor/github.com/aead/chacha20/.travis.yml b/vendor/github.com/aead/chacha20/.travis.yml index 81be6b23..dc12a35d 100644 --- a/vendor/github.com/aead/chacha20/.travis.yml +++ b/vendor/github.com/aead/chacha20/.travis.yml @@ -1,23 +1,22 @@ language: go go: - - "1.8.7" - - "1.9.4" - - "1.10" + - "1.8.x" + - "1.9.x" + - "1.10.x" env: - ARCH=x86_64 - ARCH=i686 - - TRAVIS_GOARCH=amd64 - - TRAVIS_GOARCH=386 -before_install: - - export GOARCH=$TRAVIS_GOARCH - branches: only: - master +before_script: +- go get -u github.com/klauspost/asmfmt/cmd/asmfmt + script: - diff -au <(gofmt -d .) <(printf "") +- diff -au <(asmfmt -d .) <(printf "") - go test -v ./... diff --git a/vendor/github.com/aead/chacha20/chacha/chacha_amd64.s b/vendor/github.com/aead/chacha20/chacha/chacha_amd64.s index 7cbc789d..0962f232 100644 --- a/vendor/github.com/aead/chacha20/chacha/chacha_amd64.s +++ b/vendor/github.com/aead/chacha20/chacha/chacha_amd64.s @@ -667,7 +667,7 @@ CHACHA_LOOP_192: ADDQ $64, Src SUBQ $64, Len JZ DONE - CMPQ Len, $64 // If Len <= 64 -> gen. only 64 byte keystream. + CMPQ Len, $64 // If Len <= 64 -> gen. only 64 byte keystream. JBE GENERATE_KEYSTREAM_64 GENERATE_KEYSTREAM_128: @@ -793,13 +793,13 @@ TEXT ·xorKeyStreamAVX(SB), 4, $144-80 VMOVDQU ·one<>(SB), X4 VMOVDQU ·rol16<>(SB), X5 VMOVDQU ·rol8<>(SB), X6 - VMOVDQA X0, 0*16(Stack) - VMOVDQA X1, 1*16(Stack) - VMOVDQA X2, 2*16(Stack) - VMOVDQA X3, 3*16(Stack) - VMOVDQA X4, 4*16(Stack) - VMOVDQA X5, 6*16(Stack) - VMOVDQA X6, 7*16(Stack) + VMOVDQA X0, 0*16(Stack) + VMOVDQA X1, 1*16(Stack) + VMOVDQA X2, 2*16(Stack) + VMOVDQA X3, 3*16(Stack) + VMOVDQA X4, 4*16(Stack) + VMOVDQA X5, 6*16(Stack) + VMOVDQA X6, 7*16(Stack) CMPQ Len, $64 JBE GENERATE_KEYSTREAM_64 @@ -809,22 +809,22 @@ TEXT ·xorKeyStreamAVX(SB), 4, $144-80 JBE GENERATE_KEYSTREAM_192 GENERATE_KEYSTREAM_256: - VMOVDQA X0, X12 - VMOVDQA X1, X13 - VMOVDQA X2, X14 - VMOVDQA X3, X15 - VPADDQ 4*16(Stack), X15, X15 - VMOVDQA X0, X8 - VMOVDQA X1, X9 - VMOVDQA X2, X10 - VMOVDQA X15, X11 - VPADDQ 4*16(Stack), X11, X11 - VMOVDQA X0, X4 - VMOVDQA X1, X5 - VMOVDQA X2, X6 - VMOVDQA X11, X7 - VPADDQ 4*16(Stack), X7, X7 - MOVQ Rounds, Tmp0 + VMOVDQA X0, X12 + VMOVDQA X1, X13 + VMOVDQA X2, X14 + VMOVDQA X3, X15 + VPADDQ 4*16(Stack), X15, X15 + VMOVDQA X0, X8 + VMOVDQA X1, X9 + VMOVDQA X2, X10 + VMOVDQA X15, X11 + VPADDQ 4*16(Stack), X11, X11 + VMOVDQA X0, X4 + VMOVDQA X1, X5 + VMOVDQA X2, X6 + VMOVDQA X11, X7 + VPADDQ 4*16(Stack), X7, X7 + MOVQ Rounds, Tmp0 VMOVDQA X3, 3*16(Stack) // Save X3 @@ -853,22 +853,22 @@ CHACHA_LOOP_256: CHACHA_SHUFFLE_AVX(X15, X14, X13) CHACHA_SHUFFLE_AVX(X11, X10, X9) CHACHA_SHUFFLE_AVX(X7, X6, X5) - SUBQ $2, Tmp0 - JNZ CHACHA_LOOP_256 + SUBQ $2, Tmp0 + JNZ CHACHA_LOOP_256 - VPADDD 0*16(Stack), X0, X0 - VPADDD 1*16(Stack), X1, X1 - VPADDD 2*16(Stack), X2, X2 - VPADDD 3*16(Stack), X3, X3 - VMOVDQA X4, 5*16(Stack) // Save X4 + VPADDD 0*16(Stack), X0, X0 + VPADDD 1*16(Stack), X1, X1 + VPADDD 2*16(Stack), X2, X2 + VPADDD 3*16(Stack), X3, X3 + VMOVDQA X4, 5*16(Stack) // Save X4 XOR_AVX(Dst, Src, 0, X0, X1, X2, X3, X4) - VMOVDQA 5*16(Stack), X4 // Restore X4 + VMOVDQA 5*16(Stack), X4 // Restore X4 - VMOVDQA 0*16(Stack), X0 - VMOVDQA 1*16(Stack), X1 - VMOVDQA 2*16(Stack), X2 - VMOVDQA 3*16(Stack), X3 - VPADDQ 4*16(Stack), X3, X3 + VMOVDQA 0*16(Stack), X0 + VMOVDQA 1*16(Stack), X1 + VMOVDQA 2*16(Stack), X2 + VMOVDQA 3*16(Stack), X3 + VPADDQ 4*16(Stack), X3, X3 VPADDD X0, X12, X12 VPADDD X1, X13, X13 @@ -889,9 +889,9 @@ CHACHA_LOOP_256: XOR_AVX(Dst, Src, 64, X12, X13, X14, X15, X0) XOR_AVX(Dst, Src, 128, X8, X9, X10, X11, X0) VMOVDQA 0*16(Stack), X0 // Restore X0 - ADDQ $192, Dst - ADDQ $192, Src - SUBQ $192, Len + ADDQ $192, Dst + ADDQ $192, Src + SUBQ $192, Len CMPQ Len, $64 JB BUFFER_KEYSTREAM @@ -909,21 +909,21 @@ CHACHA_LOOP_256: JA GENERATE_KEYSTREAM_256 GENERATE_KEYSTREAM_192: - VMOVDQA X0, X12 - VMOVDQA X1, X13 - VMOVDQA X2, X14 - VMOVDQA X3, X15 - VMOVDQA X0, X8 - VMOVDQA X1, X9 - VMOVDQA X2, X10 - VMOVDQA X3, X11 - VPADDQ 4*16(Stack), X11, X11 - VMOVDQA X0, X4 - VMOVDQA X1, X5 - VMOVDQA X2, X6 - VMOVDQA X11, X7 - VPADDQ 4*16(Stack), X7, X7 - MOVQ Rounds, Tmp0 + VMOVDQA X0, X12 + VMOVDQA X1, X13 + VMOVDQA X2, X14 + VMOVDQA X3, X15 + VMOVDQA X0, X8 + VMOVDQA X1, X9 + VMOVDQA X2, X10 + VMOVDQA X3, X11 + VPADDQ 4*16(Stack), X11, X11 + VMOVDQA X0, X4 + VMOVDQA X1, X5 + VMOVDQA X2, X6 + VMOVDQA X11, X7 + VPADDQ 4*16(Stack), X7, X7 + MOVQ Rounds, Tmp0 VMOVDQA 6*16(Stack), X1 // Load 16 bit rotate-left constant VMOVDQA 7*16(Stack), X2 // Load 8 bit rotate-left constant @@ -944,31 +944,31 @@ CHACHA_LOOP_192: SUBQ $2, Tmp0 JNZ CHACHA_LOOP_192 - VMOVDQA 0*16(Stack), X0 // Restore X0 - VMOVDQA 1*16(Stack), X1 // Restore X1 - VMOVDQA 2*16(Stack), X2 // Restore X2 - VPADDD X0, X12, X12 - VPADDD X1, X13, X13 - VPADDD X2, X14, X14 - VPADDD X3, X15, X15 - VPADDQ 4*16(Stack), X3, X3 - VPADDD X0, X8, X8 - VPADDD X1, X9, X9 - VPADDD X2, X10, X10 - VPADDD X3, X11, X11 - VPADDQ 4*16(Stack), X3, X3 - VPADDD X0, X4, X4 - VPADDD X1, X5, X5 - VPADDD X2, X6, X6 - VPADDD X3, X7, X7 - VPADDQ 4*16(Stack), X3, X3 + VMOVDQA 0*16(Stack), X0 // Restore X0 + VMOVDQA 1*16(Stack), X1 // Restore X1 + VMOVDQA 2*16(Stack), X2 // Restore X2 + VPADDD X0, X12, X12 + VPADDD X1, X13, X13 + VPADDD X2, X14, X14 + VPADDD X3, X15, X15 + VPADDQ 4*16(Stack), X3, X3 + VPADDD X0, X8, X8 + VPADDD X1, X9, X9 + VPADDD X2, X10, X10 + VPADDD X3, X11, X11 + VPADDQ 4*16(Stack), X3, X3 + VPADDD X0, X4, X4 + VPADDD X1, X5, X5 + VPADDD X2, X6, X6 + VPADDD X3, X7, X7 + VPADDQ 4*16(Stack), X3, X3 XOR_AVX(Dst, Src, 0, X12, X13, X14, X15, X0) XOR_AVX(Dst, Src, 64, X8, X9, X10, X11, X0) VMOVDQA 0*16(Stack), X0 // Restore X0 - ADDQ $128, Dst - ADDQ $128, Src - SUBQ $128, Len + ADDQ $128, Dst + ADDQ $128, Src + SUBQ $128, Len CMPQ Len, $64 JB BUFFER_KEYSTREAM @@ -978,20 +978,20 @@ CHACHA_LOOP_192: ADDQ $64, Src SUBQ $64, Len JZ DONE - CMPQ Len, $64 // If Len <= 64 -> gen. only 64 byte keystream. + CMPQ Len, $64 // If Len <= 64 -> gen. only 64 byte keystream. JBE GENERATE_KEYSTREAM_64 GENERATE_KEYSTREAM_128: - VMOVDQA X0, X8 - VMOVDQA X1, X9 - VMOVDQA X2, X10 - VMOVDQA X3, X11 - VMOVDQA X0, X4 - VMOVDQA X1, X5 - VMOVDQA X2, X6 - VMOVDQA X3, X7 - VPADDQ 4*16(Stack), X7, X7 - MOVQ Rounds, Tmp0 + VMOVDQA X0, X8 + VMOVDQA X1, X9 + VMOVDQA X2, X10 + VMOVDQA X3, X11 + VMOVDQA X0, X4 + VMOVDQA X1, X5 + VMOVDQA X2, X6 + VMOVDQA X3, X7 + VPADDQ 4*16(Stack), X7, X7 + MOVQ Rounds, Tmp0 VMOVDQA 6*16(Stack), X13 // Load 16 bit rotate-left constant VMOVDQA 7*16(Stack), X14 // Load 8 bit rotate-left constant @@ -1038,7 +1038,7 @@ GENERATE_KEYSTREAM_64: VMOVDQA X1, X5 VMOVDQA X2, X6 VMOVDQA X3, X7 - MOVQ Rounds, Tmp0 + MOVQ Rounds, Tmp0 VMOVDQA 6*16(Stack), X9 // Load 16 bit rotate-left constant VMOVDQA 7*16(Stack), X10 // Load 8 bit rotate-left constant @@ -1071,14 +1071,14 @@ BUFFER_KEYSTREAM: VMOVDQU X5, 1*16(Buffer) VMOVDQU X6, 2*16(Buffer) VMOVDQU X7, 3*16(Buffer) - MOVQ Len, Tmp0 + MOVQ Len, Tmp0 FINALIZE(Dst, Src, Buffer, Tmp0, Tmp1, Tmp2) DONE: - MOVQ SavedSP, Stack // Restore stack pointer + MOVQ SavedSP, Stack // Restore stack pointer VMOVDQU X3, 3*16(State) VZEROUPPER - MOVQ Len, ret+72(FP) + MOVQ Len, ret+72(FP) RET #undef Dst diff --git a/vendor/github.com/aead/chacha20/chacha/chacha_test.go b/vendor/github.com/aead/chacha20/chacha/chacha_test.go index 6024f90b..e0dec5e0 100644 --- a/vendor/github.com/aead/chacha20/chacha/chacha_test.go +++ b/vendor/github.com/aead/chacha20/chacha/chacha_test.go @@ -34,7 +34,7 @@ func TestHChaCha20(t *testing.T) { } if useAVX { t.Log("AVX version") - testIncremental(t, 5, 2049) + testHChaCha20(t) useAVX = false } if useSSSE3 { @@ -63,7 +63,7 @@ func TestVectors(t *testing.T) { } if useAVX { t.Log("AVX version") - testIncremental(t, 5, 2049) + testVectors(t) useAVX = false } if useSSSE3 { diff --git a/vendor/github.com/aead/chacha20/chacha/const.s b/vendor/github.com/aead/chacha20/chacha/const.s index 7f2e28a3..c7a94a47 100644 --- a/vendor/github.com/aead/chacha20/chacha/const.s +++ b/vendor/github.com/aead/chacha20/chacha/const.s @@ -38,7 +38,7 @@ DATA ·two_AVX2<>+0x00(SB)/8, $2 DATA ·two_AVX2<>+0x08(SB)/8, $0 DATA ·two_AVX2<>+0x10(SB)/8, $2 DATA ·two_AVX2<>+0x18(SB)/8, $0 -GLOBL ·two_AVX2<>(SB), (NOPTR+RODATA), $32 +GLOBL ·two_AVX2<>(SB), (NOPTR+RODATA), $32 DATA ·rol16_AVX2<>+0x00(SB)/8, $0x0504070601000302 DATA ·rol16_AVX2<>+0x08(SB)/8, $0x0D0C0F0E09080B0A diff --git a/vendor/github.com/aead/chacha20/chacha/macro.s b/vendor/github.com/aead/chacha20/chacha/macro.s index b60c464b..780108f8 100644 --- a/vendor/github.com/aead/chacha20/chacha/macro.s +++ b/vendor/github.com/aead/chacha20/chacha/macro.s @@ -5,7 +5,7 @@ // +build 386,!gccgo,!appengine,!nacl amd64,!gccgo,!appengine,!nacl // ROTL_SSE rotates all 4 32 bit values of the XMM register v -// left by n bits using SSE2 instructions (0 <= n <= 32). +// left by n bits using SSE2 instructions (0 <= n <= 32). // The XMM register t is used as a temp. register. #define ROTL_SSE(n, t, v) \ MOVO v, t; \ @@ -14,7 +14,7 @@ PXOR t, v // ROTL_AVX rotates all 4/8 32 bit values of the AVX/AVX2 register v -// left by n bits using AVX/AVX2 instructions (0 <= n <= 32). +// left by n bits using AVX/AVX2 instructions (0 <= n <= 32). // The AVX/AVX2 register t is used as a temp. register. #define ROTL_AVX(n, t, v) \ VPSLLD $n, v, t; \ @@ -25,41 +25,41 @@ // 4 XMM registers v0, v1, v2 and v3. It uses only ROTL_SSE2 for // rotations. The XMM register t is used as a temp. register. #define CHACHA_QROUND_SSE2(v0, v1, v2, v3, t) \ - PADDL v1, v0; \ - PXOR v0, v3; \ + PADDL v1, v0; \ + PXOR v0, v3; \ ROTL_SSE(16, t, v3); \ - PADDL v3, v2; \ - PXOR v2, v1; \ + PADDL v3, v2; \ + PXOR v2, v1; \ ROTL_SSE(12, t, v1); \ - PADDL v1, v0; \ - PXOR v0, v3; \ + PADDL v1, v0; \ + PXOR v0, v3; \ ROTL_SSE(8, t, v3); \ - PADDL v3, v2; \ - PXOR v2, v1; \ + PADDL v3, v2; \ + PXOR v2, v1; \ ROTL_SSE(7, t, v1) // CHACHA_QROUND_SSSE3 performs a ChaCha quarter-round using the -// 4 XMM registers v0, v1, v2 and v3. It uses PSHUFB for 8/16 bit +// 4 XMM registers v0, v1, v2 and v3. It uses PSHUFB for 8/16 bit // rotations. The XMM register t is used as a temp. register. // // r16 holds the PSHUFB constant for a 16 bit left rotate. // r8 holds the PSHUFB constant for a 8 bit left rotate. #define CHACHA_QROUND_SSSE3(v0, v1, v2, v3, t, r16, r8) \ - PADDL v1, v0; \ - PXOR v0, v3; \ - PSHUFB r16, v3; \ - PADDL v3, v2; \ - PXOR v2, v1; \ + PADDL v1, v0; \ + PXOR v0, v3; \ + PSHUFB r16, v3; \ + PADDL v3, v2; \ + PXOR v2, v1; \ ROTL_SSE(12, t, v1); \ - PADDL v1, v0; \ - PXOR v0, v3; \ - PSHUFB r8, v3; \ - PADDL v3, v2; \ - PXOR v2, v1; \ + PADDL v1, v0; \ + PXOR v0, v3; \ + PSHUFB r8, v3; \ + PADDL v3, v2; \ + PXOR v2, v1; \ ROTL_SSE(7, t, v1) // CHACHA_QROUND_AVX performs a ChaCha quarter-round using the -// 4 AVX/AVX2 registers v0, v1, v2 and v3. It uses VPSHUFB for 8/16 bit +// 4 AVX/AVX2 registers v0, v1, v2 and v3. It uses VPSHUFB for 8/16 bit // rotations. The AVX/AVX2 register t is used as a temp. register. // // r16 holds the VPSHUFB constant for a 16 bit left rotate. @@ -70,7 +70,7 @@ VPSHUFB r16, v3, v3; \ VPADDD v2, v3, v2; \ VPXOR v1, v2, v1; \ - ROTL_AVX(12, t, v1); \ + ROTL_AVX(12, t, v1); \ VPADDD v0, v1, v0; \ VPXOR v3, v0, v3; \ VPSHUFB r8, v3, v3; \ @@ -94,8 +94,8 @@ VPSHUFD $0x4E, v2, v2; \ VPSHUFD $0x93, v3, v3 -// XOR_SSE extracts 4x16 byte vectors from src at -// off, xors all vectors with the corresponding XMM +// XOR_SSE extracts 4x16 byte vectors from src at +// off, xors all vectors with the corresponding XMM // register (v0 - v3) and writes the result to dst // at off. // The XMM register t is used as a temp. register. @@ -113,8 +113,8 @@ PXOR v3, t; \ MOVOU t, 48+off(dst) -// XOR_AVX extracts 4x16 byte vectors from src at -// off, xors all vectors with the corresponding AVX +// XOR_AVX extracts 4x16 byte vectors from src at +// off, xors all vectors with the corresponding AVX // register (v0 - v3) and writes the result to dst // at off. // The XMM register t is used as a temp. register. diff --git a/vendor/github.com/k-sone/critbitgo/CHANGES.md b/vendor/github.com/k-sone/critbitgo/CHANGES.md index b7370c0b..902be457 100644 --- a/vendor/github.com/k-sone/critbitgo/CHANGES.md +++ b/vendor/github.com/k-sone/critbitgo/CHANGES.md @@ -1,3 +1,7 @@ +## 1.2.0 (2018/04/25) + +- Add ContainedIP() as fast way to check an IP [#7](https://github.com/k-sone/critbitgo/pull/7) + ## 1.1.0 (2016/12/29) - Add `LongestPrefix ` and `Walk` functions diff --git a/vendor/github.com/k-sone/critbitgo/critbit.go b/vendor/github.com/k-sone/critbitgo/critbit.go index 73a7e41c..477f4b0a 100644 --- a/vendor/github.com/k-sone/critbitgo/critbit.go +++ b/vendor/github.com/k-sone/critbitgo/critbit.go @@ -236,9 +236,11 @@ func (t *Trie) Allprefixed(prefix []byte, handle func(key []byte, value interfac p := &t.root top := p if len(prefix) > 0 { - for p.internal != nil { - top = p - p = &p.internal.child[p.internal.direction(prefix)] + for q := p.internal; q != nil; q = p.internal { + p = &q.child[q.direction(prefix)] + if q.offset < len(prefix) { + top = p + } } // check prefix diff --git a/vendor/github.com/k-sone/critbitgo/critbit_test.go b/vendor/github.com/k-sone/critbitgo/critbit_test.go index e3d4ec18..1042970d 100644 --- a/vendor/github.com/k-sone/critbitgo/critbit_test.go +++ b/vendor/github.com/k-sone/critbitgo/critbit_test.go @@ -137,7 +137,7 @@ func TestSize(t *testing.T) { } func TestAllprefixed(t *testing.T) { - keys := []string{"", "a", "aa", "b", "bb", "ab", "ba", "aba", "bab"} + keys := []string{"", "a", "aa", "b", "bb", "ab", "ba", "aba", "bab", "bc"} trie := buildTrie(t, keys) elems := make([]string, 0, len(keys)) @@ -150,10 +150,10 @@ func TestAllprefixed(t *testing.T) { if !trie.Allprefixed([]byte{}, handle) { t.Error("Allprefixed() - invalid result") } - if len(elems) != 9 { + if len(elems) != 10 { t.Errorf("Allprefixed() - invalid elems length [%v]", elems) } - for i, key := range []string{"", "a", "aa", "ab", "aba", "b", "ba", "bab", "bb"} { + for i, key := range []string{"", "a", "aa", "ab", "aba", "b", "ba", "bab", "bb", "bc"} { if key != elems[i] { t.Errorf("Allprefixed() - not found [%s]", key) } @@ -172,6 +172,19 @@ func TestAllprefixed(t *testing.T) { } } + elems = make([]string, 0, len(keys)) + if !trie.Allprefixed([]byte("bb"), handle) { + t.Error("Allprefixed() - invalid result") + } + if len(elems) != 1 { + t.Errorf("Allprefixed() - invalid elems length [%v]", elems) + } + for i, key := range []string{"bb"} { + if key != elems[i] { + t.Errorf("Allprefixed() - not found [%s]", key) + } + } + elems = make([]string, 0, len(keys)) handle = func(key []byte, value interface{}) bool { if k := string(key); k == value { diff --git a/vendor/github.com/k-sone/critbitgo/net.go b/vendor/github.com/k-sone/critbitgo/net.go index 7e155b24..9c822e40 100644 --- a/vendor/github.com/k-sone/critbitgo/net.go +++ b/vendor/github.com/k-sone/critbitgo/net.go @@ -97,9 +97,25 @@ func (n *Net) MatchCIDR(s string) (route *net.IPNet, value interface{}, err erro return } +// Return a bool indicating whether a route would be found +func (n *Net) ContainedIP(ip net.IP) (contained bool, err error) { + k, _, err := n.matchIP(ip) + contained = k != nil + return +} + // Return a specific route by using the longest prefix matching. // If `ip` is invalid IP, or a route is not found, `route` is nil. func (n *Net) MatchIP(ip net.IP) (route *net.IPNet, value interface{}, err error) { + k, v, err := n.matchIP(ip) + if k != nil { + route = netKeyToIPNet(k) + value = v + } + return +} + +func (n *Net) matchIP(ip net.IP) (k []byte, v interface{}, err error) { var isV4 bool ip, isV4, err = netValidateIP(ip) if err != nil { @@ -111,10 +127,7 @@ func (n *Net) MatchIP(ip net.IP) (route *net.IPNet, value interface{}, err error } else { mask = mask128 } - if k, v := n.match(netIPNetToKey(ip, mask)); k != nil { - route = netKeyToIPNet(k) - value = v - } + k, v = n.match(netIPNetToKey(ip, mask)) return } diff --git a/vendor/github.com/k-sone/critbitgo/net_test.go b/vendor/github.com/k-sone/critbitgo/net_test.go index 091f0948..0847034d 100644 --- a/vendor/github.com/k-sone/critbitgo/net_test.go +++ b/vendor/github.com/k-sone/critbitgo/net_test.go @@ -31,6 +31,12 @@ func TestNet(t *testing.T) { if r, v, err := trie.MatchIP(hostIP); r != nil || v != nil || err != nil { t.Errorf("MatchIP() - phantom: %v, %v, %v", r, v, err) } + if _, err := trie.ContainedIP(net.IP([]byte{})); err == nil { + t.Error("ContainedIP() - not error") + } + if b, err := trie.ContainedIP(hostIP); b || err != nil { + t.Errorf("ContainedIP() - phantom: %v, %v", b, err) + } if _, _, err := trie.DeleteCIDR(""); err == nil { t.Error("DeleteCIDR() - not error") } @@ -50,6 +56,9 @@ func TestNet(t *testing.T) { if r, v, err := trie.MatchIP(hostIP); r == nil || r.String() != cidr || v != &cidr || err != nil { t.Errorf("MatchIP() - failed: %v, %v, %v", r, v, err) } + if b, err := trie.ContainedIP(hostIP); !b || err != nil { + t.Errorf("ContainedIP() - failed: %v, %v", b, err) + } if v, ok, err := trie.DeleteCIDR(cidr); v != &cidr || !ok || err != nil { t.Errorf("DeleteCIDR() - failed: %v, %v, %v", v, ok, err) } diff --git a/vendor/golang.org/x/net/http2/transport.go b/vendor/golang.org/x/net/http2/transport.go index e6b321f4..da91d19d 100644 --- a/vendor/golang.org/x/net/http2/transport.go +++ b/vendor/golang.org/x/net/http2/transport.go @@ -951,6 +951,9 @@ func (cc *ClientConn) awaitOpenSlotForRequest(req *http.Request) error { for { cc.lastActive = time.Now() if cc.closed || !cc.canTakeNewRequestLocked() { + if waitingForConn != nil { + close(waitingForConn) + } return errClientConnUnusable } if int64(len(cc.streams))+1 <= int64(cc.maxConcurrentStreams) {