check if peer id exists

This commit is contained in:
davtoro 2019-04-13 15:25:19 +02:00 committed by Matt Joiner
parent bc249730aa
commit f40140283a
1 changed files with 3 additions and 1 deletions

View 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))
}