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

Conversation

linrock
Copy link
Contributor

@linrock linrock commented Aug 11, 2013

Fixes #245. The following should work now:

$ ruby-whois surface.net -h whois.tucows.com

The guessed server is also still used if the hostname happens to match:

$ ruby-whois 130.66.76.222 -h whois.arin.net

@weppos
Copy link
Owner

weppos commented Aug 11, 2013

I'm actually not sure about this patch. While the final solution is correct, I'm actually considering whether it's a better idea to reset the adapter to the Standard adapter instead of implementing an if condition in every single adapter.

@linrock
Copy link
Contributor Author

linrock commented Aug 11, 2013

What about updating lookup in the Base adapter?

def lookup(string)
  buffer_start do |buffer|
    request(options[:host] ? string : formatted_string(string))
    Whois::Record.new(self, buffer)
  end
end

With formatted_string returning string by default, but defined for adapters that need a different format - i.e. "=#{string}" in the case of Verisign. That way, the referral logic for each adapter can still be used.

@linrock
Copy link
Contributor Author

linrock commented Aug 11, 2013

Nevermind, that was a bad idea. You're right - it'd be better to just fall back to Standard if the custom hostname doesn't match the guessed server. That would handle the referrals too.

@linrock linrock closed this Aug 11, 2013
@linrock
Copy link
Contributor Author

linrock commented Aug 11, 2013

Here's a general solution using the Standard adapter. Hopefully this is on the right track.

@linrock linrock reopened this Aug 11, 2013
@weppos
Copy link
Owner

weppos commented Aug 28, 2013

There are no tests attached to this patch, but I believe because this is a work-in-progress prototype.

I'm not a big fan of this implementation. It has some drawbacks.

  1. If you pass an host along with an unsupported TLD, it will fail. For example

    ruby-whois google.va -h whois.holygrail.va
    
  2. It will fail if the object is not recognized. For example, if you try to pass a formatted query.

I have to think a little bit about a possible solution. In my opinion, a possible approach would be to change the .guess method itself to return a standard adapter whenever an host is passed. But this is just an hypothesis.

The best approach is probably to write some test cases and use TDD to satisfy the requirements.

@weppos
Copy link
Owner

weppos commented Nov 30, 2015

I'm closing this for now, as I'm not really convinced it's the best approach. The first step, in any case, is to fix #440 and #245

@weppos weppos closed this Nov 30, 2015
@weppos weppos self-assigned this Nov 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Format is preserved even if an hostname is passed
2 participants