tracker: Return announcing peer if there are no others to avoid an empty peers field

This commit is contained in:
Justin Li
2015-02-28 00:56:45 -05:00
parent ac2fcade1e
commit da46ef8c8a
3 changed files with 18 additions and 12 deletions

View File

@@ -280,6 +280,10 @@ func newAnnounceResponse(ann *models.Announce) *models.AnnounceResponse {
if ann.NumWant > 0 && ann.Event != "stopped" && ann.Event != "paused" {
res.IPv4Peers, res.IPv6Peers = getPeers(ann)
if len(res.IPv4Peers)+len(res.IPv6Peers) == 0 {
models.AppendPeer(&res.IPv4Peers, &res.IPv6Peers, ann, ann.Peer)
}
}
return res