Skip to content

Commit

Permalink
whois (joker)
Browse files Browse the repository at this point in the history
  • Loading branch information
kubicek committed Mar 9, 2024
1 parent 96ae8ab commit 831c843
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
/pkg/
/spec/reports/
/tmp/
/production/
1 change: 1 addition & 0 deletions lib/xmon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
require_relative "xmon/dns"
require_relative "xmon/rdap"
require_relative "xmon/reverse_dns"
require_relative "xmon/whois"

module Xmon
class Error < StandardError; end
Expand Down
5 changes: 5 additions & 0 deletions lib/xmon/descriptions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ def dns(&)
@description = Xmon::DNS.new(self)
describe(&)
end

def whois(&)
@description = Xmon::Whois.new(self)
describe(&)
end
end

class IPv4Description < Description
Expand Down
23 changes: 22 additions & 1 deletion lib/xmon/whois.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,29 @@

module Xmon
class Whois < Description
def initialize(parent, **opts)
@parent = parent
@domain = parent.name
define_attributes([:registrant, :registrar, :expires])
end

def fetch(record)
::Whois.whois(record)
response = ::Whois.whois(record)
# only joker.com compatible
{
registrar: response.match(/Registrar URL: https:\/\/(.*)/)[1].strip,
registrant: response.match(/Registrant Organization: (.*)/)[1].strip,
expiration: response.match(/Registrar Registration Expiration Date: (.*)/)[1].strip,
status: response.match(/Domain Status: (.*)/)[1].strip
}
end

def check
checker = fetch(@domain)
[Xmon.compare(@status, checker[:status].split(" ").first, self),
Xmon.compare(@registrant, checker[:registrant], self),
Xmon.compare(@registrar, checker[:registrar], self),
Xmon.compare(@expires, checker[:expiration][0, 10], self)]
end
end
end

0 comments on commit 831c843

Please sign in to comment.