masque.ts 1.1 KB

1234567891011121314151617181920212223242526
  1. import { z } from 'zod';
  2. // The path xray-core's MASQUE transport uses when none is set; the server matches
  3. // a request on it after expanding {target}/{ipproto} to "*".
  4. export const MASQUE_DEFAULT_PATH = '/.well-known/masque/ip/*/*/';
  5. // WARP over MASQUE: an enrolled ECDSA P-256 key (PEM or base64 DER), the endpoint's
  6. // public key, and the tunnel addresses Cloudflare assigned (one IPv4, one IPv6).
  7. export const MasqueWarpSchema = z.object({
  8. privateKey: z.string().default(''),
  9. publicKey: z.string().default(''),
  10. address: z.array(z.string()).default([]),
  11. });
  12. export type MasqueWarp = z.infer<typeof MasqueWarpSchema>;
  13. // A server reads only `path`; host, user/pass (Basic auth), headers and warp are the
  14. // client side. Every key is optional so a stored stream round-trips byte-stably.
  15. export const MasqueStreamSettingsSchema = z.object({
  16. host: z.string().optional(),
  17. path: z.string().optional(),
  18. user: z.string().optional(),
  19. pass: z.string().optional(),
  20. headers: z.record(z.string(), z.string()).optional(),
  21. warp: MasqueWarpSchema.optional(),
  22. });
  23. export type MasqueStreamSettings = z.infer<typeof MasqueStreamSettingsSchema>;