- Inheritance
- < Object
Resolv is a thread-aware DNS resolver library written in Ruby. Resolv can handle multiple DNS requests concurrently without blocking. The ruby interpreter.
See also resolv-replace.rb to replace the libc resolver with # Resolv.
Resolv can look up various DNS resources using the DNS module directly.
Examples:
p Resolv.getaddress "www.ruby-lang.org" p Resolv.getname "210.251.121.214" Resolv::DNS.open do |dns| ress = dns.getresources "www.ruby-lang.org", Resolv::DNS::Resource::IN::A p ress.map { |r| r.address } ress = dns.getresources "ruby-lang.org", Resolv::DNS::Resource::IN::MX p ress.map { |r| [r.exchange.to_s, r.preference] } end
Bugs
- NIS is not supported.
- /etc/nsswitch.conf is not supported.
Classes & Modules
Constants
Name | Description | |
---|---|---|
AddressRegex | = /(?:#{IPv4::Regex})|(?:#{IPv6::Regex})/ | Address Regexp to use for matching IP addresses. |
DefaultResolver | = self.new | Default resolver to use for Resolv class methods. |
Methods
Class
Visibility | Signature |
---|---|
public | each_address (name, &block) |
public | each_name (address, &proc) |
public | getaddress (name) |
public | getaddresses (name) |
public | getname (address) |
public | getnames (address) |
public | new (resolvers=[Hosts.new, DNS.new]) |
Instance
Visibility | Signature |
---|---|
public | each_address (name) {|name| ...} |
public | each_name (address) {|name.to_s| ...} |
public | getaddress (name) |
public | getaddresses (name) |
public | getname (address) |
public | getnames (address) |
Class Method Detail
each_address(name, &block)
Iterates over all IP addresses for name.
each_name(address, &proc)
Iterates over all hostnames for address.
getaddress(name)
Looks up the first IP address for name.
getaddresses(name)
Looks up all IP address for name.
getname(address)
Looks up the hostname of address.
getnames(address)
Looks up all hostnames for address.
new(resolvers=[Hosts.new, DNS.new])
Instance Method Detail
each_address(name) {|name| ...}
Iterates over all IP addresses for name.
each_name(address) {|name.to_s| ...}
Iterates over all hostnames for address.
getaddress(name)
Looks up the first IP address for name.
getaddresses(name)
Looks up all IP address for name.
getname(address)
Looks up the hostname of address.
getnames(address)
Looks up all hostnames for address.