6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/joker-dmapi/host.rb', line 6
def host_info(host)
response = query_no_raise :query_whois, { host: host }
case response[:headers][:status_code]
when '2303' then nil
when '0' then
result = {}
response[:body].split("\n").each do |line|
line.slice! /^host\./
line_parsed = parse_line(line)
next if line_parsed.is_a? String
key, value = line_parsed.first
case key
when :fqdn then result[:host] = value
when :ip_address then result[:ipv4] = value
when :ip_address_v6 then result[:ipv6] = value
when :created_date, :modified_date then
result[key] = DateTime.parse value
else
result.merge! line_parsed
end
end
result
else
raise_response response
end
end
|