dns_resolver 0.1.3 dns_resolver: ^0.1.3 copied to clipboard
Dart package that implements DNS over HTTPS client for Google Public DNS and Cloudflare DNS.
Basic Usage #
Resolver will return DnsRecord or null if the domain is not found or error occurred. Take care about null safety.
import 'package:dns_resolver/dns_resolver.dart';
void main() async {
var resolver = GoogleDnsResolver();
var record = await resolver.resolve(
"www.apple.com",
DnsRecordType.A,
);
print(record);
}
Custom Resolver #
You may create a custom resolver by extending the Resolver class by baseUrl. Service must implement the DNS over HTTPS protocol with application/dns-json response type.
import 'package:dns_resolver/dns_resolver.dart';
class MyResolver extends Resolver {
@override
String baseUrl = 'https://my.custom.service/dns-query';
}