mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-12 01:00:34 +08:00
Chore: update ruleset marker
This commit is contained in:
parent
3aac2a8893
commit
9f821b84ca
@ -7,3 +7,6 @@ export function createFileDescription(license = 'AGPL 3.0') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const SHARED_DESCRIPTION = createFileDescription('AGPL 3.0');
|
export const SHARED_DESCRIPTION = createFileDescription('AGPL 3.0');
|
||||||
|
|
||||||
|
// this_ruleset_is_made_by_sukkaw.ruleset.skk.moe
|
||||||
|
export const MARKER_DOMAIN = 'th1s_rule5et_1s_m4d3_by_5ukk4w_ruleset.skk.moe';
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import { noop } from 'foxts/noop';
|
|||||||
import { fastIpVersion, notSupported, withBannerArray } from '../misc';
|
import { fastIpVersion, notSupported, withBannerArray } from '../misc';
|
||||||
import { OUTPUT_CLASH_DIR } from '../../constants/dir';
|
import { OUTPUT_CLASH_DIR } from '../../constants/dir';
|
||||||
import { appendArrayInPlace } from 'foxts/append-array-in-place';
|
import { appendArrayInPlace } from 'foxts/append-array-in-place';
|
||||||
|
import { MARKER_DOMAIN } from '../../constants/description';
|
||||||
|
|
||||||
export class ClashDomainSet extends BaseWriteStrategy {
|
export class ClashDomainSet extends BaseWriteStrategy {
|
||||||
public readonly name = 'clash domainset';
|
public readonly name = 'clash domainset';
|
||||||
@ -12,7 +13,7 @@ export class ClashDomainSet extends BaseWriteStrategy {
|
|||||||
readonly fileExtension = 'txt';
|
readonly fileExtension = 'txt';
|
||||||
readonly type = 'domainset';
|
readonly type = 'domainset';
|
||||||
|
|
||||||
protected result: string[] = ['this_ruleset_is_made_by_sukkaw.ruleset.skk.moe'];
|
protected result: string[] = [MARKER_DOMAIN];
|
||||||
|
|
||||||
constructor(public readonly outputDir = OUTPUT_CLASH_DIR) {
|
constructor(public readonly outputDir = OUTPUT_CLASH_DIR) {
|
||||||
super(outputDir);
|
super(outputDir);
|
||||||
@ -90,7 +91,7 @@ export class ClashClassicRuleSet extends BaseWriteStrategy {
|
|||||||
|
|
||||||
readonly fileExtension = 'txt';
|
readonly fileExtension = 'txt';
|
||||||
|
|
||||||
protected result: string[] = ['DOMAIN,this_ruleset_is_made_by_sukkaw.ruleset.skk.moe'];
|
protected result: string[] = [`DOMAIN,${MARKER_DOMAIN}`];
|
||||||
|
|
||||||
constructor(public readonly type: 'ip' | 'non_ip' /* | (string & {}) */, public readonly outputDir = OUTPUT_CLASH_DIR) {
|
constructor(public readonly type: 'ip' | 'non_ip' /* | (string & {}) */, public readonly outputDir = OUTPUT_CLASH_DIR) {
|
||||||
super(outputDir);
|
super(outputDir);
|
||||||
|
|||||||
@ -1,13 +1,14 @@
|
|||||||
import { noop } from 'foxts/noop';
|
import { noop } from 'foxts/noop';
|
||||||
import { OUTPUT_LEAGCY_CLASH_PREMIUM_DIR } from '../../constants/dir';
|
import { OUTPUT_LEAGCY_CLASH_PREMIUM_DIR } from '../../constants/dir';
|
||||||
import { ClashClassicRuleSet } from './clash';
|
import { ClashClassicRuleSet } from './clash';
|
||||||
|
import { MARKER_DOMAIN } from '../../constants/description';
|
||||||
|
|
||||||
export class LegacyClashPremiumClassicRuleSet extends ClashClassicRuleSet {
|
export class LegacyClashPremiumClassicRuleSet extends ClashClassicRuleSet {
|
||||||
public override readonly name = 'legacy clash premium classic ruleset';
|
public override readonly name = 'legacy clash premium classic ruleset';
|
||||||
|
|
||||||
readonly fileExtension = 'txt';
|
readonly fileExtension = 'txt';
|
||||||
|
|
||||||
protected result: string[] = ['DOMAIN,this_ruleset_is_made_by_sukkaw.ruleset.skk.moe'];
|
protected result: string[] = [`DOMAIN,${MARKER_DOMAIN}`];
|
||||||
|
|
||||||
constructor(public readonly type: 'ip' | 'non_ip' /* | (string & {}) */, public readonly outputDir = OUTPUT_LEAGCY_CLASH_PREMIUM_DIR) {
|
constructor(public readonly type: 'ip' | 'non_ip' /* | (string & {}) */, public readonly outputDir = OUTPUT_LEAGCY_CLASH_PREMIUM_DIR) {
|
||||||
super(type, outputDir);
|
super(type, outputDir);
|
||||||
|
|||||||
@ -4,10 +4,11 @@ import { noop } from 'foxts/noop';
|
|||||||
import { fastIpVersion, withIdentityContent } from '../misc';
|
import { fastIpVersion, withIdentityContent } from '../misc';
|
||||||
import stringify from 'json-stringify-pretty-compact';
|
import stringify from 'json-stringify-pretty-compact';
|
||||||
import { OUTPUT_SINGBOX_DIR } from '../../constants/dir';
|
import { OUTPUT_SINGBOX_DIR } from '../../constants/dir';
|
||||||
|
import { MARKER_DOMAIN } from '../../constants/description';
|
||||||
|
|
||||||
interface SingboxHeadlessRule {
|
interface SingboxHeadlessRule {
|
||||||
domain: string[], // this_ruleset_is_made_by_sukkaw.ruleset.skk.moe
|
domain: string[],
|
||||||
domain_suffix: string[], // this_ruleset_is_made_by_sukkaw.ruleset.skk.moe
|
domain_suffix: string[],
|
||||||
domain_keyword?: string[],
|
domain_keyword?: string[],
|
||||||
domain_regex?: string[],
|
domain_regex?: string[],
|
||||||
source_ip_cidr?: string[],
|
source_ip_cidr?: string[],
|
||||||
@ -34,8 +35,8 @@ export class SingboxSource extends BaseWriteStrategy {
|
|||||||
static readonly jsonToLines = (json: unknown): string[] => stringify(json).split('\n');
|
static readonly jsonToLines = (json: unknown): string[] => stringify(json).split('\n');
|
||||||
|
|
||||||
private singbox: SingboxHeadlessRule = {
|
private singbox: SingboxHeadlessRule = {
|
||||||
domain: ['this_ruleset_is_made_by_sukkaw.ruleset.skk.moe'],
|
domain: [MARKER_DOMAIN],
|
||||||
domain_suffix: ['this_ruleset_is_made_by_sukkaw.ruleset.skk.moe']
|
domain_suffix: [MARKER_DOMAIN]
|
||||||
};
|
};
|
||||||
|
|
||||||
protected get result() {
|
protected get result() {
|
||||||
|
|||||||
@ -2,11 +2,12 @@ import { noop } from 'foxts/noop';
|
|||||||
import { SurgeRuleSet } from './surge';
|
import { SurgeRuleSet } from './surge';
|
||||||
import { OUTPUT_SURFBOARD_DIR } from '../../constants/dir';
|
import { OUTPUT_SURFBOARD_DIR } from '../../constants/dir';
|
||||||
import { appendSetElementsToArray } from 'foxts/append-set-elements-to-array';
|
import { appendSetElementsToArray } from 'foxts/append-set-elements-to-array';
|
||||||
|
import { MARKER_DOMAIN } from '../../constants/description';
|
||||||
|
|
||||||
export class SurfboardRuleSet extends SurgeRuleSet {
|
export class SurfboardRuleSet extends SurgeRuleSet {
|
||||||
public override readonly name: string = 'surfboard for android ruleset';
|
public override readonly name: string = 'surfboard for android ruleset';
|
||||||
|
|
||||||
protected result: string[] = ['DOMAIN,this_ruleset_is_made_by_sukkaw.ruleset.skk.moe'];
|
protected result: string[] = [`DOMAIN,${MARKER_DOMAIN}`];
|
||||||
constructor(public readonly type: 'ip' | 'non_ip' /* | (string & {}) */, public readonly outputDir = OUTPUT_SURFBOARD_DIR) {
|
constructor(public readonly type: 'ip' | 'non_ip' /* | (string & {}) */, public readonly outputDir = OUTPUT_SURFBOARD_DIR) {
|
||||||
super(type, outputDir);
|
super(type, outputDir);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import picocolors from 'picocolors';
|
|||||||
import { normalizeDomain } from '../normalize-domain';
|
import { normalizeDomain } from '../normalize-domain';
|
||||||
import { OUTPUT_MODULES_DIR, OUTPUT_SURGE_DIR } from '../../constants/dir';
|
import { OUTPUT_MODULES_DIR, OUTPUT_SURGE_DIR } from '../../constants/dir';
|
||||||
import { withBannerArray, withIdentityContent } from '../misc';
|
import { withBannerArray, withIdentityContent } from '../misc';
|
||||||
|
import { MARKER_DOMAIN } from '../../constants/description';
|
||||||
|
|
||||||
export class SurgeDomainSet extends BaseWriteStrategy {
|
export class SurgeDomainSet extends BaseWriteStrategy {
|
||||||
public readonly name = 'surge domainset';
|
public readonly name = 'surge domainset';
|
||||||
@ -15,7 +16,7 @@ export class SurgeDomainSet extends BaseWriteStrategy {
|
|||||||
readonly fileExtension = 'conf';
|
readonly fileExtension = 'conf';
|
||||||
type = 'domainset';
|
type = 'domainset';
|
||||||
|
|
||||||
protected result: string[] = ['this_ruleset_is_made_by_sukkaw.ruleset.skk.moe'];
|
protected result: string[] = [MARKER_DOMAIN];
|
||||||
|
|
||||||
constructor(outputDir = OUTPUT_SURGE_DIR) {
|
constructor(outputDir = OUTPUT_SURGE_DIR) {
|
||||||
super(outputDir);
|
super(outputDir);
|
||||||
@ -53,7 +54,7 @@ export class SurgeRuleSet extends BaseWriteStrategy {
|
|||||||
|
|
||||||
readonly fileExtension = 'conf';
|
readonly fileExtension = 'conf';
|
||||||
|
|
||||||
protected result: string[] = ['DOMAIN,this_ruleset_is_made_by_sukkaw.ruleset.skk.moe'];
|
protected result: string[] = [`DOMAIN,${MARKER_DOMAIN}`];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
/** Surge RULE-SET can be both ip or non_ip, so this needs to be specified */
|
/** Surge RULE-SET can be both ip or non_ip, so this needs to be specified */
|
||||||
|
|||||||
@ -5,13 +5,14 @@ import { ICP_TLD } from './constants/domains';
|
|||||||
import tldts from 'tldts-experimental';
|
import tldts from 'tldts-experimental';
|
||||||
import { looseTldtsOpt } from './constants/loose-tldts-opt';
|
import { looseTldtsOpt } from './constants/loose-tldts-opt';
|
||||||
import runAgainstSourceFile from './lib/run-against-source-file';
|
import runAgainstSourceFile from './lib/run-against-source-file';
|
||||||
|
import { MARKER_DOMAIN } from './constants/description';
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
const trie = new HostnameSmolTrie();
|
const trie = new HostnameSmolTrie();
|
||||||
const extraWhiteTLDs = new Set<string>();
|
const extraWhiteTLDs = new Set<string>();
|
||||||
|
|
||||||
await runAgainstSourceFile(path.join(OUTPUT_SURGE_DIR, 'non_ip', 'domestic.conf'), (domain) => {
|
await runAgainstSourceFile(path.join(OUTPUT_SURGE_DIR, 'non_ip', 'domestic.conf'), (domain) => {
|
||||||
if (domain === 'this_ruleset_is_made_by_sukkaw.ruleset.skk.moe') {
|
if (domain === MARKER_DOMAIN) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const tld = tldts.getPublicSuffix(domain, looseTldtsOpt);
|
const tld = tldts.getPublicSuffix(domain, looseTldtsOpt);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user