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

オープン
#318 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
55/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
静か
技術スタック
ruby
領域
networking

調査の方向性

Net::HTTP#proxy_uri から URI::Generic#find_proxy までを追跡し、proxy と no_proxy の選択に対して IPSocket.getaddress がどの時点で実行されるかに注目してください。宛先がプロキシ経由でのみ解決される環境でブロッキングする名前解決を再現し、その後、プロキシの選択で最初に直接 DNS ルックアップを必要としなくなったことを確認してください。

索引モデルが issue の本文から書いたものです。

説明

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).

主要言語
Ruby
スター
148
フォーク
95
平均マージ
10時間 54分
マージ済み PR(30日)
4

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

ruby/net-http のほかの issue

ruby/net-http の issue をすべて見る

似ている issue

Ruby の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。