Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

新增ECH客户端支持 #3162

Merged
merged 3 commits into from
Oct 1, 2024
Merged

新增ECH客户端支持 #3162

merged 3 commits into from
Oct 1, 2024

Conversation

Fangliding
Copy link
Contributor

从这copy东西走了 copy点东西回来才叫礼尚往来
基本就是从 XTLS/Xray-core#3813 copy来的
新增两个tlsSettings字段 指定ECH Config 或者从一个指定的DOH服务器查询(需要设置serverName)

"echConfig": "AFj+DQBUAAAgACAJSBrX4ZNnpgYFsaF+sUabAbsO+y2Bs61D6nmHEw7dRgAkAAEAAQABAAIAAQADAAIAAQACAAIAAgADAAMAAQADAAIAAwADAAV4LmNvbQAA",
"echDohServer": "https://1.1.1.1/dns-query"

还没测试~~(因为手上没可用的config)~~ 不过隔壁测试是OK的 两边应该大差不差

@dyhkwong
Copy link
Contributor

At least you need to use internet.DialSystem to dial, otherwise client software using internet.UseAlternativeSystemDialer or internet.RegisterDialerController will break.

@Fangliding
Copy link
Contributor Author

Fangliding commented Sep 17, 2024

At least you need to use internet.DialSystem to dial, otherwise client software using internet.UseAlternativeSystemDialer or internet.RegisterDialerController will break.

我暂时没有考虑把它整合进ray里的系统 这个doh是随手糊的 没用dispatcher也没用ray里的internet包 虽然改也很简单不过 作为一个go软件难道连用http包发出一个小请求都会炸么

@xiaokangwang xiaokangwang added the Extensive Review Required Require an extensive review from organization owner, cannot be merged without owner approval label Sep 17, 2024
@xiaokangwang
Copy link
Contributor

其实还不如拆分一下 TLS 这里就不搞DOH了请求了,就只留下ECHConfig。然后直接给DoH请求的部分给放进命令行工具,这样也就没必要完全遵守那些针对于协议实现的规则了。

@dyhkwong
Copy link
Contributor

dyhkwong commented Sep 17, 2024

作为一个go软件难道连用http包发出一个小请求都会炸么

UseAlternativeSystemDialer 一般来说是给 Android VpnService 绕过 core 自己发出的流量用的。在这种情况下如果 core 自己不使用 DialSystem 发出,会导致流量回环。用别的方法绕过另说。

@Fangliding
Copy link
Contributor Author

其实还不如拆分一下 TLS 这里就不搞DOH了请求了,就只留下ECHConfig。然后直接给DoH请求的部分给放进命令行工具,这样也就没必要完全遵守那些针对于协议实现的规则了。

个人觉得没必要搞命令行工具 这个记录的格式非常简单 一个典型的 type65记录就长这样 稍微dig一下就出来了

"data": "1 . alpn=h3,h2 ipv4hint=104.21.64.221,172.67.156.37 ech=AEX+DQBBHgAgACA5X3JvPSm0+20Mk8YmwftwaYaHDz7GfRfFpVzISLi7dwAEAAEAAQASY2xvdWRmbGFyZS1lY2guY29tAAA= ipv6hint=2606:4700:3031::ac43:9c25,2606:4700:3037::6815:40dd"

我只是构建了一个最基础的doh请求然后用正则表达式把里面的ech=xxx匹配出来而已 做这个的原因是cloudflare的ECH公钥似乎是轮换滚动的 写死不方便用而已
还是打算删的的话回头就毙了 只留一个最基础的搬config就完事了
顺便说一下 utls现在是不支持ECH的 我在想办法在什么地方返回一个警告或错误 但是好像没找到utls是在哪开的

@xiaokangwang
Copy link
Contributor

utls 是在 https://github.com/v2fly/v2ray-core/blob/master/transport/internet/tls/utls/utls.go#L29
但是现在这样又会每个连接都去请求一次吧.... 感觉合并的时候得改改。

Fangliding added a commit to XTLS/Xray-core that referenced this pull request Sep 17, 2024
@Fangliding
Copy link
Contributor Author

Fangliding commented Sep 17, 2024

utls 是在 https://github.com/v2fly/v2ray-core/blob/master/transport/internet/tls/utls/utls.go#L29 。 但是现在这样又会每个连接都去请求一次吧.... 感觉合并的时候得改改。

写了cache的呀 我还是没那么蠢

var (
	dnsCache = make(map[string]record)
	mutex    sync.RWMutex
)

@xiaokangwang
Copy link
Contributor

utls 是在 https://github.com/v2fly/v2ray-core/blob/master/transport/internet/tls/utls/utls.go#L29 。 但是现在这样又会每个连接都去请求一次吧.... 感觉合并的时候得改改。

写了cache的呀 我还是没那么蠢

var (
	dnsCache = make(map[string]record)
	mutex    sync.RWMutex
)

哦 抱歉是我蠢了。。。没看到。。。我的锅。。。

@xiaokangwang xiaokangwang merged commit 5ff7c71 into v2fly:master Oct 1, 2024
38 of 39 checks passed
if config.ServerName == "" {
return newError("Using DOH for ECH needs serverName")
}
ECHConfig, err = QueryRecord(c.ServerName, c.Ech_DOHserver)
Copy link
Contributor

Choose a reason for hiding this comment

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

consider the situation that server address will be filled into config.ServerName if no c.ServerName specified and server address is a domain name, should use ECHConfig, err = QueryRecord(config.ServerName, c.Ech_DOHserver) here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Extensive Review Required Require an extensive review from organization owner, cannot be merged without owner approval
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants