mirror of
https://github.com/pierre-emmanuelJ/iptv-proxy.git
synced 2026-03-13 14:46:16 +01:00
Forward user-agent
Signed-off-by: Pierre-Emmanuel Jacquier <15922119+pierre-emmanuelJ@users.noreply.github.com>
This commit is contained in:
@@ -57,7 +57,17 @@ func (c *Config) stream(ctx *gin.Context, oriURL *url.URL) {
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := http.Get(oriURL.String())
|
||||
client := &http.Client{}
|
||||
|
||||
req, err := http.NewRequest("GET", oriURL.String(), nil)
|
||||
if err != nil {
|
||||
ctx.AbortWithError(http.StatusInternalServerError, err) // nolint: errcheck
|
||||
return
|
||||
}
|
||||
|
||||
req.Header.Set("User-Agent", ctx.Request.UserAgent())
|
||||
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
ctx.AbortWithError(http.StatusInternalServerError, err) // nolint: errcheck
|
||||
return
|
||||
@@ -79,7 +89,15 @@ func (c *Config) hlsStream(ctx *gin.Context, oriURL *url.URL) {
|
||||
},
|
||||
}
|
||||
|
||||
resp, err := client.Get(oriURL.String())
|
||||
req, err := http.NewRequest("GET", oriURL.String(), nil)
|
||||
if err != nil {
|
||||
ctx.AbortWithError(http.StatusInternalServerError, err) // nolint: errcheck
|
||||
return
|
||||
}
|
||||
|
||||
req.Header.Set("User-Agent", ctx.Request.UserAgent())
|
||||
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
ctx.AbortWithError(http.StatusInternalServerError, err) // nolint: errcheck
|
||||
return
|
||||
@@ -98,7 +116,15 @@ func (c *Config) hlsStream(ctx *gin.Context, oriURL *url.URL) {
|
||||
hlsChannelsRedirectURL[id] = *location
|
||||
hlsChannelsRedirectURLLock.Unlock()
|
||||
|
||||
hlsResp, err := http.Get(location.String())
|
||||
hlsReq, err := http.NewRequest("GET", location.String(), nil)
|
||||
if err != nil {
|
||||
ctx.AbortWithError(http.StatusInternalServerError, err) // nolint: errcheck
|
||||
return
|
||||
}
|
||||
|
||||
hlsReq.Header.Set("User-Agent", ctx.Request.UserAgent())
|
||||
|
||||
hlsResp, err := client.Do(hlsReq)
|
||||
if err != nil {
|
||||
ctx.AbortWithError(http.StatusInternalServerError, err) // nolint: errcheck
|
||||
return
|
||||
|
||||
@@ -160,7 +160,7 @@ func (c *Config) xtreamPlayerAPI(ctx *gin.Context, q url.Values) {
|
||||
action = q["action"][0]
|
||||
}
|
||||
|
||||
client, err := xtreamapi.New(c.XtreamUser.String(), c.XtreamPassword.String(), c.XtreamBaseURL)
|
||||
client, err := xtreamapi.New(c.XtreamUser.String(), c.XtreamPassword.String(), c.XtreamBaseURL, ctx.Request.UserAgent())
|
||||
if err != nil {
|
||||
ctx.AbortWithError(http.StatusInternalServerError, err) // nolint: errcheck
|
||||
return
|
||||
@@ -183,7 +183,7 @@ func (c *Config) xtreamPlayerAPI(ctx *gin.Context, q url.Values) {
|
||||
}
|
||||
|
||||
func (c *Config) xtreamXMLTV(ctx *gin.Context) {
|
||||
client, err := xtreamapi.New(c.XtreamUser.String(), c.XtreamPassword.String(), c.XtreamBaseURL)
|
||||
client, err := xtreamapi.New(c.XtreamUser.String(), c.XtreamPassword.String(), c.XtreamBaseURL, ctx.Request.UserAgent())
|
||||
if err != nil {
|
||||
ctx.AbortWithError(http.StatusInternalServerError, err) // nolint: errcheck
|
||||
return
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package xtreamproxy
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
@@ -47,8 +48,8 @@ type Client struct {
|
||||
}
|
||||
|
||||
// New new xtream client
|
||||
func New(user, password, baseURL string) (*Client, error) {
|
||||
cli, err := xtream.NewClient(user, password, baseURL)
|
||||
func New(user, password, baseURL, userAgent string) (*Client, error) {
|
||||
cli, err := xtream.NewClientWithUserAgent(context.Background(), user, password, baseURL, userAgent)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user