revert to old engine

This commit is contained in:
nikk gitanes
2021-07-20 07:44:44 +03:00
parent 8355ad3794
commit 2ec43233fb
16 changed files with 98 additions and 878 deletions

View File

@@ -63,8 +63,6 @@ func (bt *BTServer) configure() {
peerID := "-qB4320-"
cliVers := userAgent //"uTorrent/2210(25302)"
bt.config.AcceptPeerConnections = settings.BTsets.AcceptPeerCon
bt.config.PeriodicallyAnnounceTorrentsToDht = settings.BTsets.AnnTorrentsToDht
bt.config.Debug = settings.BTsets.EnableDebug
bt.config.DisableIPv6 = settings.BTsets.EnableIPv6 == false
bt.config.DisableTCP = settings.BTsets.DisableTCP
@@ -81,11 +79,13 @@ func (bt *BTServer) configure() {
bt.config.EstablishedConnsPerTorrent = settings.BTsets.ConnectionsLimit
// Encryption/Obfuscation
bt.config.HeaderObfuscationPolicy = torrent.HeaderObfuscationPolicy{
RequirePreferred: settings.BTsets.ForceEncrypt,
Preferred: true,
bt.config.EncryptionPolicy = torrent.EncryptionPolicy{
ForceEncryption: settings.BTsets.ForceEncrypt,
}
if settings.BTsets.DhtConnectionLimit > 0 {
bt.config.ConnTracker.SetMaxEntries(settings.BTsets.DhtConnectionLimit)
}
if settings.BTsets.DownloadRateLimit > 0 {
bt.config.DownloadRateLimiter = utils.Limit(settings.BTsets.DownloadRateLimit * 1024)
}

View File

@@ -8,6 +8,8 @@ import (
"sync"
"time"
"github.com/anacrolix/torrent"
"server/log"
"server/settings"
)
@@ -82,4 +84,6 @@ func (p *DiskPiece) Release() {
p.piece.Complete = false
os.Remove(p.name)
p.piece.cache.torrent.Piece(p.piece.Id).SetPriority(torrent.PiecePriorityNone)
}

View File

@@ -4,6 +4,8 @@ import (
"io"
"sync"
"time"
"github.com/anacrolix/torrent"
)
type MemPiece struct {
@@ -67,4 +69,6 @@ func (p *MemPiece) Release() {
}
p.piece.Size = 0
p.piece.Complete = false
p.piece.cache.torrent.Piece(p.piece.Id).SetPriority(torrent.PiecePriorityNone)
}

View File

@@ -1,9 +1,7 @@
package torrstor
import (
"github.com/anacrolix/torrent"
"github.com/anacrolix/torrent/storage"
"server/settings"
)
@@ -75,7 +73,4 @@ func (p *Piece) Release() {
} else {
p.dPiece.Release()
}
p.cache.torrent.Piece(p.Id).SetPriority(torrent.PiecePriorityNone)
p.cache.torrent.Piece(p.Id).UpdateCompletion()
}

View File

@@ -30,11 +30,7 @@ func (s *Storage) OpenTorrent(info *metainfo.Info, infoHash metainfo.Hash) (stor
ch := NewCache(s.capacity, s)
ch.Init(info, infoHash)
s.caches[infoHash] = ch
//return ch, nil
return storage2.TorrentImpl{
Piece: ch.Piece,
Close: ch.Close,
}, nil
return ch, nil
}
func (s *Storage) CloseHash(hash metainfo.Hash) {