Skip to content

Commit 1867986

Browse files
committed
修复ECH功能:启用时伪装成Chrome浏览器,添加alpn参数
1 parent 8b96bb5 commit 1867986

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

明文源吗

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1589,14 +1589,15 @@
15891589
encryption: 'none',
15901590
security: 'tls',
15911591
sni: workerDomain,
1592-
fp: 'randomized',
1592+
fp: enableECH ? 'chrome' : 'randomized',
15931593
type: 'ws',
15941594
host: workerDomain,
15951595
path: wsPath
15961596
});
15971597

1598-
// 如果启用了ECH且有ECH配置,添加ech参数
1598+
// 如果启用了ECH且有ECH配置,添加ech参数(ECH需要伪装成Chrome浏览器)
15991599
if (enableECH && echConfig) {
1600+
wsParams.set('alpn', 'h3,h2,http/1.1');
16001601
wsParams.set('ech', echConfig);
16011602
}
16021603

@@ -1673,8 +1674,9 @@
16731674
path: wsPath
16741675
});
16751676

1676-
// 如果启用了ECH且有ECH配置,添加ech参数
1677+
// 如果启用了ECH且有ECH配置,添加ech参数(ECH需要伪装成Chrome浏览器)
16771678
if (enableECH && echConfig) {
1679+
wsParams.set('alpn', 'h3,h2,http/1.1');
16781680
wsParams.set('ech', echConfig);
16791681
}
16801682

@@ -5296,11 +5298,11 @@
52965298
if (CF_HTTPS_PORTS.includes(port)) {
52975299

52985300
const wsNodeName = `${nodeName}-${port}-WS-TLS`;
5299-
let link = `${proto}://${user}@${item.ip}:${port}?encryption=none&security=tls&sni=${workerDomain}&fp=randomized&type=ws&host=${workerDomain}&path=${wsPath}`;
5301+
let link = `${proto}://${user}@${item.ip}:${port}?encryption=none&security=tls&sni=${workerDomain}&fp=${enableECH ? 'chrome' : 'randomized'}&type=ws&host=${workerDomain}&path=${wsPath}`;
53005302

5301-
// 如果启用了ECH且有ECH配置,添加ech参数
5303+
// 如果启用了ECH且有ECH配置,添加ech参数(ECH需要伪装成Chrome浏览器)
53025304
if (enableECH && echConfig) {
5303-
link += `&ech=${encodeURIComponent(echConfig)}`;
5305+
link += `&alpn=h3%2Ch2%2Chttp%2F1.1&ech=${encodeURIComponent(echConfig)}`;
53045306
}
53055307

53065308
link += `#${encodeURIComponent(wsNodeName)}`;
@@ -5315,11 +5317,11 @@
53155317
} else {
53165318

53175319
const wsNodeName = `${nodeName}-${port}-WS-TLS`;
5318-
let link = `${proto}://${user}@${item.ip}:${port}?encryption=none&security=tls&sni=${workerDomain}&fp=randomized&type=ws&host=${workerDomain}&path=${wsPath}`;
5320+
let link = `${proto}://${user}@${item.ip}:${port}?encryption=none&security=tls&sni=${workerDomain}&fp=${enableECH ? 'chrome' : 'randomized'}&type=ws&host=${workerDomain}&path=${wsPath}`;
53195321

5320-
// 如果启用了ECH且有ECH配置,添加ech参数
5322+
// 如果启用了ECH且有ECH配置,添加ech参数(ECH需要伪装成Chrome浏览器)
53215323
if (enableECH && echConfig) {
5322-
link += `&ech=${encodeURIComponent(echConfig)}`;
5324+
link += `&alpn=h3%2Ch2%2Chttp%2F1.1&ech=${encodeURIComponent(echConfig)}`;
53235325
}
53245326

53255327
link += `#${encodeURIComponent(wsNodeName)}`;
@@ -5353,8 +5355,9 @@
53535355
mode: 'stream-one'
53545356
});
53555357

5356-
// 如果启用了ECH且有ECH配置,添加ech参数
5358+
// 如果启用了ECH且有ECH配置,添加ech参数(ECH需要伪装成Chrome浏览器)
53575359
if (enableECH && echConfig) {
5360+
params.set('alpn', 'h3,h2,http/1.1');
53585361
params.set('ech', echConfig);
53595362
}
53605363

@@ -5383,9 +5386,9 @@
53835386
const wsNodeName = `${nodeName}-${port}-${atob('VHJvamFu')}-WS-TLS`;
53845387
let link = `${atob('dHJvamFuOi8v')}${password}@${item.ip}:${port}?security=tls&sni=${workerDomain}&fp=chrome&type=ws&host=${workerDomain}&path=${wsPath}`;
53855388

5386-
// 如果启用了ECH且有ECH配置,添加ech参数
5389+
// 如果启用了ECH且有ECH配置,添加ech参数(ECH需要伪装成Chrome浏览器)
53875390
if (enableECH && echConfig) {
5388-
link += `&ech=${encodeURIComponent(echConfig)}`;
5391+
link += `&alpn=h3%2Ch2%2Chttp%2F1.1&ech=${encodeURIComponent(echConfig)}`;
53895392
}
53905393

53915394
link += `#${encodeURIComponent(wsNodeName)}`;
@@ -5402,9 +5405,9 @@
54025405
const wsNodeName = `${nodeName}-${port}-${atob('VHJvamFu')}-WS-TLS`;
54035406
let link = `${atob('dHJvamFuOi8v')}${password}@${item.ip}:${port}?security=tls&sni=${workerDomain}&fp=chrome&type=ws&host=${workerDomain}&path=${wsPath}`;
54045407

5405-
// 如果启用了ECH且有ECH配置,添加ech参数
5408+
// 如果启用了ECH且有ECH配置,添加ech参数(ECH需要伪装成Chrome浏览器)
54065409
if (enableECH && echConfig) {
5407-
link += `&ech=${encodeURIComponent(echConfig)}`;
5410+
link += `&alpn=h3%2Ch2%2Chttp%2F1.1&ech=${encodeURIComponent(echConfig)}`;
54085411
}
54095412

54105413
link += `#${encodeURIComponent(wsNodeName)}`;

0 commit comments

Comments
 (0)