Skip to content

Commit

Permalink
fix #260
Browse files Browse the repository at this point in the history
  • Loading branch information
geekdada committed Mar 22, 2024
1 parent a2d3d59 commit ec5c863
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 32 deletions.
8 changes: 4 additions & 4 deletions src/utils/__tests__/loon.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ test('getLoonNodes', (t) => {
uuid: '1386f85e-657b-4d6e-9d56-78badb75e1fd',
},
]),
'测试 = vmess,1.1.1.1,443,method=chacha20-poly1305,"1386f85e-657b-4d6e-9d56-78badb75e1fd",transport=tcp,over-tls=true',
'测试 = vmess,1.1.1.1,443,"1386f85e-657b-4d6e-9d56-78badb75e1fd",transport=tcp,method=chacha20-poly1305,over-tls=true',
)
t.is(
getLoonNodes([
Expand All @@ -46,7 +46,7 @@ test('getLoonNodes', (t) => {
},
},
]),
'测试 = vmess,1.1.1.1,443,method=chacha20-poly1305,"1386f85e-657b-4d6e-9d56-78badb75e1fd",transport=http,path=/test,host=example.com,over-tls=true',
'测试 = vmess,1.1.1.1,443,"1386f85e-657b-4d6e-9d56-78badb75e1fd",transport=http,method=chacha20-poly1305,path=/test,host=example.com,over-tls=true',
)
t.is(
getLoonNodes([
Expand All @@ -68,7 +68,7 @@ test('getLoonNodes', (t) => {
},
},
]),
'测试 = vmess,1.1.1.1,443,method=chacha20-poly1305,"1386f85e-657b-4d6e-9d56-78badb75e1fd",transport=ws,path=/test,over-tls=true',
'测试 = vmess,1.1.1.1,443,"1386f85e-657b-4d6e-9d56-78badb75e1fd",transport=ws,method=chacha20-poly1305,path=/test,over-tls=true',
)
t.is(
getLoonNodes([
Expand All @@ -83,7 +83,7 @@ test('getLoonNodes', (t) => {
network: 'tcp',
},
]),
'vless = VLESS,server,443,method=none,"uuid",transport=tcp,over-tls=true',
'vless = VLESS,server,443,"uuid",transport=tcp,over-tls=true',
)
t.is(
getLoonNodes([
Expand Down
11 changes: 8 additions & 3 deletions src/utils/loon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,18 @@ export const getLoonNodes = function (
}`,
nodeConfig.hostname,
nodeConfig.port,
nodeConfig.method === 'auto'
? `method=chacha20-poly1305`
: `method=${nodeConfig.method}`,
JSON.stringify(nodeConfig.uuid),
`transport=${nodeConfig.network}`,
]

if (nodeConfig.type === NodeTypeEnum.Vmess) {
config.push(
nodeConfig.method === 'auto'
? `method=chacha20-poly1305`
: `method=${nodeConfig.method}`,
)
}

if (nodeConfig.network === 'ws' && nodeConfig.wsOpts) {
const obfsHost = getHeader(nodeConfig.wsOpts.headers, 'Host')

Expand Down
52 changes: 27 additions & 25 deletions test/cli.cli-test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ shadowsocks=us.example.com:445, method=chacha20-ietf-poly1305, password=password
shadowsocks=us.example.com:80, method=chacha20-ietf-poly1305, password=password, obfs=http, obfs-host=www.bing.com, tag=🇺🇸US 4
shadowsocks=us.example.com:443, method=chacha20-ietf-poly1305, password=password, obfs=tls, obfs-host=gateway-carry.icloud.com, tag=🇺🇸US 1
shadowsocks=us.example.com:443, method=chacha20-ietf-poly1305, password=password, tag=🇺🇸US 2
vmess=1.1.1.1:8080, method=chacha20-ietf-poly1305, password=1386f85e-657b-4d6e-9d56-78badb75e1fd, aead=true, obfs=ws, obfs-uri=/, obfs-host=example.com, tag=测试 1
vmess=1.1.1.1:8080, method=chacha20-ietf-poly1305, password=1386f85e-657b-4d6e-9d56-78badb75e1fd, aead=true, tag=测试 2
vmess=example.com:443, method=chacha20-ietf-poly1305, password=1386f85e-657b-4d6e-9d56-78badb75e1fd, aead=true, obfs=wss, obfs-uri=/, obfs-host=example.com, tag=测试 tls
vmess=1.1.1.1:8080, method=chacha20-poly1305, password=1386f85e-657b-4d6e-9d56-78badb75e1fd, aead=true, obfs=ws, obfs-uri=/, obfs-host=example.com, tag=测试 1
vmess=1.1.1.1:8080, method=chacha20-poly1305, password=1386f85e-657b-4d6e-9d56-78badb75e1fd, aead=true, tag=测试 2
vmess=example.com:443, method=chacha20-poly1305, password=1386f85e-657b-4d6e-9d56-78badb75e1fd, aead=true, obfs=wss, obfs-uri=/, obfs-host=example.com, tag=测试 tls
shadowsocks=server:443, method=chacha20-ietf-poly1305, password=password, udp-relay=true, tag=ss1
shadowsocks=server:443, method=chacha20-ietf-poly1305, password=password, obfs=tls, obfs-host=www.bing.com, tag=ss2
shadowsocks=server:443, method=chacha20-ietf-poly1305, password=password, obfs=ws, obfs-host=server, obfs-uri=/, tag=ss3
Expand All @@ -143,9 +143,9 @@ trojan node = trojan,trojan.example.com,443,\\"password\\",tls-name=trojan.examp
🇺🇸US 4 = Shadowsocks,us.example.com,80,chacha20-ietf-poly1305,\\"password\\",http,www.bing.com
🇺🇸US 1 = Shadowsocks,us.example.com,443,chacha20-ietf-poly1305,\\"password\\",tls,gateway-carry.icloud.com
🇺🇸US 2 = Shadowsocks,us.example.com,443,chacha20-ietf-poly1305,\\"password\\"
测试 1 = vmess,1.1.1.1,8080,method=chacha20-ietf-poly1305,\\"1386f85e-657b-4d6e-9d56-78badb75e1fd\\",transport=ws,path=/,host=example.com
测试 2 = vmess,1.1.1.1,8080,method=chacha20-ietf-poly1305,\\"1386f85e-657b-4d6e-9d56-78badb75e1fd\\",transport=tcp
测试 tls = vmess,example.com,443,method=chacha20-ietf-poly1305,\\"1386f85e-657b-4d6e-9d56-78badb75e1fd\\",transport=ws,path=/,host=example.com,over-tls=true
测试 1 = vmess,1.1.1.1,8080,\\"1386f85e-657b-4d6e-9d56-78badb75e1fd\\",transport=ws,method=chacha20-poly1305,path=/,host=example.com
测试 2 = vmess,1.1.1.1,8080,\\"1386f85e-657b-4d6e-9d56-78badb75e1fd\\",transport=tcp,method=chacha20-poly1305
测试 tls = vmess,example.com,443,\\"1386f85e-657b-4d6e-9d56-78badb75e1fd\\",transport=ws,method=chacha20-poly1305,path=/,host=example.com,over-tls=true
ss1 = Shadowsocks,server,443,chacha20-ietf-poly1305,\\"password\\",udp=true
ss2 = Shadowsocks,server,443,chacha20-ietf-poly1305,\\"password\\",tls,www.bing.com
ss4 = Shadowsocks,server,443,chacha20-ietf-poly1305,\\"password\\",tls,example.com
Expand Down Expand Up @@ -194,19 +194,19 @@ getNodeNames
getQuantumultXNodes
shadowsocks=us.example.com:443, method=chacha20-ietf-poly1305, password=password, obfs=tls, obfs-host=gateway-carry.icloud.com, tag=🇺🇸US 1
shadowsocks=us.example.com:443, method=chacha20-ietf-poly1305, password=password, tag=🇺🇸US 2
vmess=1.1.1.1:8080, method=chacha20-ietf-poly1305, password=1386f85e-657b-4d6e-9d56-78badb75e1fd, aead=true, obfs=ws, obfs-uri=/, obfs-host=example.com, tag=测试 1
vmess=1.1.1.1:8080, method=chacha20-ietf-poly1305, password=1386f85e-657b-4d6e-9d56-78badb75e1fd, aead=true, tag=测试 2
vmess=example.com:443, method=chacha20-ietf-poly1305, password=1386f85e-657b-4d6e-9d56-78badb75e1fd, aead=true, obfs=wss, obfs-uri=/, obfs-host=example.com, tag=测试 tls
vmess=1.1.1.1:8080, method=chacha20-poly1305, password=1386f85e-657b-4d6e-9d56-78badb75e1fd, aead=true, obfs=ws, obfs-uri=/, obfs-host=example.com, tag=测试 1
vmess=1.1.1.1:8080, method=chacha20-poly1305, password=1386f85e-657b-4d6e-9d56-78badb75e1fd, aead=true, tag=测试 2
vmess=example.com:443, method=chacha20-poly1305, password=1386f85e-657b-4d6e-9d56-78badb75e1fd, aead=true, obfs=wss, obfs-uri=/, obfs-host=example.com, tag=测试 tls
----
getSurgeNodes
----
getLoonNodes
🇺🇸US 1 = Shadowsocks,us.example.com,443,chacha20-ietf-poly1305,\\"password\\",tls,gateway-carry.icloud.com
🇺🇸US 2 = Shadowsocks,us.example.com,443,chacha20-ietf-poly1305,\\"password\\"
测试 1 = vmess,1.1.1.1,8080,method=chacha20-ietf-poly1305,\\"1386f85e-657b-4d6e-9d56-78badb75e1fd\\",transport=ws,path=/,host=example.com
测试 2 = vmess,1.1.1.1,8080,method=chacha20-ietf-poly1305,\\"1386f85e-657b-4d6e-9d56-78badb75e1fd\\",transport=tcp
测试 tls = vmess,example.com,443,method=chacha20-ietf-poly1305,\\"1386f85e-657b-4d6e-9d56-78badb75e1fd\\",transport=ws,path=/,host=example.com,over-tls=true
测试 1 = vmess,1.1.1.1,8080,\\"1386f85e-657b-4d6e-9d56-78badb75e1fd\\",transport=ws,method=chacha20-poly1305,path=/,host=example.com
测试 2 = vmess,1.1.1.1,8080,\\"1386f85e-657b-4d6e-9d56-78badb75e1fd\\",transport=tcp,method=chacha20-poly1305
测试 tls = vmess,example.com,443,\\"1386f85e-657b-4d6e-9d56-78badb75e1fd\\",transport=ws,method=chacha20-poly1305,path=/,host=example.com,over-tls=true
----
proxyTestUrl
http://www.google.com/generate_204
Expand Down Expand Up @@ -249,19 +249,19 @@ getNodeNames
getQuantumultXNodes
shadowsocks=us.example.com:443, method=chacha20-ietf-poly1305, password=password, obfs=tls, obfs-host=gateway-carry.icloud.com, tag=🇺🇸US 1
shadowsocks=us.example.com:443, method=chacha20-ietf-poly1305, password=password, tag=🇺🇸US 2
vmess=1.1.1.1:8080, method=chacha20-ietf-poly1305, password=1386f85e-657b-4d6e-9d56-78badb75e1fd, aead=true, obfs=ws, obfs-uri=/, obfs-host=example.com, tag=测试 1
vmess=1.1.1.1:8080, method=chacha20-ietf-poly1305, password=1386f85e-657b-4d6e-9d56-78badb75e1fd, aead=true, tag=测试 2
vmess=example.com:443, method=chacha20-ietf-poly1305, password=1386f85e-657b-4d6e-9d56-78badb75e1fd, aead=true, obfs=wss, obfs-uri=/, obfs-host=example.com, tag=测试 tls
vmess=1.1.1.1:8080, method=chacha20-poly1305, password=1386f85e-657b-4d6e-9d56-78badb75e1fd, aead=true, obfs=ws, obfs-uri=/, obfs-host=example.com, tag=测试 1
vmess=1.1.1.1:8080, method=chacha20-poly1305, password=1386f85e-657b-4d6e-9d56-78badb75e1fd, aead=true, tag=测试 2
vmess=example.com:443, method=chacha20-poly1305, password=1386f85e-657b-4d6e-9d56-78badb75e1fd, aead=true, obfs=wss, obfs-uri=/, obfs-host=example.com, tag=测试 tls
----
getSurgeNodes
----
getLoonNodes
🇺🇸US 1 = Shadowsocks,us.example.com,443,chacha20-ietf-poly1305,\\"password\\",tls,gateway-carry.icloud.com
🇺🇸US 2 = Shadowsocks,us.example.com,443,chacha20-ietf-poly1305,\\"password\\"
测试 1 = vmess,1.1.1.1,8080,method=chacha20-ietf-poly1305,\\"1386f85e-657b-4d6e-9d56-78badb75e1fd\\",transport=ws,path=/,host=example.com
测试 2 = vmess,1.1.1.1,8080,method=chacha20-ietf-poly1305,\\"1386f85e-657b-4d6e-9d56-78badb75e1fd\\",transport=tcp
测试 tls = vmess,example.com,443,method=chacha20-ietf-poly1305,\\"1386f85e-657b-4d6e-9d56-78badb75e1fd\\",transport=ws,path=/,host=example.com,over-tls=true
测试 1 = vmess,1.1.1.1,8080,\\"1386f85e-657b-4d6e-9d56-78badb75e1fd\\",transport=ws,method=chacha20-poly1305,path=/,host=example.com
测试 2 = vmess,1.1.1.1,8080,\\"1386f85e-657b-4d6e-9d56-78badb75e1fd\\",transport=tcp,method=chacha20-poly1305
测试 tls = vmess,example.com,443,\\"1386f85e-657b-4d6e-9d56-78badb75e1fd\\",transport=ws,method=chacha20-poly1305,path=/,host=example.com,over-tls=true
----
proxyTestUrl
http://www.google.com/generate_204
Expand Down Expand Up @@ -290,6 +290,7 @@ ss2 = ss, server, 443, encrypt-method=chacha20-ietf-poly1305, password=password,
vmess = vmess, server, 443, username=uuid, vmess-aead=true
vmess new format = vmess, server, 443, username=uuid, ws=true, ws-path=/path, ws-headers=\\"user-agent:Mozilla/5.0 (iPhone; CPU iPhone OS 13_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Mobile/15E148 Safari/604.1|host:v2ray.com\\", tls=true, vmess-aead=true, tls13=true, skip-cert-verify=true
vmess custom header = vmess, server, 443, username=uuid, ws=true, ws-path=/path, ws-headers=\\"user-agent:Mozilla/5.0 (iPhone; CPU iPhone OS 13_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Mobile/15E148 Safari/604.1|edge:www.baidu.com\\", tls=true, vmess-aead=true, tls13=true, skip-cert-verify=false
socks = socks5, server, 443
http 1 = https, server, 443, username, password, tls13=true, skip-cert-verify=false
http 2 = http, server, 443, username, password
snell = snell, server, 44046, psk=yourpsk, obfs=http
Expand All @@ -301,20 +302,21 @@ ss2 = ss, server, 443, encrypt-method=chacha20-ietf-poly1305, password=password,
vmess = vmess, server, 443, username=uuid, vmess-aead=true
vmess new format = vmess, server, 443, username=uuid, ws=true, ws-path=/path, ws-headers=\\"user-agent:Mozilla/5.0 (iPhone; CPU iPhone OS 13_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Mobile/15E148 Safari/604.1|Host:v2ray.com\\", tls=true, skip-cert-verify=true, vmess-aead=true
vmess custom header = vmess, server, 443, username=uuid, ws=true, ws-path=/path, ws-headers=\\"user-agent:Mozilla/5.0 (iPhone; CPU iPhone OS 13_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Mobile/15E148 Safari/604.1|edge:www.baidu.com\\", tls=true, vmess-aead=true
socks = socks5, server, 443
http 1 = https, server, 443, username, password, skip-cert-verify=false
http 2 = http, server, 443, username, password
ss4 = ss, server, 443, encrypt-method=chacha20-ietf-poly1305, password=password, udp-relay=true, obfs=tls, obfs-host=example.com
----
getNodeNames
ss1, ss2, ss3, vmess, vmess new format, vmess custom header, http 1, http 2, snell, ss4, ss-wss, hysteria2
ss1, ss2, ss3, vmess, vmess new format, vmess custom header, socks, http 1, http 2, snell, ss4, ss-wss, hysteria2
----
getQuantumultXNodes
shadowsocks=server:443, method=chacha20-ietf-poly1305, password=password, udp-relay=true, tag=ss1
shadowsocks=server:443, method=chacha20-ietf-poly1305, password=password, obfs=tls, obfs-host=www.bing.com, udp-relay=true, tag=ss2
shadowsocks=server:443, method=chacha20-ietf-poly1305, password=password, obfs=ws, obfs-host=server, obfs-uri=/, udp-relay=true, tag=ss3
vmess=server:443, method=chacha20-ietf-poly1305, password=uuid, udp-relay=true, aead=true, tag=vmess
vmess=server:443, method=chacha20-ietf-poly1305, password=uuid, udp-relay=true, aead=true, obfs=wss, tls-verification=false, tls13=true, obfs-uri=/path, obfs-host=v2ray.com, tag=vmess new format
vmess=server:443, method=chacha20-ietf-poly1305, password=uuid, udp-relay=true, aead=true, obfs=wss, tls13=true, obfs-uri=/path, tag=vmess custom header
vmess=server:443, method=chacha20-poly1305, password=uuid, udp-relay=true, aead=true, tag=vmess
vmess=server:443, method=chacha20-poly1305, password=uuid, udp-relay=true, aead=true, obfs=wss, tls-verification=false, tls13=true, obfs-uri=/path, obfs-host=v2ray.com, tag=vmess new format
vmess=server:443, method=chacha20-poly1305, password=uuid, udp-relay=true, aead=true, obfs=wss, tls13=true, obfs-uri=/path, tag=vmess custom header
http=server:443, username=username, password=password, over-tls=true, tls-verification=true, tls13=true, tag=http 1
http=server:443, username=username, password=password, tag=http 2
shadowsocks=server:443, method=chacha20-ietf-poly1305, password=password, obfs=tls, obfs-host=example.com, udp-relay=true, tag=ss4
Expand All @@ -326,9 +328,9 @@ getSurgeNodes
getLoonNodes
ss1 = Shadowsocks,server,443,chacha20-ietf-poly1305,\\"password\\",udp=true
ss2 = Shadowsocks,server,443,chacha20-ietf-poly1305,\\"password\\",tls,www.bing.com,udp=true
vmess = vmess,server,443,method=chacha20-ietf-poly1305,\\"uuid\\",transport=tcp
vmess new format = vmess,server,443,method=chacha20-ietf-poly1305,\\"uuid\\",transport=ws,path=/path,host=v2ray.com,over-tls=true,skip-cert-verify=true
vmess custom header = vmess,server,443,method=chacha20-ietf-poly1305,\\"uuid\\",transport=ws,path=/path,over-tls=true
vmess = vmess,server,443,\\"uuid\\",transport=tcp,method=chacha20-poly1305
vmess new format = vmess,server,443,\\"uuid\\",transport=ws,method=chacha20-poly1305,path=/path,host=v2ray.com,over-tls=true,skip-cert-verify=true
vmess custom header = vmess,server,443,\\"uuid\\",transport=ws,method=chacha20-poly1305,path=/path,over-tls=true
http 1 = https,server,443,username,\\"password\\",tls-name=server,skip-cert-verify=false
http 2 = http,server,443,username,\\"password\\"
ss4 = Shadowsocks,server,443,chacha20-ietf-poly1305,\\"password\\",tls,example.com,udp=true
Expand Down

0 comments on commit ec5c863

Please sign in to comment.