Skip to content

Commit

Permalink
feat: add tls-verification to quantumult x vmess config
Browse files Browse the repository at this point in the history
  • Loading branch information
geekdada committed Mar 18, 2022
1 parent d968a4b commit b24f071
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 15 deletions.
50 changes: 38 additions & 12 deletions lib/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1114,26 +1114,40 @@ export const getQuantumultXNodes = function (
case 'ws':
if (nodeConfig.tls) {
config.push(`obfs=wss`);

if (nodeConfig.skipCertVerify) {
config.push('tls-verification=false');
} else {
config.push('tls-verification=true');
}

// istanbul ignore next
if (nodeConfig.tls13) {
config.push(`tls13=true`);
}
} else {
config.push(`obfs=ws`);
}
config.push(`obfs-uri=${nodeConfig.path || '/'}`);
config.push(
`obfs-host=${nodeConfig.host || nodeConfig.hostname}`,
);
// istanbul ignore next
if (nodeConfig.tls13) {
config.push(`tls13=true`);
}

break;
case 'tcp':
if (nodeConfig.tls) {
config.push(`obfs=over-tls`);
}
// istanbul ignore next
if (nodeConfig.tls13) {
config.push(`tls13=true`);

if (nodeConfig.skipCertVerify) {
config.push('tls-verification=false');
} else {
config.push('tls-verification=true');
}

// istanbul ignore next
if (nodeConfig.tls13) {
config.push(`tls13=true`);
}
}

break;
Expand Down Expand Up @@ -1175,9 +1189,19 @@ export const getQuantumultXNodes = function (
: []),
...(nodeConfig['udp-relay'] ? [`udp-relay=true`] : []),
...(nodeConfig.tfo ? [`fast-open=${nodeConfig.tfo}`] : []),
...(nodeConfig.tls13 ? [`tls13=${nodeConfig.tls13}`] : []),
`tag=${nodeConfig.nodeName}`,
].join(', ');
];

if (nodeConfig.obfs === 'wss') {
if (nodeConfig.skipCertVerify) {
config.push('tls-verification=false');
} else {
config.push('tls-verification=true');
}

if (nodeConfig.tls13) {
config.push('tls13=true');
}
}

// istanbul ignore next
if (
Expand All @@ -1189,7 +1213,9 @@ export const getQuantumultXNodes = function (
);
}

return `shadowsocks=${config}`;
config.push(`tag=${nodeConfig.nodeName}`);

return `shadowsocks=${config.join(', ')}`;
}

case NodeTypeEnum.Shadowsocksr: {
Expand Down
6 changes: 3 additions & 3 deletions test/utils/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1562,7 +1562,7 @@ test('getQuantumultXNodes', (t) => {
);
t.is(
schemeList[6],
'vmess=1.1.1.1:443, method=chacha20-ietf-poly1305, password=1386f85e-657b-4d6e-9d56-78badb75e1fd, aead=false, obfs=over-tls, tag=测试 4',
'vmess=1.1.1.1:443, method=chacha20-ietf-poly1305, password=1386f85e-657b-4d6e-9d56-78badb75e1fd, aead=false, obfs=over-tls, tls-verification=true, tag=测试 4',
);

t.is(
Expand All @@ -1581,7 +1581,7 @@ test('getQuantumultXNodes', (t) => {
uuid: '1386f85e-657b-4d6e-9d56-78badb75e1fd',
},
]),
'vmess=1.1.1.1:443, method=chacha20-ietf-poly1305, password=1386f85e-657b-4d6e-9d56-78badb75e1fd, udp-relay=true, aead=false, obfs=over-tls, tls13=true, tag=测试',
'vmess=1.1.1.1:443, method=chacha20-ietf-poly1305, password=1386f85e-657b-4d6e-9d56-78badb75e1fd, udp-relay=true, aead=false, obfs=over-tls, tls-verification=true, tls13=true, tag=测试',
);

t.is(
Expand All @@ -1603,7 +1603,7 @@ test('getQuantumultXNodes', (t) => {
},
},
]),
'vmess=1.1.1.1:443, method=chacha20-ietf-poly1305, password=1386f85e-657b-4d6e-9d56-78badb75e1fd, udp-relay=true, aead=true, obfs=over-tls, tls13=true, tag=测试',
'vmess=1.1.1.1:443, method=chacha20-ietf-poly1305, password=1386f85e-657b-4d6e-9d56-78badb75e1fd, udp-relay=true, aead=true, obfs=over-tls, tls-verification=true, tls13=true, tag=测试',
);
t.is(
utils.getQuantumultXNodes([
Expand Down

0 comments on commit b24f071

Please sign in to comment.