outbound-protocol.ts 1015 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // xray-core lowercases a protocol id before it resolves the handler, so a
  2. // template pasted as "Freedom" still runs as the freedom outbound.
  3. export function isOutboundProtocol(
  4. outbound: { protocol?: unknown } | null | undefined,
  5. id: string,
  6. ): boolean {
  7. const protocol = outbound?.protocol;
  8. return typeof protocol === 'string' && protocol.toLowerCase() === id;
  9. }
  10. export const OutboundProtocols = Object.freeze({
  11. Freedom: 'freedom',
  12. Blackhole: 'blackhole',
  13. DNS: 'dns',
  14. VMess: 'vmess',
  15. VLESS: 'vless',
  16. Trojan: 'trojan',
  17. Shadowsocks: 'shadowsocks',
  18. Wireguard: 'wireguard',
  19. AmneziaWG: 'amneziawg',
  20. Hysteria: 'hysteria',
  21. Socks: 'socks',
  22. HTTP: 'http',
  23. Loopback: 'loopback',
  24. });
  25. export const OutboundDomainStrategies = Object.freeze([
  26. 'AsIs',
  27. 'UseIP',
  28. 'UseIPv4',
  29. 'UseIPv6',
  30. 'UseIPv6v4',
  31. 'UseIPv4v6',
  32. 'ForceIP',
  33. 'ForceIPv6v4',
  34. 'ForceIPv6',
  35. 'ForceIPv4v6',
  36. 'ForceIPv4',
  37. ] as const);
  38. export type OutboundDomainStrategy = (typeof OutboundDomainStrategies)[number];