File tree Expand file tree Collapse file tree 6 files changed +17
-10
lines changed
Expand file tree Collapse file tree 6 files changed +17
-10
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ require (
1717 github.com/anacrolix/torrent v1.59.1
1818 github.com/dustin/go-humanize v1.0.1
1919 github.com/gin-contrib/cors v1.7.6
20- github.com/gin-contrib/location v1 .0.3
20+ github.com/gin-contrib/location/v2 v2 .0.0
2121 github.com/gin-gonic/gin v1.11.0
2222 github.com/hanwen/go-fuse/v2 v2.9.0
2323 github.com/kljensen/snowball v0.10.0
@@ -99,7 +99,6 @@ require (
9999 github.com/ryszard/goskiplist v0.0.0-20150312221310-2dfbae5fcf46 // indirect
100100 github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
101101 github.com/ugorji/go/codec v1.3.1 // indirect
102- go.uber.org/mock v0.6.0 // indirect
103102 go.yaml.in/yaml/v3 v3.0.4 // indirect
104103 golang.org/x/arch v0.23.0 // indirect
105104 golang.org/x/crypto v0.45.0 // indirect
Original file line number Diff line number Diff line change @@ -230,8 +230,8 @@ github.com/gin-contrib/cors v1.7.6 h1:3gQ8GMzs1Ylpf70y8bMw4fVpycXIeX1ZemuSQIsnQQ
230230github.com/gin-contrib/cors v1.7.6 /go.mod h1:Ulcl+xN4jel9t1Ry8vqph23a60FwH9xVLd+3ykmTjOk =
231231github.com/gin-contrib/gzip v0.0.6 h1:NjcunTcGAj5CO1gn4N8jHOSIeRFHIbn51z6K+xaN4d4 =
232232github.com/gin-contrib/gzip v0.0.6 /go.mod h1:QOJlmV2xmayAjkNS2Y8NQsMneuRShOU/kjovCXNuzzk =
233- github.com/gin-contrib/location v1 .0.3 h1:iy5FY2JsunZ73Lnq8YZsx7wkGFY1xcyRdKiRh/8Uptg =
234- github.com/gin-contrib/location v1 .0.3 /go.mod h1:fMoqRQxX0d5ycvxzP7e5VtqfID00RPb4jMGDh3oT0pk =
233+ github.com/gin-contrib/location/v2 v2 .0.0 h1:iLx5RatHQHSxgC0tm2AG0sIuQKecI7FhREessVd6RWY =
234+ github.com/gin-contrib/location/v2 v2 .0.0 /go.mod h1:276TDNr25NENBA/NQZUuEIlwxy/I5CYVFIr/d2TgOdU =
235235github.com/gin-contrib/sse v1.1.0 h1:n0w2GMuUpWDVp7qSpvze6fAu9iRxJY4Hmj6AmBOU05w =
236236github.com/gin-contrib/sse v1.1.0 /go.mod h1:hxRZ5gVpWMT7Z0B0gSNYqqsSCNIJMjzvm6fqCz9vjwM =
237237github.com/gin-gonic/gin v1.11.0 h1:OW/6PLjyusp2PPXtyxKHU0RbX6I/l28FTdDlae5ueWk =
Original file line number Diff line number Diff line change 11package utils
22
33import (
4- "github.com/gin-contrib/location"
4+ "github.com/gin-contrib/location/v2 "
55 "github.com/gin-gonic/gin"
66)
77
@@ -12,3 +12,11 @@ func GetScheme(c *gin.Context) string {
1212 }
1313 return url .Scheme
1414}
15+
16+ func GetHost (c * gin.Context ) string {
17+ url := location .Get (c )
18+ if url == nil {
19+ return c .Request .Host
20+ }
21+ return url .Host
22+ }
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ import (
3535func allPlayList (c * gin.Context ) {
3636 torrs := torr .ListTorrent ()
3737
38- host := utils .GetScheme (c ) + "://" + c . Request . Host
38+ host := utils .GetScheme (c ) + "://" + utils . GetHost ( c )
3939 list := "#EXTM3U\n "
4040 hash := ""
4141 // fn=file.m3u fix forkplayer bug with end .m3u in link
@@ -87,7 +87,7 @@ func playList(c *gin.Context) {
8787 }
8888 }
8989
90- host := utils .GetScheme (c ) + "://" + c . Request . Host
90+ host := utils .GetScheme (c ) + "://" + utils . GetHost ( c )
9191 list := getM3uList (tor .Status (), host , fromlast )
9292 list = "#EXTM3U\n " + list
9393 name := strings .ReplaceAll (c .Param ("fname" ), `/` , "" ) // strip starting / from param
Original file line number Diff line number Diff line change @@ -179,7 +179,7 @@ func stream(c *gin.Context) {
179179 } else if ! strings .HasSuffix (strings .ToLower (name ), ".m3u" ) && ! strings .HasSuffix (strings .ToLower (name ), ".m3u8" ) {
180180 name += ".m3u"
181181 }
182- m3ulist := "#EXTM3U\n " + getM3uList (tor .Status (), utils2 .GetScheme (c )+ "://" + c . Request . Host , fromlast )
182+ m3ulist := "#EXTM3U\n " + getM3uList (tor .Status (), utils2 .GetScheme (c )+ "://" + utils2 . GetHost ( c ) , fromlast )
183183 sendM3U (c , name , tor .Hash ().HexString (), m3ulist )
184184 return
185185 } else
@@ -299,7 +299,7 @@ func streamNoAuth(c *gin.Context) {
299299 } else if ! strings .HasSuffix (strings .ToLower (name ), ".m3u" ) && ! strings .HasSuffix (strings .ToLower (name ), ".m3u8" ) {
300300 name += ".m3u"
301301 }
302- m3ulist := "#EXTM3U\n " + getM3uList (tor .Status (), utils2 .GetScheme (c )+ "://" + c . Request . Host , fromlast )
302+ m3ulist := "#EXTM3U\n " + getM3uList (tor .Status (), utils2 .GetScheme (c )+ "://" + utils2 . GetHost ( c ) , fromlast )
303303 sendM3U (c , name , tor .Hash ().HexString (), m3ulist )
304304 return
305305 } else
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ import (
1111 "server/rutor"
1212
1313 "github.com/gin-contrib/cors"
14- "github.com/gin-contrib/location"
14+ "github.com/gin-contrib/location/v2 "
1515 "github.com/gin-gonic/gin"
1616 "github.com/wlynxg/anet"
1717
You can’t perform that action at this time.
0 commit comments