Class: Ronin::Listener::DNS::Query
- Inherits:
-
Object
- Object
- Ronin::Listener::DNS::Query
- Defined in:
- lib/ronin/listener/dns/query.rb
Overview
Represents a received DNS query.
Instance Attribute Summary collapse
-
#label ⇒ String
(also: #name)
readonly
The domain label (ex:
example.com
orwww.example.com
). -
#source_addr ⇒ Addrinfo
readonly
The remote IP address and port that sent the query.
-
#type ⇒ :A, ...
readonly
The desired record type.
Instance Method Summary collapse
-
#initialize(type, label, source_addr) ⇒ Query
constructor
private
Initializes the query.
-
#source ⇒ String
The source of the query.
-
#source_ip ⇒ String
The source IP address that sent the query.
-
#source_port ⇒ Integer
The source port the query was sent from.
-
#to_a ⇒ (String, Integer, Symbol, String)
Converts the query into an Array.
-
#to_csv ⇒ String
Converts the DNS query to a CSV row.
-
#to_h ⇒ Hash{Symbol => String,Integer,Symbol}
(also: #as_json)
Converts the query into a Hash.
-
#to_json(*args) ⇒ String
Converts the DNS query into JSON.
-
#to_s ⇒ String
Converts the query to a String.
Constructor Details
#initialize(type, label, source_addr) ⇒ Query
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initializes the query.
63 64 65 66 67 68 |
# File 'lib/ronin/listener/dns/query.rb', line 63 def initialize(type,label,source_addr) @type = type @label = label @source_addr = source_addr end |
Instance Attribute Details
#label ⇒ String (readonly) Also known as: name
The domain label (ex: example.com
or www.example.com
).
40 41 42 |
# File 'lib/ronin/listener/dns/query.rb', line 40 def label @label end |
#source_addr ⇒ Addrinfo (readonly)
The remote IP address and port that sent the query.
47 48 49 |
# File 'lib/ronin/listener/dns/query.rb', line 47 def source_addr @source_addr end |
#type ⇒ :A, ... (readonly)
The desired record type.
35 36 37 |
# File 'lib/ronin/listener/dns/query.rb', line 35 def type @type end |
Instance Method Details
#source ⇒ String
The source of the query.
94 95 96 |
# File 'lib/ronin/listener/dns/query.rb', line 94 def source "#{source_ip}:#{source_port}" end |
#source_ip ⇒ String
The source IP address that sent the query.
75 76 77 |
# File 'lib/ronin/listener/dns/query.rb', line 75 def source_ip @source_addr.ip_address end |
#source_port ⇒ Integer
The source port the query was sent from.
84 85 86 |
# File 'lib/ronin/listener/dns/query.rb', line 84 def source_port @source_addr.ip_port end |
#to_a ⇒ (String, Integer, Symbol, String)
Converts the query into an Array.
114 115 116 |
# File 'lib/ronin/listener/dns/query.rb', line 114 def to_a [source_ip, source_port, @type, @label] end |
#to_csv ⇒ String
Converts the DNS query to a CSV row.
140 141 142 |
# File 'lib/ronin/listener/dns/query.rb', line 140 def to_csv to_a.to_csv end |
#to_h ⇒ Hash{Symbol => String,Integer,Symbol} Also known as: as_json
Converts the query into a Hash.
125 126 127 128 129 130 131 132 |
# File 'lib/ronin/listener/dns/query.rb', line 125 def to_h { source_ip: source_ip, source_port: source_port, type: @type, label: @label } end |
#to_json(*args) ⇒ String
Converts the DNS query into JSON.
155 156 157 |
# File 'lib/ronin/listener/dns/query.rb', line 155 def to_json(*args) as_json.to_json(*args) end |
#to_s ⇒ String
Converts the query to a String.
104 105 106 |
# File 'lib/ronin/listener/dns/query.rb', line 104 def to_s "#{source} #{@type} #{@label}" end |