pierre-emmanuelJ / iptv-proxy

Reverse proxy on iptv m3u and m3u8 file and xtream codes client api
GNU General Public License v3.0
535 stars 153 forks source link

runtime error using XC #99

Closed rmramsey32 closed 2 years ago

rmramsey32 commented 3 years ago

I'm trying to get iptv-proxy working through my XC only provider. I'm getting the following error when I make a request:

[GIN-debug] [WARNING] Now Gin requires Go 1.6 or later and Go 1.7 will be required soon.

[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.

[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.

[GIN-debug] GET /get.php --> github.com/pierre-emmanuelJ/iptv-proxy/pkg/server.(Config).xtreamGet-fm (5 handlers) [GIN-debug] POST /get.php --> github.com/pierre-emmanuelJ/iptv-proxy/pkg/server.(Config).xtreamGet-fm (5 handlers) [GIN-debug] GET /player_api.php --> github.com/pierre-emmanuelJ/iptv-proxy/pkg/server.(Config).xtreamPlayerAPIGET-fm (5 handlers) [GIN-debug] POST /player_api.php --> github.com/pierre-emmanuelJ/iptv-proxy/pkg/server.(Config).xtreamPlayerAPIPOST-fm (5 handlers) [GIN-debug] GET /xmltv.php --> github.com/pierre-emmanuelJ/iptv-proxy/pkg/server.(Config).xtreamXMLTV-fm (5 handlers) [GIN-debug] GET /test/testpassword/:id --> github.com/pierre-emmanuelJ/iptv-proxy/pkg/server.(Config).xtreamStreamHandler-fm (4 handlers) [GIN-debug] GET /live/test/testpassword/:id --> github.com/pierre-emmanuelJ/iptv-proxy/pkg/server.(Config).xtreamStreamLive-fm (4 handlers) [GIN-debug] GET /timeshift/test/testpassword/:duration/:start/:id --> github.com/pierre-emmanuelJ/iptv-proxy/pkg/server.(Config).xtreamStreamTimeshift-fm (4 handlers) [GIN-debug] GET /movie/test/testpassword/:id --> github.com/pierre-emmanuelJ/iptv-proxy/pkg/server.(Config).xtreamStreamMovie-fm (4 handlers) [GIN-debug] GET /series/test/testpassword/:id --> github.com/pierre-emmanuelJ/iptv-proxy/pkg/server.(Config).xtreamStreamSeries-fm (4 handlers) [GIN-debug] GET /hlsr/:token/test/testpassword/:channel/:hash/:chunk --> github.com/pierre-emmanuelJ/iptv-proxy/pkg/server.(Config).xtreamHlsrStream-fm (4 handlers) [GIN-debug] GET /hls/:token/:chunk --> github.com/pierre-emmanuelJ/iptv-proxy/pkg/server.(Config).xtreamHlsStream-fm (4 handlers) [GIN-debug] GET /iptv.m3u --> github.com/pierre-emmanuelJ/iptv-proxy/pkg/server.(Config).getM3U-fm (5 handlers) [GIN-debug] POST /iptv.m3u --> github.com/pierre-emmanuelJ/iptv-proxy/pkg/server.(Config).getM3U-fm (5 handlers) [GIN-debug] Listening and serving HTTP on :8080 [iptv-proxy] 2021/09/22 - 17:10:08 | 192.168.2.238 | xtream cache m3u file [iptv-proxy] 2021/09/22 - 17:10:08 | 192.168.2.238 | xtream cache m3u file

2021/09/22 17:10:09 [Recovery] 2021/09/22 - 17:10:09 panic recovered: GET /get.php?username=test&password=testpassword&type=m3u_plus&output=ts HTTP/1.1 Host: 192.168.2.38:8088 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8 Accept-Encoding: gzip, deflate [GIN] 2021/09/22 - 17:10:09 | 500 | 538.267535ms | 192.168.2.238 | GET /get.php?username=test&password=testpassword&type=m3u_plus&output=ts Accept-Language: en-us Connection: keep-alive Cookie: grafana_session=7cfaa407dceb76391560c720b33c7d86; locale=en Upgrade-Insecure-Requests: 1 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.2 Safari/605.1.15

runtime error: invalid memory address or nil pointer dereference

/usr/local/go/src/runtime/panic.go:212 (0x433f1a) /usr/local/go/src/runtime/signal_unix.go:734 (0x44ca92) /go/src/github.com/pierre-emmanuelJ/iptv-proxy/vendor/github.com/tellytv/go.xtream-codes/xtream-codes.go:82 (0x996935) /go/src/github.com/pierre-emmanuelJ/iptv-proxy/pkg/xtream-proxy/xtream-proxy.go:52 (0x9968c1) /go/src/github.com/pierre-emmanuelJ/iptv-proxy/pkg/server/xtreamHandles.go:61 (0x99d959) /go/src/github.com/pierre-emmanuelJ/iptv-proxy/pkg/server/xtreamHandles.go:139 (0x99ef65) /go/src/github.com/pierre-emmanuelJ/iptv-proxy/vendor/github.com/gin-gonic/gin/context.go:108 (0x975423) /go/src/github.com/pierre-emmanuelJ/iptv-proxy/vendor/github.com/gin-gonic/gin/recovery.go:48 (0x986b04) /go/src/github.com/pierre-emmanuelJ/iptv-proxy/vendor/github.com/gin-gonic/gin/context.go:108 (0x975423) /go/src/github.com/pierre-emmanuelJ/iptv-proxy/vendor/github.com/gin-gonic/gin/logger.go:84 (0x98604d) /go/src/github.com/pierre-emmanuelJ/iptv-proxy/vendor/github.com/gin-gonic/gin/context.go:108 (0x975423) /go/src/github.com/pierre-emmanuelJ/iptv-proxy/vendor/github.com/gin-gonic/gin/gin.go:361 (0x97e032) /go/src/github.com/pierre-emmanuelJ/iptv-proxy/vendor/github.com/gin-gonic/gin/gin.go:326 (0x97d872) /usr/local/go/src/net/http/server.go:2887 (0x6c29e2) /usr/local/go/src/net/http/server.go:1952 (0x6bde0c) /usr/local/go/src/runtime/asm_amd64.s:1371 (0x46c060) 

olobley commented 2 years ago

Can I add a +1 here? I get the same - I see the machine make a call to the XC endpoint with the provider and get a 'success' JSON response sent back to the iptv_proxy, but then it falls over with the below error (very similar to the one above):

` [GIN] 2021/11/23 - 17:36:09 | 500 | 278.937407ms | 10.0.5.55 | GET "/xmltv.php?username=test&password=test" [GIN] 2021/11/23 - 17:36:12 | 404 | 2.829µs | 10.0.5.55 | GET "/"

2021/11/23 17:36:19 [Recovery] 2021/11/23 - 17:36:19 panic recovered: GET /xmltv.php?username=test&password=test HTTP/1.1 Host: det-docker.bplondon.org:8080 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,/;q=0.8 Accept-Encoding: gzip, deflate Accept-Language: en-US,en;q=0.5 Cache-Control: max-age=0 Connection: keep-alive Dnt: 1 Upgrade-Insecure-Requests: 1 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:94.0) Gecko/20100101 Firefox/94.0

runtime error: invalid memory address or nil pointer dereference /opt/hostedtoolcache/go/1.17.1/x64/src/runtime/panic.go:221 (0x448ba6) /opt/hostedtoolcache/go/1.17.1/x64/src/runtime/signal_unix.go:735 (0x448b76) /home/runner/work/iptv-proxy/iptv-proxy/vendor/github.com/tellytv/go.xtream-codes/xtream-codes.go:82 (0x854630) /home/runner/work/iptv-proxy/iptv-proxy/pkg/xtream-proxy/xtream-proxy.go:52 (0x854617) /home/runner/work/iptv-proxy/iptv-proxy/pkg/server/xtreamHandles.go:186 (0x85ae0c) /home/runner/work/iptv-proxy/iptv-proxy/vendor/github.com/gin-gonic/gin/context.go:165 (0x83f641) /home/runner/work/iptv-proxy/iptv-proxy/vendor/github.com/gin-gonic/gin/recovery.go:99 (0x83f62c) /home/runner/work/iptv-proxy/iptv-proxy/vendor/github.com/gin-gonic/gin/context.go:165 (0x83e8a6) /home/runner/work/iptv-proxy/iptv-proxy/vendor/github.com/gin-gonic/gin/logger.go:241 (0x83e889) /home/runner/work/iptv-proxy/iptv-proxy/vendor/github.com/gin-gonic/gin/context.go:165 (0x83dddd) /home/runner/work/iptv-proxy/iptv-proxy/vendor/github.com/gin-gonic/gin/gin.go:489 (0x83da65) /home/runner/work/iptv-proxy/iptv-proxy/vendor/github.com/gin-gonic/gin/gin.go:445 (0x83d5c4) /opt/hostedtoolcache/go/1.17.1/x64/src/net/http/server.go:2878 (0x67ff3a) /opt/hostedtoolcache/go/1.17.1/x64/src/net/http/server.go:1929 (0x67b5e7) /opt/hostedtoolcache/go/1.17.1/x64/src/runtime/asm_amd64.s:1581 (0x463100) `

This is with the native binary, but I've also tried with the docker image and got the same result.

dolhop commented 2 years ago

I am seeing the same thing with the docker image. @pierre-emmanuelJ , I see you changed it from "bug" to "provider issue". Can you elaborate? Is this something that will be fixed?

cyber1331 commented 2 years ago

i can confirm the bug is within the go.xtreme-codes but could be dependent on the provider. The issue is in the JSON packets received, some int's are in "quotes" and others are unquoted. This causes an issue with the unmarshal process as it can't determine the difference between the 2.
To make this work for all parties a way to check if the int is quoted or not would be best, however my knowledge in GO is very limited (learned the language just to resolve this issue) To simply fix the issue for your provider, you need to fix the ",string" pieces (but only for the ones that have changed) under of userinfo and serverinfo structs for the xstream-codes library. (The logging didn't explain this as it was done during the authentication, which is the stacktrace posted above). Once the authentication is complete, the logging tells you where the other places are to fix for the streams.

I also changed to https://github.com/xybydy/go.xtream-codes from https://github.com/tellytv/go.xtream-codes because they had some better base64 conversions.

I don't have the time to create the PR, but i hope this information helps anyone else that is running into this issue.

Note: changing these ",string" pieces in the structs may break other providers

pierre-emmanuelJ commented 2 years ago

The fix could implement Flex type in the go.xtream.codes package like here: https://github.com/tellytv/go.xtream-codes/blob/master/structs.go#L157-L179

there is already a related issue about the in the repo: https://github.com/pierre-emmanuelJ/iptv-proxy/issues/89

pierre-emmanuelJ commented 2 years ago

I opened a PR here that's solve all these issues: https://github.com/tellytv/go.xtream-codes/pull/6/files

pierre-emmanuelJ commented 2 years ago

Another PR will come for the illegal base64 issues. I'll see to support panel_api.php also

olobley commented 2 years ago

Thank you! I just about managed (I think) to do a pull/compile of the files a while back - how does one use the PR you mentioned above to build an executable (or docker image?) to test the fixes?

pierre-emmanuelJ commented 2 years ago

Thank you! I just about managed (I think) to do a pull/compile of the files a while back - how does one use the PR you mentioned above to build an executable (or docker image?) to test the fixes?

Once this PR will be merged I'll do a new release of the iptv-proxy don't worry ;)

olobley commented 2 years ago

Thanks. If there's a place we can contribute to the 'developer's beer fund' (or similar if beer isn't your thing), let me know. Having an XC -> M3U proxy makes my life a whole lot easier, quite happy to compensate your time for it

pierre-emmanuelJ commented 2 years ago

Thanks. If there's a place we can contribute to the 'developer's beer fund' (or similar if beer isn't your thing), let me know. Having an XC -> M3U proxy makes my life a whole lot easier, quite happy to compensate your time for it

@olobley I made a Commit especially for you 😄 https://github.com/pierre-emmanuelJ/iptv-proxy/commit/0f8ef65c417e74a5ff7dad3997095a55218c5583

pierre-emmanuelJ commented 2 years ago

Okay this PR has been merged tellytv/go.xtream-codes#6, I'll do a release in the day

pierre-emmanuelJ commented 2 years ago

Here is the new release: https://github.com/pierre-emmanuelJ/iptv-proxy/releases/tag/v3.6.1

feel free to reopen is issue persist

Another PR will come for the illegal base64 issues. I'll see to support panel_api.php also

Here is in my todolist

ggowins commented 2 years ago

I still seem to be receiving the same issue with v3.6.1. I built a docker image after the git pull.

runtime error: invalid memory address or nil pointer dereference
/usr/local/go/src/runtime/panic.go:212 (0x449269)
/usr/local/go/src/runtime/signal_unix.go:695 (0x4490b8)
/go/src/github.com/pierre-emmanuelJ/iptv-proxy/vendor/github.com/jamesnetherton/m3u/m3u.go:39 (0x9b19eb)
/go/src/github.com/pierre-emmanuelJ/iptv-proxy/pkg/server/xtreamHandles.go:57 (0x9c3a7d)
/go/src/github.com/pierre-emmanuelJ/iptv-proxy/pkg/server/xtreamHandles.go:120 (0x9c489d)
/go/src/github.com/pierre-emmanuelJ/iptv-proxy/vendor/github.com/gin-gonic/gin/context.go:108 (0x99b4b3)
/go/src/github.com/pierre-emmanuelJ/iptv-proxy/vendor/github.com/gin-gonic/gin/recovery.go:48 (0x9ac62f)
/go/src/github.com/pierre-emmanuelJ/iptv-proxy/vendor/github.com/gin-gonic/gin/context.go:108 (0x99b4b3)
/go/src/github.com/pierre-emmanuelJ/iptv-proxy/vendor/github.com/gin-gonic/gin/logger.go:84 (0x9abb0b)
/go/src/github.com/pierre-emmanuelJ/iptv-proxy/vendor/github.com/gin-gonic/gin/context.go:108 (0x99b4b3)
/go/src/github.com/pierre-emmanuelJ/iptv-proxy/vendor/github.com/gin-gonic/gin/gin.go:361 (0x9a3d74)
/go/src/github.com/pierre-emmanuelJ/iptv-proxy/vendor/github.com/gin-gonic/gin/gin.go:326 (0x9a35b2)
/usr/local/go/src/net/http/server.go:2807 (0x6d12a2)
/usr/local/go/src/net/http/server.go:1895 (0x6ccc1b)
/usr/local/go/src/runtime/asm_amd64.s:1373 (0x462930)
pierre-emmanuelJ commented 2 years ago

/go/src/github.com/pierre-emmanuelJ/iptv-proxy/vendor/github.com/jamesnetherton/m3u/m3u.go:39

It seems to come from /go/src/github.com/pierre-emmanuelJ/iptv-proxy/vendor/github.com/jamesnetherton/m3u/m3u.go:39 let me check that later why ;)

pierre-emmanuelJ commented 2 years ago

@ggowins Here is the fix of your Panic: https://github.com/jamesnetherton/m3u/pull/6 it seems something wrong is given to the m3u parse function...

pierre-emmanuelJ commented 2 years ago

@ggowins Can you try with this new release: https://github.com/pierre-emmanuelJ/iptv-proxy/releases/tag/v3.6.2

ggowins commented 2 years ago

similar error, but at different lines in the trace. Made sure I had XTREAM_API_GET=1 since my provider doesn't have the get.php anymore.

2022/01/21 16:04:30 [iptv-proxy] 2022/01/21 - 16:04:30 | 192.168.xxx.xxx | xtream cache API m3u file

2022/01/21 16:04:30 [Recovery] 2022/01/21 - 16:04:30 panic recovered:
runtime error: invalid memory address or nil pointer dereference
/opt/hostedtoolcache/go/1.17.6/x64/src/runtime/panic.go:221 (0x448e06)
/opt/hostedtoolcache/go/1.17.6/x64/src/runtime/signal_unix.go:735 (0x448dd6)
/home/runner/work/iptv-proxy/iptv-proxy/vendor/github.com/tellytv/go.xtream-codes/xtream-codes.go:82 (0x8d1650)
/home/runner/work/iptv-proxy/iptv-proxy/pkg/xtream-proxy/xtream-proxy.go:52 (0x8d1637)
/home/runner/work/iptv-proxy/iptv-proxy/pkg/server/xtreamHandles.go:76 (0x8d6f66)
/home/runner/work/iptv-proxy/iptv-proxy/pkg/server/xtreamHandles.go:206 (0x8d8687)
/home/runner/work/iptv-proxy/iptv-proxy/vendor/github.com/gin-gonic/gin/context.go:165 (0x8bc481)
/home/runner/work/iptv-proxy/iptv-proxy/vendor/github.com/gin-gonic/gin/recovery.go:99 (0x8bc46c)
/home/runner/work/iptv-proxy/iptv-proxy/vendor/github.com/gin-gonic/gin/context.go:165 (0x8bb6e6)
/home/runner/work/iptv-proxy/iptv-proxy/vendor/github.com/gin-gonic/gin/logger.go:241 (0x8bb6c9)
/home/runner/work/iptv-proxy/iptv-proxy/vendor/github.com/gin-gonic/gin/context.go:165 (0x8bac1d)
/home/runner/work/iptv-proxy/iptv-proxy/vendor/github.com/gin-gonic/gin/gin.go:489 (0x8ba8a5)
/home/runner/work/iptv-proxy/iptv-proxy/vendor/github.com/gin-gonic/gin/gin.go:445 (0x8ba404)
/opt/hostedtoolcache/go/1.17.6/x64/src/net/http/server.go:2879 (0x68165a)
/opt/hostedtoolcache/go/1.17.6/x64/src/net/http/server.go:1930 (0x67cd07)
/opt/hostedtoolcache/go/1.17.6/x64/src/runtime/asm_amd64.s:1581 (0x4633c0)

[GIN] 2022/01/21 - 16:04:30 | 500 |    1.223157ms |  192.168.xxx.xxx | GET      "/get.php?username=test&password=test&type=m3u_plus&output=ts"
pierre-emmanuelJ commented 2 years ago

similar error, but at different lines in the trace. Made sure I had XTREAM_API_GET=1 since my provider doesn't have the get.php anymore.

It's not the similar error. I'm checking why..

pierre-emmanuelJ commented 2 years ago

@ggowins there is a panic in the package go.xtream-codes you seem to have an issue to authenticate to your provider...etc.

Please can you try to fetch and pull this branch fix-panic? and rebuild the container thx

ggowins commented 2 years ago

sure thing! I'll let you know here in a bit. thanks!

pierre-emmanuelJ commented 2 years ago

sure thing! I'll let you know here in a bit. thanks!

I opened a PR to fix the proper panic: https://github.com/tellytv/go.xtream-codes/pull/9

But if you panic here, it's because something is wrong with the auth...

ggowins commented 2 years ago

AWESOME! That did the trick. Got a m3u downloaded. Thanks a bunch.

ggowins commented 2 years ago

Like you thought, there was something going on with authentication. But the error trapping you put in made it easy to see what needed to be looked at in the config.

pierre-emmanuelJ commented 2 years ago

@ggowins Many thanks for your donation :)

pierre-emmanuelJ commented 2 years ago

Like you thought, there was something going on with authentication. But the error trapping you put in made it easy to see what needed to be looked at in the config.

That's cool, you noticed this Panic to fix the used package.

I'll do a release once this PR is merged, You can use the branch pending to that ;)

rmramsey32 commented 2 years ago

I can confirm this is working on my XC only provider also. Many thanks for your work on this.

On Jan 7, 2022, at 9:32 AM, Pierre-Emmanuel Jacquier @.***> wrote:

Thanks. If there's a place we can contribute to the 'developer's beer fund' (or similar if beer isn't your thing), let me know. Having an XC -> M3U proxy makes my life a whole lot easier, quite happy to compensate your time for it

@olobley https://github.com/olobley I made a Commit especially for you 😄

— Reply to this email directly, view it on GitHub https://github.com/pierre-emmanuelJ/iptv-proxy/issues/99#issuecomment-1007499430, or unsubscribe https://github.com/notifications/unsubscribe-auth/AULHGI3CRRLRO3ACUX3LGV3UU4BSDANCNFSM5ERZRTQQ. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you authored the thread.

pierre-emmanuelJ commented 2 years ago

I can confirm this is working on my XC only provider also. Many thanks for your work on this.

Also, many thanks @rmramsey32 for your donation :)

olobley commented 2 years ago

Like you thought, there was something going on with authentication. But the error trapping you put in made it easy to see what needed to be looked at in the config.

That's cool, you noticed this Panic to fix the used package.

I'll do a release once this PR is merged, You can use the branch pending to that ;)

Is there a way to subscribe to see when that happens, as I don't think I'm smart enough to do that build (finally getting a chance to play with the machines again this weekend, and I get a similar panic to the one above...fairly sure my auth is right, as I can copy/paste the URL/username/password from my docker create command into a URL (this provider still supports M3U/XMLTV) and it works. Thank you!

pierre-emmanuelJ commented 2 years ago

Like you thought, there was something going on with authentication. But the error trapping you put in made it easy to see what needed to be looked at in the config.

That's cool, you noticed this Panic to fix the used package. I'll do a release once this PR is merged, You can use the branch pending to that ;)

Is there a way to subscribe to see when that happens, as I don't think I'm smart enough to do that build (finally getting a chance to play with the machines again this weekend, and I get a similar panic to the one above...fairly sure my auth is right, as I can copy/paste the URL/username/password from my docker create command into a URL (this provider still supports M3U/XMLTV) and it works. Thank you!

If you have a GitHub account, you can subscribe or watch the repo, to be notified about it...etc. You can be informed of new release.