From f79e486f9f959cc49d53cd14e2a400a64a046646 Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Tue, 26 May 2026 01:14:05 +0200 Subject: [PATCH] refactor(frontend): swap InboundFormModal option dicts to schemas/primitives Extends primitives/options.ts with the five inbound-only option dicts (TLS_VERSION_OPTION, TLS_CIPHER_OPTION, USAGE_OPTION, DOMAIN_STRATEGY_OPTION, TCP_CONGESTION_OPTION) and lifts InboundFormModal off @/models/inbound for 10 of its 12 imports. Only the Inbound class and SSMethods (inbound vs outbound versions diverge by 2 entries) still come from @/models/. Widens NODE_ELIGIBLE_PROTOCOLS Set element type to string since the new primitives const exposes a narrow literal union that `.has(arbitraryString)` would otherwise reject. --- .../src/pages/inbounds/InboundFormModal.tsx | 7 ++- frontend/src/schemas/primitives/options.ts | 49 +++++++++++++++++++ 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/frontend/src/pages/inbounds/InboundFormModal.tsx b/frontend/src/pages/inbounds/InboundFormModal.tsx index fb7d477b..c168bef7 100644 --- a/frontend/src/pages/inbounds/InboundFormModal.tsx +++ b/frontend/src/pages/inbounds/InboundFormModal.tsx @@ -41,10 +41,9 @@ import { } from '@/utils'; import InputAddon from '@/components/InputAddon'; import { getRandomRealityTarget } from '@/models/reality-targets'; +import { Inbound, SSMethods } from '@/models/inbound'; import { - Inbound, Protocols, - SSMethods, SNIFFING_OPTION, TLS_VERSION_OPTION, TLS_CIPHER_OPTION, @@ -54,7 +53,7 @@ import { DOMAIN_STRATEGY_OPTION, TCP_CONGESTION_OPTION, MODE_OPTION, -} from '@/models/inbound'; +} from '@/schemas/primitives'; import { DBInbound } from '@/models/dbinbound'; import FinalMaskForm from '@/components/FinalMaskForm'; import DateTimePicker from '@/components/DateTimePicker'; @@ -151,7 +150,7 @@ const DOMAIN_STRATEGIES = Object.values(DOMAIN_STRATEGY_OPTION) as string[]; const TCP_CONGESTIONS = Object.values(TCP_CONGESTION_OPTION) as string[]; const MODE_OPTIONS = Object.values(MODE_OPTION) as string[]; -const NODE_ELIGIBLE_PROTOCOLS = new Set([ +const NODE_ELIGIBLE_PROTOCOLS = new Set([ Protocols.VLESS, Protocols.VMESS, Protocols.TROJAN, diff --git a/frontend/src/schemas/primitives/options.ts b/frontend/src/schemas/primitives/options.ts index 40e853e8..daccc4c1 100644 --- a/frontend/src/schemas/primitives/options.ts +++ b/frontend/src/schemas/primitives/options.ts @@ -60,3 +60,52 @@ export const Address_Port_Strategy = Object.freeze({ }); export const DNSRuleActions = Object.freeze(['direct', 'drop', 'reject', 'hijack'] as const); + +export const TLS_VERSION_OPTION = Object.freeze({ + TLS10: '1.0', + TLS11: '1.1', + TLS12: '1.2', + TLS13: '1.3', +}); + +export const TLS_CIPHER_OPTION = Object.freeze({ + AES_128_GCM: 'TLS_AES_128_GCM_SHA256', + AES_256_GCM: 'TLS_AES_256_GCM_SHA384', + CHACHA20_POLY1305: 'TLS_CHACHA20_POLY1305_SHA256', + ECDHE_ECDSA_AES_128_CBC: 'TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA', + ECDHE_ECDSA_AES_256_CBC: 'TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA', + ECDHE_RSA_AES_128_CBC: 'TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA', + ECDHE_RSA_AES_256_CBC: 'TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA', + ECDHE_ECDSA_AES_128_GCM: 'TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256', + ECDHE_ECDSA_AES_256_GCM: 'TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384', + ECDHE_RSA_AES_128_GCM: 'TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256', + ECDHE_RSA_AES_256_GCM: 'TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384', + ECDHE_ECDSA_CHACHA20_POLY1305: 'TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256', + ECDHE_RSA_CHACHA20_POLY1305: 'TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256', +}); + +export const USAGE_OPTION = Object.freeze({ + ENCIPHERMENT: 'encipherment', + VERIFY: 'verify', + ISSUE: 'issue', +}); + +export const DOMAIN_STRATEGY_OPTION = Object.freeze({ + AS_IS: 'AsIs', + USE_IP: 'UseIP', + USE_IPV6V4: 'UseIPv6v4', + USE_IPV6: 'UseIPv6', + USE_IPV4V6: 'UseIPv4v6', + USE_IPV4: 'UseIPv4', + FORCE_IP: 'ForceIP', + FORCE_IPV6V4: 'ForceIPv6v4', + FORCE_IPV6: 'ForceIPv6', + FORCE_IPV4V6: 'ForceIPv4v6', + FORCE_IPV4: 'ForceIPv4', +}); + +export const TCP_CONGESTION_OPTION = Object.freeze({ + BBR: 'bbr', + CUBIC: 'cubic', + RENO: 'reno', +});