getresources returns nothing for types created with Generic.create since 0.7.2
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 86/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- ruby
- 領域
- networking
調査の方向性
まず、提供されているネットワークなしの再現を実行し、DNS#extract_resources を調査します。特に、typeclass に基づいて回答を選択する両方の分岐を確認してください。getresources がデコードされた Generic レコードを返し、名前付きの IN::A および IN::AAAA レコードが既存の動作を維持することを検証してください。
索引モデルが issue の本文から書いたものです。
説明
Since 0.7.2, getresources and each_resource never return records for a type created with Resolv::DNS::Resource::Generic.create, for example NAPTR (type 35), which has no named class in Resolv.
Cause
fa5e689c4 ("Do not register on-demand classes for unknown DNS types and SvcParamKeys") stopped registering the classes from Generic.create. So decoding a reply gives each unknown record a new anonymous class, not the class the caller passed. 05185b432 and fcff0a19e updated Message#== and Generic#== for this with Generic.type_class_equal?. DNS#extract_resources still selects answers with when typeclass, so it drops every decoded record of such a type.
Reproduction
This needs no network: it encodes and decodes a reply and gives it to getresources.
require "resolv"
naptr = Resolv::DNS::Resource::Generic.create(35, Resolv::DNS::Resource::IN::ClassValue)
name = "example.com."
rdata = "\x00\x64\x00\x0A\x01U\x07E2U+sip\x1C!^.*$!sip:[email protected]!\x00".b
reply = Resolv::DNS::Message.new
reply.add_answer(name, 60, naptr.new(rdata))
decoded = Resolv::DNS::Message.decode(reply.encode)
dns = Resolv::DNS.new
dns.define_singleton_method(:fetch_resource) {|_name, _typeclass, &block| block.call(decoded, Resolv::DNS::Name.create(name)) }
puts "resolv #{Resolv::VERSION}: #{dns.getresources(name, naptr).size} record(s)"
resolv 0.7.0: 1 record(s)
resolv 0.7.2: 0 record(s)
resolv 0.8.0: 0 record(s)
A real query shows the same result: getresources returns [], but fetch_resource gets the NAPTR answer. Ruby 4.0.7 includes 0.7.2, so a patch update of Ruby is enough to get this behaviour.
Possible fix
Compare by type and class value in extract_resources, in both when typeclass branches:
- when typeclass
+ when ->(data) { Resource::Generic.type_class_equal?(data.class, typeclass) }
With this change, the reproduction returns 1 record on 0.8.0. Named types (IN::A, IN::AAAA) behave as before, because type_class_equal? compares identity first and returns false for classes that are not Generic.
Workaround
Register the type in the same way as Resolv's built-in types:
class NAPTR < Resolv::DNS::Resource::Generic
const_set(:TypeValue, 35)
const_set(:ClassValue, Resolv::DNS::Resource::IN::ClassValue)
Resolv::DNS::Resource::ClassHash[[self::TypeValue, self::ClassValue]] = self
end
- 主要言語
- Ruby
- スター
- 56
- フォーク
- 41
- 平均マージ
- 2時間 50分
- マージ済み PR(30日)
- 8
環境構築
このプロジェクトの環境構築ファイルはまだ確認していません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
ruby/resolv のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 45/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 30/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
-
`resolv.conf` on macOS sometimes has interface suffix which breaks `resolve.rb`.再び着手できるかも @ioquatix が 1253 日前に担当しましたが、オープン中のプルリクエストはありません。 オープン
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 90/100
メンテナーはふだん 3 日以内に返信
-
L: docker L: elm L: github:actions L: helm L: ruby:bundler
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
dependabot/dependabot-core#16425 ·
メンテナーはふだん 2 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 2 日以内に返信