aboutsummaryrefslogtreecommitdiffstats
path: root/lib/resolv.rb
Commit message (Collapse)AuthorAgeFilesLines
* [ruby/resolv] Support a :use_ipv6 option to Resolv#initializeJeremy Evans2023-11-251-2/+15
| | | | | | | | | When set, supports returning IPv6 results even if there is no public IPv6 address for the system. Implements Ruby Feature #14922 https://github.com/ruby/resolv/commit/09d141de38
* [ruby/resolv] Support a :raise_timeout_errors option to raise timeouts as ↵Jeremy Evans2023-11-251-0/+6
| | | | | | | | | | Resolv::ResolvError This allows to differentiate a timeout from an NXDOMAIN response. Fixes [Bug #18151] https://github.com/ruby/resolv/commit/c0e5abab76
* [ruby/resolv] Fix the fallback from UDP to TCP due to message truncationJeremy Evans2023-11-241-2/+4
| | | | | | | | | | If truncation is detected, return immediately from decode so that the UDP connection can be retried with TCP, instead of failing to decode due to trying to decode a truncated response. Fixes [Bug #13513] https://github.com/ruby/resolv/commit/0de996dbca
* [ruby/resolv] Catch EPROTONOSUPPORT as a sign of no IPv6 as wellKJ Tsanaktsidis2023-11-241-1/+1
| | | | | | | | | | | | (https://github.com/ruby/resolv/pull/41) If IPv6 is disabled inside a freebsd jail, it seems this returns EPROTONOSUPPORT and not EAFNOSUPPORT. In both cases, we should simply try some other listed DNS servers. Fixes [Bug #19928] https://bugs.ruby-lang.org/issues/19928 https://github.com/ruby/resolv/commit/5e2d48708b
* [ruby/resolv] Implement dohpath SvcParamKasumi Hanazuki2023-11-241-0/+29
| | | | | | | | | | | | | | | | | | | | | | (https://github.com/ruby/resolv/pull/33) * Implement dohpath SvcParam [RFC 9461] This patch implements "dohpath" SvcParam proposed in [draft-ietf-add-svcb-dns-08]. This parameter specifies a URI template for the :path used in DNS-over-HTTPS requests. "dohpath" is employed by [DDR], also a to-be-published Proposed Standard that specifies how to upgrade DNS transport to a more secure one, i.d., DNS-over-TLS or DNS-over-HTTPS. DDR is deployed in the public DNS resolvers including Cloudflare DNS, Google Public DNS, and Quad9. [RFC 9461]: https://datatracker.ietf.org/doc/rfc9461/ [DDR]: https://datatracker.ietf.org/doc/draft-ietf-add-ddr/ https://github.com/ruby/resolv/commit/da9c023539 Co-authored-by: Sorah Fukumori <her@sorah.jp>
* [ruby/resolv] Implement SVCB and HTTPS RRsKasumi Hanazuki2023-11-241-0/+429
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (https://github.com/ruby/resolv/pull/32) * Add MessageDecoder#get_list This method repeats yielding until all the data upto the current limit is consumed, and then returns an Array containig the block results. * Implement SVCB and HTTPS RRs [RFC 9460] > This patch implements SVCB and HTTPS resource record types defined in > [RFC 9460]. > > The RR types are now supported by many server implementations including > BIND, unbound, PowerDNS, and Knot DNS. Major browsers such as Chrome, > Edge, and Safari have started to query HTTPS records, with the records > gradually adopted by websites. Also, SVCB is actually deployed in the > public DNS resolvers such as Cloudflare DNS and Google Public DNS for > [DDR]. > > With such wide adoption, we have plenty of real-world use cases, and > it is unlikely the wire format will change further in an incompatible > way. It is time to implement them in the client libraries! > > # Rationale for proposed API > > ## `Resolv::DNS::Resource::IN::ServiceBinding` > > This is an abstract class for SVCB-compatible RR types. > SVCB-compatible RR types, as defined in the Draft, shares the wire > format and the semantics of their RDATA fields with SVCB to allow > implementations to share the processing of these RR types. So we do > so. > > The interface of this class is straightforward: It has three > attributes `priority`, `target`, and `params`, which correspond the > RDATA fields SvcPriority, TargetName, and SvcParams, resp. > > SVCB RR type is defined specifically within IN class. Thus, this > class is placed in the `Resolv::DNS::Resource::IN` namespace. > > ## `Resolv::DNS::Resource::IN::SVCB`, `Resolv::DNS::Resource::IN::HTTPS` > > Just inherits ServiceBinding class. > > ## `Resolv::DNS::SvcParam` > > This class represents a pair of a SvcParamKey and a SvcParamValue. > Aligned with the design of `Resolv::DNS::Resource`, each SvcParamKey > has its own subclass of `Resolv::DNS::SvcParam`. > > ## `Resolv::DNS::SvcParam::Generic` > > This is an abstract class representing a SvcParamKey that is unknown > to this library. `Generic.create(key)` dynamically defines its > subclass for specific `key`. E.g., `Generic.create(667)` will define > `Generic::Key667`. > > This class holds SvcParamValue in its wire format. > > SvcParam with an unknown SvcParamKey will be decoded as a subclass of > this class. Also, users of this library can generate a non-supported > SvcParam if they know its wire format. > > ## `Resolv::DNS::SvcParams` > > This is conceptually a set of `SvcParam`s, whose elements have the > unique SvcParamKeys. It behaves like a set, and for convenience > provides indexing by SvcParamKey. > > - `#initialize(params)` takes an Enumerable of `SvcParam`s as the > initial content. If it contains `SvcParam`s with the duplicate key, > the one that appears last takes precedence. > - `#[](key)` fetches the `SvcParam` with the given key. The key can be > specified by its name (e.g., `:alpn`) or number (e.g., `1`). > - `#add(param)` adds a `SvcParam` to the set. If the set already has a > `SvcParam` with the same key, it will be replaced. > - `#delete(key)` deletes a `SvcParam` by its key and returns it. The key > can be specified by its name or number. * Update comments referring to draft-ietf-dnsop-svcb-https-12 Published as RFC 9460. https://datatracker.ietf.org/doc/rfc9460/ [draft-ietf-dnsop-svcb-https-12]: https://datatracker.ietf.org/doc/draft-ietf-dnsop-svcb-https/12/ [RFC 9460]: https://datatracker.ietf.org/doc/rfc9460/ [DDR]: https://datatracker.ietf.org/doc/draft-ietf-add-ddr/ https://github.com/ruby/resolv/commit/b3ced7f039
* [ruby/resolv] IPv6: update to_s method to be RFC5952 compliantJohn Bond2023-11-221-5/+1
| | | | | | | | | | | | | | | | | | | (https://github.com/ruby/resolv/pull/25) * IPv6: update to_s method to be RFC5952 compliant I noticed that the resolv library does not honour RFC 5952 Section 4.2.2. in relation to textural representation of ipv6 addresses: The symbol "::" MUST NOT be used to shorten just one 16-bit 0 field. For example, the representation 2001:db8:0:1:1:1:1:1 is correct, but 2001:db8::1:1:1:1:1 is not correct. Fixes https://github.com/ruby/resolv/pull/24 https://github.com/ruby/resolv/commit/5efcd6ed70 Co-authored-by: Sorah Fukumori <sora134@gmail.com>
* [ruby/resolv] Prefer `Array#concat` over `#+=` on `Array`Nobuyoshi Nakada2023-04-281-2/+2
| | | | | | Fix https://bugs.ruby-lang.org/issues/19621 https://github.com/ruby/resolv/commit/7faaa78847
* [ruby/resolv] Expose Resolv::VERSIONHiroshi SHIBATA2023-04-141-0/+2
| | | | https://github.com/ruby/resolv/commit/6ab2385e89
* [ruby/resolv] Do not compress domain name in SRV RDATAKasumi Hanazuki2023-04-081-5/+5
| | | | | | | | | | | [RFC2782] prohibits use of name compression for the target host name in the RDATA of a SRV record. [RFC2782]: https://datatracker.ietf.org/doc/rfc2782/ Closes: https://github.com/ruby/resolv/issues/29 https://github.com/ruby/resolv/commit/ac85724e17
* [ruby/resolv] Support more characters in link local addressesJeremy Evans2022-01-121-2/+2
| | | | | | Implements [Feature #17524] https://github.com/ruby/resolv/commit/993a1a374f
* [ruby/resolv] Fix confusion of received response messageKazuki Yamaguchi2021-05-111-3/+3
| | | | | | | | | | | | | | | | | | | This is a follow up for commit 33fb966197f1 ("Remove sender/message_id pair after response received in resolv", 2020-09-11). As the @senders instance variable is also used for tracking transaction ID allocation, simply removing an entry without releasing the ID would eventually deplete the ID space and cause Resolv::DNS.allocate_request_id to hang. It seems the intention of the code was to check that the received DNS message is actually the response for the question made within the method earlier. Let's have it actually do so. [Bug #12838] https://bugs.ruby-lang.org/issues/12838 [Bug #17748] https://bugs.ruby-lang.org/issues/17748 https://github.com/ruby/resolv/commit/53ca9c9209
* `fe80` should be case insensitive tooKazuhiro NISHIYAMA2020-11-091-2/+2
|
* Support s390 IPv6 link local addressesJeremy Evans2020-11-071-1/+1
|
* Add support for IPv6 link local addresses to resolvJeremy Evans2020-11-071-1/+26
| | | | | | | | | | Now that it should work correctly, test that every address returned by Socket.ip_address_list is resolvable. Socket works with IPv6 link local addresses, and ipaddr now does as well, so I think resolv should support them. Fixes [Bug #17112]
* Remove sender/message_id pair after response received in resolvJeremy Evans2020-11-071-1/+1
| | | | | | | | | Once a response for a given DNS request has been received (which requires a matching message id), the [sender, message_id] pair should be removed from the list of valid senders. This makes it so duplicate responses from the same sender are ignored. Fixes [Bug #12838]
* Convert ip addresses to canonical form in ↵Jeremy Evans2020-05-291-0/+1
| | | | | | | | | Resolv::DNS::Requester::UnconnectedUDP#sender Otherwise, if the IP address given is not in canonical form, it won't match, and Resolv will ignore it. Fixes [Bug #16439]
* Deprecate taint/trust and related methods, and make the methods no-opsJeremy Evans2019-11-181-4/+0
| | | | | | This removes the related tests, and puts the related specs behind version guards. This affects all code in lib, including some libraries that may want to support older versions of Ruby.
* Fallback to TCP in resolv if UDP bind raises EACCESJeremy Evans2019-10-211-2/+7
| | | | | | Original patch from Andy Grimm. Fixes [Bug #10747]
* Use lowercase letters for IPv6 addresses.Tanaka Akira2019-07-301-1/+1
| | | | | | Reported by chucke (Tiago Cardoso). Patch by jeremyevans0 (Jeremy Evans). [Bug #14612]
* Get rid of LoadError with $DEBUGNobuyoshi Nakada2019-07-171-6/+7
|
* Make Resolv::DNS#each_name accept Resolv::IPv{4,6} argumentsJeremy Evans2019-06-081-0/+2
| | | | | | | | | These arguments were previously documented as supported, but not actually supported. Patch from Toru Iwase Fixes [Bug #15900]
* resolv.rb: remove rangerandnobu2018-03-061-12/+2
| | | | | | | * lib/resolv.rb (Resolv::DNS.rangerand): rand and random_number accept a Range. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* resolv.rb: close socketnobu2018-03-061-33/+69
| | | | | | | | | | | | | | | | | | | * lib/resolv.rb (UnconnectedUDP#lazy_initialize): store new sockets before binding, so the sockets get closed when the requester is closing. * lib/resolv.rb (ConnectedUDP#lazy_initialize): ditto. * lib/resolv.rb (UnconnectedUDP#close): synchronize to get rid of race condition. * lib/resolv.rb (ConnectedUDP#close): ditto. [ruby-core:85901] [Bug #14571] From: quixoten (Devin Christensen) <quixoten@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62671 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* resolv.rb: NUL hostsnobu2018-01-181-1/+1
| | | | | | | | | * lib/resolv.rb (Resolv::Hosts::DefaultFileName): fallback to NUL device when Win32::Resolv.get_hosts_path() returned nil, to get rid of TypeError in lazy_initialize. [ruby-core:84907] [Bug #14369] [Fix GH-1791] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61898 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* resolv: use safe navigation operatornobu2018-01-181-3/+1
| | | | | | | * lib/resolv.rb (each_address): use safe navigation operator to avoid extra hash lookups, as well as each_name since r56890. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61897 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Mock fetching data from real DNS [Feature #14340]naruse2018-01-111-1/+1
| | | | | | This test just tests MDNS#each_address method. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61774 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Fixed command Injectionnobu2017-12-201-1/+1
| | | | | | | | * lib/resolv.rb (Resolv::Config.parse_resolv_conf): fixed potential command injection by use of Kernel#open. [ruby-core:84347] [Bug #14205] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61351 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Fixed command Injectionnobu2017-12-201-1/+1
| | | | | | | | | | * resolv.rb (Resolv::Hosts#lazy_initialize): fixed potential command Injection in Hosts::new() by use of Kernel#open. [Fix GH-1777] [ruby-core:84347] [Bug #14205] From: Drigg3r <drigg3r@yandex.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61349 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Fixed unexpected behavior of `Resolv::MDNS#each_address` when given ".local" ↵hsbt2017-10-211-1/+1
| | | | | | | | | | address. https://github.com/ruby/ruby/pull/1425 Patch by @elct9620 [fix GH-1484] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60275 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* resolv.rb: remove unnecessary require statementglass2017-08-291-1/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59679 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* resolv.rb: byte buffernobu2017-01-141-6/+6
| | | | | | | * lib/resolv.rb (Resolv::DNS::Message::MessageDecoder): treat the data as a byte buffer. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57326 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Made #decode_rdata client to catch errorsnobu2017-01-141-1/+7
| | | | | | | | | | | * lib/resolv.rb (Resolv::DNS::Message::MessageDecoder#get_rr): re-raise an exception from decode_rdata as DecodeError, so it can report them to the top in more informative way. It was not reflecting on errors of data and thus breaking. Client code expects `DecodeError` and knows how to handle broken messages. [Fix GH-1511] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57325 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* resolv: use safe navigation operator to avoid extra hash lookupsnormal2016-11-231-3/+1
| | | | | | | | | | @addr2name is a private Hash and never changes its default_proc, so only pay the hash lookup cost once; we know missing entries in the hash will be nil. * lib/resolv.rb (each_name): use safe navigation operator git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56890 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Use `&.` instead of modifier ifkazu2016-11-221-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56873 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* resolv: use symbol proc when possiblenormal2016-11-211-7/+3
| | | | | | | | This reduces both human code and bytecode. lib/resolv.rb (sender_for, Config.parse_resolv_conf): use symbol proc git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56868 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* fix Resolv::LOC::Coord.create.akr2016-11-051-4/+6
| | | | | | | | | | * lib/resolv.rb (Resolv::LOC::Coord.create): fixed. [ruby-core:72567] [Bug #11912] fixed by Eric Wong and Kazuhiro NISHIYAMA. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56604 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* extract_resources uses each_resource instead of each_answer.akr2016-11-051-3/+3
| | | | | | | | | | * lib/resolv.rb (Resolv::DNS#extract_resources): Use each_resource instead of each_answer. [ruby-core:75461] [Bug#12372] reported by Rafael Fernandez Lopez. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56583 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Use qualified namesnobu2016-08-301-4/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56037 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Resolv::IPv6.create: avoid modifying frozen string literalnormal2015-12-281-5/+5
| | | | | | | | * lib/resolv.rb (Resolv::IPv6.create): avoid modifying frozen * test/resolv/test_dns.rb (test_ipv6_create): test for above [Bug #11910] [ruby-core:72559] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53363 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/open-uri.rb: Remove indicator for "frozen_string_literal: true".akr2015-11-101-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lib/pp.rb: Ditto. * lib/prettyprint.rb: Ditto. * lib/resolv.rb: Ditto. * lib/securerandom.rb: Ditto. * lib/tmpdir.rb: Ditto. * lib/unicode_normalize/tables.rb: Ditto. * test/net/ftp/test_buffered_socket.rb: Ditto. * test/net/ftp/test_mlsx_entry.rb: Ditto. * test/open-uri/test_open-uri.rb: Ditto. * test/open-uri/test_ssl.rb: Ditto. * test/pathname/test_pathname.rb: Ditto. * test/test_pp.rb: Ditto. * test/test_prettyprint.rb: Ditto. * tool/transcode-tblgen.rb: Ditto. * ext/pathname/lib/pathname.rb: Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52526 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/resolv.rb (Resolv::DNS::Message::MessageEncoder#put_labels):akr2015-11-091-1/+3
| | | | | | | | | Prevent overflow of pointer to labels. Patch by Hannes Georg. [ruby-core:71248] [Bug #11632] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52508 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Put an line before "frozen_string_literal: true" for emacs.akr2015-10-051-0/+1
| | | | | | | https://bugs.ruby-lang.org/issues/8976#note-49 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52052 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/pp.rb: Use frozen_string_literal: true.akr2015-10-051-1/+3
| | | | | | | | | | | | | | | | | | * lib/prettyprint.rb: Ditto. * lib/resolv.rb: Ditto. * lib/tmpdir.rb: Ditto. * test/test_pp.rb: Ditto. * test/test_prettyprint.rb: Ditto. * tool/transcode-tblgen.rb: Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52042 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* lib/*: use monotonic clock for timeoutsnormal2015-05-291-3/+3
| | | | | | | | | | The monotonic clock is preferred as it is guaranteed to be continuous and not subject to jumps due to adjustments. * lib/net/resolv.rb (request): use monotonic clock * lib/net/http.rb (begin_transport, end_transport): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50664 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* stdlib: use IO#wait_*able instead of IO.select when possiblenormal2015-05-061-1/+6
| | | | | | | | | | | | | | In case a process encounters high-numbered FDs, this allows consistent performance on systems with ppoll support. [ruby-core:35572] * ext/socket/lib/socket.rb (connect_nonblock): use IO#wait_writable * lib/drb/drb.rb (DRB::DRbTCPSocket#alive?): use IO#wait_readable * lib/webrick/httpserver.rb (run): ditto * lib/resolv.rb (request): ditto for single socket case [ruby-core:68943] [Feature #11081] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50432 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* resolv.rb: fix equalitynobu2015-02-171-3/+3
| | | | | | | | * lib/resolv.rb (Resolv::DNS::Resource#==, #hash): elements returned by Kernel#instance_variables are Symbols now. [ruby-core:68128] [Bug #10857] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* lib/resolv.rb: consider ENETUNREACH as ResolvTimeoutnormal2015-01-071-2/+2
| | | | | | | | | This allows "gem install /path/to/local.gem" to be successful on a machine without a network connection. [ruby-core:67411] [Bug #10712] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49175 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/resolv.rb (Resolv::DNS::Label::Str#==): Check class equality.akr2015-01-021-1/+9
| | | | | | | | | (Resolv::DNS::Name#initialize): Normalize labels as Resolv::DNS::Label::Str objects. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49095 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* resolv.rb: String#bnobu2014-12-311-1/+1
| | | | | | * lib/resolv.rb (Resolv::DNS::Label::Str#initialize): use String#b. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49084 b2dd03c8-39d4-4d8f-98ff-823fe69b080e