Don't write ipv6 peers field if empty
This commit is contained in:
parent
b99e5e0c36
commit
e7481b31c1
1 changed files with 6 additions and 1 deletions
|
@ -40,7 +40,12 @@ func (w *Writer) WriteAnnounce(res *models.AnnounceResponse) error {
|
||||||
dict["peers"] = compactPeers(false, res.IPv4Peers)
|
dict["peers"] = compactPeers(false, res.IPv4Peers)
|
||||||
}
|
}
|
||||||
if res.IPv6Peers != nil {
|
if res.IPv6Peers != nil {
|
||||||
dict["peers6"] = compactPeers(true, res.IPv6Peers)
|
compact := compactPeers(true, res.IPv6Peers)
|
||||||
|
|
||||||
|
// Don't bother writing the IPv6 field if there is no value.
|
||||||
|
if len(compact) > 0 {
|
||||||
|
dict["peers6"] = compact
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if res.IPv4Peers != nil || res.IPv6Peers != nil {
|
} else if res.IPv4Peers != nil || res.IPv6Peers != nil {
|
||||||
dict["peers"] = peersList(res.IPv6Peers, res.IPv4Peers)
|
dict["peers"] = peersList(res.IPv6Peers, res.IPv4Peers)
|
||||||
|
|
Loading…
Reference in a new issue