Skip to content

Commit

Permalink
fix: 在 external 中开启 tfo 和 mptcp 是没有意义的
Browse files Browse the repository at this point in the history
  • Loading branch information
geekdada committed Dec 29, 2019
1 parent 12ee9e3 commit 8b0e6f0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 22 deletions.
17 changes: 1 addition & 16 deletions lib/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(', '),
Expand Down Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions test/snapshots/cli.test.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -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, 测试中文␊
----␊
Expand All @@ -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␊
Expand Down
Binary file modified test/snapshots/cli.test.ts.snap
Binary file not shown.
12 changes: 8 additions & 4 deletions test/utils/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ test('getSurgeNodes', async t => {
password: 'password',
surgeConfig: {
shadowsocksFormat: 'ss',
}
},
tfo: true,
mptcp: true,
}, {
type: NodeTypeEnum.Vmess,
alterId: '64',
Expand All @@ -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');
Expand All @@ -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');
});

Expand Down

0 comments on commit 8b0e6f0

Please sign in to comment.