Class: PhisherPhinder::HostInformationFinder
- Inherits:
-
Object
- Object
- PhisherPhinder::HostInformationFinder
- Defined in:
- lib/phisher_phinder/host_information_finder.rb
Instance Method Summary collapse
- #information_for(address) ⇒ Object
-
#initialize(whois_client:, extractor:) ⇒ HostInformationFinder
constructor
A new instance of HostInformationFinder.
Constructor Details
#initialize(whois_client:, extractor:) ⇒ HostInformationFinder
Returns a new instance of HostInformationFinder.
5 6 7 8 |
# File 'lib/phisher_phinder/host_information_finder.rb', line 5 def initialize(whois_client:, extractor:) @whois_client = whois_client @extractor = extractor end |
Instance Method Details
#information_for(address) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/phisher_phinder/host_information_finder.rb', line 10 def information_for(address) most_relevant_record = nil begin case address when ExtendedIp most_relevant_record = @whois_client.lookup(address.ip_address.to_s) when String hostname_parts = address.split('.') until most_relevant_record do address = hostname_parts.join('.') whois_record = @whois_client.lookup(address) if whois_record.parser.available? hostname_parts = hostname_parts[1..-1] else most_relevant_record = whois_record end end end rescue Whois::ServerNotFound rescue Whois::AttributeNotImplemented end { abuse_contacts: most_relevant_record ? @extractor.abuse_contact_emails(most_relevant_record.content) : [], creation_date: creation_date(most_relevant_record) } end |