From e7481b31c1dbd057990f048636150f957a50ac34 Mon Sep 17 00:00:00 2001 From: Justin Li Date: Wed, 23 Jul 2014 00:56:11 -0400 Subject: [PATCH] Don't write ipv6 peers field if empty --- http/writer.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/http/writer.go b/http/writer.go index 3d16b61..66a179d 100644 --- a/http/writer.go +++ b/http/writer.go @@ -40,7 +40,12 @@ func (w *Writer) WriteAnnounce(res *models.AnnounceResponse) error { dict["peers"] = compactPeers(false, res.IPv4Peers) } 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 { dict["peers"] = peersList(res.IPv6Peers, res.IPv4Peers)