This happens when you use custom dialer that returns custom net.Conn
that returns a non-*net.TCPAddr net.Addr for LocalAddr() calls.
For example, if you dial through an SSH connection,
it might be difficult to figure out remote local address,
so you return a stub instead.
Although one can put the FQDN into the context and retrieve it later, this
makes it more straightforward.
Usecase: forwarding to another (SOCKS-)proxy, filtering/routing based on FQDN.
Read http://blog.golang.org/context for its benefits.
This PR has not utilized contexts yet; just passing them
to every customization points to help them add/retrieve
request context values.
This PR improves proxy() implementation so that it passes down EOF
(i.e. TCP FIN) from the read end to the write end by using
TCPConn.CloseWrite(). This is a must for TCP proxy as TCP sockets
can be half-closed.
Moreover, Server.handleConnect() should wait for two acks from
errCh to guarantee that the communication is completely over.
This is also fixed.
Lastly, noisy debug log is removed.