2021-12-14 10:13:17 +00:00
|
|
|
package trackers
|
|
|
|
|
|
|
|
import (
|
2022-05-18 03:28:14 +00:00
|
|
|
"bufio"
|
2021-12-14 10:13:17 +00:00
|
|
|
"strings"
|
2022-02-04 05:42:55 +00:00
|
|
|
|
2022-07-20 02:47:58 +00:00
|
|
|
"github.com/ledgerwatch/trackerslist"
|
|
|
|
)
|
2021-12-14 10:13:17 +00:00
|
|
|
|
2022-07-20 02:47:58 +00:00
|
|
|
var (
|
|
|
|
Best = split(trackerslist.Best)
|
|
|
|
Https = split(trackerslist.Https)
|
|
|
|
Http = split(trackerslist.Http)
|
|
|
|
Udp = split(trackerslist.Udp)
|
|
|
|
Ws = split(trackerslist.Ws)
|
|
|
|
)
|
2022-05-18 03:28:14 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|
2021-12-14 10:13:17 +00:00
|
|
|
|
2022-02-04 05:42:55 +00:00
|
|
|
func First(n int, in []string) (res []string) {
|
|
|
|
if n <= len(in) {
|
|
|
|
return in[:n]
|
2021-12-14 10:13:17 +00:00
|
|
|
}
|
2022-02-04 05:42:55 +00:00
|
|
|
return in
|
2021-12-14 10:13:17 +00:00
|
|
|
}
|