mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-12 01:00:34 +08:00
Update Reject Hosts
This commit is contained in:
parent
53fc370774
commit
62ee184921
@ -33,6 +33,27 @@ interface CacheApplyStringOption {
|
||||
|
||||
type CacheApplyOption<T> = T extends string ? CacheApplyStringOption : CacheApplyNonStringOption<T>;
|
||||
|
||||
const randomInt = (min: number, max: number) => Math.floor(Math.random() * (max - min + 1)) + min;
|
||||
// Add some randomness to the cache ttl to avoid thundering herd
|
||||
export const TTL = {
|
||||
humanReadable(ttl: number) {
|
||||
if (ttl >= 24 * 60 * 60 * 1000) {
|
||||
return `${Math.round(ttl / 24 / 60 / 60 / 1000)}d`;
|
||||
}
|
||||
if (ttl >= 60 * 60 * 1000) {
|
||||
return `${Math.round(ttl / 60 / 60 / 1000)}h`;
|
||||
}
|
||||
return `${Math.round(ttl / 1000)}s`;
|
||||
},
|
||||
THREE_HOURS: () => randomInt(1, 3) * 60 * 60 * 1000,
|
||||
TWLVE_HOURS: () => randomInt(8, 12) * 60 * 60 * 1000,
|
||||
ONE_DAY: () => randomInt(23, 25) * 60 * 60 * 1000,
|
||||
THREE_DAYS: () => randomInt(1, 3) * 24 * 60 * 60 * 1000,
|
||||
ONE_WEEK: () => randomInt(5, 7) * 24 * 60 * 60 * 1000,
|
||||
TWO_WEEKS: () => randomInt(10, 14) * 24 * 60 * 60 * 1000,
|
||||
TEN_DAYS: () => randomInt(7, 10) * 24 * 60 * 60 * 1000
|
||||
};
|
||||
|
||||
export class Cache {
|
||||
db: Database;
|
||||
tbd = 60 * 1000; // time before deletion
|
||||
@ -108,7 +129,7 @@ export class Cache {
|
||||
const cached = this.get(key);
|
||||
let value: T;
|
||||
if (cached == null) {
|
||||
console.log(picocolors.yellow('[cache] miss'), picocolors.gray(key), picocolors.gray(`ttl: ${ttl / 60 * 60 * 1000}h`));
|
||||
console.log(picocolors.yellow('[cache] miss'), picocolors.gray(key), picocolors.gray(`ttl: ${TTL.humanReadable(ttl)}`));
|
||||
value = await fn();
|
||||
|
||||
const serializer = 'serializer' in opt ? opt.serializer : identity;
|
||||
@ -132,19 +153,6 @@ export const fsCache = new Cache({ cachePath: path.resolve(import.meta.dir, '../
|
||||
// fsCache.destroy();
|
||||
// });
|
||||
|
||||
const randomInt = (min: number, max: number) => Math.floor(Math.random() * (max - min + 1)) + min;
|
||||
|
||||
// Add some randomness to the cache ttl to avoid thundering herd
|
||||
export const TTL = {
|
||||
THREE_HOURS: () => randomInt(1, 3) * 60 * 60 * 1000,
|
||||
TWLVE_HOURS: () => randomInt(8, 12) * 60 * 60 * 1000,
|
||||
ONE_DAY: () => randomInt(23, 25) * 60 * 60 * 1000,
|
||||
THREE_DAYS: () => randomInt(1, 3) * 24 * 60 * 60 * 1000,
|
||||
ONE_WEEK: () => randomInt(5, 7) * 24 * 60 * 60 * 1000,
|
||||
TWO_WEEKS: () => randomInt(10, 14) * 24 * 60 * 60 * 1000,
|
||||
TEN_DAYS: () => randomInt(7, 10) * 24 * 60 * 60 * 1000
|
||||
};
|
||||
|
||||
const separator = '\u0000';
|
||||
// const textEncoder = new TextEncoder();
|
||||
// const textDecoder = new TextDecoder();
|
||||
|
||||
@ -1873,3 +1873,17 @@ adserve2.tom.com
|
||||
.hola.sk
|
||||
.hola.org
|
||||
.holacdn.com
|
||||
|
||||
# EasyPrivacy Migration
|
||||
.click.signaturemarket.co
|
||||
.link.clubmanagergame.com
|
||||
.link.ag.fan
|
||||
.wp-tw.americanexpress.com
|
||||
.mail.dolce-gusto.cz
|
||||
.smetrics.suncorpbank.com.au
|
||||
.smetrics.viabcp.com
|
||||
.metrics.reallymoving.com
|
||||
.adbmetrics.koreanair.com
|
||||
.link.plazahogar.com.py
|
||||
.link.localmasters.co
|
||||
.trk.drdobbs.com
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user