DnsService class

Web 端 DNS 解析测试服务 / DNS resolution service for the web platform.

浏览器禁止原始 UDP 套接字,因此:

  • 系统解析器退化为通过 DNS-over-HTTPS (DoH) 解析;
  • 显式 DNS 服务器若提供已知 DoH 端点(如 1.1.1.1 / 8.8.8.8)则走 DoH, 否则(如 114.114.114.114)返回“不支持”结果 / Browsers forbid raw UDP sockets, so on the web:
  • the platform resolver degrades to DNS-over-HTTPS (DoH);
  • explicit servers with a known DoH endpoint (e.g. 1.1.1.1 / 8.8.8.8) use DoH, while others (e.g. 114.114.114.114) report "unsupported".

Constructors

DnsService({Duration defaultTimeout = const Duration(seconds: 5)})
构造 DnsService / Creates a DnsService.
const

Properties

defaultTimeout Duration
单次查询默认超时 / Default timeout of a single query.
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
query({required String domain, required String server, Duration? timeout}) Future<DnsTestResult>
查询单个 DNS 服务器 / Queries a single DNS server.
resolveWithSystemResolver({required String domain, Duration? timeout}) Future<DnsTestResult>
使用系统解析器解析域名(Web 端通过 DoH 实现)/ Resolves a domain through the platform resolver (DoH on the web).
testDns({String domain = 'www.google.com', List<String> dnsServers = const <String>['1.1.1.1', '8.8.8.8', '114.114.114.114'], Duration? timeout, bool concurrent = true, bool includeSystemResolver = false}) Future<List<DnsTestResult>>
依次/并发测试多台 DNS 服务器 / Tests multiple DNS servers.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited