]> Sergey Matveev's repositories - btrtrc.git/commitdiff
check if peer id exists
authordavtoro <35560260+davtoro@users.noreply.github.com>
Sat, 13 Apr 2019 13:25:19 +0000 (15:25 +0200)
committerMatt Joiner <anacrolix@gmail.com>
Mon, 15 Apr 2019 07:58:23 +0000 (17:58 +1000)
tracker/peer.go

index 44d61e82882845dc92017c6ce71ef2559ed876ec..6f13c569c2b664de487f5a1250ccb781cbf74ab7 100644 (file)
@@ -15,7 +15,9 @@ type Peer struct {
 // Set from the non-compact form in BEP 3.
 func (p *Peer) fromDictInterface(d map[string]interface{}) {
        p.IP = net.ParseIP(d["ip"].(string))
-       p.ID = []byte(d["peer id"].(string))
+       if _, ok := d["peer id"]; ok {
+               p.ID = []byte(d["peer id"].(string))
+       }
        p.Port = int(d["port"].(int64))
 }