A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.
fix(api): mask Tor blocks as administrator IP bans (#2023)
Hampuscf1a7d7a8af4
diff --git a/fluxer_admin/openapi-admin.json b/fluxer_admin/openapi-admin.jsonindex 51eeaedee..20fd585de 100644--- a/fluxer_admin/openapi-admin.json+++ b/fluxer_admin/openapi-admin.json@@ -9896,8 +9896,6 @@"GLOBAL_IP_BANNED","GLOBAL_IP_TEMPORARILY_BANNED","IP_BANNED",- "RESIDENTIAL_PROXY_BLOCKED",- "TOR_BLOCKED","MAX_ANIMATED_EMOJIS","MAX_APPLICATIONS","MAX_BOOKMARKS",diff --git a/fluxer_api/src/api/auth/tests/Registration.test.ts b/fluxer_api/src/api/auth/tests/Registration.test.tsindex 5a35f09ab..5e6e7746f 100644--- a/fluxer_api/src/api/auth/tests/Registration.test.ts+++ b/fluxer_api/src/api/auth/tests/Registration.test.ts@@ -311,7 +311,7 @@ describe('Auth registration', () => {date_of_birth: '2000-01-01',consent: true,})- .expect(403, 'TOR_BLOCKED')+ .expect(403, 'GLOBAL_IP_BANNED').execute();} finally {torExitListCache.clearForTesting();diff --git a/fluxer_api/src/api/middleware/TorExitMiddleware.ts b/fluxer_api/src/api/middleware/TorExitMiddleware.tsindex 732e10e84..ba57416b5 100644--- a/fluxer_api/src/api/middleware/TorExitMiddleware.ts+++ b/fluxer_api/src/api/middleware/TorExitMiddleware.ts@@ -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();});diff --git a/fluxer_api/src/api/openapi/openapi.json b/fluxer_api/src/api/openapi/openapi.jsonindex 66f718a9e..1291cd748 100644--- a/fluxer_api/src/api/openapi/openapi.json+++ b/fluxer_api/src/api/openapi/openapi.json@@ -25344,8 +25344,6 @@"GLOBAL_IP_BANNED","GLOBAL_IP_TEMPORARILY_BANNED","IP_BANNED",- "RESIDENTIAL_PROXY_BLOCKED",- "TOR_BLOCKED","MAX_ANIMATED_EMOJIS","MAX_APPLICATIONS","MAX_BOOKMARKS",@@ -25660,8 +25658,6 @@"Your IP address {ipAddress} has been permanently blocked from the Fluxer API by platform administrators. If you believe this is a mistake, contact [email protected] to appeal. Include this IP address in your appeal.","Your IP address {ipAddress} has been temporarily blocked from the Fluxer API for 24 hours because of abusive or unusual access patterns. We usually do not provide appeals for temporary API bans. Change IP addresses or wait for the ban to expire, and review the Fluxer API access patterns coming from your client.","Your IP address {ipAddress} has been permanently blocked from the Fluxer API by platform administrators. If you believe this is a mistake, contact [email protected] to appeal. Include this IP address in your appeal.",- "This user's IP is banned from this community.",- "This user's IP is banned from this community.","You've reached the maximum of {count, plural, one {# animated emoji} other {# animated emojis}}.","You've reached the maximum of {limit, plural, one {# application} other {# applications}}.","You've reached the maximum of {count, plural, one {# bookmark} other {# bookmarks}}.",diff --git a/packages/constants/src/ApiErrorCodes.ts b/packages/constants/src/ApiErrorCodes.tsindex 91b576afa..d9c4628d8 100644--- a/packages/constants/src/ApiErrorCodes.ts+++ b/packages/constants/src/ApiErrorCodes.ts@@ -159,8 +159,6 @@ export const APIErrorCodes = {GLOBAL_IP_BANNED: 'GLOBAL_IP_BANNED',GLOBAL_IP_TEMPORARILY_BANNED: 'GLOBAL_IP_TEMPORARILY_BANNED',IP_BANNED: 'IP_BANNED',- RESIDENTIAL_PROXY_BLOCKED: 'RESIDENTIAL_PROXY_BLOCKED',- TOR_BLOCKED: 'TOR_BLOCKED',MAX_ANIMATED_EMOJIS: 'MAX_ANIMATED_EMOJIS',MAX_APPLICATIONS: 'MAX_APPLICATIONS',MAX_BOOKMARKS: 'MAX_BOOKMARKS',diff --git a/packages/errors/src/domains/moderation/TorBlockedError.ts b/packages/errors/src/domains/moderation/TorBlockedError.tsdeleted file mode 100644index 3c0c3f091..000000000--- a/packages/errors/src/domains/moderation/TorBlockedError.ts+++ /dev/null@@ -1,10 +0,0 @@-// SPDX-License-Identifier: AGPL-3.0-or-later--import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes';-import {ForbiddenError} from '@fluxer/errors/src/domains/core/ForbiddenError';--export class TorBlockedError extends ForbiddenError {- constructor() {- super({code: APIErrorCodes.TOR_BLOCKED});- }-}diff --git a/packages/errors/src/i18n/ErrorCodeMappings.ts b/packages/errors/src/i18n/ErrorCodeMappings.tsindex 1ad3b248d..75b872e70 100644--- a/packages/errors/src/i18n/ErrorCodeMappings.ts+++ b/packages/errors/src/i18n/ErrorCodeMappings.ts@@ -208,8 +208,6 @@ export const ErrorCodeToI18nKey = {[APIErrorCodes.GLOBAL_IP_BANNED]: 'permissions.global_ip_banned',[APIErrorCodes.GLOBAL_IP_TEMPORARILY_BANNED]: 'permissions.global_ip_temporarily_banned',[APIErrorCodes.IP_BANNED]: 'permissions.global_ip_banned',- [APIErrorCodes.RESIDENTIAL_PROXY_BLOCKED]: 'permissions.user_ip_banned_from_guild',- [APIErrorCodes.TOR_BLOCKED]: 'permissions.user_ip_banned_from_guild',[APIErrorCodes.MAX_ANIMATED_EMOJIS]: 'invites_and_packs.max_animated_emojis_reached',[APIErrorCodes.MAX_APPLICATIONS]: 'misc_limits.max_applications_reached',[APIErrorCodes.MAX_BOOKMARKS]: 'misc_limits.max_bookmarks_reached',