Fix crash printing client status if DHT isn't enabled

This commit is contained in:
Matt Joiner 2014-07-23 01:50:49 +10:00
parent 244c70bc83
commit 3ae290fef6
1 changed files with 3 additions and 1 deletions

View File

@ -121,7 +121,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())
if cl.DHT != nil {
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 {