From faab9842789524eaf75e1aa5246165db7ffbd48a Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet <juan@benet.ai> Date: Tue, 18 Nov 2014 00:47:42 -0800 Subject: [PATCH] net: expose GetConnections --- net/interface.go | 4 ++++ net/net.go | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/net/interface.go b/net/interface.go index 04a74c0bf..3c0e8d204 100644 --- a/net/interface.go +++ b/net/interface.go @@ -2,6 +2,7 @@ package net import ( "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context" + conn "github.com/jbenet/go-ipfs/net/conn" msg "github.com/jbenet/go-ipfs/net/message" mux "github.com/jbenet/go-ipfs/net/mux" srv "github.com/jbenet/go-ipfs/net/service" @@ -34,6 +35,9 @@ type Network interface { // GetPeerList returns the list of peers currently connected in this network. GetPeerList() []peer.Peer + // GetConnections returns the list of connections currently open in this network. + GetConnections() []conn.Conn + // GetBandwidthTotals returns the total number of bytes passed through // the network since it was instantiated GetBandwidthTotals() (uint64, uint64) diff --git a/net/net.go b/net/net.go index 4fdd7c7e7..0ee1e76b5 100644 --- a/net/net.go +++ b/net/net.go @@ -2,6 +2,7 @@ package net import ( + conn "github.com/jbenet/go-ipfs/net/conn" msg "github.com/jbenet/go-ipfs/net/message" mux "github.com/jbenet/go-ipfs/net/mux" swarm "github.com/jbenet/go-ipfs/net/swarm" @@ -99,6 +100,11 @@ func (n *IpfsNetwork) GetPeerList() []peer.Peer { return n.swarm.GetPeerList() } +// GetConnections returns the networks list of open connections +func (n *IpfsNetwork) GetConnections() []conn.Conn { + return n.swarm.Connections() +} + // GetBandwidthTotals returns the total amount of bandwidth transferred func (n *IpfsNetwork) GetBandwidthTotals() (in uint64, out uint64) { return n.muxer.GetBandwidthTotals() -- GitLab