mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-06-04 11:13:59 +08:00
feat: VMess 支持 kcp/quic(正确处理 type, host, path, fp, alpn, tls等参数)
This commit is contained in:
parent
9e0028219d
commit
37fc7ac88e
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sub-store",
|
"name": "sub-store",
|
||||||
"version": "2.19.52",
|
"version": "2.19.54",
|
||||||
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
|
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
|
||||||
"main": "src/main.js",
|
"main": "src/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -439,7 +439,16 @@ function URI_VMess() {
|
|||||||
type: 'vmess',
|
type: 'vmess',
|
||||||
server,
|
server,
|
||||||
port,
|
port,
|
||||||
cipher: getIfPresent(params.scy, 'auto'),
|
// https://github.com/2dust/v2rayN/wiki/Description-of-VMess-share-link
|
||||||
|
// https://github.com/XTLS/Xray-core/issues/91
|
||||||
|
cipher: [
|
||||||
|
'auto',
|
||||||
|
'aes-128-gcm',
|
||||||
|
'chacha20-poly1305',
|
||||||
|
'none',
|
||||||
|
].includes(params.scy)
|
||||||
|
? params.scy
|
||||||
|
: 'auto',
|
||||||
uuid: params.id,
|
uuid: params.id,
|
||||||
alterId: parseInt(
|
alterId: parseInt(
|
||||||
getIfPresent(params.aid ?? params.alterId, 0),
|
getIfPresent(params.aid ?? params.alterId, 0),
|
||||||
@ -473,8 +482,8 @@ function URI_VMess() {
|
|||||||
['http'].includes(params.type)
|
['http'].includes(params.type)
|
||||||
) {
|
) {
|
||||||
proxy.network = 'http';
|
proxy.network = 'http';
|
||||||
} else if (['grpc'].includes(params.net)) {
|
} else if (['grpc', 'kcp', 'quic'].includes(params.net)) {
|
||||||
proxy.network = 'grpc';
|
proxy.network = params.net;
|
||||||
} else if (
|
} else if (
|
||||||
params.net === 'httpupgrade' ||
|
params.net === 'httpupgrade' ||
|
||||||
proxy.network === 'httpupgrade'
|
proxy.network === 'httpupgrade'
|
||||||
@ -524,13 +533,28 @@ function URI_VMess() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 传输层应该有配置, 暂时不考虑兼容不给配置的节点
|
// 传输层应该有配置, 暂时不考虑兼容不给配置的节点
|
||||||
if (transportPath || transportHost) {
|
if (
|
||||||
|
transportPath ||
|
||||||
|
transportHost ||
|
||||||
|
['kcp', 'quic'].includes(proxy.network)
|
||||||
|
) {
|
||||||
if (['grpc'].includes(proxy.network)) {
|
if (['grpc'].includes(proxy.network)) {
|
||||||
proxy[`${proxy.network}-opts`] = {
|
proxy[`${proxy.network}-opts`] = {
|
||||||
'grpc-service-name': getIfNotBlank(transportPath),
|
'grpc-service-name': getIfNotBlank(transportPath),
|
||||||
'_grpc-type': getIfNotBlank(params.type),
|
'_grpc-type': getIfNotBlank(params.type),
|
||||||
'_grpc-authority': getIfNotBlank(params.authority),
|
'_grpc-authority': getIfNotBlank(params.authority),
|
||||||
};
|
};
|
||||||
|
} else if (['kcp', 'quic'].includes(proxy.network)) {
|
||||||
|
proxy[`${proxy.network}-opts`] = {
|
||||||
|
[`_${proxy.network}-type`]: getIfNotBlank(
|
||||||
|
params.type,
|
||||||
|
),
|
||||||
|
[`_${proxy.network}-host`]: getIfNotBlank(
|
||||||
|
getIfNotBlank(transportHost),
|
||||||
|
),
|
||||||
|
[`_${proxy.network}-path`]:
|
||||||
|
getIfNotBlank(transportPath),
|
||||||
|
};
|
||||||
} else {
|
} else {
|
||||||
const opts = {
|
const opts = {
|
||||||
path: getIfNotBlank(transportPath),
|
path: getIfNotBlank(transportPath),
|
||||||
@ -546,6 +570,12 @@ function URI_VMess() {
|
|||||||
delete proxy.network;
|
delete proxy.network;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
proxy['client-fingerprint'] = params.fp;
|
||||||
|
proxy.alpn = params.alpn ? params.alpn.split(',') : undefined;
|
||||||
|
// 然而 wiki 和 app 实测中都没有字段表示这个
|
||||||
|
// proxy['skip-cert-verify'] = /(TRUE)|1/i.test(params.allowInsecure);
|
||||||
|
|
||||||
return proxy;
|
return proxy;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -119,12 +119,17 @@ export default function URI_Producer() {
|
|||||||
v: '2',
|
v: '2',
|
||||||
ps: proxy.name,
|
ps: proxy.name,
|
||||||
add: proxy.server,
|
add: proxy.server,
|
||||||
port: proxy.port,
|
port: `${proxy.port}`,
|
||||||
id: proxy.uuid,
|
id: proxy.uuid,
|
||||||
type,
|
aid: `${proxy.alterId || 0}`,
|
||||||
aid: proxy.alterId || 0,
|
scy: proxy.cipher,
|
||||||
net,
|
net,
|
||||||
|
type,
|
||||||
tls: proxy.tls ? 'tls' : '',
|
tls: proxy.tls ? 'tls' : '',
|
||||||
|
alpn: Array.isArray(proxy.alpn)
|
||||||
|
? proxy.alpn.join(',')
|
||||||
|
: proxy.alpn,
|
||||||
|
fp: proxy['client-fingerprint'],
|
||||||
};
|
};
|
||||||
if (proxy.tls && proxy.sni) {
|
if (proxy.tls && proxy.sni) {
|
||||||
result.sni = proxy.sni;
|
result.sni = proxy.sni;
|
||||||
@ -135,16 +140,7 @@ export default function URI_Producer() {
|
|||||||
proxy[`${proxy.network}-opts`]?.path;
|
proxy[`${proxy.network}-opts`]?.path;
|
||||||
let vmessTransportHost =
|
let vmessTransportHost =
|
||||||
proxy[`${proxy.network}-opts`]?.headers?.Host;
|
proxy[`${proxy.network}-opts`]?.headers?.Host;
|
||||||
if (vmessTransportPath) {
|
|
||||||
result.path = Array.isArray(vmessTransportPath)
|
|
||||||
? vmessTransportPath[0]
|
|
||||||
: vmessTransportPath;
|
|
||||||
}
|
|
||||||
if (vmessTransportHost) {
|
|
||||||
result.host = Array.isArray(vmessTransportHost)
|
|
||||||
? vmessTransportHost[0]
|
|
||||||
: vmessTransportHost;
|
|
||||||
}
|
|
||||||
if (['grpc'].includes(proxy.network)) {
|
if (['grpc'].includes(proxy.network)) {
|
||||||
result.path =
|
result.path =
|
||||||
proxy[`${proxy.network}-opts`]?.[
|
proxy[`${proxy.network}-opts`]?.[
|
||||||
@ -156,6 +152,31 @@ export default function URI_Producer() {
|
|||||||
'gun';
|
'gun';
|
||||||
result.host =
|
result.host =
|
||||||
proxy[`${proxy.network}-opts`]?.['_grpc-authority'];
|
proxy[`${proxy.network}-opts`]?.['_grpc-authority'];
|
||||||
|
} else if (['kcp', 'quic'].includes(proxy.network)) {
|
||||||
|
// https://github.com/XTLS/Xray-core/issues/91
|
||||||
|
result.type =
|
||||||
|
proxy[`${proxy.network}-opts`]?.[
|
||||||
|
`_${proxy.network}-type`
|
||||||
|
] || 'none';
|
||||||
|
result.host =
|
||||||
|
proxy[`${proxy.network}-opts`]?.[
|
||||||
|
`_${proxy.network}-host`
|
||||||
|
];
|
||||||
|
result.path =
|
||||||
|
proxy[`${proxy.network}-opts`]?.[
|
||||||
|
`_${proxy.network}-path`
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
if (vmessTransportPath) {
|
||||||
|
result.path = Array.isArray(vmessTransportPath)
|
||||||
|
? vmessTransportPath[0]
|
||||||
|
: vmessTransportPath;
|
||||||
|
}
|
||||||
|
if (vmessTransportHost) {
|
||||||
|
result.host = Array.isArray(vmessTransportHost)
|
||||||
|
? vmessTransportHost[0]
|
||||||
|
: vmessTransportHost;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result = 'vmess://' + Base64.encode(JSON.stringify(result));
|
result = 'vmess://' + Base64.encode(JSON.stringify(result));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user