xray.html 103 KB

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