Skip to content

Commit

Permalink
upgrade deps + interoperable uvarint delimited writer/reader. (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
raulk authored Jul 30, 2020
1 parent fc59437 commit 67e4a6d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
9 changes: 5 additions & 4 deletions p2p/host/autonat/autonat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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"),
Expand All @@ -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()),
Expand Down
11 changes: 6 additions & 5 deletions p2p/host/autonat/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions p2p/host/autonat/svc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 67e4a6d

Please sign in to comment.