Previously Chris AtLee wrote: > > On Thu, Jul 3, 2008 at 1:04 PM, kevin <[EMAIL PROTECTED]> wrote: > > > > hello, > > > > hope all is well. > > > > i'm wondering what the best way to get a user's IP address is? > > because the reCaptcha verification wants the remote IP. > > > > I know I can get request.host and socket.gethostbyname can resolve > > host to IP. > > > > but i'm looking for something else first, maybe a Pylons/WSGI field > > for IP, because resolution is relatively expensive at scale. > > > > thanks, > > kevin > > request.environ['REMOTE_ADDR'] does it for me
Possibly better: request.environ.get("X_FORWARDED_FOR", request.environ["REMOTE_ADDR"]) that handles requests coming in from a proxy server as well. You may want add some extra checking to see if REMOTE_ADDR really is a proxy server before trusting the X-Forwarded-For header. Wichert. -- Wichert Akkerman <[EMAIL PROTECTED]> It is simple to make things. http://www.wiggy.net/ It is hard to make things simple. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~----------~----~----~----~------~----~------~--~---