Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mybee
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
mybee
Commits
6898125c
Commit
6898125c
authored
Jan 27, 2020
by
Svetomir Smiljkovic
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/ethersphere/bee
parents
6af55846
18b2f6bc
Changes
19
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
410 additions
and
107 deletions
+410
-107
Makefile
Makefile
+4
-3
go.sum
go.sum
+0
-29
error.go
pkg/p2p/libp2p/error.go
+26
-0
handshake.go
pkg/p2p/libp2p/internal/handshake/handshake.go
+13
-14
handshake_test.go
pkg/p2p/libp2p/internal/handshake/handshake_test.go
+204
-0
doc.go
pkg/p2p/libp2p/internal/handshake/pb/doc.go
+8
-0
handshake.pb.go
pkg/p2p/libp2p/internal/handshake/pb/handshake.pb.go
+11
-11
handshake.proto
pkg/p2p/libp2p/internal/handshake/pb/handshake.proto
+13
-0
libp2p.go
pkg/p2p/libp2p/libp2p.go
+19
-3
metrics.go
pkg/p2p/libp2p/metrics.go
+0
-1
peer.go
pkg/p2p/libp2p/peer.go
+8
-0
mock.go
pkg/p2p/mock/mock.go
+39
-9
p2p.go
pkg/p2p/p2p.go
+5
-1
protobuf.go
pkg/p2p/protobuf/protobuf.go
+1
-1
doc.go
pkg/pingpong/pb/doc.go
+8
-0
pingpong.pb.go
pkg/pingpong/pb/pingpong.pb.go
+10
-10
pingpong.proto
pkg/pingpong/pb/pingpong.proto
+1
-1
pingpong.go
pkg/pingpong/pingpong.go
+13
-16
pingpong_test.go
pkg/pingpong/pingpong_test.go
+27
-8
No files found.
Makefile
View file @
6898125c
COMMIT
?=
""
GO
?=
go
GO
?=
go
GOLANGCI_LINT
?=
golangci-lint
GOLANGCI_LINT
?=
golangci-lint
LDFLAGS
?=
-s
-w
-X
github.com/ethersphere/bee.commit
=
"
$(COMMIT)
"
LDFLAGS
?=
-s
-w
ifdef
COMMIT
LDFLAGS
+=
-X
github.com/ethersphere/bee.commit
=
"
$(COMMIT)
"
endif
.PHONY
:
all
.PHONY
:
all
all
:
build lint vet test binary
all
:
build lint vet test binary
...
...
go.sum
View file @
6898125c
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/AndreasBriese/bbloom v0.0.0-20180913140656-343706a395b7/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8=
github.com/AndreasBriese/bbloom v0.0.0-20180913140656-343706a395b7/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8=
github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8=
github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8=
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Kubuxu/go-os-helper v0.0.1/go.mod h1:N8B+I7vPCT80IcP58r50u4+gEEcsZETFUpAzWW2ep1Y=
github.com/Kubuxu/go-os-helper v0.0.1/go.mod h1:N8B+I7vPCT80IcP58r50u4+gEEcsZETFUpAzWW2ep1Y=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
github.com/alangpierce/go-forceexport v0.0.0-20160317203124-8f1d6941cd75 h1:3ILjVyslFbc4jl1w5TWuvvslFD/nDfR2H8tVaMVLrEY=
github.com/alangpierce/go-forceexport v0.0.0-20160317203124-8f1d6941cd75/go.mod h1:uAXEEpARkRhCZfEvy/y0Jcc888f9tHCc1W7/UeEtreE=
github.com/alangpierce/go-forceexport v0.0.0-20160317203124-8f1d6941cd75/go.mod h1:uAXEEpARkRhCZfEvy/y0Jcc888f9tHCc1W7/UeEtreE=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
...
@@ -50,7 +48,6 @@ github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfc
...
@@ -50,7 +48,6 @@ github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfc
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgraph-io/badger v1.5.5-0.20190226225317-8115aed38f8f/go.mod h1:VZxzAIRPHRVNRKRo6AXrX9BJegn6il06VMTZVJYCIjQ=
github.com/dgraph-io/badger v1.5.5-0.20190226225317-8115aed38f8f/go.mod h1:VZxzAIRPHRVNRKRo6AXrX9BJegn6il06VMTZVJYCIjQ=
github.com/dgraph-io/badger v1.6.0-rc1/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhYy6psNgSztDR4=
github.com/dgraph-io/badger v1.6.0-rc1/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhYy6psNgSztDR4=
...
@@ -78,11 +75,9 @@ github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls=
...
@@ -78,11 +75,9 @@ github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls=
github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6 h1:ZgQEtGgCBiWRM39fZuwSd1LwSqqSW0hOdXCYYDX0R3I=
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/mock v1.3.1 h1:qGJ6qTW+x6xX/my+8YUVl4WNpX9B7+/l2tRsHGZ7f2s=
github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0=
github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0=
...
@@ -93,12 +88,10 @@ github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8l
...
@@ -93,12 +88,10 @@ github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8l
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1 h1:Xye71clBPdm5HgqGwUkwhbynsUJZhDbS20FvLhQ2izg=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gorilla/handlers v1.4.2 h1:0QniY0USkHQ1RGCLfKxeNHK9bkDHGRYGNDFBCS+YARg=
github.com/gorilla/handlers v1.4.2 h1:0QniY0USkHQ1RGCLfKxeNHK9bkDHGRYGNDFBCS+YARg=
github.com/gorilla/handlers v1.4.2/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ=
github.com/gorilla/handlers v1.4.2/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ=
...
@@ -118,12 +111,10 @@ github.com/hashicorp/golang-lru v0.5.3 h1:YPkqC67at8FYaadspW/6uE0COsBxS2656RLEr8
...
@@ -118,12 +111,10 @@ github.com/hashicorp/golang-lru v0.5.3 h1:YPkqC67at8FYaadspW/6uE0COsBxS2656RLEr8
github.com/hashicorp/golang-lru v0.5.3/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
github.com/hashicorp/golang-lru v0.5.3/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/huin/goupnp v1.0.0 h1:wg75sLpL6DZqwHQN6E1Cfk6mtfzS45z8OV+ic+DtHRo=
github.com/huin/goupnp v1.0.0 h1:wg75sLpL6DZqwHQN6E1Cfk6mtfzS45z8OV+ic+DtHRo=
github.com/huin/goupnp v1.0.0/go.mod h1:n9v9KO1tAxYH82qOn+UTIFQDmx5n1Zxd/ClZDMX7Bnc=
github.com/huin/goupnp v1.0.0/go.mod h1:n9v9KO1tAxYH82qOn+UTIFQDmx5n1Zxd/ClZDMX7Bnc=
github.com/huin/goutil v0.0.0-20170803182201-1ca381bf3150/go.mod h1:PpLOETDnJ0o3iZrZfqZzyLl6l7F3c6L1oWn7OICBi6o=
github.com/huin/goutil v0.0.0-20170803182201-1ca381bf3150/go.mod h1:PpLOETDnJ0o3iZrZfqZzyLl6l7F3c6L1oWn7OICBi6o=
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/ipfs/go-cid v0.0.1/go.mod h1:GHWU/WuQdMPmIosc4Yn1bcCT7dSeX4lBafM7iqUPQvM=
github.com/ipfs/go-cid v0.0.1/go.mod h1:GHWU/WuQdMPmIosc4Yn1bcCT7dSeX4lBafM7iqUPQvM=
github.com/ipfs/go-cid v0.0.2/go.mod h1:GHWU/WuQdMPmIosc4Yn1bcCT7dSeX4lBafM7iqUPQvM=
github.com/ipfs/go-cid v0.0.2/go.mod h1:GHWU/WuQdMPmIosc4Yn1bcCT7dSeX4lBafM7iqUPQvM=
...
@@ -133,7 +124,6 @@ github.com/ipfs/go-cid v0.0.4/go.mod h1:4LLaPOQwmk5z9LBgQnpkivrx8BJjUyGwTXCd5Xfj
...
@@ -133,7 +124,6 @@ github.com/ipfs/go-cid v0.0.4/go.mod h1:4LLaPOQwmk5z9LBgQnpkivrx8BJjUyGwTXCd5Xfj
github.com/ipfs/go-datastore v0.0.1/go.mod h1:d4KVXhMt913cLBEI/PXAy6ko+W7e9AhyAKBGh803qeE=
github.com/ipfs/go-datastore v0.0.1/go.mod h1:d4KVXhMt913cLBEI/PXAy6ko+W7e9AhyAKBGh803qeE=
github.com/ipfs/go-datastore v0.1.0/go.mod h1:d4KVXhMt913cLBEI/PXAy6ko+W7e9AhyAKBGh803qeE=
github.com/ipfs/go-datastore v0.1.0/go.mod h1:d4KVXhMt913cLBEI/PXAy6ko+W7e9AhyAKBGh803qeE=
github.com/ipfs/go-datastore v0.1.1/go.mod h1:w38XXW9kVFNp57Zj5knbKWM2T+KOZCGDRVNdgPHtbHw=
github.com/ipfs/go-datastore v0.1.1/go.mod h1:w38XXW9kVFNp57Zj5knbKWM2T+KOZCGDRVNdgPHtbHw=
github.com/ipfs/go-detect-race v0.0.1 h1:qX/xay2W3E4Q1U7d9lNs1sU9nvguX0a7319XbyQ6cOk=
github.com/ipfs/go-detect-race v0.0.1/go.mod h1:8BNT7shDZPo99Q74BpGMK+4D8Mn4j46UU0LZ723meps=
github.com/ipfs/go-detect-race v0.0.1/go.mod h1:8BNT7shDZPo99Q74BpGMK+4D8Mn4j46UU0LZ723meps=
github.com/ipfs/go-ds-badger v0.0.2/go.mod h1:Y3QpeSFWQf6MopLTiZD+VT6IC1yZqaGmjvRcKeSGij8=
github.com/ipfs/go-ds-badger v0.0.2/go.mod h1:Y3QpeSFWQf6MopLTiZD+VT6IC1yZqaGmjvRcKeSGij8=
github.com/ipfs/go-ds-badger v0.0.5/go.mod h1:g5AuuCGmr7efyzQhLL8MzwqcauPojGPUaHzfGTzuE3s=
github.com/ipfs/go-ds-badger v0.0.5/go.mod h1:g5AuuCGmr7efyzQhLL8MzwqcauPojGPUaHzfGTzuE3s=
...
@@ -153,7 +143,6 @@ github.com/jackpal/gateway v1.0.5/go.mod h1:lTpwd4ACLXmpyiCTRtfiNyVnUmqT9RivzCDQ
...
@@ -153,7 +143,6 @@ github.com/jackpal/gateway v1.0.5/go.mod h1:lTpwd4ACLXmpyiCTRtfiNyVnUmqT9RivzCDQ
github.com/jackpal/go-nat-pmp v1.0.1 h1:i0LektDkO1QlrTm/cSuP+PyBCDnYvjPLGl4LdWEMiaA=
github.com/jackpal/go-nat-pmp v1.0.1 h1:i0LektDkO1QlrTm/cSuP+PyBCDnYvjPLGl4LdWEMiaA=
github.com/jackpal/go-nat-pmp v1.0.1/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc=
github.com/jackpal/go-nat-pmp v1.0.1/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc=
github.com/jbenet/go-cienv v0.0.0-20150120210510-1bb1476777ec/go.mod h1:rGaEvXB4uRSZMmzKNLoXvTu1sfx+1kv/DojUlPrSZGs=
github.com/jbenet/go-cienv v0.0.0-20150120210510-1bb1476777ec/go.mod h1:rGaEvXB4uRSZMmzKNLoXvTu1sfx+1kv/DojUlPrSZGs=
github.com/jbenet/go-cienv v0.1.0 h1:Vc/s0QbQtoxX8MwwSLWWh+xNNZvM3Lw7NsTcHrvvhMc=
github.com/jbenet/go-cienv v0.1.0/go.mod h1:TqNnHUmJgXau0nCzC7kXWeotg3J9W34CUv5Djy1+FlA=
github.com/jbenet/go-cienv v0.1.0/go.mod h1:TqNnHUmJgXau0nCzC7kXWeotg3J9W34CUv5Djy1+FlA=
github.com/jbenet/go-temp-err-catcher v0.0.0-20150120210811-aac704a3f4f2 h1:vhC1OXXiT9R2pczegwz6moDvuRpggaroAXhPIseh57A=
github.com/jbenet/go-temp-err-catcher v0.0.0-20150120210811-aac704a3f4f2 h1:vhC1OXXiT9R2pczegwz6moDvuRpggaroAXhPIseh57A=
github.com/jbenet/go-temp-err-catcher v0.0.0-20150120210811-aac704a3f4f2/go.mod h1:8GXXJV31xl8whumTzdZsTt3RnUIiPqzkyf7mxToRCMs=
github.com/jbenet/go-temp-err-catcher v0.0.0-20150120210811-aac704a3f4f2/go.mod h1:8GXXJV31xl8whumTzdZsTt3RnUIiPqzkyf7mxToRCMs=
...
@@ -166,7 +155,6 @@ github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22
...
@@ -166,7 +155,6 @@ github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22
github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ=
github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/kami-zh/go-capturer v0.0.0-20171211120116-e492ea43421d/go.mod h1:P2viExyCEfeWGU259JnaQ34Inuec4R38JCyBx2edgD0=
github.com/kami-zh/go-capturer v0.0.0-20171211120116-e492ea43421d/go.mod h1:P2viExyCEfeWGU259JnaQ34Inuec4R38JCyBx2edgD0=
...
@@ -175,16 +163,13 @@ github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvW
...
@@ -175,16 +163,13 @@ github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvW
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4=
github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4=
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/koron/go-ssdp v0.0.0-20180514024734-4a0ed625a78b/go.mod h1:5Ky9EC2xfoUKUor0Hjgi2BJhCSXJfMOFlmyYrVKGQMk=
github.com/koron/go-ssdp v0.0.0-20180514024734-4a0ed625a78b/go.mod h1:5Ky9EC2xfoUKUor0Hjgi2BJhCSXJfMOFlmyYrVKGQMk=
github.com/koron/go-ssdp v0.0.0-20191105050749-2e1c40ed0b5d h1:68u9r4wEvL3gYg2jvAOgROwZ3H+Y3hIDk4tbbmIjcYQ=
github.com/koron/go-ssdp v0.0.0-20191105050749-2e1c40ed0b5d h1:68u9r4wEvL3gYg2jvAOgROwZ3H+Y3hIDk4tbbmIjcYQ=
github.com/koron/go-ssdp v0.0.0-20191105050749-2e1c40ed0b5d/go.mod h1:5Ky9EC2xfoUKUor0Hjgi2BJhCSXJfMOFlmyYrVKGQMk=
github.com/koron/go-ssdp v0.0.0-20191105050749-2e1c40ed0b5d/go.mod h1:5Ky9EC2xfoUKUor0Hjgi2BJhCSXJfMOFlmyYrVKGQMk=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/libp2p/go-addr-util v0.0.1 h1:TpTQm9cXVRVSKsYbgQ7GKc3KbbHVTnbostgGaDEP+88=
github.com/libp2p/go-addr-util v0.0.1 h1:TpTQm9cXVRVSKsYbgQ7GKc3KbbHVTnbostgGaDEP+88=
github.com/libp2p/go-addr-util v0.0.1/go.mod h1:4ac6O7n9rIAKB1dnd+s8IbbMXkt+oBpzX4/+RACcnlQ=
github.com/libp2p/go-addr-util v0.0.1/go.mod h1:4ac6O7n9rIAKB1dnd+s8IbbMXkt+oBpzX4/+RACcnlQ=
...
@@ -208,7 +193,6 @@ github.com/libp2p/go-libp2p-autonat v0.1.1/go.mod h1:OXqkeGOY2xJVWKAGV2inNF5aKN/
...
@@ -208,7 +193,6 @@ github.com/libp2p/go-libp2p-autonat v0.1.1/go.mod h1:OXqkeGOY2xJVWKAGV2inNF5aKN/
github.com/libp2p/go-libp2p-autonat-svc v0.1.0 h1:28IM7iWMDclZeVkpiFQaWVANwXwE7zLlpbnS7yXxrfs=
github.com/libp2p/go-libp2p-autonat-svc v0.1.0 h1:28IM7iWMDclZeVkpiFQaWVANwXwE7zLlpbnS7yXxrfs=
github.com/libp2p/go-libp2p-autonat-svc v0.1.0/go.mod h1:fqi8Obl/z3R4PFVLm8xFtZ6PBL9MlV/xumymRFkKq5A=
github.com/libp2p/go-libp2p-autonat-svc v0.1.0/go.mod h1:fqi8Obl/z3R4PFVLm8xFtZ6PBL9MlV/xumymRFkKq5A=
github.com/libp2p/go-libp2p-blankhost v0.1.1/go.mod h1:pf2fvdLJPsC1FsVrNP3DUUvMzUts2dsLLBEpo1vW1ro=
github.com/libp2p/go-libp2p-blankhost v0.1.1/go.mod h1:pf2fvdLJPsC1FsVrNP3DUUvMzUts2dsLLBEpo1vW1ro=
github.com/libp2p/go-libp2p-blankhost v0.1.4 h1:I96SWjR4rK9irDHcHq3XHN6hawCRTPUADzkJacgZLvk=
github.com/libp2p/go-libp2p-blankhost v0.1.4/go.mod h1:oJF0saYsAXQCSfDq254GMNmLNz6ZTHTOvtF4ZydUvwU=
github.com/libp2p/go-libp2p-blankhost v0.1.4/go.mod h1:oJF0saYsAXQCSfDq254GMNmLNz6ZTHTOvtF4ZydUvwU=
github.com/libp2p/go-libp2p-circuit v0.1.0/go.mod h1:Ahq4cY3V9VJcHcn1SBXjr78AbFkZeIRmfunbA7pmFh8=
github.com/libp2p/go-libp2p-circuit v0.1.0/go.mod h1:Ahq4cY3V9VJcHcn1SBXjr78AbFkZeIRmfunbA7pmFh8=
github.com/libp2p/go-libp2p-circuit v0.1.4 h1:Phzbmrg3BkVzbqd4ZZ149JxCuUWu2wZcXf/Kr6hZJj8=
github.com/libp2p/go-libp2p-circuit v0.1.4 h1:Phzbmrg3BkVzbqd4ZZ149JxCuUWu2wZcXf/Kr6hZJj8=
...
@@ -254,7 +238,6 @@ github.com/libp2p/go-libp2p-testing v0.0.2/go.mod h1:gvchhf3FQOtBdr+eFUABet5a4MB
...
@@ -254,7 +238,6 @@ github.com/libp2p/go-libp2p-testing v0.0.2/go.mod h1:gvchhf3FQOtBdr+eFUABet5a4MB
github.com/libp2p/go-libp2p-testing v0.0.3/go.mod h1:gvchhf3FQOtBdr+eFUABet5a4MBLK8jM3V4Zghvmi+E=
github.com/libp2p/go-libp2p-testing v0.0.3/go.mod h1:gvchhf3FQOtBdr+eFUABet5a4MBLK8jM3V4Zghvmi+E=
github.com/libp2p/go-libp2p-testing v0.0.4/go.mod h1:gvchhf3FQOtBdr+eFUABet5a4MBLK8jM3V4Zghvmi+E=
github.com/libp2p/go-libp2p-testing v0.0.4/go.mod h1:gvchhf3FQOtBdr+eFUABet5a4MBLK8jM3V4Zghvmi+E=
github.com/libp2p/go-libp2p-testing v0.1.0/go.mod h1:xaZWMJrPUM5GlDBxCeGUi7kI4eqnjVyavGroI2nxEM0=
github.com/libp2p/go-libp2p-testing v0.1.0/go.mod h1:xaZWMJrPUM5GlDBxCeGUi7kI4eqnjVyavGroI2nxEM0=
github.com/libp2p/go-libp2p-testing v0.1.1 h1:U03z3HnGI7Ni8Xx6ONVZvUFOAzWYmolWf5W5jAOPNmU=
github.com/libp2p/go-libp2p-testing v0.1.1/go.mod h1:xaZWMJrPUM5GlDBxCeGUi7kI4eqnjVyavGroI2nxEM0=
github.com/libp2p/go-libp2p-testing v0.1.1/go.mod h1:xaZWMJrPUM5GlDBxCeGUi7kI4eqnjVyavGroI2nxEM0=
github.com/libp2p/go-libp2p-tls v0.1.1/go.mod h1:wZfuewxOndz5RTnCAxFliGjvYSDA40sKitV4c50uI1M=
github.com/libp2p/go-libp2p-tls v0.1.1/go.mod h1:wZfuewxOndz5RTnCAxFliGjvYSDA40sKitV4c50uI1M=
github.com/libp2p/go-libp2p-tls v0.1.2 h1:H96DWm11fO3+LF6fgLUfK/AtD8350RuMluFeeYXS01k=
github.com/libp2p/go-libp2p-tls v0.1.2 h1:H96DWm11fO3+LF6fgLUfK/AtD8350RuMluFeeYXS01k=
...
@@ -278,7 +261,6 @@ github.com/libp2p/go-nat v0.0.4 h1:KbizNnq8YIf7+Hn7+VFL/xE0eDrkPru2zIO9NMwL8UQ=
...
@@ -278,7 +261,6 @@ github.com/libp2p/go-nat v0.0.4 h1:KbizNnq8YIf7+Hn7+VFL/xE0eDrkPru2zIO9NMwL8UQ=
github.com/libp2p/go-nat v0.0.4/go.mod h1:Nmw50VAvKuk38jUBcmNh6p9lUJLoODbJRvYAa/+KSDo=
github.com/libp2p/go-nat v0.0.4/go.mod h1:Nmw50VAvKuk38jUBcmNh6p9lUJLoODbJRvYAa/+KSDo=
github.com/libp2p/go-openssl v0.0.2/go.mod h1:v8Zw2ijCSWBQi8Pq5GAixw6DbFfa9u6VIYDXnvOXkc0=
github.com/libp2p/go-openssl v0.0.2/go.mod h1:v8Zw2ijCSWBQi8Pq5GAixw6DbFfa9u6VIYDXnvOXkc0=
github.com/libp2p/go-openssl v0.0.3/go.mod h1:unDrJpgy3oFr+rqXsarWifmJuNnJR4chtO1HmaZjggc=
github.com/libp2p/go-openssl v0.0.3/go.mod h1:unDrJpgy3oFr+rqXsarWifmJuNnJR4chtO1HmaZjggc=
github.com/libp2p/go-openssl v0.0.4 h1:d27YZvLoTyMhIN4njrkr8zMDOM4lfpHIp6A+TK9fovg=
github.com/libp2p/go-openssl v0.0.4/go.mod h1:unDrJpgy3oFr+rqXsarWifmJuNnJR4chtO1HmaZjggc=
github.com/libp2p/go-openssl v0.0.4/go.mod h1:unDrJpgy3oFr+rqXsarWifmJuNnJR4chtO1HmaZjggc=
github.com/libp2p/go-reuseport v0.0.1 h1:7PhkfH73VXfPJYKQ6JwS5I/eVcoyYi9IMNGc6FWpFLw=
github.com/libp2p/go-reuseport v0.0.1 h1:7PhkfH73VXfPJYKQ6JwS5I/eVcoyYi9IMNGc6FWpFLw=
github.com/libp2p/go-reuseport v0.0.1/go.mod h1:jn6RmB1ufnQwl0Q1f+YxAj8isJgDCQzaaxIFYDhcYEA=
github.com/libp2p/go-reuseport v0.0.1/go.mod h1:jn6RmB1ufnQwl0Q1f+YxAj8isJgDCQzaaxIFYDhcYEA=
...
@@ -375,11 +357,9 @@ github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn
...
@@ -375,11 +357,9 @@ github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.11.0 h1:JAKSXpt1YjtLA7YpPiqO9ss6sNXEsPfSGdwN0UHqzrw=
github.com/onsi/ginkgo v1.11.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.11.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/onsi/gomega v1.8.1 h1:C5Dqfs/LeauYDX0jJXIe2SWmwCbGzx9yF8C8xy3Lh34=
github.com/onsi/gomega v1.8.1/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA=
github.com/onsi/gomega v1.8.1/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA=
github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsqf19k25Ur8rU=
github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsqf19k25Ur8rU=
...
@@ -389,7 +369,6 @@ github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/9
...
@@ -389,7 +369,6 @@ github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/9
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso=
github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso=
...
@@ -419,14 +398,11 @@ github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR
...
@@ -419,14 +398,11 @@ github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/smola/gocompat v0.2.0/go.mod h1:1B0MlxbmoZNo3h8guHp8HztB3BSYR5itql9qtVc0ypY=
github.com/smola/gocompat v0.2.0/go.mod h1:1B0MlxbmoZNo3h8guHp8HztB3BSYR5itql9qtVc0ypY=
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
github.com/spacemonkeygo/openssl v0.0.0-20181017203307-c2dcc5cca94a/go.mod h1:7AyxJNCJ7SBZ1MfVQCWD6Uqo2oubI2Eq2y2eqf+A5r0=
github.com/spacemonkeygo/openssl v0.0.0-20181017203307-c2dcc5cca94a/go.mod h1:7AyxJNCJ7SBZ1MfVQCWD6Uqo2oubI2Eq2y2eqf+A5r0=
github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572 h1:RC6RW7j+1+HkWaX/Yh71Ee5ZHaHYt7ZP4sQgUrm6cDU=
github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572/go.mod h1:w0SWMsp6j9O/dk4/ZpIhL+3CkG8ofA2vuv7k+ltqUMc=
github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572/go.mod h1:w0SWMsp6j9O/dk4/ZpIhL+3CkG8ofA2vuv7k+ltqUMc=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI=
github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI=
...
@@ -449,7 +425,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
...
@@ -449,7 +425,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
...
@@ -568,7 +543,6 @@ golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3
...
@@ -568,7 +543,6 @@ golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3
golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
...
@@ -587,9 +561,7 @@ gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLks
...
@@ -587,9 +561,7 @@ gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLks
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod h1:m7x9LTH6d71AHyAX77c9yqWCCa3UKHcVEj9y7hAtKDk=
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod h1:m7x9LTH6d71AHyAX77c9yqWCCa3UKHcVEj9y7hAtKDk=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno=
gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno=
gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
...
@@ -598,7 +570,6 @@ gopkg.in/mail.v2 v2.3.1/go.mod h1:htwXN1Qh09vZJ1NVKxQqHPBaCBbzKhp5GzuJEA4VJWw=
...
@@ -598,7 +570,6 @@ gopkg.in/mail.v2 v2.3.1/go.mod h1:htwXN1Qh09vZJ1NVKxQqHPBaCBbzKhp5GzuJEA4VJWw=
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
gopkg.in/src-d/go-cli.v0 v0.0.0-20181105080154-d492247bbc0d/go.mod h1:z+K8VcOYVYcSwSjGebuDL6176A1XskgbtNl64NSg+n8=
gopkg.in/src-d/go-cli.v0 v0.0.0-20181105080154-d492247bbc0d/go.mod h1:z+K8VcOYVYcSwSjGebuDL6176A1XskgbtNl64NSg+n8=
gopkg.in/src-d/go-log.v1 v1.0.1/go.mod h1:GN34hKP0g305ysm2/hctJ0Y8nWP3zxXXJ8GFabTyABE=
gopkg.in/src-d/go-log.v1 v1.0.1/go.mod h1:GN34hKP0g305ysm2/hctJ0Y8nWP3zxXXJ8GFabTyABE=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
...
...
pkg/p2p/libp2p/error.go
0 → 100644
View file @
6898125c
// Copyright 2020 The Swarm Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
libp2p
// This error is handled specially by libp2p
// If returned by specific protocol handler it causes peer disconnect
type
disconnectError
struct
{
err
error
}
// Disconnect wraps error and creates a special error that is treated specially by libp2p
// It causes peer disconnect
func
Disconnect
(
err
error
)
error
{
return
&
disconnectError
{
err
:
err
,
}
}
// Unwrap returns an underlying error
func
(
e
*
disconnectError
)
Unwrap
()
error
{
return
e
.
err
}
// Error implements function of the standard go error interface
func
(
w
*
disconnectError
)
Error
()
string
{
return
w
.
err
.
Error
()
}
pkg/p2p/libp2p/internal/handshake/handshake.go
View file @
6898125c
...
@@ -2,14 +2,13 @@
...
@@ -2,14 +2,13 @@
// Use of this source code is governed by a BSD-style
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// license that can be found in the LICENSE file.
//go:generate sh -c "protoc -I . -I \"$(go list -f '{{ .Dir }}' -m github.com/gogo/protobuf)/protobuf\" --gogofaster_out=. handshake.proto"
package
handshake
package
handshake
import
(
import
(
"fmt"
"fmt"
"github.com/ethersphere/bee/pkg/p2p"
"github.com/ethersphere/bee/pkg/p2p"
"github.com/ethersphere/bee/pkg/p2p/libp2p/internal/handshake/pb"
"github.com/ethersphere/bee/pkg/p2p/protobuf"
"github.com/ethersphere/bee/pkg/p2p/protobuf"
)
)
...
@@ -39,20 +38,20 @@ type Logger interface {
...
@@ -39,20 +38,20 @@ type Logger interface {
func
(
s
*
Service
)
Handshake
(
stream
p2p
.
Stream
)
(
i
*
Info
,
err
error
)
{
func
(
s
*
Service
)
Handshake
(
stream
p2p
.
Stream
)
(
i
*
Info
,
err
error
)
{
w
,
r
:=
protobuf
.
NewWriterAndReader
(
stream
)
w
,
r
:=
protobuf
.
NewWriterAndReader
(
stream
)
var
resp
ShakeHand
var
resp
pb
.
ShakeHand
if
err
:=
w
.
WriteMsg
(
&
ShakeHand
{
if
err
:=
w
.
WriteMsg
(
&
pb
.
ShakeHand
{
Address
:
s
.
overlay
,
Address
:
s
.
overlay
,
NetworkID
:
s
.
networkID
,
NetworkID
:
s
.
networkID
,
});
err
!=
nil
{
});
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"handshake
handler:
write message: %w"
,
err
)
return
nil
,
fmt
.
Errorf
(
"handshake write message: %w"
,
err
)
}
}
s
.
logger
.
Tracef
(
"handshake
:
sent request %s"
,
s
.
overlay
)
s
.
logger
.
Tracef
(
"handshake sent request %s"
,
s
.
overlay
)
if
err
:=
r
.
ReadMsg
(
&
resp
);
err
!=
nil
{
if
err
:=
r
.
ReadMsg
(
&
resp
);
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"handshake
handler:
read message: %w"
,
err
)
return
nil
,
fmt
.
Errorf
(
"handshake read message: %w"
,
err
)
}
}
s
.
logger
.
Tracef
(
"handshake
:
read response: %s"
,
resp
.
Address
)
s
.
logger
.
Tracef
(
"handshake read response: %s"
,
resp
.
Address
)
return
&
Info
{
return
&
Info
{
Address
:
resp
.
Address
,
Address
:
resp
.
Address
,
NetworkID
:
resp
.
NetworkID
,
NetworkID
:
resp
.
NetworkID
,
...
@@ -64,20 +63,20 @@ func (s *Service) Handle(stream p2p.Stream) (i *Info, err error) {
...
@@ -64,20 +63,20 @@ func (s *Service) Handle(stream p2p.Stream) (i *Info, err error) {
w
,
r
:=
protobuf
.
NewWriterAndReader
(
stream
)
w
,
r
:=
protobuf
.
NewWriterAndReader
(
stream
)
defer
stream
.
Close
()
defer
stream
.
Close
()
var
req
ShakeHand
var
req
pb
.
ShakeHand
if
err
:=
r
.
ReadMsg
(
&
req
);
err
!=
nil
{
if
err
:=
r
.
ReadMsg
(
&
req
);
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"read message: %w"
,
err
)
return
nil
,
fmt
.
Errorf
(
"
handshake handler
read message: %w"
,
err
)
}
}
s
.
logger
.
Tracef
(
"handshake
:
received request %s"
,
req
.
Address
)
s
.
logger
.
Tracef
(
"handshake
handler
received request %s"
,
req
.
Address
)
if
err
:=
w
.
WriteMsg
(
&
ShakeHand
{
if
err
:=
w
.
WriteMsg
(
&
pb
.
ShakeHand
{
Address
:
s
.
overlay
,
Address
:
s
.
overlay
,
NetworkID
:
s
.
networkID
,
NetworkID
:
s
.
networkID
,
});
err
!=
nil
{
});
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"write message: %w"
,
err
)
return
nil
,
fmt
.
Errorf
(
"
handshake handler
write message: %w"
,
err
)
}
}
s
.
logger
.
Tracef
(
"handshake
:
handled response: %s"
,
s
.
overlay
)
s
.
logger
.
Tracef
(
"handshake handled response: %s"
,
s
.
overlay
)
return
&
Info
{
return
&
Info
{
Address
:
req
.
Address
,
Address
:
req
.
Address
,
NetworkID
:
req
.
NetworkID
,
NetworkID
:
req
.
NetworkID
,
...
...
pkg/p2p/libp2p/internal/handshake/handshake_test.go
0 → 100644
View file @
6898125c
// Copyright 2020 The Swarm Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
handshake
import
(
"bytes"
"errors"
"fmt"
"io/ioutil"
"testing"
"github.com/ethersphere/bee/pkg/logging"
"github.com/ethersphere/bee/pkg/p2p/libp2p/internal/handshake/pb"
"github.com/ethersphere/bee/pkg/p2p/protobuf"
)
type
StreamMock
struct
{
readBuffer
*
bytes
.
Buffer
writeBuffer
*
bytes
.
Buffer
readError
error
writeError
error
}
func
(
s
*
StreamMock
)
Read
(
p
[]
byte
)
(
n
int
,
err
error
)
{
if
s
.
readError
!=
nil
{
return
0
,
s
.
readError
}
return
s
.
readBuffer
.
Read
(
p
)
}
func
(
s
*
StreamMock
)
Write
(
p
[]
byte
)
(
n
int
,
err
error
)
{
if
s
.
writeError
!=
nil
{
return
0
,
s
.
writeError
}
return
s
.
writeBuffer
.
Write
(
p
)
}
func
(
s
*
StreamMock
)
Close
()
error
{
return
nil
}
func
TestHandshake
(
t
*
testing
.
T
)
{
logger
:=
logging
.
New
(
ioutil
.
Discard
)
info
:=
Info
{
Address
:
"node1"
,
NetworkID
:
0
,
Light
:
false
,
}
handshakeService
:=
New
(
info
.
Address
,
info
.
NetworkID
,
logger
)
t
.
Run
(
"OK"
,
func
(
t
*
testing
.
T
)
{
expectedInfo
:=
Info
{
Address
:
"node2"
,
NetworkID
:
1
,
Light
:
false
,
}
var
buffer1
bytes
.
Buffer
var
buffer2
bytes
.
Buffer
stream1
:=
&
StreamMock
{
readBuffer
:
&
buffer1
,
writeBuffer
:
&
buffer2
}
stream2
:=
&
StreamMock
{
readBuffer
:
&
buffer2
,
writeBuffer
:
&
buffer1
}
w
,
_
:=
protobuf
.
NewWriterAndReader
(
stream2
)
if
err
:=
w
.
WriteMsg
(
&
pb
.
ShakeHand
{
Address
:
expectedInfo
.
Address
,
NetworkID
:
expectedInfo
.
NetworkID
,
Light
:
expectedInfo
.
Light
,
});
err
!=
nil
{
t
.
Fatal
(
err
)
}
res
,
err
:=
handshakeService
.
Handshake
(
stream1
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
*
res
!=
expectedInfo
{
t
.
Fatalf
(
"got %+v, expected %+v"
,
res
,
info
)
}
})
t
.
Run
(
"ERROR - write error "
,
func
(
t
*
testing
.
T
)
{
testErr
:=
errors
.
New
(
"test error"
)
expectedErr
:=
fmt
.
Errorf
(
"handshake write message: %w"
,
testErr
)
stream
:=
&
StreamMock
{
writeError
:
testErr
}
res
,
err
:=
handshakeService
.
Handshake
(
stream
)
if
err
==
nil
||
err
.
Error
()
!=
expectedErr
.
Error
()
{
t
.
Fatal
(
"expected:"
,
expectedErr
,
"got:"
,
err
)
}
if
res
!=
nil
{
t
.
Fatal
(
"handshake returned non-nil res"
)
}
})
t
.
Run
(
"ERROR - read error "
,
func
(
t
*
testing
.
T
)
{
testErr
:=
errors
.
New
(
"test error"
)
expectedErr
:=
fmt
.
Errorf
(
"handshake read message: %w"
,
testErr
)
stream
:=
&
StreamMock
{
writeBuffer
:
&
bytes
.
Buffer
{},
readError
:
testErr
}
res
,
err
:=
handshakeService
.
Handshake
(
stream
)
if
err
==
nil
||
err
.
Error
()
!=
expectedErr
.
Error
()
{
t
.
Fatal
(
"expected:"
,
expectedErr
,
"got:"
,
err
)
}
if
res
!=
nil
{
t
.
Fatal
(
"handshake returned non-nil res"
)
}
})
}
func
TestHandle
(
t
*
testing
.
T
)
{
nodeInfo
:=
Info
{
Address
:
"node1"
,
NetworkID
:
0
,
Light
:
false
,
}
logger
:=
logging
.
New
(
ioutil
.
Discard
)
handshakeService
:=
New
(
nodeInfo
.
Address
,
nodeInfo
.
NetworkID
,
logger
)
t
.
Run
(
"OK"
,
func
(
t
*
testing
.
T
)
{
node2Info
:=
Info
{
Address
:
"node2"
,
NetworkID
:
1
,
Light
:
false
,
}
var
buffer1
bytes
.
Buffer
var
buffer2
bytes
.
Buffer
stream1
:=
&
StreamMock
{
readBuffer
:
&
buffer1
,
writeBuffer
:
&
buffer2
}
stream2
:=
&
StreamMock
{
readBuffer
:
&
buffer2
,
writeBuffer
:
&
buffer1
}
w
,
_
:=
protobuf
.
NewWriterAndReader
(
stream2
)
if
err
:=
w
.
WriteMsg
(
&
pb
.
ShakeHand
{
Address
:
node2Info
.
Address
,
NetworkID
:
node2Info
.
NetworkID
,
Light
:
node2Info
.
Light
,
});
err
!=
nil
{
t
.
Fatal
(
err
)
}
res
,
err
:=
handshakeService
.
Handle
(
stream1
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
*
res
!=
node2Info
{
t
.
Fatalf
(
"got %+v, expected %+v"
,
res
,
node2Info
)
}
_
,
r
:=
protobuf
.
NewWriterAndReader
(
stream2
)
var
got
pb
.
ShakeHand
if
err
:=
r
.
ReadMsg
(
&
got
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
nodeInfo
!=
Info
(
got
)
{
t
.
Fatalf
(
"got %+v, expected %+v"
,
got
,
node2Info
)
}
})
t
.
Run
(
"ERROR - read error "
,
func
(
t
*
testing
.
T
)
{
testErr
:=
errors
.
New
(
"test error"
)
expectedErr
:=
fmt
.
Errorf
(
"handshake handler read message: %w"
,
testErr
)
stream
:=
&
StreamMock
{
readError
:
testErr
}
res
,
err
:=
handshakeService
.
Handle
(
stream
)
if
err
==
nil
||
err
.
Error
()
!=
expectedErr
.
Error
()
{
t
.
Fatal
(
"expected:"
,
expectedErr
,
"got:"
,
err
)
}
if
res
!=
nil
{
t
.
Fatal
(
"handle returned non-nil res"
)
}
})
t
.
Run
(
"ERROR - write error "
,
func
(
t
*
testing
.
T
)
{
testErr
:=
errors
.
New
(
"test error"
)
expectedErr
:=
fmt
.
Errorf
(
"handshake handler write message: %w"
,
testErr
)
var
buffer
bytes
.
Buffer
stream
:=
&
StreamMock
{
readBuffer
:
&
buffer
,
writeBuffer
:
&
buffer
}
w
,
_
:=
protobuf
.
NewWriterAndReader
(
stream
)
if
err
:=
w
.
WriteMsg
(
&
pb
.
ShakeHand
{
Address
:
"node1"
,
NetworkID
:
0
,
Light
:
false
,
});
err
!=
nil
{
t
.
Fatal
(
err
)
}
stream
.
writeError
=
testErr
res
,
err
:=
handshakeService
.
Handle
(
stream
)
if
err
==
nil
||
err
.
Error
()
!=
expectedErr
.
Error
()
{
t
.
Fatal
(
"expected:"
,
expectedErr
,
"got:"
,
err
)
}
if
res
!=
nil
{
t
.
Fatal
(
"handshake returned non-nil res"
)
}
})
}
pkg/p2p/libp2p/internal/handshake/pb/doc.go
0 → 100644
View file @
6898125c
// Copyright 2020 The Swarm Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:generate sh -c "protoc -I . -I \"$(go list -f '{{ .Dir }}' -m github.com/gogo/protobuf)/protobuf\" --gogofaster_out=. handshake.proto"
// Package pb holds only Protocol Buffer definitions and generated code.
package
pb
pkg/p2p/libp2p/internal/handshake/handshake.pb.go
→
pkg/p2p/libp2p/internal/handshake/
pb/
handshake.pb.go
View file @
6898125c
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: handshake.proto
// source: handshake.proto
package
handshake
package
pb
import
(
import
(
fmt
"fmt"
fmt
"fmt"
...
@@ -83,7 +83,7 @@ func (m *ShakeHand) GetLight() bool {
...
@@ -83,7 +83,7 @@ func (m *ShakeHand) GetLight() bool {
}
}
func
init
()
{
func
init
()
{
proto
.
RegisterType
((
*
ShakeHand
)(
nil
),
"
handshake
.ShakeHand"
)
proto
.
RegisterType
((
*
ShakeHand
)(
nil
),
"
pb
.ShakeHand"
)
}
}
func
init
()
{
proto
.
RegisterFile
(
"handshake.proto"
,
fileDescriptor_a77305914d5d202f
)
}
func
init
()
{
proto
.
RegisterFile
(
"handshake.proto"
,
fileDescriptor_a77305914d5d202f
)
}
...
@@ -91,15 +91,15 @@ func init() { proto.RegisterFile("handshake.proto", fileDescriptor_a77305914d5d2
...
@@ -91,15 +91,15 @@ func init() { proto.RegisterFile("handshake.proto", fileDescriptor_a77305914d5d2
var
fileDescriptor_a77305914d5d202f
=
[]
byte
{
var
fileDescriptor_a77305914d5d202f
=
[]
byte
{
// 148 bytes of a gzipped FileDescriptorProto
// 148 bytes of a gzipped FileDescriptorProto
0x1f
,
0x8b
,
0x08
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x02
,
0xff
,
0xe2
,
0xe2
,
0xcf
,
0x48
,
0xcc
,
0x4b
,
0x1f
,
0x8b
,
0x08
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x02
,
0xff
,
0xe2
,
0xe2
,
0xcf
,
0x48
,
0xcc
,
0x4b
,
0x29
,
0xce
,
0x48
,
0xcc
,
0x4e
,
0xd5
,
0x2b
,
0x28
,
0xca
,
0x2f
,
0xc9
,
0x17
,
0x
e2
,
0x84
,
0x0b
,
0x28
,
0x29
,
0xce
,
0x48
,
0xcc
,
0x4e
,
0xd5
,
0x2b
,
0x28
,
0xca
,
0x2f
,
0xc9
,
0x17
,
0x
62
,
0x2a
,
0x48
,
0x52
,
0x
45
,
0x72
,
0x71
,
0x06
,
0x83
,
0x18
,
0x1e
,
0x89
,
0x79
,
0x29
,
0x42
,
0x12
,
0x5c
,
0xec
,
0x8e
,
0x29
,
0x
8a
,
0xe4
,
0xe2
,
0x0c
,
0x06
,
0x09
,
0x79
,
0x24
,
0xe6
,
0xa5
,
0x08
,
0x49
,
0x70
,
0xb1
,
0x3b
,
0xa6
,
0x
29
,
0x45
,
0xa9
,
0xc5
,
0xc5
,
0x12
,
0x8c
,
0x0a
,
0x8c
,
0x1a
,
0x9c
,
0x41
,
0x30
,
0xae
,
0x90
,
0x0c
,
0x
a4
,
0x14
,
0xa5
,
0x16
,
0x17
,
0x4b
,
0x30
,
0x2a
,
0x30
,
0x6a
,
0x70
,
0x06
,
0xc1
,
0xb8
,
0x42
,
0x32
,
0x
17
,
0xa7
,
0x5f
,
0x6a
,
0x49
,
0x79
,
0x7e
,
0x51
,
0xb6
,
0xa7
,
0x8b
,
0x04
,
0x93
,
0x02
,
0xa3
,
0x06
,
0x
5c
,
0x9c
,
0x7e
,
0xa9
,
0x25
,
0xe5
,
0xf9
,
0x45
,
0xd9
,
0x9e
,
0x2e
,
0x12
,
0x4c
,
0x0a
,
0x8c
,
0x1a
,
0x
6b
,
0x10
,
0x42
,
0x40
,
0x48
,
0x84
,
0x8b
,
0xd5
,
0x27
,
0x33
,
0x3d
,
0xa3
,
0x44
,
0x82
,
0x59
,
0x81
,
0x
ac
,
0x41
,
0x08
,
0x01
,
0x21
,
0x11
,
0x2e
,
0x56
,
0x9f
,
0xcc
,
0xf4
,
0x8c
,
0x12
,
0x09
,
0x66
,
0x05
,
0x
51
,
0x83
,
0x23
,
0x08
,
0xc2
,
0x71
,
0x92
,
0x38
,
0xf1
,
0x48
,
0x8e
,
0xf1
,
0xc2
,
0x23
,
0x39
,
0xc6
,
0x
46
,
0x0d
,
0x8e
,
0x20
,
0x08
,
0xc7
,
0x49
,
0xe2
,
0xc4
,
0x23
,
0x39
,
0xc6
,
0x0b
,
0x8f
,
0xe4
,
0x18
,
0x
07
,
0x8f
,
0xe4
,
0x18
,
0x27
,
0x3c
,
0x96
,
0x63
,
0xb8
,
0xf0
,
0x58
,
0x8e
,
0xe1
,
0xc6
,
0x63
,
0x39
,
0x
1f
,
0x3c
,
0x92
,
0x63
,
0x9c
,
0xf0
,
0x58
,
0x8e
,
0xe1
,
0xc2
,
0x63
,
0x39
,
0x86
,
0x1b
,
0x8f
,
0xe5
,
0x
86
,
0x24
,
0x36
,
0xb0
,
0x33
,
0x8c
,
0x01
,
0x01
,
0x00
,
0x00
,
0xff
,
0xff
,
0x62
,
0x1c
,
0xa2
,
0x06
,
0x
18
,
0x92
,
0xd8
,
0xc0
,
0xf6
,
0x1b
,
0x03
,
0x02
,
0x00
,
0x00
,
0xff
,
0xff
,
0x80
,
0x1a
,
0x2a
,
0xd7
,
0x9
9
,
0x00
,
0x00
,
0x00
,
0x9
2
,
0x00
,
0x00
,
0x00
,
}
}
func
(
m
*
ShakeHand
)
Marshal
()
(
dAtA
[]
byte
,
err
error
)
{
func
(
m
*
ShakeHand
)
Marshal
()
(
dAtA
[]
byte
,
err
error
)
{
...
...
pkg/p2p/libp2p/internal/handshake/handshake.proto
→
pkg/p2p/libp2p/internal/handshake/
pb/
handshake.proto
View file @
6898125c
// Copyright 2020 The Swarm Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
syntax
=
"proto3"
;
syntax
=
"proto3"
;
package
handshake
;
package
pb
;
message
ShakeHand
{
message
ShakeHand
{
string
Address
=
1
;
string
Address
=
1
;
...
...
pkg/p2p/libp2p/libp2p.go
View file @
6898125c
...
@@ -7,6 +7,7 @@ package libp2p
...
@@ -7,6 +7,7 @@ package libp2p
import
(
import
(
"bytes"
"bytes"
"context"
"context"
"errors"
"fmt"
"fmt"
"io"
"io"
"io/ioutil"
"io/ioutil"
...
@@ -216,11 +217,15 @@ func New(ctx context.Context, o Options) (*Service, error) {
...
@@ -216,11 +217,15 @@ func New(ctx context.Context, o Options) (*Service, error) {
peerID
:=
stream
.
Conn
()
.
RemotePeer
()
peerID
:=
stream
.
Conn
()
.
RemotePeer
()
i
,
err
:=
s
.
handshakeService
.
Handle
(
stream
)
i
,
err
:=
s
.
handshakeService
.
Handle
(
stream
)
if
err
!=
nil
{
if
err
!=
nil
{
s
.
logger
.
Errorf
(
"handshake with peer %s: %w"
,
peerID
,
err
)
s
.
logger
.
Errorf
(
"handshake with x %s: %w"
,
peerID
,
err
)
// todo: test connection close and refactor
_
=
stream
.
Conn
()
.
Close
()
return
return
}
}
if
i
.
NetworkID
!=
s
.
networkID
{
if
i
.
NetworkID
!=
s
.
networkID
{
s
.
logger
.
Errorf
(
"handshake with peer %s: invalid network id %v"
,
peerID
,
i
.
NetworkID
)
s
.
logger
.
Errorf
(
"handshake with peer %s: invalid network id %v"
,
peerID
,
i
.
NetworkID
)
// todo: test connection close and refactor
_
=
stream
.
Conn
()
.
Close
()
return
return
}
}
s
.
peers
.
add
(
peerID
,
i
.
Address
)
s
.
peers
.
add
(
peerID
,
i
.
Address
)
...
@@ -260,13 +265,24 @@ func (s *Service) AddProtocol(p p2p.ProtocolSpec) (err error) {
...
@@ -260,13 +265,24 @@ func (s *Service) AddProtocol(p p2p.ProtocolSpec) (err error) {
peerID
:=
stream
.
Conn
()
.
RemotePeer
()
peerID
:=
stream
.
Conn
()
.
RemotePeer
()
overlay
,
found
:=
s
.
peers
.
overlay
(
peerID
)
overlay
,
found
:=
s
.
peers
.
overlay
(
peerID
)
if
!
found
{
if
!
found
{
// todo: handle better
// todo: this should never happen, should we disconnect in this case?
// todo: test connection close and refactor
_
=
stream
.
Conn
()
.
Close
()
s
.
logger
.
Errorf
(
"overlay address for peer %q not found"
,
peerID
)
s
.
logger
.
Errorf
(
"overlay address for peer %q not found"
,
peerID
)
return
return
}
}
s
.
metrics
.
HandledStreamCount
.
Inc
()
s
.
metrics
.
HandledStreamCount
.
Inc
()
ss
.
Handler
(
p2p
.
Peer
{
Address
:
overlay
},
stream
)
if
err
:=
ss
.
Handler
(
p2p
.
Peer
{
Address
:
overlay
},
stream
);
err
!=
nil
{
var
e
*
disconnectError
if
errors
.
Is
(
err
,
e
)
{
// todo: test connection close and refactor
s
.
peers
.
remove
(
peerID
)
_
=
stream
.
Conn
()
.
Close
()
}
s
.
logger
.
Errorf
(
"%s: %s/%s: %w"
,
p
.
Name
,
ss
.
Name
,
ss
.
Version
,
err
)
}
})
})
}
}
return
nil
return
nil
...
...
pkg/p2p/libp2p/metrics.go
View file @
6898125c
...
@@ -9,7 +9,6 @@ import (
...
@@ -9,7 +9,6 @@ import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus"
)
)
type
metrics
struct
{
type
metrics
struct
{
// all metrics fields must be exported
// all metrics fields must be exported
// to be able to return them by Metrics()
// to be able to return them by Metrics()
...
...
pkg/p2p/libp2p/peer.go
View file @
6898125c
...
@@ -43,3 +43,11 @@ func (r *peerRegistry) overlay(peerID libp2ppeer.ID) (overlay string, found bool
...
@@ -43,3 +43,11 @@ func (r *peerRegistry) overlay(peerID libp2ppeer.ID) (overlay string, found bool
r
.
mu
.
RUnlock
()
r
.
mu
.
RUnlock
()
return
overlay
,
found
return
overlay
,
found
}
}
func
(
r
*
peerRegistry
)
remove
(
peerID
libp2ppeer
.
ID
)
{
r
.
mu
.
Lock
()
overlay
:=
r
.
overlays
[
peerID
]
delete
(
r
.
overlays
,
peerID
)
delete
(
r
.
peers
,
overlay
)
r
.
mu
.
Unlock
()
}
pkg/p2p/mock/mock.go
View file @
6898125c
...
@@ -14,16 +14,32 @@ import (
...
@@ -14,16 +14,32 @@ import (
)
)
type
Recorder
struct
{
type
Recorder
struct
{
records
map
[
string
][]
Record
records
map
[
string
][]
Record
recordsMu
sync
.
Mutex
recordsMu
sync
.
Mutex
protocols
[]
p2p
.
ProtocolSpec
protocols
[]
p2p
.
ProtocolSpec
middlewares
[]
p2p
.
HandlerMiddleware
}
}
func
NewRecorder
(
protocols
...
p2p
.
ProtocolSpec
)
*
Recorder
{
func
WithProtocols
(
protocols
...
p2p
.
ProtocolSpec
)
Option
{
return
&
Recorder
{
return
optionFunc
(
func
(
r
*
Recorder
)
{
records
:
make
(
map
[
string
][]
Record
),
r
.
protocols
=
append
(
r
.
protocols
,
protocols
...
)
protocols
:
protocols
,
})
}
func
WithMiddlewares
(
middlewares
...
p2p
.
HandlerMiddleware
)
Option
{
return
optionFunc
(
func
(
r
*
Recorder
)
{
r
.
middlewares
=
append
(
r
.
middlewares
,
middlewares
...
)
})
}
func
NewRecorder
(
opts
...
Option
)
*
Recorder
{
r
:=
&
Recorder
{
records
:
make
(
map
[
string
][]
Record
),
}
for
_
,
o
:=
range
opts
{
o
.
apply
(
r
)
}
}
return
r
}
}
func
(
r
*
Recorder
)
NewStream
(
_
context
.
Context
,
overlay
,
protocolName
,
streamName
,
version
string
)
(
p2p
.
Stream
,
error
)
{
func
(
r
*
Recorder
)
NewStream
(
_
context
.
Context
,
overlay
,
protocolName
,
streamName
,
version
string
)
(
p2p
.
Stream
,
error
)
{
...
@@ -32,7 +48,7 @@ func (r *Recorder) NewStream(_ context.Context, overlay, protocolName, streamNam
...
@@ -32,7 +48,7 @@ func (r *Recorder) NewStream(_ context.Context, overlay, protocolName, streamNam
streamOut
:=
newStream
(
recordIn
,
recordOut
)
streamOut
:=
newStream
(
recordIn
,
recordOut
)
streamIn
:=
newStream
(
recordOut
,
recordIn
)
streamIn
:=
newStream
(
recordOut
,
recordIn
)
var
handler
func
(
p2p
.
Peer
,
p2p
.
Stream
)
var
handler
p2p
.
HandlerFunc
for
_
,
p
:=
range
r
.
protocols
{
for
_
,
p
:=
range
r
.
protocols
{
if
p
.
Name
==
protocolName
{
if
p
.
Name
==
protocolName
{
for
_
,
s
:=
range
p
.
StreamSpecs
{
for
_
,
s
:=
range
p
.
StreamSpecs
{
...
@@ -45,7 +61,14 @@ func (r *Recorder) NewStream(_ context.Context, overlay, protocolName, streamNam
...
@@ -45,7 +61,14 @@ func (r *Recorder) NewStream(_ context.Context, overlay, protocolName, streamNam
if
handler
==
nil
{
if
handler
==
nil
{
return
nil
,
fmt
.
Errorf
(
"unsupported protocol stream %q %q %q"
,
protocolName
,
streamName
,
version
)
return
nil
,
fmt
.
Errorf
(
"unsupported protocol stream %q %q %q"
,
protocolName
,
streamName
,
version
)
}
}
go
handler
(
p2p
.
Peer
{
Address
:
overlay
},
streamIn
)
for
_
,
m
:=
range
r
.
middlewares
{
handler
=
m
(
handler
)
}
go
func
()
{
if
err
:=
handler
(
p2p
.
Peer
{
Address
:
overlay
},
streamIn
);
err
!=
nil
{
panic
(
err
)
// todo: store error and export error records for inspection
}
}()
id
:=
overlay
+
p2p
.
NewSwarmStreamName
(
protocolName
,
streamName
,
version
)
id
:=
overlay
+
p2p
.
NewSwarmStreamName
(
protocolName
,
streamName
,
version
)
...
@@ -167,3 +190,10 @@ func (r *record) bytes() []byte {
...
@@ -167,3 +190,10 @@ func (r *record) bytes() []byte {
return
r
.
b
return
r
.
b
}
}
type
Option
interface
{
apply
(
*
Recorder
)
}
type
optionFunc
func
(
*
Recorder
)
func
(
f
optionFunc
)
apply
(
r
*
Recorder
)
{
f
(
r
)
}
pkg/p2p/p2p.go
View file @
6898125c
...
@@ -34,9 +34,13 @@ type ProtocolSpec struct {
...
@@ -34,9 +34,13 @@ type ProtocolSpec struct {
type
StreamSpec
struct
{
type
StreamSpec
struct
{
Name
string
Name
string
Version
string
Version
string
Handler
func
(
Peer
,
Stream
)
Handler
HandlerFunc
}
}
type
HandlerFunc
func
(
Peer
,
Stream
)
error
type
HandlerMiddleware
func
(
HandlerFunc
)
HandlerFunc
type
IncompatibleStreamError
struct
{
type
IncompatibleStreamError
struct
{
err
error
err
error
}
}
...
...
pkg/p2p/protobuf/protobuf.go
View file @
6898125c
...
@@ -5,9 +5,9 @@
...
@@ -5,9 +5,9 @@
package
protobuf
package
protobuf
import
(
import
(
"github.com/ethersphere/bee/pkg/p2p"
ggio
"github.com/gogo/protobuf/io"
ggio
"github.com/gogo/protobuf/io"
"github.com/gogo/protobuf/proto"
"github.com/gogo/protobuf/proto"
"github.com/ethersphere/bee/pkg/p2p"
"io"
"io"
)
)
...
...
pkg/pingpong/pb/doc.go
0 → 100644
View file @
6898125c
// Copyright 2020 The Swarm Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:generate sh -c "protoc -I . -I \"$(go list -f '{{ .Dir }}' -m github.com/gogo/protobuf)/protobuf\" --gogofaster_out=. pingpong.proto"
// Package pb holds only Protocol Buffer definitions and generated code.
package
pb
pkg/pingpong/pingpong.pb.go
→
pkg/pingpong/p
b/p
ingpong.pb.go
View file @
6898125c
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: pingpong.proto
// source: pingpong.proto
package
p
ingpong
package
p
b
import
(
import
(
fmt
"fmt"
fmt
"fmt"
...
@@ -111,8 +111,8 @@ func (m *Pong) GetResponse() string {
...
@@ -111,8 +111,8 @@ func (m *Pong) GetResponse() string {
}
}
func
init
()
{
func
init
()
{
proto
.
RegisterType
((
*
Ping
)(
nil
),
"p
ingpong
.Ping"
)
proto
.
RegisterType
((
*
Ping
)(
nil
),
"p
b
.Ping"
)
proto
.
RegisterType
((
*
Pong
)(
nil
),
"p
ingpong
.Pong"
)
proto
.
RegisterType
((
*
Pong
)(
nil
),
"p
b
.Pong"
)
}
}
func
init
()
{
proto
.
RegisterFile
(
"pingpong.proto"
,
fileDescriptor_1cfbf639ab46154b
)
}
func
init
()
{
proto
.
RegisterFile
(
"pingpong.proto"
,
fileDescriptor_1cfbf639ab46154b
)
}
...
@@ -120,13 +120,13 @@ func init() { proto.RegisterFile("pingpong.proto", fileDescriptor_1cfbf639ab4615
...
@@ -120,13 +120,13 @@ func init() { proto.RegisterFile("pingpong.proto", fileDescriptor_1cfbf639ab4615
var
fileDescriptor_1cfbf639ab46154b
=
[]
byte
{
var
fileDescriptor_1cfbf639ab46154b
=
[]
byte
{
// 122 bytes of a gzipped FileDescriptorProto
// 122 bytes of a gzipped FileDescriptorProto
0x1f
,
0x8b
,
0x08
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x02
,
0xff
,
0xe2
,
0xe2
,
0x2b
,
0xc8
,
0xcc
,
0x4b
,
0x1f
,
0x8b
,
0x08
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x02
,
0xff
,
0xe2
,
0xe2
,
0x2b
,
0xc8
,
0xcc
,
0x4b
,
0x2f
,
0xc8
,
0xcf
,
0x4b
,
0xd7
,
0x2b
,
0x28
,
0xca
,
0x2f
,
0xc9
,
0x17
,
0x
e2
,
0x80
,
0xf1
,
0x95
,
0x94
,
0x2f
,
0xc8
,
0xcf
,
0x4b
,
0xd7
,
0x2b
,
0x28
,
0xca
,
0x2f
,
0xc9
,
0x17
,
0x
62
,
0x2a
,
0x48
,
0x52
,
0x52
,
0x
b8
,
0x58
,
0x02
,
0x32
,
0xf3
,
0xd2
,
0x85
,
0xa4
,
0xb8
,
0x38
,
0xdc
,
0x8b
,
0x52
,
0x53
,
0x4b
,
0x32
,
0x
e2
,
0x62
,
0x09
,
0xc8
,
0xcc
,
0x4b
,
0x17
,
0x92
,
0xe2
,
0xe2
,
0x70
,
0x2f
,
0x4a
,
0x4d
,
0x2d
,
0xc9
,
0x
f3
,
0xd2
,
0x25
,
0x18
,
0x15
,
0x18
,
0x35
,
0x38
,
0x83
,
0xe0
,
0x7c
,
0xb0
,
0x9a
,
0x7c
,
0x88
,
0x9
a
,
0x
cc
,
0x4b
,
0x97
,
0x60
,
0x54
,
0x60
,
0xd4
,
0xe0
,
0x0c
,
0x82
,
0xf3
,
0xc1
,
0x6a
,
0xf2
,
0x21
,
0x6
a
,
0x
a0
,
0xd4
,
0xe2
,
0x82
,
0xfc
,
0xbc
,
0xe2
,
0x54
,
0x98
,
0x1a
,
0x18
,
0xdf
,
0x49
,
0xe2
,
0xc4
,
0x23
,
0x
82
,
0x52
,
0x8b
,
0x0b
,
0xf2
,
0xf3
,
0x8a
,
0x53
,
0x61
,
0x6a
,
0x60
,
0x7c
,
0x27
,
0x89
,
0x13
,
0x8f
,
0x
39
,
0xc6
,
0x0b
,
0x8f
,
0xe4
,
0x18
,
0x1f
,
0x3c
,
0x92
,
0x63
,
0x9c
,
0xf0
,
0x58
,
0x8e
,
0xe1
,
0xc2
,
0x
e4
,
0x18
,
0x2f
,
0x3c
,
0x92
,
0x63
,
0x7c
,
0xf0
,
0x48
,
0x8e
,
0x71
,
0xc2
,
0x63
,
0x39
,
0x86
,
0x0b
,
0x
63
,
0x39
,
0x86
,
0x1b
,
0x8f
,
0xe5
,
0x18
,
0x92
,
0xd8
,
0xc0
,
0x56
,
0x1a
,
0x03
,
0x02
,
0x00
,
0x00
,
0x
8f
,
0xe5
,
0x18
,
0x6e
,
0x3c
,
0x96
,
0x63
,
0x48
,
0x62
,
0x03
,
0x5b
,
0x66
,
0x0c
,
0x08
,
0x00
,
0x00
,
0xff
,
0xff
,
0x
a8
,
0xfc
,
0xee
,
0x94
,
0x84
,
0x00
,
0x00
,
0x00
,
0xff
,
0xff
,
0x
8c
,
0xe4
,
0x0f
,
0x96
,
0x7e
,
0x00
,
0x00
,
0x00
,
}
}
func
(
m
*
Ping
)
Marshal
()
(
dAtA
[]
byte
,
err
error
)
{
func
(
m
*
Ping
)
Marshal
()
(
dAtA
[]
byte
,
err
error
)
{
...
...
pkg/pingpong/pingpong.proto
→
pkg/pingpong/p
b/p
ingpong.proto
View file @
6898125c
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
syntax
=
"proto3"
;
syntax
=
"proto3"
;
package
p
ingpong
;
package
p
b
;
message
Ping
{
message
Ping
{
string
Greeting
=
1
;
string
Greeting
=
1
;
...
...
pkg/pingpong/pingpong.go
View file @
6898125c
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// license that can be found in the LICENSE file.
//go:generate sh -c "protoc -I . -I \"$(go list -f '{{ .Dir }}' -m github.com/gogo/protobuf)/protobuf\" --gogofaster_out=. pingpong.proto"
package
pingpong
package
pingpong
import
(
import
(
...
@@ -13,6 +12,7 @@ import (
...
@@ -13,6 +12,7 @@ import (
"github.com/ethersphere/bee/pkg/p2p"
"github.com/ethersphere/bee/pkg/p2p"
"github.com/ethersphere/bee/pkg/p2p/protobuf"
"github.com/ethersphere/bee/pkg/p2p/protobuf"
"github.com/ethersphere/bee/pkg/pingpong/pb"
)
)
const
(
const
(
...
@@ -34,7 +34,6 @@ type Options struct {
...
@@ -34,7 +34,6 @@ type Options struct {
type
Logger
interface
{
type
Logger
interface
{
Debugf
(
format
string
,
args
...
interface
{})
Debugf
(
format
string
,
args
...
interface
{})
Errorf
(
format
string
,
args
...
interface
{})
}
}
func
New
(
o
Options
)
*
Service
{
func
New
(
o
Options
)
*
Service
{
...
@@ -59,6 +58,7 @@ func (s *Service) Protocol() p2p.ProtocolSpec {
...
@@ -59,6 +58,7 @@ func (s *Service) Protocol() p2p.ProtocolSpec {
}
}
func
(
s
*
Service
)
Ping
(
ctx
context
.
Context
,
address
string
,
msgs
...
string
)
(
rtt
time
.
Duration
,
err
error
)
{
func
(
s
*
Service
)
Ping
(
ctx
context
.
Context
,
address
string
,
msgs
...
string
)
(
rtt
time
.
Duration
,
err
error
)
{
start
:=
time
.
Now
()
stream
,
err
:=
s
.
streamer
.
NewStream
(
ctx
,
address
,
protocolName
,
streamName
,
streamVersion
)
stream
,
err
:=
s
.
streamer
.
NewStream
(
ctx
,
address
,
protocolName
,
streamName
,
streamVersion
)
if
err
!=
nil
{
if
err
!=
nil
{
return
0
,
fmt
.
Errorf
(
"new stream: %w"
,
err
)
return
0
,
fmt
.
Errorf
(
"new stream: %w"
,
err
)
...
@@ -67,13 +67,12 @@ func (s *Service) Ping(ctx context.Context, address string, msgs ...string) (rtt
...
@@ -67,13 +67,12 @@ func (s *Service) Ping(ctx context.Context, address string, msgs ...string) (rtt
w
,
r
:=
protobuf
.
NewWriterAndReader
(
stream
)
w
,
r
:=
protobuf
.
NewWriterAndReader
(
stream
)
var
pong
Pong
var
pong
pb
.
Pong
start
:=
time
.
Now
()
for
_
,
msg
:=
range
msgs
{
for
_
,
msg
:=
range
msgs
{
if
err
:=
w
.
WriteMsg
(
&
Ping
{
if
err
:=
w
.
WriteMsg
(
&
pb
.
Ping
{
Greeting
:
msg
,
Greeting
:
msg
,
});
err
!=
nil
{
});
err
!=
nil
{
return
0
,
fmt
.
Errorf
(
"
stream writ
e: %w"
,
err
)
return
0
,
fmt
.
Errorf
(
"
write messag
e: %w"
,
err
)
}
}
s
.
metrics
.
PingSentCount
.
Inc
()
s
.
metrics
.
PingSentCount
.
Inc
()
...
@@ -81,38 +80,36 @@ func (s *Service) Ping(ctx context.Context, address string, msgs ...string) (rtt
...
@@ -81,38 +80,36 @@ func (s *Service) Ping(ctx context.Context, address string, msgs ...string) (rtt
if
err
==
io
.
EOF
{
if
err
==
io
.
EOF
{
break
break
}
}
return
0
,
err
return
0
,
fmt
.
Errorf
(
"read message: %w"
,
err
)
}
}
s
.
logger
.
Debugf
(
"got pong: %q"
,
pong
.
Response
)
s
.
logger
.
Debugf
(
"got pong: %q"
,
pong
.
Response
)
s
.
metrics
.
PongReceivedCount
.
Inc
()
s
.
metrics
.
PongReceivedCount
.
Inc
()
}
}
return
time
.
Since
(
start
)
/
time
.
Duration
(
len
(
msgs
))
,
nil
return
time
.
Since
(
start
),
nil
}
}
func
(
s
*
Service
)
Handler
(
peer
p2p
.
Peer
,
stream
p2p
.
Stream
)
{
func
(
s
*
Service
)
Handler
(
peer
p2p
.
Peer
,
stream
p2p
.
Stream
)
error
{
w
,
r
:=
protobuf
.
NewWriterAndReader
(
stream
)
w
,
r
:=
protobuf
.
NewWriterAndReader
(
stream
)
defer
stream
.
Close
()
defer
stream
.
Close
()
fmt
.
Printf
(
"Initiate pinpong for peer %s"
,
peer
)
var
ping
pb
.
Ping
var
ping
Ping
for
{
for
{
if
err
:=
r
.
ReadMsg
(
&
ping
);
err
!=
nil
{
if
err
:=
r
.
ReadMsg
(
&
ping
);
err
!=
nil
{
if
err
==
io
.
EOF
{
if
err
==
io
.
EOF
{
break
break
}
}
s
.
logger
.
Errorf
(
"pingpong handler: read message: %v
\n
"
,
err
)
return
fmt
.
Errorf
(
"read message: %w"
,
err
)
return
}
}
s
.
logger
.
Debugf
(
"got ping: %q"
,
ping
.
Greeting
)
s
.
logger
.
Debugf
(
"got ping: %q"
,
ping
.
Greeting
)
s
.
metrics
.
PingReceivedCount
.
Inc
()
s
.
metrics
.
PingReceivedCount
.
Inc
()
if
err
:=
w
.
WriteMsg
(
&
Pong
{
if
err
:=
w
.
WriteMsg
(
&
pb
.
Pong
{
Response
:
"{"
+
ping
.
Greeting
+
"}"
,
Response
:
"{"
+
ping
.
Greeting
+
"}"
,
});
err
!=
nil
{
});
err
!=
nil
{
s
.
logger
.
Errorf
(
"pingpong handler: write message: %v
\n
"
,
err
)
return
fmt
.
Errorf
(
"write message: %w"
,
err
)
return
}
}
s
.
metrics
.
PongSentCount
.
Inc
()
s
.
metrics
.
PongSentCount
.
Inc
()
}
}
return
nil
}
}
pkg/pingpong/pingpong_test.go
View file @
6898125c
...
@@ -9,15 +9,18 @@ import (
...
@@ -9,15 +9,18 @@ import (
"context"
"context"
"fmt"
"fmt"
"io/ioutil"
"io/ioutil"
"runtime"
"testing"
"testing"
"time"
"github.com/ethersphere/bee/pkg/logging"
"github.com/ethersphere/bee/pkg/logging"
"github.com/ethersphere/bee/pkg/p2p"
"github.com/ethersphere/bee/pkg/p2p/mock"
"github.com/ethersphere/bee/pkg/p2p/mock"
"github.com/ethersphere/bee/pkg/p2p/protobuf"
"github.com/ethersphere/bee/pkg/p2p/protobuf"
"github.com/ethersphere/bee/pkg/pingpong"
"github.com/ethersphere/bee/pkg/pingpong"
"github.com/ethersphere/bee/pkg/pingpong/pb"
)
)
func
TestPing
(
t
*
testing
.
T
)
{
func
TestPing
(
t
*
testing
.
T
)
{
logger
:=
logging
.
New
(
ioutil
.
Discard
)
logger
:=
logging
.
New
(
ioutil
.
Discard
)
...
@@ -27,7 +30,18 @@ func TestPing(t *testing.T) {
...
@@ -27,7 +30,18 @@ func TestPing(t *testing.T) {
})
})
// setup the stream recorder to record stream data
// setup the stream recorder to record stream data
recorder
:=
mock
.
NewRecorder
(
server
.
Protocol
())
recorder
:=
mock
.
NewRecorder
(
mock
.
WithProtocols
(
server
.
Protocol
()),
mock
.
WithMiddlewares
(
func
(
f
p2p
.
HandlerFunc
)
p2p
.
HandlerFunc
{
if
runtime
.
GOOS
==
"windows"
{
// windows has a bit lower time resolution
// so, slow down the handler with a middleware
// not to get 0s for rtt value
time
.
Sleep
(
100
*
time
.
Millisecond
)
}
return
f
}),
)
// create a pingpong client that will do pinging
// create a pingpong client that will do pinging
client
:=
pingpong
.
New
(
pingpong
.
Options
{
client
:=
pingpong
.
New
(
pingpong
.
Options
{
...
@@ -36,13 +50,18 @@ func TestPing(t *testing.T) {
...
@@ -36,13 +50,18 @@ func TestPing(t *testing.T) {
})
})
// ping
// ping
peerID
:=
"
/p2p/QmZt98UimwpW9ptJumKTq7B7t3FzNfyoWVNGcd8PFCd7XS
"
peerID
:=
"
124
"
greetings
:=
[]
string
{
"hey"
,
"there"
,
"fella"
}
greetings
:=
[]
string
{
"hey"
,
"there"
,
"fella"
}
_
,
err
:=
client
.
Ping
(
context
.
Background
(),
peerID
,
greetings
...
)
rtt
,
err
:=
client
.
Ping
(
context
.
Background
(),
peerID
,
greetings
...
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
// check that RTT is a sane value
if
rtt
<=
0
{
t
.
Errorf
(
"invalid RTT value %v"
,
rtt
)
}
// get a record for this stream
// get a record for this stream
records
,
err
:=
recorder
.
Records
(
peerID
,
"pingpong"
,
"pingpong"
,
"1.0.0"
)
records
,
err
:=
recorder
.
Records
(
peerID
,
"pingpong"
,
"pingpong"
,
"1.0.0"
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -57,14 +76,14 @@ func TestPing(t *testing.T) {
...
@@ -57,14 +76,14 @@ func TestPing(t *testing.T) {
wantGreetings
:=
greetings
wantGreetings
:=
greetings
messages
,
err
:=
protobuf
.
ReadMessages
(
messages
,
err
:=
protobuf
.
ReadMessages
(
bytes
.
NewReader
(
record
.
In
()),
bytes
.
NewReader
(
record
.
In
()),
func
()
protobuf
.
Message
{
return
new
(
p
ingpong
.
Ping
)
},
func
()
protobuf
.
Message
{
return
new
(
p
b
.
Ping
)
},
)
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
var
gotGreetings
[]
string
var
gotGreetings
[]
string
for
_
,
m
:=
range
messages
{
for
_
,
m
:=
range
messages
{
gotGreetings
=
append
(
gotGreetings
,
m
.
(
*
p
ingpong
.
Ping
)
.
Greeting
)
gotGreetings
=
append
(
gotGreetings
,
m
.
(
*
p
b
.
Ping
)
.
Greeting
)
}
}
if
fmt
.
Sprint
(
gotGreetings
)
!=
fmt
.
Sprint
(
wantGreetings
)
{
if
fmt
.
Sprint
(
gotGreetings
)
!=
fmt
.
Sprint
(
wantGreetings
)
{
t
.
Errorf
(
"got greetings %v, want %v"
,
gotGreetings
,
wantGreetings
)
t
.
Errorf
(
"got greetings %v, want %v"
,
gotGreetings
,
wantGreetings
)
...
@@ -77,14 +96,14 @@ func TestPing(t *testing.T) {
...
@@ -77,14 +96,14 @@ func TestPing(t *testing.T) {
}
}
messages
,
err
=
protobuf
.
ReadMessages
(
messages
,
err
=
protobuf
.
ReadMessages
(
bytes
.
NewReader
(
record
.
Out
()),
bytes
.
NewReader
(
record
.
Out
()),
func
()
protobuf
.
Message
{
return
new
(
p
ingpong
.
Pong
)
},
func
()
protobuf
.
Message
{
return
new
(
p
b
.
Pong
)
},
)
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
var
gotResponses
[]
string
var
gotResponses
[]
string
for
_
,
m
:=
range
messages
{
for
_
,
m
:=
range
messages
{
gotResponses
=
append
(
gotResponses
,
m
.
(
*
p
ingpong
.
Pong
)
.
Response
)
gotResponses
=
append
(
gotResponses
,
m
.
(
*
p
b
.
Pong
)
.
Response
)
}
}
if
fmt
.
Sprint
(
gotResponses
)
!=
fmt
.
Sprint
(
wantResponses
)
{
if
fmt
.
Sprint
(
gotResponses
)
!=
fmt
.
Sprint
(
wantResponses
)
{
t
.
Errorf
(
"got responses %v, want %v"
,
gotResponses
,
wantResponses
)
t
.
Errorf
(
"got responses %v, want %v"
,
gotResponses
,
wantResponses
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment