Skip to content

Commit

Permalink
Merge branch 'SukkaW:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
FYLSen authored Dec 16, 2024
2 parents e13dca4 + 3034783 commit 0b61edc
Show file tree
Hide file tree
Showing 32 changed files with 447 additions and 878 deletions.
10 changes: 5 additions & 5 deletions Build/build-reject-domainset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { task } from './trace';
import { SHARED_DESCRIPTION } from './constants/description';
import { getPhishingDomains } from './lib/get-phishing-domains';

import { setAddFromArray } from './lib/set-add-from-array';
import { addArrayElementsToSet } from 'foxts/add-array-elements-to-set';
import { appendArrayInPlace } from './lib/append-array-in-place';
import { OUTPUT_INTERNAL_DIR, SOURCE_DIR } from './constants/dir';
import { DomainsetOutput } from './lib/create-file';
Expand Down Expand Up @@ -77,7 +77,7 @@ export const buildRejectDomainSet = task(require.main === module, __filename)(as
shouldStop = true;
// we should not break here, as we want to see full matches from all data source
}
setAddFromArray(filterRuleWhitelistDomainSets, white);
addArrayElementsToSet(filterRuleWhitelistDomainSets, white);
appendArrayToRejectOutput(black);
})
),
Expand All @@ -89,13 +89,13 @@ export const buildRejectDomainSet = task(require.main === module, __filename)(as
shouldStop = true;
// we should not break here, as we want to see full matches from all data source
}
setAddFromArray(filterRuleWhitelistDomainSets, white);
addArrayElementsToSet(filterRuleWhitelistDomainSets, white);
appendArrayToRejectExtraOutput(black);
})
),
ADGUARD_FILTERS_WHITELIST.map(entry => processFilterRules(childSpan, ...entry).then(({ white, black }) => {
setAddFromArray(filterRuleWhitelistDomainSets, white);
setAddFromArray(filterRuleWhitelistDomainSets, black);
addArrayElementsToSet(filterRuleWhitelistDomainSets, white);
addArrayElementsToSet(filterRuleWhitelistDomainSets, black);
})),
getPhishingDomains(childSpan).then(appendArrayToRejectExtraOutput),
readFileIntoProcessedArray(path.join(SOURCE_DIR, 'domainset/reject_sukka.conf')).then(appendArrayToRejectOutput),
Expand Down
2 changes: 1 addition & 1 deletion Build/build-reject-ip-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import path from 'node:path';
import { createReadlineInterfaceFromResponse, readFileIntoProcessedArray } from './lib/fetch-text-by-line';
import { task } from './trace';
import { SHARED_DESCRIPTION } from './constants/description';
import { isProbablyIpv4, isProbablyIpv6 } from './lib/is-fast-ip';
import { isProbablyIpv4, isProbablyIpv6 } from 'foxts/is-probably-ip';
import { fsFetchCache, getFileContentHash } from './lib/cache-filesystem';
import { processLine } from './lib/process-line';
import { RulesetOutput } from './lib/create-file';
Expand Down
2 changes: 1 addition & 1 deletion Build/build-telegram-cidr.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-check
import { createReadlineInterfaceFromResponse } from './lib/fetch-text-by-line';
import { isProbablyIpv4, isProbablyIpv6 } from './lib/is-fast-ip';
import { isProbablyIpv4, isProbablyIpv6 } from 'foxts/is-probably-ip';
import { task } from './trace';
import { SHARED_DESCRIPTION } from './constants/description';
import { createMemoizedPromise } from './lib/memo-promise';
Expand Down
74 changes: 0 additions & 74 deletions Build/lib/aho-corasick.bench.ts

This file was deleted.

33 changes: 0 additions & 33 deletions Build/lib/aho-corasick.test.ts

This file was deleted.

79 changes: 0 additions & 79 deletions Build/lib/aho-corasick.ts

This file was deleted.

4 changes: 2 additions & 2 deletions Build/lib/cache-filesystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { identity } from 'foxts/identity';
import { fastStringArrayJoin } from 'foxts/fast-string-array-join';
import { performance } from 'node:perf_hooks';
import fs from 'node:fs';
import { stringHash } from './string-hash';
import { simpleStringHash } from 'foxts/simple-string-hash';
import { defaultRequestInit, requestWithLog, ResponseError } from './fetch-retry';
import type { UndiciResponseData } from './fetch-retry';
// import type { UndiciResponseData } from './fetch-retry';
Expand Down Expand Up @@ -447,7 +447,7 @@ export const deserializeSet = (str: string) => new Set(str.split(separator));
export const serializeArray = (arr: string[]) => fastStringArrayJoin(arr, separator);
export const deserializeArray = (str: string) => str.split(separator);

export const getFileContentHash = (filename: string) => stringHash(fs.readFileSync(filename, 'utf-8'));
export const getFileContentHash = (filename: string) => simpleStringHash(fs.readFileSync(filename, 'utf-8'));
export function createCacheKey(filename: string) {
const fileHash = getFileContentHash(filename);
return (key: string) => key + '$' + fileHash + '$';
Expand Down
5 changes: 2 additions & 3 deletions Build/lib/fetch-assets.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import picocolors from 'picocolors';
import { defaultRequestInit, requestWithLog, ResponseError } from './fetch-retry';
import { setTimeout } from 'node:timers/promises';
import { wait } from 'foxts/wait';

// eslint-disable-next-line sukka/unicorn/custom-error-definition -- typescript is better
export class CustomAbortError extends Error {
Expand Down Expand Up @@ -35,8 +35,7 @@ export function sleepWithAbort(ms: number, signal: AbortSignal) {

signal.addEventListener('abort', stop, { once: true });

// eslint-disable-next-line sukka/prefer-timer-id -- node:timers/promises
setTimeout(ms, undefined, { ref: false }).then(resolve).catch(reject).finally(() => signal.removeEventListener('abort', stop));
wait(ms).then(resolve).catch(reject).finally(() => signal.removeEventListener('abort', stop));

function stop(this: AbortSignal) { reject(this.reason as Error); }
});
Expand Down
63 changes: 0 additions & 63 deletions Build/lib/fifo.ts

This file was deleted.

2 changes: 1 addition & 1 deletion Build/lib/get-phishing-domains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { appendArrayInPlaceCurried } from './append-array-in-place';
import { DEBUG_DOMAIN_TO_FIND, PHISHING_DOMAIN_LISTS_EXTRA, PHISHING_HOSTS_EXTRA } from '../constants/reject-data-source';
import { loosTldOptWithPrivateDomains } from '../constants/loose-tldts-opt';
import picocolors from 'picocolors';
import createKeywordFilter from './aho-corasick';
import { createAhoCorasick as createKeywordFilter } from 'foxts/ahocorasick';
import { createCacheKey, deserializeArray, serializeArray } from './cache-filesystem';
import { cache } from './fs-memo';
import { isCI } from 'ci-info';
Expand Down
Loading

0 comments on commit 0b61edc

Please sign in to comment.