Skip to content

Commit 11e1191

Browse files
committed
ignore trojan peer
1 parent bb49773 commit 11e1191

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ytflow-app-util/src/share_link/trojan.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ impl TrojanProxy {
2727
let host = parse_host_transparent(url)?;
2828
let port = url.port().unwrap_or(443);
2929
let skip_cert_check = queries.remove("allowInsecure").map(|s| s == "1");
30+
queries.remove("peer"); // ShadowRocket's non standard field
3031
let sni = queries.remove("sni").map(|s| s.into_owned());
3132
let alpn = queries
3233
.remove("alpn")
@@ -102,7 +103,7 @@ mod tests {
102103
#[test]
103104
fn test_decode_share_link() {
104105
let url = Url::parse(&format!(
105-
"trojan://a%[email protected]:10443?alpn=ipv9,http/1.1&sni=b.com&allowInsecure=1#c/d",
106+
"trojan://a%[email protected]:10443?alpn=ipv9,http/1.1&sni=b.com&peer=wtf&allowInsecure=1#c/d",
106107
))
107108
.unwrap();
108109
let mut queries = url.query_pairs().collect::<QueryMap>();

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use chrono::NaiveDateTime;
1+
use chrono::{DateTime, NaiveDateTime};
22
use serde::{Deserialize, Serialize};
33

44
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
@@ -34,7 +34,8 @@ impl SubscriptionUserInfo {
3434
ret.expires_at = value
3535
.parse()
3636
.ok()
37-
.and_then(|s| NaiveDateTime::from_timestamp_opt(s, 0));
37+
.and_then(|s| DateTime::from_timestamp(s, 0))
38+
.map(|dt| dt.naive_utc());
3839
}
3940
_ => {
4041
continue;
@@ -60,7 +61,7 @@ mod tests {
6061
upload_bytes_used: Some(455727941),
6162
download_bytes_used: Some(6174315083),
6263
bytes_total: Some(1073741824000),
63-
expires_at: NaiveDateTime::from_timestamp_opt(1671815872, 0),
64+
expires_at: DateTime::from_timestamp(1671815872, 0).map(|t| t.naive_local()),
6465
}
6566
);
6667
}

0 commit comments

Comments
 (0)