Skip to content

Commit

Permalink
feat: add blockQuic option for surge
Browse files Browse the repository at this point in the history
  • Loading branch information
geekdada committed Mar 17, 2024
1 parent d8cab8a commit 23fed38
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 3 deletions.
11 changes: 11 additions & 0 deletions docs/guide/custom-provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,17 @@ Surgio 不会验证名称是否有效

是否为该节点开启 [ECN(Explicit Congestion Notification)](https://yach.me/2023/10/14/ccn-and-ecn/)。目前仅 Surge 支持这一特性。

### nodeConfig.blockQuic

- 类型: `string`
- 默认值: `undefined`

通过代理转发 QUIC 流量可能会导致性能问题。启用该选项将阻止 QUIC 流量,使客户端退回到传统的 HTTPS/TCP 协议。目前仅 Surge 支持这一特性。

`auto`: 根据代理是否适合转发 QUIC 流量自动启用
`on`: 强制阻止 QUIC 流量
`off`: 不阻止 QUIC 流量

### 客户端特殊配置

> <Badge text="v3.2.0" vertical="middle" />
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import {
SortedNodeFilterTypeValidator,
Hysteria2NodeConfigValidator,
ClashCoreValidator,
VlessNodeConfigValidator,
} from './validators'
import { VlessNodeConfigValidator } from './validators/vless'

export enum NodeTypeEnum {
HTTPS = 'https',
Expand Down
6 changes: 4 additions & 2 deletions src/utils/__tests__/surge.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,9 +384,10 @@ test('getSurgeNodes', async (t) => {
nodeName: 'socks node 1',
hostname: '1.1.1.1',
port: '80',
blockQuic: 'auto',
},
]),
'socks node 1 = socks5, 1.1.1.1, 80',
'socks node 1 = socks5, 1.1.1.1, 80, block-quic=auto',
)

t.is(
Expand All @@ -397,9 +398,10 @@ test('getSurgeNodes', async (t) => {
hostname: '1.1.1.1',
port: '80',
tfo: true,
blockQuic: 'on',
},
]),
'socks node 2 = socks5, 1.1.1.1, 80, tfo=true',
'socks node 2 = socks5, 1.1.1.1, 80, tfo=true, block-quic=on',
)

t.is(
Expand Down
1 change: 1 addition & 0 deletions src/utils/surge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,7 @@ function appendCommonConfig(
'skipCertVerify',
'sni',
'serverCertFingerprintSha256',
'blockQuic',
],
{
keyFormat: 'kebabCase',
Expand Down
5 changes: 5 additions & 0 deletions src/validators/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ export const SimpleNodeConfigValidator = z.object({
})
.optional(),

// UDP features
blockQuic: z
.union([z.literal('auto'), z.literal('on'), z.literal('off')])
.optional(),

// Misc
underlyingProxy: z.string().optional(),
testUrl: z.string().optional(),
Expand Down
1 change: 1 addition & 0 deletions src/validators/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ export * from './artifact'
export * from './filter'
export * from './hooks'
export * from './hysteria2'
export * from './vless'

0 comments on commit 23fed38

Please sign in to comment.