Created
December 25, 2014 14:36
-
-
Save lcat/bfd570d3aa5ba3eebc76 to your computer and use it in GitHub Desktop.
node get ip
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ipAddr = req.headers["x-forwarded-for"]; | |
if (ipAddr){ | |
var list = ipAddr.split(","); | |
ipAddr = list[list.length-1]; | |
} else { | |
ipAddr = req.connection.remoteAddress; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment