From: 520079130762-0001@... (Michael Neumann) Date: 2002-10-24T01:24:51+09:00 Subject: Re: XMLRPC and IP authentication On Wed, 2002-10-23 at 18:15, Daniel Berger wrote: > Michael Neumann wrote: > > > > > > > I've added a ip_auth_handler method in class Server, which is called > > from method serve (in httpserver.rb) before request_handler is called. > > This method should return true if the client is allowed to connect, > > otherwise false. > > This way, you can simply override Server#ip_auth_handler to perform > > IP-based restrictions. > > > > What's the right status code when IP auth disallows access? > > 405 - Method not allowed? > > > > Regards, > > > > Michael > > Sounds interesting, but how does it work? > > All I really want to do is something like this: > > valid_ip = ["1.2.3.4","22.33.44.55"] > server.set_service_hook{ |obj,*args| > raise SomeException unless valid_ip.include?(server.peer_addr) > obj.call(*args) > } In xmlrpc4r version 1.7.12, the following should work: class MyServer < XMLRPC::Server def ip_auth_handler(io) valid_ips = ["192.168.1.5", "127.0.0.1"] if valid_ips.include? io.peeraddr[3] true else false end end end s = MyServer.new(....) Maybe I add in the next version a method set_valid_ip to the Server class, and use the above shown ip_auth_handler by default. Regards, Michael