summaryrefslogtreecommitdiff
path: root/packages/backend/src/core/HttpRequestService.ts
diff options
context:
space:
mode:
authorおさむのひと <46447427+samunohito@users.noreply.github.com>2025-02-26 10:48:38 +0900
committerGitHub <noreply@github.com>2025-02-26 01:48:38 +0000
commit495db2743318d43961f2a7fea0084ccae1cd9dea (patch)
treebaa8b619b04956b11ef3e419a86fae97f44f9eb0 /packages/backend/src/core/HttpRequestService.ts
parentfix(backend): ローカル判定でisUriLocalを使用していない箇所... (diff)
downloadsharkey-495db2743318d43961f2a7fea0084ccae1cd9dea.tar.gz
sharkey-495db2743318d43961f2a7fea0084ccae1cd9dea.tar.bz2
sharkey-495db2743318d43961f2a7fea0084ccae1cd9dea.zip
fix(backend): カスタム絵文字の一括インポートをした時にHTTPプロキシの除外設定が効かないのを修正 (#15431)
* pxory * fix * fix CHANGELOG.md * allow localAddress --------- Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
Diffstat (limited to 'packages/backend/src/core/HttpRequestService.ts')
-rw-r--r--packages/backend/src/core/HttpRequestService.ts47
1 files changed, 40 insertions, 7 deletions
diff --git a/packages/backend/src/core/HttpRequestService.ts b/packages/backend/src/core/HttpRequestService.ts
index 8085bbf961..13d8f7f43b 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 {
@@ -214,6 +215,38 @@ export class HttpRequestService {
}
}
+ /**
+ * Get agent for http by URL
+ * @param url URL
+ * @param isLocalAddressAllowed
+ */
+ @bindThis
+ 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, isLocalAddressAllowed = false): https.Agent {
+ if ((this.config.proxyBypassHosts ?? []).includes(url.hostname)) {
+ return isLocalAddressAllowed
+ ? this.httpsNative
+ : this.https;
+ } else {
+ return this.httpsAgent;
+ }
+ }
+
@bindThis
public async getActivityJson(url: string, isLocalAddressAllowed = false, allowSoftfail: FetchAllowSoftFailMask = FetchAllowSoftFailMask.Strict): Promise<IObject> {
const res = await this.send(url, {