Skip to content
This repository has been archived by the owner on May 11, 2022. It is now read-only.

Commit

Permalink
feat: update to go-libp2p-core 0.7.0
Browse files Browse the repository at this point in the history
This uses the latest stream interface changes.

(it also fixes a bug in the test)
  • Loading branch information
Stebalien committed Sep 2, 2020
1 parent 6e94b6c commit 8682466
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 20 deletions.
2 changes: 1 addition & 1 deletion 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 autonat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func TestAutoNATPrivate(t *testing.T) {
}

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

status = an.Status()
if status != network.ReachabilityPrivate {
Expand Down
3 changes: 1 addition & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"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"
Expand Down Expand Up @@ -41,7 +40,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 := ggio.NewDelimitedReader(s, network.MessageSizeMax)
w := ggio.NewDelimitedWriter(s)
Expand Down
2 changes: 1 addition & 1 deletion 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
7 changes: 3 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ require (
github.com/ipfs/go-log v1.0.4
github.com/libp2p/go-eventbus v0.2.1
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/multiformats/go-multiaddr v0.2.2
github.com/multiformats/go-multiaddr-net v0.1.5
github.com/libp2p/go-libp2p-core v0.7.0
github.com/libp2p/go-libp2p-swarm v0.3.0
github.com/multiformats/go-multiaddr v0.3.1
)

go 1.13
60 changes: 53 additions & 7 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion 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
5 changes: 2 additions & 3 deletions 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 (

ggio "github.com/gogo/protobuf/io"
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 8682466

Please sign in to comment.