@cryptotaxi247 / kubo / commits / faab98427

net: expose GetConnections

Juan Batiz-Benet committed Nov 18, 2014 at 00:47 UTC faab9842789524eaf75e1aa5246165db7ffbd48a
2 files changed +10
net/interface.go
+4
@@ -2,6 +2,7 @@ package net
2
3 import (
4 "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
5 + conn "github.com/jbenet/go-ipfs/net/conn"
6 msg "github.com/jbenet/go-ipfs/net/message"
7 mux "github.com/jbenet/go-ipfs/net/mux"
8 srv "github.com/jbenet/go-ipfs/net/service"
@@ -34,6 +35,9 @@ type Network interface {
35 // GetPeerList returns the list of peers currently connected in this network.
36 GetPeerList() []peer.Peer
37
38 + // GetConnections returns the list of connections currently open in this network.
39 + GetConnections() []conn.Conn
40 +
41 // GetBandwidthTotals returns the total number of bytes passed through
42 // the network since it was instantiated
43 GetBandwidthTotals() (uint64, uint64)
net/net.go
+6
@@ -2,6 +2,7 @@
2 package net
3
4 import (
5 + conn "github.com/jbenet/go-ipfs/net/conn"
6 msg "github.com/jbenet/go-ipfs/net/message"
7 mux "github.com/jbenet/go-ipfs/net/mux"
8 swarm "github.com/jbenet/go-ipfs/net/swarm"
@@ -99,6 +100,11 @@ func (n *IpfsNetwork) GetPeerList() []peer.Peer {
100 return n.swarm.GetPeerList()
101 }
102
103 +// GetConnections returns the networks list of open connections
104 +func (n *IpfsNetwork) GetConnections() []conn.Conn {
105 + return n.swarm.Connections()
106 +}
107 +
108 // GetBandwidthTotals returns the total amount of bandwidth transferred
109 func (n *IpfsNetwork) GetBandwidthTotals() (in uint64, out uint64) {
110 return n.muxer.GetBandwidthTotals()