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-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
How to get the Client IP address with webrick
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password