bogdanfinn / tls-client

net/http.Client like HTTP Client with options to select specific client TLS Fingerprints to use for requests.
BSD 4-Clause "Original" or "Old" License
670 stars 133 forks source link

[Feature Request]: socks5h supports. #67

Closed hongyi-zhao closed 2 months ago

hongyi-zhao commented 11 months ago

Describe the feature / enhancement and how it would improve things

werner@X10DAi:~/Public/repo/github.com/acheong08/ChatGPT-to-API.git$ http_proxy=socks5h://127.0.0.1:18890 SERVER_PORT=18080 ./freechatgpt
[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.
 - using env:   export GIN_MODE=release
 - using code:  gin.SetMode(gin.ReleaseMode)

[GIN-debug] GET    /ping                     --> main.main.func1 (4 handlers)
[GIN-debug] PATCH  /admin/password           --> main.passwordHandler (5 handlers)
[GIN-debug] PATCH  /admin/tokens             --> main.tokensHandler (5 handlers)
[GIN-debug] PATCH  /admin/puid               --> main.puidHandler (5 handlers)
[GIN-debug] PATCH  /admin/openai             --> main.openaiHandler (5 handlers)
[GIN-debug] OPTIONS /v1/chat/completions      --> main.optionsHandler (4 handlers)
[GIN-debug] POST   /v1/chat/completions      --> main.nightmare (5 handlers)
[GIN-debug] GET    /v1/engines               --> main.engines_handler (5 handlers)
[GIN-debug] GET    /v1/models                --> main.engines_handler (5 handlers)
2023/08/02 14:26:28 17121 127.0.0.1:18080
[GIN] 2023/08/02 - 14:26:41 | 500 |  791.445879ms |       127.0.0.1 | POST     "/v1/chat/completions"

werner@X10DAi:~/Public/repo/github.com/acheong08/ChatGPT-to-API.git$ curl -v http://127.0.0.1:18080/v1/chat/completions -d '{"messages": [{"role": "user", "content": "Say this is a test!"}],"stream": true}'
*   Trying 127.0.0.1:18080...
* Connected to 127.0.0.1 (127.0.0.1) port 18080 (#0)
> POST /v1/chat/completions HTTP/1.1
> Host: 127.0.0.1:18080
> User-Agent: curl/7.81.0
> Accept: */*
> Content-Length: 81
> Content-Type: application/x-www-form-urlencoded
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 500 Internal Server Error
< Access-Control-Allow-Headers: *
< Access-Control-Allow-Methods: *
< Access-Control-Allow-Origin: *
< Content-Type: application/json; charset=utf-8
< Date: Wed, 02 Aug 2023 06:26:41 GMT
< Content-Length: 33
< 
* Connection #0 to host 127.0.0.1 left intact
{"error":"error sending request"}

Describe how your proposal will work, with code and/or pseudo-code

This is because tls-client does not support socks5h currently.

See https://github.com/acheong08/ChatGPT-to-API/issues/104#issuecomment-1661532075 for the related comment.

bogdanfinn commented 10 months ago

Just leaving this as a reference here for now: https://github.com/golang/go/issues/13454