Improve client status

This commit is contained in:
Matt Joiner 2014-07-24 13:43:11 +10:00
parent ef7c4f4120
commit ec1c4b0cf8
1 changed files with 7 additions and 1 deletions

View File

@ -96,7 +96,13 @@ type Client struct {
func (cl *Client) WriteStatus(w io.Writer) { func (cl *Client) WriteStatus(w io.Writer) {
cl.mu.Lock() cl.mu.Lock()
defer cl.mu.Unlock() defer cl.mu.Unlock()
fmt.Fprintf(w, "Half open: %d\n", cl.halfOpen) if cl.Listener != nil {
fmt.Fprintf(w, "Listening on %s\n", cl.Listener.Addr())
} else {
fmt.Fprintf(w, "No listening torrent port!\n")
}
fmt.Fprintf(w, "Peer ID: %q\n", cl.PeerId)
fmt.Fprintf(w, "Half open outgoing connections: %d\n", cl.halfOpen)
if cl.DHT != nil { if cl.DHT != nil {
fmt.Fprintf(w, "DHT nodes: %d\n", cl.DHT.NumNodes()) fmt.Fprintf(w, "DHT nodes: %d\n", cl.DHT.NumNodes())
} }