Support SVCB/HTTPS SvcParams presentation format from DoH (fixes #22) - #23
Merged
Merged
Conversation
Some DoH servers (e.g. private query-dns endpoints) return HTTPS RR answers in RFC 9460 presentation format (e.g. "1 . alpn=h3,h2 ech=AEX+...") instead of RFC 3597 \# <len> <hex>. This caused parse_https_answer to fail and ECH to be unavailable (502 with default config). Refactor the wire parsing into parse_https_answer_wire and add an encoder that translates the presentation format into wire bytes, covering mandatory/alpn/no-default-alpn/port/ipv4hint/ech/ipv6hint. Fixes fjh1997#22.
Owner
|
wow,谢谢你的贡献,赞一个! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
修复 #22:默认配置下(
doh_endpoints = ["https://aaa.ddd.oaifree.com/query-dns"])访问 linux.do 返回 502,日志显示ech=no。根因
src/proxy.rs的parse_https_answer只接受 RFC 3597\# <len> <hex>格式。但实测的主流 DoH(oaifree query-dns、cloudflare-dns.com、1.1.1.1)对 type=65 (HTTPS) 均返回 RFC 9460 presentation 文本格式:strip_prefix("\\#")失败 → HTTPS RR 解析报错 → 绑定列表为空 → ECH 配置不可用 → ECH 强制模式下直接 502。修改
parse_https_answer_wire;encode_https_answer_svc_params:把 SVCB/HTTPS SvcParams presentation 格式(priority target key=value...)编码为 wire 字节,支持mandatory/alpn/no-default-alpn/port/ipv4hint/ech/ipv6hint,未知键按keyNNNN处理并作 base64 解码;base64 = "0.22"依赖。验证
cargo check通过;cargo test23 个测试全部通过(含新增的 4 个 HTTPS RR 解析测试);ech=yes,ECH + HTTP/2 链路打通。作者此前已在 issue 中确认解析器与 ECH 握手链路本身正常,问题仅在 presentation 格式支持缺失。