Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Http get request through socks5 | EOF error

What I'm trying to do:
Build a package (later usage) that provides a method to execute a get-request to any page through a given socks5 proxy.

My problem:
When ever I try to request a page with SSL (https) I get the following error:

Error executing request Get https://www.xxxxxxx.com: socks connect tcp 83.234.8.214:4145->www.xxxxxxx.com:443: EOF

However requesting http://www.google.com is working fine. So there must be a problem with the SSL connection. Can't imagine why this isn't working as I'm not very experienced with SSL-connections. End of file makes no sense to me.

My current code:

func main() {
    // public socks5 - worked when I created this question
    proxy_addr := "83.234.8.214:4145"

    // With this address I get the error
    web_addr := "https://www.whatismyip.com"

    // Requesting google works fine
    //web_addr := "http://www.google.com"

    dialer, err := proxy.SOCKS5("tcp", proxy_addr, nil, proxy.Direct)
    handleError(err, "error creating dialer")

    httpTransport := &http.Transport{}
    httpClient := &http.Client{Transport: httpTransport}

    httpTransport.DialTLS = dialer.Dial

    req, err := http.NewRequest("GET", web_addr, nil)
    handleError(err, "error creating request")

    httpClient.Timeout = 5 * time.Second

    resp, err := httpClient.Do(req)
    handleError(err, "error executing request")

    defer resp.Body.Close()
    b, err := ioutil.ReadAll(resp.Body)
    handleError(err, "error reading body")

    fmt.Println(string(b))
}

func handleError(err error, msg string) {
    if err != nil {
        log.Fatal(err)
    }
}

So what am I missing in here to deal with ssl-connections?

Thank you very much.


Edit 1:

In case someone would think this is an issue with whatismyip.com I've done some more tests:

  • https://www.google.com
    • EOF error
  • https://stackoverflow.com
    • EOF error
  • https://www.youtube.com/
    • EOF error
like image 718
C4d Avatar asked Dec 06 '25 07:12

C4d


1 Answers

Connection between your program and your socks5 proxy goes not through SSL/TLS

So you should change line
httpTransport.DialTLS = dialer.Dial
to
httpTransport.Dial = dialer.Dial

I checked https://www.whatismyip.com and https://www.google.com. URLs are downloaded fine.
For test I set up 3proxy service on my server, test your code with fixed line and check 3proxy logs.

All made requests was in proxy server logs.

If you need more help - please let me know, I'll help


Things to notice:

  • Socks5 proxies need to support SSL connections.
  • The code from the question won't work with this answer as the proxy (used in the code) isn't supporting SSL connections.
like image 166
Evgeny A. Mamonov Avatar answered Dec 08 '25 00:12

Evgeny A. Mamonov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!