Permalink
Browse files

Updated .NU definition and parser (closes GH-165)

  • Loading branch information...
1 parent ab343ce commit 9de02420bd8460d5d3c35bf7fd12e2dd9311e3e5 @weppos committed Oct 30, 2013
View
@@ -4,12 +4,16 @@
- SERVER: Added .XN--MGBX4CD0AB (.ایران, Iran) IDN TLD definition.
+- SERVER: Updated .NU (GH-265) TLD definition.
+
- NEW: Added whois.yoursrs.com parser (GH-266). [Thanks @takama]
- NEW: Added whois.ascio.com parser (GH-262). [Thanks @takama]
- NEW: Added whois.rrpproxy.net parser (GH-259). [Thanks @takama]
+- CHANGED: Changed .NU TLD to the new response format and parser (GH-265).
+
## Release 3.3.1
View
@@ -830,7 +830,7 @@
"url": "http://www.cenpac.net.nr/dns/whois.html"
},
".nu": {
- "host": "whois.nic.nu"
+ "host": "whois.iis.nu"
},
".nz": {
"host": "whois.srs.net.nz"
@@ -0,0 +1,117 @@
+#--
+# Ruby Whois
+#
+# An intelligent pure Ruby WHOIS client and parser.
+#
+# Copyright (c) 2009-2013 Simone Carletti <weppos@weppos.net>
+#++
+
+
+require 'whois/record/parser/base'
+require 'whois/record/scanners/base_iisse.rb'
+
+
+module Whois
+ class Record
+ class Parser
+
+ # Parser for the whois.iis.nu server.
+ #
+ # @see Whois::Record::Parser::Example
+ # The Example parser for the list of all available methods.
+ #
+ class WhoisIisNu < Base
+ include Scanners::Scannable
+
+ self.scanner = Scanners::BaseIisse
+
+
+ property_supported :disclaimer do
+ node("field:disclaimer")
+ end
+
+
+ property_supported :domain do
+ node("domain")
+ end
+
+ property_not_supported :domain_id
+
+
+ property_supported :status do
+ if available?
+ :available
+ else
+ :registered
+ end
+ end
+
+ property_supported :available? do
+ !!node("status:available")
+ end
+
+ property_supported :registered? do
+ !available?
+ end
+
+
+ property_supported :created_on do
+ node("created") { |value| Time.parse(value) }
+ end
+
+ property_supported :expires_on do
+ node("expires") { |value| Time.parse(value) }
+ end
+
+ property_supported :updated_on do
+ node("modified") { |value| Time.parse(value) unless value == "-" }
+ end
+
+
+ property_supported :registrar do
+ node("registrar") { |name| Record::Registrar.new(name: name) unless name == "-" }
+ end
+
+
+ property_supported :registrant_contacts do
+ build_contact(Whois::Record::Contact::TYPE_REGISTRANT, node("holder"))
+ end
+
+ property_supported :admin_contacts do
+ build_contact(Whois::Record::Contact::TYPE_ADMINISTRATIVE, node("admin-c"))
+ end
+
+ property_supported :technical_contacts do
+ build_contact(Whois::Record::Contact::TYPE_TECHNICAL, node("tech-c"))
+ end
+
+
+ # nserver: ns2.loopia.se
+ # nserver: ns2.loopia.se 93.188.0.21
+ #
+ property_supported :nameservers do
+ node("nserver") do |values|
+ values.map do |line|
+ name, ipv4 = line.split(/\s+/)
+ Record::Nameserver.new(name: name, ipv4: ipv4)
+ end
+ end
+ end
+
+
+ private
+
+ def build_contact(type, id)
+ return if id.nil? || id == "-"
+
+ Record::Contact.new(
+ type: type,
+ id: id
+ )
+ end
+
+ end
+
+ end
+ end
+end
@@ -8,7 +8,8 @@
require 'whois/record/parser/base'
-require 'whois/record/scanners/whois.nic-se.se.rb'
+require 'whois/record/scanners/base_iisse.rb'
+
module Whois
class Record
@@ -23,7 +24,7 @@ class Parser
class WhoisNicSeSe < Base
include Scanners::Scannable
- self.scanner = Scanners::WhoisNicSeSe
+ self.scanner = Scanners::BaseIisse
property_supported :disclaimer do
@@ -1,96 +0,0 @@
-#--
-# Ruby Whois
-#
-# An intelligent pure Ruby WHOIS client and parser.
-#
-# Copyright (c) 2009-2013 Simone Carletti <weppos@weppos.net>
-#++
-
-
-require 'whois/record/parser/base'
-
-
-module Whois
- class Record
- class Parser
-
- #
- # = whois.nic.nu
- #
- # Parser for the whois.nic.nu server.
- #
- # 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.
- # See WhoisNicIt parser for an explanation of all available methods
- # and examples.
- #
- # @author Simone Carletti <weppos@weppos.net>
- # @author Mikkel Kristensen <mikkel@tdx.dk>
- #
- class WhoisNicNu < Base
-
-
- # == Values for Status
- #
- # @see http://www.nic.nu/about/about5.pdf
- #
- property_supported :status do
- if content_for_scanner =~ /Record status:\s+(.*)\n/
- case $1.downcase
- when "active" then :registered
- # The day after the domain name expires, its status is changed to "Not Renewed",
- # but it is still available for you to renew during another fourweek period.
- # After this expiration reprieve, the name is put up for shortterm auction.
- # If no one registers the name via the auction, it expires and becomes available
- # to the general public for registration using the standard process.
- when "notrenewed" then :redemption
- else
- Whois.bug!(ParserError, "Unknown status `#{$1}'.")
- end
- else
- :available
- end
- end
-
- property_supported :available? do
- !!(content_for_scanner =~ /NO MATCH for domain/)
- end
-
- property_supported :registered? do
- !available?
- end
-
-
- property_supported :created_on do
- if content_for_scanner =~ /Record created on (.+?).\n/
- Time.parse($1)
- end
- end
-
- property_supported :updated_on do
- if content_for_scanner =~ /Record last updated on (.+?).\n/
- Time.parse($1)
- end
- end
-
- property_supported :expires_on do
- if content_for_scanner =~ /Record expires on (.+?).\n/
- Time.parse($1)
- end
- end
-
-
- property_supported :nameservers do
- if content_for_scanner =~ /Domain servers in listed order:(.*)Owner and Administrative Contact information for domains/m
- $1.split.map do |name|
- Record::Nameserver.new(:name => name)
- end
- end
- end
-
- end
-
- end
- end
-end
@@ -14,7 +14,8 @@ module Whois
class Record
module Scanners
- class WhoisNicSeSe < Base
+ # Scanner for the IIS.se company.
+ class BaseIisse < Base
self.tokenizers += [
:skip_empty_line,
@@ -25,13 +26,15 @@ class WhoisNicSeSe < Base
tokenizer :scan_available do
- @ast["status:available"] = true if @input.skip(/".*" not found\.\n/)
+ if @input.skip(/^domain "(.+)" not found.+\n/)
+ @ast["status:available"] = true
+ end
end
tokenizer :scan_disclaimer do
- if @input.match?(/# Copyright \(c\) [\d-]* \.SE \(The Internet Infrastructure Foundation\)\.\n# All rights reserved\.\n\n/)
+ if @input.match?(/# Copyright/)
lines = []
- while !@input.match?(/# Result of search for registered domain names under\n/) && @input.scan(/#?(.*)\n/)
+ while !@input.match?(/# Result of/) && @input.scan(/#?(.*)\n/)
lines << @input[1].strip unless @input[1].strip == ""
end
@input.skip_until(/# printed with .+ bits\.\n/m)
@@ -0,0 +1,51 @@
+#disclaimer
+ %s == "Copyright (c) 1997- .SE (The Internet Infrastructure Foundation). All rights reserved. The information obtained through searches, or otherwise, is protected by the Swedish Copyright Act (1960:729) and international conventions. It is also subject to database protection according to the Swedish Copyright Act. Any use of this material to target advertising or similar activities is forbidden and will be prosecuted. If any of the information below is transferred to a third party, it must be done in its entirety. This server must not be used as a backend for a search engine."
+
+
+#domain
+ %s == nil
+
+#domain_id
+ %s %ERROR{AttributeNotSupported}
+
+
+#status
+ %s == :available
+
+#available?
+ %s == true
+
+#registered?
+ %s == false
+
+
+#created_on
+ %s == nil
+
+#updated_on
+ %s == nil
+
+#expires_on
+ %s == nil
+
+
+#registrar
+ %s == nil
+
+
+#registrant_contacts
+ %s %CLASS{array}
+ %s == []
+
+#admin_contacts
+ %s %CLASS{array}
+ %s == []
+
+#technical_contacts
+ %s %CLASS{array}
+ %s == []
+
+
+#nameservers
+ %s %CLASS{array}
+ %s == []
@@ -0,0 +1,19 @@
+# Copyright (c) 1997- .SE (The Internet Infrastructure Foundation).
+# All rights reserved.
+
+# The information obtained through searches, or otherwise, is protected
+# by the Swedish Copyright Act (1960:729) and international conventions.
+# It is also subject to database protection according to the Swedish
+# Copyright Act.
+
+# Any use of this material to target advertising or
+# similar activities is forbidden and will be prosecuted.
+# If any of the information below is transferred to a third
+# party, it must be done in its entirety. This server must
+# not be used as a backend for a search engine.
+
+# Result of search for registered domain names under
+# the .nu top level domain.
+# The data is in the UTF-8 character set and the result is
+# printed with eight bits.
+domain "u34jedzcq.nu" not found.
Oops, something went wrong. Retry.

0 comments on commit 9de0242

Please sign in to comment.