ruby / ruby/net-http

`URI::Generic#find_proxy` performs blocking DNS lookup before proxy selection

Open
#318 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
148
Forks
95
Avg merge
10h 54m
Merged PRs (30d)
4

Description

Net::HTTP#proxy_uri calls URI::Generic#find_proxy, which in turn calls IPSocket.getaddress on the destination hostname before deciding whether to route the request through the configured proxy. For some air-gapped deployments where hosts can only resolve public hostnames through the proxy (instead of e.g. via /etc/resolv.conf), the DNS lookup stalls for the OS DNS timeout (often 30+ seconds) when trying to perform any request via Net::Http.

We're considering a workaround for our Rails application at https://gitlab.com/gitlab-org/gitlab/-/merge_requests/245458. As we've noted before in https://about.gitlab.com/blog/we-need-to-talk-no-proxy/, wether no_proxy is checked before or after performing DNS lookups is inconsistent across languages and libraries, but as far as we can tell Net::HTTP is the outlier, whereas all other tools we checked did not perform a DNS lookup before checking against no_proxy (see specifically https://about.gitlab.com/blog/we-need-to-talk-no-proxy/#no_proxy-format. Note that Go is also listed there as resolving IP addresses, but it appears it does not perform DNS lookups. See https://gitlab.com/gitlab-org/gitlab/-/merge_requests/245458#note_3625951439).

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Trace Net::HTTP#proxy_uri into URI::Generic#find_proxy, focusing on where IPSocket.getaddress runs relative to proxy and no_proxy selection. Reproduce the blocking lookup in an environment where the destination resolves only through the proxy, then verify that proxy selection no longer requires a direct DNS lookup first.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.