mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-13 01:30:37 +08:00
Experimental Surfboard support
This commit is contained in:
parent
647ef48491
commit
c3e4a1a445
@ -13,6 +13,7 @@ export const OUTPUT_SURGE_DIR = path.join(PUBLIC_DIR, 'List');
|
||||
export const OUTPUT_CLASH_DIR = path.resolve(PUBLIC_DIR, 'Clash');
|
||||
export const OUTPUT_LEAGCY_CLASH_PREMIUM_DIR = path.resolve(PUBLIC_DIR, 'LegacyClashPremium');
|
||||
export const OUTPUT_SINGBOX_DIR = path.resolve(PUBLIC_DIR, 'sing-box');
|
||||
export const OUTPUT_SURFBOARD_DIR = path.resolve(PUBLIC_DIR, 'Surfboard');
|
||||
export const OUTPUT_MODULES_DIR = path.resolve(PUBLIC_DIR, 'Modules');
|
||||
export const OUTPUT_MODULES_RULES_DIR = path.resolve(OUTPUT_MODULES_DIR, 'Rules');
|
||||
export const OUTPUT_INTERNAL_DIR = path.resolve(PUBLIC_DIR, 'Internal');
|
||||
|
||||
@ -2,6 +2,7 @@ import type { Span } from '../../trace';
|
||||
import { ClashClassicRuleSet } from '../writing-strategy/clash';
|
||||
import { LegacyClashPremiumClassicRuleSet } from '../writing-strategy/legacy-clash-premium';
|
||||
import { SingboxSource } from '../writing-strategy/singbox';
|
||||
import { SurfboardRuleSet } from '../writing-strategy/surfboard';
|
||||
import { SurgeRuleSet } from '../writing-strategy/surge';
|
||||
import { FileOutput } from './base';
|
||||
|
||||
@ -13,6 +14,7 @@ export class RulesetOutput extends FileOutput {
|
||||
new SurgeRuleSet(type),
|
||||
new ClashClassicRuleSet(type),
|
||||
new LegacyClashPremiumClassicRuleSet(type),
|
||||
new SurfboardRuleSet(type),
|
||||
new SingboxSource(type)
|
||||
];
|
||||
}
|
||||
|
||||
25
Build/lib/writing-strategy/surfboard.ts
Normal file
25
Build/lib/writing-strategy/surfboard.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import { noop } from 'foxts/noop';
|
||||
import { SurgeRuleSet } from './surge';
|
||||
import { OUTPUT_SURFBOARD_DIR } from '../../constants/dir';
|
||||
import { appendSetElementsToArray } from 'foxts/append-set-elements-to-array';
|
||||
|
||||
export class SurfboardRuleSet extends SurgeRuleSet {
|
||||
public override readonly name: string = 'surfboard for android ruleset';
|
||||
|
||||
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_SURFBOARD_DIR) {
|
||||
super(type, outputDir);
|
||||
}
|
||||
|
||||
override writeDomainWildcards = noop;
|
||||
override writeUserAgents = noop;
|
||||
override writeUrlRegexes = noop;
|
||||
override writeIpAsns = noop;
|
||||
|
||||
override writeSourcePorts(port: Set<string>): void {
|
||||
// https://getsurfboard.com/docs/profile-format/rule/misc
|
||||
appendSetElementsToArray(this.result, port, i => `IN-PORT,${i}`);
|
||||
}
|
||||
|
||||
override writeOtherRules = noop;
|
||||
}
|
||||
@ -48,7 +48,7 @@ export class SurgeDomainSet extends BaseWriteStrategy {
|
||||
}
|
||||
|
||||
export class SurgeRuleSet extends BaseWriteStrategy {
|
||||
public readonly name = 'surge ruleset';
|
||||
public readonly name: string = 'surge ruleset';
|
||||
|
||||
readonly fileExtension = 'conf';
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user