diff --git a/autonat_test.go b/autonat_test.go index 4146dd8..fef03a7 100644 --- a/autonat_test.go +++ b/autonat_test.go @@ -5,15 +5,16 @@ import ( "testing" "time" - pb "github.com/libp2p/go-libp2p-autonat/pb" "github.com/libp2p/go-libp2p-core/event" "github.com/libp2p/go-libp2p-core/host" "github.com/libp2p/go-libp2p-core/network" "github.com/libp2p/go-libp2p-core/peer" - ggio "github.com/gogo/protobuf/io" + pb "github.com/libp2p/go-libp2p-autonat/pb" + bhost "github.com/libp2p/go-libp2p-blankhost" swarmt "github.com/libp2p/go-libp2p-swarm/testing" + "github.com/libp2p/go-msgio/protoio" ma "github.com/multiformats/go-multiaddr" ) @@ -32,7 +33,7 @@ func makeAutoNATServicePublic(ctx context.Context, t *testing.T) host.Host { func sayAutoNATPrivate(s network.Stream) { defer s.Close() - w := ggio.NewDelimitedWriter(s) + w := protoio.NewDelimitedWriter(s) res := pb.Message{ Type: pb.Message_DIAL_RESPONSE.Enum(), DialResponse: newDialResponseError(pb.Message_E_DIAL_ERROR, "no dialable addresses"), @@ -42,7 +43,7 @@ func sayAutoNATPrivate(s network.Stream) { func sayAutoNATPublic(s network.Stream) { defer s.Close() - w := ggio.NewDelimitedWriter(s) + w := protoio.NewDelimitedWriter(s) res := pb.Message{ Type: pb.Message_DIAL_RESPONSE.Enum(), DialResponse: newDialResponseOK(s.Conn().RemoteMultiaddr()), diff --git a/client.go b/client.go index e2ab8a3..a6a059b 100644 --- a/client.go +++ b/client.go @@ -4,13 +4,14 @@ import ( "context" "fmt" - pb "github.com/libp2p/go-libp2p-autonat/pb" "github.com/libp2p/go-libp2p-core/helpers" - - ggio "github.com/gogo/protobuf/io" "github.com/libp2p/go-libp2p-core/host" "github.com/libp2p/go-libp2p-core/network" "github.com/libp2p/go-libp2p-core/peer" + + pb "github.com/libp2p/go-libp2p-autonat/pb" + + protoio "github.com/libp2p/go-msgio/protoio" ma "github.com/multiformats/go-multiaddr" ) @@ -43,8 +44,8 @@ func (c *client) DialBack(ctx context.Context, p peer.ID) (ma.Multiaddr, error) // don't care about being nice. defer helpers.FullClose(s) - r := ggio.NewDelimitedReader(s, network.MessageSizeMax) - w := ggio.NewDelimitedWriter(s) + r := protoio.NewDelimitedReader(s, network.MessageSizeMax) + w := protoio.NewDelimitedWriter(s) req := newDialMessage(peer.AddrInfo{ID: c.h.ID(), Addrs: c.addrFunc()}) err = w.WriteMsg(req) diff --git a/go.mod b/go.mod index 7b15825..efa9e82 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,7 @@ module github.com/libp2p/go-libp2p-autonat +go 1.13 + require ( github.com/gogo/protobuf v1.3.1 github.com/ipfs/go-log v1.0.4 @@ -7,8 +9,7 @@ require ( github.com/libp2p/go-libp2p-blankhost v0.2.0 github.com/libp2p/go-libp2p-core v0.6.0 github.com/libp2p/go-libp2p-swarm v0.2.8 + github.com/libp2p/go-msgio v0.0.6 github.com/multiformats/go-multiaddr v0.2.2 github.com/multiformats/go-multiaddr-net v0.1.5 ) - -go 1.13 diff --git a/go.sum b/go.sum index cdd47d9..262ed82 100644 --- a/go.sum +++ b/go.sum @@ -170,6 +170,8 @@ github.com/libp2p/go-mplex v0.1.2 h1:qOg1s+WdGLlpkrczDqmhYzyk3vCfsQ8+RxRTQjOZWwI github.com/libp2p/go-mplex v0.1.2/go.mod h1:Xgz2RDCi3co0LeZfgjm4OgUF15+sVR8SRcu3SFXI1lk= github.com/libp2p/go-msgio v0.0.4 h1:agEFehY3zWJFUHK6SEMR7UYmk2z6kC3oeCM7ybLhguA= github.com/libp2p/go-msgio v0.0.4/go.mod h1:63lBBgOTDKQL6EWazRMCwXsEeEeK9O2Cd+0+6OOuipQ= +github.com/libp2p/go-msgio v0.0.6 h1:lQ7Uc0kS1wb1EfRxO2Eir/RJoHkHn7t6o+EiwsYIKJA= +github.com/libp2p/go-msgio v0.0.6/go.mod h1:4ecVB6d9f4BDSL5fqvPiC4A3KivjWn+Venn/1ALLMWA= github.com/libp2p/go-netroute v0.1.2 h1:UHhB35chwgvcRI392znJA3RCBtZ3MpE3ahNCN5MR4Xg= github.com/libp2p/go-netroute v0.1.2/go.mod h1:jZLDV+1PE8y5XxBySEBgbuVAXbhtuHSdmLPL2n9MKbk= github.com/libp2p/go-openssl v0.0.4 h1:d27YZvLoTyMhIN4njrkr8zMDOM4lfpHIp6A+TK9fovg= @@ -244,6 +246,8 @@ github.com/multiformats/go-varint v0.0.1/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXS github.com/multiformats/go-varint v0.0.2/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE= github.com/multiformats/go-varint v0.0.5 h1:XVZwSo04Cs3j/jS0uAEPpT3JY6DzMcVLLoWOSnCxOjg= github.com/multiformats/go-varint v0.0.5/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE= +github.com/multiformats/go-varint v0.0.6 h1:gk85QWKxh3TazbLxED/NlDVv8+q+ReFJk7Y2W/KhfNY= +github.com/multiformats/go-varint v0.0.6/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE= 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.12.0 h1:Iw5WCbBcaAAd0fpRb1c9r5YCylv4XDoCSigm1zLevwU= @@ -375,6 +379,7 @@ golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3 golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5 h1:hKsoRgsbwY1NafxrwTs+k64bikrLBkAgPir1TNCj3Zs= golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191108193012-7d206e10da11 h1:Yq9t9jnGoR+dBuitxdo9l6Q7xh/zOyNnYUtDKaQ3x0E= golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= @@ -389,6 +394,7 @@ google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRn google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= 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= @@ -400,6 +406,7 @@ gopkg.in/src-d/go-log.v1 v1.0.1/go.mod h1:GN34hKP0g305ysm2/hctJ0Y8nWP3zxXXJ8GFab 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/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/svc.go b/svc.go index 481de16..165cde6 100644 --- a/svc.go +++ b/svc.go @@ -15,7 +15,7 @@ import ( pb "github.com/libp2p/go-libp2p-autonat/pb" - ggio "github.com/gogo/protobuf/io" + "github.com/libp2p/go-msgio/protoio" ma "github.com/multiformats/go-multiaddr" manet "github.com/multiformats/go-multiaddr-net" ) @@ -56,8 +56,8 @@ func (as *autoNATService) handleStream(s network.Stream) { pid := s.Conn().RemotePeer() log.Debugf("New stream from %s", pid.Pretty()) - r := ggio.NewDelimitedReader(s, network.MessageSizeMax) - w := ggio.NewDelimitedWriter(s) + r := protoio.NewDelimitedReader(s, network.MessageSizeMax) + w := protoio.NewDelimitedWriter(s) var req pb.Message var res pb.Message