diff --git a/lib/utils/index.ts b/lib/utils/index.ts index 6df85099e..8d7c59d7d 100644 --- a/lib/utils/index.ts +++ b/lib/utils/index.ts @@ -433,14 +433,6 @@ export const getSurgeNodes = ( configString.push(`addresses = ${config.hostname}`); - if (typeof config.tfo === 'boolean') { - configString.push(`tfo=${config.tfo}`); - } - - if (typeof config.mptcp === 'boolean') { - configString.push(`mptcp=${config.mptcp}`); - } - return ([ config.nodeName, configString.join(', '), @@ -530,14 +522,7 @@ export const getSurgeNodes = ( configString.push(`addresses = ${config.hostname}`); - if (typeof config.tfo === 'boolean') { - configString.push(`tfo=${config.tfo}`); - } - - if (typeof config.mptcp === 'boolean') { - configString.push(`mptcp=${config.mptcp}`); - } - + // istanbul ignore next if (process.env.NODE_ENV !== 'test') { fs.writeJSONSync(jsonFilePath, jsonFile); } diff --git a/test/snapshots/cli.test.ts.md b/test/snapshots/cli.test.ts.md index 922d6db2b..1920c3b8f 100644 --- a/test/snapshots/cli.test.ts.md +++ b/test/snapshots/cli.test.ts.md @@ -22,7 +22,7 @@ Generated by [AVA](https://ava.li). ss1 = custom, server, 443, chacha20-ietf-poly1305, password, https://raw.githubusercontent.com/ConnersHua/SSEncrypt/master/SSEncrypt.module, udp-relay=true␊ ss2 = custom, server, 443, chacha20-ietf-poly1305, password, https://raw.githubusercontent.com/ConnersHua/SSEncrypt/master/SSEncrypt.module, udp-relay=false, obfs=tls, obfs-host=www.bing.com␊ ss4 = custom, server, 443, chacha20-ietf-poly1305, password, https://raw.githubusercontent.com/ConnersHua/SSEncrypt/master/SSEncrypt.module, udp-relay=false, obfs=tls, obfs-host=example.com␊ - 测试中文 = external, exec = "/usr/local/bin/ssr-local", args = "-s", args = "127.0.0.1", args = "-p", args = "1234", args = "-m", args = "aes-128-cfb", args = "-o", args = "tls1.2_ticket_auth", args = "-O", args = "auth_aes128_md5", args = "-k", args = "aaabbb", args = "-l", args = "61105", args = "-b", args = "127.0.0.1", args = "-g", args = "breakwa11.moe", local-port = 61105, addresses = 127.0.0.1, tfo=true␊ + 测试中文 = external, exec = "/usr/local/bin/ssr-local", args = "-s", args = "127.0.0.1", args = "-p", args = "1234", args = "-m", args = "aes-128-cfb", args = "-o", args = "tls1.2_ticket_auth", args = "-O", args = "auth_aes128_md5", args = "-k", args = "aaabbb", args = "-l", args = "61105", args = "-b", args = "127.0.0.1", args = "-g", args = "breakwa11.moe", local-port = 61105, addresses = 127.0.0.1␊ ----␊ 🇺🇸US 1, 🇺🇸US 2, 🇺🇸US 3, 🇺🇲 US, Snell, HTTPS, 🇺🇸US 1, 🇺🇸US 2, 🇺🇸US 3, 🇺🇸US 4, 测试 1, 测试 2, ss1, ss2, ss3, ss4, ss-wss, 测试中文␊ ----␊ @@ -44,7 +44,7 @@ Generated by [AVA](https://ava.li). shadowsocks=server:443, method=chacha20-ietf-poly1305, password=password, obfs=wss, obfs-host=cloudflare.com, obfs-uri=/ws, tag=ss-wss␊ shadowsocks=127.0.0.1:1234, method=aes-128-cfb, password=aaabbb, ssr-protocol=auth_aes128_md5, ssr-protocol-param=, obfs=tls1.2_ticket_auth, obfs-host=breakwa11.moe, udp-relay=true, fast-open=true, tag=测试中文␊ ----␊ - 测试中文 = external, exec = "/usr/local/bin/ssr-local", args = "-s", args = "127.0.0.1", args = "-p", args = "1234", args = "-m", args = "aes-128-cfb", args = "-o", args = "tls1.2_ticket_auth", args = "-O", args = "auth_aes128_md5", args = "-k", args = "aaabbb", args = "-l", args = "61105", args = "-b", args = "127.0.0.1", args = "-g", args = "breakwa11.moe", local-port = 61105, addresses = 127.0.0.1, tfo=true␊ + 测试中文 = external, exec = "/usr/local/bin/ssr-local", args = "-s", args = "127.0.0.1", args = "-p", args = "1234", args = "-m", args = "aes-128-cfb", args = "-o", args = "tls1.2_ticket_auth", args = "-O", args = "auth_aes128_md5", args = "-k", args = "aaabbb", args = "-l", args = "61105", args = "-b", args = "127.0.0.1", args = "-g", args = "breakwa11.moe", local-port = 61105, addresses = 127.0.0.1␊ ----␊ 测试 1, vmess1, vmess1://1386f85e-657b-4d6e-9d56-78badb75e1fd@1.1.1.1:8080/?network=ws&tls=false␊ 测试 2, vmess1, vmess1://1386f85e-657b-4d6e-9d56-78badb75e1fd@1.1.1.1:8080/?network=tcp&tls=false␊ diff --git a/test/snapshots/cli.test.ts.snap b/test/snapshots/cli.test.ts.snap index 98e313529..6234eecaf 100644 Binary files a/test/snapshots/cli.test.ts.snap and b/test/snapshots/cli.test.ts.snap differ diff --git a/test/utils/index.test.ts b/test/utils/index.test.ts index 2315d1741..c35840004 100644 --- a/test/utils/index.test.ts +++ b/test/utils/index.test.ts @@ -147,7 +147,9 @@ test('getSurgeNodes', async t => { password: 'password', surgeConfig: { shadowsocksFormat: 'ss', - } + }, + tfo: true, + mptcp: true, }, { type: NodeTypeEnum.Vmess, alterId: '64', @@ -166,7 +168,9 @@ test('getSurgeNodes', async t => { localPort: 61101, surgeConfig: { v2ray: 'native', - } + }, + tfo: true, + mptcp: true, }]; const txt1 = utils.getSurgeNodes(nodeList).split('\n'); const txt2 = utils.getSurgeNodes(nodeList, nodeConfig => nodeConfig.nodeName === 'Test Node 1'); @@ -180,8 +184,8 @@ test('getSurgeNodes', async t => { t.is(txt1[6], 'Test Node 4 = ss, example.com, 443, encrypt-method=chacha20-ietf-poly1305, password=password, udp-relay=true, obfs=tls, obfs-host=example.com, mptcp=true'); t.is(txt1[7], 'Test Node 5 = ss, example2.com, 443, encrypt-method=chacha20-ietf-poly1305, password=password, mptcp=false'); t.is(txt1[8], 'Test Node 6 = ss, example2.com, 443, encrypt-method=chacha20-ietf-poly1305, password=password'); - t.is(txt1[9], 'Test Node 7 = ss, example2.com, 443, encrypt-method=chacha20-ietf-poly1305, password=password'); - t.is(txt1[10], '测试 6 = vmess, 1.1.1.1, 8080, username=1386f85e-657b-4d6e-9d56-78badb75e1fd, ws=true, ws-path=/, ws-headers=Host:1.1.1.1|User-Agent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148", tls=true, tls13=true, skip-cert-verify=true'); + t.is(txt1[9], 'Test Node 7 = ss, example2.com, 443, encrypt-method=chacha20-ietf-poly1305, password=password, tfo=true, mptcp=true'); + t.is(txt1[10], '测试 6 = vmess, 1.1.1.1, 8080, username=1386f85e-657b-4d6e-9d56-78badb75e1fd, ws=true, ws-path=/, ws-headers=Host:1.1.1.1|User-Agent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148", tls=true, tls13=true, skip-cert-verify=true, tfo=true, mptcp=true'); t.is(txt2, 'Test Node 1 = custom, example.com, 443, chacha20-ietf-poly1305, password, https://raw.githubusercontent.com/ConnersHua/SSEncrypt/master/SSEncrypt.module, udp-relay=true, obfs=tls, obfs-host=example.com'); });