From 11bc02e66e349980428debee1f576e4216af07af Mon Sep 17 00:00:00 2001 From: YouROK <8yourok8@mail.ru> Date: Thu, 25 Mar 2021 11:07:35 +0300 Subject: [PATCH] fix play without auth --- server/web/api/stream.go | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/server/web/api/stream.go b/server/web/api/stream.go index ddbdf1e..d94977e 100644 --- a/server/web/api/stream.go +++ b/server/web/api/stream.go @@ -4,7 +4,6 @@ import ( "net/http" "net/url" "strconv" - "strings" "server/torr" "server/torr/state" @@ -144,16 +143,7 @@ func streamNoAuth(c *gin.Context) { return } - if title == "" { - title = c.Param("fname") - title, _ = url.PathUnescape(title) - title = strings.TrimLeft(title, "/") - } else { - title, _ = url.QueryUnescape(title) - } - link, _ = url.QueryUnescape(link) - poster, _ = url.QueryUnescape(poster) spec, err := utils.ParseLink(link) if err != nil { @@ -162,12 +152,16 @@ func streamNoAuth(c *gin.Context) { } tor := torr.GetTorrent(spec.InfoHash.HexString()) - if tor != nil { - title = tor.Title - poster = tor.Poster - data = tor.Data + if tor == nil { + c.AbortWithStatus(http.StatusForbidden) + return } - if tor == nil || tor.Stat == state.TorrentInDB { + + title = tor.Title + poster = tor.Poster + data = tor.Data + + if tor.Stat == state.TorrentInDB { tor, err = torr.AddTorrent(spec, title, poster, data) if err != nil { c.AbortWithError(http.StatusInternalServerError, err) @@ -180,10 +174,6 @@ func streamNoAuth(c *gin.Context) { return } - if tor.Title == "" { - tor.Title = tor.Name() - } - // find file index := -1 if len(tor.Files()) == 1 {