xray.html 104 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. {{template "head" .}}
  4. <link rel="stylesheet" href="{{ .base_path }}assets/codemirror/codemirror.min.css?{{ .cur_ver }}">
  5. <link rel="stylesheet" href="{{ .base_path }}assets/codemirror/fold/foldgutter.css">
  6. <link rel="stylesheet" href="{{ .base_path }}assets/codemirror/xq.min.css?{{ .cur_ver }}">
  7. <link rel="stylesheet" href="{{ .base_path }}assets/codemirror/lint/lint.css">
  8. <script src="{{ .base_path }}assets/base64/base64.min.js"></script>
  9. <script src="{{ .base_path }}assets/js/model/outbound.js?{{ .cur_ver }}"></script>
  10. <script src="{{ .base_path }}assets/codemirror/codemirror.min.js?{{ .cur_ver }}"></script>
  11. <script src="{{ .base_path }}assets/codemirror/javascript.js"></script>
  12. <script src="{{ .base_path }}assets/codemirror/jshint.js"></script>
  13. <script src="{{ .base_path }}assets/codemirror/jsonlint.js"></script>
  14. <script src="{{ .base_path }}assets/codemirror/lint/lint.js"></script>
  15. <script src="{{ .base_path }}assets/codemirror/lint/javascript-lint.js"></script>
  16. <script src="{{ .base_path }}assets/codemirror/hint/javascript-hint.js"></script>
  17. <script src="{{ .base_path }}assets/codemirror/fold/foldcode.js"></script>
  18. <script src="{{ .base_path }}assets/codemirror/fold/foldgutter.js"></script>
  19. <script src="{{ .base_path }}assets/codemirror/fold/brace-fold.js"></script>
  20. <style>
  21. @media (min-width: 769px) {
  22. .ant-layout-content {
  23. margin: 24px 16px;
  24. }
  25. }
  26. @media (max-width: 768px) {
  27. .ant-tabs-nav .ant-tabs-tab {
  28. margin: 0;
  29. padding: 12px .5rem;
  30. }
  31. .ant-table-thead>tr>th,
  32. .ant-table-tbody>tr>td {
  33. padding: 10px 0px;
  34. }
  35. }
  36. .ant-tabs-bar {
  37. margin: 0;
  38. }
  39. .ant-list-item {
  40. display: block;
  41. }
  42. .collapse-title {
  43. color: inherit;
  44. font-weight: bold;
  45. font-size: 18px;
  46. padding: 10px 20px;
  47. border-bottom: 2px solid;
  48. }
  49. .collapse-title>i {
  50. color: inherit;
  51. font-size: 24px;
  52. }
  53. .ant-collapse-content-box>li {
  54. padding: 12px 0 0 0 !important;
  55. }
  56. .ant-list-item>li {
  57. padding: 10px 20px !important;
  58. }
  59. </style>
  60. <body>
  61. <a-layout id="app" v-cloak :class="themeSwitcher.currentTheme">
  62. {{ template "commonSider" . }}
  63. <a-layout id="content-layout">
  64. <a-layout-content>
  65. <a-spin :spinning="spinning" :delay="500" tip='{{ i18n "loading"}}'>
  66. <transition name="list" appear>
  67. <a-alert type="error" v-if="showAlert" style="margin-bottom: 10px"
  68. message='{{ i18n "secAlertTitle" }}'
  69. color="red"
  70. description='{{ i18n "secAlertSsl" }}'
  71. show-icon closable>
  72. </a-alert>
  73. </transition>
  74. <a-space direction="vertical">
  75. <a-card hoverable style="margin-bottom: .5rem;">
  76. <a-row style="display: flex; flex-wrap: wrap; align-items: center;">
  77. <a-col :xs="24" :sm="10" style="padding: 4px;">
  78. <a-space direction="horizontal">
  79. <a-button type="primary" :disabled="saveBtnDisable" @click="updateXraySetting">{{ i18n "pages.xray.save" }}</a-button>
  80. <a-button type="danger" :disabled="!saveBtnDisable" @click="restartXray">{{ i18n "pages.xray.restart" }}</a-button>
  81. <a-popover v-if="restartResult"
  82. :overlay-class-name="themeSwitcher.currentTheme">
  83. <span slot="title" style="font-size: 12pt">Error in running xray-core</span>
  84. <template slot="content">
  85. <p style="max-width: 400px" v-for="line in restartResult.split('\n')">[[ line ]]</p>
  86. </template>
  87. <a-icon type="question-circle"></a-icon>
  88. </a-popover>
  89. </a-space>
  90. </a-col>
  91. <a-col :xs="24" :sm="14">
  92. <template>
  93. <div>
  94. <a-back-top :target="() => document.getElementById('content-layout')" visibility-height="200"></a-back-top>
  95. <a-alert type="warning" style="float: right; width: fit-content" message='{{ i18n "pages.settings.infoDesc" }}' show-icon>
  96. </a-alert>
  97. </div>
  98. </template>
  99. </a-col>
  100. </a-row>
  101. </a-card>
  102. <a-tabs class="ant-card-dark-box-nohover" default-active-key="1"
  103. @change="(activeKey) => { this.changePage(activeKey); }"
  104. :class="themeSwitcher.currentTheme">
  105. <a-tab-pane key="tpl-basic" tab='{{ i18n "pages.xray.basicTemplate"}}' style="padding-top: 20px;">
  106. <a-collapse>
  107. <a-collapse-panel header='{{ i18n "pages.xray.generalConfigs"}}'>
  108. <a-row :xs="24" :sm="24" :lg="12">
  109. <a-alert type="warning" style="text-align: center;">
  110. <template slot="message">
  111. <a-icon type="exclamation-circle" theme="filled" style="color: #FFA031"></a-icon>
  112. {{ i18n "pages.xray.generalConfigsDesc" }}
  113. </template>
  114. </a-alert>
  115. </a-row>
  116. <a-list-item>
  117. <a-row style="padding: 10px 20px">
  118. <a-col :lg="24" :xl="12">
  119. <a-list-item-meta title='{{ i18n "pages.xray.FreedomStrategy" }}'
  120. description='{{ i18n "pages.xray.FreedomStrategyDesc" }}'>
  121. </a-list-item-meta>
  122. </a-col>
  123. <a-col :lg="24" :xl="12">
  124. <template>
  125. <a-select v-model="freedomStrategy" :dropdown-class-name="themeSwitcher.currentTheme"
  126. style="width: 100%">
  127. <a-select-option v-for="s in OutboundDomainStrategies" :value="s">[[ s ]]</a-select-option>
  128. </a-select>
  129. </template>
  130. </a-col>
  131. </a-row>
  132. <a-row style="padding: 10px 20px">
  133. <a-col :lg="24" :xl="12">
  134. <a-list-item-meta title='{{ i18n "pages.xray.RoutingStrategy" }}'
  135. description='{{ i18n "pages.xray.RoutingStrategyDesc" }}'>
  136. </a-list-item-meta>
  137. </a-col>
  138. <a-col :lg="24" :xl="12">
  139. <a-select v-model="routingStrategy" :dropdown-class-name="themeSwitcher.currentTheme"
  140. style="width: 100%">
  141. <a-select-option v-for="s in routingDomainStrategies" :value="s">[[ s ]]</a-select-option>
  142. </a-select>
  143. </a-col>
  144. </a-row>
  145. </a-list-item>
  146. </a-collapse-panel>
  147. <a-collapse-panel header='{{ i18n "pages.xray.logConfigs" }}'>
  148. <a-row :xs="24" :sm="24" :lg="12">
  149. <a-alert type="warning" style="text-align: center;">
  150. <template slot="message">
  151. <a-icon type="exclamation-circle" theme="filled" style="color: #FFA031"></a-icon>
  152. {{ i18n "pages.xray.logConfigsDesc" }}
  153. </template>
  154. </a-alert>
  155. </a-row>
  156. <a-list-item>
  157. <a-row style="padding: 10px 20px">
  158. <a-col :lg="24" :xl="12">
  159. <a-list-item-meta title='{{ i18n "pages.xray.logLevel" }}'
  160. description='{{ i18n "pages.xray.logLevelDesc" }}'>
  161. </a-list-item-meta>
  162. </a-col>
  163. <a-col :lg="24" :xl="12">
  164. <template>
  165. <a-select v-model="logLevel" :dropdown-class-name="themeSwitcher.currentTheme" style="width: 100%">
  166. <a-select-option v-for="s in log.loglevel" :value="s">[[ s ]]</a-select-option>
  167. </a-select>
  168. </template>
  169. </a-col>
  170. </a-row>
  171. <a-row style="padding: 10px 20px">
  172. <a-col :lg="24" :xl="12">
  173. <a-list-item-meta title='{{ i18n "pages.xray.accessLog" }}'
  174. description='{{ i18n "pages.xray.accessLogDesc" }}'>
  175. </a-list-item-meta>
  176. </a-col>
  177. <a-col :lg="24" :xl="12">
  178. <template>
  179. <a-select v-model="accessLog" :dropdown-class-name="themeSwitcher.currentTheme" style="width: 100%">
  180. <a-select-option value=''>Empty</a-select-option>
  181. <a-select-option v-for="s in log.access" :value="s">[[ s ]]</a-select-option>
  182. </a-select>
  183. </template>
  184. </a-col>
  185. </a-row>
  186. <a-row style="padding: 10px 20px">
  187. <a-col :lg="24" :xl="12">
  188. <a-list-item-meta title='{{ i18n "pages.xray.errorLog" }}'
  189. description='{{ i18n "pages.xray.errorLogDesc" }}'>
  190. </a-list-item-meta>
  191. </a-col>
  192. <a-col :lg="24" :xl="12">
  193. <template>
  194. <a-select v-model="errorLog" :dropdown-class-name="themeSwitcher.currentTheme" style="width: 100%">
  195. <a-select-option value=''>Empty</a-select-option>
  196. <a-select-option v-for="s in log.error" :value="s">[[ s ]]</a-select-option>
  197. </a-select>
  198. </template>
  199. </a-col>
  200. </a-row>
  201. <a-row style="padding: 10px 20px">
  202. <a-col :lg="24" :xl="12">
  203. <a-list-item-meta title='{{ i18n "pages.xray.maskAddress" }}'
  204. description='{{ i18n "pages.xray.maskAddressDesc" }}'>
  205. </a-list-item-meta>
  206. </a-col>
  207. <a-col :lg="24" :xl="12">
  208. <template>
  209. <a-select v-model="maskAddressLog" :dropdown-class-name="themeSwitcher.currentTheme" style="width: 100%">
  210. <a-select-option value=''>Empty</a-select-option>
  211. <a-select-option v-for="s in log.maskAddress" :value="s">[[ s ]]</a-select-option>
  212. </a-select>
  213. </template>
  214. </a-col>
  215. </a-row>
  216. <setting-list-item type="switch" title='{{ i18n "pages.xray.dnsLog"}}' desc='{{ i18n "pages.xray.dnsLogDesc"}}' v-model="dnslog"></setting-list-item>
  217. </a-list-item>
  218. </a-collapse-panel>
  219. <a-collapse-panel header='{{ i18n "pages.xray.blockConfigs"}}'>
  220. <a-row :xs="24" :sm="24" :lg="12">
  221. <a-alert type="warning" style="text-align: center;">
  222. <template slot="message">
  223. <a-icon type="exclamation-circle" theme="filled" style="color: #FFA031"></a-icon>
  224. {{ i18n "pages.xray.blockConfigsDesc" }}
  225. </template>
  226. </a-alert>
  227. </a-row>
  228. <a-list-item>
  229. <setting-list-item type="switch" title='{{ i18n "pages.xray.Torrent"}}' desc='{{ i18n "pages.xray.TorrentDesc"}}' v-model="torrentSettings"></setting-list-item>
  230. <setting-list-item type="switch" title='{{ i18n "pages.xray.Family"}}' desc='{{ i18n "pages.xray.FamilyDesc"}}' v-model="familyProtectSettings"></setting-list-item>
  231. </a-list-item>
  232. <a-list-item>
  233. <a-row style="padding: 0 20px">
  234. <a-col :lg="24" :xl="12">
  235. <a-list-item-meta
  236. title='{{ i18n "pages.xray.blockdomains" }}'/>
  237. </a-col>
  238. <a-col :lg="24" :xl="12">
  239. <template>
  240. <a-select mode="tags" style="width: 100%"
  241. v-model="blockedDomains"
  242. :dropdown-class-name="themeSwitcher.currentTheme">
  243. <a-select-option :value="p.value" :label="p.label"
  244. v-for="p in settingsData.ProtectionOptions"> [[ p.label ]]
  245. </a-select-option>
  246. </a-select>
  247. </template>
  248. </a-col>
  249. </a-row>
  250. </a-list-item>
  251. </a-collapse-panel>
  252. <a-collapse-panel header='{{ i18n "pages.xray.basicRouting"}}'>
  253. <a-row :xs="24" :sm="24" :lg="12">
  254. <a-alert type="warning" style="text-align: center;">
  255. <template slot="message">
  256. <a-icon type="exclamation-circle" theme="filled" style="color: #FFA031"></a-icon>
  257. {{ i18n "pages.xray.blockConnectionsConfigsDesc" }}
  258. </template>
  259. </a-alert>
  260. </a-row>
  261. <a-list-item>
  262. <a-row style="padding: 0 20px">
  263. <a-col :lg="24" :xl="12">
  264. <a-list-item-meta
  265. title='{{ i18n "pages.xray.blockips" }}'/>
  266. </a-col>
  267. <a-col :lg="24" :xl="12">
  268. <template>
  269. <a-select mode="tags" v-model="blockedIPs" style="width: 100%"
  270. :dropdown-class-name="themeSwitcher.currentTheme">
  271. <a-select-option :value="p.value" :label="p.label"
  272. v-for="p in settingsData.IPsOptions"> [[ p.label ]]
  273. </a-select-option>
  274. </a-select>
  275. </template>
  276. </a-col>
  277. </a-row>
  278. </a-list-item>
  279. <a-list-item>
  280. <a-row style="padding: 0 20px">
  281. <a-col :lg="24" :xl="12">
  282. <a-list-item-meta
  283. title='{{ i18n "pages.xray.blockdomains" }}'/>
  284. </a-col>
  285. <a-col :lg="24" :xl="12">
  286. <template>
  287. <a-select mode="tags" style="width: 100%"
  288. v-model="blockedDomains"
  289. :dropdown-class-name="themeSwitcher.currentTheme">
  290. <a-select-option :value="p.value" :label="p.label"
  291. v-for="p in settingsData.DomainsOptions"> [[ p.label ]]
  292. </a-select-option>
  293. </a-select>
  294. </template>
  295. </a-col>
  296. </a-row>
  297. </a-list-item>
  298. <a-row :xs="24" :sm="24" :lg="12">
  299. <a-alert type="warning" style="text-align: center; margin-top: 20px;">
  300. <template slot="message">
  301. <a-icon type="exclamation-circle" theme="filled" style="color: #FFA031"></a-icon>
  302. {{ i18n "pages.xray.directConnectionsConfigsDesc" }}
  303. </template>
  304. </a-alert>
  305. </a-row>
  306. <a-list-item>
  307. <a-row style="padding: 0 20px">
  308. <a-col :lg="24" :xl="12">
  309. <a-list-item-meta
  310. title='{{ i18n "pages.xray.directips" }}'/>
  311. </a-col>
  312. <a-col :lg="24" :xl="12">
  313. <template>
  314. <a-select mode="tags" style="width: 100%"
  315. v-model="directIPs"
  316. :dropdown-class-name="themeSwitcher.currentTheme">
  317. <a-select-option :value="p.value" :label="p.label"
  318. v-for="p in settingsData.IPsOptions"> [[ p.label ]]
  319. </a-select-option>
  320. </a-select>
  321. </template>
  322. </a-col>
  323. </a-row>
  324. </a-list-item>
  325. <a-list-item>
  326. <a-row style="padding: 0 20px">
  327. <a-col :lg="24" :xl="12">
  328. <a-list-item-meta
  329. title='{{ i18n "pages.xray.directdomains" }}'/>
  330. </a-col>
  331. <a-col :lg="24" :xl="12">
  332. <template>
  333. <a-select mode="tags" style="width: 100%"
  334. v-model="directDomains"
  335. :dropdown-class-name="themeSwitcher.currentTheme">
  336. <a-select-option :value="p.value" :label="p.label"
  337. v-for="p in settingsData.DomainsOptions"> [[ p.label ]]
  338. </a-select-option>
  339. </a-select>
  340. </template>
  341. </a-col>
  342. </a-row>
  343. </a-list-item>
  344. <a-row :xs="24" :sm="24" :lg="12">
  345. <a-alert type="warning" style="text-align: center; margin-top: 20px;">
  346. <template slot="message">
  347. <a-icon type="exclamation-circle" theme="filled" style="color: #FFA031"></a-icon>
  348. {{ i18n "pages.xray.ipv4RoutingDesc" }}
  349. </template>
  350. </a-alert>
  351. </a-row>
  352. <a-list-item>
  353. <a-row style="padding: 0 20px">
  354. <a-col :lg="24" :xl="12">
  355. <a-list-item-meta
  356. title='{{ i18n "pages.xray.ipv4Routing" }}'/>
  357. </a-col>
  358. <a-col :lg="24" :xl="12">
  359. <template>
  360. <a-select mode="tags" style="width: 100%"
  361. v-model="ipv4Domains"
  362. :dropdown-class-name="themeSwitcher.currentTheme">
  363. <a-select-option :value="p.value" :label="p.label"
  364. v-for="p in settingsData.ServicesOptions"> [[ p.label ]]
  365. </a-select-option>
  366. </a-select>
  367. </template>
  368. </a-col>
  369. </a-row>
  370. </a-list-item>
  371. <a-row :xs="24" :sm="24" :lg="12">
  372. <a-alert type="warning" style="text-align: center; margin-top: 20px;">
  373. <template slot="message">
  374. <a-icon type="exclamation-circle" theme="filled" style="color: #FFA031"></a-icon>
  375. {{ i18n "pages.xray.warpRoutingDesc" }}
  376. </template>
  377. </a-alert>
  378. </a-row>
  379. <a-list-item>
  380. <template v-if="WarpExist">
  381. <a-list-item>
  382. <a-row style="padding: 0 20px">
  383. <a-col :lg="24" :xl="12">
  384. <a-list-item-meta
  385. title='{{ i18n "pages.xray.warpRouting" }}'/>
  386. </a-col>
  387. <a-col :lg="24" :xl="12">
  388. <template>
  389. <a-select mode="tags" style="width: 100%"
  390. v-model="warpDomains"
  391. :dropdown-class-name="themeSwitcher.currentTheme">
  392. <a-select-option :value="p.value" :label="p.label"
  393. v-for="p in settingsData.ServicesOptions"> [[ p.label ]]
  394. </a-select-option>
  395. </a-select>
  396. </template>
  397. </a-col>
  398. </a-row>
  399. </a-list-item>
  400. </template>
  401. <a-button style="margin-left: 20px;" v-else type="primary" icon="cloud" @click="showWarp()">WARP</a-button>
  402. </a-list-item>
  403. </a-collapse-panel>
  404. <a-collapse-panel header='{{ i18n "pages.settings.resetDefaultConfig"}}'>
  405. <a-space direction="horizontal" style="padding: 0 20px">
  406. <a-button type="danger" @click="resetXrayConfigToDefault">{{ i18n "pages.settings.resetDefaultConfig" }}</a-button>
  407. </a-space>
  408. </a-collapse-panel>
  409. </a-collapse>
  410. </a-tab-pane>
  411. <a-tab-pane key="tpl-routing" tab='{{ i18n "pages.xray.Routings"}}' style="padding-top: 20px;">
  412. <a-button type="primary" icon="plus" @click="addRule">{{ i18n "pages.xray.rules.add" }}</a-button>
  413. <a-table-sortable :columns="isMobile ? rulesMobileColumns : rulesColumns" bordered
  414. :row-key="r => r.key"
  415. :data-source="routingRuleData"
  416. :scroll="isMobile ? {} : { x: 1000 }"
  417. :pagination="false"
  418. :indent-size="0"
  419. :style="isMobile ? 'padding: 5px 0' : 'margin-top: 10px;'"
  420. v-on:onSort="replaceRule">
  421. <template slot="action" slot-scope="text, rule, index">
  422. <table-sort-trigger :item-index="index"></table-sort-trigger>
  423. <span class="ant-table-row-index"> [[ index+1 ]] </span>
  424. <a-dropdown :trigger="['click']">
  425. <a-icon @click="e => e.preventDefault()" type="more" style="font-size: 16px; text-decoration: bold;"></a-icon>
  426. <a-menu slot="overlay" :theme="themeSwitcher.currentTheme">
  427. <a-menu-item v-if="index>0" @click="replaceRule(index,0)">
  428. <a-icon type="vertical-align-top"></a-icon>
  429. {{ i18n "pages.xray.rules.first"}}
  430. </a-menu-item>
  431. <a-menu-item v-if="index>0" @click="replaceRule(index,index-1)">
  432. <a-icon type="arrow-up"></a-icon>
  433. {{ i18n "pages.xray.rules.up"}}
  434. </a-menu-item>
  435. <a-menu-item v-if="index<routingRuleData.length-1" @click="replaceRule(index,index+1)">
  436. <a-icon type="arrow-down"></a-icon>
  437. {{ i18n "pages.xray.rules.down"}}
  438. </a-menu-item>
  439. <a-menu-item v-if="index<routingRuleData.length-1" @click="replaceRule(index,routingRuleData.length-1)">
  440. <a-icon type="vertical-align-bottom"></a-icon>
  441. {{ i18n "pages.xray.rules.last"}}
  442. </a-menu-item>
  443. <a-menu-item @click="editRule(index)">
  444. <a-icon type="edit"></a-icon>
  445. {{ i18n "edit" }}
  446. </a-menu-item>
  447. <a-menu-item @click="deleteRule(index)">
  448. <span style="color: #FF4D4F">
  449. <a-icon type="delete"></a-icon> {{ i18n "delete"}}
  450. </span>
  451. </a-menu-item>
  452. </a-menu>
  453. </a-dropdown>
  454. </template>
  455. <template slot="inbound" slot-scope="text, rule, index">
  456. <a-popover :overlay-class-name="themeSwitcher.currentTheme">
  457. <template slot="content">
  458. <p v-if="rule.inboundTag">Inbound Tag: [[ rule.inboundTag ]]</p>
  459. <p v-if="rule.user">User email: [[ rule.user ]]</p>
  460. </template>
  461. [[ [rule.inboundTag,rule.user].join('\n') ]]
  462. </a-popover>
  463. </template>
  464. <template slot="outbound" slot-scope="text, rule, index">
  465. <a-popover :overlay-class-name="themeSwitcher.currentTheme">
  466. <template slot="content">
  467. <p v-if="rule.outboundTag">Outbound Tag: [[ rule.outboundTag ]]</p>
  468. </template>
  469. [[ rule.outboundTag ]]
  470. </a-popover>
  471. </template>
  472. <template slot="balancer" slot-scope="text, rule, index">
  473. <a-popover :overlay-class-name="themeSwitcher.currentTheme">
  474. <template slot="content">
  475. <p v-if="rule.balancerTag">Balancer Tag: [[ rule.balancerTag ]]</p>
  476. </template>
  477. [[ rule.balancerTag ]]
  478. </a-popover>
  479. </template>
  480. <template slot="info" slot-scope="text, rule, index">
  481. <a-popover placement="bottomRight"
  482. v-if="(rule.source+rule.sourcePort+rule.network+rule.protocol+rule.attrs+rule.ip+rule.domain+rule.port).length>0"
  483. :overlay-class-name="themeSwitcher.currentTheme" trigger="click">
  484. <template slot="content">
  485. <table cellpadding="2" style="max-width: 300px;">
  486. <tr v-if="rule.source">
  487. <td>Source</td>
  488. <td><a-tag color="blue" v-for="r in rule.source.split(',')">[[ r ]]</a-tag></td>
  489. </tr>
  490. <tr v-if="rule.sourcePort">
  491. <td>Source Port</td>
  492. <td><a-tag color="green" v-for="r in rule.sourcePort.split(',')">[[ r ]]</a-tag></td>
  493. </tr>
  494. <tr v-if="rule.network">
  495. <td>Network</td>
  496. <td><a-tag color="blue" v-for="r in rule.network.split(',')">[[ r ]]</a-tag></td>
  497. </tr>
  498. <tr v-if="rule.protocol">
  499. <td>Protocol</td>
  500. <td><a-tag color="green" v-for="r in rule.protocol.split(',')">[[ r ]]</a-tag></td>
  501. </tr>
  502. <tr v-if="rule.attrs">
  503. <td>Attrs</td>
  504. <td><a-tag color="blue" v-for="r in rule.attrs.split(',')">[[ r ]]</a-tag></td>
  505. </tr>
  506. <tr v-if="rule.ip">
  507. <td>IP</td>
  508. <td><a-tag color="green" v-for="r in rule.ip.split(',')">[[ r ]]</a-tag></td>
  509. </tr>
  510. <tr v-if="rule.domain">
  511. <td>Domain</td>
  512. <td><a-tag color="blue" v-for="r in rule.domain.split(',')">[[ r ]]</a-tag></td>
  513. </tr>
  514. <tr v-if="rule.port">
  515. <td>Port</td>
  516. <td><a-tag color="green" v-for="r in rule.port.split(',')">[[ r ]]</a-tag></td>
  517. </tr>
  518. <tr v-if="rule.balancerTag">
  519. <td>Balancer Tag</td>
  520. <td><a-tag color="blue">[[ rule.balancerTag ]]</a-tag></td>
  521. </tr>
  522. </table>
  523. </template>
  524. <a-button shape="round" size="small" style="font-size: 14px; padding: 0 10px;">
  525. <a-icon type="info"></a-icon>
  526. </a-button>
  527. </a-popover>
  528. </template>
  529. </a-table-sortable>
  530. </a-tab-pane>
  531. <a-tab-pane key="tpl-outbound" tab='{{ i18n "pages.xray.Outbounds"}}' style="padding-top: 20px;" force-render="true">
  532. <a-row>
  533. <a-col :xs="12" :sm="12" :lg="12">
  534. <a-button type="primary" icon="plus" @click="addOutbound()" style="margin-bottom: 10px;">
  535. {{ i18n "pages.xray.outbound.addOutbound" }}
  536. </a-button>
  537. <a-button type="primary" icon="cloud" @click="showWarp()" style="margin-bottom: 10px;">WARP</a-button>
  538. </a-col>
  539. <a-col :xs="12" :sm="12" :lg="12" style="text-align: right;">
  540. <a-icon type="sync" :spin="refreshing" @click="refreshOutboundTraffic()" style="margin: 0 5px;"></a-icon>
  541. <a-popconfirm placement="topRight" @confirm="resetOutboundTraffic(-1)"
  542. title='{{ i18n "pages.inbounds.resetTrafficContent"}}'
  543. :overlay-class-name="themeSwitcher.currentTheme"
  544. ok-text='{{ i18n "reset"}}'
  545. cancel-text='{{ i18n "cancel"}}'>
  546. <a-icon slot="icon" type="question-circle-o" :style="themeSwitcher.isDarkTheme ? 'color: #008771' : 'color: #008771'"></a-icon>
  547. <a-icon type="retweet" style="cursor: pointer;"></a-icon>
  548. </a-popconfirm>
  549. </a-col>
  550. </a-row>
  551. <a-table :columns="outboundColumns" bordered
  552. :row-key="r => r.key"
  553. :data-source="outboundData"
  554. :scroll="isMobile ? {} : { x: 800 }"
  555. :pagination="false"
  556. :indent-size="0"
  557. :style="isMobile ? 'padding: 5px 5px' : 'margin-right: 1px;'">
  558. <template slot="action" slot-scope="text, outbound, index">
  559. [[ index+1 ]]
  560. <a-dropdown :trigger="['click']">
  561. <a-icon @click="e => e.preventDefault()" type="more" style="font-size: 16px; text-decoration: bold;"></a-icon>
  562. <a-menu slot="overlay" :theme="themeSwitcher.currentTheme">
  563. <a-menu-item v-if="index>0" @click="setFirstOutbound(index)">
  564. <a-icon type="vertical-align-top"></a-icon>
  565. {{ i18n "pages.xray.rules.first"}}
  566. </a-menu-item>
  567. <a-menu-item @click="editOutbound(index)">
  568. <a-icon type="edit"></a-icon>
  569. {{ i18n "edit" }}
  570. </a-menu-item>
  571. <a-menu-item @click="resetOutboundTraffic(index)">
  572. <span>
  573. <a-icon type="retweet"></a-icon> {{ i18n "pages.inbounds.resetTraffic"}}
  574. </span>
  575. </a-menu-item>
  576. <a-menu-item @click="deleteOutbound(index)">
  577. <span style="color: #FF4D4F">
  578. <a-icon type="delete"></a-icon> {{ i18n "delete"}}
  579. </span>
  580. </a-menu-item>
  581. </a-menu>
  582. </a-dropdown>
  583. </template>
  584. <template slot="address" slot-scope="text, outbound, index">
  585. <p style="margin: 0 5px;" v-for="addr in findOutboundAddress(outbound)">[[ addr ]]</p>
  586. </template>
  587. <template slot="protocol" slot-scope="text, outbound, index">
  588. <a-tag style="margin:0;" color="purple">[[ outbound.protocol ]]</a-tag>
  589. <template v-if="[Protocols.VMess, Protocols.VLESS, Protocols.Trojan, Protocols.Shadowsocks].includes(outbound.protocol)">
  590. <a-tag style="margin:0;" color="blue">[[ outbound.streamSettings.network ]]</a-tag>
  591. <a-tag style="margin:0;" v-if="outbound.streamSettings.security=='tls'" color="green">tls</a-tag>
  592. <a-tag style="margin:0;" v-if="outbound.streamSettings.security=='reality'" color="green">reality</a-tag>
  593. </template>
  594. </template>
  595. <template slot="traffic" slot-scope="text, outbound, index">
  596. <a-tag color="green">[[ findOutboundTraffic(outbound) ]]</a-tag>
  597. </template>
  598. </a-table>
  599. </a-tab-pane>
  600. <a-tab-pane key="tpl-reverse" tab='{{ i18n "pages.xray.outbound.reverse"}}' style="padding-top: 20px;" force-render="true">
  601. <a-button type="primary" icon="plus" @click="addReverse()" style="margin-bottom: 10px;">
  602. {{ i18n "pages.xray.outbound.addReverse" }}
  603. </a-button>
  604. <a-table :columns="reverseColumns" bordered v-if="reverseData.length>0"
  605. :row-key="r => r.key"
  606. :data-source="reverseData"
  607. :scroll="isMobile ? {} : { x: 200 }"
  608. :pagination="false"
  609. :indent-size="0"
  610. :style="isMobile ? 'padding: 5px 0' : 'margin-left: 1px;'">
  611. <template slot="action" slot-scope="text, reverse, index">
  612. [[ index+1 ]]
  613. <a-dropdown :trigger="['click']">
  614. <a-icon @click="e => e.preventDefault()" type="more" style="font-size: 16px; text-decoration: bold;"></a-icon>
  615. <a-menu slot="overlay" :theme="themeSwitcher.currentTheme">
  616. <a-menu-item @click="editReverse(index)">
  617. <a-icon type="edit"></a-icon>
  618. {{ i18n "edit" }}
  619. </a-menu-item>
  620. <a-menu-item @click="deleteReverse(index)">
  621. <span style="color: #FF4D4F">
  622. <a-icon type="delete"></a-icon> {{ i18n "delete"}}
  623. </span>
  624. </a-menu-item>
  625. </a-menu>
  626. </a-dropdown>
  627. </template>
  628. </a-table>
  629. </a-tab-pane>
  630. <a-tab-pane key="tpl-balancer" tab='{{ i18n "pages.xray.Balancers"}}' style="padding-top: 20px;" force-render="true">
  631. <a-button type="primary" icon="plus" @click="addBalancer()" style="margin-bottom: 10px;">
  632. {{ i18n "pages.xray.balancer.addBalancer"}}
  633. </a-button>
  634. <a-table :columns="balancerColumns" bordered v-if="balancersData.length>0"
  635. :row-key="r => r.key"
  636. :data-source="balancersData"
  637. :scroll="isMobile ? {} : { x: 200 }"
  638. :pagination="false"
  639. :indent-size="0"
  640. :style="isMobile ? 'padding: 5px 0' : 'margin-left: 1px;'">
  641. <template slot="action" slot-scope="text, balancer, index">
  642. [[ index+1 ]]
  643. <a-dropdown :trigger="['click']">
  644. <a-icon @click="e => e.preventDefault()" type="more" style="font-size: 16px; text-decoration: bold;"></a-icon>
  645. <a-menu slot="overlay" :theme="themeSwitcher.currentTheme">
  646. <a-menu-item @click="editBalancer(index)">
  647. <a-icon type="edit"></a-icon>
  648. {{ i18n "edit" }}
  649. </a-menu-item>
  650. <a-menu-item @click="deleteBalancer(index)">
  651. <span style="color: #FF4D4F">
  652. <a-icon type="delete"></a-icon> {{ i18n "delete"}}
  653. </span>
  654. </a-menu-item>
  655. </a-menu>
  656. </a-dropdown>
  657. </template>
  658. <template slot="strategy" slot-scope="text, balancer, index">
  659. <a-tag style="margin:0;" v-if="balancer.strategy=='random'" color="purple">Random</a-tag>
  660. <a-tag style="margin:0;" v-if="balancer.strategy=='roundRobin'" color="green">Round Robin</a-tag>
  661. <a-tag style="margin:0;" v-if="balancer.strategy=='leastLoad'" color="green">Least Load</a-tag>
  662. <a-tag style="margin:0;" v-if="balancer.strategy=='leastPing'" color="green">Least Ping</a-tag>
  663. </template>
  664. <template slot="selector" slot-scope="text, balancer, index">
  665. <a-tag class="info-large-tag" style="margin:1;" v-for="sel in balancer.selector">[[ sel ]]</a-tag>
  666. </template>
  667. </a-table>
  668. <a-radio-group
  669. v-if="observatoryEnable || burstObservatoryEnable"
  670. v-model="obsSettings"
  671. @change="changeObsCode"
  672. button-style="solid"
  673. style="margin: 10px 0;"
  674. :size="isMobile ? 'small' : ''">
  675. <a-radio-button value="observatory" v-if="observatoryEnable">Observatory</a-radio-button>
  676. <a-radio-button value="burstObservatory" v-if="burstObservatoryEnable">Burst Observatory</a-radio-button>
  677. </a-radio-group>
  678. <textarea style="position:absolute; left: -800px;" id="obsSetting"></textarea>
  679. </a-tab-pane>
  680. <a-tab-pane key="tpl-dns" tab='DNS' style="padding-top: 20px;" force-render="true">
  681. <setting-list-item type="switch" title='{{ i18n "pages.xray.dns.enable" }}'
  682. desc='{{ i18n "pages.xray.dns.enableDesc" }}' v-model="enableDNS"></setting-list-item>
  683. <template v-if="enableDNS">
  684. <setting-list-item style="padding: 10px 20px" type="text" title='{{ i18n "pages.xray.dns.tag" }}'
  685. desc='{{ i18n "pages.xray.dns.tagDesc" }}' v-model="dnsTag"></setting-list-item>
  686. <a-list-item style="padding: 10px 20px">
  687. <a-row>
  688. <a-col :lg="24" :xl="12">
  689. <a-list-item-meta title='{{ i18n "pages.xray.dns.strategy" }}'
  690. description='{{ i18n "pages.xray.dns.strategyDesc" }}' />
  691. </a-col>
  692. <a-col :lg="24" :xl="12">
  693. <a-select v-model="dnsStrategy" style="width: 100%"
  694. :dropdown-class-name="themeSwitcher.currentTheme">
  695. <a-select-option :value="l" :label="l" v-for="l in ['UseIP', 'UseIPv4', 'UseIPv6']">
  696. [[ l ]]
  697. </a-select-option>
  698. </a-select>
  699. </a-col>
  700. </a-row>
  701. </a-list-item>
  702. <a-divider>DNS</a-divider>
  703. <a-button type="primary" icon="plus" @click="addDNSServer()" style="margin-bottom: 10px;">{{ i18n
  704. "pages.xray.dns.add" }}</a-button>
  705. <a-table :columns="dnsColumns" bordered v-if="dnsServers.length>0" :row-key="r => r.key"
  706. :data-source="dnsServers" :scroll="isMobile ? {} : { x: 200 }" :pagination="false" :indent-size="0"
  707. :style="isMobile ? 'padding: 5px 0' : 'margin-left: 1px;'">
  708. <template slot="action" slot-scope="text,dns,index">
  709. [[ index+1 ]]
  710. <a-dropdown :trigger="['click']">
  711. <a-icon @click="e => e.preventDefault()" type="more"
  712. style="font-size: 16px; text-decoration: bold;"></a-icon>
  713. <a-menu slot="overlay" :theme="themeSwitcher.currentTheme">
  714. <a-menu-item @click="editDNSServer(index)">
  715. <a-icon type="edit"></a-icon>
  716. {{ i18n "edit" }}
  717. </a-menu-item>
  718. <a-menu-item @click="deleteDNSServer(index)">
  719. <span style="color: #FF4D4F">
  720. <a-icon type="delete"></a-icon> {{ i18n "delete"}}
  721. </span>
  722. </a-menu-item>
  723. </a-menu>
  724. </a-dropdown>
  725. </template>
  726. <template slot="address" slot-scope="dns,index">
  727. <span v-if="typeof dns == 'object'">[[ dns.address ]]</span>
  728. <span v-else>[[ dns ]]</span>
  729. </template>
  730. <template slot="domain" slot-scope="dns,index">
  731. <span v-if="typeof dns == 'object'">[[ dns.domains.join(",") ]]</span>
  732. </template>
  733. <template slot="expectIPs" slot-scope="dns,index">
  734. <span v-if="typeof dns == 'object'">[[ dns.expectIPs.join(",") ]]</span>
  735. </template>
  736. </a-table>
  737. <a-divider>Fake DNS</a-divider>
  738. <a-button type="primary" icon="plus" @click="addFakedns()" style="margin-bottom: 10px;">{{ i18n
  739. "pages.xray.fakedns.add" }}</a-button>
  740. <a-table :columns="fakednsColumns" bordered v-if="fakeDns && fakeDns.length>0" :row-key="r => r.key"
  741. :data-source="fakeDns" :scroll="isMobile ? {} : { x: 200 }" :pagination="false" :indent-size="0"
  742. :style="isMobile ? 'padding: 5px 0' : 'margin-left: 1px;'">
  743. <template slot="action" slot-scope="text,fakedns,index">
  744. [[ index+1 ]]
  745. <a-dropdown :trigger="['click']">
  746. <a-icon @click="e => e.preventDefault()" type="more"
  747. style="font-size: 16px; text-decoration: bold;"></a-icon>
  748. <a-menu slot="overlay" :theme="themeSwitcher.currentTheme">
  749. <a-menu-item @click="editFakedns(index)">
  750. <a-icon type="edit"></a-icon>
  751. {{ i18n "edit" }}
  752. </a-menu-item>
  753. <a-menu-item @click="deleteFakedns(index)">
  754. <span style="color: #FF4D4F">
  755. <a-icon type="delete"></a-icon> {{ i18n "delete"}}
  756. </span>
  757. </a-menu-item>
  758. </a-menu>
  759. </a-dropdown>
  760. </template>
  761. </a-table>
  762. </template>
  763. </a-tab-pane>
  764. <a-tab-pane key="tpl-advanced" tab='{{ i18n "pages.xray.advancedTemplate"}}' style="padding-top: 20px;" force-render="true">
  765. <a-list-item-meta title='{{ i18n "pages.xray.Template"}}' description='{{ i18n "pages.xray.TemplateDesc"}}'></a-list-item-meta>
  766. <a-radio-group v-model="advSettings" @change="changeCode" button-style="solid" style="margin: 10px 0;" :size="isMobile ? 'small' : ''">
  767. <a-radio-button value="xraySetting">{{ i18n "pages.xray.completeTemplate"}}</a-radio-button>
  768. <a-radio-button value="inboundSettings">{{ i18n "pages.xray.Inbounds" }}</a-radio-button>
  769. <a-radio-button value="outboundSettings">{{ i18n "pages.xray.Outbounds" }}</a-radio-button>
  770. <a-radio-button value="routingRuleSettings">{{ i18n "pages.xray.Routings" }}</a-radio-button>
  771. </a-radio-group>
  772. <textarea style="position:absolute; left: -800px;" id="xraySetting"></textarea>
  773. </a-tab-pane>
  774. </a-tabs>
  775. </a-space>
  776. </a-spin>
  777. </a-layout-content>
  778. </a-layout>
  779. </a-layout>
  780. {{template "js" .}}
  781. {{template "component/themeSwitcher" .}}
  782. {{template "component/sortableTable" .}}
  783. {{template "component/setting"}}
  784. {{template "ruleModal"}}
  785. {{template "outModal"}}
  786. {{template "reverseModal"}}
  787. {{template "balancerModal"}}
  788. {{template "dnsModal"}}
  789. {{template "fakednsModal"}}
  790. {{template "warpModal"}}
  791. <script>
  792. const rulesColumns = [
  793. { title: "#", align: 'center', width: 15, scopedSlots: { customRender: 'action' } },
  794. { title: '{{ i18n "pages.xray.rules.source"}}', children: [
  795. { title: 'IP', dataIndex: "source", align: 'center', width: 20, ellipsis: true },
  796. { title: 'Port', dataIndex: 'sourcePort', align: 'center', width: 10, ellipsis: true } ]},
  797. { title: '{{ i18n "pages.inbounds.network"}}', children: [
  798. { title: 'L4', dataIndex: 'network', align: 'center', width: 10 },
  799. { title: 'Protocol', dataIndex: 'protocol', align: 'center', width: 10, ellipsis: true },
  800. { title: 'Attrs', dataIndex: 'attrs', align: 'center', width: 20, ellipsis: true } ]},
  801. { title: '{{ i18n "pages.xray.rules.dest"}}', children: [
  802. { title: 'IP', dataIndex: 'ip', align: 'center', width: 20, ellipsis: true },
  803. { title: 'Domain', dataIndex: 'domain', align: 'center', width: 20, ellipsis: true },
  804. { title: 'Port', dataIndex: 'port', align: 'center', width: 10, ellipsis: true }]},
  805. { title: '{{ i18n "pages.xray.rules.inbound"}}', children: [
  806. { title: 'Inbound Tag', dataIndex: 'inboundTag', align: 'center', width: 15, ellipsis: true },
  807. { title: 'Client Email', dataIndex: 'user', align: 'center', width: 20, ellipsis: true }]},
  808. { title: '{{ i18n "pages.xray.rules.outbound"}}', dataIndex: 'outboundTag', align: 'center', width: 15 },
  809. { title: '{{ i18n "pages.xray.rules.balancer"}}', dataIndex: 'balancerTag', align: 'center', width: 15 },
  810. ];
  811. const rulesMobileColumns = [
  812. { title: "#", align: 'center', width: 20, scopedSlots: { customRender: 'action' } },
  813. { title: '{{ i18n "pages.xray.rules.inbound"}}', align: 'center', width: 50, ellipsis: true, scopedSlots: { customRender: 'inbound' } },
  814. { title: '{{ i18n "pages.xray.rules.outbound"}}', align: 'center', width: 50, ellipsis: true, scopedSlots: { customRender: 'outbound' } },
  815. { title: '{{ i18n "pages.xray.rules.info"}}', align: 'center', width: 50, ellipsis: true, scopedSlots: { customRender: 'info' } },
  816. ];
  817. const outboundColumns = [
  818. { title: "#", align: 'center', width: 20, scopedSlots: { customRender: 'action' } },
  819. { title: '{{ i18n "pages.xray.outbound.tag"}}', dataIndex: 'tag', align: 'center', width: 50 },
  820. { title: '{{ i18n "protocol"}}', align: 'center', width: 50, scopedSlots: { customRender: 'protocol' } },
  821. { title: '{{ i18n "pages.xray.outbound.address"}}', align: 'center', width: 50, scopedSlots: { customRender: 'address' } },
  822. { title: '{{ i18n "pages.inbounds.traffic" }}', align: 'center', width: 50, scopedSlots: { customRender: 'traffic' } },
  823. ];
  824. const reverseColumns = [
  825. { title: "#", align: 'center', width: 20, scopedSlots: { customRender: 'action' } },
  826. { title: '{{ i18n "pages.xray.outbound.type"}}', dataIndex: 'type', align: 'center', width: 50 },
  827. { title: '{{ i18n "pages.xray.outbound.tag"}}', dataIndex: 'tag', align: 'center', width: 50 },
  828. { title: '{{ i18n "pages.xray.outbound.domain"}}', dataIndex: 'domain', align: 'center', width: 50 },
  829. ];
  830. const balancerColumns = [
  831. { title: "#", align: 'center', width: 20, scopedSlots: { customRender: 'action' } },
  832. { title: '{{ i18n "pages.xray.balancer.tag"}}', dataIndex: 'tag', align: 'center', width: 50 },
  833. { title: '{{ i18n "pages.xray.balancer.balancerStrategy"}}', align: 'center', width: 50, scopedSlots: { customRender: 'strategy' }},
  834. { title: '{{ i18n "pages.xray.balancer.balancerSelectors"}}', align: 'center', width: 100, scopedSlots: { customRender: 'selector' }},
  835. ];
  836. const dnsColumns = [
  837. { title: "#", align: 'center', width: 20, scopedSlots: { customRender: 'action' } },
  838. { title: '{{ i18n "pages.xray.outbound.address"}}', align: 'center', width: 50, scopedSlots: { customRender: 'address' } },
  839. { title: '{{ i18n "pages.xray.dns.domains"}}', align: 'center', width: 50, scopedSlots: { customRender: 'domain' } },
  840. { title: '{{ i18n "pages.xray.dns.expectIPs"}}', align: 'center', width: 50, scopedSlots: { customRender: 'expectIPs' } },
  841. ];
  842. const fakednsColumns = [
  843. { title: "#", align: 'center', width: 20, scopedSlots: { customRender: 'action' } },
  844. { title: '{{ i18n "pages.xray.fakedns.ipPool"}}', dataIndex: 'ipPool', align: 'center', width: 50 },
  845. { title: '{{ i18n "pages.xray.fakedns.poolSize"}}', dataIndex: 'poolSize', align: 'center', width: 50 },
  846. ];
  847. const app = new Vue({
  848. delimiters: ['[[', ']]'],
  849. el: '#app',
  850. data: {
  851. siderDrawer,
  852. themeSwitcher,
  853. isDarkTheme: themeSwitcher.isDarkTheme,
  854. spinning: false,
  855. oldXraySetting: '',
  856. xraySetting: '',
  857. inboundTags: [],
  858. outboundsTraffic: [],
  859. saveBtnDisable: true,
  860. refreshing: false,
  861. restartResult: '',
  862. showAlert: false,
  863. isMobile: window.innerWidth <= 768,
  864. advSettings: 'xraySetting',
  865. obsSettings: '',
  866. cm: null,
  867. cmOptions: {
  868. lineNumbers: true,
  869. mode: "application/json",
  870. lint: true,
  871. styleActiveLine: true,
  872. matchBrackets: true,
  873. theme: "xq",
  874. autoCloseTags: true,
  875. lineWrapping: true,
  876. indentUnit: 2,
  877. indentWithTabs: true,
  878. smartIndent: true,
  879. tabSize: 2,
  880. lineWiseCopyCut: false,
  881. foldGutter: true,
  882. gutters: [
  883. "CodeMirror-lint-markers",
  884. "CodeMirror-linenumbers",
  885. "CodeMirror-foldgutter",
  886. ],
  887. },
  888. ipv4Settings: {
  889. tag: "IPv4",
  890. protocol: "freedom",
  891. settings: {
  892. domainStrategy: "UseIPv4"
  893. }
  894. },
  895. directSettings: {
  896. tag: "direct",
  897. protocol: "freedom"
  898. },
  899. routingDomainStrategies: ["AsIs", "IPIfNonMatch", "IPOnDemand"],
  900. log: {
  901. loglevel: ["none", "debug", "info", "warning", "error"],
  902. access: ["none", "./access.log"],
  903. error: ["none", "./error.log"],
  904. dnsLog: false,
  905. maskAddress: ["quarter", "half", "full"],
  906. },
  907. settingsData: {
  908. protocols: {
  909. bittorrent: ["bittorrent"],
  910. },
  911. IPsOptions: [
  912. { label: 'Private IPs', value: 'geoip:private' },
  913. { label: '🇮🇷 Iran', value: 'ext:geoip_IR.dat:ir' },
  914. { label: '🇨🇳 China', value: 'geoip:cn' },
  915. { label: '🇷🇺 Russia', value: 'geoip:ru' },
  916. { label: '🇻🇳 Vietnam', value: 'ext:geoip_VN.dat:vn' },
  917. { label: '🇪🇸 Spain', value: 'geoip:es' },
  918. { label: '🇮🇩 Indonesia', value: 'geoip:id' },
  919. { label: '🇺🇦 Ukraine', value: 'geoip:ua' },
  920. { label: '🇹🇷 Türkiye', value: 'geoip:tr' },
  921. { label: '🇧🇷 Brazil', value: 'geoip:br' },
  922. ],
  923. DomainsOptions: [
  924. { label: '🇮🇷 Iran', value: 'ext:geosite_IR.dat:ir' },
  925. { label: '🇮🇷 .ir', value: 'regexp:.*\\.ir$' },
  926. { label: '🇮🇷 .ایران', value: 'regexp:.*\\.xn--mgba3a4f16a$' },
  927. { label: '🇨🇳 China', value: 'geosite:cn' },
  928. { label: '🇨🇳 .cn', value: 'regexp:.*\\.cn$' },
  929. { label: '🇷🇺 Russia', value: 'geosite:category-ru' },
  930. { label: '🇷🇺 .ru', value: 'regexp:.*\\.ru' },
  931. { label: '🇻🇳 Vietnam', value: 'ext:geosite_VN.dat:vn' },
  932. { label: '🇻🇳 .vn', value: 'regexp:.*\\.vn$' },
  933. ],
  934. ProtectionOptions: [
  935. { label: 'Ads All', value: 'geosite:category-ads-all' },
  936. { label: 'Ads IR 🇮🇷', value: 'ext:geosite_IR.dat:category-ads-all' },
  937. { label: 'Ads VN 🇻🇳', value: 'ext:geosite_VN.dat:ads' },
  938. { label: 'Malware 🇮🇷', value: 'geosite_IR.dat:malware' },
  939. { label: 'Phishing 🇮🇷', value: 'geosite_IR.dat:phishing' },
  940. { label: 'Cryptominers 🇮🇷', value: 'geosite_IR.dat:cryptominers' },
  941. ],
  942. ServicesOptions: [
  943. { label: 'Apple', value: 'geosite:apple' },
  944. { label: 'Meta', value: 'geosite:meta' },
  945. { label: 'Google', value: 'geosite:google' },
  946. { label: 'OpenAI', value: 'geosite:openai' },
  947. { label: 'Spotify', value: 'geosite:spotify' },
  948. { label: 'Netflix', value: 'geosite:netflix' },
  949. { label: 'Reddit', value: 'geosite:reddit' },
  950. { label: 'Speedtest', value: 'geosite:speedtest' },
  951. ],
  952. familyProtectDNS: {
  953. "servers": [
  954. "1.1.1.3", // https://developers.cloudflare.com/1.1.1.1/setup/
  955. "1.0.0.3",
  956. "2606:4700:4700::1113",
  957. "2606:4700:4700::1003"
  958. ],
  959. "queryStrategy": "UseIP"
  960. },
  961. },
  962. defaultObservatory: {
  963. subjectSelector: [],
  964. probeURL: "http://www.google.com/gen_204",
  965. probeInterval: "10m",
  966. enableConcurrency: true
  967. },
  968. defaultBurstObservatory: {
  969. subjectSelector: [],
  970. pingConfig: {
  971. destination: "http://www.google.com/gen_204",
  972. interval: "30m",
  973. connectivity: "http://connectivitycheck.platform.hicloud.com/generate_204",
  974. timeout: "10s",
  975. sampling: 2
  976. }
  977. }
  978. },
  979. methods: {
  980. loading(spinning = true) {
  981. this.spinning = spinning;
  982. },
  983. async getOutboundsTraffic() {
  984. const msg = await HttpUtil.get("/panel/xray/getOutboundsTraffic");
  985. if (msg.success) {
  986. this.outboundsTraffic = msg.obj;
  987. }
  988. },
  989. async getXraySetting() {
  990. this.loading(true);
  991. const msg = await HttpUtil.post("/panel/xray/");
  992. this.loading(false);
  993. if (msg.success) {
  994. result = JSON.parse(msg.obj);
  995. xs = JSON.stringify(result.xraySetting, null, 2);
  996. this.oldXraySetting = xs;
  997. this.xraySetting = xs;
  998. this.inboundTags = result.inboundTags;
  999. this.saveBtnDisable = true;
  1000. }
  1001. },
  1002. async updateXraySetting() {
  1003. this.loading(true);
  1004. const msg = await HttpUtil.post("/panel/xray/update", {xraySetting : this.xraySetting});
  1005. this.loading(false);
  1006. if (msg.success) {
  1007. await this.getXraySetting();
  1008. }
  1009. },
  1010. async restartXray() {
  1011. this.loading(true);
  1012. const msg = await HttpUtil.post("server/restartXrayService");
  1013. this.loading(false);
  1014. if (msg.success) {
  1015. await PromiseUtil.sleep(500);
  1016. await this.getXrayResult();
  1017. }
  1018. this.loading(false);
  1019. },
  1020. async getXrayResult() {
  1021. const msg = await HttpUtil.get("/panel/xray/getXrayResult");
  1022. if (msg.success) {
  1023. this.restartResult=msg.obj;
  1024. if(msg.obj.length > 1) Vue.prototype.$message.error(msg.obj);
  1025. }
  1026. },
  1027. async fetchUserSecret() {
  1028. this.loading(true);
  1029. const userMessage = await HttpUtil.post("/panel/setting/getUserSecret", this.user);
  1030. if (userMessage.success) {
  1031. this.user = userMessage.obj;
  1032. }
  1033. this.loading(false);
  1034. },
  1035. async updateSecret() {
  1036. this.loading(true);
  1037. const msg = await HttpUtil.post("/panel/setting/updateUserSecret", this.user);
  1038. if (msg.success) {
  1039. this.user = msg.obj;
  1040. window.location.replace(basePath + "logout");
  1041. }
  1042. this.loading(false);
  1043. await this.updateXraySetting();
  1044. },
  1045. generateRandomString(length) {
  1046. var chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
  1047. let randomString = "";
  1048. for (let i = 0; i < length; i++) {
  1049. randomString += chars[Math.floor(Math.random() * chars.length)];
  1050. }
  1051. return randomString;
  1052. },
  1053. async getNewSecret() {
  1054. this.loading(true);
  1055. await PromiseUtil.sleep(600);
  1056. const newSecret = this.generateRandomString(64);
  1057. this.user.loginSecret = newSecret;
  1058. document.getElementById("token").textContent = newSecret;
  1059. this.loading(false);
  1060. },
  1061. async toggleToken(value) {
  1062. if (value) {
  1063. await this.getNewSecret();
  1064. } else {
  1065. this.user.loginSecret = "";
  1066. }
  1067. },
  1068. async resetXrayConfigToDefault() {
  1069. this.loading(true);
  1070. const msg = await HttpUtil.get("/panel/setting/getDefaultJsonConfig");
  1071. this.loading(false);
  1072. if (msg.success) {
  1073. this.templateSettings = JSON.parse(JSON.stringify(msg.obj, null, 2));
  1074. this.saveBtnDisable = true;
  1075. }
  1076. },
  1077. changePage(pageKey) {
  1078. if(pageKey == 'tpl-advanced') this.changeCode();
  1079. if(pageKey == 'tpl-balancer') this.changeObsCode();
  1080. },
  1081. syncRulesWithOutbound(tag, setting) {
  1082. const newTemplateSettings = this.templateSettings;
  1083. const haveRules = newTemplateSettings.routing.rules.some((r) => r?.outboundTag === tag);
  1084. const outboundIndex = newTemplateSettings.outbounds.findIndex((o) => o.tag === tag);
  1085. if (!haveRules && outboundIndex > 0) {
  1086. newTemplateSettings.outbounds.splice(outboundIndex);
  1087. }
  1088. if (haveRules && outboundIndex < 0) {
  1089. newTemplateSettings.outbounds.push(setting);
  1090. }
  1091. this.templateSettings = newTemplateSettings;
  1092. },
  1093. templateRuleGetter(routeSettings) {
  1094. const { property, outboundTag } = routeSettings;
  1095. let result = [];
  1096. if (this.templateSettings != null) {
  1097. this.templateSettings.routing.rules.forEach(
  1098. (routingRule) => {
  1099. if (
  1100. routingRule.hasOwnProperty(property) &&
  1101. routingRule.hasOwnProperty("outboundTag") &&
  1102. routingRule.outboundTag === outboundTag
  1103. ) {
  1104. result.push(...routingRule[property]);
  1105. }
  1106. }
  1107. );
  1108. }
  1109. return result;
  1110. },
  1111. templateRuleSetter(routeSettings) {
  1112. const { data, property, outboundTag } = routeSettings;
  1113. const oldTemplateSettings = this.templateSettings;
  1114. const newTemplateSettings = oldTemplateSettings;
  1115. currentProperty = this.templateRuleGetter({ outboundTag, property })
  1116. if (currentProperty.length == 0) {
  1117. const propertyRule = {
  1118. type: "field",
  1119. outboundTag,
  1120. [property]: data
  1121. };
  1122. newTemplateSettings.routing.rules.push(propertyRule);
  1123. }
  1124. else {
  1125. const newRules = [];
  1126. insertedOnce = false;
  1127. newTemplateSettings.routing.rules.forEach(
  1128. (routingRule) => {
  1129. if (
  1130. routingRule.hasOwnProperty(property) &&
  1131. routingRule.hasOwnProperty("outboundTag") &&
  1132. routingRule.outboundTag === outboundTag
  1133. ) {
  1134. if (!insertedOnce && data.length > 0) {
  1135. insertedOnce = true;
  1136. routingRule[property] = data;
  1137. newRules.push(routingRule);
  1138. }
  1139. }
  1140. else {
  1141. newRules.push(routingRule);
  1142. }
  1143. }
  1144. );
  1145. newTemplateSettings.routing.rules = newRules;
  1146. }
  1147. this.templateSettings = newTemplateSettings;
  1148. },
  1149. changeCode() {
  1150. if(this.cm != null) {
  1151. this.cm.toTextArea();
  1152. }
  1153. textAreaObj = document.getElementById('xraySetting');
  1154. textAreaObj.value = this[this.advSettings];
  1155. this.cm = CodeMirror.fromTextArea(textAreaObj, this.cmOptions);
  1156. this.cm.on('change',editor => {
  1157. value = editor.getValue();
  1158. if (this.isJsonString(value)) {
  1159. this[this.advSettings] = value;
  1160. }
  1161. });
  1162. },
  1163. changeObsCode() {
  1164. if(this.cm != null) {
  1165. this.cm.toTextArea();
  1166. }
  1167. if (this.obsSettings == ''){
  1168. this.cm = null;
  1169. return
  1170. }
  1171. textAreaObj = document.getElementById('obsSetting');
  1172. textAreaObj.value = this[this.obsSettings];
  1173. this.cm = CodeMirror.fromTextArea(textAreaObj, this.cmOptions);
  1174. this.cm.on('change',editor => {
  1175. value = editor.getValue();
  1176. if(this.isJsonString(value)){
  1177. this[this.obsSettings] = value;
  1178. }
  1179. });
  1180. },
  1181. isJsonString(str) {
  1182. try {
  1183. JSON.parse(str);
  1184. } catch (e) {
  1185. return false;
  1186. }
  1187. return true;
  1188. },
  1189. findOutboundTraffic(o) {
  1190. for (const otraffic of this.outboundsTraffic) {
  1191. if (otraffic.tag == o.tag) {
  1192. return sizeFormat(otraffic.up) + ' / ' + sizeFormat(otraffic.down);
  1193. }
  1194. }
  1195. return sizeFormat(0) + ' / ' + sizeFormat(0);
  1196. },
  1197. findOutboundAddress(o) {
  1198. serverObj = null;
  1199. switch(o.protocol){
  1200. case Protocols.VMess:
  1201. case Protocols.VLESS:
  1202. serverObj = o.settings.vnext;
  1203. break;
  1204. case Protocols.HTTP:
  1205. case Protocols.Socks:
  1206. case Protocols.Shadowsocks:
  1207. case Protocols.Trojan:
  1208. serverObj = o.settings.servers;
  1209. break;
  1210. case Protocols.DNS:
  1211. return [o.settings?.address + ':' + o.settings?.port];
  1212. case Protocols.Wireguard:
  1213. return o.settings.peers.map(peer => peer.endpoint);
  1214. default:
  1215. return null;
  1216. }
  1217. return serverObj ? serverObj.map(obj => obj.address + ':' + obj.port) : null;
  1218. },
  1219. addOutbound(){
  1220. outModal.show({
  1221. title: '{{ i18n "pages.xray.outbound.addOutbound"}}',
  1222. okText: '{{ i18n "pages.xray.outbound.addOutbound" }}',
  1223. confirm: (outbound) => {
  1224. outModal.loading();
  1225. if(outbound.tag.length > 0){
  1226. this.templateSettings.outbounds.push(outbound);
  1227. this.outboundSettings = JSON.stringify(this.templateSettings.outbounds);
  1228. }
  1229. outModal.close();
  1230. },
  1231. isEdit: false,
  1232. tags: this.templateSettings.outbounds.map(obj => obj.tag)
  1233. });
  1234. },
  1235. editOutbound(index){
  1236. outModal.show({
  1237. title: '{{ i18n "pages.xray.outbound.editOutbound"}} ' + (index+1),
  1238. outbound: app.templateSettings.outbounds[index],
  1239. confirm: (outbound) => {
  1240. outModal.loading();
  1241. this.templateSettings.outbounds[index] = outbound;
  1242. this.outboundSettings = JSON.stringify(this.templateSettings.outbounds);
  1243. outModal.close();
  1244. },
  1245. isEdit: true,
  1246. tags: this.outboundData.filter((o) => o.key != index ).map(obj => obj.tag)
  1247. });
  1248. },
  1249. deleteOutbound(index){
  1250. outbounds = this.templateSettings.outbounds;
  1251. outbounds.splice(index,1);
  1252. this.outboundSettings = JSON.stringify(outbounds);
  1253. },
  1254. setFirstOutbound(index){
  1255. outbounds = this.templateSettings.outbounds;
  1256. outbounds.splice(0, 0, outbounds.splice(index, 1)[0]);
  1257. this.outboundSettings = JSON.stringify(outbounds);
  1258. },
  1259. addReverse(){
  1260. reverseModal.show({
  1261. title: '{{ i18n "pages.xray.outbound.addReverse"}}',
  1262. okText: '{{ i18n "pages.xray.outbound.addReverse" }}',
  1263. confirm: (reverse, rules) => {
  1264. reverseModal.loading();
  1265. if(reverse.tag.length > 0){
  1266. newTemplateSettings = this.templateSettings;
  1267. if(newTemplateSettings.reverse == undefined) newTemplateSettings.reverse = {};
  1268. if(newTemplateSettings.reverse[reverse.type+'s'] == undefined) newTemplateSettings.reverse[reverse.type+'s'] = [];
  1269. newTemplateSettings.reverse[reverse.type+'s'].push({ tag: reverse.tag, domain: reverse.domain });
  1270. this.templateSettings = newTemplateSettings;
  1271. // Add related rules
  1272. this.templateSettings.routing.rules.push(...rules);
  1273. this.routingRuleSettings = JSON.stringify(this.templateSettings.routing.rules);
  1274. }
  1275. reverseModal.close();
  1276. },
  1277. isEdit: false
  1278. });
  1279. },
  1280. editReverse(index){
  1281. if(this.reverseData[index].type == "bridge") {
  1282. oldRules = this.templateSettings.routing.rules.filter(r => r.inboundTag && r.inboundTag[0] == this.reverseData[index].tag);
  1283. } else {
  1284. oldRules = this.templateSettings.routing.rules.filter(r => r.outboundTag && r.outboundTag == this.reverseData[index].tag);
  1285. }
  1286. reverseModal.show({
  1287. title: '{{ i18n "pages.xray.outbound.editReverse"}} ' + (index+1),
  1288. reverse: this.reverseData[index],
  1289. rules: oldRules,
  1290. confirm: (reverse, rules) => {
  1291. reverseModal.loading();
  1292. if(reverse.tag.length > 0){
  1293. oldData = this.reverseData[index];
  1294. newTemplateSettings = this.templateSettings;
  1295. oldReverseIndex = newTemplateSettings.reverse[oldData.type+'s'].findIndex(rs => rs.tag == oldData.tag);
  1296. oldRuleIndex0 = oldRules.length>0 ? newTemplateSettings.routing.rules.findIndex(r => JSON.stringify(r) == JSON.stringify(oldRules[0])) : -1;
  1297. oldRuleIndex1 = oldRules.length==2 ? newTemplateSettings.routing.rules.findIndex(r => JSON.stringify(r) == JSON.stringify(oldRules[1])) : -1;
  1298. if(oldData.type == reverse.type){
  1299. newTemplateSettings.reverse[oldData.type + 's'][oldReverseIndex] = { tag: reverse.tag, domain: reverse.domain };
  1300. } else {
  1301. newTemplateSettings.reverse[oldData.type+'s'].splice(oldReverseIndex,1);
  1302. // delete empty object
  1303. if(newTemplateSettings.reverse[oldData.type+'s'].length == 0) Reflect.deleteProperty(newTemplateSettings.reverse, oldData.type+'s');
  1304. // add other type of reverse if it is not exist
  1305. if(!newTemplateSettings.reverse[reverse.type+'s']) newTemplateSettings.reverse[reverse.type+'s'] = [];
  1306. newTemplateSettings.reverse[reverse.type+'s'].push({ tag: reverse.tag, domain: reverse.domain });
  1307. }
  1308. this.templateSettings = newTemplateSettings;
  1309. // Adjust Rules
  1310. newRules = this.templateSettings.routing.rules;
  1311. oldRuleIndex0 != -1 ? newRules[oldRuleIndex0] = rules[0] : newRules.push(rules[0]);
  1312. oldRuleIndex1 != -1 ? newRules[oldRuleIndex1] = rules[1] : newRules.push(rules[1]);
  1313. this.routingRuleSettings = JSON.stringify(newRules);
  1314. }
  1315. reverseModal.close();
  1316. },
  1317. isEdit: true
  1318. });
  1319. },
  1320. deleteReverse(index){
  1321. oldData = this.reverseData[index];
  1322. newTemplateSettings = this.templateSettings;
  1323. reverseTypeObj = newTemplateSettings.reverse[oldData.type+'s'];
  1324. realIndex = reverseTypeObj.findIndex(r => r.tag==oldData.tag && r.domain==oldData.domain);
  1325. newTemplateSettings.reverse[oldData.type+'s'].splice(realIndex,1);
  1326. // delete empty objects
  1327. if(reverseTypeObj.length == 0) Reflect.deleteProperty(newTemplateSettings.reverse, oldData.type+'s');
  1328. if(Object.keys(newTemplateSettings.reverse).length === 0) Reflect.deleteProperty(newTemplateSettings, 'reverse');
  1329. // delete related routing rules
  1330. newRules = newTemplateSettings.routing.rules;
  1331. if(oldData.type == "bridge"){
  1332. newRules = newTemplateSettings.routing.rules.filter(r => !( r.inboundTag && r.inboundTag.length == 1 && r.inboundTag[0] == oldData.tag));
  1333. } else if(oldData.type == "portal"){
  1334. newRules = newTemplateSettings.routing.rules.filter(r => r.outboundTag != oldData.tag);
  1335. }
  1336. newTemplateSettings.routing.rules = newRules;
  1337. this.templateSettings = newTemplateSettings;
  1338. },
  1339. async refreshOutboundTraffic() {
  1340. if (!this.refreshing) {
  1341. this.refreshing = true;
  1342. await this.getOutboundsTraffic();
  1343. data = []
  1344. if (this.templateSettings != null) {
  1345. this.templateSettings.outbounds.forEach((o, index) => {
  1346. data.push({'key': index, ...o});
  1347. });
  1348. }
  1349. this.outboundData = data;
  1350. this.refreshing = false;
  1351. }
  1352. },
  1353. async resetOutboundTraffic(index) {
  1354. let tag = "-alltags-";
  1355. if (index >= 0) {
  1356. tag = this.outboundData[index].tag ? this.outboundData[index].tag : ""
  1357. }
  1358. const msg = await HttpUtil.post("/panel/xray/resetOutboundsTraffic", { tag: tag });
  1359. if (msg.success) {
  1360. await this.refreshOutboundTraffic();
  1361. }
  1362. },
  1363. addBalancer() {
  1364. balancerModal.show({
  1365. title: '{{ i18n "pages.xray.balancer.addBalancer"}}',
  1366. okText: '{{ i18n "pages.xray.balancer.addBalancer"}}',
  1367. balancerTags: this.balancersData.filter((o) => !ObjectUtil.isEmpty(o.tag)).map(obj => obj.tag),
  1368. balancer: {
  1369. tag: '',
  1370. strategy: 'random',
  1371. selector: [],
  1372. fallbackTag: ''
  1373. },
  1374. confirm: (balancer) => {
  1375. balancerModal.loading();
  1376. newTemplateSettings = this.templateSettings;
  1377. if (newTemplateSettings.routing.balancers == undefined) {
  1378. newTemplateSettings.routing.balancers = [];
  1379. }
  1380. let tmpBalancer = {
  1381. 'tag': balancer.tag,
  1382. 'selector': balancer.selector,
  1383. 'fallbackTag': balancer.fallbackTag
  1384. };
  1385. if (balancer.strategy && balancer.strategy != 'random') {
  1386. tmpBalancer.strategy = {
  1387. 'type': balancer.strategy
  1388. };
  1389. }
  1390. newTemplateSettings.routing.balancers.push(tmpBalancer);
  1391. this.templateSettings = newTemplateSettings;
  1392. if (balancer.strategy == 'leastPing' || balancer.strategy == 'leastLoad')
  1393. this.updateObservatorySelectors();
  1394. balancerModal.close();
  1395. this.changeObsCode();
  1396. },
  1397. isEdit: false
  1398. });
  1399. },
  1400. editBalancer(index) {
  1401. const oldTag = this.balancersData[index].tag;
  1402. balancerModal.show({
  1403. title: '{{ i18n "pages.xray.balancer.editBalancer"}}',
  1404. okText: '{{ i18n "sure" }}',
  1405. balancerTags: this.balancersData.filter((o) => !ObjectUtil.isEmpty(o.tag)).map(obj => obj.tag),
  1406. balancer: this.balancersData[index],
  1407. confirm: (balancer) => {
  1408. balancerModal.loading();
  1409. newTemplateSettings = this.templateSettings;
  1410. let tmpBalancer = {
  1411. 'tag': balancer.tag,
  1412. 'selector': balancer.selector,
  1413. 'fallbackTag': balancer.fallbackTag
  1414. };
  1415. // Remove old tag
  1416. if (newTemplateSettings.observatory){
  1417. newTemplateSettings.observatory.subjectSelector = newTemplateSettings.observatory.subjectSelector.filter(s => s != oldTag);
  1418. }
  1419. if (newTemplateSettings.burstObservatory){
  1420. newTemplateSettings.burstObservatory.subjectSelector = newTemplateSettings.burstObservatory.subjectSelector.filter(s => s != oldTag);
  1421. }
  1422. if (balancer.strategy && balancer.strategy != 'random') {
  1423. tmpBalancer.strategy = {
  1424. 'type': balancer.strategy
  1425. };
  1426. }
  1427. newTemplateSettings.routing.balancers[index] = tmpBalancer;
  1428. // change edited tag if used in rule section
  1429. if (oldTag != balancer.tag) {
  1430. newTemplateSettings.routing.rules.forEach((rule) => {
  1431. if (rule.balancerTag && rule.balancerTag == oldTag) {
  1432. rule.balancerTag = balancer.tag;
  1433. }
  1434. });
  1435. }
  1436. this.templateSettings = newTemplateSettings;
  1437. if (balancer.strategy == 'leastPing' || balancer.strategy == 'leastLoad')
  1438. this.updateObservatorySelectors();
  1439. balancerModal.close();
  1440. this.changeObsCode();
  1441. },
  1442. isEdit: true
  1443. });
  1444. },
  1445. updateObservatorySelectors(){
  1446. newTemplateSettings = this.templateSettings;
  1447. const leastPings = this.balancersData.filter((b) => b.strategy == 'leastPing');
  1448. const leastLoads = this.balancersData.filter((b) => b.strategy == 'leastLoad');
  1449. if (leastPings.length>0){
  1450. if (!newTemplateSettings.observatory)
  1451. newTemplateSettings.observatory = this.defaultObservatory;
  1452. newTemplateSettings.observatory.subjectSelector = [];
  1453. leastPings.forEach((b) => {
  1454. b.selector.forEach((s) => {
  1455. if (!newTemplateSettings.observatory.subjectSelector.includes(s))
  1456. newTemplateSettings.observatory.subjectSelector.push(s);
  1457. });
  1458. });
  1459. } else {
  1460. delete newTemplateSettings.observatory
  1461. }
  1462. if (leastLoads.length>0){
  1463. if (!newTemplateSettings.burstObservatory)
  1464. newTemplateSettings.burstObservatory = this.defaultBurstObservatory;
  1465. newTemplateSettings.burstObservatory.subjectSelector = [];
  1466. leastLoads.forEach((b) => {
  1467. b.selector.forEach((s) => {
  1468. if (!newTemplateSettings.burstObservatory.subjectSelector.includes(s))
  1469. newTemplateSettings.burstObservatory.subjectSelector.push(s);
  1470. });
  1471. });
  1472. } else {
  1473. delete newTemplateSettings.burstObservatory
  1474. }
  1475. this.templateSettings = newTemplateSettings;
  1476. this.changeObsCode();
  1477. },
  1478. deleteBalancer(index) {
  1479. newTemplateSettings = this.templateSettings;
  1480. // Remove from balancers
  1481. const removedBalancer = this.balancersData.splice(index, 1)[0];
  1482. // Remove from settings
  1483. let realIndex = newTemplateSettings.routing.balancers.findIndex((b) => b.tag === removedBalancer.tag);
  1484. newTemplateSettings.routing.balancers.splice(realIndex, 1);
  1485. // Update balancers property to an empty array if there are no more balancers
  1486. if (newTemplateSettings.routing.balancers.length === 0) {
  1487. delete newTemplateSettings.routing.balancers;
  1488. }
  1489. this.templateSettings = newTemplateSettings;
  1490. this.updateObservatorySelectors();
  1491. this.obsSettings = '';
  1492. this.changeObsCode()
  1493. },
  1494. addDNSServer(){
  1495. dnsModal.show({
  1496. title: '{{ i18n "pages.xray.dns.add" }}',
  1497. confirm: (dnsServer) => {
  1498. dnsServers = this.dnsServers;
  1499. dnsServers.push(dnsServer);
  1500. this.dnsServers = dnsServers;
  1501. dnsModal.close();
  1502. },
  1503. isEdit: false
  1504. });
  1505. },
  1506. editDNSServer(index){
  1507. dnsModal.show({
  1508. title: '{{ i18n "pages.xray.dns.edit" }} #' + (index+1),
  1509. dnsServer: this.dnsServers[index],
  1510. confirm: (dnsServer) => {
  1511. dnsServers = this.dnsServers;
  1512. dnsServers[index] = dnsServer;
  1513. this.dnsServers = dnsServers;
  1514. dnsModal.close();
  1515. },
  1516. isEdit: true
  1517. });
  1518. },
  1519. deleteDNSServer(index){
  1520. newDnsServers = this.dnsServers;
  1521. newDnsServers.splice(index,1);
  1522. this.dnsServers = newDnsServers;
  1523. },
  1524. addFakedns() {
  1525. fakednsModal.show({
  1526. title: '{{ i18n "pages.xray.fakedns.add" }}',
  1527. confirm: (item) => {
  1528. fakeDns = this.fakeDns?? [];
  1529. fakeDns.push(item);
  1530. this.fakeDns = fakeDns;
  1531. fakednsModal.close();
  1532. },
  1533. isEdit: false
  1534. });
  1535. },
  1536. editFakedns(index){
  1537. fakednsModal.show({
  1538. title: '{{ i18n "pages.xray.fakedns.edit" }} #' + (index+1),
  1539. fakeDns: this.fakeDns[index],
  1540. confirm: (item) => {
  1541. fakeDns = this.fakeDns;
  1542. fakeDns[index] = item;
  1543. this.fakeDns = fakeDns;
  1544. fakednsModal.close();
  1545. },
  1546. isEdit: true
  1547. });
  1548. },
  1549. deleteFakedns(index){
  1550. fakeDns = this.fakeDns;
  1551. fakeDns.splice(index,1);
  1552. this.fakeDns = fakeDns;
  1553. },
  1554. addRule(){
  1555. ruleModal.show({
  1556. title: '{{ i18n "pages.xray.rules.add"}}',
  1557. okText: '{{ i18n "pages.xray.rules.add" }}',
  1558. confirm: (rule) => {
  1559. ruleModal.loading();
  1560. if(JSON.stringify(rule).length > 3){
  1561. this.templateSettings.routing.rules.push(rule);
  1562. this.routingRuleSettings = JSON.stringify(this.templateSettings.routing.rules);
  1563. }
  1564. ruleModal.close();
  1565. },
  1566. isEdit: false
  1567. });
  1568. },
  1569. editRule(index){
  1570. ruleModal.show({
  1571. title: '{{ i18n "pages.xray.rules.edit"}} ' + (index+1),
  1572. rule: app.templateSettings.routing.rules[index],
  1573. confirm: (rule) => {
  1574. ruleModal.loading();
  1575. if(JSON.stringify(rule).length > 3){
  1576. this.templateSettings.routing.rules[index] = rule;
  1577. this.routingRuleSettings = JSON.stringify(this.templateSettings.routing.rules);
  1578. }
  1579. ruleModal.close();
  1580. },
  1581. isEdit: true
  1582. });
  1583. },
  1584. replaceRule(old_index,new_index){
  1585. rules = this.templateSettings.routing.rules;
  1586. if (new_index >= rules.length) rules.push(undefined);
  1587. rules.splice(new_index, 0, rules.splice(old_index, 1)[0]);
  1588. this.routingRuleSettings = JSON.stringify(rules);
  1589. },
  1590. deleteRule(index){
  1591. rules = this.templateSettings.routing.rules;
  1592. rules.splice(index,1);
  1593. this.routingRuleSettings = JSON.stringify(rules);
  1594. },
  1595. showWarp(){
  1596. warpModal.show();
  1597. }
  1598. },
  1599. async mounted() {
  1600. if (window.location.protocol !== "https:") {
  1601. this.showAlert = true;
  1602. }
  1603. await this.getXraySetting();
  1604. await this.getXrayResult();
  1605. await this.getOutboundsTraffic();
  1606. while (true) {
  1607. await PromiseUtil.sleep(800);
  1608. this.saveBtnDisable = this.oldXraySetting === this.xraySetting;
  1609. }
  1610. },
  1611. computed: {
  1612. templateSettings: {
  1613. get: function () {
  1614. const parsedSettings = this.xraySetting ? JSON.parse(this.xraySetting) : null;
  1615. return parsedSettings;
  1616. },
  1617. set: function (newValue) {
  1618. if (newValue) {
  1619. this.xraySetting = JSON.stringify(newValue, null, 2);
  1620. }
  1621. },
  1622. },
  1623. inboundSettings: {
  1624. get: function () { return this.templateSettings ? JSON.stringify(this.templateSettings.inbounds, null, 2) : null; },
  1625. set: function (newValue) {
  1626. newTemplateSettings = this.templateSettings;
  1627. newTemplateSettings.inbounds = JSON.parse(newValue);
  1628. this.templateSettings = newTemplateSettings;
  1629. },
  1630. },
  1631. outboundSettings: {
  1632. get: function () { return this.templateSettings ? JSON.stringify(this.templateSettings.outbounds, null, 2) : null; },
  1633. set: function (newValue) {
  1634. newTemplateSettings = this.templateSettings;
  1635. newTemplateSettings.outbounds = JSON.parse(newValue);
  1636. this.templateSettings = newTemplateSettings;
  1637. },
  1638. },
  1639. outboundData: {
  1640. get: function () {
  1641. data = []
  1642. if (this.templateSettings != null) {
  1643. this.templateSettings.outbounds.forEach((o, index) => {
  1644. data.push({'key': index, ...o});
  1645. });
  1646. }
  1647. return data;
  1648. },
  1649. },
  1650. reverseData: {
  1651. get: function () {
  1652. data = []
  1653. if (this.templateSettings != null && this.templateSettings.reverse != null) {
  1654. if(this.templateSettings.reverse.bridges) {
  1655. this.templateSettings.reverse.bridges.forEach((o, index) => {
  1656. data.push({'key': index, 'type':'bridge', ...o});
  1657. });
  1658. }
  1659. if(this.templateSettings.reverse.portals){
  1660. this.templateSettings.reverse.portals.forEach((o, index) => {
  1661. data.push({'key': index, 'type':'portal', ...o});
  1662. });
  1663. }
  1664. }
  1665. return data;
  1666. },
  1667. },
  1668. routingRuleSettings: {
  1669. get: function () { return this.templateSettings ? JSON.stringify(this.templateSettings.routing.rules, null, 2) : null; },
  1670. set: function (newValue) {
  1671. newTemplateSettings = this.templateSettings;
  1672. newTemplateSettings.routing.rules = JSON.parse(newValue);
  1673. this.templateSettings = newTemplateSettings;
  1674. },
  1675. },
  1676. routingRuleData: {
  1677. get: function () {
  1678. data = [];
  1679. if (this.templateSettings != null) {
  1680. this.templateSettings.routing.rules.forEach((r, index) => {
  1681. data.push({'key': index, ...r});
  1682. });
  1683. // Make rules readable
  1684. data.forEach(r => {
  1685. if(r.domain) r.domain = r.domain.join(',')
  1686. if(r.ip) r.ip = r.ip.join(',')
  1687. if(r.source) r.source = r.source.join(',');
  1688. if(r.user) r.user = r.user.join(',')
  1689. if(r.inboundTag) r.inboundTag = r.inboundTag.join(',')
  1690. if(r.protocol) r.protocol = r.protocol.join(',')
  1691. if(r.attrs) r.attrs = JSON.stringify(r.attrs, null, 2)
  1692. });
  1693. }
  1694. return data;
  1695. }
  1696. },
  1697. balancersData: {
  1698. get: function () {
  1699. data = []
  1700. if (this.templateSettings != null && this.templateSettings.routing != null && this.templateSettings.routing.balancers != null) {
  1701. this.templateSettings.routing.balancers.forEach((o, index) => {
  1702. data.push({
  1703. 'key': index,
  1704. 'tag': o.tag ? o.tag : "",
  1705. 'strategy': o.strategy?.type ?? "random",
  1706. 'selector': o.selector ? o.selector : [],
  1707. 'fallbackTag': o.fallbackTag?? '',
  1708. });
  1709. });
  1710. }
  1711. return data;
  1712. }
  1713. },
  1714. observatory: {
  1715. get: function () {
  1716. return this.templateSettings?.observatory ? JSON.stringify(this.templateSettings.observatory, null, 2) : null;
  1717. },
  1718. set: function (newValue) {
  1719. newTemplateSettings = this.templateSettings;
  1720. newTemplateSettings.observatory = JSON.parse(newValue);
  1721. this.templateSettings = newTemplateSettings;
  1722. },
  1723. },
  1724. burstObservatory: {
  1725. get: function () {
  1726. return this.templateSettings?.burstObservatory ? JSON.stringify(this.templateSettings.burstObservatory, null, 2) : null;
  1727. },
  1728. set: function (newValue) {
  1729. newTemplateSettings = this.templateSettings;
  1730. newTemplateSettings.burstObservatory = JSON.parse(newValue);
  1731. this.templateSettings = newTemplateSettings;
  1732. },
  1733. },
  1734. observatoryEnable: function () { return this.templateSettings != null && this.templateSettings.observatory != undefined },
  1735. burstObservatoryEnable: function () { return this.templateSettings != null && this.templateSettings.burstObservatory != undefined },
  1736. freedomStrategy: {
  1737. get: function () {
  1738. if (!this.templateSettings) return "AsIs";
  1739. freedomOutbound = this.templateSettings.outbounds.find((o) => o.protocol === "freedom" && o.tag == "direct");
  1740. if (!freedomOutbound) return "AsIs";
  1741. if (!freedomOutbound.settings || !freedomOutbound.settings.domainStrategy) return "AsIs";
  1742. return freedomOutbound.settings.domainStrategy;
  1743. },
  1744. set: function (newValue) {
  1745. newTemplateSettings = this.templateSettings;
  1746. freedomOutboundIndex = newTemplateSettings.outbounds.findIndex((o) => o.protocol === "freedom" && o.tag == "direct");
  1747. if(freedomOutboundIndex == -1){
  1748. newTemplateSettings.outbounds.push({protocol: "freedom", tag: "direct", settings: { "domainStrategy": newValue }});
  1749. } else if (!newTemplateSettings.outbounds[freedomOutboundIndex].settings) {
  1750. newTemplateSettings.outbounds[freedomOutboundIndex].settings = {"domainStrategy": newValue};
  1751. } else {
  1752. newTemplateSettings.outbounds[freedomOutboundIndex].settings.domainStrategy = newValue;
  1753. }
  1754. this.templateSettings = newTemplateSettings;
  1755. }
  1756. },
  1757. routingStrategy: {
  1758. get: function () {
  1759. if (!this.templateSettings || !this.templateSettings.routing || !this.templateSettings.routing.domainStrategy) return "AsIs";
  1760. return this.templateSettings.routing.domainStrategy;
  1761. },
  1762. set: function (newValue) {
  1763. newTemplateSettings = this.templateSettings;
  1764. newTemplateSettings.routing.domainStrategy = newValue;
  1765. this.templateSettings = newTemplateSettings;
  1766. }
  1767. },
  1768. logLevel: {
  1769. get: function () {
  1770. if (!this.templateSettings || !this.templateSettings.log || !this.templateSettings.log.loglevel) return "warning";
  1771. return this.templateSettings.log.loglevel;
  1772. },
  1773. set: function (newValue) {
  1774. newTemplateSettings = this.templateSettings;
  1775. newTemplateSettings.log.loglevel = newValue;
  1776. this.templateSettings = newTemplateSettings;
  1777. }
  1778. },
  1779. accessLog: {
  1780. get: function () {
  1781. if (!this.templateSettings || !this.templateSettings.log || !this.templateSettings.log.access) return "";
  1782. return this.templateSettings.log.access;
  1783. },
  1784. set: function (newValue) {
  1785. newTemplateSettings = this.templateSettings;
  1786. newTemplateSettings.log.access = newValue;
  1787. this.templateSettings = newTemplateSettings;
  1788. }
  1789. },
  1790. errorLog: {
  1791. get: function () {
  1792. if (!this.templateSettings || !this.templateSettings.log || !this.templateSettings.log.error) return "";
  1793. return this.templateSettings.log.error;
  1794. },
  1795. set: function (newValue) {
  1796. newTemplateSettings = this.templateSettings;
  1797. newTemplateSettings.log.error = newValue;
  1798. this.templateSettings = newTemplateSettings;
  1799. }
  1800. },
  1801. dnslog: {
  1802. get: function () {
  1803. if (!this.templateSettings || !this.templateSettings.log || !this.templateSettings.log.dnsLog) return false;
  1804. return this.templateSettings.log.dnsLog;
  1805. },
  1806. set: function (newValue) {
  1807. newTemplateSettings = this.templateSettings;
  1808. newTemplateSettings.log.dnsLog = newValue;
  1809. this.templateSettings = newTemplateSettings;
  1810. }
  1811. },
  1812. maskAddressLog: {
  1813. get: function () {
  1814. if (!this.templateSettings || !this.templateSettings.log || !this.templateSettings.log.maskAddress) return "";
  1815. return this.templateSettings.log.maskAddress;
  1816. },
  1817. set: function (newValue) {
  1818. newTemplateSettings = this.templateSettings;
  1819. newTemplateSettings.log.maskAddress = newValue;
  1820. this.templateSettings = newTemplateSettings;
  1821. }
  1822. },
  1823. blockedIPs: {
  1824. get: function () {
  1825. return this.templateRuleGetter({ outboundTag: "blocked", property: "ip" });
  1826. },
  1827. set: function (newValue) {
  1828. this.templateRuleSetter({ outboundTag: "blocked", property: "ip", data: newValue });
  1829. }
  1830. },
  1831. blockedDomains: {
  1832. get: function () {
  1833. return this.templateRuleGetter({ outboundTag: "blocked", property: "domain" });
  1834. },
  1835. set: function (newValue) {
  1836. this.templateRuleSetter({ outboundTag: "blocked", property: "domain", data: newValue });
  1837. }
  1838. },
  1839. blockedProtocols: {
  1840. get: function () {
  1841. return this.templateRuleGetter({ outboundTag: "blocked", property: "protocol" });
  1842. },
  1843. set: function (newValue) {
  1844. this.templateRuleSetter({ outboundTag: "blocked", property: "protocol", data: newValue });
  1845. }
  1846. },
  1847. directIPs: {
  1848. get: function () {
  1849. return this.templateRuleGetter({ outboundTag: "direct", property: "ip" });
  1850. },
  1851. set: function (newValue) {
  1852. this.templateRuleSetter({ outboundTag: "direct", property: "ip", data: newValue });
  1853. this.syncRulesWithOutbound("direct", this.directSettings);
  1854. }
  1855. },
  1856. directDomains: {
  1857. get: function () {
  1858. return this.templateRuleGetter({ outboundTag: "direct", property: "domain" });
  1859. },
  1860. set: function (newValue) {
  1861. this.templateRuleSetter({ outboundTag: "direct", property: "domain", data: newValue });
  1862. this.syncRulesWithOutbound("direct", this.directSettings);
  1863. }
  1864. },
  1865. ipv4Domains: {
  1866. get: function () {
  1867. return this.templateRuleGetter({ outboundTag: "IPv4", property: "domain" });
  1868. },
  1869. set: function (newValue) {
  1870. this.templateRuleSetter({ outboundTag: "IPv4", property: "domain", data: newValue });
  1871. this.syncRulesWithOutbound("IPv4", this.ipv4Settings);
  1872. }
  1873. },
  1874. warpDomains: {
  1875. get: function () {
  1876. return this.templateRuleGetter({ outboundTag: "warp", property: "domain" });
  1877. },
  1878. set: function (newValue) {
  1879. this.templateRuleSetter({ outboundTag: "warp", property: "domain", data: newValue });
  1880. }
  1881. },
  1882. torrentSettings: {
  1883. get: function () {
  1884. return doAllItemsExist(this.settingsData.protocols.bittorrent, this.blockedProtocols);
  1885. },
  1886. set: function (newValue) {
  1887. if (newValue) {
  1888. this.blockedProtocols = [...this.blockedProtocols, ...this.settingsData.protocols.bittorrent];
  1889. } else {
  1890. this.blockedProtocols = this.blockedProtocols.filter(data => !this.settingsData.protocols.bittorrent.includes(data));
  1891. }
  1892. },
  1893. },
  1894. familyProtectSettings: {
  1895. get: function () {
  1896. if (!this.templateSettings || !this.templateSettings.dns || !this.templateSettings.dns.servers) return false;
  1897. return doAllItemsExist(this.settingsData.familyProtectDNS.servers, this.templateSettings.dns.servers);
  1898. },
  1899. set: function (newValue) {
  1900. newTemplateSettings = this.templateSettings;
  1901. if (newValue) {
  1902. newTemplateSettings.dns = this.settingsData.familyProtectDNS;
  1903. } else {
  1904. newTemplateSettings.dns.servers = newTemplateSettings.dns?.servers?.filter(data => !this.settingsData.familyProtectDNS.servers.includes(data))
  1905. }
  1906. this.templateSettings = newTemplateSettings;
  1907. },
  1908. },
  1909. WarpExist: {
  1910. get: function() {
  1911. return this.templateSettings ? this.templateSettings.outbounds.findIndex((o) => o.tag == "warp")>=0 : false;
  1912. },
  1913. },
  1914. enableDNS: {
  1915. get: function () {
  1916. return this.templateSettings ? this.templateSettings.dns != null : false;
  1917. },
  1918. set: function (newValue) {
  1919. newTemplateSettings = this.templateSettings;
  1920. if (newValue) {
  1921. newTemplateSettings.dns = { servers: [], queryStrategy: "UseIP", tag: "dns_inbound" };
  1922. newTemplateSettings.fakedns = null;
  1923. } else {
  1924. delete newTemplateSettings.dns;
  1925. delete newTemplateSettings.fakedns;
  1926. }
  1927. this.templateSettings = newTemplateSettings;
  1928. }
  1929. },
  1930. dnsTag: {
  1931. get: function () {
  1932. return this.enableDNS ? this.templateSettings.dns.tag : "";
  1933. },
  1934. set: function (newValue) {
  1935. newTemplateSettings = this.templateSettings;
  1936. newTemplateSettings.dns.tag = newValue;
  1937. this.templateSettings = newTemplateSettings;
  1938. }
  1939. },
  1940. dnsStrategy: {
  1941. get: function () {
  1942. return this.enableDNS ? this.templateSettings.dns.queryStrategy : null;
  1943. },
  1944. set: function (newValue) {
  1945. newTemplateSettings = this.templateSettings;
  1946. newTemplateSettings.dns.queryStrategy = newValue;
  1947. this.templateSettings = newTemplateSettings;
  1948. }
  1949. },
  1950. dnsServers: {
  1951. get: function () { return this.enableDNS ? this.templateSettings.dns.servers : []; },
  1952. set: function (newValue) {
  1953. newTemplateSettings = this.templateSettings;
  1954. newTemplateSettings.dns.servers = newValue;
  1955. this.templateSettings = newTemplateSettings;
  1956. }
  1957. },
  1958. fakeDns: {
  1959. get: function () { return this.templateSettings && this.templateSettings.fakedns ? this.templateSettings.fakedns : []; },
  1960. set: function (newValue) {
  1961. newTemplateSettings = this.templateSettings;
  1962. if (this.enableDNS) {
  1963. newTemplateSettings.fakedns = newValue.length > 0 ? newValue : null;
  1964. } else {
  1965. delete newTemplateSettings.fakedns;
  1966. }
  1967. this.templateSettings = newTemplateSettings;
  1968. }
  1969. }
  1970. },
  1971. });
  1972. </script>
  1973. </body>
  1974. </html>