|
@@ -9,15 +9,14 @@ import { traceAsync } from './trace-runner';
|
|
|
import picocolors from 'picocolors';
|
|
import picocolors from 'picocolors';
|
|
|
import { normalizeDomain } from './normalize-domain';
|
|
import { normalizeDomain } from './normalize-domain';
|
|
|
import { fetchAssets } from './fetch-assets';
|
|
import { fetchAssets } from './fetch-assets';
|
|
|
-import { deserializeSet, fsCache, serializeSet } from './cache-filesystem';
|
|
|
|
|
|
|
|
|
|
const DEBUG_DOMAIN_TO_FIND: string | null = null; // example.com | null
|
|
const DEBUG_DOMAIN_TO_FIND: string | null = null; // example.com | null
|
|
|
let foundDebugDomain = false;
|
|
let foundDebugDomain = false;
|
|
|
|
|
|
|
|
-export function processDomainLists(domainListsUrl: string, includeAllSubDomain = false, ttl: number | null = null) {
|
|
|
|
|
- return traceAsync(`- processDomainLists: ${domainListsUrl}`, () => fsCache.apply(
|
|
|
|
|
|
|
+export function processDomainLists(domainListsUrl: string, includeAllSubDomain = false, _ttl: number | null = null) {
|
|
|
|
|
+ return traceAsync(`- processDomainLists: ${domainListsUrl}`, /* () => fsCache.apply(
|
|
|
domainListsUrl,
|
|
domainListsUrl,
|
|
|
- async () => {
|
|
|
|
|
|
|
+ */async () => {
|
|
|
const domainSets = new Set<string>();
|
|
const domainSets = new Set<string>();
|
|
|
|
|
|
|
|
for await (const line of await fetchRemoteTextByLine(domainListsUrl)) {
|
|
for await (const line of await fetchRemoteTextByLine(domainListsUrl)) {
|
|
@@ -33,19 +32,19 @@ export function processDomainLists(domainListsUrl: string, includeAllSubDomain =
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return domainSets;
|
|
return domainSets;
|
|
|
- },
|
|
|
|
|
|
|
+ });/* ,
|
|
|
{
|
|
{
|
|
|
ttl,
|
|
ttl,
|
|
|
temporaryBypass: DEBUG_DOMAIN_TO_FIND !== null,
|
|
temporaryBypass: DEBUG_DOMAIN_TO_FIND !== null,
|
|
|
serializer: serializeSet,
|
|
serializer: serializeSet,
|
|
|
deserializer: deserializeSet
|
|
deserializer: deserializeSet
|
|
|
}
|
|
}
|
|
|
- ));
|
|
|
|
|
|
|
+ )); */
|
|
|
}
|
|
}
|
|
|
-export function processHosts(hostsUrl: string, includeAllSubDomain = false, skipDomainCheck = false, ttl: number | null = null) {
|
|
|
|
|
- return traceAsync(`- processHosts: ${hostsUrl}`, () => fsCache.apply(
|
|
|
|
|
|
|
+export function processHosts(hostsUrl: string, includeAllSubDomain = false, skipDomainCheck = false, _ttl: number | null = null) {
|
|
|
|
|
+ return traceAsync(`- processHosts: ${hostsUrl}`, /* () => fsCache.apply(
|
|
|
hostsUrl,
|
|
hostsUrl,
|
|
|
- async () => {
|
|
|
|
|
|
|
+ */async () => {
|
|
|
const domainSets = new Set<string>();
|
|
const domainSets = new Set<string>();
|
|
|
|
|
|
|
|
for await (const l of await fetchRemoteTextByLine(hostsUrl)) {
|
|
for await (const l of await fetchRemoteTextByLine(hostsUrl)) {
|
|
@@ -74,14 +73,14 @@ export function processHosts(hostsUrl: string, includeAllSubDomain = false, skip
|
|
|
console.log(picocolors.gray('[process hosts]'), picocolors.gray(hostsUrl), picocolors.gray(domainSets.size));
|
|
console.log(picocolors.gray('[process hosts]'), picocolors.gray(hostsUrl), picocolors.gray(domainSets.size));
|
|
|
|
|
|
|
|
return domainSets;
|
|
return domainSets;
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ });
|
|
|
|
|
+ /* {
|
|
|
ttl,
|
|
ttl,
|
|
|
temporaryBypass: DEBUG_DOMAIN_TO_FIND !== null,
|
|
temporaryBypass: DEBUG_DOMAIN_TO_FIND !== null,
|
|
|
serializer: serializeSet,
|
|
serializer: serializeSet,
|
|
|
deserializer: deserializeSet
|
|
deserializer: deserializeSet
|
|
|
}
|
|
}
|
|
|
- ));
|
|
|
|
|
|
|
+ ) */
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// eslint-disable-next-line sukka-ts/no-const-enum -- bun bundler is smart, maybe?
|
|
// eslint-disable-next-line sukka-ts/no-const-enum -- bun bundler is smart, maybe?
|
|
@@ -96,15 +95,15 @@ const enum ParseType {
|
|
|
export async function processFilterRules(
|
|
export async function processFilterRules(
|
|
|
filterRulesUrl: string,
|
|
filterRulesUrl: string,
|
|
|
fallbackUrls?: readonly string[] | undefined | null,
|
|
fallbackUrls?: readonly string[] | undefined | null,
|
|
|
- ttl: number | null = null
|
|
|
|
|
|
|
+ _ttl: number | null = null
|
|
|
): Promise<{ white: string[], black: string[], foundDebugDomain: boolean }> {
|
|
): Promise<{ white: string[], black: string[], foundDebugDomain: boolean }> {
|
|
|
- const [white, black, warningMessages] = await traceAsync(`- processFilterRules: ${filterRulesUrl}`, () => fsCache.apply<[
|
|
|
|
|
|
|
+ const [white, black, warningMessages] = await traceAsync(`- processFilterRules: ${filterRulesUrl}`, /* () => fsCache.apply<[
|
|
|
white: string[],
|
|
white: string[],
|
|
|
black: string[],
|
|
black: string[],
|
|
|
warningMessages: string[]
|
|
warningMessages: string[]
|
|
|
]>(
|
|
]>(
|
|
|
filterRulesUrl,
|
|
filterRulesUrl,
|
|
|
- async () => {
|
|
|
|
|
|
|
+ */async () => {
|
|
|
const whitelistDomainSets = new Set<string>();
|
|
const whitelistDomainSets = new Set<string>();
|
|
|
const blacklistDomainSets = new Set<string>();
|
|
const blacklistDomainSets = new Set<string>();
|
|
|
|
|
|
|
@@ -192,14 +191,14 @@ export async function processFilterRules(
|
|
|
Array.from(blacklistDomainSets),
|
|
Array.from(blacklistDomainSets),
|
|
|
warningMessages
|
|
warningMessages
|
|
|
];
|
|
];
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ });
|
|
|
|
|
+ /* {
|
|
|
ttl,
|
|
ttl,
|
|
|
temporaryBypass: DEBUG_DOMAIN_TO_FIND !== null,
|
|
temporaryBypass: DEBUG_DOMAIN_TO_FIND !== null,
|
|
|
serializer: JSON.stringify,
|
|
serializer: JSON.stringify,
|
|
|
deserializer: JSON.parse
|
|
deserializer: JSON.parse
|
|
|
}
|
|
}
|
|
|
- ));
|
|
|
|
|
|
|
+ ) */
|
|
|
|
|
|
|
|
warningMessages.forEach(msg => {
|
|
warningMessages.forEach(msg => {
|
|
|
console.warn(
|
|
console.warn(
|