Fix: IPv4 onlyホストからDualstackホストにAP deliverできない (#4879)
This commit is contained in:
		
							parent
							
								
									c7bcf31105
								
							
						
					
					
						commit
						a57e9460c8
					
				
					 3 changed files with 16 additions and 4 deletions
				
			
		|  | @ -113,3 +113,6 @@ autoAdmin: true | ||||||
| 
 | 
 | ||||||
| # Clustering | # Clustering | ||||||
| #clusterLimit: 1 | #clusterLimit: 1 | ||||||
|  | 
 | ||||||
|  | # IP address family used for outgoing request (ipv4, ipv6 or dual) | ||||||
|  | #outgoingAddressFamily: ipv4 | ||||||
|  |  | ||||||
|  | @ -42,6 +42,8 @@ export type Source = { | ||||||
| 	accesslog?: string; | 	accesslog?: string; | ||||||
| 
 | 
 | ||||||
| 	clusterLimit?: number; | 	clusterLimit?: number; | ||||||
|  | 
 | ||||||
|  | 	outgoingAddressFamily?: 'ipv4' | 'ipv6' | 'dual'; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  |  | ||||||
|  | @ -96,11 +96,18 @@ export default async (user: ILocalUser, url: string, object: any) => { | ||||||
|  * Resolve host (with cached, asynchrony) |  * Resolve host (with cached, asynchrony) | ||||||
|  */ |  */ | ||||||
| async function resolveAddr(domain: string) { | 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で先に取得できた方を採用する
 | 	// v4/v6で先に取得できた方を採用する
 | ||||||
| 	return await promiseAny([ | 	return await promiseAny(promises); | ||||||
| 		resolveAddrInner(domain, { family: 4 }), |  | ||||||
| 		resolveAddrInner(domain, { family: 6 }) |  | ||||||
| 	]); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function resolveAddrInner(domain: string, options: IRunOptions = {}): Promise<string> { | function resolveAddrInner(domain: string, options: IRunOptions = {}): Promise<string> { | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue