diff --git a/.gx/lastpubver b/.gx/lastpubver index 7c4270b4ccce49df5fe062a3d9f7857629316138..ff36fe0188ce91d7379f7820b81689bb146f4492 100644 --- a/.gx/lastpubver +++ b/.gx/lastpubver @@ -1 +1 @@ -4.4.1: QmapADMpK4e5kFGBxC2aHreaDqKP9vmMng5f91MA14Ces9 +4.4.2: QmNoCFYrmNFZxpv4KRGHujfsX2QqC3gH4bLJfkizZHFdUS diff --git a/.travis.yml b/.travis.yml index 386f384fc86cef11db87a5bd1e70a90aade51a5f..bac2a193a5bb27f3c777cd81f6804fbca9e67dba 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ os: language: go go: - - 1.7 + - 1.8 install: true diff --git a/p2p/host/basic/basic_host.go b/p2p/host/basic/basic_host.go index f0297f1975edf3edda175ba9a2d350e73c0f0c6b..88e8c609c733e63f80f540837facd93557df21f4 100644 --- a/p2p/host/basic/basic_host.go +++ b/p2p/host/basic/basic_host.go @@ -9,6 +9,7 @@ import ( logging "github.com/ipfs/go-log" goprocess "github.com/jbenet/goprocess" + connmgr "github.com/libp2p/go-libp2p-connmgr" metrics "github.com/libp2p/go-libp2p-metrics" mstream "github.com/libp2p/go-libp2p-metrics/stream" inet "github.com/libp2p/go-libp2p-net" @@ -58,6 +59,7 @@ type BasicHost struct { ids *identify.IDService natmgr NATManager addrs AddrsFactory + cmgr connmgr.ConnManager negtimeout time.Duration @@ -92,6 +94,9 @@ type HostOpts struct { // BandwidthReporter metrics.Reporter + + // ConnManager is a libp2p connection manager + ConnManager connmgr.ConnManager } // NewHost constructs a new *BasicHost and activates it by attaching its stream and connection handlers to the given inet.Network. @@ -131,6 +136,13 @@ func NewHost(net inet.Network, opts *HostOpts) *BasicHost { h.ids.Reporter = opts.BandwidthReporter } + if opts.ConnManager == nil { + // create 'disabled' conn manager for now + h.cmgr = connmgr.NewConnManager(0, 0, 0) + } else { + h.cmgr = opts.ConnManager + } + h.proc = goprocess.WithTeardown(func() error { if h.natmgr != nil { h.natmgr.Close() @@ -161,6 +173,8 @@ func New(net inet.Network, opts ...interface{}) *BasicHost { hostopts.BandwidthReporter = o case AddrsFactory: hostopts.AddrsFactory = AddrsFactory(o) + case connmgr.ConnManager: + hostopts.ConnManager = o } } @@ -411,6 +425,10 @@ func (h *BasicHost) dialPeer(ctx context.Context, p peer.ID) error { return nil } +func (h *BasicHost) ConnManager() connmgr.ConnManager { + return h.cmgr +} + // Addrs returns listening addresses that are safe to announce to the network. // The output is the same as AllAddrs, but processed by AddrsFactory. func (h *BasicHost) Addrs() []ma.Multiaddr { diff --git a/p2p/host/routed/routed.go b/p2p/host/routed/routed.go index 97493ad5e4590f959f5a32728c839fa3cb287da4..92e77a599f6567edcc51827cf92bd82e1e9847f0 100644 --- a/p2p/host/routed/routed.go +++ b/p2p/host/routed/routed.go @@ -8,6 +8,7 @@ import ( host "github.com/libp2p/go-libp2p-host" logging "github.com/ipfs/go-log" + connmgr "github.com/libp2p/go-libp2p-connmgr" lgbl "github.com/libp2p/go-libp2p-loggables" inet "github.com/libp2p/go-libp2p-net" peer "github.com/libp2p/go-libp2p-peer" @@ -124,5 +125,8 @@ func (rh *RoutedHost) Close() error { // no need to close IpfsRouting. we dont own it. return rh.host.Close() } +func (rh *RoutedHost) ConnManager() connmgr.ConnManager { + return rh.host.ConnManager() +} var _ (host.Host) = (*RoutedHost)(nil) diff --git a/package.json b/package.json index 98f625572f08ff271c743aca13ad32d32a666801..f2fe02029a626267b33eea9e90e8a8f32fc034a8 100644 --- a/package.json +++ b/package.json @@ -205,9 +205,9 @@ }, { "author": "whyrusleeping", - "hash": "QmZy7c24mmkEHpNJndwgsEE3wcVxHd8yB969yTnAJFVw7f", + "hash": "QmRNyPNJGNCaZyYonJj7owciWTsMd9gRfEKmZY3o6xwN3h", "name": "go-libp2p-host", - "version": "1.3.15" + "version": "1.3.16" }, { "author": "whyrusleeping", @@ -229,9 +229,9 @@ }, { "author": "whyrusleeping", - "hash": "QmQoFme2KBiCZmCwKDLoCVZShkYGjPt4YR7ihZK5c3vtzH", + "hash": "QmbQXcWAa9ZbTH74m6yroexY8QjTS4oivLNEFwjamZCJTU", "name": "go-libp2p-blankhost", - "version": "0.1.14" + "version": "0.1.15" } ], "gxVersion": "0.4.0", @@ -239,6 +239,6 @@ "license": "MIT", "name": "go-libp2p", "releaseCmd": "git commit -a -m \"gx publish $VERSION\"", - "version": "4.4.1" + "version": "4.4.2" }