TF-3976: Fix URL lookup failure when DNS resolution fails
This commit is contained in:
@@ -33,13 +33,13 @@ class DnsLookupManager {
|
|||||||
const debug = BuildUtils.isDebugMode;
|
const debug = BuildUtils.isDebugMode;
|
||||||
switch (priority) {
|
switch (priority) {
|
||||||
case DnsLookupPriority.system:
|
case DnsLookupPriority.system:
|
||||||
return SystemUdpSrvClient(debugMode: debug);
|
return SystemUdpSrvClient(debugMode: debug, timeout: _defaultTimeout);
|
||||||
case DnsLookupPriority.publicUdp:
|
case DnsLookupPriority.publicUdp:
|
||||||
return PublicUdpSrvClient(debugMode: debug);
|
return PublicUdpSrvClient(debugMode: debug, timeout: _defaultTimeout);
|
||||||
case DnsLookupPriority.publicDoh:
|
case DnsLookupPriority.publicDoh:
|
||||||
return DnsOverHttpsBinaryClient(debugMode: debug);
|
return DnsOverHttpsBinaryClient(debugMode: debug, timeout: _defaultTimeout);
|
||||||
case DnsLookupPriority.cloud:
|
case DnsLookupPriority.cloud:
|
||||||
return DnsOverHttps.google(debugMode: debug);
|
return DnsOverHttps.empty(debugMode: debug, timeout: _defaultTimeout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,31 +56,18 @@ class DnsLookupManager {
|
|||||||
|
|
||||||
for (final priority in priorities) {
|
for (final priority in priorities) {
|
||||||
final client = createClient(priority);
|
final client = createClient(priority);
|
||||||
log('$runtimeType::lookupJmapUrl → 🔍 Trying ${priority.label} (timeout: ${_defaultTimeout.inSeconds}s)...');
|
log('$runtimeType::lookupJmapUrl → 🔍 Trying ${priority.label} (timeout: ${client.timeout.inSeconds}s)...');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final records = client is DnsOverHttps
|
final records = client is DnsOverHttps
|
||||||
? await client.lookupSrvParallel(jmapHostName).timeout(
|
? await client.lookupSrvMulti(jmapHostName)
|
||||||
_defaultTimeout,
|
: await client.lookupSrv(jmapHostName);
|
||||||
onTimeout: () {
|
|
||||||
throw TimeoutException(
|
|
||||||
'Lookup timed out after ${_defaultTimeout.inSeconds}s');
|
|
||||||
},
|
|
||||||
)
|
|
||||||
: await client.lookupSrv(jmapHostName).timeout(
|
|
||||||
_defaultTimeout,
|
|
||||||
onTimeout: () {
|
|
||||||
throw TimeoutException(
|
|
||||||
'Lookup timed out after ${_defaultTimeout.inSeconds}s');
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
if (records.isNotEmpty) {
|
final target = records.firstOrNull?.target ?? '';
|
||||||
final target = records.first.target;
|
if (target.isNotEmpty) {
|
||||||
log('$runtimeType::lookupJmapUrl → ✅ Success via ${priority.label}: $target');
|
log('$runtimeType::lookupJmapUrl → ✅ Success via ${priority.label}: $target');
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
log('$runtimeType::lookupJmapUrl → ⚠️ No records via ${priority.label}, continuing...');
|
log('$runtimeType::lookupJmapUrl → ⚠️ No records via ${priority.label}, continuing...');
|
||||||
} on TimeoutException catch (_) {
|
} on TimeoutException catch (_) {
|
||||||
logError(
|
logError(
|
||||||
@@ -92,6 +79,6 @@ class DnsLookupManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
log('$runtimeType::lookupJmapUrl → 🚨 All DNS lookups failed for $jmapHostName');
|
log('$runtimeType::lookupJmapUrl → 🚨 All DNS lookups failed for $jmapHostName');
|
||||||
return '';
|
throw Exception('DNS lookup failed for $jmapHostName');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -2169,10 +2169,10 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: super_dns_client
|
name: super_dns_client
|
||||||
sha256: fe51cb3da20be471ca1d72293bf0f86ddff015fbc1644b586cdb695e85433b9c
|
sha256: dbb9d36e91c22dcd3455b930efbc3c6f68074a91d4e7e11efb89d721387f3593
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.3.3"
|
version: "0.3.6"
|
||||||
super_ip:
|
super_ip:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
+1
-1
@@ -105,7 +105,7 @@ dependencies:
|
|||||||
### Dependencies from pub.dev ###
|
### Dependencies from pub.dev ###
|
||||||
super_tag_editor: 1.1.0
|
super_tag_editor: 1.1.0
|
||||||
|
|
||||||
super_dns_client: 0.3.3
|
super_dns_client: 0.3.6
|
||||||
|
|
||||||
external_app_launcher: 4.0.3
|
external_app_launcher: 4.0.3
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user