mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-14 02:00:37 +08:00
Feat: include DOMAIN-WILDCARD in AdGuardHome output
This commit is contained in:
parent
7d182e3fdb
commit
ec0ce55487
@ -101,28 +101,12 @@ export const buildRejectDomainSet = task(require.main === module, __filename)(as
|
|||||||
getPhishingDomains(childSpan).then(appendArrayToRejectExtraOutput),
|
getPhishingDomains(childSpan).then(appendArrayToRejectExtraOutput),
|
||||||
readFileIntoProcessedArray(path.join(SOURCE_DIR, 'domainset/reject_sukka.conf')).then(appendArrayToRejectOutput),
|
readFileIntoProcessedArray(path.join(SOURCE_DIR, 'domainset/reject_sukka.conf')).then(appendArrayToRejectOutput),
|
||||||
// Dedupe domainSets
|
// Dedupe domainSets
|
||||||
span.traceChildAsync('collect black keywords/suffixes', async () => {
|
// span.traceChildAsync('collect black keywords/suffixes', async () =>
|
||||||
/** Collect DOMAIN-KEYWORD from non_ip/reject.conf for deduplication */
|
/**
|
||||||
for await (const line of readFileByLine(path.resolve(__dirname, '../Source/non_ip/reject.conf'))) {
|
* Collect DOMAIN, DOMAIN-SUFFIX, and DOMAIN-KEYWORD from non_ip/reject.conf for deduplication
|
||||||
const [type, value] = line.split(',');
|
* DOMAIN-WILDCARD is not really useful for deduplication, it is only included in AdGuardHome output
|
||||||
switch (type) {
|
*/
|
||||||
case 'DOMAIN-KEYWORD': {
|
rejectOutput.addFromRuleset(readFileByLine(path.resolve(__dirname, '../Source/non_ip/reject.conf')))
|
||||||
rejectOutput.addDomainKeyword(value); // Add for later deduplication
|
|
||||||
rejectExtraOutput.addDomainKeyword(value); // Add for later deduplication
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'DOMAIN-SUFFIX': {
|
|
||||||
filterRuleWhitelistDomainSets.add('.' + value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'DOMAIN': {
|
|
||||||
rejectOutput.addDomain(value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// no default
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
].flat());
|
].flat());
|
||||||
// eslint-disable-next-line sukka/no-single-return -- not single return
|
// eslint-disable-next-line sukka/no-single-return -- not single return
|
||||||
return shouldStop;
|
return shouldStop;
|
||||||
|
|||||||
@ -114,6 +114,15 @@ export class DomainsetOutput extends RuleOutput<Preprocessed> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const wildcard of this.domainWildcard) {
|
||||||
|
const processed = wildcard.replaceAll('?', '*');
|
||||||
|
if (processed.startsWith('*.')) {
|
||||||
|
results.push(`||${processed.slice(2)}^`);
|
||||||
|
} else {
|
||||||
|
results.push(`|${processed}^`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user