1

I'm trying to connect to a proxy server to start an HTTP CONNECT tunnel. The proxy server uses authentication. This code however fails to work:

conn, err := net.Dial("tcp", "[user:[email protected]]:5555")

Even though the host exists, I get an error:

"dial tcp: lookup user:[email protected]: no such host"

The string format I'm using was described in this post. Can't seem to get it to work though. https://stackoverflow.com/a/8858209/6767074

5
  • What is that user:pass@ for? Commented Oct 14, 2016 at 13:30
  • Basic authentication for the proxy server. Without it I get an '407 Proxy Authentication Required' response. Commented Oct 14, 2016 at 13:32
  • 2
    tcp doesn't know about basic auth and doesn't care either, you need to use a http-client for that. Commented Oct 14, 2016 at 13:32
  • Oh oke, so I have to add the credentials somewhere else? Commented Oct 14, 2016 at 13:36
  • 1
    Yes, to the http-connection (or to whoever handles the proxy-connection, I don't know much about the proxy protocol) Commented Oct 14, 2016 at 13:41

1 Answer 1

1

I eventually found the problem. The net.Dial() method wasn't the one concerned with proxy authentication.

I just had to fill in the "Proxy-Authorization" header of the request before calling for am HTTP response. So my TCP address became:

conn, err := net.Dial("tcp", "111.222.333.444:5555")
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.