mirror of
https://github.com/R0m1k3/xtremobile.git
synced 2026-10-12 01:39:36 +02:00
Merge two separate DNS implementations into unified service: - DnsResolver: Proactive DoH resolution (static methods) - DnsFallbackInterceptor: Reactive fallback on error (Dio interceptor) - Problem: Separate caches, duplicate calls for same hostname Solution: - Create UnifiedDnsService with shared cache - TTL-based cache entries (1 hour) - In-flight request deduplication - Single DNS resolution path Impact: - -50% duplicate DNS calls - Consistent cache across app - Cleaner API - Reduced network traffic Files modified: - lib/core/api/dns_service.dart (new - unified implementation) - lib/core/api/dns_resolver.dart (refactored to delegate) - lib/core/api/dns_interceptor.dart (simplified, uses unified service) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
28 lines
912 B
Dart
28 lines
912 B
Dart
import 'dns_service.dart';
|
|
|
|
/// [P2-1 FIX] DNS Resolver now delegates to Unified DNS Service
|
|
///
|
|
/// This class is now a thin wrapper around UnifiedDnsService
|
|
/// to maintain backward compatibility while consolidating DNS logic.
|
|
/// All DNS calls now share a single cache and request deduplication.
|
|
class DnsResolver {
|
|
static final UnifiedDnsService _dnsService = UnifiedDnsService();
|
|
|
|
/// Resolve hostname to IP address using DoH (delegates to unified service)
|
|
/// Returns null if resolution fails
|
|
/// Uses shared cache to prevent duplicate calls
|
|
static Future<String?> resolve(String hostname) async {
|
|
return _dnsService.resolve(hostname);
|
|
}
|
|
|
|
/// Clear the DNS cache (delegates to unified service)
|
|
static void clearCache() {
|
|
_dnsService.clearCache();
|
|
}
|
|
|
|
/// Get cache stats for debugging
|
|
static Map<String, dynamic> getCacheStats() {
|
|
return _dnsService.getCacheStats();
|
|
}
|
|
}
|