Class: Ddig::Resolver::DnsMessage
- Inherits:
-
Object
- Object
- Ddig::Resolver::DnsMessage
- Defined in:
- lib/ddig/resolver/dns_message.rb
Class Method Summary collapse
Class Method Details
.decode(payload) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/ddig/resolver/dns_message.rb', line 21 def self.decode(payload) if payload.nil? return nil end Resolv::DNS::Message.decode(payload) end |
.encode(hostname, typeclass) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/ddig/resolver/dns_message.rb', line 6 def self.encode(hostname, typeclass) if hostname.nil? return nil end if typeclass.nil? return nil end = Resolv::DNS::Message.new .rd = 1 # recursive query .add_question(hostname, typeclass) .encode end |
.getresources(payload) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/ddig/resolver/dns_message.rb', line 29 def self.getresources(payload) if payload.nil? return [] end response = self.decode(payload) return response.answer.map { |name, ttl, resource| resource } end |