diff --git a/server/go.mod b/server/go.mod index a35e8db..24e2344 100644 --- a/server/go.mod +++ b/server/go.mod @@ -20,7 +20,7 @@ require ( github.com/pkg/errors v0.9.1 github.com/swaggo/files v1.0.1 github.com/swaggo/gin-swagger v1.6.0 - github.com/swaggo/swag v1.16.2 + github.com/swaggo/swag v1.16.3 go.etcd.io/bbolt v1.3.8 golang.org/x/image v0.15.0 golang.org/x/time v0.5.0 @@ -29,7 +29,7 @@ require ( require ( github.com/KyleBanks/depth v1.2.1 // indirect - github.com/RoaringBitmap/roaring v1.7.0 // indirect + github.com/RoaringBitmap/roaring v1.9.0 // indirect github.com/alecthomas/atomic v0.1.0-alpha2 // indirect github.com/alexflint/go-scalar v1.2.0 // indirect github.com/anacrolix/chansync v0.4.0 // indirect @@ -58,17 +58,18 @@ require ( github.com/go-openapi/jsonpointer v0.20.2 // indirect github.com/go-openapi/jsonreference v0.20.4 // indirect github.com/go-openapi/spec v0.20.14 // indirect - github.com/go-openapi/swag v0.22.8 // indirect + github.com/go-openapi/swag v0.22.9 // indirect github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect github.com/go-playground/validator/v10 v10.17.0 // indirect github.com/goccy/go-json v0.10.2 // indirect github.com/google/btree v1.1.2 // indirect + github.com/google/go-cmp v0.6.0 // indirect github.com/huandu/xstrings v1.4.0 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/cpuid/v2 v2.2.6 // indirect - github.com/leodido/go-urn v1.2.4 // indirect + github.com/leodido/go-urn v1.3.0 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect diff --git a/server/go.sum b/server/go.sum index fbcde88..7855689 100644 --- a/server/go.sum +++ b/server/go.sum @@ -9,8 +9,8 @@ github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6Xge github.com/RoaringBitmap/roaring v0.4.7/go.mod h1:8khRDP4HmeXns4xIj9oGrKSz7XTQiJx2zgh7AcNke4w= github.com/RoaringBitmap/roaring v0.4.17/go.mod h1:D3qVegWTmfCaX4Bl5CrBE9hfrSrrXIr8KVNvRsDi1NI= github.com/RoaringBitmap/roaring v0.4.23/go.mod h1:D0gp8kJQgE1A4LQ5wFLggQEyvDi06Mq5mKs52e1TwOo= -github.com/RoaringBitmap/roaring v1.7.0 h1:OZF303tJCER1Tj3x+aArx/S5X7hrT186ri6JjrGvG68= -github.com/RoaringBitmap/roaring v1.7.0/go.mod h1:6AXUsoIEzDTFFQCe1RbGA6uFONMhvejWj5rqITANK90= +github.com/RoaringBitmap/roaring v1.9.0 h1:lwKhr90/j0jVXJyh5X+vQN1VVn77rQFfYnh6RDRGCcE= +github.com/RoaringBitmap/roaring v1.9.0/go.mod h1:6AXUsoIEzDTFFQCe1RbGA6uFONMhvejWj5rqITANK90= github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/agnivade/levenshtein v1.1.1 h1:QY8M92nrzkmr798gCo3kmMyqXFzdQVpxLlGPRBij0P8= @@ -155,8 +155,8 @@ github.com/go-openapi/jsonreference v0.20.4 h1:bKlDxQxQJgwpUSgOENiMPzCTBVuc7vTdX github.com/go-openapi/jsonreference v0.20.4/go.mod h1:5pZJyJP2MnYCpoeoMAql78cCHauHj0V9Lhc506VOpw4= github.com/go-openapi/spec v0.20.14 h1:7CBlRnw+mtjFGlPDRZmAMnq35cRzI91xj03HVyUi/Do= github.com/go-openapi/spec v0.20.14/go.mod h1:8EOhTpBoFiask8rrgwbLC3zmJfz4zsCUueRuPM6GNkw= -github.com/go-openapi/swag v0.22.8 h1:/9RjDSQ0vbFR+NyjGMkFTsA1IA0fmhKSThmfGZjicbw= -github.com/go-openapi/swag v0.22.8/go.mod h1:6QT22icPLEqAM/z/TChgb4WAveCHF92+2gF0CNjHpPI= +github.com/go-openapi/swag v0.22.9 h1:XX2DssF+mQKM2DHsbgZK74y/zj4mo9I99+89xUmuZCE= +github.com/go-openapi/swag v0.22.9/go.mod h1:3/OXnFfnMAwBD099SwYRk7GD3xOrr1iL7d/XNLXVVwE= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= @@ -196,8 +196,9 @@ github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5a github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= @@ -240,8 +241,8 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= -github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q= -github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4= +github.com/leodido/go-urn v1.3.0 h1:jX8FDLfW4ThVXctBNZ+3cIWnCSnrACDV73r76dy0aQQ= +github.com/leodido/go-urn v1.3.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= @@ -320,15 +321,14 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/swaggo/files v1.0.1 h1:J1bVJ4XHZNq0I46UU90611i9/YzdrF7x92oX1ig5IdE= github.com/swaggo/files v1.0.1/go.mod h1:0qXmMNH6sXNf+73t65aKeB+ApmgxdnkQzVTAj2uaMUg= github.com/swaggo/gin-swagger v1.6.0 h1:y8sxvQ3E20/RCyrXeFfg60r6H0Z+SwpTjMYsMm+zy8M= github.com/swaggo/gin-swagger v1.6.0/go.mod h1:BG00cCEy294xtVpyIAHG6+e2Qzj/xKlRdOqDkvq0uzo= -github.com/swaggo/swag v1.16.2 h1:28Pp+8DkQoV+HLzLx8RGJZXNGKbFqnuvSbAAtoxiY04= -github.com/swaggo/swag v1.16.2/go.mod h1:6YzXnDcpr0767iOejs318CwYkCQqyGer6BizOg03f+E= +github.com/swaggo/swag v1.16.3 h1:PnCYjPCah8FK4I26l2F/KQ4yz3sILcVUN3cTlBFA9Pg= +github.com/swaggo/swag v1.16.3/go.mod h1:DImHIuOFXKpMFAQjcC7FG4m3Dg4+QuUgUzJmKjI/gRk= github.com/tinylib/msgp v1.0.2/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE= github.com/tinylib/msgp v1.1.0/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE= github.com/tinylib/msgp v1.1.2/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE= diff --git a/server/torr/btserver.go b/server/torr/btserver.go index 1c73417..30e0a64 100644 --- a/server/torr/btserver.go +++ b/server/torr/btserver.go @@ -88,14 +88,13 @@ func (bt *BTServer) configure(ctx context.Context) { upnpID := "TorrServer/" + version.Version cliVers := userAgent - // bt.config.AlwaysWantConns = true bt.config.Debug = settings.BTsets.EnableDebug bt.config.DisableIPv6 = !settings.BTsets.EnableIPv6 bt.config.DisableTCP = settings.BTsets.DisableTCP bt.config.DisableUTP = settings.BTsets.DisableUTP // https://github.com/anacrolix/torrent/issues/703 - // bt.config.DisableWebtorrent = true // TODO: check memory usage - // bt.config.DisableWebseeds = false + // bt.config.DisableWebtorrent = true // NE + // bt.config.DisableWebseeds = false // NE bt.config.NoDefaultPortForwarding = settings.BTsets.DisableUPNP bt.config.NoDHT = settings.BTsets.DisableDHT bt.config.DisablePEX = settings.BTsets.DisablePEX @@ -109,13 +108,13 @@ func (bt *BTServer) configure(ctx context.Context) { bt.config.EstablishedConnsPerTorrent = settings.BTsets.ConnectionsLimit bt.config.TotalHalfOpenConns = 500 // Encryption/Obfuscation - bt.config.EncryptionPolicy = torrent.EncryptionPolicy{ - ForceEncryption: settings.BTsets.ForceEncrypt, - } - // bt.config.HeaderObfuscationPolicy = torrent.HeaderObfuscationPolicy{ - // RequirePreferred: settings.BTsets.ForceEncrypt, - // Preferred: true, - // } + bt.config.EncryptionPolicy = torrent.EncryptionPolicy{ // OE + ForceEncryption: settings.BTsets.ForceEncrypt, // OE + } // OE + // bt.config.HeaderObfuscationPolicy = torrent.HeaderObfuscationPolicy{ // NE + // RequirePreferred: settings.BTsets.ForceEncrypt, // NE + // Preferred: true, // NE + // } // NE if settings.BTsets.DownloadRateLimit > 0 { bt.config.DownloadRateLimiter = utils.Limit(settings.BTsets.DownloadRateLimit * 1024) } @@ -130,21 +129,8 @@ 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) log.Println("Set listen port to random autoselect (0)") - bt.config.ListenPort = 0 // lport + bt.config.ListenPort = 0 } } diff --git a/server/torr/storage/torrstor/storage.go b/server/torr/storage/torrstor/storage.go index 31b23bb..195fbb7 100644 --- a/server/torr/storage/torrstor/storage.go +++ b/server/torr/storage/torrstor/storage.go @@ -25,20 +25,20 @@ func NewStorage(capacity int64) *Storage { } func (s *Storage) OpenTorrent(info *metainfo.Info, infoHash metainfo.Hash) (ts.TorrentImpl, error) { - // capFunc := func() (int64, bool) { - // return s.capacity, true - // } + // capFunc := func() (int64, bool) { // NE + // return s.capacity, true // NE + // } // NE s.mu.Lock() defer s.mu.Unlock() ch := NewCache(s.capacity, s) ch.Init(info, infoHash) s.caches[infoHash] = ch - return ch, nil - // return ts.TorrentImpl{ - // Piece: ch.Piece, - // Close: ch.Close, - // Capacity: &capFunc, - // }, nil + return ch, nil // OE + // return ts.TorrentImpl{ // NE + // Piece: ch.Piece, // NE + // Close: ch.Close, // NE + // Capacity: &capFunc, // NE + // }, nil // NE } func (s *Storage) CloseHash(hash metainfo.Hash) { diff --git a/server/version/version.go b/server/version/version.go index db892ff..4597419 100644 --- a/server/version/version.go +++ b/server/version/version.go @@ -6,7 +6,7 @@ import ( // "github.com/anacrolix/torrent" ) -const Version = "MatriX.129" +const Version = "MatriX.129.1" func GetTorrentVersion() string { bi, ok := debug.ReadBuildInfo() diff --git a/server/web/api/ffprobe.go b/server/web/api/ffprobe.go index 423a619..5a7f2ce 100644 --- a/server/web/api/ffprobe.go +++ b/server/web/api/ffprobe.go @@ -18,12 +18,12 @@ import ( // // @Tags API // -// @Param hash query string true "Torrent hash" -// @Param id query string true "File index in torrent" +// @Param hash path string true "Torrent hash" +// @Param id path string true "File index in torrent" // // @Produce json // @Success 200 "Data returned from ffprobe" -// @Router /ffp [get] +// @Router /ffp/{hash}/{id} [get] func ffp(c *gin.Context) { hash := c.Param("hash") indexStr := c.Param("id") diff --git a/server/web/api/play.go b/server/web/api/play.go index 5a573dc..3a4c946 100644 --- a/server/web/api/play.go +++ b/server/web/api/play.go @@ -19,13 +19,13 @@ import ( // // @Tags API // -// @Param hash query string true "Torrent hash" -// @Param id query string true "File index in torrent" +// @Param hash path string true "Torrent hash" +// @Param id path string true "File index in torrent" // @Param not_auth query bool false "Not authenticated" // // @Produce application/octet-stream // @Success 200 "Torrent data" -// @Router /play [get] +// @Router /play/{hash}/{id} [get] func play(c *gin.Context) { hash := c.Param("hash") indexStr := c.Param("id")