Skip to content

Commit

Permalink
perf: improve req.ips performance
Browse files Browse the repository at this point in the history
closes #2723
  • Loading branch information
Ángel Sanz authored and dougwilson committed Feb 21, 2017
1 parent 906164b commit 485b6f8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions History.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ unreleased
* deps: [email protected]
- Fix array parsing from skipping empty values
- Fix compacting nested arrays
* perf: improve `req.ips` performance

4.14.1 / 2017-01-28
===================
Expand Down
7 changes: 6 additions & 1 deletion lib/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,12 @@ defineGetter(req, 'ip', function ip(){
defineGetter(req, 'ips', function ips() {
var trust = this.app.get('trust proxy fn');
var addrs = proxyaddr.all(this, trust);
return addrs.slice(1).reverse();

// reverse the order (to farthest -> closest)
// and remove socket address
addrs.reverse().pop()

return addrs
});

/**
Expand Down

0 comments on commit 485b6f8

Please sign in to comment.