diff --git a/client.go b/client.go index 9808a2aa..6362275e 100644 --- a/client.go +++ b/client.go @@ -120,6 +120,9 @@ type Client struct { func (cl *Client) WriteStatus(w io.Writer) { cl.mu.Lock() defer cl.mu.Unlock() + fmt.Fprintf(w, "Half open: %d\n", cl.halfOpen) + fmt.Fprintf(w, "DHT nodes: %d\n", cl.DHT.NumNodes()) + fmt.Fprintln(w) for _, t := range cl.torrents { fmt.Fprintf(w, "%s: %f%%\n", t.Name(), func() float32 { if !t.haveInfo() { diff --git a/connection.go b/connection.go index 2832e0cf..f0747375 100644 --- a/connection.go +++ b/connection.go @@ -69,7 +69,7 @@ func (cn *connection) piecesPeerHasCount() (count int) { } func (cn *connection) WriteStatus(w io.Writer) { - fmt.Fprintf(w, "%q: %s-%s: %s completed: ", cn.PeerId, cn.Socket.LocalAddr(), cn.Socket.RemoteAddr(), cn.completedString()) + fmt.Fprintf(w, "%q: %s-%s: %s completed, reqs: %d-%d, flags: ", cn.PeerId, cn.Socket.LocalAddr(), cn.Socket.RemoteAddr(), cn.completedString(), len(cn.Requests), len(cn.PeerRequests)) c := func(b byte) { fmt.Fprintf(w, "%c", b) } diff --git a/dht/dht.go b/dht/dht.go index 16e4a20b..25794541 100644 --- a/dht/dht.go +++ b/dht/dht.go @@ -679,6 +679,12 @@ func (s *Server) Bootstrap() (err error) { return } +func (s *Server) NumNodes() int { + s.mu.Lock() + defer s.mu.Unlock() + return len(s.nodes) +} + func (s *Server) Nodes() (nis []NodeInfo) { s.mu.Lock() defer s.mu.Unlock() diff --git a/torrent.go b/torrent.go index 8a212457..a96c48d6 100644 --- a/torrent.go +++ b/torrent.go @@ -206,6 +206,7 @@ func (t *torrent) WriteStatus(w io.Writer) { fmt.Fprintf(w, "\t%v\n", e.Value) } } + fmt.Fprintf(w, "Pending peers: %d\n", len(t.Peers)) for _, c := range t.Conns { c.WriteStatus(w) }