diff options
| author | MeiMei <30769358+mei23@users.noreply.github.com> | 2019-05-07 17:49:25 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2019-05-07 17:49:25 +0900 |
| commit | 96f675abed4e73d57c38cd11fc7cc6950cf6743b (patch) | |
| tree | 80f7c21abef714b248ee3cb2b748cf5286059fff /src/remote/activitypub | |
| parent | 2段階認証コードの入力フォームタイプの訂正 (#4869) (diff) | |
| download | sharkey-96f675abed4e73d57c38cd11fc7cc6950cf6743b.tar.gz sharkey-96f675abed4e73d57c38cd11fc7cc6950cf6743b.tar.bz2 sharkey-96f675abed4e73d57c38cd11fc7cc6950cf6743b.zip | |
Fix: IPv4 onlyホストからDualstackホストにAP deliverできない (#4872)
Diffstat (limited to 'src/remote/activitypub')
| -rw-r--r-- | src/remote/activitypub/request.ts | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/remote/activitypub/request.ts b/src/remote/activitypub/request.ts index da2113faea..3b69dd9ae4 100644 --- a/src/remote/activitypub/request.ts +++ b/src/remote/activitypub/request.ts @@ -101,11 +101,18 @@ export default async (user: ILocalUser, url: string, object: any) => { * Resolve host (with cached, asynchrony) */ async function resolveAddr(domain: string) { + const af = config.outgoingAddressFamily || 'ipv4'; + const useV4 = af == 'ipv4' || af == 'dual'; + const useV6 = af == 'ipv6' || af == 'dual'; + + const promises = []; + + if (!useV4 && !useV6) throw 'No usable address family available'; + if (useV4) promises.push(resolveAddrInner(domain, { family: 4 })); + if (useV6) promises.push(resolveAddrInner(domain, { family: 6 })); + // v4/v6で先に取得できた方を採用する - return await promiseAny([ - resolveAddrInner(domain, { family: 4 }), - resolveAddrInner(domain, { family: 6 }) - ]); + return await promiseAny(promises); } function resolveAddrInner(domain: string, options: IRunOptions = {}): Promise<string> { |