add block ip

This commit is contained in:
yourok
2020-02-14 12:44:12 +03:00
parent 03374b876a
commit 19e5188905

View File

@@ -3,7 +3,6 @@ package torr
import ( import (
"fmt" "fmt"
"io" "io"
"path/filepath"
"sync" "sync"
"server/settings" "server/settings"
@@ -11,10 +10,10 @@ import (
"server/torr/storage/state" "server/torr/storage/state"
"server/utils" "server/utils"
"github.com/anacrolix/torrent"
"github.com/anacrolix/torrent/iplist"
"github.com/anacrolix/torrent/metainfo"
"log" "log"
"github.com/anacrolix/torrent"
"github.com/anacrolix/torrent/metainfo"
) )
type BTServer struct { type BTServer struct {
@@ -53,7 +52,7 @@ func (bt *BTServer) Disconnect() {
if bt.client != nil { if bt.client != nil {
bt.client.Close() bt.client.Close()
bt.client = nil bt.client = nil
utils.FreeOSMemGC(0) utils.FreeOSMemGC()
} }
} }
@@ -65,7 +64,8 @@ func (bt *BTServer) Reconnect() error {
func (bt *BTServer) configure() { func (bt *BTServer) configure() {
bt.storage = memcache.NewStorage(settings.Get().CacheSize) bt.storage = memcache.NewStorage(settings.Get().CacheSize)
blocklist, _ := iplist.MMapPackedFile(filepath.Join(settings.Path, "blocklist")) //blocklist, _ := iplist.MMapPackedFile(filepath.Join(settings.Path, "blocklist"))
blocklist, _ := utils.ReadBlockedIP()
userAgent := "uTorrent/3.5.5" userAgent := "uTorrent/3.5.5"
peerID := "-UT3550-" peerID := "-UT3550-"