SyliusResourceBundle icon indicating copy to clipboard operation
SyliusResourceBundle copied to clipboard

HTTP Client: Disable Name Resolution in Proxy Mode

Open alexanderkiel opened this issue 5 years ago • 4 comments

When going though a proxy, local name resolution isn't necessary, because the full URL is send to the proxy.

If I set only :proxy-options in :connection-options while creating a connection-pool, Netty is still resolving the remote address without any need.

Setting, in addition to :proxy-options, :name-resolver to :noop, solves the problem.

It might be a good idea to do this by default. But I may also overlook something here.

alexanderkiel avatar Sep 05 '19 16:09 alexanderkiel

Just to add my 2c: I use name resolution in proxy mode, specifically with Tor (DNSPort, AutomapHostsOnResolve, HTTPTunnelPort). However, this is with an explicit :name-resolver, and using :tunnel? true.

dspearson avatar Sep 10 '19 18:09 dspearson

Good point. From what I can see, curl by default disables name resolution for non-tunnel proxy but resolves host when sending CONNECT (--proxytunnel setting). I think, it makes sense to follow the same logic: if no configuration is given for DNS resolver and the client establishes non-tunnel connection, the resolver should be set to :noop. Explicitly setting to :default should force client to resolve name first.

kachayev avatar Aug 23 '20 02:08 kachayev

@alexanderkiel I'm trying to reproduce the situation and... I don't see the host being resolved, both with tunnel and non-tunnel options (see attached Wireshark screenshots). No configuration to name-resolver is provided. Do you have short reproducer that I can run to see what's going on wrong? Screen Shot 2020-08-22 at 8 23 24 PM Screen Shot 2020-08-22 at 8 23 34 PM

kachayev avatar Aug 23 '20 03:08 kachayev

Oh... okay, it seems I finally got the problem. We do send DNS query even thought we don't use the result. So, better not to waste time by default. But there's another question, if proxy host is given as domain name rather than IP, it itself should be resolve before establishing the connection. I'm not sure if setting DNS resolver to :noop is the best call here. We should probably create URI as "resolved" to avoid whatever DNS resolver configured skips resolution for destination but still be able to resolve proxy. Let me think what would be a good way to accomplish this.

kachayev avatar Aug 23 '20 22:08 kachayev