Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade dependencies. #233

Merged
merged 7 commits into from
Aug 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ import (

multierror "github.com/hashicorp/go-multierror"
logging "github.com/ipfs/go-log"
autonat "github.com/libp2p/go-libp2p-autonat-svc"
dht "github.com/libp2p/go-libp2p-kad-dht"
dhtopts "github.com/libp2p/go-libp2p-kad-dht/opts"
ps "github.com/libp2p/go-libp2p-pubsub"
ma "github.com/multiformats/go-multiaddr"
manet "github.com/multiformats/go-multiaddr-net"
manet "github.com/multiformats/go-multiaddr/net"
)

var log = logging.Logger("p2pd")
Expand All @@ -32,9 +31,8 @@ type Daemon struct {
host host.Host
listener manet.Listener

dht *dht.IpfsDHT
pubsub *ps.PubSub
autonat *autonat.AutoNATService
dht *dht.IpfsDHT
pubsub *ps.PubSub

mx sync.Mutex
// stream handlers: map of protocol.ID to multi-address
Expand Down Expand Up @@ -126,12 +124,6 @@ func (d *Daemon) EnablePubsub(router string, sign, strict bool) error {

}

func (d *Daemon) EnableAutoNAT(opts ...libp2p.Option) error {
svc, err := autonat.NewAutoNATService(d.ctx, d.host, opts...)
d.autonat = svc
return err
}

func (d *Daemon) ID() peer.ID {
return d.host.ID()
}
Expand Down
37 changes: 4 additions & 33 deletions dht.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ import (
"github.com/libp2p/go-libp2p-core/peer"

cid "github.com/ipfs/go-cid"
dht "github.com/libp2p/go-libp2p-kad-dht"
)

const defaultProviderCount = 20

func (d *Daemon) doDHT(req *pb.Request) (*pb.Response, <-chan *pb.DHTResponse, func()) {
if d.dht == nil {
return errorResponseString("DHT not enabled"), nil, nil
Expand Down Expand Up @@ -77,37 +78,7 @@ func (d *Daemon) doDHTFindPeer(req *pb.DHTRequest) (*pb.Response, <-chan *pb.DHT
}

func (d *Daemon) doDHTFindPeersConnectedToPeer(req *pb.DHTRequest) (*pb.Response, <-chan *pb.DHTResponse, func()) {
if req.Peer == nil {
return errorResponseString("Malformed request; missing peer parameter"), nil, nil
}

p, err := peer.IDFromBytes(req.Peer)
if err != nil {
return errorResponse(err), nil, nil
}

ctx, cancel := d.dhtRequestContext(req)

ch, err := d.dht.FindPeersConnectedToPeer(ctx, p)
if err != nil {
cancel()
return errorResponse(err), nil, nil
}

rch := make(chan *pb.DHTResponse)
go func() {
defer cancel()
defer close(rch)
for pi := range ch {
select {
case rch <- dhtResponsePeerInfo(*pi):
case <-ctx.Done():
return
}
}
}()

return dhtOkResponse(dhtResponseBegin()), rch, cancel
return errorResponseString("not supported"), nil, nil
}

func (d *Daemon) doDHTFindProviders(req *pb.DHTRequest) (*pb.Response, <-chan *pb.DHTResponse, func()) {
Expand All @@ -120,7 +91,7 @@ func (d *Daemon) doDHTFindProviders(req *pb.DHTRequest) (*pb.Response, <-chan *p
return errorResponse(err), nil, nil
}

count := dht.KValue
count := defaultProviderCount
if req.GetCount() > 0 {
count = int(*req.Count)
}
Expand Down
49 changes: 22 additions & 27 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,29 @@ module github.com/libp2p/go-libp2p-daemon
go 1.12

require (
github.com/ChainSafe/log15 v1.0.0 // indirect
github.com/gogo/protobuf v1.3.1
github.com/hashicorp/go-multierror v1.0.0
github.com/ipfs/go-cid v0.0.5
github.com/ipfs/go-log v1.0.3
github.com/libp2p/go-libp2p v0.8.1
github.com/libp2p/go-libp2p-autonat-svc v0.1.0
github.com/libp2p/go-libp2p-circuit v0.2.1
github.com/libp2p/go-libp2p-connmgr v0.1.1
github.com/libp2p/go-libp2p-core v0.5.1
github.com/libp2p/go-libp2p-kad-dht v0.3.2
github.com/libp2p/go-libp2p-noise v0.1.1-0.20200507064022-02dc2ad5c414
github.com/libp2p/go-libp2p-peerstore v0.2.2
github.com/libp2p/go-libp2p-pubsub v0.2.4
github.com/libp2p/go-libp2p-quic-transport v0.2.2
github.com/hashicorp/go-multierror v1.1.0
github.com/ipfs/go-cid v0.0.7
github.com/ipfs/go-log v1.0.4
github.com/libp2p/go-libp2p v0.10.3
github.com/libp2p/go-libp2p-circuit v0.3.1
github.com/libp2p/go-libp2p-connmgr v0.2.4
github.com/libp2p/go-libp2p-core v0.6.1
github.com/libp2p/go-libp2p-kad-dht v0.8.3
github.com/libp2p/go-libp2p-noise v0.1.1
github.com/libp2p/go-libp2p-peerstore v0.2.6
github.com/libp2p/go-libp2p-pubsub v0.3.4
github.com/libp2p/go-libp2p-quic-transport v0.7.1
github.com/libp2p/go-libp2p-secio v0.2.2
github.com/libp2p/go-libp2p-tls v0.1.3
github.com/mattn/go-colorable v0.1.4 // indirect
github.com/mattn/go-isatty v0.0.11 // indirect
github.com/multiformats/go-multiaddr v0.2.1
github.com/multiformats/go-multiaddr-net v0.1.4
github.com/multiformats/go-multihash v0.0.13
github.com/prometheus/client_golang v1.2.1
github.com/stretchr/testify v1.5.1
github.com/whyrusleeping/go-logging v0.0.1 // indirect
go.uber.org/atomic v1.5.1 // indirect
go.uber.org/multierr v1.4.0 // indirect
go.uber.org/zap v1.13.0 // indirect
golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f // indirect
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553 // indirect
github.com/multiformats/go-multiaddr v0.3.0
github.com/multiformats/go-multiaddr-net v0.2.0 // indirect
github.com/multiformats/go-multihash v0.0.14
github.com/prometheus/client_golang v1.7.1
github.com/stretchr/testify v1.6.1
golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37 // indirect
golang.org/x/net v0.0.0-20200602114024-627f9648deb9 // indirect
google.golang.org/protobuf v1.24.0 // indirect
gopkg.in/yaml.v2 v2.3.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20200602154603-c1a7af8cc6cd // indirect
)
Loading