Leadaxe 解释 DNS group 使用独立 hosts 字段及本地优先应答

Leadaxe 在 sing-box-lx #60 中说明,hosts 使用组的独立字段,不放入 servers;理由是它没有网络延迟、健康状态或恢复过程。按配置顺序先查 hosts,命中时原样返回,包括仅有另一地址族时的空 NOERROR;未命中则沿用原网络选择路径。hosts 不参与胜负、扇出或生存模式,不出现在 GetDNSGroups 中;servers 仍须非空,内含 hosts 仍会被拒绝。他在该评论发出时称改动已合入 lx、将随下一稳定标签发布,并注明已做单元测试、尚未设备实测。

作者原文

Landed in lx: b3cdb00dd (code and tests), 9bb311b6d (spec and docs). Ships with the next stable tag.

The shape differs from the proposal above: instead of a hosts member inside servers, the group gets a separate key.

{
  "type": "group", "tag": "resolver",
  "hosts": ["local"],
  "servers": ["google", "cloudflare"],
  "mode": "stable"
}

Why a key and not a member: the group decides which network server to trust right now, and a hosts server has no network, no latency, nothing to fail and nothing to recover — the same reason fakeip is kept out. Listing it in servers would make the order partly significant, show it in GetDNSGroups with health it does not have, and turn the LxBox validator's ban into "allowed, but not all of them". A key leaves servers as it is.

Behaviour is as proposed. Hosts members are asked first, in key order. A hit — A/AAAA, the member knows the name (PreferredDomain, the same check the preferred_by rule item uses), NOERROR — is returned as is, including the empty NOERROR when only the other family is listed. A miss takes the network path unchanged in every mode. Hosts members get no ERROR/WIN records, never join a fan or survival mode, never become current and are absent from GetDNSGroups. A hit shows as the effective server with one answered probe and a dns_member stage in the connection test; a miss records nothing. servers stays required and non-empty; hosts inside servers is still rejected at start, the error now points at the key.

Docs: docs-lx/lx-config.md §5, spec SPECS/TASKS/143-DNS_GROUP_HOSTS_OVERLAY. Unit-tested in all modes including the real hosts transport; not checked on a device yet — if the dual-stack wg.home case misbehaves there, reopen and I will look.