Skip to content

Commit 9e09f8c

Browse files
authored
refactor: simplify smart strategy group logic (#814)
1 parent 1704e67 commit 9e09f8c

File tree

10 files changed

+126
-640
lines changed

10 files changed

+126
-640
lines changed

Cargo.lock

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

clash_lib/src/app/outbound/manager.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,6 @@ impl OutboundManager {
679679
},
680680
udp: proto.udp.unwrap_or(true),
681681
max_retries: proto.max_retries,
682-
site_stickiness: proto.site_stickiness,
683682
bandwidth_weight: proto.bandwidth_weight,
684683
},
685684
providers,

clash_lib/src/app/profile/mod.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,6 @@ impl ThreadSafeCacheFile {
122122
let g = self.0.read().await;
123123
g.get_smart_stats(group_name)
124124
}
125-
126-
/// Get smart proxy group policy priority
127-
pub async fn get_smart_policy_priority(
128-
&self,
129-
group_name: &str,
130-
) -> Option<String> {
131-
let g = self.0.read().await;
132-
g.get_smart_policy_priority(group_name)
133-
}
134125
}
135126

136127
struct CacheFile {
@@ -222,8 +213,4 @@ impl CacheFile {
222213
) -> Option<crate::proxy::group::smart::state::SmartStateData> {
223214
self.db.smart_stats.get(group_name).cloned()
224215
}
225-
226-
pub fn get_smart_policy_priority(&self, group_name: &str) -> Option<String> {
227-
self.db.smart_policy_priority.get(group_name).cloned()
228-
}
229216
}

clash_lib/src/common/utils.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
use async_recursion::async_recursion;
22
use futures::StreamExt;
33
use http_body_util::BodyDataStream;
4-
use std::{fmt::Write, num::ParseIntError, path::Path};
4+
use std::{
5+
fmt::Write,
6+
num::ParseIntError,
7+
path::Path,
8+
time::{SystemTime, UNIX_EPOCH},
9+
};
510

611
use crate::{Error, common::errors::new_io_error};
712
use rand::{
@@ -62,6 +67,13 @@ pub fn md5_str(bytes: &[u8]) -> String {
6267
format!("{:x}", hasher.finalize())
6368
}
6469

70+
pub fn current_timestamp_secs() -> u64 {
71+
SystemTime::now()
72+
.duration_since(UNIX_EPOCH)
73+
.unwrap_or_default()
74+
.as_secs()
75+
}
76+
6577
/// Default value true for bool on serde
6678
/// use this if you don't want do deal with Option<bool>
6779
/// Use Default::default() for false

clash_lib/src/proxy/group/smart/config.rs

Lines changed: 0 additions & 114 deletions
This file was deleted.

0 commit comments

Comments
 (0)