Skip to content

Commit 309062a

Browse files
committed
feat: Add support for TUIC protocol
1 parent cccc9a5 commit 309062a

File tree

5 files changed

+50
-11
lines changed

5 files changed

+50
-11
lines changed

README.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
1010
## 功能特点
1111

12-
- 支持协议:SS、VMess、VLESS、Hysteria2, Trojan
12+
- 支持协议:SS、VMess、VLESS、Hysteria2, Trojan, TUIC
1313
- 支持导入Base64订阅链接
1414
- [一键部署](#最近更新), 无需后端
1515
- 支持客户端:
@@ -22,9 +22,13 @@
2222

2323
## 最近更新
2424

25+
### 31/7
26+
27+
- 支持 TUIC
28+
2529
### 30/7
2630

27-
- 简化逆天路由规则
31+
- 简化路由逻辑
2832
- 修复了一些小问题
2933

3034
### 28/7

src/ClashConfigBuilder.js

+11
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,17 @@ export class ClashConfigBuilder {
158158
'skip-cert-verify': proxy.tls.insecure,
159159
'flow': proxy.flow ?? undefined,
160160
}
161+
case 'tuic':
162+
return {
163+
name: proxy.tag,
164+
type: proxy.type,
165+
server: proxy.server,
166+
port: proxy.server_port,
167+
uuid: proxy.uuid,
168+
password: proxy.password,
169+
'congestion-controller': proxy.congestion,
170+
'skip-cert-verify': proxy.tls.insecure,
171+
};
161172
default:
162173
return proxy; // Return as-is if no specific conversion is defined
163174
}

src/ProxyParsers.js

+32-3
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ export class ProxyParser {
99
case 'vmess': return new VmessParser().parse(url);
1010
case 'vless': return new VlessParser().parse(url);
1111
case 'hysteria2': return new Hysteria2Parser().parse(url);
12-
case 'http' || 'https': return HttpParser.parse(url);
12+
case 'http':
13+
case 'https':
14+
return HttpParser.parse(url);
1315
case 'trojan': return new TrojanParser().parse(url);
16+
case 'tuic': return new TuicParser().parse(url);
1417
}
1518
}
1619
}
@@ -137,7 +140,6 @@ export class ProxyParser {
137140

138141
class TrojanParser {
139142
parse(url) {
140-
// trojan://8jxfHkRdEV@diylink.qhr.icu:31190?security=reality&sni=yahoo.com&fp=random&pbk=KlaUGzBvKlBX0GqI7hCPioRZvDuLP3O5wozg-L8nCiw&sid=a9d30b07&spx=%2F&type=tcp&headerType=none#trojan-test-nuu4xgxm
141143
const { addressPart, params, name } = parseUrlParams(url);
142144
const [password, serverInfo] = addressPart.split('@');
143145
const { host, port } = parseServerInfo(serverInfo);
@@ -159,7 +161,34 @@ export class ProxyParser {
159161
};
160162
}
161163
}
162-
//
164+
165+
class TuicParser {
166+
parse(url) {
167+
const { addressPart, params, name } = parseUrlParams(url);
168+
const [userinfo, serverInfo] = addressPart.split('@');
169+
const { host, port } = parseServerInfo(serverInfo);
170+
171+
const tls = {
172+
enabled: true,
173+
server_name: params.sni,
174+
alpn: [params.alpn],
175+
};
176+
177+
return {
178+
tag: name,
179+
type: "tuic",
180+
server: host,
181+
server_port: port,
182+
uuid: userinfo.split(':')[0],
183+
password: userinfo.split(':')[1],
184+
congestion_control: params.congestion_control,
185+
tls: tls,
186+
flow: params.flow ?? undefined
187+
};
188+
}
189+
}
190+
191+
163192
class HttpParser {
164193
static async parse(url) {
165194
try {

src/config.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,6 @@ export const CLASH_CONFIG = {
269269
fallback: ['8.8.8.8', '8.8.4.4', 'tls://1.0.0.1:853', 'tls://dns.google:853'],
270270
},
271271
proxies: [],
272-
'proxy-groups': [
273-
// 'name': '🐟 漏网之鱼',
274-
// 'type': 'select',
275-
// 'proxies': ['🚀 节点选择','DIRECT','REJECT']
276-
],
272+
'proxy-groups': [],
277273
rules: parsedRules,
278274
};

wrangler.toml

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#:schema node_modules/wrangler/config-schema.json
22
name = "sublink-worker"
3-
type = "javascript"
43
usage_model = "bundled"
54
main = "src/index.js"
65
compatibility_date = "2024-07-24"

0 commit comments

Comments
 (0)