diff --git a/docker-compose.proxyless.yml b/docker-compose.proxyless.yml new file mode 100644 index 0000000..06c40f2 --- /dev/null +++ b/docker-compose.proxyless.yml @@ -0,0 +1,6 @@ +services: + ryd-proxy: + image: 1337kavin/ryd-proxy:latest + restart: unless-stopped + ports: + - "127.0.0.1:3000:3000" diff --git a/docker-compose.yml b/docker-compose.yml index 0bca4e2..b8fd2a7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,5 +9,7 @@ services: restart: unless-stopped depends_on: - tor-proxy + environment: + - PROXY=socks5://tor-proxy:5566 ports: - "127.0.0.1:3000:3000" diff --git a/main.go b/main.go index 9f17213..ace9222 100644 --- a/main.go +++ b/main.go @@ -20,13 +20,13 @@ var client *http.Client func main() { proxy := os.Getenv("PROXY") + var httpProxy func(*http.Request) (*url.URL, error) - if proxy == "" { - proxy = "socks5://tor-proxy:5566" + if proxy != "" { + proxyUrl, _ := url.Parse(proxy) + httpProxy = http.ProxyURL(proxyUrl) } - proxyUrl, _ := url.Parse(proxy) - client = &http.Client{ Transport: &http.Transport{ Dial: (&net.Dialer{ @@ -41,7 +41,7 @@ func main() { MaxConnsPerHost: 0, MaxIdleConnsPerHost: 10, MaxIdleConns: 0, - Proxy: http.ProxyURL(proxyUrl), + Proxy: httpProxy, }, }