[Pkg-javascript-commits] [node-proxy-addr] 01/10: Imported Upstream version 1.0.3

Leo Iannacone l3on-guest at moszumanska.debian.org
Sun Oct 12 00:34:51 UTC 2014


This is an automated email from the git hooks/post-receive script.

l3on-guest pushed a commit to branch master
in repository node-proxy-addr.

commit de3436072df54f43099f217193e897564b6116d4
Author: Leo Iannacone <l3on at ubuntu.com>
Date:   Sun Oct 12 02:03:43 2014 +0200

    Imported Upstream version 1.0.3
---
 .npmignore               |  4 ----
 .travis.yml              |  8 ++++++--
 History.md => HISTORY.md | 12 ++++++++++++
 README.md                | 19 ++++++++++++++++---
 index.js                 | 22 +++++++---------------
 package.json             | 31 ++++++++++++++++---------------
 test/test.js             |  1 +
 7 files changed, 58 insertions(+), 39 deletions(-)

diff --git a/.npmignore b/.npmignore
deleted file mode 100644
index 85c82a5..0000000
--- a/.npmignore
+++ /dev/null
@@ -1,4 +0,0 @@
-benchmark/
-coverage/
-test/
-.travis.yml
diff --git a/.travis.yml b/.travis.yml
index 1ff243c..f034de0 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,5 +1,6 @@
 language: node_js
 node_js:
+  - "0.6"
   - "0.8"
   - "0.10"
   - "0.11"
@@ -7,5 +8,8 @@ matrix:
   allow_failures:
     - node_js: "0.11"
   fast_finish: true
-script: "npm run-script test-travis"
-after_script: "npm install coveralls at 2.10.0 && cat ./coverage/lcov.info | coveralls"
+script:
+  - "test $TRAVIS_NODE_VERSION != '0.6' || npm test"
+  - "test $TRAVIS_NODE_VERSION  = '0.6' || npm run-script test-travis"
+after_script:
+  - "test $TRAVIS_NODE_VERSION = '0.10' && npm install coveralls at 2 && cat ./coverage/lcov.info | coveralls"
diff --git a/History.md b/HISTORY.md
similarity index 72%
rename from History.md
rename to HISTORY.md
index 61a0d50..c0ff10e 100644
--- a/History.md
+++ b/HISTORY.md
@@ -1,3 +1,15 @@
+1.0.3 / 2014-09-21
+==================
+
+  * Use `forwarded` npm module
+
+1.0.2 / 2014-09-18
+==================
+
+  * Fix a global leak when multiple subnets are trusted
+  * Support Node.js 0.6
+  * deps: ipaddr.js at 0.1.3
+
 1.0.1 / 2014-06-03
 ==================
 
diff --git a/README.md b/README.md
index 4fe57d3..57ec4cd 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,10 @@
 # proxy-addr
 
-[![NPM version](https://badge.fury.io/js/proxy-addr.svg)](http://badge.fury.io/js/proxy-addr)
-[![Build Status](https://travis-ci.org/expressjs/proxy-addr.svg?branch=master)](https://travis-ci.org/expressjs/proxy-addr)
-[![Coverage Status](https://img.shields.io/coveralls/expressjs/proxy-addr.svg?branch=master)](https://coveralls.io/r/expressjs/proxy-addr)
+[![NPM Version][npm-image]][npm-url]
+[![NPM Downloads][downloads-image]][downloads-url]
+[![Node.js Version][node-version-image]][node-version-url]
+[![Build Status][travis-image]][travis-url]
+[![Test Coverage][coveralls-image]][coveralls-url]
 
 Determine address of proxied request
 
@@ -122,3 +124,14 @@ $ npm run-script bench
 ## License
 
 [MIT](LICENSE)
+
+[npm-image]: https://img.shields.io/npm/v/proxy-addr.svg?style=flat
+[npm-url]: https://npmjs.org/package/proxy-addr
+[node-version-image]: https://img.shields.io/node/v/proxy-addr.svg?style=flat
+[node-version-url]: http://nodejs.org/download/
+[travis-image]: https://img.shields.io/travis/jshttp/proxy-addr.svg?style=flat
+[travis-url]: https://travis-ci.org/jshttp/proxy-addr
+[coveralls-image]: https://img.shields.io/coveralls/jshttp/proxy-addr.svg?style=flat
+[coveralls-url]: https://coveralls.io/r/jshttp/proxy-addr?branch=master
+[downloads-image]: https://img.shields.io/npm/dm/proxy-addr.svg?style=flat
+[downloads-url]: https://npmjs.org/package/proxy-addr
diff --git a/index.js b/index.js
index 75ee432..d739513 100644
--- a/index.js
+++ b/index.js
@@ -16,6 +16,7 @@ module.exports.compile = compile;
  * Module dependencies.
  */
 
+var forwarded = require('forwarded');
 var ipaddr = require('ipaddr.js');
 
 /**
@@ -46,16 +47,8 @@ var ipranges = {
  */
 
 function alladdrs(req, trust) {
-  if (!req) {
-    throw new TypeError('req argument is required');
-  }
-
-  var proxyAddrs = (req.headers['x-forwarded-for'] || '')
-    .split(/ *, */)
-    .filter(Boolean)
-    .reverse();
-  var socketAddr = req.connection.remoteAddress;
-  var addrs = [socketAddr].concat(proxyAddrs);
+  // get addresses
+  var addrs = forwarded(req);
 
   if (!trust) {
     // Return all addresses
@@ -170,9 +163,9 @@ function parseipNotation(note) {
   ip = parseip(ip);
 
   kind = ip.kind();
-  max = kind === 'ipv4' ? 32
-    : kind === 'ipv6' ? 128
-    : 0;
+  max = kind === 'ipv6'
+    ? 128
+    : 32;
 
   range = pos !== -1
     ? note.substring(pos + 1, note.length)
@@ -222,8 +215,6 @@ function parseNetmask(netmask) {
       parts = ip.parts;
       size = 16;
       break;
-    default:
-      throw new TypeError('unknown netmask');
   }
 
   var max = Math.pow(2, size) - 1;
@@ -299,6 +290,7 @@ function trustMulti(subnets) {
     var subnet;
     var subnetip;
     var subnetkind;
+    var subnetrange;
     var trusted;
 
     for (var i = 0; i < subnets.length; i++) {
diff --git a/package.json b/package.json
index 2f6bcaa..b558f65 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
 {
   "name": "proxy-addr",
   "description": "Determine address of proxied request",
-  "version": "1.0.1",
+  "version": "1.0.3",
   "author": "Douglas Christopher Wilson <doug at somethingdoug.com>",
   "license": "MIT",
   "keywords": [
@@ -9,30 +9,31 @@
     "proxy",
     "x-forwarded-for"
   ],
-  "repository": {
-    "type": "git",
-    "url": "https://github.com/expressjs/proxy-addr.git"
-  },
-  "bugs": {
-    "url": "https://github.com/expressjs/proxy-addr/issues"
-  },
+  "repository": "jshttp/proxy-addr",
   "dependencies": {
-    "ipaddr.js": "0.1.2"
+    "forwarded": "~0.1.0",
+    "ipaddr.js": "0.1.3"
   },
   "devDependencies": {
     "benchmark": "1.0.0",
     "beautify-benchmark": "0.2.4",
-    "istanbul": "0.2.10",
-    "mocha": "~1.20.0",
+    "istanbul": "0.3.2",
+    "mocha": "~1.21.4",
     "should": "~4.0.0"
   },
+  "files": [
+    "LICENSE",
+    "HISTORY.md",
+    "README.md",
+    "index.js"
+  ],
   "engines": {
-    "node": ">= 0.8.0"
+    "node": ">= 0.6"
   },
   "scripts": {
     "bench": "node benchmark/index.js",
-    "test": "mocha --reporter dot test/",
-    "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot test/",
-    "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec test/"
+    "test": "mocha --reporter spec --bail --check-leaks test/",
+    "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/",
+    "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/"
   }
 }
diff --git a/test/test.js b/test/test.js
index 1b05b90..ade5516 100644
--- a/test/test.js
+++ b/test/test.js
@@ -69,6 +69,7 @@ describe('proxyaddr(req, trust)', function () {
 
       it('should reject bad CIDR', function () {
         var req = createReq('127.0.0.1');
+        proxyaddr.bind(null, req, '10.0.0.1/internet').should.throw(/invalid range on address/);
         proxyaddr.bind(null, req, '10.0.0.1/6000').should.throw(/invalid range on address/);
         proxyaddr.bind(null, req, '::1/6000').should.throw(/invalid range on address/);
         proxyaddr.bind(null, req, '::ffff:a00:2/136').should.throw(/invalid range on address/);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-proxy-addr.git



More information about the Pkg-javascript-commits mailing list