lookupHttps method
Future<DnsRecord>
lookupHttps(
- String hostname, {
- InternetAddressType type = InternetAddressType.any,
Implementation
Future<DnsRecord> lookupHttps(String hostname,
{InternetAddressType type = InternetAddressType.any}) async {
// Build URL
var query = {'name': hostname};
// Add: IPv4 or IPv6?
if (type == InternetAddressType.any || type == InternetAddressType.IPv4) {
query['type'] = 'A';
} else {
query['type'] = 'AAAA';
}
// Hide my IP?
if (maximalPrivacy) {
query['edns_client_subnet'] = '0.0.0.0/0';
}
final request =
await _client.getUrl(Uri.https(_uri.authority, _uri.path, query));
request.headers.set('accept', 'application/dns-json');
final response = await request.close();
final contents = StringBuffer();
await for (var data in response.transform(utf8.decoder)) {
contents.write(data);
}
final record = DnsRecord.fromJson(jsonDecode(contents.toString()));
return record;
}