super_dns_client 0.3.8 copy "super_dns_client: ^0.3.8" to clipboard
super_dns_client: ^0.3.8 copied to clipboard

A modern and lightweight Dart library for performing DNS-over-HTTPS (DoH) lookups. Supports multiple resolvers and easy integration for Flutter and server-side apps.

🧭 super_dns_client #

A modern, lightweight, and native-integrated DNS resolver for Dart and Flutter β€”
supporting both DNS-over-HTTPS (DoH) and traditional UDP/TCP lookups
with system-aware DNS discovery across all major platforms.

Built for Flutter, Dart CLI, and backend apps.


πŸš€ Features #

  • πŸ” Query A, AAAA, CNAME, SRV, TXT records
  • 🌐 Supports DoH and traditional UDP/TCP DNS
  • 🧩 Native System DNS detection (macOS, Linux, Android, iOS)
  • βš™οΈ Public resolver fallback with automatic switching
  • πŸ’Ύ TTL-based SRV caching
  • 🧱 Built with universal_io, super_raw, and super_ip
  • βœ… Null-safe, CI-tested, production-ready

πŸ“¦ Installation #

dependencies:
  super_dns_client: ^0.3.0

Then run:

dart pub get

πŸ’‘ Example #

import 'package:super_dns_client/super_dns_client.dart';
import 'package:super_dns_client/src/udp_tcp/system_udp_srv_client.dart';
import 'package:super_dns_client/src/udp_tcp/public_udp_srv_client.dart';

void main() async {
  // Example 1: DNS-over-HTTPS (Cloudflare)
  final doh = DnsOverHttps.cloudflare();
  final records = await doh.lookup('google.com');
  for (var ip in records) {
    print('DoH β†’ ${ip.address}');
  }

  // Example 2: SRV lookup via System-configured DNS
  final systemClient = SystemUdpSrvClient();
  final systemRecords = await systemClient.lookupSrv('_jmap._tcp.example.com');
  for (var r in systemRecords) {
    print('SystemDNS β†’ ${r.target}:${r.port}');
  }

  // Example 3: SRV lookup via Public DNS resolvers
  final publicClient = PublicUdpSrvClient();
  final publicRecords = await publicClient.lookupSrv('_jmap._tcp.example.com');
  for (var r in publicRecords) {
    print('PublicDNS(${r.resolverName}) β†’ ${r.target}:${r.port}');
  }
}

βš™οΈ Platform-specific System DNS Detection #

Platform Method Description
Android ConnectivityManager.getLinkProperties() The plugin uses a native Kotlin bridge to fetch DNS servers from the currently active network interface. Requires ACCESS_NETWORK_STATE permission.
iOS res_ninit() via Objective-C helper Calls the BSD resolver API to enumerate system DNS servers (/etc/resolv.conf equivalent).
macOS / Linux File parsing Reads /etc/resolv.conf for configured nameservers.
Web Not supported Browsers restrict raw DNS queries; DoH should be used instead.

🧠 System detection is handled automatically by SystemUdpSrvClient,
which internally uses PlatformSystemDns to bridge native resolvers.


βš™οΈ Available DNS Resolvers #

πŸ”Έ DNS-over-HTTPS (DoH) #

Provider Endpoint URL
Google https://dns.google/dns-query
Cloudflare https://cloudflare-dns.com/dns-query
Quad9 https://dns.quad9.net/dns-query
AdGuard https://dns.adguard-dns.com/dns-query
Mullvad https://doh.mullvad.net/dns-query
Yandex https://dns.yandex.com/dns-query
OpenDNS https://doh.opendns.com/dns-query

πŸ”Έ Traditional (UDP/TCP) #

  • System resolvers from platform configuration (Android, iOS, Linux, macOS)
  • Public resolvers (Quad9, AdGuard, Yandex, OpenDNS, Cloudflare)
  • TCP fallback for truncated UDP responses

πŸ§ͺ Run Tests #

dart test

🌍 Example Output #

DnsOverHttps.cloudflare::SRV β†’ _jmap._tcp.example.com β†’ jmap.example.com:443
SystemUdpSrvClient::SRV β†’ example.com:443
PublicUdpSrvClient(quad9)::SRV β†’ jmap.example.com:443

🧠 Summary #

Feature Status
DNS-over-HTTPS βœ…
UDP/TCP resolver βœ…
System DNS detection (native) βœ…
Public resolver fallback βœ…
TTL cache βœ…
IPv6 support βœ…
Android native bridge βœ…
iOS native bridge βœ…

πŸͺͺ License #

Licensed under the MIT License.
See LICENSE for details.


❀️ Contributing #

Pull requests and ideas are welcome!
Open an issue or PR at GitHub Issues.


pub package Dart

2
likes
150
points
831
downloads

Publisher

unverified uploader

Weekly Downloads

A modern and lightweight Dart library for performing DNS-over-HTTPS (DoH) lookups. Supports multiple resolvers and easy integration for Flutter and server-side apps.

Repository (GitHub)
View/report issues

Topics

#dns #doh #network #http #resolver

Documentation

API reference

License

MIT (license)

Dependencies

equatable, flutter, freezed_annotation, http, json_annotation, super_dns, super_raw, universal_io

More

Packages that depend on super_dns_client

Packages that implement super_dns_client