fix: Ensure HTTP Host Header format compliance #1905
Merged
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.
[ ]
) per RFC 3986smartdns 在发送 https 请求时,会添加 Host 字段,内容为
https_flag->httphost
。上游为flag_http->httphost => server->httphost => server->server
。server->server
则来自配置文件中服务器地址的解析结果,当 url 中 host 为 ipv6 地址时,util.c:parse_ip
会移除首尾的[ ]
。而在 RFC 规范 中,Host 字段中的 ipv6 地址必须用方括号包裹。cloudflare 和 google 的服务器都会拒绝错误格式的 Host 字段。目前可以用-http-host
选项暂时解决这个问题。配置:
报错:
其他复现方式: