Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getip(req) {
- var headerip = req.headers ? getheaderip(req) : 'unknown'
- if (headerip.length > 15) {headerip = headerip.match(/\d+\.\d+\.\d+\.\d/g)[0]}
- return headerip
- function getheaderip(req) {
- return req.headers['x-forwarded-for']
- ? req.headers['x-forwarded-for']
- : (req.connection && req.connection.remoteAddress)
- ? req.connection.remoteAddress
- : (req.connection.socket && req.connection.socket.remoteAddress)
- ? req.connection.socket.remoteAddress
- : (req.socket && req.socket.remoteAddress)
- ? req.socket.remoteAddress
- : '0.0.0.0';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement