erigon-pulse/downloader/trackers/embed.go
2022-11-20 10:41:20 +07:00

41 lines
658 B
Go

package trackers
import (
"bufio"
"strings"
"github.com/ledgerwatch/trackerslist"
)
var (
Best = split(trackerslist.Best)
Https = split(trackerslist.Https)
Http = split(trackerslist.Http)
Udp = split(trackerslist.Udp)
Ws = split(trackerslist.Ws)
)
func split(txt string) (lines []string) {
sc := bufio.NewScanner(strings.NewReader(txt))
for sc.Scan() {
l := sc.Text()
l = strings.TrimSpace(l)
if len(l) == 0 {
continue
}
lines = append(lines, sc.Text())
}
if err := sc.Err(); err != nil {
panic(err)
}
return lines
}
func First(n int, in []string) (res []string) {
if n <= len(in) {
return in[:n]
}
return in
}