Skip to content

Commit

Permalink
Improved Error Handling
Browse files Browse the repository at this point in the history
  • Loading branch information
dkrutsko committed Nov 8, 2013
1 parent d5c7e44 commit 84d6f14
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,10 @@ function bouncer (min, max, free)

this.reset = function (req)
{
var address =
var address; try { address =
req.headers["x-forwarded-for"] || req.connection.remoteAddress ||
req.socket.remoteAddress || req.connection.socket.remoteAddress;
} catch (error) { }

// Remove the current address from block list
address && delete instance.addresses[address];
Expand All @@ -114,9 +115,10 @@ function bouncer (min, max, free)

this.block = function (req, res, next)
{
var address =
var address; try { address =
req.headers["x-forwarded-for"] || req.connection.remoteAddress ||
req.socket.remoteAddress || req.connection.socket.remoteAddress;
} catch (error) { }

// Allow any invalid or white-listed IP addresses
if (!address || instance.whitelist.indexOf (address) > -1)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name" : "express-bouncer",
"description" : "Express middleware for mitigating brute-force attacks",
"version" : "0.1.0",
"version" : "0.1.1",
"main" : "./index.js",
"license" : "ZLIB",

Expand Down

0 comments on commit 84d6f14

Please sign in to comment.