From 3eacbe6b6d80321d2672c02e640616395ef565ae Mon Sep 17 00:00:00 2001 From: Essem Date: Sat, 19 Aug 2023 23:20:01 -0500 Subject: [PATCH] enhance(backend): Add address bind config option (#11725) * Add address bind config option * Edit changelog * forgot to add to types --- .config/example.yml | 3 +++ CHANGELOG.md | 1 + packages/backend/src/config.ts | 1 + packages/backend/src/core/HttpRequestService.ts | 4 ++++ 4 files changed, 9 insertions(+) diff --git a/.config/example.yml b/.config/example.yml index 49683c2f30..cca44ce88c 100644 --- a/.config/example.yml +++ b/.config/example.yml @@ -159,6 +159,9 @@ id: 'aid' #deliverJobMaxAttempts: 12 #inboxJobMaxAttempts: 8 +# Local address used for outgoing requests +#outgoingAddress: 127.0.0.1 + # IP address family used for outgoing request (ipv4, ipv6 or dual) #outgoingAddressFamily: ipv4 diff --git a/CHANGELOG.md b/CHANGELOG.md index 38dcddaa91..02a0fa16d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,6 +54,7 @@ ### Server - Fix: APIのオフセットが壊れていたせいで「もっと見る」でもっと見れない問題を修正 - Fix: 外部サーバーの投稿がタイムラインに表示されないことがある問題を修正 +- Enhance: Add address bind config option (outgoingAddress) ## 13.14.1 diff --git a/packages/backend/src/config.ts b/packages/backend/src/config.ts index 29f511842c..3c70e0bbe3 100644 --- a/packages/backend/src/config.ts +++ b/packages/backend/src/config.ts @@ -76,6 +76,7 @@ export type Source = { id: string; + outgoingAddress?: string; outgoingAddressFamily?: 'ipv4' | 'ipv6' | 'dual'; deliverJobConcurrency?: number; diff --git a/packages/backend/src/core/HttpRequestService.ts b/packages/backend/src/core/HttpRequestService.ts index 487172deae..73bb3dc7e9 100644 --- a/packages/backend/src/core/HttpRequestService.ts +++ b/packages/backend/src/core/HttpRequestService.ts @@ -53,12 +53,14 @@ export class HttpRequestService { keepAlive: true, keepAliveMsecs: 30 * 1000, lookup: cache.lookup as unknown as net.LookupFunction, + localAddress: config.outgoingAddress, }); this.https = new https.Agent({ keepAlive: true, keepAliveMsecs: 30 * 1000, lookup: cache.lookup as unknown as net.LookupFunction, + localAddress: config.outgoingAddress, }); const maxSockets = Math.max(256, config.deliverJobConcurrency ?? 128); @@ -71,6 +73,7 @@ export class HttpRequestService { maxFreeSockets: 256, scheduling: 'lifo', proxy: config.proxy, + localAddress: config.outgoingAddress, }) : this.http; @@ -82,6 +85,7 @@ export class HttpRequestService { maxFreeSockets: 256, scheduling: 'lifo', proxy: config.proxy, + localAddress: config.outgoingAddress, }) : this.https; }