mirror of
https://github.com/SukkaW/Surge.git
synced 2026-01-28 17:41:54 +08:00
Feat: legacy Clash Premium support
This commit is contained in:
@@ -95,7 +95,7 @@ export async function compareAndWriteFile(span: Span, linesA: string[], filePath
|
||||
return;
|
||||
}
|
||||
|
||||
return span.traceChildAsync(`writing ${filePath}`, async () => {
|
||||
return span.traceChildAsync<void>(`writing ${filePath}`, async () => {
|
||||
const linesALen = linesA.length;
|
||||
|
||||
// The default highwater mark is normally 16384,
|
||||
|
||||
@@ -29,7 +29,7 @@ interface Write {
|
||||
(
|
||||
destination: string,
|
||||
input: NodeJS.TypedArray | string,
|
||||
): Promise<unknown>
|
||||
): Promise<void>
|
||||
}
|
||||
|
||||
export function mkdirp(dir: string) {
|
||||
@@ -39,7 +39,7 @@ export function mkdirp(dir: string) {
|
||||
return fsp.mkdir(dir, { recursive: true });
|
||||
}
|
||||
|
||||
export const writeFile: Write = async (destination: string, input, dir = dirname(destination)) => {
|
||||
export const writeFile: Write = async (destination: string, input, dir = dirname(destination)): Promise<void> => {
|
||||
const p = mkdirp(dir);
|
||||
if (p) {
|
||||
await p;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { Span } from '../../trace';
|
||||
import { ClashClassicRuleSet } from '../writing-strategy/clash';
|
||||
import { LegacyClashPremiumRuleSet } from '../writing-strategy/legacy-clash-premium';
|
||||
import { SingboxSource } from '../writing-strategy/singbox';
|
||||
import { SurgeRuleSet } from '../writing-strategy/surge';
|
||||
import { FileOutput } from './base';
|
||||
@@ -11,6 +12,7 @@ export class RulesetOutput extends FileOutput {
|
||||
this.strategies = [
|
||||
new SurgeRuleSet(type),
|
||||
new ClashClassicRuleSet(type),
|
||||
new LegacyClashPremiumRuleSet(type),
|
||||
new SingboxSource(type)
|
||||
];
|
||||
}
|
||||
@@ -40,7 +42,8 @@ export class ClashOnlyRulesetOutput extends FileOutput {
|
||||
super(span, id);
|
||||
|
||||
this.strategies = [
|
||||
new ClashClassicRuleSet(type)
|
||||
new ClashClassicRuleSet(type),
|
||||
new LegacyClashPremiumRuleSet(type)
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ export class ClashIPSet extends BaseWriteStrategy {
|
||||
}
|
||||
|
||||
export class ClashClassicRuleSet extends BaseWriteStrategy {
|
||||
public readonly name = 'clash classic ruleset';
|
||||
public readonly name: string = 'clash classic ruleset';
|
||||
|
||||
readonly fileExtension = 'txt';
|
||||
|
||||
|
||||
18
Build/lib/writing-strategy/legacy-clash-premium.ts
Normal file
18
Build/lib/writing-strategy/legacy-clash-premium.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { noop } from 'foxts/noop';
|
||||
import { OUTPUT_LEAGCY_CLASH_PREMIUM } from '../../constants/dir';
|
||||
import { ClashClassicRuleSet } from './clash';
|
||||
|
||||
export class LegacyClashPremiumRuleSet extends ClashClassicRuleSet {
|
||||
public override readonly name = 'legacy clash premium ruleset';
|
||||
|
||||
readonly fileExtension = 'txt';
|
||||
|
||||
protected result: string[] = ['DOMAIN,this_ruleset_is_made_by_sukkaw.ruleset.skk.moe'];
|
||||
|
||||
constructor(public readonly type: 'ip' | 'non_ip' /* | (string & {}) */, public readonly outputDir = OUTPUT_LEAGCY_CLASH_PREMIUM) {
|
||||
super(type, outputDir);
|
||||
}
|
||||
|
||||
override writeDomainWildcards = noop;
|
||||
override writeIpAsns = noop;
|
||||
}
|
||||
Reference in New Issue
Block a user