Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/http: http client not support socks:// proxy #65766

Closed
zzxn opened this issue Feb 17, 2024 · 1 comment
Closed

net/http: http client not support socks:// proxy #65766

zzxn opened this issue Feb 17, 2024 · 1 comment

Comments

@zzxn
Copy link

zzxn commented Feb 17, 2024

Go version

go version go1.22.0 linux/amd64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/zzxn/.cache/go-build'
GOENV='/home/zzxn/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/zzxn/go/pkg/mod'
GONOPROXY='git.shihe.tech'
GONOSUMDB='git.shihe.tech'
GOOS='linux'
GOPATH='/home/zzxn/go'
GOPRIVATE='git.shihe.tech'
GOPROXY='https://goproxy.cn,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.22.0'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/zzxn/code/crypto/go-solana-play/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build3618547432=/tmp/go-build -gno-record-gcc-switches'

What did you do?

Set http_proxy which starts with socks://:

export ALL_PROXY="socks://$host_ip:10810"
export HTTP_PROXY=$ALL_PROXY
export HTTPS_PROXY=$ALL_PROXY

Then I use the default http client to request a random domain:

package main

import (
	"fmt"
	"net/http"
)

func main() {
    _, err := http.Get("https://www.google.com")
    if err != nil {
        fmt.Println(err)
    }
}

What did you see happen?

I got a error like:

 proxyconnect tcp: dial tcp: lookup socks on 172.23.32.1:53: no such host

It seems like it treats socks as a domain instead of a protocol.

However, if I set http_proxy using http://, everything is OK.

What did you expect to see?

No error.

@seankhliao
Copy link
Member

https://pkg.go.dev/net/http#ProxyFromEnvironment

Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For questions please refer to https://github.com/golang/go/wiki/Questions

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Feb 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants