From e6612f610c4b8a04663e95bc23e4b5e7ae255831 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 8 Feb 2019 04:26:43 +0900 Subject: Implement instance blocking (#4182) * Implement instance blocking * Add missing text * Delete unnecessary file * Covert Punycode to Unicode --- src/queue/processors/http/process-inbox.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/queue/processors') diff --git a/src/queue/processors/http/process-inbox.ts b/src/queue/processors/http/process-inbox.ts index d88f00a098..583e255136 100644 --- a/src/queue/processors/http/process-inbox.ts +++ b/src/queue/processors/http/process-inbox.ts @@ -45,6 +45,15 @@ export default async (job: bq.Job, done: any): Promise => { return; } + // ブロックしてたら中断 + // TODO: いちいちデータベースにアクセスするのはコスト高そうなのでどっかにキャッシュしておく + const instance = await Instance.findOne({ host: host.toLowerCase() }); + if (instance && instance.isBlocked) { + logger.warn(`Blocked request: ${host}`); + done(); + return; + } + user = await User.findOne({ usernameLower: username, host: host.toLowerCase() }) as IRemoteUser; } else { // アクティビティ内のホストの検証 @@ -57,6 +66,15 @@ export default async (job: bq.Job, done: any): Promise => { return; } + // ブロックしてたら中断 + // TODO: いちいちデータベースにアクセスするのはコスト高そうなのでどっかにキャッシュしておく + const instance = await Instance.findOne({ host: host.toLowerCase() }); + if (instance && instance.isBlocked) { + logger.warn(`Blocked request: ${host}`); + done(); + return; + } + user = await User.findOne({ host: { $ne: null }, 'publicKey.id': signature.keyId -- cgit v1.2.3-freya