feat: add QR code generation support and rate limiting for known device probes

This commit is contained in:
shuaiplus
2026-02-27 22:07:37 +08:00
committed by Shuai
parent 829008db7f
commit 172f6626c0
8 changed files with 81 additions and 5 deletions
+7
View File
@@ -235,6 +235,13 @@ export async function handleRequest(request: Request, env: Env): Promise<Respons
// Known device check (no auth required)
if (path === '/api/devices/knowndevice' && method === 'GET') {
const rateLimit = new RateLimitService(env.DB);
const clientIp = getClientIdentifier(request);
const probeLimit = await rateLimit.consumeKnownDeviceProbeBudget(clientIp + ':known-device');
if (!probeLimit.allowed) {
// Keep compatibility simple: do not error, just answer "unknown device".
return jsonResponse(false);
}
return handleKnownDevice(request, env);
}