Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
"rebrowser-playwright": "1.52.0",
"socks-proxy-agent": "^8.0.5",
"ts-node": "^10.9.2",
"ws": "^8.18.3"
"ws": "^8.18.3",
"express-rate-limit": "^8.2.1"
}
}
10 changes: 8 additions & 2 deletions src/dashboard/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import fs from 'fs'
import { createServer } from 'http'
import path from 'path'
import { WebSocket, WebSocketServer } from 'ws'
import rateLimit from 'express-rate-limit'
import { log as botLog } from '../util/notifications/Logger'
import { apiRouter } from './routes'
import { DashboardLog, dashboardState } from './state'
Expand All @@ -20,7 +21,12 @@ export class DashboardServer {
private server: ReturnType<typeof createServer>
private wss: WebSocketServer
private clients: Set<WebSocket> = new Set()

private dashboardLimiter = rateLimit({
windowMs: 15 * 60 * 1000, // 15 minutes
max: 100, // limit each IP to 100 requests per windowMs for dashboard UI
standardHeaders: true,
legacyHeaders: false,
})
constructor() {
this.app = express()
this.server = createServer(this.app)
Expand Down Expand Up @@ -69,7 +75,7 @@ export class DashboardServer {
})

// Serve dashboard UI
this.app.get('/', (_req, res) => {
this.app.get('/', this.dashboardLimiter, (_req, res) => {
const indexPath = path.join(__dirname, '../../public/index.html')

// Force no cache on HTML files
Expand Down
Loading