Merge branch 'master' into old-engine

This commit is contained in:
nikk gitanes
2023-03-11 08:22:17 +03:00
5 changed files with 11 additions and 5 deletions

View File

@@ -35,6 +35,7 @@ type args struct {
TorrentAddr string `help:"Torrent client address, default :32000"` TorrentAddr string `help:"Torrent client address, default :32000"`
PubIPv4 string `arg:"-4" help:"set public IPv4 addr"` PubIPv4 string `arg:"-4" help:"set public IPv4 addr"`
PubIPv6 string `arg:"-6" help:"set public IPv6 addr"` PubIPv6 string `arg:"-6" help:"set public IPv6 addr"`
SearchWA bool `arg:"-s" help:"search without auth"`
} }
func (args) Version() string { func (args) Version() string {
@@ -91,7 +92,7 @@ func main() {
go watchTDir(params.TorrentsDir) go watchTDir(params.TorrentsDir)
} }
server.Start(params.Port, params.RDB) server.Start(params.Port, params.RDB, params.SearchWA)
log.TLogln(server.WaitServer()) log.TLogln(server.WaitServer())
log.Close() log.Close()
time.Sleep(time.Second * 3) time.Sleep(time.Second * 3)

View File

@@ -11,8 +11,8 @@ import (
"server/web" "server/web"
) )
func Start(port string, roSets bool) { func Start(port string, roSets, searchWA bool) {
settings.InitSets(roSets) settings.InitSets(roSets, searchWA)
if port == "" { if port == "" {
port = "8090" port = "8090"
} }

View File

@@ -13,13 +13,15 @@ var (
Port string Port string
ReadOnly bool ReadOnly bool
HttpAuth bool HttpAuth bool
SearchWA bool
PubIPv4 string PubIPv4 string
PubIPv6 string PubIPv6 string
TorAddr string TorAddr string
) )
func InitSets(readOnly bool) { func InitSets(readOnly, searchWA bool) {
ReadOnly = readOnly ReadOnly = readOnly
SearchWA = searchWA
tdb = NewTDB() tdb = NewTDB()
if tdb == nil { if tdb == nil {
log.TLogln("Error open db:", filepath.Join(Path, "config.db")) log.TLogln("Error open db:", filepath.Join(Path, "config.db"))

View File

@@ -2,12 +2,14 @@ package api
import ( import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"net/url"
"server/rutor" "server/rutor"
"server/rutor/models" "server/rutor/models"
) )
func rutorSearch(c *gin.Context) { func rutorSearch(c *gin.Context) {
query := c.Query("query") query := c.Query("query")
query, _ = url.QueryUnescape(query)
list := rutor.Search(query) list := rutor.Search(query)
if list == nil { if list == nil {
list = []*models.TorrentDetails{} list = []*models.TorrentDetails{}

View File

@@ -66,7 +66,8 @@ func BasicAuth(accounts gin.Accounts) gin.HandlerFunc {
if strings.HasPrefix(c.FullPath(), "/stream") || if strings.HasPrefix(c.FullPath(), "/stream") ||
c.FullPath() == "/site.webmanifest" || c.FullPath() == "/site.webmanifest" ||
// https://github.com/YouROK/TorrServer/issues/172 // https://github.com/YouROK/TorrServer/issues/172
(strings.HasPrefix(c.FullPath(), "/play") && c.FullPath() != "/playlistall/all.m3u") { (strings.HasPrefix(c.FullPath(), "/play") && c.FullPath() != "/playlistall/all.m3u") ||
(settings.SearchWA && strings.HasPrefix(c.FullPath(), "/search")) {
c.Set("not_auth", true) c.Set("not_auth", true)
return return
} }