File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
packages/federation-sdk/src/server-discovery Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change 1+ import type { LookupAllOptions } from 'node:dns' ;
12import { Resolver , lookup } from 'node:dns/promises' ;
23
34// no caching, depends on system
45class _Resolver extends Resolver {
6+ private lookupOrder : LookupAllOptions [ 'order' ] = 'ipv6first' ;
7+
58 constructor ( ) {
69 super ( ) ;
710
@@ -12,6 +15,18 @@ class _Resolver extends Resolver {
1215
1316 this . setServers ( servers ) ;
1417 }
18+
19+ // spec says v6 first, but there shouldn't be a case where a and aaaa records point to different services. if does, not an application problem.
20+ // for systems with no v6 support this still lets allow a fallback to v4 first. without needing to add system level dns filter.
21+ // as long as the name has an a record, should be able to communicate.
22+ const order = process . env . HOMESERVER_CONFIG_DNS_LOOKUP_ORDER ;
23+ if (
24+ order === 'ipv4first' ||
25+ order === 'ipv6first' ||
26+ order === 'verbatim'
27+ ) {
28+ this . lookupOrder = order ;
29+ }
1530 }
1631
1732 // The implementation uses an operating system facility that can associate names with addresses and vice versa
@@ -20,7 +35,7 @@ class _Resolver extends Resolver {
2035 const result = await lookup ( hostname , {
2136 all : true ,
2237 family : 0 ,
23- order : 'ipv6first' ,
38+ order : this . lookupOrder ,
2439 } ) ;
2540
2641 return result . map ( ( r ) => r . address ) ;
You can’t perform that action at this time.
0 commit comments