Class: IPv6FavorResolv
- Inherits:
-
Object
show all
- Defined in:
- lib/resolv-ipv6favor.rb
Overview
Resolver class that resolves AAAA record first, then A record
Constant Summary
collapse
- DefaultResolver =
self.new
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(resolv_conf = '/etc/resolv.conf') ⇒ IPv6FavorResolv
Returns a new instance of IPv6FavorResolv.
20
21
22
|
# File 'lib/resolv-ipv6favor.rb', line 20
def initialize(resolv_conf='/etc/resolv.conf')
@r = Resolv::DNS.new(resolv_conf)
end
|
Class Method Details
.each_address(name) ⇒ Object
8
9
10
|
# File 'lib/resolv-ipv6favor.rb', line 8
def self.each_address(name)
DefaultResolver.each_address(name)
end
|
.getaddress(name) ⇒ Object
16
17
18
|
# File 'lib/resolv-ipv6favor.rb', line 16
def self.getaddress(name)
DefaultResolver.getaddress(name)
end
|
.getaddresses(name) ⇒ Object
12
13
14
|
# File 'lib/resolv-ipv6favor.rb', line 12
def self.getaddresses(name)
DefaultResolver.getaddresses(name)
end
|
Instance Method Details
#each_address(name) ⇒ Object
25
26
27
28
|
# File 'lib/resolv-ipv6favor.rb', line 25
def each_address(name)
@r.each_resource(name, Resolv::DNS::Resource::IN::AAAA) {|resource| yield resource.address}
@r.each_resource(name, Resolv::DNS::Resource::IN::A) {|resource| yield resource.address}
end
|
#getaddress(name) ⇒ Object
36
37
38
|
# File 'lib/resolv-ipv6favor.rb', line 36
def getaddress(name)
getaddresses(name)[0]
end
|
#getaddresses(name) ⇒ Object
30
31
32
33
34
|
# File 'lib/resolv-ipv6favor.rb', line 30
def getaddresses(name)
res = []
each_address(name) { |addr| res << addr}
res
end
|