diff --git a/server/cmd/main.go b/server/cmd/main.go index 712fe6e..d97966f 100644 --- a/server/cmd/main.go +++ b/server/cmd/main.go @@ -35,6 +35,7 @@ type args struct { TorrentAddr string `help:"Torrent client address, default :32000"` PubIPv4 string `arg:"-4" help:"set public IPv4 addr"` PubIPv6 string `arg:"-6" help:"set public IPv6 addr"` + SearchWA bool `arg:"-swa" help:"search without auth"` } func (args) Version() string { @@ -91,7 +92,7 @@ func main() { go watchTDir(params.TorrentsDir) } - server.Start(params.Port, params.RDB) + server.Start(params.Port, params.RDB, params.SearchWA) log.TLogln(server.WaitServer()) log.Close() time.Sleep(time.Second * 3) diff --git a/server/server.go b/server/server.go index b9ebab8..8aebb3d 100644 --- a/server/server.go +++ b/server/server.go @@ -11,8 +11,8 @@ import ( "server/web" ) -func Start(port string, roSets bool) { - settings.InitSets(roSets) +func Start(port string, roSets, searchWA bool) { + settings.InitSets(roSets, searchWA) if port == "" { port = "8090" } diff --git a/server/settings/settings.go b/server/settings/settings.go index a59be07..09f129e 100644 --- a/server/settings/settings.go +++ b/server/settings/settings.go @@ -13,13 +13,15 @@ var ( Port string ReadOnly bool HttpAuth bool + SearchWA bool PubIPv4 string PubIPv6 string TorAddr string ) -func InitSets(readOnly bool) { +func InitSets(readOnly, searchWA bool) { ReadOnly = readOnly + SearchWA = searchWA tdb = NewTDB() if tdb == nil { log.TLogln("Error open db:", filepath.Join(Path, "config.db")) diff --git a/server/web/auth/auth.go b/server/web/auth/auth.go index 61408bb..2b07c90 100644 --- a/server/web/auth/auth.go +++ b/server/web/auth/auth.go @@ -66,7 +66,8 @@ func BasicAuth(accounts gin.Accounts) gin.HandlerFunc { if strings.HasPrefix(c.FullPath(), "/stream") || c.FullPath() == "/site.webmanifest" || // 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) return }