Chore: drop reject stats generation

This commit is contained in:
SukkaW
2025-01-17 20:43:56 +08:00
parent 79c8e2ceef
commit 43085cc00e
3 changed files with 3 additions and 59 deletions

View File

@@ -1,11 +1,7 @@
import { invariant } from 'foxts/guard';
import { createRetrieKeywordFilter as createKeywordFilter } from 'foxts/retrie';
import { RuleOutput } from './base';
import type { SingboxSourceFormat } from '../singbox';
import * as tldts from 'tldts-experimental';
import { looseTldtsOpt } from '../../constants/loose-tldts-opt';
import { fastStringCompare } from '../misc';
import { escapeStringRegexp } from 'foxts/escape-string-regexp';
export class DomainsetOutput extends RuleOutput<string[]> {
@@ -55,42 +51,6 @@ export class DomainsetOutput extends RuleOutput<string[]> {
} satisfies SingboxSourceFormat);
}
protected apexDomainMap: Map<string, string> | null = null;
getStatMap() {
this.runPreprocess();
invariant(this.$preprocessed, 'Non dumped yet');
if (!this.apexDomainMap) {
const domainMap = new Map<string, string>();
for (let i = 0, len = this.$preprocessed.length; i < len; i++) {
const cur = this.$preprocessed[i];
if (!domainMap.has(cur)) {
const domain = tldts.getDomain(cur, looseTldtsOpt);
domainMap.set(cur, domain ?? cur);
}
}
this.apexDomainMap = domainMap;
}
return Array.from(this.$preprocessed
.reduce<Map<string, number>>(
(acc, cur) => {
const suffix = this.apexDomainMap!.get(cur);
if (suffix) {
acc.set(suffix, (acc.get(suffix) ?? 0) + 1);
}
return acc;
},
new Map()
)
.entries())
.filter(a => a[1] > 9)
.sort((a, b) => (b[1] - a[1]) || fastStringCompare(a[0], b[0]))
.map(([domain, count]) => `${domain}${' '.repeat(100 - domain.length)}${count}`);
}
mitmSgmodule = undefined;
adguardhome(): string[] {