mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-08-11 01:29:00 +08:00
fix: servername/sni priority over wss host
This commit is contained in:
parent
9ac1112b37
commit
feb207b333
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "sub-store",
|
||||
"version": "2.14.18",
|
||||
"version": "2.14.20",
|
||||
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
|
||||
"main": "src/main.js",
|
||||
"scripts": {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import download from '@/utils/download';
|
||||
|
||||
import { isIPv4, isIPv6 } from '@/utils';
|
||||
import PROXY_PROCESSORS, { ApplyProcessor } from './processors';
|
||||
import PROXY_PREPROCESSORS from './preprocessors';
|
||||
import PROXY_PRODUCERS from './producers';
|
||||
@ -36,6 +36,10 @@ function parse(raw) {
|
||||
if (lastParser) {
|
||||
const [proxy, error] = tryParse(lastParser, line);
|
||||
if (!error) {
|
||||
// 前面已经处理过普通情况下的 SNI, 这里显式设置 SNI, 防止之后解析成 IP 后丢失域名 SNI
|
||||
if (proxy.tls && !proxy.sni && !isIP(proxy.server)) {
|
||||
proxy.sni = proxy.server;
|
||||
}
|
||||
proxies.push(proxy);
|
||||
success = true;
|
||||
}
|
||||
@ -182,3 +186,7 @@ function safeMatch(parser, line) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function isIP(ip) {
|
||||
return isIPv4(ip) || isIPv6(ip);
|
||||
}
|
||||
|
@ -224,6 +224,10 @@ function URI_VMess() {
|
||||
? !params.verify_cert
|
||||
: undefined,
|
||||
};
|
||||
// https://github.com/2dust/v2rayN/wiki/%E5%88%86%E4%BA%AB%E9%93%BE%E6%8E%A5%E6%A0%BC%E5%BC%8F%E8%AF%B4%E6%98%8E(ver-2)
|
||||
if (proxy.tls && proxy.sni) {
|
||||
proxy.sni = params.sni;
|
||||
}
|
||||
// handle obfs
|
||||
if (params.net === 'ws') {
|
||||
proxy.network = 'ws';
|
||||
@ -231,7 +235,9 @@ function URI_VMess() {
|
||||
path: getIfNotBlank(params.path),
|
||||
headers: { Host: getIfNotBlank(params.host) },
|
||||
};
|
||||
if (proxy.tls && params.host) {
|
||||
// https://github.com/MetaCubeX/Clash.Meta/blob/Alpha/docs/config.yaml#L413
|
||||
// sni 优先级应高于 host
|
||||
if (proxy.tls && !proxy.sni && params.host) {
|
||||
proxy.sni = params.host;
|
||||
}
|
||||
}
|
||||
|
@ -65,10 +65,15 @@ export default function URI_Producer() {
|
||||
net: proxy.network || 'tcp',
|
||||
tls: proxy.tls ? 'tls' : '',
|
||||
};
|
||||
if (proxy.tls && proxy.sni) {
|
||||
result.sni = proxy.sni;
|
||||
}
|
||||
// obfs
|
||||
if (proxy.network === 'ws') {
|
||||
result.path = proxy['ws-opts'].path || '/';
|
||||
result.host = proxy['ws-opts'].headers.Host || proxy.server;
|
||||
if (proxy['ws-opts'].headers.Host) {
|
||||
result.host = proxy['ws-opts'].headers.Host;
|
||||
}
|
||||
}
|
||||
result = 'vmess://' + Base64.encode(JSON.stringify(result));
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user