From af1593f14e8019fd3c21d4d397c81d96c7497bc7 Mon Sep 17 00:00:00 2001 From: Random Guy <50927468+M03ED@users.noreply.github.com> Date: Sun, 28 Apr 2024 16:05:35 +0330 Subject: [PATCH] fix: early data for clash --- app/subscription/clash.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/app/subscription/clash.py b/app/subscription/clash.py index 7e540d17c..ffda30796 100644 --- a/app/subscription/clash.py +++ b/app/subscription/clash.py @@ -77,6 +77,14 @@ def make_node(self, 'udp': udp } + if "?ed=" in path: + path, max_early_data = path.split("?ed=") + max_early_data, = max_early_data.split("/") + max_early_data = int(max_early_data) + early_data_header_name = "Sec-WebSocket-Protocol" + else: + max_early_data = None + if type == 'ss': # shadowsocks return node @@ -101,11 +109,18 @@ def make_node(self, net_opts['method'] = 'GET' net_opts['Host'] = host - if network == 'ws': + if network == 'ws' or network == 'httpupgrade': if path: net_opts['path'] = path if host: net_opts['headers'] = {"Host": host} + if max_early_data: + net_opts['max-early-data'] = max_early_data + net_opts['early-data-header-name'] = early_data_header_name + if network == 'httpupgrade': + net_opts['v2ray-http-upgrade'] = True + if max_early_data: + net_opts['v2ray-http-upgrade-fast-open'] = True if network == 'grpc': if path: