mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-21 14:36:09 +05:00
revert to _9 and add save info bytes
This commit is contained in:
@@ -4,7 +4,6 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"server/settings"
|
||||
"server/torr/storage/memcache"
|
||||
@@ -80,10 +79,10 @@ func (bt *BTServer) configure() {
|
||||
bt.config.NoDefaultPortForwarding = settings.Get().DisableUPNP
|
||||
bt.config.NoDHT = settings.Get().DisableDHT
|
||||
bt.config.NoUpload = settings.Get().DisableUpload
|
||||
//bt.config.EncryptionPolicy = torrent.EncryptionPolicy{
|
||||
// DisableEncryption: settings.Get().Encryption == 1,
|
||||
// ForceEncryption: settings.Get().Encryption == 2,
|
||||
//}
|
||||
bt.config.EncryptionPolicy = torrent.EncryptionPolicy{
|
||||
DisableEncryption: settings.Get().Encryption == 1,
|
||||
ForceEncryption: settings.Get().Encryption == 2,
|
||||
}
|
||||
bt.config.IPBlocklist = blocklist
|
||||
bt.config.DefaultStorage = bt.storage
|
||||
bt.config.Bep20 = peerID
|
||||
@@ -91,13 +90,6 @@ func (bt *BTServer) configure() {
|
||||
bt.config.HTTPUserAgent = userAgent
|
||||
bt.config.ExtendedHandshakeClientVersion = cliVers
|
||||
bt.config.EstablishedConnsPerTorrent = settings.Get().ConnectionsLimit
|
||||
if settings.Get().PeerStrategy == 1 { //Fastest
|
||||
bt.config.DefaultRequestStrategy = torrent.RequestStrategyFastest()
|
||||
} else if settings.Get().PeerStrategy == 2 { //Fuzzing
|
||||
bt.config.DefaultRequestStrategy = torrent.RequestStrategyFuzzing()
|
||||
} else {
|
||||
bt.config.DefaultRequestStrategy = torrent.RequestStrategyDuplicateRequestTimeout(time.Second * 5)
|
||||
}
|
||||
if settings.Get().DhtConnectionLimit > 0 {
|
||||
bt.config.ConnTracker.SetMaxEntries(settings.Get().DhtConnectionLimit)
|
||||
}
|
||||
@@ -115,8 +107,8 @@ func (bt *BTServer) configure() {
|
||||
log.Println("Configure client:", settings.Get())
|
||||
}
|
||||
|
||||
func (bt *BTServer) AddTorrent(magnet metainfo.Magnet, onAdd func(*Torrent)) (*Torrent, error) {
|
||||
torr, err := NewTorrent(magnet, bt)
|
||||
func (bt *BTServer) AddTorrent(magnet metainfo.Magnet, infobytes []byte, onAdd func(*Torrent)) (*Torrent, error) {
|
||||
torr, err := NewTorrent(magnet, infobytes, bt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -169,7 +161,6 @@ func (bt *BTServer) BTState() *BTState {
|
||||
btState.LocalPort = bt.client.LocalPort()
|
||||
btState.PeerID = fmt.Sprintf("%x", bt.client.PeerID())
|
||||
btState.BannedIPs = len(bt.client.BadPeerIPs())
|
||||
|
||||
for _, dht := range bt.client.DhtServers() {
|
||||
btState.DHTs = append(btState.DHTs, dht)
|
||||
}
|
||||
|
||||
@@ -8,10 +8,11 @@ import (
|
||||
"server/settings"
|
||||
"server/utils"
|
||||
|
||||
"log"
|
||||
|
||||
"github.com/anacrolix/missinggo/httptoo"
|
||||
"github.com/anacrolix/torrent"
|
||||
"github.com/labstack/echo"
|
||||
"log"
|
||||
)
|
||||
|
||||
func (bt *BTServer) View(torr *Torrent, file *torrent.File, c echo.Context) error {
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package torr
|
||||
|
||||
import (
|
||||
"github.com/anacrolix/torrent"
|
||||
"github.com/anacrolix/dht"
|
||||
)
|
||||
|
||||
type BTState struct {
|
||||
LocalPort int
|
||||
PeerID string
|
||||
BannedIPs int
|
||||
DHTs []torrent.DhtServer
|
||||
DHTs []*dht.Server
|
||||
|
||||
Torrents []*Torrent
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ type Torrent struct {
|
||||
progressTicker *time.Ticker
|
||||
}
|
||||
|
||||
func NewTorrent(magnet metainfo.Magnet, bt *BTServer) (*Torrent, error) {
|
||||
func NewTorrent(magnet metainfo.Magnet, infobytes []byte, bt *BTServer) (*Torrent, error) {
|
||||
switch settings.Get().RetrackersMode {
|
||||
case 1:
|
||||
magnet.Trackers = append(magnet.Trackers, utils.GetDefTrackers()...)
|
||||
@@ -84,6 +84,7 @@ func NewTorrent(magnet metainfo.Magnet, bt *BTServer) (*Torrent, error) {
|
||||
magnet.Trackers = utils.GetDefTrackers()
|
||||
}
|
||||
goTorrent, _, err := bt.client.AddTorrentSpec(&torrent.TorrentSpec{
|
||||
InfoBytes: infobytes,
|
||||
Trackers: [][]string{magnet.Trackers},
|
||||
DisplayName: magnet.DisplayName,
|
||||
InfoHash: magnet.InfoHash,
|
||||
|
||||
Reference in New Issue
Block a user