Skip to content

Commit 0690c00

Browse files
committed
fix surge proxy list tls13,tfo
1 parent 81ef84a commit 0690c00

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

ytflow-app-util/src/subscription/surge_proxy_list.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,21 @@ fn decode_surge_proxy_line(line: &str, parents: &mut BTreeMap<String, String>) -
6363
}));
6464
kv_args.remove("group");
6565
kv_args.remove("no-error-alert");
66+
kv_args.remove("tls13");
67+
68+
if kv_args.remove("tfo") == Some("true") {
69+
return None;
70+
}
6671

6772
let sni = kv_args.remove("sni").filter(|&sni| sni != "off");
73+
let skip_cert_check = kv_args.remove("skip-cert-verify").map(|v| v == "true");
6874
let tls = if kv_args.remove("tls") == Some("true")
6975
|| ["https", "trojan", "socks5-tls"].contains(&protocol)
7076
{
7177
Some(ProxyTlsLayer {
7278
alpn: vec![],
7379
sni: sni.map(String::from),
74-
skip_cert_check: kv_args.remove("skip-cert-verify").map(|v| v == "true"),
80+
skip_cert_check,
7581
})
7682
} else {
7783
None
@@ -143,9 +149,12 @@ fn decode_surge_proxy_line(line: &str, parents: &mut BTreeMap<String, String>) -
143149
parents.insert(name.into(), underlying_proxy.into());
144150
}
145151

146-
if !kv_args.is_empty() {
147-
return None;
148-
}
152+
kv_args
153+
.into_values()
154+
.filter(|extra_value| !matches!(*extra_value, "" | "none" | "false" | "off"))
155+
.map(|_| None)
156+
.next()
157+
.unwrap_or(Some(()))?;
149158

150159
Some(Proxy {
151160
name: name.into(),
@@ -202,7 +211,7 @@ mod tests {
202211
fn test_decode_surge_proxy_list() {
203212
let data = b"
204213
// # aa = ss , a.com , 11451 , group = g , no-error-alert = t , encrypt-method = aes-256-cfb , password = abc , udp-relay = true
205-
aa = ss , a.com , 11451 , group = g , no-error-alert = t , encrypt-method = aes-256-cfb , password = abc , udp-relay = true , kk
214+
aa = ss , a.com , 11451 , group = g , no-error-alert = t , encrypt-method = aes-256-cfb , password = abc , udp-relay = true , tfo = false , kk
206215
";
207216
let sub = decode_surge_proxy_list(data).unwrap();
208217
assert_eq!(
@@ -232,7 +241,7 @@ mod tests {
232241
fn test_decode_surge_proxy_list_tls() {
233242
let cases = [
234243
(
235-
"aa = ss, a.com, 114, encrypt-method=aes-256-cfb, password=abc, tls=true, sni=b.com, skip-cert-verify=false",
244+
"aa = ss, a.com, 114, encrypt-method=aes-256-cfb, password=abc, tls=true, sni=b.com, skip-cert-verify=false, tls13=true",
236245
ProxyTlsLayer {
237246
alpn: vec![],
238247
sni: Some("b.com".into()),

0 commit comments

Comments
 (0)