Skip to content

Commit

Permalink
fix: early data for clash
Browse files Browse the repository at this point in the history
  • Loading branch information
M03ED committed Apr 28, 2024
1 parent 12b21b1 commit af1593f
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion app/subscription/clash.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:
Expand Down

0 comments on commit af1593f

Please sign in to comment.