lookupHttps method

Future<DnsRecord> lookupHttps(
  1. String hostname,
  2. {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 == null) {
    throw ArgumentError.notNull("type");
  } else 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 response = await http.get(Uri.https(_uri.authority, _uri.path, query),
      headers: {'accept': 'application/dns-json'});
  final record = DnsRecord.fromJson(jsonDecode(response.body));
  return record;
}