Class: Middleman::DnsResolver::BasicNetworkResolver
- Inherits:
-
Object
- Object
- Middleman::DnsResolver::BasicNetworkResolver
- Defined in:
- lib/middleman-core/dns_resolver/basic_network_resolver.rb
Overview
Use network name server to resolve ips and names
Direct Known Subclasses
Instance Attribute Summary collapse
-
#timeouts ⇒ Object
writeonly
Set timeout for lookup.
Instance Method Summary collapse
-
#getaddresses(name) ⇒ Array
Get ips for name.
-
#getnames(ip) ⇒ Array
Get names for ip.
-
#initialize(opts = {}) ⇒ BasicNetworkResolver
constructor
A new instance of BasicNetworkResolver.
Constructor Details
#initialize(opts = {}) ⇒ BasicNetworkResolver
Returns a new instance of BasicNetworkResolver.
11 12 13 |
# File 'lib/middleman-core/dns_resolver/basic_network_resolver.rb', line 11 def initialize(opts={}) @timeouts = opts.fetch(:timeouts, 2) end |
Instance Attribute Details
#timeouts=(timeouts) ⇒ Object
Set timeout for lookup
45 46 47 48 49 |
# File 'lib/middleman-core/dns_resolver/basic_network_resolver.rb', line 45 def timeouts=(timeouts) return if RUBY_VERSION < '2' resolver.timeouts = timeouts end |
Instance Method Details
#getaddresses(name) ⇒ Array
Get ips for name
35 36 37 38 39 |
# File 'lib/middleman-core/dns_resolver/basic_network_resolver.rb', line 35 def getaddresses(name) resolver.getaddresses(name.to_s).map(&:to_s) rescue Resolv::ResolvError, Errno::EADDRNOTAVAIL [] end |
#getnames(ip) ⇒ Array
Get names for ip
22 23 24 25 26 |
# File 'lib/middleman-core/dns_resolver/basic_network_resolver.rb', line 22 def getnames(ip) resolver.getnames(ip.to_s).map(&:to_s) rescue Resolv::ResolvError, Errno::EADDRNOTAVAIL [] end |