mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-03 17:44:29 +00:00
41 lines
658 B
Go
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
|
|
}
|