ip.ts 760 B

123456789101112131415161718192021
  1. import type { Span } from '../../trace';
  2. import type { BaseWriteStrategy } from '../writing-strategy/base';
  3. import { ClashClassicRuleSet, ClashIPSet } from '../writing-strategy/clash';
  4. import { SingboxSource } from '../writing-strategy/singbox';
  5. import { SurgeRuleSet } from '../writing-strategy/surge';
  6. import { FileOutput } from './base';
  7. export class IPListOutput extends FileOutput {
  8. protected type = 'ip' as const;
  9. strategies: Array<false | BaseWriteStrategy>;
  10. constructor(span: Span, id: string, private readonly clashUseRule = true) {
  11. super(span, id);
  12. this.strategies = [
  13. new SurgeRuleSet(this.type),
  14. this.clashUseRule ? new ClashClassicRuleSet(this.type) : new ClashIPSet(),
  15. new SingboxSource(this.type)
  16. ];
  17. }
  18. }