mirror of
https://github.com/CrazyJasonwell/clash-verge-rev.git
synced 2026-10-21 09:38:42 +08:00
feat: support sort proxy node and custom test url
This commit is contained in:
1 parent
30421bf247
commit
6cfbde43ab
6 files changed
+104
-123
No files matched your search
+11
-1
@@ -4,6 +4,15 @@ const hashKey = (name: string, group: string) => `${group ?? ""}::${name}`;
|
||||
|
||||
class DelayManager {
|
||||
private cache = new Map<string, [number, number]>();
|
||||
private urlMap = new Map<string, string>();
|
||||
|
||||
setUrl(group: string, url: string) {
|
||||
this.urlMap.set(group, url);
|
||||
}
|
||||
|
||||
getUrl(group: string) {
|
||||
return this.urlMap.get(group);
|
||||
}
|
||||
|
||||
setDelay(name: string, group: string, delay: number) {
|
||||
this.cache.set(hashKey(name, group), [Date.now(), delay]);
|
||||
@@ -23,7 +32,8 @@ class DelayManager {
|
||||
let delay = -1;
|
||||
|
||||
try {
|
||||
const result = await getProxyDelay(name);
|
||||
const url = this.getUrl(group);
|
||||
const result = await getProxyDelay(name, url);
|
||||
delay = result.delay;
|
||||
} catch {
|
||||
delay = 1e6; // error
|
||||
|
||||
Reference in new issue
Block a user