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

WSS Browser Dialer #421

Merged
merged 3 commits into from
Mar 23, 2021
Merged

WSS Browser Dialer #421

merged 3 commits into from
Mar 23, 2021

Conversation

RPRX
Copy link
Member

@RPRX RPRX commented Mar 21, 2021

Background

v2ray/discussion#754 (comment) 基于一年前的想法,原生 JS 实现了简洁的 WSS Browser Dialer,真实浏览器的 TLS 指纹、行为特征

不过 WSS 仍存在 ALPN 明显的问题,所以下一步是浏览器转发 gRPC、QUIC

Xray & JS

创造了一个非常简单、巧妙的通信机制:

  1. Xray 监听地址端口 A,作为 HTTP 服务,浏览器访问 A,加载网页中的 JS
  2. JS 主动向 A 建立 WebSocket 连接,成功后,Xray 将 conn 发给 channel
  3. 需要 dial 时,Xray 从 channel 接收一个可用的 conn,并发送目标 URL 和可选的 early data
  4. JS 成功 dial 目标后告知 Xray,并继续用这个 conn 全双工双向转发数据,连接关闭行为同步
  5. 注意这个 conn 用过了就会被关闭,但 JS 会确保始终有新空闲连接可用

Early data

根据浏览器的需求,对 early data 机制进行了如下调整:

  1. 服务端响应的 header 会带有请求的 Sec-WebSocket-Protocol,这也初步混淆了 WSS 握手响应的长度特征
  2. 用于浏览器的 early data 编码是 base64.RawURLEncoding 而不是 StdEncoding,服务端做了兼容

此外,由于 #375 推荐 ?ed=2048,这个 PR 顺便将服务端一处 MaxHeaderBytes 扩至了 4096(虽然好像不改也没问题)

Configuration

这是一个探索的过程,目前两边都是 Xray-core v1.4.1 时的配置方式:

  1. 准备一份可用的 WSS 配置,注意 address 必须填域名,若需要指定 IP,请配置 DNS 或系统 hosts
  2. 若浏览器的流量也会经过 Xray-core,务必将这个域名设为直连,否则会造成流量回环
  3. 设置环境变量指定要监听的地址端口,比如 XRAY_BROWSER_DIALER = 127.0.0.1:8080
  4. 先运行 Xray-core,再用任一浏览器访问上面指定的地址端口,还可以 F12 看 Console 和 Network

浏览器会限制 WebSocket 连接数,所以建议开启 Xray-core 的 Mux,之后我会修一些 Mux、WS 的历史遗留问题

@RPRX RPRX mentioned this pull request Mar 21, 2021
wwqgtxx added a commit to wwqgtxx/wstunnel that referenced this pull request Mar 22, 2021
@RPRX RPRX merged commit d46af8b into main Mar 23, 2021
@RPRX RPRX deleted the browser-dialer branch March 23, 2021 09:25
@RPRX
Copy link
Member Author

RPRX commented Mar 23, 2021

Update dialer.html e0910ab

@RPRX RPRX mentioned this pull request Mar 29, 2021
@RPRX
Copy link
Member Author

RPRX commented Mar 31, 2021

我要把

@RPRX
Copy link
Member Author

RPRX commented Mar 31, 2021

这个

@RPRX
Copy link
Member Author

RPRX commented Mar 31, 2021

刷上去

@rurirei rurirei mentioned this pull request Apr 1, 2021
1715173329 added a commit to 1715173329/packages-official that referenced this pull request Apr 2, 2021
Since v1.4.1, Xray has introduced a new feature to transfer data via
browsers, which can disguise itself as a normal browser to cheat
network censorship.

For more details, see XTLS/Xray-core#421.

Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
1715173329 added a commit to immortalwrt/packages that referenced this pull request Apr 2, 2021
Since v1.4.1, Xray has introduced a new feature to transfer data via
browsers, which can disguise itself as a normal browser to cheat
network censorship.

For more details, see XTLS/Xray-core#421.

Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
1715173329 added a commit to 1715173329/packages-official that referenced this pull request Apr 2, 2021
Since v1.4.1, Xray has introduced a new feature to transfer data via
browsers, which can disguise itself as a normal browser to cheat
network censorship.

For more details, see XTLS/Xray-core#421.

Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
(backported from 736667c)
zxlhhyccc added a commit to zxlhhyccc/bf-package-master that referenced this pull request Apr 2, 2021
Since v1.4.1, Xray has introduced a new feature to transfer data via
browsers, which can disguise itself as a normal browser to cheat
network censorship.

For more details, see XTLS/Xray-core#421.
Lienol pushed a commit to Lienol/openwrt-packages that referenced this pull request Apr 6, 2021
Since v1.4.1, Xray has introduced a new feature to transfer data via
browsers, which can disguise itself as a normal browser to cheat
network censorship.

For more details, see XTLS/Xray-core#421.

Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
Lienol pushed a commit to Lienol/openwrt-packages that referenced this pull request Nov 19, 2021
Since v1.4.1, Xray has introduced a new feature to transfer data via
browsers, which can disguise itself as a normal browser to cheat
network censorship.

For more details, see XTLS/Xray-core#421.

Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
Lienol pushed a commit to Lienol/openwrt-packages that referenced this pull request Dec 19, 2021
Since v1.4.1, Xray has introduced a new feature to transfer data via
browsers, which can disguise itself as a normal browser to cheat
network censorship.

For more details, see XTLS/Xray-core#421.

Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
Lienol pushed a commit to Lienol/openwrt-packages that referenced this pull request Feb 11, 2022
Since v1.4.1, Xray has introduced a new feature to transfer data via
browsers, which can disguise itself as a normal browser to cheat
network censorship.

For more details, see XTLS/Xray-core#421.

Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
Lienol pushed a commit to Lienol/openwrt-packages that referenced this pull request Jan 4, 2023
Since v1.4.1, Xray has introduced a new feature to transfer data via
browsers, which can disguise itself as a normal browser to cheat
network censorship.

For more details, see XTLS/Xray-core#421.

Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
Lienol pushed a commit to Lienol/openwrt-packages that referenced this pull request Mar 2, 2024
Since v1.4.1, Xray has introduced a new feature to transfer data via
browsers, which can disguise itself as a normal browser to cheat
network censorship.

For more details, see XTLS/Xray-core#421.

Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
@RPRX RPRX mentioned this pull request Mar 17, 2024
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.

1 participant