[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

How to get the Client IP address with webrick

Sal Syed

9/9/2007 7:24:00 PM

I need to ensure that the user who has sent the request is the localhost
... what's the best way to do this?
--
Posted via http://www.ruby-....

1 Answer

Shai Rosenfeld

9/10/2007 1:31:00 PM

0

Sal Syed wrote:
> I need to ensure that the user who has sent the request is the localhost
> ... what's the best way to do this?

... i don't know how to do this via webrick, but u find out the
remote_ip that required the request in the app code simply so:
request.remote_ip

so u could do something like

class SomeController

before_filter :block_localhosts

def action1
end

def action2
end

def block_localhosts
if request.remote_ip=~/127\.0\.0\.1/
return false
end
end

end

in the example above, all requests coming from 127.0.0.1 won't be
rendered.
hth :)

--
Posted via http://www.ruby-....