@glints/hapi-real-ip-plugin
Advanced tools
Comparing version 3.0.1 to 4.0.0
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.RealIPPlugin = void 0; | ||
var RealIPPlugin_1 = require("./RealIPPlugin"); | ||
exports.RealIPPlugin = RealIPPlugin_1.default; | ||
Object.defineProperty(exports, "RealIPPlugin", { enumerable: true, get: function () { return RealIPPlugin_1.default; } }); | ||
//# sourceMappingURL=index.js.map |
@@ -5,3 +5,14 @@ import * as Hapi from '@hapi/hapi'; | ||
} | ||
export interface RealIPPluginState { | ||
ip?: string; | ||
} | ||
declare module '@hapi/hapi' { | ||
interface PluginsListRegistered { | ||
RealIPPlugin: PluginRegistered; | ||
} | ||
interface PluginsStates { | ||
RealIPPlugin: RealIPPluginState; | ||
} | ||
} | ||
declare const RealIPPlugin: Hapi.Plugin<RealIPPluginOptions> & Hapi.PluginNameVersion; | ||
export default RealIPPlugin; |
@@ -7,2 +7,5 @@ "use strict"; | ||
server.ext('onRequest', async (request, h) => { | ||
request.plugins.RealIPPlugin = { | ||
ip: request.info.remoteAddress, | ||
}; | ||
const xffHeader = request.headers['x-forwarded-for']; | ||
@@ -18,3 +21,3 @@ if (!xffHeader) { | ||
if (downstreamNodes.length === options.numProxies) { | ||
request.info.remoteAddress = downstreamNodes[0]; | ||
request.plugins.RealIPPlugin.ip = downstreamNodes[0]; | ||
} | ||
@@ -21,0 +24,0 @@ return h.continue; |
{ | ||
"name": "@glints/hapi-real-ip-plugin", | ||
"version": "3.0.1", | ||
"version": "4.0.0", | ||
"description": "A plugin that attempts to determine the real IP of the client.", | ||
@@ -14,21 +14,21 @@ "main": "./dist/index.js", | ||
"clean": "rm -r dist/", | ||
"tslint": "tslint --project .", | ||
"test": "mocha --require ts-node/register/type-check --recursive \"src/**/*.spec.ts\"" | ||
"eslint": "eslint .", | ||
"test": "jest" | ||
}, | ||
"engines": { | ||
"node": ">= 10" | ||
"node": ">= 12" | ||
}, | ||
"devDependencies": { | ||
"@glints/tslint-rules": "^1.0.6", | ||
"@hapi/hapi": "^18.4.0", | ||
"@types/chai": "^4.2.4", | ||
"@types/hapi__hapi": "^18.2.6", | ||
"@types/mocha": "^5.2.7", | ||
"@types/sinon": "^7.5.0", | ||
"chai": "^4.2.0", | ||
"mocha": "^6.2.2", | ||
"sinon": "^7.5.0", | ||
"ts-node": "^8.4.1", | ||
"tslint": "^5.20.1", | ||
"typescript": "^3.7.2" | ||
"@hapi/hapi": "^20.2.2", | ||
"@types/hapi__hapi": "^20.0.10", | ||
"@types/jest": "^27.5.1", | ||
"@types/node": "^12.20.52", | ||
"@typescript-eslint/eslint-plugin": "^5.25.0", | ||
"@typescript-eslint/parser": "^5.25.0", | ||
"eslint": "^8.16.0", | ||
"eslint-plugin-jest": "^26.2.2", | ||
"jest": "^28.1.0", | ||
"ts-jest": "^28.0.2", | ||
"ts-node": "^10.8.0", | ||
"typescript": "^4.6.4" | ||
}, | ||
@@ -35,0 +35,0 @@ "peerDependencies": {}, |
@@ -5,3 +5,3 @@ # real-ip-plugin [![npm version](https://badge.fury.io/js/%40glints%2Fhapi-real-ip-plugin.svg)](https://badge.fury.io/js/%40glints%2Fhapi-real-ip-plugin) [![Greenkeeper badge](https://badges.greenkeeper.io/glints-dev/hapi-real-ip-plugin.svg)](https://greenkeeper.io/) | ||
any downstream proxies are present. The resolved addresses are stored in | ||
`request.info.remoteAddress`. | ||
`request.plugins.RealIPPlugin.ip`. | ||
@@ -8,0 +8,0 @@ # Usage Instructions |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
6960
11
56