0.0.1 • Published 7 years ago

x-real-ip v0.0.1

Weekly downloads
4
License
ISC
Repository
github
Last release
7 years ago

node-request-ip

real client ip

what it can do

to use this, you can get the client real ip and then proxy ip list

future

support that you can configure whether use proxy server or not

such as an example

'use strict';

var express = require('express');

var reqIP = require('x-real-ip');

var app = express();

var options = {
	real: 'r',
	forward: 'f'
};

app.use(reqIP(options));

app.get('/ip', function (req, res, next) {
	console.log(req[options.real]);
	console.log(req[options.forward]);
});

app.listen(8080);

api

getXRealIP(req)

it will return the client real ip address

var ip = getXRealIP(req);
console.log(ip);   // ::ffff:192.168.3.3
getXForwardedFor(req)

it will return the proxy ip list

var ip = getXForwardedFor(req);
console.log(ip);   // ::ffff:192.168.3.3, ::ffff:192.168.3.7
mw(options)

as a middleware, it can get the both above

var reqIP = require('x-real-ip');
var options = { real: 'r', forward: 'f'};
app.get('/ip', reqIP (options), function(req, res, next) {
    req[options.real];  // 
    req[options.forward]; //
});

options: attached to req[key]

  1. real: real ip ,default clientIP.

  2. forward: proxy ip list, default forwardedIPList

  3. wait...