Commit 207c03bc authored by acud's avatar acud Committed by GitHub

update libp2p version (#1095)

parent 533e83f3
...@@ -9,7 +9,7 @@ import ( ...@@ -9,7 +9,7 @@ import (
"os" "os"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"golang.org/x/crypto/ssh/terminal" "golang.org/x/term"
) )
type passwordReader interface { type passwordReader interface {
...@@ -19,7 +19,7 @@ type passwordReader interface { ...@@ -19,7 +19,7 @@ type passwordReader interface {
type stdInPasswordReader struct{} type stdInPasswordReader struct{}
func (stdInPasswordReader) ReadPassword() (password string, err error) { func (stdInPasswordReader) ReadPassword() (password string, err error) {
v, err := terminal.ReadPassword(int(os.Stdin.Fd())) v, err := term.ReadPassword(int(os.Stdin.Fd()))
if err != nil { if err != nil {
return "", err return "", err
} }
......
...@@ -3,7 +3,8 @@ module github.com/ethersphere/bee ...@@ -3,7 +3,8 @@ module github.com/ethersphere/bee
go 1.14 go 1.14
require ( require (
github.com/btcsuite/btcd v0.20.1-beta github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect
github.com/btcsuite/btcd v0.21.0-beta
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd // indirect github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd // indirect
github.com/coreos/go-semver v0.3.0 github.com/coreos/go-semver v0.3.0
github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect
...@@ -12,35 +13,37 @@ require ( ...@@ -12,35 +13,37 @@ require (
github.com/ethersphere/langos v1.0.0 github.com/ethersphere/langos v1.0.0
github.com/ethersphere/manifest v0.3.6 github.com/ethersphere/manifest v0.3.6
github.com/ethersphere/sw3-bindings/v2 v2.1.0 github.com/ethersphere/sw3-bindings/v2 v2.1.0
github.com/go-ole/go-ole v1.2.4 // indirect
github.com/gogo/protobuf v1.3.1 github.com/gogo/protobuf v1.3.1
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
github.com/golang/protobuf v1.4.3 // indirect
github.com/google/gopacket v1.1.19 // indirect
github.com/google/uuid v1.1.4 // indirect
github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00 // indirect github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00 // indirect
github.com/gorilla/handlers v1.4.2 github.com/gorilla/handlers v1.4.2
github.com/gorilla/mux v1.7.4 github.com/gorilla/mux v1.7.4
github.com/gorilla/websocket v1.4.2 github.com/gorilla/websocket v1.4.2
github.com/ipfs/go-log/v2 v2.1.1 // indirect
github.com/kardianos/service v1.2.0 github.com/kardianos/service v1.2.0
github.com/koron/go-ssdp v0.0.2 // indirect
github.com/kr/text v0.2.0 // indirect github.com/kr/text v0.2.0 // indirect
github.com/libp2p/go-libp2p v0.10.0 github.com/libp2p/go-libp2p v0.13.0
github.com/libp2p/go-libp2p-autonat v0.3.0 // indirect github.com/libp2p/go-libp2p-autonat v0.4.0
github.com/libp2p/go-libp2p-autonat-svc v0.1.0 github.com/libp2p/go-libp2p-core v0.8.0
github.com/libp2p/go-libp2p-circuit v0.3.0 // indirect github.com/libp2p/go-libp2p-noise v0.1.2 // indirect
github.com/libp2p/go-libp2p-core v0.6.0
github.com/libp2p/go-libp2p-discovery v0.5.0 // indirect
github.com/libp2p/go-libp2p-peerstore v0.2.6 github.com/libp2p/go-libp2p-peerstore v0.2.6
github.com/libp2p/go-libp2p-quic-transport v0.8.0 github.com/libp2p/go-libp2p-quic-transport v0.10.0
github.com/libp2p/go-libp2p-transport-upgrader v0.3.0 github.com/libp2p/go-libp2p-transport-upgrader v0.4.0
github.com/libp2p/go-openssl v0.0.6 // indirect github.com/libp2p/go-netroute v0.1.4 // indirect
github.com/libp2p/go-tcp-transport v0.2.0 github.com/libp2p/go-sockaddr v0.1.0 // indirect
github.com/libp2p/go-ws-transport v0.3.1 github.com/libp2p/go-tcp-transport v0.2.1
github.com/libp2p/go-yamux v1.3.8 // indirect github.com/libp2p/go-ws-transport v0.4.0
github.com/mattn/go-colorable v0.1.2 // indirect
github.com/mitchellh/mapstructure v1.3.2 // indirect github.com/mitchellh/mapstructure v1.3.2 // indirect
github.com/mr-tron/base58 v1.2.0 // indirect github.com/multiformats/go-multiaddr v0.3.1
github.com/multiformats/go-multiaddr v0.2.2
github.com/multiformats/go-multiaddr-dns v0.2.0 github.com/multiformats/go-multiaddr-dns v0.2.0
github.com/multiformats/go-multistream v0.1.1 github.com/multiformats/go-multistream v0.2.0
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
github.com/opentracing/opentracing-go v1.1.0 github.com/opentracing/opentracing-go v1.2.0
github.com/pelletier/go-toml v1.8.0 // indirect github.com/pelletier/go-toml v1.8.0 // indirect
github.com/prometheus/client_golang v1.7.1 github.com/prometheus/client_golang v1.7.1
github.com/sirupsen/logrus v1.6.0 github.com/sirupsen/logrus v1.6.0
...@@ -56,15 +59,16 @@ require ( ...@@ -56,15 +59,16 @@ require (
github.com/uber/jaeger-lib v2.2.0+incompatible // indirect github.com/uber/jaeger-lib v2.2.0+incompatible // indirect
github.com/wealdtech/go-ens/v3 v3.4.3 github.com/wealdtech/go-ens/v3 v3.4.3
gitlab.com/nolash/go-mockbytes v0.0.7 gitlab.com/nolash/go-mockbytes v0.0.7
go.opencensus.io v0.22.4 // indirect go.opencensus.io v0.22.5 // indirect
go.uber.org/zap v1.15.0 // indirect go.uber.org/multierr v1.6.0 // indirect
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de go.uber.org/zap v1.16.0 // indirect
golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad
golang.org/x/mod v0.3.0 // indirect golang.org/x/mod v0.3.0 // indirect
golang.org/x/net v0.0.0-20200707034311-ab3426394381 golang.org/x/net v0.0.0-20201224014010-6772e930b67b
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9 golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9
golang.org/x/sys v0.0.0-20201015000850-e3ed0017c211 golang.org/x/sys v0.0.0-20210108172913-0df2131ae363
golang.org/x/text v0.3.3 // indirect golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf
golang.org/x/text v0.3.4 // indirect
golang.org/x/tools v0.0.0-20200626171337-aa94e735be7f // indirect golang.org/x/tools v0.0.0-20200626171337-aa94e735be7f // indirect
google.golang.org/protobuf v1.25.0 // indirect google.golang.org/protobuf v1.25.0 // indirect
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
......
This diff is collapsed.
...@@ -25,7 +25,7 @@ import ( ...@@ -25,7 +25,7 @@ import (
"github.com/ethersphere/bee/pkg/swarm" "github.com/ethersphere/bee/pkg/swarm"
"github.com/ethersphere/bee/pkg/tracing" "github.com/ethersphere/bee/pkg/tracing"
"github.com/libp2p/go-libp2p" "github.com/libp2p/go-libp2p"
autonat "github.com/libp2p/go-libp2p-autonat-svc" autonat "github.com/libp2p/go-libp2p-autonat"
crypto "github.com/libp2p/go-libp2p-core/crypto" crypto "github.com/libp2p/go-libp2p-core/crypto"
"github.com/libp2p/go-libp2p-core/host" "github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/network" "github.com/libp2p/go-libp2p-core/network"
...@@ -173,14 +173,17 @@ func New(ctx context.Context, signer beecrypto.Signer, networkID uint64, overlay ...@@ -173,14 +173,17 @@ func New(ctx context.Context, signer beecrypto.Signer, networkID uint64, overlay
return nil, err return nil, err
} }
// Support same non default security and transport options as
// original host.
dialer, err := libp2p.New(ctx, append(transports, security)...)
if err != nil {
return nil, err
}
// If you want to help other peers to figure out if they are behind // If you want to help other peers to figure out if they are behind
// NATs, you can launch the server-side of AutoNAT too (AutoRelay // NATs, you can launch the server-side of AutoNAT too (AutoRelay
// already runs the client) // already runs the client)
if _, err = autonat.NewAutoNATService(ctx, h, if _, err = autonat.New(ctx, h, autonat.EnableService(dialer.Network())); err != nil {
// Support same non default security and transport options as
// original host.
append(transports, security)...,
); err != nil {
return nil, fmt.Errorf("autonat: %w", err) return nil, fmt.Errorf("autonat: %w", err)
} }
......
...@@ -5,11 +5,18 @@ ...@@ -5,11 +5,18 @@
package libp2p package libp2p
import ( import (
"errors"
"io"
"time"
"github.com/ethersphere/bee/pkg/p2p" "github.com/ethersphere/bee/pkg/p2p"
"github.com/libp2p/go-libp2p-core/helpers"
"github.com/libp2p/go-libp2p-core/network" "github.com/libp2p/go-libp2p-core/network"
) )
var (
closeDeadline = 30 * time.Second
errExpectedEof = errors.New("read: expected eof")
)
var _ p2p.Stream = (*stream)(nil) var _ p2p.Stream = (*stream)(nil)
type stream struct { type stream struct {
...@@ -29,5 +36,29 @@ func (s *stream) Headers() p2p.Headers { ...@@ -29,5 +36,29 @@ func (s *stream) Headers() p2p.Headers {
} }
func (s *stream) FullClose() error { func (s *stream) FullClose() error {
return helpers.FullClose(s) if err := s.CloseWrite(); err != nil {
_ = s.Reset()
return err
}
// So we don't wait forever
_ = s.SetDeadline(time.Now().Add(closeDeadline))
// We *have* to observe the EOF. Otherwise, we leak the stream.
// Now, technically, we should do this *before*
// returning from SendMessage as the message
// hasn't really been sent yet until we see the
// EOF but we don't actually *know* what
// protocol the other side is speaking.
n, err := s.Read([]byte{0})
if n > 0 || err == nil {
_ = s.Reset()
return errExpectedEof
}
if err != io.EOF {
_ = s.Reset()
return err
}
return nil
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment