mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-13 17:50:34 +08:00
Chore: minor infra changes
1
This commit is contained in:
parent
3d3abb8b50
commit
7f6e631847
@ -11,7 +11,7 @@ import { sortDomains } from './lib/stable-sort-domain';
|
|||||||
|
|
||||||
const getS3OSSDomainsPromise = (async (): Promise<string[]> => {
|
const getS3OSSDomainsPromise = (async (): Promise<string[]> => {
|
||||||
const trie = createTrie(
|
const trie = createTrie(
|
||||||
(await getPublicSuffixListTextPromise()).split('\n'),
|
await getPublicSuffixListTextPromise(),
|
||||||
true,
|
true,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|||||||
@ -1,14 +1,17 @@
|
|||||||
import { TTL, fsFetchCache } from './cache-filesystem';
|
import { TTL, deserializeArray, fsFetchCache, serializeArray } from './cache-filesystem';
|
||||||
import { defaultRequestInit, fetchWithRetry } from './fetch-retry';
|
import { defaultRequestInit, fetchWithRetry } from './fetch-retry';
|
||||||
import { createMemoizedPromise } from './memo-promise';
|
import { createMemoizedPromise } from './memo-promise';
|
||||||
|
|
||||||
export const getPublicSuffixListTextPromise = createMemoizedPromise(() => fsFetchCache.apply(
|
export const getPublicSuffixListTextPromise = createMemoizedPromise(() => fsFetchCache.apply(
|
||||||
'https://publicsuffix.org/list/public_suffix_list.dat',
|
'https://publicsuffix.org/list/public_suffix_list.dat array',
|
||||||
() => fetchWithRetry('https://publicsuffix.org/list/public_suffix_list.dat', defaultRequestInit).then(r => r.text()),
|
() => fetchWithRetry('https://publicsuffix.org/list/public_suffix_list.dat', defaultRequestInit)
|
||||||
|
.then(r => r.text()).then(text => text.split('\n')),
|
||||||
{
|
{
|
||||||
// https://github.com/publicsuffix/list/blob/master/.github/workflows/tld-update.yml
|
// https://github.com/publicsuffix/list/blob/master/.github/workflows/tld-update.yml
|
||||||
// Though the action runs every 24 hours, the IANA list is updated every 7 days.
|
// Though the action runs every 24 hours, the IANA list is updated every 7 days.
|
||||||
// So a 3 day TTL should be enough.
|
// So a 3 day TTL should be enough.
|
||||||
ttl: TTL.THREE_DAYS()
|
ttl: TTL.THREE_DAYS(),
|
||||||
|
serializer: serializeArray,
|
||||||
|
deserializer: deserializeArray
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
|
|||||||
@ -127,7 +127,7 @@ function createFetchRetry($fetch: typeof fetch): FetchWithRetry {
|
|||||||
|
|
||||||
export const defaultRequestInit: RequestInit = {
|
export const defaultRequestInit: RequestInit = {
|
||||||
headers: {
|
headers: {
|
||||||
'User-Agent': 'curl/8.1.2 (https://github.com/SukkaW/Surge)'
|
'User-Agent': 'curl/8.9.0 (https://github.com/SukkaW/Surge)'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { parse as tldtsParse } from 'tldts';
|
import { parse as tldtsParse } from 'tldts-experimental';
|
||||||
import { isProbablyIpv4 } from './is-fast-ip';
|
import { isProbablyIpv4 } from './is-fast-ip';
|
||||||
export const normalizeDomain = (domain: string) => {
|
export const normalizeDomain = (domain: string) => {
|
||||||
if (!domain) return null;
|
if (!domain) return null;
|
||||||
|
|||||||
@ -402,8 +402,10 @@ export const createTrie = (from?: string[] | Set<string> | null, hostnameMode =
|
|||||||
},
|
},
|
||||||
whitelist,
|
whitelist,
|
||||||
|
|
||||||
[inspect.custom]: (depth: number) => JSON.stringify(deepTrieNodeToJSON(root), null, 2).split('\n').map((line) => ' '.repeat(depth) + line).join('\n'),
|
[inspect.custom]: (depth: number) => fastStringArrayJoin(
|
||||||
|
JSON.stringify(deepTrieNodeToJSON(root), null, 2).split('\n').map((line) => ' '.repeat(depth) + line),
|
||||||
|
'\n'
|
||||||
|
),
|
||||||
hostnameMode,
|
hostnameMode,
|
||||||
smolTree
|
smolTree
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user