Merge branch 'master' into old-engine

This commit is contained in:
nikk gitanes
2023-08-23 18:15:48 +03:00
22 changed files with 257 additions and 61 deletions

View File

@@ -2,7 +2,6 @@ package torr
import (
"io"
"io/ioutil"
"os"
"path/filepath"
"sort"
@@ -143,7 +142,7 @@ func RemTorrent(hashHex string) {
hash := metainfo.NewHashFromHex(hashHex)
if sets.BTsets.UseDisk && hashHex != "" && hashHex != "/" {
name := filepath.Join(sets.BTsets.TorrentsSavePath, hashHex)
ff, _ := ioutil.ReadDir(name)
ff, _ := os.ReadDir(name)
for _, f := range ff {
os.Remove(filepath.Join(name, f.Name()))
}

View File

@@ -5,7 +5,6 @@ import (
"fmt"
"log"
"net"
"strconv"
"sync"
"github.com/anacrolix/publicip"
@@ -131,20 +130,21 @@ func (bt *BTServer) configure(ctx context.Context) {
log.Println("Set listen port", settings.BTsets.PeersListenPort)
bt.config.ListenPort = settings.BTsets.PeersListenPort
} else {
lport := 32000
for {
log.Println("Check listen port", lport)
l, err := net.Listen("tcp", ":"+strconv.Itoa(lport))
if l != nil {
l.Close()
}
if err == nil {
break
}
lport++
}
log.Println("Set listen port", lport)
bt.config.ListenPort = lport
// lport := 32000
// for {
// log.Println("Check listen port", lport)
// l, err := net.Listen("tcp", ":"+strconv.Itoa(lport))
// if l != nil {
// l.Close()
// }
// if err == nil {
// break
// }
// lport++
// }
// log.Println("Set listen port", lport)
log.Println("Set listen port to random autoselect (0)")
bt.config.ListenPort = 0 // lport
}
}

View File

@@ -2,7 +2,7 @@ package utils
import (
"bufio"
"io/ioutil"
"os"
"path/filepath"
"strings"
@@ -12,7 +12,7 @@ import (
)
func ReadBlockedIP() (ranger iplist.Ranger, err error) {
buf, err := ioutil.ReadFile(filepath.Join(settings.Path, "blocklist"))
buf, err := os.ReadFile(filepath.Join(settings.Path, "blocklist"))
if err != nil {
return nil, err
}

View File

@@ -2,9 +2,10 @@ package utils
import (
"encoding/base32"
"io/ioutil"
"io"
"math/rand"
"net/http"
"os"
"path/filepath"
"strings"
@@ -14,7 +15,7 @@ import (
)
var defTrackers = []string{
"http://retracker.local",
"http://retracker.local/announce",
"http://bt4.t-ru.org/ann?magnet",
"http://retracker.mgts.by:80/announce",
"http://tracker.city9x.com:2710/announce",
@@ -34,7 +35,7 @@ var loadedTrackers []string
func GetTrackerFromFile() []string {
name := filepath.Join(settings.Path, "trackers.txt")
buf, err := ioutil.ReadFile(name)
buf, err := os.ReadFile(name)
if err == nil {
list := strings.Split(string(buf), "\n")
var ret []string
@@ -62,7 +63,7 @@ func loadNewTracker() {
}
resp, err := http.Get("https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_best_ip.txt")
if err == nil {
buf, err := ioutil.ReadAll(resp.Body)
buf, err := io.ReadAll(resp.Body)
if err == nil {
arr := strings.Split(string(buf), "\n")
var ret []string