diff --git a/.config/example.yml b/.config/example.yml index 49683c2f3092c1099fafbb6b4010f1fe90f2a2e1..cca44ce88c50a66d3477d3d6714bdcfe5cbcd7f0 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 38dcddaa91c04e5104ab6f50e8b5367d59f80828..02a0fa16d62332f08bb205b9fe2bb67212bef46e 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 29f511842cd91224fc9d60a213a50c67d332f9c5..3c70e0bbe35fc2b9d8ea9bd9f5fc1c2c9b9197a3 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 487172deae4c9bc4f01ef502a606282f84a8b50c..73bb3dc7e971bbee0d34aa1b474ff0dd635fd85c 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; }