Skip to content

fix: preserve DNS resolvers from sing-box subscriptions#25

Open
1392726643 wants to merge 1 commit into
GUI-for-Cores:mainfrom
1392726643:fix/subscription-dns-resolvers
Open

fix: preserve DNS resolvers from sing-box subscriptions#25
1392726643 wants to merge 1 commit into
GUI-for-Cores:mainfrom
1392726643:fix/subscription-dns-resolvers

Conversation

@1392726643

Copy link
Copy Markdown

Summary

  • preserve DNS servers referenced by imported sing-box subscription outbounds via domain_resolver
  • merge referenced subscription DNS servers into generated runtime config without overriding profile DNS servers
  • migrate existing subscriptions with an empty dnsServers list and guard missing DNS detours when only part of a subscription is used

Verification

  • pnpm type-check
  • pnpm build-only
  • pnpm exec oxlint src/stores/subscribes.ts src/utils/generator.ts src/utils/migration.ts src/types/app.d.ts

Go tests were not run because the local environment does not have the go command available.

Copilot AI review requested due to automatic review settings July 2, 2026 11:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 dnsServers list.
  • Collect referenced subscription DNS servers during outbound generation and merge them into the generated DNS config.
  • Normalize subscription DNS server detour fields 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.

Comment on lines +47 to +56
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 Bubble-droid left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

杀鸡焉用牛刀,毫无意义的重复功能,如果你使用【节点转换】插件,请在插件源码中注释或删除以下代码

    if (isGFS) {
      // 移除暂未适配的字段
      proxies.forEach((proxy) => {
        delete proxy.domain_resolver
      })
    }

如此 domain_resolver 字段将会保留在订阅中,如果此字段为对象格式,包含了一个完整的 DNS 服务器,那你不需要任何操作,如果是引用了配置中 dns.servers部分所声明的 DNS 服务器,你只需前往对应的配置设置页面,参照原始的订阅配置,添加一个同名服务器即可

如果嫌手动添加麻烦,可以右键配置卡片 -> 更多 -> 编辑配置(源文件),直接粘贴你的订阅原始配置,或只粘贴对应的 DNS 服务器项

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants