fix: Vmess auto/none cipher parsed incorrectly

This commit is contained in:
Peng-YM 2022-07-11 23:33:06 +08:00
parent b143476e71
commit de892aaa2b
12 changed files with 41 additions and 37 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{ {
"name": "sub-store", "name": "sub-store",
"version": "2.10.1", "version": "2.10.2",
"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": {

View File

@ -56,7 +56,7 @@ shadowsocks = tag equals "shadowsocks"i address method password (obfs_ss/obfs_ho
} }
vmess = tag equals "vmess"i address method uuid (transport/transport_host/transport_path/over_tls/tls_host/tls_verification/vmess_alterId/fast_open/udp_relay/others)* { vmess = tag equals "vmess"i address method uuid (transport/transport_host/transport_path/over_tls/tls_host/tls_verification/vmess_alterId/fast_open/udp_relay/others)* {
proxy.type = "vmess"; proxy.type = "vmess";
proxy.cipher = proxy.cipher || "auto"; proxy.cipher = proxy.cipher || "none";
proxy.alterId = proxy.alterId || 0; proxy.alterId = proxy.alterId || 0;
handleTransport(); handleTransport();
} }
@ -112,10 +112,9 @@ port = digits:[0-9]+ {
} }
method = comma cipher:cipher { method = comma cipher:cipher {
if (cipher !== 'none') proxy.cipher = cipher; proxy.cipher = cipher;
else proxy.cipher = 'auto'; }
} cipher = ("aes-128-gcm"/"aes-192-gcm"/"aes-256-gcm"/"aes-128-cfb"/"aes-192-cfb"/"aes-256-cfb"/"aes-128-ctr"/"aes-192-ctr"/"aes-256-ctr"/"rc4-md5"/"chacha20-ietf-poly1305"/"chacha20-ietf"/"chacha20-poly1305"/"chacha20"/"none"/"auto");
cipher = ("aes-128-gcm"/"aes-192-gcm"/"aes-256-gcm"/"aes-128-cfb"/"aes-192-cfb"/"aes-256-cfb"/"aes-128-ctr"/"aes-192-ctr"/"aes-256-ctr"/"rc4-md5"/"chacha20-ietf-poly1305"/"chacha20-ietf"/"chacha20-poly1305"/"chacha20"/"none");
username = & { username = & {
let j = peg$currPos; let j = peg$currPos;

View File

@ -54,7 +54,7 @@ shadowsocks = tag equals "shadowsocks"i address method password (obfs_ss/obfs_ho
} }
vmess = tag equals "vmess"i address method uuid (transport/transport_host/transport_path/over_tls/tls_host/tls_verification/vmess_alterId/fast_open/udp_relay/others)* { vmess = tag equals "vmess"i address method uuid (transport/transport_host/transport_path/over_tls/tls_host/tls_verification/vmess_alterId/fast_open/udp_relay/others)* {
proxy.type = "vmess"; proxy.type = "vmess";
proxy.cipher = proxy.cipher || "auto"; proxy.cipher = proxy.cipher || "none";
proxy.alterId = proxy.alterId || 0; proxy.alterId = proxy.alterId || 0;
handleTransport(); handleTransport();
} }
@ -110,10 +110,9 @@ port = digits:[0-9]+ {
} }
method = comma cipher:cipher { method = comma cipher:cipher {
if (cipher !== 'none') proxy.cipher = cipher; proxy.cipher = cipher;
else proxy.cipher = 'auto'; }
} cipher = ("aes-128-gcm"/"aes-192-gcm"/"aes-256-gcm"/"aes-128-cfb"/"aes-192-cfb"/"aes-256-cfb"/"aes-128-ctr"/"aes-192-ctr"/"aes-256-ctr"/"rc4-md5"/"chacha20-ietf-poly1305"/"chacha20-ietf"/"chacha20-poly1305"/"chacha20"/"none"/"auto");
cipher = ("aes-128-gcm"/"aes-192-gcm"/"aes-256-gcm"/"aes-128-cfb"/"aes-192-cfb"/"aes-256-cfb"/"aes-128-ctr"/"aes-192-ctr"/"aes-256-ctr"/"rc4-md5"/"chacha20-ietf-poly1305"/"chacha20-ietf"/"chacha20-poly1305"/"chacha20"/"none");
username = & { username = & {
let j = peg$currPos; let j = peg$currPos;

View File

@ -82,7 +82,7 @@ shadowsocks = "shadowsocks" equals address
vmess = "vmess" equals address vmess = "vmess" equals address
(uuid/method/over_tls/tls_host/tls_fingerprint/tls_verification/tag/obfs/obfs_host/obfs_uri/udp_relay/udp_over_tcp/fast_open/aead/others)* { (uuid/method/over_tls/tls_host/tls_fingerprint/tls_verification/tag/obfs/obfs_host/obfs_uri/udp_relay/udp_over_tcp/fast_open/aead/others)* {
proxy.type = "vmess"; proxy.type = "vmess";
proxy.cipher = proxy.cipher || "auto"; proxy.cipher = proxy.cipher || "none";
if (proxy.aead) { if (proxy.aead) {
proxy.alterId = 0; proxy.alterId = 0;
} else { } else {
@ -140,8 +140,7 @@ password = comma "password" equals password:[^=,]+ { proxy.password = password.j
uuid = comma "password" equals uuid:[^=,]+ { proxy.uuid = uuid.join("").trim(); } uuid = comma "password" equals uuid:[^=,]+ { proxy.uuid = uuid.join("").trim(); }
method = comma "method" equals cipher:cipher { method = comma "method" equals cipher:cipher {
if (cipher !== 'none') proxy.cipher = cipher; proxy.cipher = cipher;
else proxy.cipher = 'auto';
}; };
cipher = ("aes-128-gcm"/"aes-192-gcm"/"aes-256-gcm"/"aes-128-cfb"/"aes-192-cfb"/"aes-256-cfb"/"aes-128-ctr"/"aes-192-ctr"/"aes-256-ctr"/"rc4-md5"/"chacha20-ietf-poly1305"/"chacha20-ietf"/"chacha20-poly1305"/"chacha20"/"none"); cipher = ("aes-128-gcm"/"aes-192-gcm"/"aes-256-gcm"/"aes-128-cfb"/"aes-192-cfb"/"aes-256-cfb"/"aes-128-ctr"/"aes-192-ctr"/"aes-256-ctr"/"rc4-md5"/"chacha20-ietf-poly1305"/"chacha20-ietf"/"chacha20-poly1305"/"chacha20"/"none");
aead = comma "aead" equals flag:bool { proxy.aead = flag; } aead = comma "aead" equals flag:bool { proxy.aead = flag; }

View File

@ -80,7 +80,7 @@ shadowsocks = "shadowsocks" equals address
vmess = "vmess" equals address vmess = "vmess" equals address
(uuid/method/over_tls/tls_host/tls_fingerprint/tls_verification/tag/obfs/obfs_host/obfs_uri/udp_relay/udp_over_tcp/fast_open/aead/others)* { (uuid/method/over_tls/tls_host/tls_fingerprint/tls_verification/tag/obfs/obfs_host/obfs_uri/udp_relay/udp_over_tcp/fast_open/aead/others)* {
proxy.type = "vmess"; proxy.type = "vmess";
proxy.cipher = proxy.cipher || "auto"; proxy.cipher = proxy.cipher || "none";
if (proxy.aead) { if (proxy.aead) {
proxy.alterId = 0; proxy.alterId = 0;
} else { } else {
@ -138,8 +138,7 @@ password = comma "password" equals password:[^=,]+ { proxy.password = password.j
uuid = comma "password" equals uuid:[^=,]+ { proxy.uuid = uuid.join("").trim(); } uuid = comma "password" equals uuid:[^=,]+ { proxy.uuid = uuid.join("").trim(); }
method = comma "method" equals cipher:cipher { method = comma "method" equals cipher:cipher {
if (cipher !== 'none') proxy.cipher = cipher; proxy.cipher = cipher;
else proxy.cipher = 'auto';
}; };
cipher = ("aes-128-gcm"/"aes-192-gcm"/"aes-256-gcm"/"aes-128-cfb"/"aes-192-cfb"/"aes-256-cfb"/"aes-128-ctr"/"aes-192-ctr"/"aes-256-ctr"/"rc4-md5"/"chacha20-ietf-poly1305"/"chacha20-ietf"/"chacha20-poly1305"/"chacha20"/"none"); cipher = ("aes-128-gcm"/"aes-192-gcm"/"aes-256-gcm"/"aes-128-cfb"/"aes-192-cfb"/"aes-256-cfb"/"aes-128-ctr"/"aes-192-ctr"/"aes-256-ctr"/"rc4-md5"/"chacha20-ietf-poly1305"/"chacha20-ietf"/"chacha20-poly1305"/"chacha20"/"none");
aead = comma "aead" equals flag:bool { proxy.aead = flag; } aead = comma "aead" equals flag:bool { proxy.aead = flag; }

View File

@ -45,7 +45,7 @@ shadowsocks = tag equals "ss" address (method/passwordk/obfs/obfs_host/obfs_uri/
} }
vmess = tag equals "vmess" address (vmess_uuid/vmess_aead/ws/ws_path/ws_headers/method/tls/sni/tls_fingerprint/tls_verification/fast_open/udp_relay/others)* { vmess = tag equals "vmess" address (vmess_uuid/vmess_aead/ws/ws_path/ws_headers/method/tls/sni/tls_fingerprint/tls_verification/fast_open/udp_relay/others)* {
proxy.type = "vmess"; proxy.type = "vmess";
proxy.cipher = proxy.cipher || "auto"; proxy.cipher = proxy.cipher || "none";
if (proxy.aead) { if (proxy.aead) {
proxy.alterId = 0; proxy.alterId = 0;
} else { } else {
@ -152,8 +152,7 @@ vmess_uuid = comma "username" equals match:[^,]+ { proxy.uuid = match.join("");
vmess_aead = comma "vmess-aead" equals flag:bool { proxy.aead = flag; } vmess_aead = comma "vmess-aead" equals flag:bool { proxy.aead = flag; }
method = comma "encrypt-method" equals cipher:cipher { method = comma "encrypt-method" equals cipher:cipher {
if (cipher !== 'none') proxy.cipher = cipher; proxy.cipher = cipher;
else proxy.cipher = 'auto';
} }
cipher = ("aes-128-gcm"/"aes-192-gcm"/"aes-256-gcm"/"aes-128-cfb"/"aes-192-cfb"/"aes-256-cfb"/"aes-128-ctr"/"aes-192-ctr"/"aes-256-ctr"/"rc4-md5"/"chacha20-ietf-poly1305"/"chacha20-ietf"/"chacha20-poly1305"/"chacha20"/"none"); cipher = ("aes-128-gcm"/"aes-192-gcm"/"aes-256-gcm"/"aes-128-cfb"/"aes-192-cfb"/"aes-256-cfb"/"aes-128-ctr"/"aes-192-ctr"/"aes-256-ctr"/"rc4-md5"/"chacha20-ietf-poly1305"/"chacha20-ietf"/"chacha20-poly1305"/"chacha20"/"none");

View File

@ -43,7 +43,7 @@ shadowsocks = tag equals "ss" address (method/passwordk/obfs/obfs_host/obfs_uri/
} }
vmess = tag equals "vmess" address (vmess_uuid/vmess_aead/ws/ws_path/ws_headers/method/tls/sni/tls_fingerprint/tls_verification/fast_open/udp_relay/others)* { vmess = tag equals "vmess" address (vmess_uuid/vmess_aead/ws/ws_path/ws_headers/method/tls/sni/tls_fingerprint/tls_verification/fast_open/udp_relay/others)* {
proxy.type = "vmess"; proxy.type = "vmess";
proxy.cipher = proxy.cipher || "auto"; proxy.cipher = proxy.cipher || "none";
if (proxy.aead) { if (proxy.aead) {
proxy.alterId = 0; proxy.alterId = 0;
} else { } else {
@ -150,8 +150,7 @@ vmess_uuid = comma "username" equals match:[^,]+ { proxy.uuid = match.join("");
vmess_aead = comma "vmess-aead" equals flag:bool { proxy.aead = flag; } vmess_aead = comma "vmess-aead" equals flag:bool { proxy.aead = flag; }
method = comma "encrypt-method" equals cipher:cipher { method = comma "encrypt-method" equals cipher:cipher {
if (cipher !== 'none') proxy.cipher = cipher; proxy.cipher = cipher;
else proxy.cipher = 'auto';
} }
cipher = ("aes-128-gcm"/"aes-192-gcm"/"aes-256-gcm"/"aes-128-cfb"/"aes-192-cfb"/"aes-256-cfb"/"aes-128-ctr"/"aes-192-ctr"/"aes-256-ctr"/"rc4-md5"/"chacha20-ietf-poly1305"/"chacha20-ietf"/"chacha20-poly1305"/"chacha20"/"none"); cipher = ("aes-128-gcm"/"aes-192-gcm"/"aes-256-gcm"/"aes-128-cfb"/"aes-192-cfb"/"aes-256-cfb"/"aes-128-ctr"/"aes-192-ctr"/"aes-256-ctr"/"rc4-md5"/"chacha20-ietf-poly1305"/"chacha20-ietf"/"chacha20-poly1305"/"chacha20"/"none");

View File

@ -1,4 +1,5 @@
import { isPresent, Result } from './utils'; import { isPresent, Result } from './utils';
const targetPlatform = 'QX'; const targetPlatform = 'QX';
export default function QX_Producer() { export default function QX_Producer() {
@ -180,7 +181,16 @@ function vmess(proxy) {
const appendIfPresent = result.appendIfPresent.bind(result); const appendIfPresent = result.appendIfPresent.bind(result);
append(`vmess=${proxy.server}:${proxy.port}`); append(`vmess=${proxy.server}:${proxy.port}`);
append(`,method=${proxy.cipher === 'auto' ? 'none' : proxy.cipher}`);
// cipher
let cipher;
if (proxy.cipher === 'auto') {
cipher = 'chacha20-ietf-poly1305';
} else {
cipher = proxy.cipher;
}
append(`,method=${cipher}`);
append(`,password=${proxy.uuid}`); append(`,password=${proxy.uuid}`);
// obfs // obfs

View File

@ -251,7 +251,7 @@ function createTestCases() {
server, server,
port, port,
uuid, uuid,
cipher: 'auto', // Surge lacks support for specifying cipher for vmess protocol! cipher: 'none', // Surge lacks support for specifying cipher for vmess protocol!
alterId: 0, alterId: 0,
}, },
}, },
@ -288,7 +288,7 @@ function createTestCases() {
server, server,
port, port,
uuid, uuid,
cipher: 'auto', // Surge lacks support for specifying cipher for vmess protocol! cipher: 'none', // Surge lacks support for specifying cipher for vmess protocol!
alterId: 0, alterId: 0,
aead: true, aead: true,
}, },
@ -339,7 +339,7 @@ function createTestCases() {
server, server,
port, port,
uuid, uuid,
cipher: 'auto', // Surge lacks support for specifying cipher for vmess protocol! cipher: 'none', // Surge lacks support for specifying cipher for vmess protocol!
network: 'ws', network: 'ws',
'ws-opts': { 'ws-opts': {
path: obfs_path, path: obfs_path,
@ -402,7 +402,7 @@ function createTestCases() {
server, server,
port, port,
uuid, uuid,
cipher: 'auto', // Surge lacks support for specifying cipher for vmess protocol! cipher: 'none', // Surge lacks support for specifying cipher for vmess protocol!
network: 'ws', network: 'ws',
'ws-opts': { 'ws-opts': {
path: obfs_path, path: obfs_path,

File diff suppressed because one or more lines are too long