All-In-One Anti-DDoS & Rate Limiting Shield for Node.js (Zero Dependencies)
디도스, 광클, API 남용을 한 방에 차단하는 초경량 종합 방어 패키지.
- 🛡️ Rate Limiting: Sets max request limits per IP within a custom time window.
- 🔨 Auto IP Banning: Automatically bans malicious IPs after repeated limit breaches.
- 🧹 Memory Safe: Built-in auto garbage collection to prevent memory leaks during heavy DDoS traffic.
- 🔌 Universal Middleware: Seamlessly integrates with Express, Fastify, Next.js, or Native HTTP.
- 🎈 Zero Dependencies: 100% Native Node.js ESM.
npm install lllshield
"type": "module" in package.json).
import express from 'express';
import { LllShield } from 'lllshield';
const app = express();
// Allow 100 requests per minute.
// If an IP breaches the limit 3 times, ban it for 5 minutes.
const shield = new LllShield({
windowMs: 60000, // 1 min
maxRequests: 100, // Max requests per window
banThreshold: 3, // 3 breaches = BAN
banDuration: 300000 // 5 mins ban
});
app.use(shield.middleware());
app.get('/api/data', (req, res) => {
res.send('Safe and Protected Data!');
});
app.listen(3000);Express 없이 직접 IP 검사만 수행하여 차단할 수도 있습니다.
import { LllShield } from 'lllshield';
const shield = new LllShield({ maxRequests: 50 });
// HTTP 요청 또는 웹소켓 IP 전달
const result = shield.check('192.168.0.1');
if (!result.allowed) {
console.log(`차단 원인: ${result.reason}`);
console.log(`재시도 대기시간: ${result.retryAfter}초`);
} else {
console.log(`남은 요청 횟수: ${result.remaining}`);
}