Class: FTW::DNS::DNS
- Inherits:
-
Object
- Object
- FTW::DNS::DNS
- Defined in:
- lib/ftw/dns/dns.rb
Overview
A FTW::DNS resolver that uses Socket.gethostbyname() to resolve addresses.
Instance Method Summary collapse
-
#resolve(hostname) ⇒ Object
Resolve a hostname.
Instance Method Details
#resolve(hostname) ⇒ Object
Resolve a hostname.
It will return an array of all known addresses for the host.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/ftw/dns/dns.rb', line 12 def resolve(hostname) official, aliases, family, *addresses = Socket.gethostbyname(hostname) # We ignore family, here. Ruby will return v6 *and* v4 addresses in # the same gethostbyname() call. It is confusing. # # Let's just rely entirely on the length of the address string. return addresses.collect do |address| if address.length == 16 unpack_v6(address) else unpack_v4(address) end end end |