Skip to content

Commit

Permalink
fix: Surge Wireguard 节点某些配置不生效的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
geekdada committed Jul 8, 2023
1 parent 9aa3e64 commit 30df8f9
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 5 deletions.
6 changes: 6 additions & 0 deletions docs/guide/upgrade-guide-v3.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

在 v3.0.0 中对原有的一些接口和行为进行了修改,你可能要花一些时间来解决这些问题。相信我,会很快。

:::warning 注意
- 请不要在 package.json 中直接更改版本号
- 请不要修改完直接提交代码
- 请确认在本地运行 `npx surgio generate` 后没有报错再提交代码
:::

**目录**

[[toc]]
Expand Down
22 changes: 21 additions & 1 deletion src/utils/__tests__/surge.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,9 @@ test('getSurgeNodes', async (t) => {
'测试 Snell = snell, example.com, 443, psk=psk, shadow-tls-password=password, shadow-tls-sni=sni.example.com',
].join('\n'),
)
})

test('getSurgeNodes - Wireguard', (t) => {
t.is(
surge.getSurgeNodes([
{
Expand All @@ -485,8 +487,26 @@ test('getSurgeNodes', async (t) => {
},
],
},
{
type: NodeTypeEnum.Wireguard,
nodeName: 'wg node',
privateKey: 'privateKey',
selfIp: '10.0.0.1',
mtu: 1420,
peers: [
{
endpoint: 'wg.example.com:51820',
publicKey: 'publicKey',
},
],
underlyingProxy: 'UnderlyingProxy',
testUrl: 'http://www.google.com',
},
]),
['wg node = wireguard, section-name = wg node'].join('\n'),
[
'wg node = wireguard, section-name = wg node',
'wg node = wireguard, section-name = wg node, underlying-proxy=UnderlyingProxy, test-url=http://www.google.com',
].join('\n'),
)
})

Expand Down
14 changes: 10 additions & 4 deletions src/utils/surge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -549,10 +549,16 @@ function nodeListMapper(
return [
nodeConfig.nodeName,
[
nodeConfig.nodeName,
' = wireguard, section-name = ',
nodeConfig.nodeName,
].join(''),
`${nodeConfig.nodeName} = wireguard`,
`section-name = ${nodeConfig.nodeName}`,
...pickAndFormatStringList(
nodeConfig,
['underlyingProxy', 'testUrl'],
{
keyFormat: 'kebabCase',
},
),
].join(', '),
]

// istanbul ignore next
Expand Down

0 comments on commit 30df8f9

Please sign in to comment.