Skip to content

Commit

Permalink
update docs and features list
Browse files Browse the repository at this point in the history
  • Loading branch information
tunnckoCore committed May 24, 2015
1 parent 5495ca7 commit 80b8047
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
24 changes: 13 additions & 11 deletions README.md
Expand Up @@ -15,24 +15,26 @@ npm test


## Features
- blacklist and whitelist through options
- black and white lists to be glob pattern, regex, string, array or function
- different identifier than IP (defaults to `this.ip`) through `opts.id`
- `opts.forbidden` for custom message when `403 Forbidden`
- custom message when `403 Forbidden` response, through `opts.forbidden`
- custom identifier different than default `this.ip`, through `opts.id`
+ you may want to add `opts.strict: false` if it's not IP
- filter IP using glob patterns, regexp, string, array or function
- blacklist with negative glob patterns, whitelist with positive
- would restrict all to `403 Forbidden` that not match to filter


## Usage
> For more use-cases see the [tests](./test.js)
### [koaIpFilter](./index#L25)
### [koaIpFilter](./index.js#L26)
> Filtering incoming request with glob patterns array, regexp, string or matcher function
- `[options]` **{Object}**
+ `[id]` **{Function}** custom identifier, defaults to `this.ip`
+ `[blacklist]` **{Array|String|RegExp|Function}** blacklist filter
+ `[whitelist]` **{Array|String|RegExp|Function}** whitelist filter
+ `[forbidden]` **{String|Function}** message to display when 403 forbidden
- `return` **{GeneratorFunction}**
- `options` **{Object}**
+ `id` **{Function}** custom identifier, defaults to `this.ip`
+ `strict` **{Boolean}** to throw when not valid IPv4/IPv6? default `true`
+ `filter` **{Array|String|RegExp|Function}** filter
+ `forbidden` **{String|Function}** custom message when `403 Forbidden` response
- `returns` **{GeneratorFunction}**

**example.js**

Expand Down
5 changes: 3 additions & 2 deletions index.js
Expand Up @@ -13,11 +13,12 @@ var ipFilter = require('ip-filter')
* > Filtering incoming request with glob patterns
* array, regexp, string or matcher function
*
* @name koaIpFilter
* @param {Object} `options`
* @option {Function} [options] `id` custom identifier, defaults to `this.ip`
* @option {Boolean} [options] `strict` to throw when not valid ip? default `true`
* @option {Boolean} [options] `strict` to throw when not valid IPv4/IPv6? default `true`
* @option {Array|String|RegExp|Function} [options] `filter` black/white list filter
* @option {String|Function} [options] `forbidden` message to display when 403 forbidden
* @option {String|Function} [options] `forbidden` custom message when `403 Forbidden` response
* @return {GeneratorFunction}
* @api public
*/
Expand Down

0 comments on commit 80b8047

Please sign in to comment.