fix: preserve DNS resolvers from sing-box subscriptions#25
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates subscription handling and runtime config generation to preserve DNS servers referenced by sing-box subscription outbounds (via domain_resolver), merging them into the generated config without overriding profile DNS servers, and migrating existing saved subscriptions to include a dnsServers field.
Changes:
- Extract and persist referenced subscription DNS servers during subscription updates, and migrate older subscriptions to include an initialized
dnsServerslist. - Collect referenced subscription DNS servers during outbound generation and merge them into the generated DNS config.
- Normalize subscription DNS server
detourfields to avoid referencing outbounds that are not included in the generated runtime outbounds set.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| frontend/src/utils/migration.ts | Migrates existing subscription records to ensure dnsServers is always initialized. |
| frontend/src/utils/generator.ts | Collects subscription DNS servers alongside generated outbounds and merges/normalizes them into the runtime DNS config. |
| frontend/src/types/app.d.ts | Extends App.Subscription typing to include dnsServers. |
| frontend/src/stores/subscribes.ts | Parses subscription DNS servers from sing-box JSON subscriptions and stores the referenced subset in subscription.dnsServers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| while (pending.length > 0) { | ||
| const tag = pending.shift()! | ||
| if (result.has(tag)) continue | ||
|
|
||
| const server = serverMap.get(tag) | ||
| if (!server) continue | ||
|
|
||
| result.set(tag, server) | ||
| pending.push(...collectDomainResolverTags(server)) | ||
| } |
Bubble-droid
left a comment
There was a problem hiding this comment.
杀鸡焉用牛刀,毫无意义的重复功能,如果你使用【节点转换】插件,请在插件源码中注释或删除以下代码
if (isGFS) {
// 移除暂未适配的字段
proxies.forEach((proxy) => {
delete proxy.domain_resolver
})
}如此 domain_resolver 字段将会保留在订阅中,如果此字段为对象格式,包含了一个完整的 DNS 服务器,那你不需要任何操作,如果是引用了配置中 dns.servers部分所声明的 DNS 服务器,你只需前往对应的配置设置页面,参照原始的订阅配置,添加一个同名服务器即可
如果嫌手动添加麻烦,可以右键配置卡片 -> 更多 -> 编辑配置(源文件),直接粘贴你的订阅原始配置,或只粘贴对应的 DNS 服务器项
Summary
Verification
Go tests were not run because the local environment does not have the go command available.