ruleset.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import type { Span } from '../../trace';
  2. import { ClashClassicRuleSet } from '../writing-strategy/clash';
  3. import { LegacyClashPremiumClassicRuleSet } from '../writing-strategy/legacy-clash-premium';
  4. import { SingboxSource } from '../writing-strategy/singbox';
  5. import { SurfboardRuleSet } from '../writing-strategy/surfboard';
  6. import { SurgeRuleSet } from '../writing-strategy/surge';
  7. import { FileOutput } from './base';
  8. export class RulesetOutput extends FileOutput {
  9. constructor(span: Span, id: string, type: 'non_ip' | 'ip') {
  10. super(span, id);
  11. this.strategies = [
  12. new SurgeRuleSet(type),
  13. new ClashClassicRuleSet(type),
  14. new LegacyClashPremiumClassicRuleSet(type),
  15. new SurfboardRuleSet(type),
  16. new SingboxSource(type)
  17. ];
  18. }
  19. }
  20. export class SurgeOnlyRulesetOutput extends FileOutput {
  21. constructor(
  22. span: Span,
  23. id: string,
  24. type: 'non_ip' | 'ip' | (string & {}),
  25. overrideOutputDir?: string
  26. ) {
  27. super(span, id);
  28. this.strategies = [
  29. new SurgeRuleSet(type, overrideOutputDir)
  30. ];
  31. }
  32. }
  33. export class ClashOnlyRulesetOutput extends FileOutput {
  34. constructor(
  35. span: Span,
  36. id: string,
  37. type: 'non_ip' | 'ip'
  38. ) {
  39. super(span, id);
  40. this.strategies = [
  41. new ClashClassicRuleSet(type),
  42. new LegacyClashPremiumClassicRuleSet(type)
  43. ];
  44. }
  45. }