From 5984938b0186e7579c51c5867e74c842e5a26a2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=8A=E3=81=95=E3=82=80=E3=81=AE=E3=81=B2=E3=81=A8?= <46447427+samunohito@users.noreply.github.com> Date: Sat, 8 Feb 2025 11:27:14 +0900 Subject: [PATCH 1/4] pxory --- packages/backend/src/core/DownloadService.ts | 4 ++-- .../backend/src/core/HttpRequestService.ts | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/packages/backend/src/core/DownloadService.ts b/packages/backend/src/core/DownloadService.ts index 2e78e6d877..079ce17975 100644 --- a/packages/backend/src/core/DownloadService.ts +++ b/packages/backend/src/core/DownloadService.ts @@ -60,8 +60,8 @@ export class DownloadService { request: operationTimeout, // whole operation timeout }, agent: { - http: this.httpRequestService.httpAgent, - https: this.httpRequestService.httpsAgent, + http: this.httpRequestService.getAgentForHttp(urlObj), + https: this.httpRequestService.getAgentForHttps(urlObj), }, http2: false, // default retry: { diff --git a/packages/backend/src/core/HttpRequestService.ts b/packages/backend/src/core/HttpRequestService.ts index 083153940a..0b2677e008 100644 --- a/packages/backend/src/core/HttpRequestService.ts +++ b/packages/backend/src/core/HttpRequestService.ts @@ -214,6 +214,24 @@ export class HttpRequestService { } } + /** + * Get agent for http by URL + * @param url URL + */ + @bindThis + public getAgentForHttp(url: URL): http.Agent { + return (this.config.proxyBypassHosts ?? []).includes(url.hostname) ? this.http : this.httpAgent; + } + + /** + * Get agent for https by URL + * @param url URL + */ + @bindThis + public getAgentForHttps(url: URL): https.Agent { + return (this.config.proxyBypassHosts ?? []).includes(url.hostname) ? this.https : this.httpsAgent; + } + @bindThis public async getActivityJson(url: string, isLocalAddressAllowed = false): Promise { const res = await this.send(url, { From 5fe2283de7d3910f6d93212c4ec94bd3efd32731 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=8A=E3=81=95=E3=82=80=E3=81=AE=E3=81=B2=E3=81=A8?= <46447427+samunohito@users.noreply.github.com> Date: Sat, 8 Feb 2025 22:07:59 +0900 Subject: [PATCH 2/4] fix --- .../backend/src/core/HttpRequestService.ts | 37 +++++++++++++------ 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/packages/backend/src/core/HttpRequestService.ts b/packages/backend/src/core/HttpRequestService.ts index 0b2677e008..fe8faab0a4 100644 --- a/packages/backend/src/core/HttpRequestService.ts +++ b/packages/backend/src/core/HttpRequestService.ts @@ -115,32 +115,32 @@ export class HttpRequestService { /** * Get http non-proxy agent (without local address filtering) */ - private httpNative: http.Agent; + private readonly httpNative: http.Agent; /** * Get https non-proxy agent (without local address filtering) */ - private httpsNative: https.Agent; + private readonly httpsNative: https.Agent; /** * Get http non-proxy agent */ - private http: http.Agent; + private readonly http: http.Agent; /** * Get https non-proxy agent */ - private https: https.Agent; + private readonly https: https.Agent; /** * Get http proxy or non-proxy agent */ - public httpAgent: http.Agent; + public readonly httpAgent: http.Agent; /** * Get https proxy or non-proxy agent */ - public httpsAgent: https.Agent; + public readonly httpsAgent: https.Agent; constructor( @Inject(DI.config) @@ -197,7 +197,8 @@ export class HttpRequestService { /** * Get agent by URL * @param url URL - * @param bypassProxy Allways bypass proxy + * @param bypassProxy Always bypass proxy + * @param isLocalAddressAllowed */ @bindThis public getAgentByUrl(url: URL, bypassProxy = false, isLocalAddressAllowed = false): http.Agent | https.Agent { @@ -217,19 +218,33 @@ export class HttpRequestService { /** * Get agent for http by URL * @param url URL + * @param isLocalAddressAllowed */ @bindThis - public getAgentForHttp(url: URL): http.Agent { - return (this.config.proxyBypassHosts ?? []).includes(url.hostname) ? this.http : this.httpAgent; + public getAgentForHttp(url: URL, isLocalAddressAllowed = false): http.Agent { + if ((this.config.proxyBypassHosts ?? []).includes(url.hostname)) { + return isLocalAddressAllowed + ? this.httpNative + : this.http; + } else { + return this.httpAgent; + } } /** * Get agent for https by URL * @param url URL + * @param isLocalAddressAllowed */ @bindThis - public getAgentForHttps(url: URL): https.Agent { - return (this.config.proxyBypassHosts ?? []).includes(url.hostname) ? this.https : this.httpsAgent; + public getAgentForHttps(url: URL, isLocalAddressAllowed = false): https.Agent { + if ((this.config.proxyBypassHosts ?? []).includes(url.hostname)) { + return isLocalAddressAllowed + ? this.httpsNative + : this.https; + } else { + return this.httpsAgent; + } } @bindThis From 36cc152dd5d54c9cd98eb2da67a833f66549c1f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=8A=E3=81=95=E3=82=80=E3=81=AE=E3=81=B2=E3=81=A8?= <46447427+samunohito@users.noreply.github.com> Date: Sat, 8 Feb 2025 22:19:52 +0900 Subject: [PATCH 3/4] fix CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d17921700..a4ef0eb2e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ - ### Server -- +- Fix: HTTPプロキシとその除外設定を行った状態でカスタム絵文字の一括インポートをしたとき、除外設定が効かないのを修正( #8766 ) ## 2025.2.0 From 9cbc32e864dbf8639358b3ff9583c441ff9473a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=8A=E3=81=95=E3=82=80=E3=81=AE=E3=81=B2=E3=81=A8?= <46447427+samunohito@users.noreply.github.com> Date: Sat, 8 Feb 2025 22:23:05 +0900 Subject: [PATCH 4/4] allow localAddress --- packages/backend/src/core/DownloadService.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/backend/src/core/DownloadService.ts b/packages/backend/src/core/DownloadService.ts index 079ce17975..a2b74d1ab2 100644 --- a/packages/backend/src/core/DownloadService.ts +++ b/packages/backend/src/core/DownloadService.ts @@ -60,8 +60,8 @@ export class DownloadService { request: operationTimeout, // whole operation timeout }, agent: { - http: this.httpRequestService.getAgentForHttp(urlObj), - https: this.httpRequestService.getAgentForHttps(urlObj), + http: this.httpRequestService.getAgentForHttp(urlObj, true), + https: this.httpRequestService.getAgentForHttps(urlObj, true), }, http2: false, // default retry: {