From cd13046c827c24a6815fa9c474438f7017349376 Mon Sep 17 00:00:00 2001 From: tamaina Date: Fri, 6 Jan 2023 14:03:36 +0000 Subject: [PATCH] set maxRedirections (default 3, ApRequest/ApResolver: 0) --- packages/backend/src/core/HttpRequestService.ts | 1 + packages/backend/src/core/activitypub/ApRequestService.ts | 4 +++- packages/backend/src/core/activitypub/ApResolverService.ts | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/backend/src/core/HttpRequestService.ts b/packages/backend/src/core/HttpRequestService.ts index 6787dab907..632e8f98ae 100644 --- a/packages/backend/src/core/HttpRequestService.ts +++ b/packages/backend/src/core/HttpRequestService.ts @@ -211,6 +211,7 @@ export class HttpRequestService { bodyTimeout: 10 * 1000, maxHeaderSize: 16364, // default maxResponseSize: 10 * 1024 * 1024, + maxRedirections: 3, connect: { timeout: 10 * 1000, // コネクションが確立するまでのタイムアウト maxCachedSessions: 300, // TLSセッションのキャッシュ数 https://github.com/nodejs/undici/blob/v5.14.0/lib/core/connect.js#L80 diff --git a/packages/backend/src/core/activitypub/ApRequestService.ts b/packages/backend/src/core/activitypub/ApRequestService.ts index fe487e8fd6..c686a7bfd8 100644 --- a/packages/backend/src/core/activitypub/ApRequestService.ts +++ b/packages/backend/src/core/activitypub/ApRequestService.ts @@ -37,7 +37,9 @@ export class ApRequestService { private userKeypairStoreService: UserKeypairStoreService, private httpRequestService: HttpRequestService, ) { - this.undiciFetcher = new UndiciFetcher(this.httpRequestService.getStandardUndiciFetcherOption()); + this.undiciFetcher = new UndiciFetcher(this.httpRequestService.getStandardUndiciFetcherOption({ + maxRedirections: 0, + })); } @bindThis diff --git a/packages/backend/src/core/activitypub/ApResolverService.ts b/packages/backend/src/core/activitypub/ApResolverService.ts index 94c053473e..2f8c97d375 100644 --- a/packages/backend/src/core/activitypub/ApResolverService.ts +++ b/packages/backend/src/core/activitypub/ApResolverService.ts @@ -35,7 +35,9 @@ export class Resolver { private recursionLimit = 100, ) { this.history = new Set(); - this.undiciFetcher = new UndiciFetcher(this.httpRequestService.getStandardUndiciFetcherOption()); + this.undiciFetcher = new UndiciFetcher(this.httpRequestService.getStandardUndiciFetcherOption({ + maxRedirections: 0, + })); } @bindThis