fix: 修复 v1.19.21 中 gRPC 自定义 UserAgent 不生效的问题#2620
Merged
Merged
Conversation
|
顺手把 |
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.
mihomo 的配置文件 config.yaml 中 设置了 gRPC 自定义 UserAgent
grpc-opts.grpc-user-agent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"在使用 mihomo v1.19.20时,自定义UA生效,在Cloudflare Security后台能看到请求的UA为自定义UA;但是升级到 v1.19.21后,在配置不变的情况下,Cloudflare后台显示UA变回了默认UA
grpc-go/1.36.0,被Cloudflare视为HTTP DDoS攻击拦截。对比 v1.19.20 和 v1,19,21 代码发现:
能正常替换
user-agent的值此时会新建一个名为
User-Agent的自定义UA键值,而并不会替换原有的默认UAuser-agent,所以导致自定义UA失效,修改defaultHeader中的user-agent为User-Agent后才能替换默认UA为自定义UA我已经在我自己的repo中编译测试过了,通过Cloudflare后台日志确定这个pr能修复gRPC自定义UA不生效的问题。