New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

ipblock

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ipblock

Limit request times(ip).

latest
Source
npmnpm
Version
0.0.3
Version published
Maintainers
1
Created
Source

ipblock

koa middleware 限制ip访问次数

Installation

npm install ipblock	

Example

code


var koa = require("koa");
var app = koa(), ipblock = require("ipblock");

// block router
// test: 100000 ms / 10 times

ipblock(app, {method: "get", path:"/block", times: 10, range: 10000});
ipblock(app, {method: "post", path:"/block", times: 10, range: 10000});
ipblock(app, {method: "get", path:"/block/:id", times: 10, range: 10000});


app.use(function*(){

	this.body = "Hello World";
});

app.listen(4000);

Test

bash

	sh testes/test.sh

output

200
200
200
200
200
200
200
200
200
200
403

策略 (假设30s 限制10次访问

  • 时间节点A,开始访问
  • 则设A为cursor。开始计数,达到10次,则 开始触发block算法。
  • 如果当前时间戳 - A > 30s,则 A的节点往前移一位,且把当前时间戳压入栈。
  • 如果当前时间戳 - A < 30s,则 返回403,不做任何操作。

Keywords

limit

FAQs

Package last updated on 29 Jun 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts