mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-12 01:00:34 +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),
|
||||
readFileIntoProcessedArray(path.join(SOURCE_DIR, 'domainset/reject_sukka.conf')).then(appendArrayToRejectOutput),
|
||||
// Dedupe domainSets
|
||||
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'))) {
|
||||
const [type, value] = line.split(',');
|
||||
switch (type) {
|
||||
case 'DOMAIN-KEYWORD': {
|
||||
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
|
||||
}
|
||||
}
|
||||
})
|
||||
// span.traceChildAsync('collect black keywords/suffixes', async () =>
|
||||
/**
|
||||
* Collect DOMAIN, DOMAIN-SUFFIX, and DOMAIN-KEYWORD from non_ip/reject.conf for deduplication
|
||||
* DOMAIN-WILDCARD is not really useful for deduplication, it is only included in AdGuardHome output
|
||||
*/
|
||||
rejectOutput.addFromRuleset(readFileByLine(path.resolve(__dirname, '../Source/non_ip/reject.conf')))
|
||||
].flat());
|
||||
// eslint-disable-next-line sukka/no-single-return -- not single return
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user