Sha256: 65f0f97d86d2a210bcf4132bb44bcd353bd9555159923cab0922dea604049613

Contents?: true

Size: 1.33 KB

Versions: 10

Compression:

Stored size: 1.33 KB

Contents

#--
# Ruby Whois
#
# An intelligent pure Ruby WHOIS client and parser.
#
# Copyright (c) 2009-2011 Simone Carletti <weppos@weppos.net>
#++


module Whois
  class Server
    module Adapters

      #
      # = Public Internet Registry (PIR) Adapter
      #
      # Provides ability to query PIR WHOIS interfaces.
      #
      # The following WHOIS servers are currently known
      # to require the Pir adapter:
      #
      # - whois.publicinterestregistry.net
      #
      class Pir < Base

        # Executes a WHOIS query to the PIR WHOIS interface,
        # resolving any intermediate referral,
        # and appends the response to the client buffer.
        #
        # @param  [String] string
        # @return [void]
        #
        def request(string)
          response = query_the_socket("FULL #{string}", host, DEFAULT_WHOIS_PORT)
          buffer_append response, host

          if endpoint = extract_referral(response)
            response = query_the_socket(string, endpoint, DEFAULT_WHOIS_PORT)
            buffer_append response, endpoint
          end
        end


        private

          def extract_referral(response)
            if response =~ /Registrant Name:SEE SPONSORING REGISTRAR/ &&
               response =~ /Registrant Street1:Whois Server:(\S+)/
              $1
            end
          end

      end

    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
whois-2.2.0 lib/whois/server/adapters/pir.rb
whois-2.1.0 lib/whois/server/adapters/pir.rb
whois-2.0.7 lib/whois/server/adapters/pir.rb
whois-2.0.6 lib/whois/server/adapters/pir.rb
whois-2.0.5 lib/whois/server/adapters/pir.rb
whois-2.0.4 lib/whois/server/adapters/pir.rb
whois-2.0.3 lib/whois/server/adapters/pir.rb
whois-2.0.2 lib/whois/server/adapters/pir.rb
whois-2.0.1 lib/whois/server/adapters/pir.rb
whois-2.0.0 lib/whois/server/adapters/pir.rb