Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the client's IP address in Roda?

Tags:

I'm using Roda, and I need to get the client's IP address from the http request. In Sinatra, I think this would be:

request.ip

Is there an equivalent method in Roda?

like image 943
cksk Avatar asked Mar 18 '16 20:03

cksk


People also ask

How do I find the IP address of my client?

After the client establishes a successful connection to the server, the IP address of the client will be printed on the server console.

How do I find the client IP address in node JS?

The easiest way to find your IP address in Node. js is to pull the client IP address from the incoming HTTP request object. If you are running Express in your Node app, this is very easy to do. Access the socket field of the Express request object, and then look up the remoteAddress property of that field.


1 Answers

That exact code should work in Roda. It's not mentioned explicitly in Roda's documentation, but Roda::RodaRequest is a subclass of Rack::Request, and Rack::Request#ip returns the client's IP.

like image 70
Jeremy Evans Avatar answered Oct 12 '22 09:10

Jeremy Evans