external-proxy.ts 1.1 KB

12345678910111213141516171819202122232425262728
  1. import { z } from 'zod';
  2. import { PortSchema } from '@/schemas/primitives';
  3. import { AlpnSchema, UtlsFingerprintSchema } from '@/schemas/protocols/security/tls';
  4. export const ExternalProxyForceTlsSchema = z.enum(['same', 'tls', 'none']);
  5. export type ExternalProxyForceTls = z.infer<typeof ExternalProxyForceTlsSchema>;
  6. // An inbound can advertise external proxy fronts (CDN edges, mirror nodes)
  7. // that share its config but vary the dest+port+SNI for the share link. The
  8. // panel form ships rows of this shape; link generators iterate them when
  9. // stream.externalProxy is non-empty.
  10. export const ExternalProxyEntrySchema = z.object({
  11. forceTls: ExternalProxyForceTlsSchema.default('same'),
  12. dest: z.string().default(''),
  13. port: PortSchema.default(443),
  14. remark: z.string().default(''),
  15. sni: z.string().optional(),
  16. fingerprint: z.preprocess(
  17. (val) => (val === '' ? undefined : val),
  18. UtlsFingerprintSchema.optional(),
  19. ),
  20. alpn: z.array(AlpnSchema).optional(),
  21. pinnedPeerCertSha256: z.array(z.string()).optional(),
  22. echConfigList: z.string().optional(),
  23. });
  24. export type ExternalProxyEntry = z.infer<typeof ExternalProxyEntrySchema>;