client.go | 3 +++ connection.go | 2 +- dht/dht.go | 6 ++++++ torrent.go | 1 + diff --git a/client.go b/client.go index 9808a2aa8ca91954dceded26b5eb19a55e17bd5f..6362275e46715074de55102b1d397440ab1cd8e8 100644 --- a/client.go +++ b/client.go @@ -120,6 +120,9 @@ 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 2832e0cfcc54e379791bb189896e24cca0406a28..f07473757ec262149d6fb9f72784660515fa0c92 100644 --- a/connection.go +++ b/connection.go @@ -69,7 +69,7 @@ return } 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 16e4a20b3b4335faf931d1aee442324a408688b7..257945418344a050510c571fedf7a9ba6203337a 100644 --- a/dht/dht.go +++ b/dht/dht.go @@ -679,6 +679,12 @@ } 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 8a2124576f7a1c954d91fc3b574c4d99389d9e5b..a96c48d6273b957850bb8457acb70b21b227fb6e 100644 --- a/torrent.go +++ b/torrent.go @@ -206,6 +206,7 @@ for e := t.Priorities.Front(); e != nil; e = e.Next() { 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) }