JioTV-Go / jiotv_go

Unlock the magic of JioTV across all your devices, without the need for the JioTV App. Crafted with love in Golang for a delightful blend of speed and efficiency! 🌟✨
https://jiotv_go.rabil.me/
Other
330 stars 91 forks source link

feat: Add Proxy Support to Fasthttp client #40

Closed rabilrbl closed 12 months ago

rabilrbl commented 1 year ago

Description

Addition of proxy support to Fasthttp library for HTTP requests.

Proposed Solution

To enable proxy support, we can explore the following steps:

  1. Identify the specific use cases where proxy support is required.
  2. Evaluate the available proxy options and libraries that are compatible with Fasthttp.
  3. Implement proxy configuration and handling in our Go application.
  4. Test the proxy support thoroughly to ensure it works seamlessly with Fasthttp.
  5. Document the changes and update the README with instructions on how to configure and use the proxy feature.
spacex97 commented 12 months ago

Hi I tested it just now and its giving me error, 59100 is my proxy port. television.go:246: strconv.Atoi: parsing "59100\"": invalid syntax panic: strconv.Atoi: parsing "59100\"": invalid syntax

rabilrbl commented 12 months ago

Hi I tested it just now and its giving me error, 59100 is my proxy port. television.go:246: strconv.Atoi: parsing "59100\"": invalid syntax panic: strconv.Atoi: parsing "59100\"": invalid syntax

Can you send me complete logs? and web page screenshot if possible. Also please tell how did u set environment variable with a dummy example

spacex97 commented 12 months ago

Hi Can we discuss on telegram @ https://t.me/G0ku95 or discord @ shinigami007 if possible since proxy works fine in my python client.

2023/09/22 22:02:50 television.go:246: strconv.Atoi: parsing "59100\"": invalid syntax panic: strconv.Atoi: parsing "59100\"": invalid syntax goroutine 35 [running]: runtime/debug.Stack() C:/Program Files/Go/src/runtime/debug/stack.go:24 +0x5e github.com/gofiber/fiber/v2/middleware/recover.defaultStackTraceHandler(0x52786a?, {0x905380, 0xc000086540}) C:/Users/Adi/go/pkg/mod/github.com/gofiber/fiber/v2@v2.49.2/middleware/recover/recover.go:12 +0x25 main.main.New.func1.1() C:/Users/Adi/go/pkg/mod/github.com/gofiber/fiber/v2@v2.49.2/middleware/recover/recover.go:31 +0x72 panic({0x905380?, 0xc000086540?}) C:/Program Files/Go/src/runtime/panic.go:914 +0x21f log.(*Logger).Panic(0xc0000b6500?, {0xc00026f708?, 0x8?, 0x4c9693?}) C:/Program Files/Go/src/log/log.go:303 +0x65 github.com/rabilrbl/jiotv_go/internals/television.Channels() C:/Users/Adi/Desktop/jiotv_go-feat-proxysupport/internals/television/television.go:246 +0x505 github.com/rabilrbl/jiotv_go/internals/handlers.IndexHandler(0x922e60?) C:/Users/Adi/Desktop/jiotv_go-feat-proxysupport/internals/handlers/handlers.go:43 +0x2a github.com/gofiber/fiber/v2.(*App).next(0xc00013f400, 0xc0000a6000) C:/Users/Adi/go/pkg/mod/github.com/gofiber/fiber/v2@v2.49.2/router.go:145 +0x1b2 github.com/gofiber/fiber/v2.(*Ctx).Next(0xc00009a2aa?) C:/Users/Adi/go/pkg/mod/github.com/gofiber/fiber/v2@v2.49.2/ctx.go:970 +0x4d main.main.CORS.func2(0x1?) C:/Users/Adi/Desktop/jiotv_go-feat-proxysupport/internals/middleware/cors.go:16 +0xa5 github.com/gofiber/fiber/v2.(*Ctx).Next(0x8104bc?) C:/Users/Adi/go/pkg/mod/github.com/gofiber/fiber/v2@v2.49.2/ctx.go:967 +0x3d main.main.New.func1(0x922e60?) C:/Users/Adi/go/pkg/mod/github.com/gofiber/fiber/v2@v2.49.2/middleware/recover/recover.go:43 +0xbb github.com/gofiber/fiber/v2.(*App).next(0xc00013f400, 0xc0000a6000) C:/Users/Adi/go/pkg/mod/github.com/gofiber/fiber/v2@v2.49.2/router.go:145 +0x1b2 github.com/gofiber/fiber/v2.(*App).handler(0xc00013f400, 0x5475af?) C:/Users/Adi/go/pkg/mod/github.com/gofiber/fiber/v2@v2.49.2/router.go:172 +0x78 github.com/valyala/fasthttp.(*Server).serveConn(0xc00025a000, {0xadec98?, 0xc0002901b8}) C:/Users/Adi/go/pkg/mod/github.com/valyala/fasthttp@v1.50.0/server.go:2359 +0x11d4 github.com/valyala/fasthttp.(*workerPool).workerFunc(0xc0002840a0, 0xc00028e7e0) C:/Users/Adi/go/pkg/mod/github.com/valyala/fasthttp@v1.50.0/workerpool.go:224 +0xa4 github.com/valyala/fasthttp.(*workerPool).getCh.func1() C:/Users/Adi/go/pkg/mod/github.com/valyala/fasthttp@v1.50.0/workerpool.go:196 +0x32 created by github.com/valyala/fasthttp.(*workerPool).getCh in goroutine 1 C:/Users/Adi/go/pkg/mod/github.com/valyala/fasthttp@v1.50.0/workerpool.go:195 +0x1ab

Screenshot 2023-09-22 230436
rabilrbl commented 12 months ago

So far the bug is only found in windows, looks like fasthttpproxy has some issues with Windows.

spacex97 commented 12 months ago

@rabilrbl thanks you very much for support, issue persist with windows only and work fine in linux, we just need to proxify ts file too so that it stream without any issue

rabilrbl commented 12 months ago

@spacex97 Why proxify ts? What is it? Why can't it just stream with gofiber routes?

ragmehos commented 12 months ago

@rabilrbl This works great, can we get it merged?

I was also checking, does fasthttp support https proxy types? I tried https proxy type and it doesnt seem to work.

spacex97 commented 12 months ago

there is no need for https proxy, most proxies are http in nature and support https out of the box

rabilrbl commented 12 months ago

@ragmehos as said by @spacex97 All proxy types are supported. Conditions:

ragmehos commented 12 months ago

@rabilrbl That's interesting, I tried to use a https proxy, and it fails saying "the server closed connection before returning the first response byte. Make sure the server returns 'Connection: close' response header before closing the connection"

television.go:276: the server closed connection before returning the first response byte. Make sure the server returns 'Connection: close' response header before closing the connection panic: the server closed connection before returning the first response byte. Make sure the server returns 'Connection: close' response header before closing the connection goroutine 18 [running]: runtime/debug.Stack() versions/1.21.1/src/runtime/debug/stack.go:24 +0x64 github.com/gofiber/fiber/v2/middleware/recover.defaultStackTraceHandler(0x102e739c0?, {0x102aa4fe0, 0x14000322000}) pkg/mod/github.com/gofiber/fiber/v2@v2.49.2/middleware/recover/recover.go:12 +0x24 main.main.New.func1.1() pkg/mod/github.com/gofiber/fiber/v2@v2.49.2/middleware/recover/recover.go:31 +0x70 panic({0x102aa4fe0?, 0x14000322000?}) versions/1.21.1/src/runtime/panic.go:914 +0x218 log.(*Logger).Panic(0x140002b8000?, {0x140002196c8?, 0x8?, 0x1025834b0?}) versions/1.21.1/src/log/log.go:303 +0x68 github.com/rabilrbl/jiotv_go/internals/television.Channels() internals/television/television.go:276 +0x4c4

I verified that this proxy works with the https://jiotv.data.cdn.jio.com..... url and it lists it fine.

rabilrbl commented 12 months ago

@ragmehos likely because your proxy timeout is high, what's the timeout?

ragmehos commented 12 months ago

@ragmehos likely because your proxy timeout is high, what's the timeout?

Doesn't seem to be related to the timeout, it happens immediately, also happens if I set the timeout to be low. I tried two https proxies from two different vpns, both of them run into the same error.

Also, let's say the access token is expired and I launch the binary with a proxy, it fails immediately when trying to route via the proxy to refresh the token.

http proxy on the other hand works fine, no issues, not sure what it is with a https proxy - not sure if fasthttpproxy supports using a https proxy, I looked at the code, its not super clear.

spacex97 commented 12 months ago

there are many things that do not work with https proxy even with my python scripts, u need to set verify as false but again if http works fine what is pushing you to use https. Now I am more interested in your use case as http proxies are widely available as compared to https.

ragmehos commented 12 months ago

Most of the proxies I have are https, only one of them is http, so I just want to get it working with the https proxy too so that there are alternatives for me, in case the http proxy gets blocked.

rabilrbl commented 12 months ago

@ragmehos the only way, I can debug this is with your proxy. Give me temporary access to proxy. Post a message in Telegram group with your GitHub username, I'll message you private. Or If you understand Go, you can debug yourself and make a PR.

rabilrbl commented 12 months ago

@ragmehos Closing this issue as it is not relevant here. Please create a new issue bug at https://github.com/rabilrbl/jiotv_go/issues/new?assignees=&labels=bug&projects=&template=bug_issue.yml&title=bug%3A+