We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Есть ли возможность отображать username(accs.db) того, кто начал загрузку торрента в WebUI?
The text was updated successfully, but these errors were encountered:
нет, так как загрузка торрента происходит без авторизации
Sorry, something went wrong.
@tsynik ну не так уж и сложно оказалось, мне всего-лишь нужно было понимать, кто какой торрент добавлял
diff --git a/server/web/api/torrents.go b/server/web/api/torrents.go index 9a07aed..47f62d3 100644 --- a/server/web/api/torrents.go +++ b/server/web/api/torrents.go @@ -3,6 +3,8 @@ package api import ( "net/http" "strings" + "encoding/base64" + "fmt" "server/dlna" "server/log" @@ -86,6 +88,19 @@ func addTorrent(req torrReqJS, c *gin.Context) { return } + authHeader := c.Request.Header.Get("Authorization") + log.TLogln("Authorization header:", authHeader) + + decodedBytes, err := base64.StdEncoding.DecodeString(strings.TrimPrefix(authHeader, "Basic ")) + if err != nil { + fmt.Println("Error decode Base64:", err) + return + } + + decodedString := string(decodedBytes) + fmt.Println("Decoded string:", decodedString) + + userName := strings.Split(decodedString, ":")[0] log.TLogln("add torrent", req.Link) req.Link = strings.ReplaceAll(req.Link, "&", "&") torrSpec, err := utils.ParseLink(req.Link) @@ -95,6 +110,7 @@ func addTorrent(req torrReqJS, c *gin.Context) { return } + torrSpec.DisplayName = userName + ":" + torrSpec.DisplayName; tor, err := torr.AddTorrent(torrSpec, req.Title, req.Poster, req.Data, req.Category) if tor.Data != "" && set.BTsets.EnableDebug {
No branches or pull requests
Есть ли возможность отображать username(accs.db) того, кто начал загрузку торрента в WebUI?
The text was updated successfully, but these errors were encountered: