mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-18 21:45:31 +09:00
feat(api): add IP ban exemptions (#1448)
This commit is contained in:
1 parent
311a1addce
commit
fb5fe38d52
12 files changed
+88
-1
No files matched your search
@@ -10,6 +10,7 @@ import {AdminRepository} from '../admin/AdminRepository';
|
||||
import {Config} from '../Config';
|
||||
import {IP_BAN_REFRESH_CHANNEL} from '../constants/IpBan';
|
||||
import {Logger} from '../Logger';
|
||||
import {isIpBanExempt} from '../risk/IpBanExemptions';
|
||||
import type {HonoEnv} from '../types/HonoEnv';
|
||||
import {parseJsonRecord} from '../utils/JsonBoundaryUtils';
|
||||
import {ipBanCache} from './IpBanMiddleware';
|
||||
@@ -118,6 +119,7 @@ function normalizeSignalIp(ip: string | null): AbuseSignalIp | null {
|
||||
const parsed = parseIpAddress(ip);
|
||||
if (!parsed) return null;
|
||||
if (!isPublicIpAddress(parsed.normalized)) return null;
|
||||
if (isIpBanExempt(parsed.normalized)) return null;
|
||||
const banKey = getSameIpDecisionKey(parsed.normalized) ?? parsed.normalized;
|
||||
return {banKey, lookupIp: parsed.normalized};
|
||||
}
|
||||
@@ -324,6 +326,9 @@ async function executeAutoBan(
|
||||
if (!isPublicIpAddress(ctx.lookupIp)) {
|
||||
return;
|
||||
}
|
||||
if (isIpBanExempt(ctx.lookupIp)) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await adminRepository.banIpTemp(key, AUTO_BAN_TTL_SECONDS);
|
||||
ipBanCache.banTemp(key, AUTO_BAN_TTL_SECONDS);
|
||||
|
||||
Reference in new issue
Block a user