mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-18 13:35:42 +09:00
fix(api): mask Tor blocks as administrator IP bans (#2023)
This commit is contained in:
1 parent
14a935db81
commit
cf1a7d7a8a
7 files changed
+6
-23
No files matched your search
@@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import {TorBlockedError} from '@fluxer/errors/src/domains/moderation/TorBlockedError';
|
||||
import {IpBannedError} from '@fluxer/errors/src/domains/moderation/IpBannedError';
|
||||
import {extractClientIp} from '@fluxer/ip_utils/src/ClientIp';
|
||||
import {createMiddleware} from 'hono/factory';
|
||||
import {Config} from '../Config';
|
||||
@@ -13,7 +13,10 @@ export const TorExitMiddleware = createMiddleware<HonoEnv>(async (ctx, next) =>
|
||||
clientIpHeaderName: Config.proxy.client_ip_header,
|
||||
});
|
||||
if (clientIp && torExitListCache.isTorExit(clientIp)) {
|
||||
throw new TorBlockedError();
|
||||
throw new IpBannedError({
|
||||
ipAddress: clientIp,
|
||||
kind: 'permanent',
|
||||
});
|
||||
}
|
||||
await next();
|
||||
});
|
||||
Reference in new issue
Block a user