whois
whois copied to clipboard
Whois::Server::Adapters::Base.query_handler= no longer working
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?
That was not intentional.
Can you provide some more hint on how you use it and what's happening? Which version specifically broke it?
It looks like it happened between 3.6.5 and 4.0.1 and I'm using it like this:
class MyHandler
def self.call(query, *args)
# cose in here doesn't execute on lookup anymore
end
end
Whois::Server::Adapters::Base.query_handler = MyHandler
On Mon, Jul 17, 2017 at 4:36 PM, Simone Carletti [email protected] wrote:
That was not intentional.
Can you provide some more hint on how you use it and what's happening? Which version specifically broke it?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/weppos/whois/issues/558#issuecomment-315696227, or mute the thread https://github.com/notifications/unsubscribe-auth/AA1afM9uo11rCfsF8FRe-Sny0wXIN_Zlks5sOx0WgaJpZM4OZdch .
OK, thanks. I'll take a look.
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?
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?