doh 0.0.4+2
doh: ^0.0.4+2 copied to clipboard
A high-performance DNS over HTTPS (DoH) client library with China network optimization, proxy support, smart caching, and failover.
0.0.4+2 - 2024-12-19 #
๐จ๐ณ China Network Optimization & Proxy Support #
โจ New Features
- China Network Support: Smart provider categorization for China mainland users
- Proxy Support: Added HTTP/SOCKS proxy support for blocked providers
- Provider Classification:
chinaDirectProviders(3) - Direct access providers (Alibaba DNS, Taiwan DNS)chinaProxyProviders(9) - Proxy-required providers (Google, Cloudflare, etc.)chinaOptimizedProviders(12) - Smart fallback strategy
- Smart Testing Script:
test_proxy.dartwith automatic fallback strategy - Clash/V2Ray Integration: Built-in support for popular proxy tools
๐ง Provider Reorganization
- Direct Access: Alibaba DNS (alidns, alidns2), Taiwan DNS (tw101)
- Proxy Required: Google DNS, Cloudflare, Quad9, OpenDNS, AdGuard, DNS.SB
- Auto-Detection: Smart switching between direct and proxy access
- Performance Optimized: Prioritize direct providers for lower latency
๐ Documentation Updates
- China Network Guide: Comprehensive guide for China users
- Proxy Configuration: Examples for Clash, V2Ray, and other tools
- Best Practices: Recommended strategies for different environments
- Testing Guide: How to verify network connectivity
๐งช Testing Improvements
- Network-Aware Tests: Separate tests for direct and proxy providers
- Fallback Testing: Automatic proxy port detection (7890, 1080, 8080, etc.)
- Provider Validation: Tests ensure proper categorization
- Performance Monitoring: Connection time measurement
๐ Code Cleanup
- Redundant Code Removal: Eliminated duplicate implementations
- Test Optimization: Streamlined testing logic and removed repetition
- Provider Logic: Simplified provider switching mechanism
- Error Handling: More descriptive error messages for China users
๐ฏ Usage for China Users #
// Direct providers (fastest, no proxy needed)
final directClient = DoH(providers: DoHProvider.chinaDirectProviders);
// Proxy providers (for blocked services)
final proxyClient = DoH(
providers: DoHProvider.chinaProxyProviders,
proxyHost: '127.0.0.1',
proxyPort: 7890, // Clash default port
);
// Smart combined approach (recommended)
final smartClient = DoH(providers: DoHProvider.chinaOptimizedProviders);
๐งช Testing Your Setup #
# Run comprehensive network test
dart run test_proxy.dart
The test will:
- Try direct providers first (no proxy)
- Fall back to proxy providers with 127.0.0.1:7890
- Test alternative proxy ports if needed
- Provide detailed connectivity report
0.0.4+1 - 2024-12-19 #
๐ Major Architecture Overhaul & Feature Enhancements #
โจ New Features
- 25+ DNS Record Types: Added comprehensive support for DNS record types including DNSSEC records (DS, RRSIG, NSEC, DNSKEY, etc.)
- 12 DoH Providers: Added support for AdGuard DNS, DNS.SB, OpenDNS, and more providers
- Provider Groups: Added
recommendedProviders,chinaOptimizedProviders, andallProvidersfor easy selection - Advanced Caching: Implemented LRU cache with memory management, statistics, and configurable limits
- Custom Exception System: Added detailed exception types (DnsResolutionException, NetworkException, etc.)
- Cache Statistics: Added hit rate, memory usage tracking, and cache entry counting
- Resource Management: Added proper
dispose()method for cleanup
๐ง Breaking Changes
- Singleton Pattern: Improved singleton implementation with proper lifecycle management
- API Changes: Modified
lookup()method parameters (attemptโattempts) - Type Safety: Enhanced generic type constraints and safe type casting
- Provider Management: Removed mutable
providersetter, use constructor parameter instead
๐ Performance Improvements
- HTTP Client Reuse: Single HTTP client instance per DoH client to avoid connection overhead
- Parallel Tool Execution: Optimized for concurrent DNS queries
- Memory Management: Smart cache cleanup with TTL expiration and LRU eviction
- Connection Pooling: Reused connections for better performance
๐ Architecture Improvements
- Error Handling: Comprehensive error handling with specific exception types
- Code Organization: Better module separation and clear responsibilities
- Type System: Enhanced type safety with proper generic constraints
- Validation: Input validation for all public methods
๐ Documentation & Examples
- Complete README: Professional documentation with usage examples
- API Reference: Detailed method documentation with parameter descriptions
- Example Code: Comprehensive examples demonstrating all features
- Performance Guide: Best practices for optimal performance
๐งช Testing Improvements
- Test Coverage: Comprehensive test suite covering all major functionality
- Error Testing: Tests for all exception scenarios
- Performance Tests: Concurrent query and caching performance tests
- Model Tests: Unit tests for all data models
๐ Internationalization
- English Documentation: All comments and documentation converted to English
- Consistent Naming: Standardized naming conventions throughout codebase
๐ง Technical Improvements
- DNS Response Parsing: Improved RFC 8484 compliance and error handling
- Cache Algorithm: Advanced LRU cache with memory pressure management
- Network Stack: Better timeout handling and connection management
- Error Recovery: Improved failover between providers
๐โโ๏ธ Migration Guide #
From 0.0.3 to 0.0.4
// Old way (deprecated)
DoH.instance.provider = [DoHProvider.cloudflare1];
await DoH.instance.lookup('example.com', DohRequestType.A, attempt: 2);
// New way
final doh = DoH(providers: [DoHProvider.cloudflare1]);
try {
final results = await doh.lookup('example.com', DohRequestType.A, attempts: 2);
// Process results
} finally {
doh.dispose(); // Important: cleanup resources
}
Exception Handling
// Enhanced error handling
try {
final results = await doh.lookup('example.com', DohRequestType.A);
} on DnsResolutionException catch (e) {
print('DNS resolution failed: ${e.domain} - ${e.message}');
} on NetworkException catch (e) {
print('Network error from ${e.provider}: ${e.message}');
} on InvalidRequestTypeException catch (e) {
print('Unsupported record type: ${e.requestType}');
}