-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Expand file tree
/
Copy pathanytlsParser.js
More file actions
47 lines (42 loc) · 1.05 KB
/
anytlsParser.js
File metadata and controls
47 lines (42 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import {
parseServerInfo,
parseUrlParams,
parseArray,
parseBool,
} from "../../utils.js";
export function parseAnyTls(url) {
const { addressPart, params, name } = parseUrlParams(url);
const [password, serverInfo] = addressPart.split("@");
const { host, port } = parseServerInfo(serverInfo);
const alpn = parseArray(params.alpn);
const insecure = parseBool(
params["skip-cert-verify"] ?? params.insecure ?? params.allowInsecure,
true,
);
const tls = {
enabled: true,
server_name: params.sni,
insecure: insecure,
alpn: alpn,
};
if (params["client-fingerprint"]) {
tls.utls = {
enabled: true,
fingerprint: params["client-fingerprint"],
};
}
return {
tag: name,
type: "anytls",
server: host,
server_port: port,
password: password,
tls: tls,
udp: parseBool(params.udp, false),
sni: params.sni,
alpn: alpn.length ? alpn : undefined,
"idle-session-check-interval": params["idle-session-check-interval"],
"idle-session-timeout": params["idle-session-timeout"],
"min-idle-session": params["min-idle-session"],
};
}