mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-14 02:00:37 +08:00
Feat: include my_reject in adguardhome
This commit is contained in:
parent
e43ba55357
commit
4e9e206ec0
@ -6,7 +6,7 @@ import { processHosts, processFilterRules, processDomainLists } from './lib/pars
|
|||||||
|
|
||||||
import { HOSTS, ADGUARD_FILTERS, PREDEFINED_WHITELIST, DOMAIN_LISTS, HOSTS_EXTRA, DOMAIN_LISTS_EXTRA, ADGUARD_FILTERS_EXTRA, PHISHING_DOMAIN_LISTS_EXTRA, ADGUARD_FILTERS_WHITELIST } from './constants/reject-data-source';
|
import { HOSTS, ADGUARD_FILTERS, PREDEFINED_WHITELIST, DOMAIN_LISTS, HOSTS_EXTRA, DOMAIN_LISTS_EXTRA, ADGUARD_FILTERS_EXTRA, PHISHING_DOMAIN_LISTS_EXTRA, ADGUARD_FILTERS_WHITELIST } from './constants/reject-data-source';
|
||||||
import { compareAndWriteFile } from './lib/create-file';
|
import { compareAndWriteFile } from './lib/create-file';
|
||||||
import { readFileByLine, readFileIntoProcessedArray } from './lib/fetch-text-by-line';
|
import { readFileIntoProcessedArray } from './lib/fetch-text-by-line';
|
||||||
import { task } from './trace';
|
import { task } from './trace';
|
||||||
// tldts-experimental is way faster than tldts, but very little bit inaccurate
|
// tldts-experimental is way faster than tldts, but very little bit inaccurate
|
||||||
// (since it is hashes based). But the result is still deterministic, which is
|
// (since it is hashes based). But the result is still deterministic, which is
|
||||||
@ -21,7 +21,8 @@ import { DomainsetOutput } from './lib/create-file';
|
|||||||
|
|
||||||
const readLocalRejectDomainsetPromise = readFileIntoProcessedArray(path.join(SOURCE_DIR, 'domainset/reject_sukka.conf'));
|
const readLocalRejectDomainsetPromise = readFileIntoProcessedArray(path.join(SOURCE_DIR, 'domainset/reject_sukka.conf'));
|
||||||
const readLocalRejectExtraDomainsetPromise = readFileIntoProcessedArray(path.join(SOURCE_DIR, 'domainset/reject_sukka_extra.conf'));
|
const readLocalRejectExtraDomainsetPromise = readFileIntoProcessedArray(path.join(SOURCE_DIR, 'domainset/reject_sukka_extra.conf'));
|
||||||
const readLocalRejectRulesetPromise = readFileByLine(path.join(SOURCE_DIR, 'non_ip/reject.conf'));
|
const readLocalRejectRulesetPromise = readFileIntoProcessedArray(path.join(SOURCE_DIR, 'non_ip/reject.conf'));
|
||||||
|
const readLocalMyRejectRulesetPromise = readFileIntoProcessedArray(path.join(SOURCE_DIR, 'non_ip/my_reject.conf'));
|
||||||
|
|
||||||
export const buildRejectDomainSet = task(require.main === module, __filename)(async (span) => {
|
export const buildRejectDomainSet = task(require.main === module, __filename)(async (span) => {
|
||||||
const rejectBaseDescription = [
|
const rejectBaseDescription = [
|
||||||
@ -171,7 +172,15 @@ export const buildRejectDomainSet = task(require.main === module, __filename)(as
|
|||||||
'! Description: The domainset supports AD blocking, tracking protection, privacy protection, anti-phishing, anti-mining',
|
'! Description: The domainset supports AD blocking, tracking protection, privacy protection, anti-phishing, anti-mining',
|
||||||
'!'
|
'!'
|
||||||
],
|
],
|
||||||
rejectOutput.adguardhome()
|
appendArrayInPlace(
|
||||||
|
rejectOutput.adguardhome(),
|
||||||
|
(
|
||||||
|
await new DomainsetOutput(span, 'my_reject')
|
||||||
|
.addFromRuleset(readLocalMyRejectRulesetPromise)
|
||||||
|
.addFromRuleset(readLocalRejectRulesetPromise)
|
||||||
|
.done()
|
||||||
|
).adguardhome()
|
||||||
|
)
|
||||||
),
|
),
|
||||||
path.join(OUTPUT_INTERNAL_DIR, 'reject-adguardhome.txt')
|
path.join(OUTPUT_INTERNAL_DIR, 'reject-adguardhome.txt')
|
||||||
)
|
)
|
||||||
|
|||||||
@ -36,7 +36,7 @@ export abstract class RuleOutput<TPreprocessed = unknown> {
|
|||||||
protected otherRules: string[] = [];
|
protected otherRules: string[] = [];
|
||||||
protected abstract type: 'domainset' | 'non_ip' | 'ip';
|
protected abstract type: 'domainset' | 'non_ip' | 'ip';
|
||||||
|
|
||||||
private pendingPromise: Promise<void> | null = null;
|
private pendingPromise: Promise<any> | null = null;
|
||||||
|
|
||||||
static readonly jsonToLines = (json: unknown): string[] => stringify(json).split('\n');
|
static readonly jsonToLines = (json: unknown): string[] => stringify(json).split('\n');
|
||||||
|
|
||||||
@ -201,8 +201,13 @@ export abstract class RuleOutput<TPreprocessed = unknown> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addFromRuleset(source: AsyncIterable<string> | Iterable<string>) {
|
addFromRuleset(source: AsyncIterable<string> | Iterable<string> | Promise<Iterable<string>>) {
|
||||||
this.pendingPromise = (this.pendingPromise ||= Promise.resolve()).then(() => this.addFromRulesetPromise(source));
|
if (this.pendingPromise) {
|
||||||
|
this.pendingPromise = this.pendingPromise.then(() => source);
|
||||||
|
} else {
|
||||||
|
this.pendingPromise = Promise.resolve(source);
|
||||||
|
}
|
||||||
|
this.pendingPromise = this.pendingPromise.then((source) => this.addFromRulesetPromise(source));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -247,6 +252,7 @@ export abstract class RuleOutput<TPreprocessed = unknown> {
|
|||||||
async done() {
|
async done() {
|
||||||
await this.pendingPromise;
|
await this.pendingPromise;
|
||||||
this.pendingPromise = null;
|
this.pendingPromise = null;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private guardPendingPromise() {
|
private guardPendingPromise() {
|
||||||
|
|||||||
@ -38,18 +38,6 @@ DOMAIN-SUFFIX,uhabo.com
|
|||||||
DOMAIN-SUFFIX,xycdn.com
|
DOMAIN-SUFFIX,xycdn.com
|
||||||
|
|
||||||
# >> Misc
|
# >> Misc
|
||||||
DOMAIN-SUFFIX,parallels.com
|
|
||||||
DOMAIN-SUFFIX,www.parallelskorea.com
|
|
||||||
DOMAIN-SUFFIX,parallels.cn
|
|
||||||
DOMAIN-SUFFIX,parallels.de
|
|
||||||
DOMAIN-SUFFIX,parallels.es
|
|
||||||
DOMAIN-SUFFIX,parallels.fr
|
|
||||||
DOMAIN-SUFFIX,parallels.nl
|
|
||||||
DOMAIN-SUFFIX,parallels.pt
|
|
||||||
DOMAIN-SUFFIX,parallels.ru
|
|
||||||
DOMAIN-SUFFIX,parallelskorea.com
|
|
||||||
DOMAIN-SUFFIX,myparallels.com
|
|
||||||
DOMAIN-SUFFIX,my.parallels.com
|
|
||||||
|
|
||||||
DOMAIN-KEYWORD,bahoom
|
DOMAIN-KEYWORD,bahoom
|
||||||
DOMAIN,daisydiskapp.com
|
DOMAIN,daisydiskapp.com
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user