Skip to content

Commit

Permalink
Merge pull request #97 from libp2p/feat/rw-stream
Browse files Browse the repository at this point in the history
feat: update to go-libp2p-core 0.7.0
  • Loading branch information
Stebalien authored Sep 2, 2020
2 parents ec8d960 + 87e9356 commit be059b4
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion p2p/host/autonat/autonat.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

logging "github.com/ipfs/go-log"
ma "github.com/multiformats/go-multiaddr"
manet "github.com/multiformats/go-multiaddr-net"
manet "github.com/multiformats/go-multiaddr/net"
)

var log = logging.Logger("autonat")
Expand Down
2 changes: 1 addition & 1 deletion p2p/host/autonat/autonat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func TestAutoNATPrivate(t *testing.T) {
}

connect(t, hs, hc)
time.Sleep(1 * time.Second)
time.Sleep(2 * time.Second)

status = an.Status()
if status != network.ReachabilityPrivate {
Expand Down
3 changes: 1 addition & 2 deletions p2p/host/autonat/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"

"github.com/libp2p/go-libp2p-core/helpers"
"github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p-core/peer"
Expand Down Expand Up @@ -42,7 +41,7 @@ func (c *client) DialBack(ctx context.Context, p peer.ID) (ma.Multiaddr, error)
}
// Might as well just reset the stream. Once we get to this point, we
// don't care about being nice.
defer helpers.FullClose(s)
defer s.Close()

r := protoio.NewDelimitedReader(s, network.MessageSizeMax)
w := protoio.NewDelimitedWriter(s)
Expand Down
2 changes: 1 addition & 1 deletion p2p/host/autonat/dialpolicy.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/libp2p/go-libp2p-core/host"
ma "github.com/multiformats/go-multiaddr"
manet "github.com/multiformats/go-multiaddr-net"
manet "github.com/multiformats/go-multiaddr/net"
)

type dialPolicy struct {
Expand Down
2 changes: 1 addition & 1 deletion p2p/host/autonat/notify.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"github.com/libp2p/go-libp2p-core/network"

ma "github.com/multiformats/go-multiaddr"
manet "github.com/multiformats/go-multiaddr-net"
manet "github.com/multiformats/go-multiaddr/net"
)

var _ network.Notifiee = (*AmbientAutoNAT)(nil)
Expand Down
6 changes: 3 additions & 3 deletions p2p/host/autonat/pb/autonat.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions p2p/host/autonat/svc.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"sync"
"time"

"github.com/libp2p/go-libp2p-core/helpers"
"github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-libp2p-core/peerstore"
Expand All @@ -17,7 +16,7 @@ import (

"github.com/libp2p/go-msgio/protoio"
ma "github.com/multiformats/go-multiaddr"
manet "github.com/multiformats/go-multiaddr-net"
manet "github.com/multiformats/go-multiaddr/net"
)

// AutoNATService provides NAT autodetection services to other peers
Expand Down Expand Up @@ -51,7 +50,7 @@ func newAutoNATService(ctx context.Context, c *config) (*autoNATService, error)
}

func (as *autoNATService) handleStream(s network.Stream) {
defer helpers.FullClose(s)
defer s.Close()

pid := s.Conn().RemotePeer()
log.Debugf("New stream from %s", pid.Pretty())
Expand Down

0 comments on commit be059b4

Please sign in to comment.