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

Whois::Server::Adapters::Base.query_handler= no longer working #558

Open
ghost opened this issue Jul 17, 2017 · 5 comments
Open

Whois::Server::Adapters::Base.query_handler= no longer working #558

ghost opened this issue Jul 17, 2017 · 5 comments
Labels

Comments

@ghost
Copy link

ghost commented Jul 17, 2017

I used to be able to hook into that to do some custom stuff but it doesn't do anything anymore.

Is there any way to bring this back?

@weppos
Copy link
Owner

weppos commented Jul 17, 2017

That was not intentional.

Can you provide some more hint on how you use it and what's happening? Which version specifically broke it?

@ghost
Copy link
Author

ghost commented Jul 17, 2017 via email

@weppos
Copy link
Owner

weppos commented Jul 17, 2017

OK, thanks. I'll take a look.

@weppos weppos added the bug label Jul 17, 2017
@crondaemon
Copy link

Hello. I hit this bug report and I had the chance to look into the code. Unless I'm mistaken the problem is that in a class method, a instance variable has been used. Then the fix is

def query_handler
  -@query_handler ||= SocketHandler.new
  +@@query_handler ||= SocketHandler.new
end

def query_handler=(handler)
  -@query_handler = handler
  +@@query_handler = handler
end

With this patch I can use the code

class MyHandler
  def self.call(query, *args)
    pp "CALLED #{query} #{args}"
  end
end

Whois::Server::Adapters::Base.query_handler = MyHandler

Can you confirm the patch is working for you? Any chance it can be fixed?

@crondaemon
Copy link

I also found a temporary solution that fixes the use of custom query handlers:

    Whois::Server::Adapters::Base.query_handler =
      Whois::Server::Adapters::Afilias.query_handler =
      Whois::Server::Adapters::Arin.query_handler =
      Whois::Server::Adapters::Arpa.query_handler =
      Whois::Server::Adapters::Formatted.query_handler =
      Whois::Server::Adapters::None.query_handler =
      Whois::Server::Adapters::Standard.query_handler =
      Whois::Server::Adapters::Verisign.query_handler =
      Whois::Server::Adapters::Web.query_handler =
        MyWhoisQueryHandler

Forcing the query handler on all adapters makes the things work. However this is not a fix but a workaround. The fix is to use a class variable, as pointed out above. Can you fix it yourself or do you prefer a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants