mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 13:36:09 +05:00
use backported metainfo package
This commit is contained in:
@@ -3,8 +3,6 @@ package main
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/anacrolix/torrent"
|
||||
"github.com/anacrolix/torrent/metainfo"
|
||||
"net"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -12,6 +10,9 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/anacrolix/torrent"
|
||||
"github.com/anacrolix/torrent/metainfo"
|
||||
|
||||
"github.com/alexflint/go-arg"
|
||||
"github.com/pkg/browser"
|
||||
|
||||
@@ -183,8 +184,8 @@ func openFile(path string) (*torrent.TorrentSpec, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
mag := minfo.Magnet(info.Name, minfo.HashInfoBytes())
|
||||
// mag := minfo.Magnet(nil, &info)
|
||||
// mag := minfo.Magnet(info.Name, minfo.HashInfoBytes())
|
||||
mag := minfo.Magnet(nil, &info)
|
||||
return &torrent.TorrentSpec{
|
||||
InfoBytes: minfo.InfoBytes,
|
||||
Trackers: [][]string{mag.Trackers},
|
||||
|
||||
@@ -241,7 +241,6 @@ func getLink(host, path string) string {
|
||||
// } else {
|
||||
host = "http://" + host
|
||||
// }
|
||||
|
||||
}
|
||||
pos := strings.LastIndex(host, ":")
|
||||
if pos > 7 {
|
||||
|
||||
@@ -2,7 +2,7 @@ module server
|
||||
|
||||
go 1.20
|
||||
|
||||
replace github.com/anacrolix/torrent v1.53.1 => github.com/tsynik/torrent v1.2.10
|
||||
replace github.com/anacrolix/torrent v1.53.1 => github.com/tsynik/torrent v1.2.11
|
||||
|
||||
require (
|
||||
github.com/agnivade/levenshtein v1.1.1
|
||||
|
||||
@@ -355,8 +355,8 @@ github.com/swaggo/swag v1.16.2/go.mod h1:6YzXnDcpr0767iOejs318CwYkCQqyGer6BizOg0
|
||||
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=
|
||||
github.com/tsynik/torrent v1.2.10 h1:ZUFd9FymJg4EReoQbG3Q/zRDaWruOGqL41feAIKfces=
|
||||
github.com/tsynik/torrent v1.2.10/go.mod h1:AjuETm1Xae+Vk31UrvrSrb29bBunwMKGZLXK6T+AgPo=
|
||||
github.com/tsynik/torrent v1.2.11 h1:viD8HWicqyCCEyHVTM10UILmbvG1v+eZroPqFaLEbbY=
|
||||
github.com/tsynik/torrent v1.2.11/go.mod h1:AjuETm1Xae+Vk31UrvrSrb29bBunwMKGZLXK6T+AgPo=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
||||
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
|
||||
|
||||
@@ -68,7 +68,6 @@ func Start(port, sslport, sslCert, sslKey string, sslEnabled, roSets, searchWA b
|
||||
settings.Port = port
|
||||
settings.SslPort = sslport
|
||||
web.Start()
|
||||
|
||||
}
|
||||
|
||||
func cleanCache() {
|
||||
|
||||
@@ -2,9 +2,10 @@ package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
sets "server/settings"
|
||||
"server/torr"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
@@ -24,8 +24,8 @@ func ParseFile(file multipart.File) (*torrent.TorrentSpec, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
mag := minfo.Magnet(info.Name, minfo.HashInfoBytes())
|
||||
// mag := minfo.Magnet(nil, &info)
|
||||
// mag := minfo.Magnet(info.Name, minfo.HashInfoBytes())
|
||||
mag := minfo.Magnet(nil, &info)
|
||||
return &torrent.TorrentSpec{
|
||||
InfoBytes: minfo.InfoBytes,
|
||||
Trackers: [][]string{mag.Trackers},
|
||||
@@ -106,8 +106,8 @@ func fromHttp(link string) (*torrent.TorrentSpec, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mag := minfo.Magnet(info.Name, minfo.HashInfoBytes())
|
||||
// mag := minfo.Magnet(nil, &info)
|
||||
// mag := minfo.Magnet(info.Name, minfo.HashInfoBytes())
|
||||
mag := minfo.Magnet(nil, &info)
|
||||
|
||||
return &torrent.TorrentSpec{
|
||||
InfoBytes: minfo.InfoBytes,
|
||||
@@ -130,8 +130,8 @@ func fromFile(path string) (*torrent.TorrentSpec, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
mag := minfo.Magnet(info.Name, minfo.HashInfoBytes())
|
||||
// mag := minfo.Magnet(nil, &info)
|
||||
// mag := minfo.Magnet(info.Name, minfo.HashInfoBytes())
|
||||
mag := minfo.Magnet(nil, &info)
|
||||
return &torrent.TorrentSpec{
|
||||
InfoBytes: minfo.InfoBytes,
|
||||
Trackers: [][]string{mag.Trackers},
|
||||
|
||||
@@ -48,8 +48,8 @@ func getTorrents(c *gin.Context) {
|
||||
mi := metainfo.MetaInfo{
|
||||
AnnounceList: ts.Trackers,
|
||||
}
|
||||
mag := mi.Magnet(ts.DisplayName, ts.InfoHash)
|
||||
// mag := mi.Magnet(&ts.InfoHash, &metainfo.Info{Name: ts.DisplayName})
|
||||
// mag := mi.Magnet(ts.DisplayName, ts.InfoHash)
|
||||
mag := mi.Magnet(&ts.InfoHash, &metainfo.Info{Name: ts.DisplayName})
|
||||
http += "<p><a href='" + mag.String() + "'>magnet:?xt=urn:btih:" + mag.InfoHash.HexString() + "</a></p>"
|
||||
}
|
||||
http += "</div>"
|
||||
|
||||
@@ -87,20 +87,20 @@ func Start() {
|
||||
if settings.BTsets.EnableDLNA {
|
||||
dlna.Start()
|
||||
}
|
||||
|
||||
|
||||
route.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
|
||||
|
||||
//check if https enabled
|
||||
// check if https enabled
|
||||
if settings.Ssl {
|
||||
//if no cert and key files set in db/settings, generate new self-signed cert and key files
|
||||
// if no cert and key files set in db/settings, generate new self-signed cert and key files
|
||||
if settings.BTsets.SslCert == "" || settings.BTsets.SslKey == "" {
|
||||
settings.BTsets.SslCert, settings.BTsets.SslKey = sslcerts.MakeCertKeyFiles(ips)
|
||||
log.TLogln("Saving path to ssl cert and key in db", settings.BTsets.SslCert, settings.BTsets.SslKey)
|
||||
settings.SetBTSets(settings.BTsets)
|
||||
}
|
||||
//verify if cert and key files are valid
|
||||
// verify if cert and key files are valid
|
||||
err = sslcerts.VerifyCertKeyFiles(settings.BTsets.SslCert, settings.BTsets.SslKey, settings.SslPort)
|
||||
//if not valid, generate new self-signed cert and key files
|
||||
// if not valid, generate new self-signed cert and key files
|
||||
if err != nil {
|
||||
log.TLogln("Error checking certificate and private key files:", err)
|
||||
settings.BTsets.SslCert, settings.BTsets.SslKey = sslcerts.MakeCertKeyFiles(ips)
|
||||
@@ -117,7 +117,6 @@ func Start() {
|
||||
log.TLogln("Start http server at port", settings.Port)
|
||||
waitChan <- route.Run(":" + settings.Port)
|
||||
}()
|
||||
|
||||
}
|
||||
|
||||
func Wait() error {
|
||||
|
||||
@@ -13,9 +13,10 @@ import (
|
||||
"net"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"server/log"
|
||||
"server/settings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func generateSelfSignedCert(ips []string) ([]byte, []byte, error) {
|
||||
|
||||
Reference in New Issue
Block a user