From 2f0e06cfe42241e273dedadd62824cb33e35c705 Mon Sep 17 00:00:00 2001 From: kilo Date: Mon, 16 Oct 2017 04:55:38 +0200 Subject: [PATCH] Update stats.go (#1672) --- controllers/torrent/stats.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/controllers/torrent/stats.go b/controllers/torrent/stats.go index 25bdcece..eb0bd089 100644 --- a/controllers/torrent/stats.go +++ b/controllers/torrent/stats.go @@ -27,12 +27,14 @@ func GetStatsHandler(c *gin.Context) { } var Trackers []string - for _, line := range strings.Split(torrent.Trackers[3:], "&tr=") { - tracker, error := url.QueryUnescape(line) - if error == nil && strings.Contains(tracker, "udp://") { - Trackers = append(Trackers, tracker) + if len(Trackers) > 3 { + for _, line := range strings.Split(torrent.Trackers[3:], "&tr=") { + tracker, error := url.QueryUnescape(line) + if error == nil && strings.Contains(tracker, "udp://") { + Trackers = append(Trackers, tracker) + } + //Cannot scrape from http trackers so don't put them in the array } - //Cannot scrape from http trackers so don't put them in the array } for _, line := range config.Get().Torrents.Trackers.Default {