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

Use the standard adapter if hostname doesn't match guessed server #250

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/whois/client.rb
Expand Up @@ -89,7 +89,7 @@ def initialize(settings = {})
def lookup(object) def lookup(object)
string = object.to_s.downcase string = object.to_s.downcase
Timeout::timeout(timeout) do Timeout::timeout(timeout) do
@server = Server.guess(string) @server = Server.guess_with_fallback(string, settings)
@server.configure(settings) @server.configure(settings)
@server.lookup(string) @server.lookup(string)
end end
Expand Down
15 changes: 15 additions & 0 deletions lib/whois/server.rb
Expand Up @@ -245,6 +245,21 @@ def self.guess(string)
end end




# Try to guess the right server, or use the Standard adapter if necessary.
#
# @param [String] string
# @param [Hash] settings Hash of settings originally sent to the client.
# @return [Whois::Server::Adapters::Base]
#
def self.guess_with_fallback(string, settings)
server = guess(string)
if settings[:host] && server.host != settings[:host]
return Adapters::Standard.new(server.type, server.allocation, server.host, server.options)
end
server
end


private private


def self.camelize(string) def self.camelize(string)
Expand Down