mirror of
https://github.com/TeamPiped/RYD-Proxy.git
synced 2024-12-12 21:30:40 +05:30
Prepare for a proxyless mode.
This commit is contained in:
parent
2b0fa64656
commit
a761ae1031
6
docker-compose.proxyless.yml
Normal file
6
docker-compose.proxyless.yml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
services:
|
||||||
|
ryd-proxy:
|
||||||
|
image: 1337kavin/ryd-proxy:latest
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- "127.0.0.1:3000:3000"
|
@ -9,5 +9,7 @@ services:
|
|||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
depends_on:
|
depends_on:
|
||||||
- tor-proxy
|
- tor-proxy
|
||||||
|
environment:
|
||||||
|
- PROXY=socks5://tor-proxy:5566
|
||||||
ports:
|
ports:
|
||||||
- "127.0.0.1:3000:3000"
|
- "127.0.0.1:3000:3000"
|
||||||
|
10
main.go
10
main.go
@ -20,13 +20,13 @@ var client *http.Client
|
|||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
proxy := os.Getenv("PROXY")
|
proxy := os.Getenv("PROXY")
|
||||||
|
var httpProxy func(*http.Request) (*url.URL, error)
|
||||||
|
|
||||||
if proxy == "" {
|
if proxy != "" {
|
||||||
proxy = "socks5://tor-proxy:5566"
|
proxyUrl, _ := url.Parse(proxy)
|
||||||
|
httpProxy = http.ProxyURL(proxyUrl)
|
||||||
}
|
}
|
||||||
|
|
||||||
proxyUrl, _ := url.Parse(proxy)
|
|
||||||
|
|
||||||
client = &http.Client{
|
client = &http.Client{
|
||||||
Transport: &http.Transport{
|
Transport: &http.Transport{
|
||||||
Dial: (&net.Dialer{
|
Dial: (&net.Dialer{
|
||||||
@ -41,7 +41,7 @@ func main() {
|
|||||||
MaxConnsPerHost: 0,
|
MaxConnsPerHost: 0,
|
||||||
MaxIdleConnsPerHost: 10,
|
MaxIdleConnsPerHost: 10,
|
||||||
MaxIdleConns: 0,
|
MaxIdleConns: 0,
|
||||||
Proxy: http.ProxyURL(proxyUrl),
|
Proxy: httpProxy,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user