Deps update

This commit is contained in:
Frank Denis 2018-04-25 20:23:31 +02:00
parent dd878d4c60
commit e8b183e576
12 changed files with 188 additions and 145 deletions

12
Gopkg.lock generated
View file

@ -23,7 +23,7 @@
branch = "master" branch = "master"
name = "github.com/aead/chacha20" name = "github.com/aead/chacha20"
packages = ["chacha"] packages = ["chacha"]
revision = "e0d4ab3067da29fbce5b60445bed6d54c41c3c62" revision = "c1766ed472dff2392a1a13de7b82e8f5a64ab11d"
[[projects]] [[projects]]
branch = "master" branch = "master"
@ -121,8 +121,8 @@
[[projects]] [[projects]]
name = "github.com/k-sone/critbitgo" name = "github.com/k-sone/critbitgo"
packages = ["."] packages = ["."]
revision = "1b44ffc7fc9ad8dea28251e340eadb04093c8af3" revision = "658116ef1e826b72c603cfe2091b12503f9bca43"
version = "v1.1.0" version = "v1.2.0"
[[projects]] [[projects]]
branch = "master" branch = "master"
@ -154,7 +154,7 @@
"poly1305", "poly1305",
"salsa20/salsa" "salsa20/salsa"
] ]
revision = "d6449816ce06963d9d136eee5a56fca5b0616e7e" revision = "b0697eccbea9adec5b7ba8008f4c33d98d733388"
[[projects]] [[projects]]
branch = "master" branch = "master"
@ -171,7 +171,7 @@
"ipv6", "ipv6",
"lex/httplex" "lex/httplex"
] ]
revision = "d41e8174641f662c5a2d1c7a5f9e828788eb8706" revision = "5f9ae10d9af5b1c89ae6904293b14b064d4ada23"
[[projects]] [[projects]]
branch = "master" branch = "master"
@ -183,7 +183,7 @@
"windows/svc/eventlog", "windows/svc/eventlog",
"windows/svc/mgr" "windows/svc/mgr"
] ]
revision = "b126b21c05a91c856b027c16779c12e3bf236954" revision = "79b0c6888797020a994db17c8510466c72fe75d9"
[[projects]] [[projects]]
name = "golang.org/x/text" name = "golang.org/x/text"

View file

@ -1,23 +1,22 @@
language: go language: go
go: go:
- "1.8.7" - "1.8.x"
- "1.9.4" - "1.9.x"
- "1.10" - "1.10.x"
env: env:
- ARCH=x86_64 - ARCH=x86_64
- ARCH=i686 - ARCH=i686
- TRAVIS_GOARCH=amd64
- TRAVIS_GOARCH=386
before_install:
- export GOARCH=$TRAVIS_GOARCH
branches: branches:
only: only:
- master - master
before_script:
- go get -u github.com/klauspost/asmfmt/cmd/asmfmt
script: script:
- diff -au <(gofmt -d .) <(printf "") - diff -au <(gofmt -d .) <(printf "")
- diff -au <(asmfmt -d .) <(printf "")
- go test -v ./... - go test -v ./...

View file

@ -34,7 +34,7 @@ func TestHChaCha20(t *testing.T) {
} }
if useAVX { if useAVX {
t.Log("AVX version") t.Log("AVX version")
testIncremental(t, 5, 2049) testHChaCha20(t)
useAVX = false useAVX = false
} }
if useSSSE3 { if useSSSE3 {
@ -63,7 +63,7 @@ func TestVectors(t *testing.T) {
} }
if useAVX { if useAVX {
t.Log("AVX version") t.Log("AVX version")
testIncremental(t, 5, 2049) testVectors(t)
useAVX = false useAVX = false
} }
if useSSSE3 { if useSSSE3 {

View file

@ -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) ## 1.1.0 (2016/12/29)
- Add `LongestPrefix ` and `Walk` functions - Add `LongestPrefix ` and `Walk` functions

View file

@ -236,9 +236,11 @@ func (t *Trie) Allprefixed(prefix []byte, handle func(key []byte, value interfac
p := &t.root p := &t.root
top := p top := p
if len(prefix) > 0 { if len(prefix) > 0 {
for p.internal != nil { for q := p.internal; q != nil; q = p.internal {
p = &q.child[q.direction(prefix)]
if q.offset < len(prefix) {
top = p top = p
p = &p.internal.child[p.internal.direction(prefix)] }
} }
// check prefix // check prefix

View file

@ -137,7 +137,7 @@ func TestSize(t *testing.T) {
} }
func TestAllprefixed(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) trie := buildTrie(t, keys)
elems := make([]string, 0, len(keys)) elems := make([]string, 0, len(keys))
@ -150,10 +150,10 @@ func TestAllprefixed(t *testing.T) {
if !trie.Allprefixed([]byte{}, handle) { if !trie.Allprefixed([]byte{}, handle) {
t.Error("Allprefixed() - invalid result") t.Error("Allprefixed() - invalid result")
} }
if len(elems) != 9 { if len(elems) != 10 {
t.Errorf("Allprefixed() - invalid elems length [%v]", elems) 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] { if key != elems[i] {
t.Errorf("Allprefixed() - not found [%s]", key) 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)) elems = make([]string, 0, len(keys))
handle = func(key []byte, value interface{}) bool { handle = func(key []byte, value interface{}) bool {
if k := string(key); k == value { if k := string(key); k == value {

View file

@ -97,9 +97,25 @@ func (n *Net) MatchCIDR(s string) (route *net.IPNet, value interface{}, err erro
return 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. // Return a specific route by using the longest prefix matching.
// If `ip` is invalid IP, or a route is not found, `route` is nil. // 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) { 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 var isV4 bool
ip, isV4, err = netValidateIP(ip) ip, isV4, err = netValidateIP(ip)
if err != nil { if err != nil {
@ -111,10 +127,7 @@ func (n *Net) MatchIP(ip net.IP) (route *net.IPNet, value interface{}, err error
} else { } else {
mask = mask128 mask = mask128
} }
if k, v := n.match(netIPNetToKey(ip, mask)); k != nil { k, v = n.match(netIPNetToKey(ip, mask))
route = netKeyToIPNet(k)
value = v
}
return return
} }

View file

@ -31,6 +31,12 @@ func TestNet(t *testing.T) {
if r, v, err := trie.MatchIP(hostIP); r != nil || v != nil || err != nil { if r, v, err := trie.MatchIP(hostIP); r != nil || v != nil || err != nil {
t.Errorf("MatchIP() - phantom: %v, %v, %v", r, v, err) 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 { if _, _, err := trie.DeleteCIDR(""); err == nil {
t.Error("DeleteCIDR() - not error") 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 { 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) 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 { if v, ok, err := trie.DeleteCIDR(cidr); v != &cidr || !ok || err != nil {
t.Errorf("DeleteCIDR() - failed: %v, %v, %v", v, ok, err) t.Errorf("DeleteCIDR() - failed: %v, %v, %v", v, ok, err)
} }

View file

@ -951,6 +951,9 @@ func (cc *ClientConn) awaitOpenSlotForRequest(req *http.Request) error {
for { for {
cc.lastActive = time.Now() cc.lastActive = time.Now()
if cc.closed || !cc.canTakeNewRequestLocked() { if cc.closed || !cc.canTakeNewRequestLocked() {
if waitingForConn != nil {
close(waitingForConn)
}
return errClientConnUnusable return errClientConnUnusable
} }
if int64(len(cc.streams))+1 <= int64(cc.maxConcurrentStreams) { if int64(len(cc.streams))+1 <= int64(cc.maxConcurrentStreams) {