fix: Failed to parse Surge/QX nodes with tls fingerprint

This commit is contained in:
Peng-YM
2022-07-02 22:53:09 +08:00
parent 606cfed8da
commit 7834fd6056
11 changed files with 46 additions and 14 deletions

View File

@@ -60,6 +60,12 @@ describe('QX', function () {
const proxy = parser.parse(input.QX);
expect(proxy).eql(expected);
});
it('test trojan + tls fingerprint', function () {
const { input, expected } = testcases.TROJAN.TLS_FINGERPRINT;
const proxy = parser.parse(input.QX);
expect(proxy).eql(expected);
});
});
describe('vmess', function () {

View File

@@ -42,6 +42,12 @@ describe('Surge', function () {
const proxy = parser.parse(input.Surge);
expect(proxy).eql(expected);
});
it('test trojan + tls fingerprint', function () {
const { input, expected } = testcases.TROJAN.TLS_FINGERPRINT;
const proxy = parser.parse(input.Surge);
expect(proxy).eql(expected);
});
});
describe('vmess', function () {

View File

@@ -20,6 +20,9 @@ function createTestCases() {
const sni = 'sni.com';
const tls_fingerprint =
'67:1B:C8:F2:D4:60:DD:A7:EE:60:DA:BB:A3:F9:A4:D7:C8:29:0F:3E:2F:75:B6:A9:46:88:48:7D:D3:97:7E:98';
const SS = {
SIMPLE: {
input: {
@@ -198,6 +201,23 @@ function createTestCases() {
sni,
},
},
TLS_FINGERPRINT: {
input: {
QX: `trojan=${server}:${port},password=${password},tls-verification=false,tls-host=${sni},tls-cert-sha256=${tls_fingerprint},tag=${name},over-tls=true`,
Surge: `${name}=trojan,${server},${port},password=${password},skip-cert-verify=true,sni=${sni},tls=true,server-cert-fingerprint-sha256=${tls_fingerprint}`,
},
expected: {
type: 'trojan',
name,
server,
port,
password,
tls: true,
'skip-cert-verify': true,
sni,
'tls-fingerprint': tls_fingerprint,
},
},
};
const VMESS = {
SIMPLE: {