1.0.1 • Published 8 years ago

remote-ip v1.0.1

Weekly downloads
6
License
ISC
Repository
github
Last release
8 years ago

remote-ip

A simple function for get the client ip on http request

#Get started

#Install:

npm install remote-ip

#Usage:

var getIp = require('remote-ip');

getIp(request); //ip address

#Example:

var http = require('http');

var getIp = require('remote-ip');

http.createServer(function(req,res){
    res.writeHead(200,{
        "content-type":"text/plain"
    });
    
    var ip = getIp(req); //your client ip
    console.log(ip);
    
    res.end();
}).listen(3000);

or on express

var getIp = require('remote-ip');

router.get('/',function(req,res,next){
    
    var ip = getIp(req); //your client ip
    console.log(ip);
    
});