Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add whois.registration.ge for .ge #139

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
201 changes: 201 additions & 0 deletions lib/whois/parsers/whois.registration.ge.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
#--
# Ruby Whois
#
# An intelligent pure Ruby WHOIS client and parser.
#
# Copyright (c) 2009-2018 Simone Carletti <[email protected]>
#++


require_relative 'base'
require 'whois/scanners/whois.registration.ge.rb'

module Whois
class Parsers

# Parser for the whois.example.com server.
#
# In case you are not implementing all the methods,
# please add the following statement to the class docblock.
#
# @note This parser is just a stub and provides only a few basic methods
# to check for domain availability and get domain status.
# Please consider to contribute implementing missing methods.
class WhoisRegistrationGe < Base

include Scanners::Scannable

self.scanner = Scanners::WhoisRegistrationGe

# Gets the registry disclaimer that comes with the record.
#
# Returns a String with the disclaimer if available,
# <tt>nil</tt> otherwise.
property_supported :disclaimer do
nil
end

# Gets the domain name as stored by the registry.
#
# Returns a String with the domain name if available,
# <tt>nil</tt> otherwise.
property_supported :domain do
if content_for_scanner =~ /No match for\s\"(.+)\"\.\n/
$1.downcase
else
node("Domain Name", &:downcase)
end
end

# Gets the unique domain ID as stored by the registry.
#
# Returns a String with the domain ID if available,
# <tt>nil</tt> otherwise.
property_supported :domain_id do
raise Whois::AttributeNotSupported
end

# Gets the record status or statuses.
#
# Returns a String/Array with the record status if available,
# <tt>nil</tt> otherwise.
property_supported :status do
if available?
:available
else
:registered
end
end

# Checks whether this record is available.
#
# Returns true/false depending whether this record is available.
property_supported :available? do
!!(content_for_scanner =~ /^No match for/)
end

# Checks whether this record is registered.
#
# Returns true/false depending this record is available.
property_supported :registered? do
!available?
end

# Gets the date the record was created,
# according to the registry record.
#
# Returns a Time object representing the date the record was created or
# <tt>nil</tt> otherwise.
property_supported :created_on do
node("Creation Date") { |value| parse_time(value) }
end

# Gets the date the record was last updated,
# according to the registry record.
#
# Returns a Time object representing the date the record was last updated or
# <tt>nil</tt> if not available.
property_supported :updated_on do
nil
end

# Gets the date the record is set to expire,
# according to the registry record.
#
# Returns a Time object representing the date the record is set to expire or
# <tt>nil</tt> if not available.
property_supported :expires_on do
node("Registry Expiry Date") { |value| parse_time(value) }
end

# Gets the registrar object containing the registrar details
# extracted from the registry record.
#
# Returns an instance of <tt>Parser::Registrar</tt> representing the registrar or
# <tt>nil</tt> if not available.
property_supported :registrar do
if node("Registrar")
Parser::Registrar.new(
name: node("Registrar"),
)
end
end


# Gets the registrant contact object containing the details of the record owner
# extracted from the registry record.
#
# Returns an instance of <tt>Parser::Contact</tt> representing the registrant contact or
# <tt>nil</tt> if not available.
property_supported :registrant_contacts do
build_contact("Registrant", Parser::Contact::TYPE_REGISTRANT)
end

# Gets the administrative contact object containing the details of the record administrator
# extracted from the registry record.
#
# Returns an instance of <tt>Parser::Contact</tt> representing the administrative contact or
# <tt>nil</tt> if not available.
property_supported :admin_contacts do
build_contact("Admin", Parser::Contact::TYPE_ADMINISTRATIVE)
end

# Gets the technical contact object containing the details of the technical representative
# extracted from the registry record.
#
# Returns an instance of <tt>Parser::Contact</tt> representing the technical contact or
# <tt>nil</tt> if not available.
property_supported :technical_contacts do
build_contact("Tech", Parser::Contact::TYPE_TECHNICAL)
end


# Gets the list of name server entries for this record,
# extracted from the registry record.
#
# @example
# nameserver
# # => []
#
# @example
# nameserver
# # => [
# # #<struct Parser::Nameserver name="ns1.google.com">,
# # #<struct Parser::Nameserver name="ns2.google.com">
# # ]
#
# @return [Array<Parser::Nameserver>]
property_supported :nameservers do
Array.wrap(node("Name Server")).reject(&:empty?).reverse.map do |name|
Parser::Nameserver.new(name: name.downcase)
end
end

private

def build_contact(element, type)
if type == Parser::Contact::TYPE_REGISTRANT
node(element) do
Parser::Contact.new(
type: type,
name: node("#{element}"),
)
end
elsif Parser::Contact::TYPE_ADMINISTRATIVE
Parser::Contact.new(
type: type,
name: node("Admin Name"),
email: node("Admin Email")
)
elsif Parser::Contact::TYPE_TECHNICAL
Parser::Contact.new(
type: type,
name: node("Tech Name"),
email: node("Tech Email")
)
end
end
end

end
end
43 changes: 43 additions & 0 deletions lib/whois/scanners/whois.registration.ge.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
require_relative 'base'

module Whois
module Scanners

class WhoisRegistrationGe < Base

self.tokenizers += [
:skip_head,
:scan_available,
:scan_throttled,
:skip_empty_line,
:skip_blank_line,
:scan_keyvalue,
:skip_end,
]

tokenizer :scan_available do
if settings[:pattern_available] && @input.skip_until(settings[:pattern_available])
@ast['status:available'] = true
end
end

tokenizer :scan_throttled do
if settings[:pattern_throttled] && @input.skip_until(settings[:pattern_throttled])
@ast['response:throttled'] = true
end
end

tokenizer :skip_head do
if @input.skip_until(/Domain Name:/)
@input.scan(/\s?(.+)\n/)
@ast["Domain Name"] = @input[1].strip
end
end

tokenizer :skip_end do
@input.terminate
end

end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#domain
%s == "u34jedzcq.ge"

#status
%s == :available

#available?
%s == true

#registered?
%s == false

#created_on
%s == nil

#updated_on
%s == nil

#expires_on
%s == nil


#registrar
%s == nil


#nameservers
%s %CLASS{array}
%s == []
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
No match for "U34JEDZCQ.GE".


TERMS OF USE:
The WHOIS service is provided solely for informational purposes.
You are not authorized to access or query our Whois
database through the use of electronic processes that are high-volume and
automated except as reasonably necessary to register domain names or
modify existing registrations; the Data is provided by NIC for
information purposes only, and to assist persons in obtaining information
about or related to a domain name registration record. NIC does not
guarantee its accuracy. By submitting a Whois query, you agree to abide
by the following terms of use: You agree that you may use this Data only
for lawful purposes and that under no circumstances will you use this Data
to: (1) allow, enable, or otherwise support the transmission of mass
unsolicited, commercial advertising or solicitations via e-mail, telephone,
or facsimile; or (2) enable high volume, automated, electronic processes
that apply to NIC (or its computer systems). The compilation,
repackaging, dissemination or other use of this Data is expressly
prohibited without the prior written consent of NIC. You agree not to
use electronic processes that are automated and high-volume to access or
query the Whois database except as reasonably necessary to register
domain names or modify existing registrations. NIC reserves the right
to restrict your access to the Whois database in its sole discretion to ensure
operational stability. NIC may restrict or terminate your access to the
Whois database for failure to abide by these terms of use. NIC
reserves the right to modify these terms at any time.
Loading