From 52edb377e4785cbcb85d79592b787784b64c9ea2 Mon Sep 17 00:00:00 2001 From: wangjia <809946525@qq.com> Date: Thu, 18 Jun 2026 21:51:10 +0800 Subject: [PATCH] =?UTF-8?q?fix(client-config):=20=E5=8E=BB=E6=8E=89=20loca?= =?UTF-8?q?l=20DNS=20=E7=9A=84=20detour:direct(sing-box=201.12=20=E8=BF=90?= =?UTF-8?q?=E8=A1=8C=E6=97=B6=20FATAL)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sing-box 1.12 start-service 阶段拒绝 DNS server detour 到空 direct 出站 (FATAL: detour to an empty direct outbound makes no sense)。local DNS 去掉 detour 后走默认路由,功能不变。已在节点用 `sing-box run`(空 inbound 复现 start-service)实测启动无 FATAL —— sing-box check 抓不到这类运行时错。 Co-Authored-By: Claude Opus 4.8 --- server/cmd/mockserver/main.go | 2 +- server/internal/httpapi/clientconfig.go | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/server/cmd/mockserver/main.go b/server/cmd/mockserver/main.go index 3dca755..276d0dd 100644 --- a/server/cmd/mockserver/main.go +++ b/server/cmd/mockserver/main.go @@ -22,7 +22,7 @@ import ( // Fields match the nodes table columns: reality_public_key / reality_short_id / hy2_password. // In production the API renders these per-user from the nodes table. // Placeholders here are mock values for integration testing only. -const connectConfig = `{"log":{"level":"warn","timestamp":true},"inbounds":[{"type":"tun","tag":"tun-in","address":["172.19.0.1/30"],"mtu":9000,"auto_route":true,"strict_route":true,"stack":"system"}],"outbounds":[{"type":"vless","tag":"reality-out","server":"18.136.60.128","server_port":11443,"uuid":"ffffffff-ffff-ffff-ffff-ffffffffffff","flow":"xtls-rprx-vision","tls":{"enabled":true,"server_name":"www.apple.com","utls":{"enabled":true,"fingerprint":"chrome"},"reality":{"enabled":true,"public_key":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","short_id":"deadbeef"}}},{"type":"hysteria2","tag":"hy2-out","server":"18.136.60.128","server_port":443,"password":"mock-hy2-password","tls":{"enabled":true,"insecure":true,"alpn":["h3"]}},{"type":"urltest","tag":"auto","outbounds":["reality-out","hy2-out"],"url":"https://www.gstatic.com/generate_204","interval":"3m","tolerance":50},{"type":"block","tag":"block"},{"type":"direct","tag":"direct"}],"route":{"rules":[{"ip_cidr":["10.0.0.0/8","172.16.0.0/12","192.168.0.0/16","127.0.0.0/8"],"outbound":"direct"}],"final":"auto","auto_detect_interface":true},"dns":{"servers":[{"tag":"remote","type":"tls","server":"8.8.8.8","detour":"auto"},{"tag":"local","type":"udp","server":"223.5.5.5","detour":"direct"}],"final":"remote","strategy":"ipv4_only"}}` +const connectConfig = `{"log":{"level":"warn","timestamp":true},"inbounds":[{"type":"tun","tag":"tun-in","address":["172.19.0.1/30"],"mtu":9000,"auto_route":true,"strict_route":true,"stack":"system"}],"outbounds":[{"type":"vless","tag":"reality-out","server":"18.136.60.128","server_port":11443,"uuid":"ffffffff-ffff-ffff-ffff-ffffffffffff","flow":"xtls-rprx-vision","tls":{"enabled":true,"server_name":"www.apple.com","utls":{"enabled":true,"fingerprint":"chrome"},"reality":{"enabled":true,"public_key":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","short_id":"deadbeef"}}},{"type":"hysteria2","tag":"hy2-out","server":"18.136.60.128","server_port":443,"password":"mock-hy2-password","tls":{"enabled":true,"insecure":true,"alpn":["h3"]}},{"type":"urltest","tag":"auto","outbounds":["reality-out","hy2-out"],"url":"https://www.gstatic.com/generate_204","interval":"3m","tolerance":50},{"type":"block","tag":"block"},{"type":"direct","tag":"direct"}],"route":{"rules":[{"ip_cidr":["10.0.0.0/8","172.16.0.0/12","192.168.0.0/16","127.0.0.0/8"],"outbound":"direct"}],"final":"auto","auto_detect_interface":true},"dns":{"servers":[{"tag":"remote","type":"tls","server":"8.8.8.8","detour":"auto"},{"tag":"local","type":"udp","server":"223.5.5.5"}],"final":"remote","strategy":"ipv4_only"}}` var reConnect = regexp.MustCompile(`^/v1/nodes/[^/]+/connect$`) diff --git a/server/internal/httpapi/clientconfig.go b/server/internal/httpapi/clientconfig.go index 67e9033..388b71f 100644 --- a/server/internal/httpapi/clientconfig.go +++ b/server/internal/httpapi/clientconfig.go @@ -126,7 +126,9 @@ func BuildClientConfig(node *nodes.NodeRow, dpUUID, deriveKey string) ([]byte, e dns := map[string]any{ "servers": []any{ map[string]any{"tag": "remote", "type": "tls", "server": "8.8.8.8", "detour": "auto"}, - map[string]any{"tag": "local", "type": "udp", "server": "223.5.5.5", "detour": "direct"}, + // local 不带 detour:sing-box 1.12 拒绝 DNS detour 到空 direct 出站 + // (FATAL: detour to an empty direct outbound makes no sense)。 + map[string]any{"tag": "local", "type": "udp", "server": "223.5.5.5"}, }, "final": "remote", "strategy": "ipv4_only",