mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 21:46:11 +05:00
trackers from file
This commit is contained in:
@@ -65,6 +65,11 @@ func NewTorrent(spec *torrent.TorrentSpec, bt *BTServer) (*Torrent, error) {
|
|||||||
spec.Trackers = [][]string{utils.GetDefTrackers()}
|
spec.Trackers = [][]string{utils.GetDefTrackers()}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trackers := utils.GetTrackerFromFile()
|
||||||
|
if len(trackers) > 0 {
|
||||||
|
spec.Trackers = append(spec.Trackers, [][]string{trackers}...)
|
||||||
|
}
|
||||||
|
|
||||||
goTorrent, _, err := bt.client.AddTorrentSpec(spec)
|
goTorrent, _, err := bt.client.AddTorrentSpec(spec)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -5,8 +5,11 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"server/settings"
|
||||||
|
|
||||||
"golang.org/x/time/rate"
|
"golang.org/x/time/rate"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -27,6 +30,22 @@ var defTrackers = []string{
|
|||||||
|
|
||||||
var loadedTrackers []string
|
var loadedTrackers []string
|
||||||
|
|
||||||
|
func GetTrackerFromFile() []string {
|
||||||
|
name := filepath.Join(settings.Path, "trackers.txt")
|
||||||
|
buf, err := ioutil.ReadFile(name)
|
||||||
|
if err == nil {
|
||||||
|
list := strings.Split(string(buf), "\n")
|
||||||
|
var ret []string
|
||||||
|
for _, l := range list {
|
||||||
|
if strings.HasPrefix(l, "udp") || strings.HasPrefix(l, "http") {
|
||||||
|
ret = append(ret, l)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func GetDefTrackers() []string {
|
func GetDefTrackers() []string {
|
||||||
loadNewTracker()
|
loadNewTracker()
|
||||||
if len(loadedTrackers) == 0 {
|
if len(loadedTrackers) == 0 {
|
||||||
|
|||||||
Reference in New Issue
Block a user