Skip to content

fix(dns): integrate managed proxy DNS repair - #441

Merged
LIghtJUNction merged 4 commits into
mainfrom
fix/dns-proxy-fallback-20261106
Nov 6, 2026
Merged

LIghtJUNction merged 4 commits into
mainfrom
fix/dns-proxy-fallback-20261106

Conversation

@LIghtJUNction

@LIghtJUNction LIghtJUNction commented Nov 6, 2026 •

Copy link
Copy Markdown
Owner

Problem

The managed DNS default could send unclassified lookups to the direct bootstrap resolver while destination traffic used a proxy. This integration keeps the rebuild requirements, fixed source and delivery evidence aligned with the repair.

Changes

  • Pin magicnet-android@38c6eea6a42eb5f2cc3697c81225f35fd3c82d5c and MagicSingBox@ba5793b41fd06704102116fe2536eef5988f2905.
  • Advance the root recipe to 0.3.15 and routing policy to 0.2.5; add M60 and POLICY-A21–A25 covering proxy DNS default, failure without direct fallback, independent bootstrap, explicit profiles, diagnostics and failed-apply rollback.
  • Record root cause, previous-code negative controls, real-core DNS packet results, immutable package identity, review corrections and both Android attempts.

Validation

  • Recipe directory, archive and complete prompt checks pass: 8 packages and 60 Markdown files. Release-entry tests pass (21).
  • All seven final-source workflows succeed. Code Quality has 7 passing jobs and Network Regression Evidence has 3.
  • The mandatory real-core fixture verifies proxied A/AAAA over UDP/TCP, independent direct node bootstrap, preserved explicit direct policy and zero direct business-query fallback when the proxy refuses connections.
  • Android attempt 1 failed at the local TLS positive control. One retry on the same source and pinned dependencies passes all 12 lifecycle phases, 5 reboots and local TLS positive/negative controls. Components were rebuilt, so byte-identical binary execution is not claimed. The first failure remains unexplained and preserved; successful harness tests were reused, not double-counted.
  • The complete ARM64 module is 68,480,032 bytes with SHA-256 1fdc0caa0c2d412562bc44058b8527210ebad6df75dbc0fcc17d1eba44bab234. All 360 ZIP entries and 10 components / 168 component files pass audit; development/test content is excluded.

Android execution evidence is an x86_64 standalone TUN fixture. ARM64 execution, physical devices and user proxy nodes are not claimed. The fixture's product Google probe did not obtain HTTPS 204, although lifecycle and diagnostic controls pass. No formal release or user-device installation was created.

Integration

@sourcery-ai

sourcery-ai Bot commented Nov 6, 2026

Copy link
Copy Markdown

审阅者指南

此 PR 修复了托管默认 DNS 出站流量的问题:使模板和运行时始终对未分类查询使用代理 DoH;代理不可用时采用失败关闭策略;并保留独立的直连引导解析器,用于查找代理节点。此 PR 还增强了诊断功能,以检查实际生效的 DNS 引用和流量转发路径;更新了可复现的源码/模板固定版本及配方契约;并记录了针对性的 CI 验证和明确的设备测试限制。

托管默认 DNS 代理出站流量时序图

sequenceDiagram
    participant Client as 客户端
    participant Runtime as 运行时
    participant DNSCore as DNS 核心
    participant Proxy as 代理
    participant DoH as doh_cloudflare
    participant Bootstrap as bootstrap_local_dns

    Client->>Runtime: magicnet_dns_apply_singbox()
    Runtime->>DNSCore: 使用 doh_cloudflare 进行评估/响应
    DNSCore->>Proxy: 建立 DoH 的 CONNECT 连接
    Proxy->>DoH: 解析未分类查询
    DoH-->>DNSCore: DNS 响应
    DNSCore-->>Client: 返回响应

    alt 代理不可用
        DNSCore-->>Client: 查询失败
        DNSCore--x Bootstrap: 不进行直连回退
    end

    DNSCore->>Bootstrap: 解析代理节点域名
    Bootstrap-->>DNSCore: 节点地址
Loading

实际生效的 DNS 诊断流程图

flowchart TD
    A[未分类 DNS 查询] --> B[解析实际生效的 dns.final]
    B --> C[检查 evaluate/respond 解析器]
    C --> D{解析器的 detour 是否为 proxy?}
    D -->|是| E[受保护的默认 DNS]
    D -->|否| F[诊断失败]
    C --> G{是否存在显式 Direct、LAN 或自定义 DNS 图?}
    G -->|是| H[保留并验证显式行为]
    G -->|否| D
Loading

文件级变更

变更 详情 文件
使托管默认 DNS 解析与代理出站流量保持一致,同时保留独立的引导解析和显式 DNS 覆盖。
  • 通过 detour: proxy 将未分类的托管 DNS 查询路由到 doh-cloudflare。
  • 代理不可用时采用失败关闭策略,而不是回退到直连引导 DNS。
  • 保留用于解析代理节点主机名的 bootstrap-local-dns,并保留国内、LAN/Tailnet、Direct、配置文件和独立 DNS 图。
  • 更新模板生成、运行时实例化、迁移、配置文件应用及重复应用行为,使其使用相同的默认 DNS 契约。
recipes/magicnet-routing-policy/BUILD_PROMPT.md
recipes/magicnet-routing-policy/ACCEPTANCE.md
recipes/magicnet-routing-policy/RECIPE.md
recipes/magicnet/BUILD_PROMPT.md
recipes/magicnet/ACCEPTANCE.md
recipes/magicnet/RECIPE.md
recipes/magicnet/DEPENDENCIES.md
recipes/magicnet/DNS_REPAIR_2026-11-06.md
修正 DNS 诊断,使其验证默认路径实际引用的服务器,而不是根据是否存在支持代理的 DNS 服务器来推断是否受到保护。
  • 检查有效默认 DNS 服务器及其在 route/evaluate 路径中的 detour。
  • 按照核心语义一致地处理省略、为空和显式指定的默认规则元数据。
  • 针对直连和代理默认项、条件规则以及其他 DNS 供应商或 IP 格式的服务器添加回归测试。
recipes/magicnet/DNS_REPAIR_2026-11-06.md
recipes/magicnet/PROVENANCE.md
recipes/magicnet/VERIFICATION.md
generated/magicnet-android
更新可复现的源码和模板固定版本,并记录配方契约更新及证据边界。
  • 固定 Android 实现和 MagicSingBox 模板的修订版本,包括生成配置摘要和更新后的核心固定版本。
  • 更新根配方和 routing-policy 的版本;新增 M60 和 POLICY-A21–A25,同时保持八个软件包的依赖闭包不变。
  • 分别记录本地、CI/核心环回和未执行的实体设备验证;明确说明未进行任何发布或设备部署。
  • 更新 README 状态以及验证/来源追溯相关引用。
README.md
generated/magicnet-android
recipes/magicnet-routing-policy/RECIPE.md
recipes/magicnet/RECIPE.md
recipes/magicnet/DEPENDENCIES.md
recipes/magicnet/BUILD_PROMPT.md
recipes/magicnet/DNS_REPAIR_2026-11-06.md
recipes/magicnet/PROVENANCE.md
recipes/magicnet/VERIFICATION.md

提示与命令

与 Sourcery 互动

  • 触发新的审查: 在拉取请求中评论 @sourcery-ai review。
  • 继续讨论: 直接回复 Sourcery 的审查评论。
  • 根据审查评论创建 GitHub issue: 回复审查评论,请 Sourcery 根据该评论创建 issue。你也可以在审查评论中回复 @sourcery-ai issue 来创建 issue。
  • 生成拉取请求标题: 在拉取请求标题的任意位置写入 @sourcery-ai,即可随时生成标题。你也可以在拉取请求中评论 @sourcery-ai title,以随时(重新)生成标题。
  • 生成拉取请求摘要: 在拉取请求正文中你希望摘要出现的位置写入 @sourcery-ai summary,即可随时在该位置生成 PR 摘要。你也可以在拉取请求中评论 @sourcery-ai summary,以随时(重新)生成摘要。
  • 生成审阅者指南: 在拉取请求中评论 @sourcery-ai guide,即可随时(重新)生成审阅者指南。
  • 解决所有 Sourcery 评论: 在拉取请求中评论 @sourcery-ai resolve,即可解决所有 Sourcery 评论。如果你已经处理完所有评论且不想再看到它们,此功能会很有用。
  • 忽略所有 Sourcery 审查: 在拉取请求中评论 @sourcery-ai dismiss,即可忽略所有现有的 Sourcery 审查。如果你想从头开始进行新的审查,这尤其有用——别忘了评论 @sourcery-ai review 以触发新的审查!

自定义使用体验

访问你的控制面板以进行以下操作:

  • 启用或禁用审查功能,例如 Sourcery 生成的拉取请求摘要、审阅者指南等。
  • 更改审查语言。
  • 添加、移除或编辑自定义审查说明。
  • 调整其他审查设置。

获取帮助

Original review guide in English

Reviewer's Guide

This PR fixes managed-default DNS egress by making the template and runtime consistently use proxied DoH for uncategorized queries, failing closed when proxy access is unavailable, and retaining a separate direct bootstrap resolver for proxy-node lookup. It also strengthens diagnostics to inspect the effective DNS reference and detour, updates reproducible source/template pins and recipe contracts, and documents targeted CI validation plus explicit device-testing limits.

Sequence diagram for managed default DNS proxy egress

sequenceDiagram
    participant Client
    participant Runtime
    participant DNSCore
    participant Proxy
    participant DoH as doh_cloudflare
    participant Bootstrap as bootstrap_local_dns

    Client->>Runtime: magicnet_dns_apply_singbox()
    Runtime->>DNSCore: evaluate/respond using doh_cloudflare
    DNSCore->>Proxy: CONNECT for DoH
    Proxy->>DoH: Resolve uncategorized query
    DoH-->>DNSCore: DNS response
    DNSCore-->>Client: Return response

    alt proxy unavailable
        DNSCore-->>Client: Query failure
        DNSCore--x Bootstrap: No direct fallback
    end

    DNSCore->>Bootstrap: Resolve proxy node domain
    Bootstrap-->>DNSCore: Node address
Loading

Flow diagram for effective DNS diagnostics

flowchart TD
    A[Uncategorized DNS query] --> B[Resolve effective dns.final]
    B --> C[Inspect evaluate/respond resolver]
    C --> D{Resolver detour is proxy?}
    D -->|Yes| E[Protected default DNS]
    D -->|No| F[Diagnostic failure]
    C --> G{Explicit Direct, LAN, or custom DNS graph?}
    G -->|Yes| H[Preserve and validate explicit behavior]
    G -->|No| D
Loading

File-Level Changes

Change Details Files
Align managed default DNS resolution with proxy egress while preserving independent bootstrap resolution and explicit DNS overrides.
  • Route uncategorized managed DNS queries through doh-cloudflare with detour: proxy.
  • Fail closed when the proxy is unavailable instead of falling back to direct bootstrap DNS.
  • Keep bootstrap-local-dns for proxy-node hostname resolution and preserve domestic, LAN/Tailnet, Direct, profile, and standalone DNS graphs.
  • Update template generation, runtime materialization, migration, profile application, and repeated-application behavior to use the same default DNS contract.
recipes/magicnet-routing-policy/BUILD_PROMPT.md
recipes/magicnet-routing-policy/ACCEPTANCE.md
recipes/magicnet-routing-policy/RECIPE.md
recipes/magicnet/BUILD_PROMPT.md
recipes/magicnet/ACCEPTANCE.md
recipes/magicnet/RECIPE.md
recipes/magicnet/DEPENDENCIES.md
recipes/magicnet/DNS_REPAIR_2026-11-06.md
Correct DNS diagnostics to validate the server actually referenced by the default path rather than inferring protection from the presence of a proxy-capable DNS server.
  • Check the effective default DNS server and its detour across route/evaluate paths.
  • Handle omitted, empty, and explicit default rule metadata consistently with core semantics.
  • Add regressions for direct and proxied defaults, conditional rules, and alternate DNS vendors or IP-form servers.
recipes/magicnet/DNS_REPAIR_2026-11-06.md
recipes/magicnet/PROVENANCE.md
recipes/magicnet/VERIFICATION.md
generated/magicnet-android
Advance reproducible source and template pins and document the recipe-contract updates and evidence boundaries.
  • Pin the Android implementation and MagicSingBox template revisions, including the generated config digest and updated core pin.
  • Advance root and routing-policy versions; add M60 and POLICY-A21–A25 without changing the eight-package dependency closure.
  • Record local, CI/core-loopback, and non-executed physical-device validation separately; make clear that no release or device deployment occurred.
  • Update the README status and verification/provenance references.
README.md
generated/magicnet-android
recipes/magicnet-routing-policy/RECIPE.md
recipes/magicnet/RECIPE.md
recipes/magicnet/DEPENDENCIES.md
recipes/magicnet/BUILD_PROMPT.md
recipes/magicnet/DNS_REPAIR_2026-11-06.md
recipes/magicnet/PROVENANCE.md
recipes/magicnet/VERIFICATION.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@LIghtJUNction
LIghtJUNction marked this pull request as ready for review November 6, 2026 09:13
@sourcery-ai

sourcery-ai Bot commented Nov 6, 2026

Copy link
Copy Markdown

Sorry @LIghtJUNction, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 1 minute by commenting @sourcery-ai review. Upgrade to get a review now.

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review ❌ Failed 2026-11-06T09:13:17.255045Z
We couldn’t complete this review. Comment @codex security review to try again.
b5ed3bf Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

The account paying for this security review has reached its Codex usage limits. The payer can check the Codex usage dashboard. For personal accounts, using credits requires enabling “Use credits for security reviews” in Code review settings. If you do not manage the paying account, contact this repository's admins.

@LIghtJUNction
LIghtJUNction merged commit d22ea2f into main Nov 6, 2026
2 checks passed
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.

2 participants