mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-13 01:30:37 +08:00
Fix Reject Process
This commit is contained in:
parent
7905ec447f
commit
dc4d978c8a
@ -46,7 +46,7 @@ export const buildRejectDomainSet = task(require.main === module, __filename)(as
|
|||||||
DOMAIN_LISTS_EXTRA.map(entry => processDomainLists(childSpan, ...entry).then(appendArrayToDomainSetsExtra)),
|
DOMAIN_LISTS_EXTRA.map(entry => processDomainLists(childSpan, ...entry).then(appendArrayToDomainSetsExtra)),
|
||||||
|
|
||||||
ADGUARD_FILTERS.map(
|
ADGUARD_FILTERS.map(
|
||||||
input => processFilterRules(childSpan, ...input)
|
entry => processFilterRules(childSpan, ...entry)
|
||||||
.then(({ white, black, foundDebugDomain }) => {
|
.then(({ white, black, foundDebugDomain }) => {
|
||||||
if (foundDebugDomain) {
|
if (foundDebugDomain) {
|
||||||
// eslint-disable-next-line sukka/no-single-return -- not single return
|
// eslint-disable-next-line sukka/no-single-return -- not single return
|
||||||
@ -58,7 +58,7 @@ export const buildRejectDomainSet = task(require.main === module, __filename)(as
|
|||||||
})
|
})
|
||||||
),
|
),
|
||||||
ADGUARD_FILTERS_EXTRA.map(
|
ADGUARD_FILTERS_EXTRA.map(
|
||||||
input => processFilterRules(childSpan, ...input)
|
entry => processFilterRules(childSpan, ...entry)
|
||||||
.then(({ white, black, foundDebugDomain }) => {
|
.then(({ white, black, foundDebugDomain }) => {
|
||||||
if (foundDebugDomain) {
|
if (foundDebugDomain) {
|
||||||
// eslint-disable-next-line sukka/no-single-return -- not single return
|
// eslint-disable-next-line sukka/no-single-return -- not single return
|
||||||
|
|||||||
@ -56,8 +56,6 @@ export const DOMAIN_LISTS_EXTRA: HostsSource[] = [
|
|||||||
['https://raw.githubusercontent.com/AdguardTeam/cname-trackers/master/data/combined_disguised_clickthroughs_justdomains.txt', [], true, TTL.THREE_DAYS()],
|
['https://raw.githubusercontent.com/AdguardTeam/cname-trackers/master/data/combined_disguised_clickthroughs_justdomains.txt', [], true, TTL.THREE_DAYS()],
|
||||||
['https://raw.githubusercontent.com/AdguardTeam/cname-trackers/master/data/combined_disguised_microsites_justdomains.txt', [], true, TTL.THREE_DAYS()],
|
['https://raw.githubusercontent.com/AdguardTeam/cname-trackers/master/data/combined_disguised_microsites_justdomains.txt', [], true, TTL.THREE_DAYS()],
|
||||||
['https://raw.githubusercontent.com/AdguardTeam/cname-trackers/master/data/combined_disguised_mail_trackers_justdomains.txt', [], true, TTL.THREE_DAYS()],
|
['https://raw.githubusercontent.com/AdguardTeam/cname-trackers/master/data/combined_disguised_mail_trackers_justdomains.txt', [], true, TTL.THREE_DAYS()],
|
||||||
// AdGuard Cookie Notices
|
|
||||||
['https://filters.adtidy.org/extension/ublock/filters/18_optimized.txt', [], true, TTL.THREE_HOURS()],
|
|
||||||
// Curben's PUP Domains Blocklist
|
// Curben's PUP Domains Blocklist
|
||||||
// 'https://curbengh.github.io/pup-filter/pup-filter-agh.txt'
|
// 'https://curbengh.github.io/pup-filter/pup-filter-agh.txt'
|
||||||
// 'https://pup-filter.pages.dev/pup-filter-agh.txt'
|
// 'https://pup-filter.pages.dev/pup-filter-agh.txt'
|
||||||
@ -154,6 +152,8 @@ export const ADGUARD_FILTERS: AdGuardFilterSource[] = [
|
|||||||
export const ADGUARD_FILTERS_EXTRA: AdGuardFilterSource[] = [
|
export const ADGUARD_FILTERS_EXTRA: AdGuardFilterSource[] = [
|
||||||
// AdGuard Annoyances filter
|
// AdGuard Annoyances filter
|
||||||
['https://filters.adtidy.org/android/filters/14_optimized.txt', null, TTL.THREE_HOURS()],
|
['https://filters.adtidy.org/android/filters/14_optimized.txt', null, TTL.THREE_HOURS()],
|
||||||
|
// AdGuard Cookie Notices
|
||||||
|
['https://filters.adtidy.org/extension/ublock/filters/18_optimized.txt', null, TTL.THREE_HOURS()],
|
||||||
// EasyList Germany filter
|
// EasyList Germany filter
|
||||||
[
|
[
|
||||||
'https://easylist.to/easylistgermany/easylistgermany.txt',
|
'https://easylist.to/easylistgermany/easylistgermany.txt',
|
||||||
|
|||||||
18
Build/lib/parse-filter.test.ts
Normal file
18
Build/lib/parse-filter.test.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import { describe, it } from 'mocha';
|
||||||
|
|
||||||
|
import { processFilterRules } from './parse-filter';
|
||||||
|
import { createCacheKey } from './cache-filesystem';
|
||||||
|
import { createSpan } from '../trace';
|
||||||
|
|
||||||
|
const cacheKey = createCacheKey(__filename);
|
||||||
|
|
||||||
|
describe('processFilterRules', () => {
|
||||||
|
it('https://filters.adtidy.org/extension/ublock/filters/18_optimized.txt', () => {
|
||||||
|
console.log(processFilterRules(
|
||||||
|
createSpan('noop'),
|
||||||
|
cacheKey('https://filters.adtidy.org/extension/ublock/filters/18_optimized.txt'),
|
||||||
|
[],
|
||||||
|
7_200_000
|
||||||
|
));
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -14,14 +14,25 @@ import { looseTldtsOpt } from '../constants/loose-tldts-opt';
|
|||||||
|
|
||||||
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;
|
||||||
const temporaryBypass = true;
|
const temporaryBypass = typeof DEBUG_DOMAIN_TO_FIND === 'string';
|
||||||
|
|
||||||
const domainListLineCb = (l: string, set: string[], includeAllSubDomain: boolean, meta: string) => {
|
const domainListLineCb = (l: string, set: string[], includeAllSubDomain: boolean, meta: string) => {
|
||||||
let line = processLine(l);
|
let line = processLine(l);
|
||||||
if (!line) return;
|
if (!line) return;
|
||||||
|
line = line.toLowerCase();
|
||||||
|
|
||||||
line = normalizeDomain(line);
|
const domain = normalizeDomain(line);
|
||||||
if (!line) return;
|
if (!domain) return;
|
||||||
|
if (domain !== line) {
|
||||||
|
console.log(
|
||||||
|
picocolors.red('[process domain list]'),
|
||||||
|
picocolors.gray(`line: ${line}`),
|
||||||
|
picocolors.gray(`domain: ${domain}`),
|
||||||
|
picocolors.gray(meta)
|
||||||
|
);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (DEBUG_DOMAIN_TO_FIND && line.includes(DEBUG_DOMAIN_TO_FIND)) {
|
if (DEBUG_DOMAIN_TO_FIND && line.includes(DEBUG_DOMAIN_TO_FIND)) {
|
||||||
console.warn(picocolors.red(meta), '(black)', line.replaceAll(DEBUG_DOMAIN_TO_FIND, picocolors.bold(DEBUG_DOMAIN_TO_FIND)));
|
console.warn(picocolors.red(meta), '(black)', line.replaceAll(DEBUG_DOMAIN_TO_FIND, picocolors.bold(DEBUG_DOMAIN_TO_FIND)));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user