InboundFormModal.vue 78 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782
  1. <script setup>
  2. import { computed, ref, watch } from 'vue';
  3. import { useI18n } from 'vue-i18n';
  4. import dayjs from 'dayjs';
  5. import { message } from 'ant-design-vue';
  6. import { SyncOutlined, PlusOutlined, MinusOutlined, DeleteOutlined } from '@ant-design/icons-vue';
  7. import {
  8. HttpUtil,
  9. RandomUtil,
  10. NumberFormatter,
  11. SizeFormatter,
  12. Wireguard,
  13. } from '@/utils';
  14. import {
  15. Inbound,
  16. Protocols,
  17. SSMethods,
  18. USERS_SECURITY,
  19. TLS_FLOW_CONTROL,
  20. SNIFFING_OPTION,
  21. TLS_VERSION_OPTION,
  22. TLS_CIPHER_OPTION,
  23. UTLS_FINGERPRINT,
  24. ALPN_OPTION,
  25. USAGE_OPTION,
  26. DOMAIN_STRATEGY_OPTION,
  27. TCP_CONGESTION_OPTION,
  28. MODE_OPTION,
  29. } from '@/models/inbound.js';
  30. import { DBInbound } from '@/models/dbinbound.js';
  31. import FinalMaskForm from '@/components/FinalMaskForm.vue';
  32. import DateTimePicker from '@/components/DateTimePicker.vue';
  33. import { useNodeList } from '@/composables/useNodeList.js';
  34. const { t } = useI18n();
  35. // Node selector — Phase 1 multi-node deployment. Shows all enabled
  36. // nodes regardless of online state so the form is usable while a node
  37. // is briefly offline; the backend's fail-fast path will surface the
  38. // real error when the user submits.
  39. const { nodes: availableNodes } = useNodeList();
  40. const selectableNodes = computed(() => (availableNodes.value || []).filter((n) => n.enable));
  41. // Phase 5f-iii-b: structured per-protocol/per-transport forms instead
  42. // of raw JSON textareas. Edits a deeply-reactive Inbound + DBInbound
  43. // pair so the existing model helpers (.toString(), .canEnableTls(),
  44. // genAllLinks(), addPeer(), etc.) keep working unchanged. The
  45. // "Advanced" tab still exposes the full streamSettings JSON for
  46. // transport variants (KCP/XHTTP/sockopt/finalmask) we don't yet have
  47. // dedicated UI for.
  48. const props = defineProps({
  49. open: { type: Boolean, default: false },
  50. mode: { type: String, default: 'add', validator: (v) => ['add', 'edit'].includes(v) },
  51. dbInbound: { type: Object, default: null },
  52. });
  53. const emit = defineEmits(['update:open', 'saved']);
  54. const TRAFFIC_RESETS = ['never', 'hourly', 'daily', 'weekly', 'monthly'];
  55. const PROTOCOLS = Object.values(Protocols);
  56. const SECURITY_OPTIONS = Object.values(USERS_SECURITY);
  57. const FLOW_OPTIONS = Object.values(TLS_FLOW_CONTROL);
  58. // === Reactive state ================================================
  59. // Cloned on every open so cancelling the modal doesn't mutate the row.
  60. const inbound = ref(null);
  61. const dbForm = ref(null);
  62. const saving = ref(false);
  63. const advancedJson = ref({ stream: '', sniffing: '', settings: '' });
  64. // Cached default cert/key paths from /panel/setting/defaultSettings —
  65. // powers the "Set default cert" button on the TLS form.
  66. const defaultCert = ref('');
  67. const defaultKey = ref('');
  68. // Lookup tables for the option dropdowns.
  69. const TLS_VERSIONS = Object.values(TLS_VERSION_OPTION);
  70. const CIPHER_SUITES = Object.entries(TLS_CIPHER_OPTION); // [label, value]
  71. const FINGERPRINTS = Object.values(UTLS_FINGERPRINT);
  72. const ALPNS = Object.values(ALPN_OPTION);
  73. const USAGES = Object.values(USAGE_OPTION);
  74. const DOMAIN_STRATEGIES = Object.values(DOMAIN_STRATEGY_OPTION);
  75. const TCP_CONGESTIONS = Object.values(TCP_CONGESTION_OPTION);
  76. const MODE_OPTIONS = Object.values(MODE_OPTION);
  77. // External proxy is a single switch in the UI but a list in the model:
  78. // flipping it on seeds one row pre-filled with the current host:port.
  79. const externalProxy = computed({
  80. get: () => Array.isArray(inbound.value?.stream?.externalProxy)
  81. && inbound.value.stream.externalProxy.length > 0,
  82. set: (v) => {
  83. if (!inbound.value?.stream) return;
  84. if (v) {
  85. inbound.value.stream.externalProxy = [{
  86. forceTls: 'same',
  87. dest: window.location.hostname,
  88. port: inbound.value.port,
  89. remark: '',
  90. }];
  91. } else {
  92. inbound.value.stream.externalProxy = [];
  93. }
  94. },
  95. });
  96. // Derived helpers — each is a computed off `inbound` so flips of
  97. // protocol / network / security re-render the right blocks.
  98. const protocol = computed(() => inbound.value?.protocol);
  99. const network = computed({
  100. get: () => inbound.value?.stream?.network,
  101. set: (v) => onNetworkChange(v),
  102. });
  103. const security = computed({
  104. get: () => inbound.value?.stream?.security,
  105. set: (v) => { if (inbound.value?.stream) inbound.value.stream.security = v; },
  106. });
  107. const isMultiUser = computed(() => {
  108. if (!inbound.value) return false;
  109. switch (inbound.value.protocol) {
  110. case Protocols.VMESS:
  111. case Protocols.VLESS:
  112. case Protocols.TROJAN:
  113. case Protocols.HYSTERIA:
  114. return true;
  115. case Protocols.SHADOWSOCKS:
  116. return !!inbound.value.isSSMultiUser;
  117. default:
  118. return false;
  119. }
  120. });
  121. const clientsArray = computed(() => {
  122. if (!inbound.value) return [];
  123. switch (inbound.value.protocol) {
  124. case Protocols.VMESS: return inbound.value.settings.vmesses || [];
  125. case Protocols.VLESS: return inbound.value.settings.vlesses || [];
  126. case Protocols.TROJAN: return inbound.value.settings.trojans || [];
  127. case Protocols.SHADOWSOCKS: return inbound.value.settings.shadowsockses || [];
  128. case Protocols.HYSTERIA: return inbound.value.settings.hysterias || [];
  129. default: return [];
  130. }
  131. });
  132. const firstClient = computed(() => clientsArray.value[0] || null);
  133. const canEnableStream = computed(() => inbound.value?.canEnableStream?.() === true);
  134. const canEnableTls = computed(() => inbound.value?.canEnableTls?.() === true);
  135. const canEnableReality = computed(() => inbound.value?.canEnableReality?.() === true);
  136. const canEnableTlsFlow = computed(() => inbound.value?.canEnableTlsFlow?.() === true);
  137. // VLESS/Trojan TLS fallbacks — surfaced in the protocol tab when the
  138. // inbound is on TCP and (for VLESS) using no Xray-side encryption.
  139. const showFallbacks = computed(() => {
  140. if (!inbound.value) return false;
  141. if (inbound.value.stream?.network !== 'tcp') return false;
  142. if (inbound.value.protocol === Protocols.VLESS) {
  143. const enc = inbound.value.settings?.encryption;
  144. return !enc || enc === 'none';
  145. }
  146. return inbound.value.protocol === Protocols.TROJAN;
  147. });
  148. function addFallback() {
  149. inbound.value?.settings?.addFallback?.();
  150. }
  151. function delFallback(idx) {
  152. inbound.value?.settings?.delFallback?.(idx);
  153. }
  154. // Date / GB bridges (legacy used moment via _expiryTime; we go direct).
  155. const expiryDate = computed({
  156. get: () => (dbForm.value?.expiryTime > 0 ? dayjs(dbForm.value.expiryTime) : null),
  157. set: (next) => { if (dbForm.value) dbForm.value.expiryTime = next ? next.valueOf() : 0; },
  158. });
  159. const totalGB = computed({
  160. get: () => (dbForm.value?.total ? Math.round((dbForm.value.total / SizeFormatter.ONE_GB) * 100) / 100 : 0),
  161. set: (gb) => { if (dbForm.value) dbForm.value.total = NumberFormatter.toFixed((gb || 0) * SizeFormatter.ONE_GB, 0); },
  162. });
  163. // Client total/expiry bridges (only relevant in add mode for new clients)
  164. const clientExpiryDate = computed({
  165. get: () => (firstClient.value?.expiryTime > 0 ? dayjs(firstClient.value.expiryTime) : null),
  166. set: (next) => { if (firstClient.value) firstClient.value.expiryTime = next ? next.valueOf() : 0; },
  167. });
  168. const clientTotalGB = computed({
  169. get: () => firstClient.value?._totalGB ?? 0,
  170. set: (gb) => { if (firstClient.value) firstClient.value._totalGB = gb || 0; },
  171. });
  172. // === Open / state management =======================================
  173. function loadFromDbInbound(dbIn) {
  174. // Round-trip through Inbound.fromJson so subsequent edits get the
  175. // structured class hierarchy (StreamSettings, TLS, Reality, etc.).
  176. const parsed = Inbound.fromJson(dbIn.toInbound().toJson());
  177. inbound.value = parsed;
  178. // DBForm carries the persisted-fields the parsed Inbound doesn't:
  179. // remark, enable, total, expiryTime, trafficReset, etc.
  180. dbForm.value = new DBInbound(dbIn);
  181. primeAdvancedJson();
  182. }
  183. function makeFreshInbound(proto) {
  184. const ib = new Inbound();
  185. ib.protocol = proto;
  186. ib.settings = Inbound.Settings.getSettings(proto);
  187. ib.port = RandomUtil.randomInteger(10000, 60000);
  188. return ib;
  189. }
  190. function freshDbForm() {
  191. const next = new DBInbound();
  192. next.enable = true;
  193. next.remark = '';
  194. next.total = 0;
  195. next.expiryTime = 0;
  196. next.trafficReset = 'never';
  197. return next;
  198. }
  199. function primeAdvancedJson() {
  200. if (!inbound.value) return;
  201. try {
  202. advancedJson.value.stream = JSON.stringify(JSON.parse(inbound.value.stream.toString()), null, 2);
  203. } catch (_e) { /* keep prior text */ }
  204. try {
  205. advancedJson.value.sniffing = JSON.stringify(JSON.parse(inbound.value.sniffing.toString()), null, 2);
  206. } catch (_e) { /* keep prior text */ }
  207. try {
  208. advancedJson.value.settings = JSON.stringify(JSON.parse(inbound.value.settings.toString()), null, 2);
  209. } catch (_e) { /* keep prior text */ }
  210. }
  211. watch(() => props.open, (next) => {
  212. if (!next) return;
  213. if (props.mode === 'edit' && props.dbInbound) {
  214. loadFromDbInbound(props.dbInbound);
  215. } else {
  216. inbound.value = makeFreshInbound(Protocols.VLESS);
  217. dbForm.value = freshDbForm();
  218. primeAdvancedJson();
  219. }
  220. fetchDefaultCertSettings();
  221. });
  222. // In add mode, switching protocol restamps settings + re-syncs port.
  223. function onProtocolChange(next) {
  224. if (props.mode === 'edit' || !inbound.value) return;
  225. inbound.value.protocol = next;
  226. inbound.value.settings = Inbound.Settings.getSettings(next);
  227. primeAdvancedJson();
  228. }
  229. function onNetworkChange(next) {
  230. if (!inbound.value?.stream) return;
  231. inbound.value.stream.network = next;
  232. // Mirror legacy streamNetworkChange: clear flow when TLS/Reality
  233. // become unavailable; reset finalmask.udp when not KCP.
  234. if (!inbound.value.canEnableTls()) inbound.value.stream.security = 'none';
  235. if (!inbound.value.canEnableReality()) inbound.value.reality = false;
  236. if (
  237. inbound.value.protocol === Protocols.VLESS
  238. && !inbound.value.canEnableTlsFlow()
  239. && Array.isArray(inbound.value.settings.vlesses)
  240. ) {
  241. inbound.value.settings.vlesses.forEach((c) => { c.flow = ''; });
  242. }
  243. if (next !== 'kcp' && inbound.value.stream.finalmask) {
  244. inbound.value.stream.finalmask.udp = [];
  245. }
  246. }
  247. // === Random helpers wired to the form's sync icons ==================
  248. function randomEmail(target) {
  249. if (target) target.email = RandomUtil.randomLowerAndNum(9);
  250. }
  251. function randomUuid(target) {
  252. if (target) target.id = RandomUtil.randomUUID();
  253. }
  254. function randomPasswordSeq(target, len = 10) {
  255. if (target) target.password = RandomUtil.randomSeq(len);
  256. }
  257. function randomSSPassword(target) {
  258. if (target) target.password = RandomUtil.randomShadowsocksPassword(inbound.value.settings.method);
  259. }
  260. function randomAuth(target) {
  261. if (target) target.auth = RandomUtil.randomSeq(10);
  262. }
  263. function randomSubId(target) {
  264. if (target) target.subId = RandomUtil.randomLowerAndNum(16);
  265. }
  266. function regenWgKeypair(target) {
  267. const kp = Wireguard.generateKeypair();
  268. target.publicKey = kp.publicKey;
  269. target.privateKey = kp.privateKey;
  270. }
  271. function regenInboundWg() {
  272. const kp = Wireguard.generateKeypair();
  273. inbound.value.settings.pubKey = kp.publicKey;
  274. inbound.value.settings.secretKey = kp.privateKey;
  275. }
  276. // === Reality keygen via existing API =================================
  277. async function genRealityKeypair() {
  278. saving.value = true;
  279. try {
  280. const msg = await HttpUtil.get('/panel/api/server/getNewX25519Cert');
  281. if (msg?.success) {
  282. inbound.value.stream.reality.privateKey = msg.obj.privateKey;
  283. inbound.value.stream.reality.settings.publicKey = msg.obj.publicKey;
  284. }
  285. } finally {
  286. saving.value = false;
  287. }
  288. }
  289. function clearRealityKeypair() {
  290. if (!inbound.value?.stream?.reality) return;
  291. inbound.value.stream.reality.privateKey = '';
  292. inbound.value.stream.reality.settings.publicKey = '';
  293. }
  294. async function genMldsa65() {
  295. saving.value = true;
  296. try {
  297. const msg = await HttpUtil.get('/panel/api/server/getNewmldsa65');
  298. if (msg?.success) {
  299. inbound.value.stream.reality.mldsa65Seed = msg.obj.seed;
  300. inbound.value.stream.reality.settings.mldsa65Verify = msg.obj.verify;
  301. }
  302. } finally {
  303. saving.value = false;
  304. }
  305. }
  306. function clearMldsa65() {
  307. if (!inbound.value?.stream?.reality) return;
  308. inbound.value.stream.reality.mldsa65Seed = '';
  309. inbound.value.stream.reality.settings.mldsa65Verify = '';
  310. }
  311. // Reality target/SNI randomizer — only available if the helper is loaded
  312. function randomizeRealityTarget() {
  313. if (!inbound.value?.stream?.reality) return;
  314. if (typeof window.getRandomRealityTarget !== 'function') return;
  315. const t = window.getRandomRealityTarget();
  316. inbound.value.stream.reality.target = t.target;
  317. inbound.value.stream.reality.serverNames = t.sni;
  318. }
  319. function randomizeShortIds() {
  320. if (!inbound.value?.stream?.reality) return;
  321. inbound.value.stream.reality.shortIds = RandomUtil.randomShortIds();
  322. }
  323. // === ECH cert helpers ================================================
  324. async function getNewEchCert() {
  325. if (!inbound.value?.stream?.tls) return;
  326. saving.value = true;
  327. try {
  328. const msg = await HttpUtil.post('/panel/api/server/getNewEchCert', {
  329. sni: inbound.value.stream.tls.sni,
  330. });
  331. if (msg?.success) {
  332. inbound.value.stream.tls.echServerKeys = msg.obj.echServerKeys;
  333. inbound.value.stream.tls.settings.echConfigList = msg.obj.echConfigList;
  334. }
  335. } finally {
  336. saving.value = false;
  337. }
  338. }
  339. function clearEchCert() {
  340. if (!inbound.value?.stream?.tls) return;
  341. inbound.value.stream.tls.echServerKeys = '';
  342. inbound.value.stream.tls.settings.echConfigList = '';
  343. }
  344. function setDefaultCertData(idx) {
  345. if (!inbound.value?.stream?.tls?.certs?.[idx]) return;
  346. inbound.value.stream.tls.certs[idx].certFile = defaultCert.value;
  347. inbound.value.stream.tls.certs[idx].keyFile = defaultKey.value;
  348. }
  349. async function fetchDefaultCertSettings() {
  350. try {
  351. const msg = await HttpUtil.post('/panel/setting/defaultSettings');
  352. if (msg?.success && msg.obj) {
  353. defaultCert.value = msg.obj.defaultCert || '';
  354. defaultKey.value = msg.obj.defaultKey || '';
  355. }
  356. } catch (_e) { /* non-fatal — leave Set Default disabled */ }
  357. }
  358. // === VLESS encryption helpers =======================================
  359. // `xray vlessenc` returns both X25519 and ML-KEM-768 variants every
  360. // call; the user clicks one of two buttons to pick which block goes
  361. // into decryption/encryption.
  362. async function getNewVlessEnc(authLabel) {
  363. if (!authLabel || !inbound.value?.settings) return;
  364. saving.value = true;
  365. try {
  366. const msg = await HttpUtil.get('/panel/api/server/getNewVlessEnc');
  367. if (!msg?.success) return;
  368. const block = (msg.obj?.auths || []).find((a) => a.label === authLabel);
  369. if (!block) return;
  370. inbound.value.settings.decryption = block.decryption;
  371. inbound.value.settings.encryption = block.encryption;
  372. } finally {
  373. saving.value = false;
  374. }
  375. }
  376. function clearVlessEnc() {
  377. if (!inbound.value?.settings) return;
  378. inbound.value.settings.decryption = 'none';
  379. inbound.value.settings.encryption = 'none';
  380. }
  381. // === SS method change tracks legacy semantics =========================
  382. function onSSMethodChange() {
  383. inbound.value.settings.password = RandomUtil.randomShadowsocksPassword(inbound.value.settings.method);
  384. if (inbound.value.isSSMultiUser) {
  385. if (inbound.value.settings.shadowsockses.length === 0) {
  386. inbound.value.settings.shadowsockses = [new Inbound.ShadowsocksSettings.Shadowsocks()];
  387. }
  388. inbound.value.settings.shadowsockses.forEach((c) => {
  389. c.method = inbound.value.isSS2022 ? '' : inbound.value.settings.method;
  390. c.password = RandomUtil.randomShadowsocksPassword(inbound.value.settings.method);
  391. });
  392. } else {
  393. inbound.value.settings.shadowsockses = [];
  394. }
  395. }
  396. // === Submit ==========================================================
  397. function close() {
  398. emit('update:open', false);
  399. }
  400. async function submit() {
  401. if (!inbound.value || !dbForm.value) return;
  402. saving.value = true;
  403. try {
  404. // Sniffing tab is structured; stream stays JSON for unsupported
  405. // transports — both go to wire as serialized JSON.
  406. let streamSettings;
  407. let sniffing;
  408. let settings;
  409. try {
  410. streamSettings = canEnableStream.value
  411. ? JSON.stringify(JSON.parse(advancedJson.value.stream))
  412. : (inbound.value.stream?.sockopt
  413. ? JSON.stringify({ sockopt: inbound.value.stream.sockopt.toJson() })
  414. : '');
  415. } catch (e) { message.error(`Stream JSON invalid: ${e.message}`); return; }
  416. try {
  417. sniffing = JSON.stringify(JSON.parse(advancedJson.value.sniffing || inbound.value.sniffing.toString()));
  418. } catch (e) { message.error(`Sniffing JSON invalid: ${e.message}`); return; }
  419. try {
  420. settings = JSON.stringify(JSON.parse(advancedJson.value.settings || inbound.value.settings.toString()));
  421. } catch (e) { message.error(`Settings JSON invalid: ${e.message}`); return; }
  422. // The structured form mutates `inbound.stream` directly when the
  423. // user edits TCP/WS/gRPC/HTTPUpgrade fields, but if they touched
  424. // the Advanced JSON tab their edits live there. Keep the JSON tab
  425. // authoritative — it was populated from the live model on open
  426. // and watch handlers below sync in either direction.
  427. const payload = {
  428. up: dbForm.value.up || 0,
  429. down: dbForm.value.down || 0,
  430. total: dbForm.value.total,
  431. remark: dbForm.value.remark,
  432. enable: dbForm.value.enable,
  433. expiryTime: dbForm.value.expiryTime,
  434. trafficReset: dbForm.value.trafficReset,
  435. lastTrafficResetTime: dbForm.value.lastTrafficResetTime || 0,
  436. listen: inbound.value.listen,
  437. port: inbound.value.port,
  438. protocol: inbound.value.protocol,
  439. settings: settings,
  440. streamSettings: streamSettings,
  441. sniffing: sniffing,
  442. };
  443. // Multi-node deployment: only include nodeId when the user picked a
  444. // remote node. Sending nodeId=null over qs.stringify becomes an
  445. // empty form value, which Go's form binding for *int parses as 0
  446. // — not nil — and we'd then try to look up node id 0 and fail with
  447. // "record not found". Omitting the key entirely keeps NodeID nil.
  448. if (dbForm.value.nodeId != null) {
  449. payload.nodeId = dbForm.value.nodeId;
  450. }
  451. const url = props.mode === 'edit'
  452. ? `/panel/api/inbounds/update/${props.dbInbound.id}`
  453. : '/panel/api/inbounds/add';
  454. const msg = await HttpUtil.post(url, payload);
  455. if (msg?.success) {
  456. emit('saved');
  457. close();
  458. }
  459. } finally {
  460. saving.value = false;
  461. }
  462. }
  463. const title = computed(() =>
  464. props.mode === 'edit'
  465. ? t('pages.inbounds.modifyInbound')
  466. : t('pages.inbounds.addInbound'),
  467. );
  468. const okText = computed(() =>
  469. props.mode === 'edit' ? t('pages.client.submitEdit') : t('create'),
  470. );
  471. // Whenever the structured form mutates stream / sniffing / settings,
  472. // refresh the matching slice of the Advanced JSON tab so the user
  473. // always sees the live state — flipping a switch in Sniffing or
  474. // editing encryption in Protocol now reflects in Advanced.
  475. watch(
  476. () => inbound.value && JSON.stringify(inbound.value.stream?.toJson?.() || {}),
  477. () => {
  478. if (!inbound.value?.stream) return;
  479. try {
  480. advancedJson.value.stream = JSON.stringify(JSON.parse(inbound.value.stream.toString()), null, 2);
  481. } catch (_e) { /* leave as is */ }
  482. },
  483. );
  484. watch(
  485. () => inbound.value && JSON.stringify(inbound.value.sniffing?.toJson?.() || {}),
  486. () => {
  487. if (!inbound.value?.sniffing) return;
  488. try {
  489. advancedJson.value.sniffing = JSON.stringify(JSON.parse(inbound.value.sniffing.toString()), null, 2);
  490. } catch (_e) { /* leave as is */ }
  491. },
  492. );
  493. watch(
  494. () => inbound.value && JSON.stringify(inbound.value.settings?.toJson?.() || {}),
  495. () => {
  496. if (!inbound.value?.settings) return;
  497. try {
  498. advancedJson.value.settings = JSON.stringify(JSON.parse(inbound.value.settings.toString()), null, 2);
  499. } catch (_e) { /* leave as is */ }
  500. },
  501. );
  502. </script>
  503. <template>
  504. <a-modal :open="open" :title="title" :ok-text="okText" :cancel-text="t('close')" :confirm-loading="saving"
  505. :mask-closable="false" width="780px" @ok="submit" @cancel="close">
  506. <a-tabs v-if="inbound && dbForm" default-active-key="basic">
  507. <!-- ============================== BASICS ============================== -->
  508. <a-tab-pane key="basic" :tab="t('pages.xray.basicTemplate')">
  509. <a-form :colon="false" :label-col="{ sm: { span: 8 } }" :wrapper-col="{ sm: { span: 14 } }">
  510. <a-form-item :label="t('enable')">
  511. <a-switch v-model:checked="dbForm.enable" />
  512. </a-form-item>
  513. <a-form-item :label="t('pages.inbounds.remark')">
  514. <a-input v-model:value="dbForm.remark" />
  515. </a-form-item>
  516. <a-form-item :label="t('pages.inbounds.deployTo')">
  517. <a-select v-model:value="dbForm.nodeId" :disabled="mode === 'edit'"
  518. :placeholder="t('pages.inbounds.localPanel')" allow-clear>
  519. <a-select-option :value="null">{{ t('pages.inbounds.localPanel') }}</a-select-option>
  520. <a-select-option v-for="n in selectableNodes" :key="n.id" :value="n.id"
  521. :disabled="n.status === 'offline'">
  522. {{ n.name }}{{ n.status === 'offline' ? ' (offline)' : '' }}
  523. </a-select-option>
  524. </a-select>
  525. </a-form-item>
  526. <a-form-item :label="t('pages.inbounds.protocol')">
  527. <a-select :value="protocol" :disabled="mode === 'edit'" @change="onProtocolChange">
  528. <a-select-option v-for="p in PROTOCOLS" :key="p" :value="p">{{ p }}</a-select-option>
  529. </a-select>
  530. </a-form-item>
  531. <a-form-item :label="t('pages.inbounds.address')">
  532. <a-input v-model:value="inbound.listen" :placeholder="t('pages.inbounds.monitorDesc')" />
  533. </a-form-item>
  534. <a-form-item :label="t('pages.inbounds.port')">
  535. <a-input-number v-model:value="inbound.port" :min="1" :max="65535" />
  536. </a-form-item>
  537. <a-form-item>
  538. <template #label>
  539. <a-tooltip :title="t('pages.inbounds.meansNoLimit')">{{ t('pages.inbounds.totalFlow') }}</a-tooltip>
  540. </template>
  541. <a-input-number v-model:value="totalGB" :min="0" :step="0.1" />
  542. </a-form-item>
  543. <a-form-item :label="t('pages.inbounds.periodicTrafficResetTitle')">
  544. <a-select v-model:value="dbForm.trafficReset">
  545. <a-select-option v-for="r in TRAFFIC_RESETS" :key="r" :value="r">
  546. {{ t(`pages.inbounds.periodicTrafficReset.${r}`) }}
  547. </a-select-option>
  548. </a-select>
  549. </a-form-item>
  550. <a-form-item>
  551. <template #label>
  552. <a-tooltip :title="t('pages.inbounds.leaveBlankToNeverExpire')">{{ t('pages.inbounds.expireDate')
  553. }}</a-tooltip>
  554. </template>
  555. <DateTimePicker v-model:value="expiryDate" />
  556. </a-form-item>
  557. </a-form>
  558. </a-tab-pane>
  559. <!-- ============================== PROTOCOL ============================== -->
  560. <!-- TUN has no per-protocol form yet (interface/mtu/gateway live in
  561. settings JSON), so the tab would render empty — hide it until
  562. a TUN form is added. -->
  563. <a-tab-pane v-if="protocol !== Protocols.TUN" key="protocol" :tab="t('pages.inbounds.protocol')">
  564. <!-- Multi-user inbounds: in add mode embed the first client form,
  565. in edit mode show a count summary. -->
  566. <template v-if="isMultiUser">
  567. <a-collapse v-if="mode === 'add' && firstClient" default-active-key="0">
  568. <a-collapse-panel key="0" header="Client">
  569. <a-form :colon="false" :label-col="{ sm: { span: 8 } }" :wrapper-col="{ sm: { span: 14 } }">
  570. <a-form-item label="Enable">
  571. <a-switch v-model:checked="firstClient.enable" />
  572. </a-form-item>
  573. <a-form-item>
  574. <template #label>
  575. <a-tooltip title="Friendly identifier">
  576. Email
  577. <SyncOutlined class="random-icon" @click="randomEmail(firstClient)" />
  578. </a-tooltip>
  579. </template>
  580. <a-input v-model:value="firstClient.email" />
  581. </a-form-item>
  582. <a-form-item v-if="protocol === Protocols.VMESS || protocol === Protocols.VLESS">
  583. <template #label>
  584. <a-tooltip title="Reset to a fresh UUID">
  585. ID
  586. <SyncOutlined class="random-icon" @click="randomUuid(firstClient)" />
  587. </a-tooltip>
  588. </template>
  589. <a-input v-model:value="firstClient.id" />
  590. </a-form-item>
  591. <a-form-item v-if="protocol === Protocols.VMESS" label="Security">
  592. <a-select v-model:value="firstClient.security">
  593. <a-select-option v-for="k in SECURITY_OPTIONS" :key="k" :value="k">{{ k }}</a-select-option>
  594. </a-select>
  595. </a-form-item>
  596. <a-form-item v-if="protocol === Protocols.TROJAN || protocol === Protocols.SHADOWSOCKS">
  597. <template #label>
  598. <a-tooltip title="Reset to a fresh random value">
  599. Password
  600. <SyncOutlined v-if="protocol === Protocols.SHADOWSOCKS" class="random-icon"
  601. @click="randomSSPassword(firstClient)" />
  602. <SyncOutlined v-else class="random-icon" @click="randomPasswordSeq(firstClient)" />
  603. </a-tooltip>
  604. </template>
  605. <a-input v-model:value="firstClient.password" />
  606. </a-form-item>
  607. <a-form-item v-if="protocol === Protocols.HYSTERIA">
  608. <template #label>
  609. <a-tooltip title="Reset"><span>Auth password</span>
  610. <SyncOutlined class="random-icon" @click="randomAuth(firstClient)" />
  611. </a-tooltip>
  612. </template>
  613. <a-input v-model:value="firstClient.auth" />
  614. </a-form-item>
  615. <a-form-item v-if="canEnableTlsFlow" label="Flow">
  616. <a-select v-model:value="firstClient.flow">
  617. <a-select-option value="">none</a-select-option>
  618. <a-select-option v-for="k in FLOW_OPTIONS" :key="k" :value="k">{{ k }}</a-select-option>
  619. </a-select>
  620. </a-form-item>
  621. <a-form-item v-if="protocol === Protocols.VLESS" label="Reverse tag">
  622. <a-input v-model:value="firstClient.reverseTag" placeholder="Optional reverse tag" />
  623. </a-form-item>
  624. <a-form-item label="Subscription">
  625. <a-input v-model:value="firstClient.subId">
  626. <template #addonAfter>
  627. <SyncOutlined class="random-icon" @click="randomSubId(firstClient)" />
  628. </template>
  629. </a-input>
  630. </a-form-item>
  631. <a-form-item label="Comment">
  632. <a-input v-model:value="firstClient.comment" />
  633. </a-form-item>
  634. <a-form-item label="Total traffic (GB)">
  635. <a-input-number v-model:value="clientTotalGB" :min="0" :step="0.1" />
  636. </a-form-item>
  637. <a-form-item label="Expiry">
  638. <DateTimePicker v-model:value="clientExpiryDate" />
  639. </a-form-item>
  640. </a-form>
  641. </a-collapse-panel>
  642. </a-collapse>
  643. <a-collapse v-else>
  644. <a-collapse-panel key="summary" :header="`Clients: ${clientsArray.length}`">
  645. <table class="client-summary">
  646. <thead>
  647. <tr>
  648. <th>Email</th>
  649. <th>{{ protocol === Protocols.TROJAN || protocol === Protocols.SHADOWSOCKS ? 'Password' : (protocol
  650. ===
  651. Protocols.HYSTERIA ? 'Auth' : 'ID') }}</th>
  652. </tr>
  653. </thead>
  654. <tbody>
  655. <tr v-for="(c, idx) in clientsArray" :key="idx">
  656. <td>{{ c.email }}</td>
  657. <td>{{ c.id || c.password || c.auth }}</td>
  658. </tr>
  659. </tbody>
  660. </table>
  661. </a-collapse-panel>
  662. </a-collapse>
  663. </template>
  664. <!-- VLess decryption / encryption -->
  665. <a-form v-if="protocol === Protocols.VLESS" :colon="false" :label-col="{ sm: { span: 8 } }"
  666. :wrapper-col="{ sm: { span: 14 } }" class="mt-12">
  667. <a-form-item label="Decryption">
  668. <a-input v-model:value="inbound.settings.decryption" />
  669. </a-form-item>
  670. <a-form-item label="Encryption">
  671. <a-input v-model:value="inbound.settings.encryption" />
  672. </a-form-item>
  673. <a-form-item label=" ">
  674. <a-space :size="8" wrap>
  675. <a-button type="primary" :loading="saving" @click="getNewVlessEnc('X25519, not Post-Quantum')">
  676. X25519
  677. </a-button>
  678. <a-button type="primary" :loading="saving" @click="getNewVlessEnc('ML-KEM-768, Post-Quantum')">
  679. ML-KEM-768
  680. </a-button>
  681. <a-button danger @click="clearVlessEnc">Clear</a-button>
  682. </a-space>
  683. </a-form-item>
  684. </a-form>
  685. <!-- Shadowsocks shared fields (method/network/ivCheck) -->
  686. <a-form v-if="protocol === Protocols.SHADOWSOCKS" :colon="false" :label-col="{ sm: { span: 8 } }"
  687. :wrapper-col="{ sm: { span: 14 } }" class="mt-12">
  688. <a-form-item label="Encryption method">
  689. <a-select v-model:value="inbound.settings.method" @change="onSSMethodChange">
  690. <a-select-option v-for="(m, k) in SSMethods" :key="k" :value="m">{{ k }}</a-select-option>
  691. </a-select>
  692. </a-form-item>
  693. <a-form-item v-if="inbound.isSS2022">
  694. <template #label>
  695. Password
  696. <SyncOutlined class="random-icon" @click="randomSSPassword(inbound.settings)" />
  697. </template>
  698. <a-input v-model:value="inbound.settings.password" />
  699. </a-form-item>
  700. <a-form-item label="Network">
  701. <a-select v-model:value="inbound.settings.network" :style="{ width: '120px' }">
  702. <a-select-option value="tcp,udp">TCP, UDP</a-select-option>
  703. <a-select-option value="tcp">TCP</a-select-option>
  704. <a-select-option value="udp">UDP</a-select-option>
  705. </a-select>
  706. </a-form-item>
  707. <a-form-item label="ivCheck">
  708. <a-switch v-model:checked="inbound.settings.ivCheck" />
  709. </a-form-item>
  710. </a-form>
  711. <!-- HTTP / Mixed accounts -->
  712. <a-form v-if="protocol === Protocols.HTTP || protocol === Protocols.MIXED" :colon="false"
  713. :label-col="{ sm: { span: 8 } }" :wrapper-col="{ sm: { span: 14 } }" class="mt-12">
  714. <a-form-item label="Accounts">
  715. <a-button size="small" @click="protocol === Protocols.HTTP
  716. ? inbound.settings.addAccount(new Inbound.HttpSettings.HttpAccount())
  717. : inbound.settings.addAccount(new Inbound.MixedSettings.SocksAccount())">
  718. <template #icon>
  719. <PlusOutlined />
  720. </template>
  721. Add
  722. </a-button>
  723. </a-form-item>
  724. <a-form-item :wrapper-col="{ span: 24 }">
  725. <a-input-group v-for="(account, idx) in inbound.settings.accounts" :key="idx" compact class="mb-8">
  726. <a-input :style="{ width: '45%' }" v-model:value="account.user" placeholder="Username">
  727. <template #addonBefore>{{ idx + 1 }}</template>
  728. </a-input>
  729. <a-input :style="{ width: '45%' }" v-model:value="account.pass" placeholder="Password" />
  730. <a-button @click="inbound.settings.delAccount(idx)">
  731. <template #icon>
  732. <MinusOutlined />
  733. </template>
  734. </a-button>
  735. </a-input-group>
  736. </a-form-item>
  737. <a-form-item v-if="protocol === Protocols.HTTP" label="Allow transparent">
  738. <a-switch v-model:checked="inbound.settings.allowTransparent" />
  739. </a-form-item>
  740. <template v-if="protocol === Protocols.MIXED">
  741. <a-form-item label="Auth">
  742. <a-select v-model:value="inbound.settings.auth">
  743. <a-select-option value="noauth">noauth</a-select-option>
  744. <a-select-option value="password">password</a-select-option>
  745. </a-select>
  746. </a-form-item>
  747. <a-form-item label="UDP">
  748. <a-switch v-model:checked="inbound.settings.udp" />
  749. </a-form-item>
  750. <a-form-item v-if="inbound.settings.udp" label="UDP IP">
  751. <a-input v-model:value="inbound.settings.ip" />
  752. </a-form-item>
  753. </template>
  754. </a-form>
  755. <!-- Tunnel -->
  756. <a-form v-if="protocol === Protocols.TUNNEL" :colon="false" :label-col="{ sm: { span: 8 } }"
  757. :wrapper-col="{ sm: { span: 14 } }" class="mt-12">
  758. <a-form-item label="Address">
  759. <a-input v-model:value="inbound.settings.address" />
  760. </a-form-item>
  761. <a-form-item label="Destination port">
  762. <a-input-number v-model:value="inbound.settings.port" :min="1" :max="65535" />
  763. </a-form-item>
  764. <a-form-item label="Network">
  765. <a-select v-model:value="inbound.settings.network">
  766. <a-select-option value="tcp,udp">TCP, UDP</a-select-option>
  767. <a-select-option value="tcp">TCP</a-select-option>
  768. <a-select-option value="udp">UDP</a-select-option>
  769. </a-select>
  770. </a-form-item>
  771. <a-form-item label="Follow redirect">
  772. <a-switch v-model:checked="inbound.settings.followRedirect" />
  773. </a-form-item>
  774. </a-form>
  775. <!-- WireGuard -->
  776. <a-form v-if="protocol === Protocols.WIREGUARD" :colon="false" :label-col="{ sm: { span: 8 } }"
  777. :wrapper-col="{ sm: { span: 14 } }" class="mt-12">
  778. <a-form-item>
  779. <template #label>
  780. Secret key
  781. <SyncOutlined class="random-icon" @click="regenInboundWg" />
  782. </template>
  783. <a-input v-model:value="inbound.settings.secretKey" />
  784. </a-form-item>
  785. <a-form-item label="Public key">
  786. <a-input v-model:value="inbound.settings.pubKey" disabled />
  787. </a-form-item>
  788. <a-form-item label="MTU">
  789. <a-input-number v-model:value="inbound.settings.mtu" />
  790. </a-form-item>
  791. <a-form-item label="No-kernel TUN">
  792. <a-switch v-model:checked="inbound.settings.noKernelTun" />
  793. </a-form-item>
  794. <a-form-item label="Peers">
  795. <a-button size="small" @click="inbound.settings.addPeer()">
  796. <template #icon>
  797. <PlusOutlined />
  798. </template>
  799. Add peer
  800. </a-button>
  801. </a-form-item>
  802. <div v-for="(peer, idx) in inbound.settings.peers" :key="idx" class="wg-peer">
  803. <a-divider style="margin: 8px 0">
  804. Peer {{ idx + 1 }}
  805. <DeleteOutlined v-if="inbound.settings.peers.length > 1" class="danger-icon"
  806. @click="inbound.settings.delPeer(idx)" />
  807. </a-divider>
  808. <a-form-item>
  809. <template #label>
  810. Secret key
  811. <SyncOutlined class="random-icon" @click="regenWgKeypair(peer)" />
  812. </template>
  813. <a-input v-model:value="peer.privateKey" />
  814. </a-form-item>
  815. <a-form-item label="Public key">
  816. <a-input v-model:value="peer.publicKey" />
  817. </a-form-item>
  818. <a-form-item label="PSK">
  819. <a-input v-model:value="peer.psk" />
  820. </a-form-item>
  821. <a-form-item label="Allowed IPs">
  822. <a-button size="small" @click="peer.allowedIPs.push('')">
  823. <template #icon>
  824. <PlusOutlined />
  825. </template>
  826. </a-button>
  827. <a-input v-for="(_ip, j) in peer.allowedIPs" :key="j" v-model:value="peer.allowedIPs[j]" class="mt-4">
  828. <template #addonAfter>
  829. <a-button v-if="peer.allowedIPs.length > 1" size="small" @click="peer.allowedIPs.splice(j, 1)">
  830. <template #icon>
  831. <MinusOutlined />
  832. </template>
  833. </a-button>
  834. </template>
  835. </a-input>
  836. </a-form-item>
  837. <a-form-item label="Keep-alive">
  838. <a-input-number v-model:value="peer.keepAlive" :min="0" />
  839. </a-form-item>
  840. </div>
  841. </a-form>
  842. <!-- ============== Fallbacks (VLESS/Trojan over TCP) ============== -->
  843. <template v-if="showFallbacks">
  844. <a-divider style="margin: 12px 0" />
  845. <div class="fallbacks-header">
  846. <a-tooltip
  847. title="Route incoming TLS traffic to a backend when it doesn't match a valid VLESS/Trojan handshake. Match by SNI, ALPN, and HTTP path; the most precise rule wins. Fallbacks require TCP+TLS transport.">
  848. <span class="fallbacks-title">
  849. Fallbacks ({{ inbound.settings.fallbacks.length }})
  850. </span>
  851. </a-tooltip>
  852. <a-button type="primary" size="small" @click="addFallback">
  853. <template #icon>
  854. <PlusOutlined />
  855. </template>
  856. Add
  857. </a-button>
  858. </div>
  859. <a-form v-for="(fallback, idx) in inbound.settings.fallbacks" :key="idx" :colon="false"
  860. :label-col="{ sm: { span: 8 } }" :wrapper-col="{ sm: { span: 14 } }">
  861. <a-divider style="margin: 0">
  862. Fallback {{ idx + 1 }}
  863. <DeleteOutlined class="danger-icon" @click="delFallback(idx)" />
  864. </a-divider>
  865. <a-form-item>
  866. <template #label>
  867. <a-tooltip title="Match TLS SNI (server name). Leave empty to match any SNI.">
  868. SNI
  869. </a-tooltip>
  870. </template>
  871. <a-input v-model:value.trim="fallback.name" placeholder="any (leave empty)" />
  872. </a-form-item>
  873. <a-form-item>
  874. <template #label>
  875. <a-tooltip
  876. title="Match TLS ALPN. 'any' = no ALPN constraint. Use h2/http/1.1 split when the inbound advertises both.">
  877. ALPN
  878. </a-tooltip>
  879. </template>
  880. <a-select v-model:value="fallback.alpn">
  881. <a-select-option value="">any</a-select-option>
  882. <a-select-option value="h2">h2</a-select-option>
  883. <a-select-option value="http/1.1">http/1.1</a-select-option>
  884. </a-select>
  885. </a-form-item>
  886. <a-form-item :validate-status="fallback.path && !fallback.path.startsWith('/') ? 'error' : ''"
  887. :help="fallback.path && !fallback.path.startsWith('/') ? 'Path must start with /' : ''">
  888. <template #label>
  889. <a-tooltip
  890. title="Match the HTTP request path of the first packet. Must start with '/'. Leave empty to match any.">
  891. Path
  892. </a-tooltip>
  893. </template>
  894. <a-input v-model:value.trim="fallback.path" placeholder="any (leave empty) or /ws" />
  895. </a-form-item>
  896. <a-form-item :validate-status="!fallback.dest ? 'error' : ''"
  897. :help="!fallback.dest ? 'Destination is required' : ''">
  898. <template #label>
  899. <a-tooltip
  900. title="Where matching traffic is forwarded. Accepts a port number (80), an addr:port (127.0.0.1:8080), or a Unix socket path (/dev/shm/x.sock or @abstract).">
  901. Destination
  902. </a-tooltip>
  903. </template>
  904. <a-input v-model:value.trim="fallback.dest" placeholder="80 | 127.0.0.1:8080 | /dev/shm/x.sock" />
  905. </a-form-item>
  906. <a-form-item>
  907. <template #label>
  908. <a-tooltip
  909. title="PROXY protocol version sent to the destination. Off (0) for plain TCP; v1/v2 to preserve client IP if the backend supports it.">
  910. PROXY
  911. </a-tooltip>
  912. </template>
  913. <a-select v-model:value="fallback.xver">
  914. <a-select-option :value="0">Off</a-select-option>
  915. <a-select-option :value="1">v1</a-select-option>
  916. <a-select-option :value="2">v2</a-select-option>
  917. </a-select>
  918. </a-form-item>
  919. </a-form>
  920. </template>
  921. </a-tab-pane>
  922. <!-- ============================== STREAM ============================== -->
  923. <a-tab-pane v-if="canEnableStream" key="stream"
  924. tab="Stream"><!-- "Stream" stays literal — it's a wire-format identifier -->
  925. <a-form :colon="false" :label-col="{ sm: { span: 8 } }" :wrapper-col="{ sm: { span: 14 } }">
  926. <a-form-item v-if="protocol !== Protocols.HYSTERIA" label="Transmission">
  927. <a-select v-model:value="network" :style="{ width: '75%' }">
  928. <a-select-option value="tcp">TCP (RAW)</a-select-option>
  929. <a-select-option value="kcp">mKCP</a-select-option>
  930. <a-select-option value="ws">WebSocket</a-select-option>
  931. <a-select-option value="grpc">gRPC</a-select-option>
  932. <a-select-option value="httpupgrade">HTTPUpgrade</a-select-option>
  933. <a-select-option value="xhttp">XHTTP</a-select-option>
  934. </a-select>
  935. </a-form-item>
  936. <!-- TCP (RAW) — proxy-protocol + optional HTTP camouflage with full request/response editor -->
  937. <template v-if="network === 'tcp'">
  938. <a-form-item v-if="canEnableTls" label="Proxy Protocol">
  939. <a-switch v-model:checked="inbound.stream.tcp.acceptProxyProtocol" />
  940. </a-form-item>
  941. <a-form-item :label="`HTTP ${t('camouflage')}`">
  942. <a-switch :checked="inbound.stream.tcp.type === 'http'"
  943. @change="(v) => (inbound.stream.tcp.type = v ? 'http' : 'none')" />
  944. </a-form-item>
  945. <template v-if="inbound.stream.tcp.type === 'http'">
  946. <!-- Request -->
  947. <a-divider :style="{ margin: '0' }">{{ t('pages.inbounds.stream.general.request') }}</a-divider>
  948. <a-form-item :label="t('pages.inbounds.stream.tcp.version')">
  949. <a-input v-model:value="inbound.stream.tcp.request.version" />
  950. </a-form-item>
  951. <a-form-item :label="t('pages.inbounds.stream.tcp.method')">
  952. <a-input v-model:value="inbound.stream.tcp.request.method" />
  953. </a-form-item>
  954. <a-form-item>
  955. <template #label>
  956. {{ t('pages.inbounds.stream.tcp.path') }}
  957. <a-button size="small" :style="{ marginLeft: '6px' }"
  958. @click="inbound.stream.tcp.request.addPath('/')">
  959. <template #icon>
  960. <PlusOutlined />
  961. </template>
  962. </a-button>
  963. </template>
  964. <template v-for="(_p, idx) in inbound.stream.tcp.request.path" :key="`tcp-path-${idx}`">
  965. <a-input v-model:value="inbound.stream.tcp.request.path[idx]" class="mb-4">
  966. <template #addonAfter>
  967. <a-button v-if="inbound.stream.tcp.request.path.length > 1" size="small"
  968. @click="inbound.stream.tcp.request.removePath(idx)">
  969. <template #icon>
  970. <MinusOutlined />
  971. </template>
  972. </a-button>
  973. </template>
  974. </a-input>
  975. </template>
  976. </a-form-item>
  977. <a-form-item :label="t('pages.inbounds.stream.tcp.requestHeader')">
  978. <a-button size="small" @click="inbound.stream.tcp.request.addHeader('Host', '')">
  979. <template #icon>
  980. <PlusOutlined />
  981. </template>
  982. </a-button>
  983. </a-form-item>
  984. <a-form-item v-if="inbound.stream.tcp.request.headers.length > 0" :wrapper-col="{ span: 24 }">
  985. <a-input-group v-for="(h, idx) in inbound.stream.tcp.request.headers" :key="`tcp-rh-${idx}`" compact
  986. class="mb-8">
  987. <a-input :style="{ width: '45%' }" v-model:value="h.name"
  988. :placeholder="t('pages.inbounds.stream.general.name')">
  989. <template #addonBefore>{{ idx + 1 }}</template>
  990. </a-input>
  991. <a-input :style="{ width: '45%' }" v-model:value="h.value"
  992. :placeholder="t('pages.inbounds.stream.general.value')" />
  993. <a-button @click="inbound.stream.tcp.request.removeHeader(idx)">
  994. <template #icon>
  995. <MinusOutlined />
  996. </template>
  997. </a-button>
  998. </a-input-group>
  999. </a-form-item>
  1000. <!-- Response -->
  1001. <a-divider :style="{ margin: '0' }">{{ t('pages.inbounds.stream.general.response') }}</a-divider>
  1002. <a-form-item :label="t('pages.inbounds.stream.tcp.version')">
  1003. <a-input v-model:value="inbound.stream.tcp.response.version" />
  1004. </a-form-item>
  1005. <a-form-item :label="t('pages.inbounds.stream.tcp.status')">
  1006. <a-input v-model:value="inbound.stream.tcp.response.status" />
  1007. </a-form-item>
  1008. <a-form-item :label="t('pages.inbounds.stream.tcp.statusDescription')">
  1009. <a-input v-model:value="inbound.stream.tcp.response.reason" />
  1010. </a-form-item>
  1011. <a-form-item :label="t('pages.inbounds.stream.tcp.responseHeader')">
  1012. <a-button size="small"
  1013. @click="inbound.stream.tcp.response.addHeader('Content-Type', 'application/octet-stream')">
  1014. <template #icon>
  1015. <PlusOutlined />
  1016. </template>
  1017. </a-button>
  1018. </a-form-item>
  1019. <a-form-item v-if="inbound.stream.tcp.response.headers.length > 0" :wrapper-col="{ span: 24 }">
  1020. <a-input-group v-for="(h, idx) in inbound.stream.tcp.response.headers" :key="`tcp-rsh-${idx}`" compact
  1021. class="mb-8">
  1022. <a-input :style="{ width: '45%' }" v-model:value="h.name"
  1023. :placeholder="t('pages.inbounds.stream.general.name')">
  1024. <template #addonBefore>{{ idx + 1 }}</template>
  1025. </a-input>
  1026. <a-input :style="{ width: '45%' }" v-model:value="h.value"
  1027. :placeholder="t('pages.inbounds.stream.general.value')" />
  1028. <a-button @click="inbound.stream.tcp.response.removeHeader(idx)">
  1029. <template #icon>
  1030. <MinusOutlined />
  1031. </template>
  1032. </a-button>
  1033. </a-input-group>
  1034. </a-form-item>
  1035. </template>
  1036. </template>
  1037. <!-- mKCP -->
  1038. <template v-if="network === 'kcp'">
  1039. <a-form-item label="MTU">
  1040. <a-input-number v-model:value="inbound.stream.kcp.mtu" :min="576" :max="1460" />
  1041. </a-form-item>
  1042. <a-form-item label="TTI (ms)">
  1043. <a-input-number v-model:value="inbound.stream.kcp.tti" :min="10" :max="100" />
  1044. </a-form-item>
  1045. <a-form-item label="Uplink (MB/s)">
  1046. <a-input-number v-model:value="inbound.stream.kcp.upCap" :min="0" />
  1047. </a-form-item>
  1048. <a-form-item label="Downlink (MB/s)">
  1049. <a-input-number v-model:value="inbound.stream.kcp.downCap" :min="0" />
  1050. </a-form-item>
  1051. <a-form-item label="CWND Multiplier">
  1052. <a-input-number v-model:value="inbound.stream.kcp.cwndMultiplier" :min="1" />
  1053. </a-form-item>
  1054. <a-form-item label="Max Sending Window">
  1055. <a-input-number v-model:value="inbound.stream.kcp.maxSendingWindow" :min="0" />
  1056. </a-form-item>
  1057. </template>
  1058. <!-- WebSocket -->
  1059. <template v-if="network === 'ws'">
  1060. <a-form-item label="Proxy Protocol">
  1061. <a-switch v-model:checked="inbound.stream.ws.acceptProxyProtocol" />
  1062. </a-form-item>
  1063. <a-form-item :label="t('host')">
  1064. <a-input v-model:value="inbound.stream.ws.host" />
  1065. </a-form-item>
  1066. <a-form-item :label="t('path')">
  1067. <a-input v-model:value="inbound.stream.ws.path" />
  1068. </a-form-item>
  1069. <a-form-item label="Heartbeat Period">
  1070. <a-input-number v-model:value="inbound.stream.ws.heartbeatPeriod" :min="0" />
  1071. </a-form-item>
  1072. <a-form-item :label="t('pages.inbounds.stream.tcp.requestHeader')">
  1073. <a-button size="small" @click="inbound.stream.ws.addHeader('', '')">
  1074. <template #icon>
  1075. <PlusOutlined />
  1076. </template>
  1077. </a-button>
  1078. </a-form-item>
  1079. <a-form-item v-if="inbound.stream.ws.headers.length > 0" :wrapper-col="{ span: 24 }">
  1080. <a-input-group v-for="(h, idx) in inbound.stream.ws.headers" :key="`ws-h-${idx}`" compact class="mb-8">
  1081. <a-input :style="{ width: '45%' }" v-model:value="h.name"
  1082. :placeholder="t('pages.inbounds.stream.general.name')">
  1083. <template #addonBefore>{{ idx + 1 }}</template>
  1084. </a-input>
  1085. <a-input :style="{ width: '45%' }" v-model:value="h.value"
  1086. :placeholder="t('pages.inbounds.stream.general.value')" />
  1087. <a-button @click="inbound.stream.ws.removeHeader(idx)">
  1088. <template #icon>
  1089. <MinusOutlined />
  1090. </template>
  1091. </a-button>
  1092. </a-input-group>
  1093. </a-form-item>
  1094. </template>
  1095. <!-- gRPC -->
  1096. <template v-if="network === 'grpc'">
  1097. <a-form-item label="Service Name">
  1098. <a-input v-model:value="inbound.stream.grpc.serviceName" />
  1099. </a-form-item>
  1100. <a-form-item label="Authority">
  1101. <a-input v-model:value="inbound.stream.grpc.authority" />
  1102. </a-form-item>
  1103. <a-form-item label="Multi Mode">
  1104. <a-switch v-model:checked="inbound.stream.grpc.multiMode" />
  1105. </a-form-item>
  1106. </template>
  1107. <!-- HTTPUpgrade -->
  1108. <template v-if="network === 'httpupgrade'">
  1109. <a-form-item label="Proxy Protocol">
  1110. <a-switch v-model:checked="inbound.stream.httpupgrade.acceptProxyProtocol" />
  1111. </a-form-item>
  1112. <a-form-item :label="t('host')">
  1113. <a-input v-model:value="inbound.stream.httpupgrade.host" />
  1114. </a-form-item>
  1115. <a-form-item :label="t('path')">
  1116. <a-input v-model:value="inbound.stream.httpupgrade.path" />
  1117. </a-form-item>
  1118. <a-form-item :label="t('pages.inbounds.stream.tcp.requestHeader')">
  1119. <a-button size="small" @click="inbound.stream.httpupgrade.addHeader('', '')">
  1120. <template #icon>
  1121. <PlusOutlined />
  1122. </template>
  1123. </a-button>
  1124. </a-form-item>
  1125. <a-form-item v-if="inbound.stream.httpupgrade.headers.length > 0" :wrapper-col="{ span: 24 }">
  1126. <a-input-group v-for="(h, idx) in inbound.stream.httpupgrade.headers" :key="`hu-h-${idx}`" compact
  1127. class="mb-8">
  1128. <a-input :style="{ width: '45%' }" v-model:value="h.name"
  1129. :placeholder="t('pages.inbounds.stream.general.name')">
  1130. <template #addonBefore>{{ idx + 1 }}</template>
  1131. </a-input>
  1132. <a-input :style="{ width: '45%' }" v-model:value="h.value"
  1133. :placeholder="t('pages.inbounds.stream.general.value')" />
  1134. <a-button @click="inbound.stream.httpupgrade.removeHeader(idx)">
  1135. <template #icon>
  1136. <MinusOutlined />
  1137. </template>
  1138. </a-button>
  1139. </a-input-group>
  1140. </a-form-item>
  1141. </template>
  1142. <!-- XHTTP -->
  1143. <template v-if="network === 'xhttp'">
  1144. <a-form-item :label="t('host')">
  1145. <a-input v-model:value="inbound.stream.xhttp.host" />
  1146. </a-form-item>
  1147. <a-form-item :label="t('path')">
  1148. <a-input v-model:value="inbound.stream.xhttp.path" />
  1149. </a-form-item>
  1150. <a-form-item :label="t('pages.inbounds.stream.tcp.requestHeader')">
  1151. <a-button size="small" @click="inbound.stream.xhttp.addHeader('', '')">
  1152. <template #icon>
  1153. <PlusOutlined />
  1154. </template>
  1155. </a-button>
  1156. </a-form-item>
  1157. <a-form-item v-if="inbound.stream.xhttp.headers.length > 0" :wrapper-col="{ span: 24 }">
  1158. <a-input-group v-for="(h, idx) in inbound.stream.xhttp.headers" :key="`xh-h-${idx}`" compact class="mb-8">
  1159. <a-input :style="{ width: '45%' }" v-model:value="h.name"
  1160. :placeholder="t('pages.inbounds.stream.general.name')">
  1161. <template #addonBefore>{{ idx + 1 }}</template>
  1162. </a-input>
  1163. <a-input :style="{ width: '45%' }" v-model:value="h.value"
  1164. :placeholder="t('pages.inbounds.stream.general.value')" />
  1165. <a-button @click="inbound.stream.xhttp.removeHeader(idx)">
  1166. <template #icon>
  1167. <MinusOutlined />
  1168. </template>
  1169. </a-button>
  1170. </a-input-group>
  1171. </a-form-item>
  1172. <a-form-item label="Mode">
  1173. <a-select v-model:value="inbound.stream.xhttp.mode" :style="{ width: '50%' }">
  1174. <a-select-option v-for="m in MODE_OPTIONS" :key="m" :value="m">{{ m }}</a-select-option>
  1175. </a-select>
  1176. </a-form-item>
  1177. <a-form-item v-if="inbound.stream.xhttp.mode === 'packet-up'" label="Max Buffered Upload">
  1178. <a-input-number v-model:value="inbound.stream.xhttp.scMaxBufferedPosts" />
  1179. </a-form-item>
  1180. <a-form-item v-if="inbound.stream.xhttp.mode === 'packet-up'" label="Max Upload Size (Byte)">
  1181. <a-input v-model:value="inbound.stream.xhttp.scMaxEachPostBytes" />
  1182. </a-form-item>
  1183. <a-form-item v-if="inbound.stream.xhttp.mode === 'stream-up'" label="Stream-Up Server">
  1184. <a-input v-model:value="inbound.stream.xhttp.scStreamUpServerSecs" />
  1185. </a-form-item>
  1186. <a-form-item label="Server Max Header Bytes">
  1187. <a-input-number v-model:value="inbound.stream.xhttp.serverMaxHeaderBytes" :min="0"
  1188. placeholder="0 (default)" />
  1189. </a-form-item>
  1190. <a-form-item label="Padding Bytes">
  1191. <a-input v-model:value="inbound.stream.xhttp.xPaddingBytes" />
  1192. </a-form-item>
  1193. <a-form-item label="Padding Obfs Mode">
  1194. <a-switch v-model:checked="inbound.stream.xhttp.xPaddingObfsMode" />
  1195. </a-form-item>
  1196. <template v-if="inbound.stream.xhttp.xPaddingObfsMode">
  1197. <a-form-item label="Padding Key">
  1198. <a-input v-model:value="inbound.stream.xhttp.xPaddingKey" placeholder="x_padding" />
  1199. </a-form-item>
  1200. <a-form-item label="Padding Header">
  1201. <a-input v-model:value="inbound.stream.xhttp.xPaddingHeader" placeholder="X-Padding" />
  1202. </a-form-item>
  1203. <a-form-item label="Padding Placement">
  1204. <a-select v-model:value="inbound.stream.xhttp.xPaddingPlacement">
  1205. <a-select-option value="">Default (queryInHeader)</a-select-option>
  1206. <a-select-option value="queryInHeader">queryInHeader</a-select-option>
  1207. <a-select-option value="header">header</a-select-option>
  1208. <a-select-option value="cookie">cookie</a-select-option>
  1209. <a-select-option value="query">query</a-select-option>
  1210. </a-select>
  1211. </a-form-item>
  1212. <a-form-item label="Padding Method">
  1213. <a-select v-model:value="inbound.stream.xhttp.xPaddingMethod">
  1214. <a-select-option value="">Default (repeat-x)</a-select-option>
  1215. <a-select-option value="repeat-x">repeat-x</a-select-option>
  1216. <a-select-option value="tokenish">tokenish</a-select-option>
  1217. </a-select>
  1218. </a-form-item>
  1219. </template>
  1220. <a-form-item label="Session Placement">
  1221. <a-select v-model:value="inbound.stream.xhttp.sessionPlacement">
  1222. <a-select-option value="">Default (path)</a-select-option>
  1223. <a-select-option value="path">path</a-select-option>
  1224. <a-select-option value="header">header</a-select-option>
  1225. <a-select-option value="cookie">cookie</a-select-option>
  1226. <a-select-option value="query">query</a-select-option>
  1227. </a-select>
  1228. </a-form-item>
  1229. <a-form-item
  1230. v-if="inbound.stream.xhttp.sessionPlacement && inbound.stream.xhttp.sessionPlacement !== 'path'"
  1231. label="Session Key">
  1232. <a-input v-model:value="inbound.stream.xhttp.sessionKey" placeholder="x_session" />
  1233. </a-form-item>
  1234. <a-form-item label="Sequence Placement">
  1235. <a-select v-model:value="inbound.stream.xhttp.seqPlacement">
  1236. <a-select-option value="">Default (path)</a-select-option>
  1237. <a-select-option value="path">path</a-select-option>
  1238. <a-select-option value="header">header</a-select-option>
  1239. <a-select-option value="cookie">cookie</a-select-option>
  1240. <a-select-option value="query">query</a-select-option>
  1241. </a-select>
  1242. </a-form-item>
  1243. <a-form-item v-if="inbound.stream.xhttp.seqPlacement && inbound.stream.xhttp.seqPlacement !== 'path'"
  1244. label="Sequence Key">
  1245. <a-input v-model:value="inbound.stream.xhttp.seqKey" placeholder="x_seq" />
  1246. </a-form-item>
  1247. <a-form-item v-if="inbound.stream.xhttp.mode === 'packet-up'" label="Uplink Data Placement">
  1248. <a-select v-model:value="inbound.stream.xhttp.uplinkDataPlacement">
  1249. <a-select-option value="">Default (body)</a-select-option>
  1250. <a-select-option value="body">body</a-select-option>
  1251. <a-select-option value="header">header</a-select-option>
  1252. <a-select-option value="cookie">cookie</a-select-option>
  1253. <a-select-option value="query">query</a-select-option>
  1254. </a-select>
  1255. </a-form-item>
  1256. <a-form-item
  1257. v-if="inbound.stream.xhttp.mode === 'packet-up' && inbound.stream.xhttp.uplinkDataPlacement && inbound.stream.xhttp.uplinkDataPlacement !== 'body'"
  1258. label="Uplink Data Key">
  1259. <a-input v-model:value="inbound.stream.xhttp.uplinkDataKey" placeholder="x_data" />
  1260. </a-form-item>
  1261. <a-form-item label="No SSE Header">
  1262. <a-switch v-model:checked="inbound.stream.xhttp.noSSEHeader" />
  1263. </a-form-item>
  1264. </template>
  1265. <!-- ====== Security section ====== -->
  1266. <a-form-item label="Security">
  1267. <a-select v-model:value="security" :style="{ width: '160px' }" :disabled="!canEnableTls">
  1268. <a-select-option value="none">none</a-select-option>
  1269. <a-select-option value="tls">tls</a-select-option>
  1270. <a-select-option v-if="canEnableReality" value="reality">reality</a-select-option>
  1271. </a-select>
  1272. </a-form-item>
  1273. <template v-if="security === 'tls' && inbound.stream.tls">
  1274. <a-form-item label="SNI">
  1275. <a-input v-model:value="inbound.stream.tls.sni" placeholder="Server Name Indication" />
  1276. </a-form-item>
  1277. <a-form-item label="Cipher Suites">
  1278. <a-select v-model:value="inbound.stream.tls.cipherSuites">
  1279. <a-select-option value="">Auto</a-select-option>
  1280. <a-select-option v-for="[label, val] in CIPHER_SUITES" :key="val" :value="val">{{ label
  1281. }}</a-select-option>
  1282. </a-select>
  1283. </a-form-item>
  1284. <a-form-item label="Min/Max Version">
  1285. <a-input-group compact>
  1286. <a-select v-model:value="inbound.stream.tls.minVersion" :style="{ width: '50%' }">
  1287. <a-select-option v-for="v in TLS_VERSIONS" :key="v" :value="v">{{ v }}</a-select-option>
  1288. </a-select>
  1289. <a-select v-model:value="inbound.stream.tls.maxVersion" :style="{ width: '50%' }">
  1290. <a-select-option v-for="v in TLS_VERSIONS" :key="v" :value="v">{{ v }}</a-select-option>
  1291. </a-select>
  1292. </a-input-group>
  1293. </a-form-item>
  1294. <a-form-item label="uTLS">
  1295. <a-select v-model:value="inbound.stream.tls.settings.fingerprint" :style="{ width: '100%' }">
  1296. <a-select-option value="">None</a-select-option>
  1297. <a-select-option v-for="fp in FINGERPRINTS" :key="fp" :value="fp">{{ fp }}</a-select-option>
  1298. </a-select>
  1299. </a-form-item>
  1300. <a-form-item label="ALPN">
  1301. <a-select v-model:value="inbound.stream.tls.alpn" mode="multiple" :style="{ width: '100%' }"
  1302. :token-separators="[',']">
  1303. <a-select-option v-for="a in ALPNS" :key="a" :value="a">{{ a }}</a-select-option>
  1304. </a-select>
  1305. </a-form-item>
  1306. <a-form-item label="Reject Unknown SNI">
  1307. <a-switch v-model:checked="inbound.stream.tls.rejectUnknownSni" />
  1308. </a-form-item>
  1309. <a-form-item label="Disable System Root">
  1310. <a-switch v-model:checked="inbound.stream.tls.disableSystemRoot" />
  1311. </a-form-item>
  1312. <a-form-item label="Session Resumption">
  1313. <a-switch v-model:checked="inbound.stream.tls.enableSessionResumption" />
  1314. </a-form-item>
  1315. <!-- Cert array — file path or inline content per row -->
  1316. <template v-for="(cert, idx) in inbound.stream.tls.certs" :key="`cert-${idx}`">
  1317. <a-form-item :label="t('certificate')">
  1318. <a-radio-group v-model:value="cert.useFile" button-style="solid">
  1319. <a-radio-button :value="true">{{ t('pages.inbounds.certificatePath') }}</a-radio-button>
  1320. <a-radio-button :value="false">{{ t('pages.inbounds.certificateContent') }}</a-radio-button>
  1321. </a-radio-group>
  1322. </a-form-item>
  1323. <a-form-item label=" ">
  1324. <a-space>
  1325. <a-button v-if="idx === 0" type="primary" size="small" @click="inbound.stream.tls.addCert()">
  1326. <template #icon>
  1327. <PlusOutlined />
  1328. </template>
  1329. </a-button>
  1330. <a-button v-if="inbound.stream.tls.certs.length > 1" type="primary" size="small"
  1331. @click="inbound.stream.tls.removeCert(idx)">
  1332. <template #icon>
  1333. <MinusOutlined />
  1334. </template>
  1335. </a-button>
  1336. </a-space>
  1337. </a-form-item>
  1338. <template v-if="cert.useFile">
  1339. <a-form-item :label="t('pages.inbounds.publicKey')">
  1340. <a-input v-model:value="cert.certFile" />
  1341. </a-form-item>
  1342. <a-form-item :label="t('pages.inbounds.privatekey')">
  1343. <a-input v-model:value="cert.keyFile" />
  1344. </a-form-item>
  1345. <a-form-item label=" ">
  1346. <a-button type="primary" :disabled="!defaultCert && !defaultKey" @click="setDefaultCertData(idx)">
  1347. {{ t('pages.inbounds.setDefaultCert') }}
  1348. </a-button>
  1349. </a-form-item>
  1350. </template>
  1351. <template v-else>
  1352. <a-form-item :label="t('pages.inbounds.publicKey')">
  1353. <a-textarea v-model:value="cert.cert" :auto-size="{ minRows: 3, maxRows: 8 }" />
  1354. </a-form-item>
  1355. <a-form-item :label="t('pages.inbounds.privatekey')">
  1356. <a-textarea v-model:value="cert.key" :auto-size="{ minRows: 3, maxRows: 8 }" />
  1357. </a-form-item>
  1358. </template>
  1359. <a-form-item label="One Time Loading">
  1360. <a-switch v-model:checked="cert.oneTimeLoading" />
  1361. </a-form-item>
  1362. <a-form-item label="Usage Option">
  1363. <a-select v-model:value="cert.usage" :style="{ width: '50%' }">
  1364. <a-select-option v-for="u in USAGES" :key="u" :value="u">{{ u }}</a-select-option>
  1365. </a-select>
  1366. </a-form-item>
  1367. <a-form-item v-if="cert.usage === 'issue'" label="Build Chain">
  1368. <a-switch v-model:checked="cert.buildChain" />
  1369. </a-form-item>
  1370. </template>
  1371. <!-- ECH (Encrypted Client Hello) -->
  1372. <a-form-item label="ECH key">
  1373. <a-input v-model:value="inbound.stream.tls.echServerKeys" />
  1374. </a-form-item>
  1375. <a-form-item label="ECH config">
  1376. <a-input v-model:value="inbound.stream.tls.settings.echConfigList" />
  1377. </a-form-item>
  1378. <a-form-item label=" ">
  1379. <a-space>
  1380. <a-button type="primary" :loading="saving" @click="getNewEchCert">Get New ECH Cert</a-button>
  1381. <a-button danger @click="clearEchCert">Clear</a-button>
  1382. </a-space>
  1383. </a-form-item>
  1384. </template>
  1385. <template v-if="security === 'reality' && inbound.stream.reality">
  1386. <a-form-item label="Show">
  1387. <a-switch v-model:checked="inbound.stream.reality.show" />
  1388. </a-form-item>
  1389. <a-form-item label="Xver">
  1390. <a-input-number v-model:value="inbound.stream.reality.xver" :min="0" />
  1391. </a-form-item>
  1392. <a-form-item label="uTLS">
  1393. <a-select v-model:value="inbound.stream.reality.settings.fingerprint" :style="{ width: '100%' }">
  1394. <a-select-option v-for="fp in FINGERPRINTS" :key="fp" :value="fp">{{ fp }}</a-select-option>
  1395. </a-select>
  1396. </a-form-item>
  1397. <a-form-item>
  1398. <template #label>
  1399. Target
  1400. <SyncOutlined class="random-icon" @click="randomizeRealityTarget" />
  1401. </template>
  1402. <a-input v-model:value="inbound.stream.reality.target" />
  1403. </a-form-item>
  1404. <a-form-item>
  1405. <template #label>
  1406. SNI
  1407. <SyncOutlined class="random-icon" @click="randomizeRealityTarget" />
  1408. </template>
  1409. <a-input v-model:value="inbound.stream.reality.serverNames" />
  1410. </a-form-item>
  1411. <a-form-item label="Max Time Diff (ms)">
  1412. <a-input-number v-model:value="inbound.stream.reality.maxTimediff" :min="0" />
  1413. </a-form-item>
  1414. <a-form-item label="Min Client Ver">
  1415. <a-input v-model:value="inbound.stream.reality.minClientVer" placeholder="25.9.11" />
  1416. </a-form-item>
  1417. <a-form-item label="Max Client Ver">
  1418. <a-input v-model:value="inbound.stream.reality.maxClientVer" placeholder="25.9.11" />
  1419. </a-form-item>
  1420. <a-form-item>
  1421. <template #label>
  1422. Short IDs
  1423. <SyncOutlined class="random-icon" @click="randomizeShortIds" />
  1424. </template>
  1425. <a-textarea v-model:value="inbound.stream.reality.shortIds" :auto-size="{ minRows: 1, maxRows: 4 }" />
  1426. </a-form-item>
  1427. <a-form-item label="SpiderX">
  1428. <a-input v-model:value="inbound.stream.reality.settings.spiderX" />
  1429. </a-form-item>
  1430. <a-form-item :label="t('pages.inbounds.publicKey')">
  1431. <a-textarea v-model:value="inbound.stream.reality.settings.publicKey"
  1432. :auto-size="{ minRows: 1, maxRows: 4 }" />
  1433. </a-form-item>
  1434. <a-form-item :label="t('pages.inbounds.privatekey')">
  1435. <a-textarea v-model:value="inbound.stream.reality.privateKey" :auto-size="{ minRows: 1, maxRows: 4 }" />
  1436. </a-form-item>
  1437. <a-form-item label=" ">
  1438. <a-space>
  1439. <a-button type="primary" :loading="saving" @click="genRealityKeypair">Get New Cert</a-button>
  1440. <a-button danger @click="clearRealityKeypair">Clear</a-button>
  1441. </a-space>
  1442. </a-form-item>
  1443. <a-form-item label="mldsa65 Seed">
  1444. <a-textarea v-model:value="inbound.stream.reality.mldsa65Seed" :auto-size="{ minRows: 2, maxRows: 6 }" />
  1445. </a-form-item>
  1446. <a-form-item label="mldsa65 Verify">
  1447. <a-textarea v-model:value="inbound.stream.reality.settings.mldsa65Verify"
  1448. :auto-size="{ minRows: 2, maxRows: 6 }" />
  1449. </a-form-item>
  1450. <a-form-item label=" ">
  1451. <a-space>
  1452. <a-button type="primary" :loading="saving" @click="genMldsa65">Get New Seed</a-button>
  1453. <a-button danger @click="clearMldsa65">Clear</a-button>
  1454. </a-space>
  1455. </a-form-item>
  1456. </template>
  1457. <!-- ====== External Proxy ====== -->
  1458. <a-form-item label="External Proxy">
  1459. <a-switch v-model:checked="externalProxy" />
  1460. <a-button v-if="externalProxy" size="small" type="primary" :style="{ marginLeft: '10px' }"
  1461. @click="inbound.stream.externalProxy.push({ forceTls: 'same', dest: '', port: 443, remark: '' })">
  1462. <template #icon>
  1463. <PlusOutlined />
  1464. </template>
  1465. </a-button>
  1466. </a-form-item>
  1467. <a-form-item v-if="externalProxy" :wrapper-col="{ span: 24 }">
  1468. <a-input-group v-for="(row, idx) in inbound.stream.externalProxy" :key="`ep-${idx}`" compact
  1469. :style="{ margin: '8px 0' }">
  1470. <a-tooltip title="Force TLS">
  1471. <a-select v-model:value="row.forceTls" :style="{ width: '20%' }">
  1472. <a-select-option value="same">{{ t('pages.inbounds.same') }}</a-select-option>
  1473. <a-select-option value="none">{{ t('none') }}</a-select-option>
  1474. <a-select-option value="tls">TLS</a-select-option>
  1475. </a-select>
  1476. </a-tooltip>
  1477. <a-input v-model:value="row.dest" :style="{ width: '30%' }" :placeholder="t('host')" />
  1478. <a-tooltip :title="t('pages.inbounds.port')">
  1479. <a-input-number v-model:value="row.port" :style="{ width: '15%' }" :min="1" :max="65535" />
  1480. </a-tooltip>
  1481. <a-input v-model:value="row.remark" :style="{ width: '35%' }" :placeholder="t('pages.inbounds.remark')">
  1482. <template #addonAfter>
  1483. <MinusOutlined @click="inbound.stream.externalProxy.splice(idx, 1)" />
  1484. </template>
  1485. </a-input>
  1486. </a-input-group>
  1487. </a-form-item>
  1488. <!-- ====== Sockopt ====== -->
  1489. <a-form-item label="Sockopt">
  1490. <a-switch v-model:checked="inbound.stream.sockoptSwitch" />
  1491. </a-form-item>
  1492. <template v-if="inbound.stream.sockoptSwitch && inbound.stream.sockopt">
  1493. <a-form-item label="Route Mark">
  1494. <a-input-number v-model:value="inbound.stream.sockopt.mark" :min="0" />
  1495. </a-form-item>
  1496. <a-form-item label="TCP Keep Alive Interval">
  1497. <a-input-number v-model:value="inbound.stream.sockopt.tcpKeepAliveInterval" :min="0" />
  1498. </a-form-item>
  1499. <a-form-item label="TCP Keep Alive Idle">
  1500. <a-input-number v-model:value="inbound.stream.sockopt.tcpKeepAliveIdle" :min="0" />
  1501. </a-form-item>
  1502. <a-form-item label="TCP Max Seg">
  1503. <a-input-number v-model:value="inbound.stream.sockopt.tcpMaxSeg" :min="0" />
  1504. </a-form-item>
  1505. <a-form-item label="TCP User Timeout">
  1506. <a-input-number v-model:value="inbound.stream.sockopt.tcpUserTimeout" :min="0" />
  1507. </a-form-item>
  1508. <a-form-item label="TCP Window Clamp">
  1509. <a-input-number v-model:value="inbound.stream.sockopt.tcpWindowClamp" :min="0" />
  1510. </a-form-item>
  1511. <a-form-item label="Proxy Protocol">
  1512. <a-switch v-model:checked="inbound.stream.sockopt.acceptProxyProtocol" />
  1513. </a-form-item>
  1514. <a-form-item label="TCP Fast Open">
  1515. <a-switch v-model:checked="inbound.stream.sockopt.tcpFastOpen" />
  1516. </a-form-item>
  1517. <a-form-item label="Multipath TCP">
  1518. <a-switch v-model:checked="inbound.stream.sockopt.tcpMptcp" />
  1519. </a-form-item>
  1520. <a-form-item label="Penetrate">
  1521. <a-switch v-model:checked="inbound.stream.sockopt.penetrate" />
  1522. </a-form-item>
  1523. <a-form-item label="V6 Only">
  1524. <a-switch v-model:checked="inbound.stream.sockopt.V6Only" />
  1525. </a-form-item>
  1526. <a-form-item label="Domain Strategy">
  1527. <a-select v-model:value="inbound.stream.sockopt.domainStrategy" :style="{ width: '50%' }">
  1528. <a-select-option v-for="d in DOMAIN_STRATEGIES" :key="d" :value="d">{{ d }}</a-select-option>
  1529. </a-select>
  1530. </a-form-item>
  1531. <a-form-item label="TCP Congestion">
  1532. <a-select v-model:value="inbound.stream.sockopt.tcpcongestion" :style="{ width: '50%' }">
  1533. <a-select-option v-for="c in TCP_CONGESTIONS" :key="c" :value="c">{{ c }}</a-select-option>
  1534. </a-select>
  1535. </a-form-item>
  1536. <a-form-item label="TProxy">
  1537. <a-select v-model:value="inbound.stream.sockopt.tproxy" :style="{ width: '50%' }">
  1538. <a-select-option value="off">Off</a-select-option>
  1539. <a-select-option value="redirect">Redirect</a-select-option>
  1540. <a-select-option value="tproxy">TProxy</a-select-option>
  1541. </a-select>
  1542. </a-form-item>
  1543. <a-form-item label="Dialer Proxy">
  1544. <a-input v-model:value="inbound.stream.sockopt.dialerProxy" />
  1545. </a-form-item>
  1546. <a-form-item label="Interface Name">
  1547. <a-input v-model:value="inbound.stream.sockopt.interfaceName" />
  1548. </a-form-item>
  1549. <a-form-item label="Trusted X-Forwarded-For">
  1550. <a-select v-model:value="inbound.stream.sockopt.trustedXForwardedFor" mode="tags"
  1551. :style="{ width: '100%' }" :token-separators="[',']">
  1552. <a-select-option value="CF-Connecting-IP">CF-Connecting-IP</a-select-option>
  1553. <a-select-option value="X-Real-IP">X-Real-IP</a-select-option>
  1554. <a-select-option value="True-Client-IP">True-Client-IP</a-select-option>
  1555. <a-select-option value="X-Client-IP">X-Client-IP</a-select-option>
  1556. </a-select>
  1557. </a-form-item>
  1558. </template>
  1559. </a-form>
  1560. <!-- ====== FinalMask (TCP/UDP masks + QUIC params) ====== -->
  1561. <FinalMaskForm :stream="inbound.stream" :protocol="protocol" />
  1562. </a-tab-pane>
  1563. <!-- ============================== SNIFFING ============================== -->
  1564. <a-tab-pane key="sniffing" tab="Sniffing"><!-- "Sniffing" stays literal — xray config term -->
  1565. <a-form :colon="false" :label-col="{ sm: { span: 8 } }" :wrapper-col="{ sm: { span: 14 } }">
  1566. <a-form-item label="Enabled">
  1567. <a-switch v-model:checked="inbound.sniffing.enabled" />
  1568. </a-form-item>
  1569. <template v-if="inbound.sniffing.enabled">
  1570. <a-form-item :wrapper-col="{ span: 24 }">
  1571. <a-checkbox-group v-model:value="inbound.sniffing.destOverride">
  1572. <a-checkbox v-for="(value, key) in SNIFFING_OPTION" :key="key" :value="value">{{ key }}</a-checkbox>
  1573. </a-checkbox-group>
  1574. </a-form-item>
  1575. <a-form-item label="Metadata only">
  1576. <a-switch v-model:checked="inbound.sniffing.metadataOnly" />
  1577. </a-form-item>
  1578. <a-form-item label="Route only">
  1579. <a-switch v-model:checked="inbound.sniffing.routeOnly" />
  1580. </a-form-item>
  1581. <a-form-item label="IPs excluded">
  1582. <a-select v-model:value="inbound.sniffing.ipsExcluded" mode="tags" :token-separators="[',']"
  1583. placeholder="IP/CIDR/geoip:*/ext:*" :style="{ width: '100%' }" />
  1584. </a-form-item>
  1585. <a-form-item label="Domains excluded">
  1586. <a-select v-model:value="inbound.sniffing.domainsExcluded" mode="tags" :token-separators="[',']"
  1587. placeholder="domain:*/ext:*" :style="{ width: '100%' }" />
  1588. </a-form-item>
  1589. </template>
  1590. </a-form>
  1591. </a-tab-pane>
  1592. <!-- ============================== ADVANCED ============================== -->
  1593. <a-tab-pane key="advanced" :tab="t('pages.xray.advancedTemplate')">
  1594. <a-alert type="info" show-icon
  1595. message="Edit raw stream JSON to access advanced fields we don't yet expose through the form."
  1596. class="mb-12" />
  1597. <a-form layout="vertical">
  1598. <a-form-item label="settings (clients, encryption, fallbacks, …)">
  1599. <a-textarea v-model:value="advancedJson.settings" :auto-size="{ minRows: 10, maxRows: 24 }"
  1600. spellcheck="false" class="json-editor" />
  1601. </a-form-item>
  1602. <a-form-item label="streamSettings">
  1603. <a-textarea v-model:value="advancedJson.stream" :auto-size="{ minRows: 10, maxRows: 24 }" spellcheck="false"
  1604. class="json-editor" />
  1605. </a-form-item>
  1606. <a-form-item label="sniffing (overrides the Sniffing tab when set)">
  1607. <a-textarea v-model:value="advancedJson.sniffing" :auto-size="{ minRows: 6, maxRows: 16 }"
  1608. spellcheck="false" class="json-editor" />
  1609. </a-form-item>
  1610. </a-form>
  1611. </a-tab-pane>
  1612. </a-tabs>
  1613. </a-modal>
  1614. </template>
  1615. <style scoped>
  1616. .mt-4 {
  1617. margin-top: 4px;
  1618. }
  1619. .mt-8 {
  1620. margin-top: 8px;
  1621. }
  1622. .mt-12 {
  1623. margin-top: 12px;
  1624. }
  1625. .mb-4 {
  1626. margin-bottom: 4px;
  1627. }
  1628. .mb-8 {
  1629. margin-bottom: 8px;
  1630. }
  1631. .mb-12 {
  1632. margin-bottom: 12px;
  1633. }
  1634. .random-icon {
  1635. margin-left: 4px;
  1636. cursor: pointer;
  1637. color: var(--ant-primary-color, #1890ff);
  1638. }
  1639. .danger-icon {
  1640. margin-left: 6px;
  1641. cursor: pointer;
  1642. color: #ff4d4f;
  1643. }
  1644. .json-editor {
  1645. font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  1646. font-size: 12px;
  1647. }
  1648. .client-summary {
  1649. width: 100%;
  1650. border-collapse: collapse;
  1651. }
  1652. .client-summary th,
  1653. .client-summary td {
  1654. padding: 4px 8px;
  1655. text-align: left;
  1656. border-bottom: 1px solid rgba(128, 128, 128, 0.15);
  1657. }
  1658. .fallbacks-header {
  1659. display: flex;
  1660. align-items: center;
  1661. gap: 8px;
  1662. margin: 8px 0;
  1663. }
  1664. .fallbacks-title {
  1665. font-weight: 500;
  1666. flex: 1;
  1667. }
  1668. .wg-peer {
  1669. margin-top: 4px;
  1670. }
  1671. .section-heading {
  1672. font-weight: 500;
  1673. margin: 12px 0 6px;
  1674. opacity: 0.85;
  1675. }
  1676. </style>