xray.html 102 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970
  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-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.DomainsOptions"> [[ 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 IP', value: 'geoip:private' },
  894. { label: '🇮🇷 Iran', value: 'ext:geoip_IR.dat:ir' },
  895. { label: '🇨🇳 China', value: 'geoip:cn' },
  896. { label: '🇷🇺 Russia', value: 'geoip:ru' },
  897. { label: '🇻🇳 Vietnam', value: 'ext:geoip_VN.dat:vn' },
  898. ],
  899. DomainsOptions: [
  900. { label: 'Ads All', value: 'geosite:category-ads-all' },
  901. { label: 'Ads IR', value: 'ext:geosite_IR.dat:category-ads-all' },
  902. { label: 'Ads VN', value: 'ext:geosite_VN.dat:ads' },
  903. { label: 'Sec-IR malware', value: 'geosite_IR.dat:malware' },
  904. { label: 'Sec-IR phishing', value: 'geosite_IR.dat:phishing' },
  905. { label: 'Sec-IR cryptominers', value: 'geosite_IR.dat:cryptominers' },
  906. { label: '🇮🇷 Iran', value: 'ext:geosite_IR.dat:ir' },
  907. { label: '🇮🇷 .ir', value: 'regexp:.*\\.ir$' },
  908. { label: '🇮🇷 .ایران', value: 'regexp:.*\\.xn--mgba3a4f16a$' },
  909. { label: '🇨🇳 China', value: 'geosite:cn' },
  910. { label: '🇨🇳 .cn', value: 'regexp:.*\\.cn$' },
  911. { label: '🇷🇺 Russia', value: 'geosite:category-ru' }, //https://github.com/v2fly/domain-list-community/blob/master/data/category-ru
  912. { label: '🇷🇺 .ru', value: 'regexp:.*\\.ru' },
  913. { label: '🇻🇳 Vietnam', value: 'ext:geosite_VN.dat:vn' },
  914. { label: '🇻🇳 .vn', value: 'regexp:.*\\.vn$' },
  915. ],
  916. ServicesOptions: [
  917. { label: 'Apple', value: 'geosite:apple' },
  918. { label: 'Meta', value: 'geosite:meta' },
  919. { label: 'Google', value: 'geosite:google' },
  920. { label: 'OpenAI', value: 'geosite:openai' },
  921. { label: 'Spotify', value: 'geosite:spotify' },
  922. { label: 'Netflix', value: 'geosite:netflix' },
  923. { label: 'Reddit', value: 'geosite:reddit' },
  924. { label: 'Speedtest', value: 'geosite:speedtest' },
  925. ],
  926. familyProtectDNS: {
  927. "servers": [
  928. "1.1.1.3", // https://developers.cloudflare.com/1.1.1.1/setup/
  929. "1.0.0.3",
  930. "2606:4700:4700::1113",
  931. "2606:4700:4700::1003"
  932. ],
  933. "queryStrategy": "UseIP"
  934. },
  935. },
  936. defaultObservatory: {
  937. subjectSelector: [],
  938. probeURL: "http://www.google.com/gen_204",
  939. probeInterval: "10m",
  940. enableConcurrency: true
  941. },
  942. defaultBurstObservatory: {
  943. subjectSelector: [],
  944. pingConfig: {
  945. destination: "http://www.google.com/gen_204",
  946. interval: "30m",
  947. connectivity: "http://connectivitycheck.platform.hicloud.com/generate_204",
  948. timeout: "10s",
  949. sampling: 2
  950. }
  951. }
  952. },
  953. methods: {
  954. loading(spinning = true) {
  955. this.spinning = spinning;
  956. },
  957. async getOutboundsTraffic() {
  958. const msg = await HttpUtil.get("/panel/xray/getOutboundsTraffic");
  959. if (msg.success) {
  960. this.outboundsTraffic = msg.obj;
  961. }
  962. },
  963. async getXraySetting() {
  964. this.loading(true);
  965. const msg = await HttpUtil.post("/panel/xray/");
  966. this.loading(false);
  967. if (msg.success) {
  968. result = JSON.parse(msg.obj);
  969. xs = JSON.stringify(result.xraySetting, null, 2);
  970. this.oldXraySetting = xs;
  971. this.xraySetting = xs;
  972. this.inboundTags = result.inboundTags;
  973. this.saveBtnDisable = true;
  974. }
  975. },
  976. async updateXraySetting() {
  977. this.loading(true);
  978. const msg = await HttpUtil.post("/panel/xray/update", {xraySetting : this.xraySetting});
  979. this.loading(false);
  980. if (msg.success) {
  981. await this.getXraySetting();
  982. }
  983. },
  984. async restartXray() {
  985. this.loading(true);
  986. const msg = await HttpUtil.post("server/restartXrayService");
  987. this.loading(false);
  988. if (msg.success) {
  989. await PromiseUtil.sleep(500);
  990. await this.getXrayResult();
  991. }
  992. this.loading(false);
  993. },
  994. async getXrayResult() {
  995. const msg = await HttpUtil.get("/panel/xray/getXrayResult");
  996. if (msg.success) {
  997. this.restartResult=msg.obj;
  998. if(msg.obj.length > 1) Vue.prototype.$message.error(msg.obj);
  999. }
  1000. },
  1001. async fetchUserSecret() {
  1002. this.loading(true);
  1003. const userMessage = await HttpUtil.post("/panel/setting/getUserSecret", this.user);
  1004. if (userMessage.success) {
  1005. this.user = userMessage.obj;
  1006. }
  1007. this.loading(false);
  1008. },
  1009. async updateSecret() {
  1010. this.loading(true);
  1011. const msg = await HttpUtil.post("/panel/setting/updateUserSecret", this.user);
  1012. if (msg.success) {
  1013. this.user = msg.obj;
  1014. window.location.replace(basePath + "logout");
  1015. }
  1016. this.loading(false);
  1017. await this.updateXraySetting();
  1018. },
  1019. generateRandomString(length) {
  1020. var chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
  1021. let randomString = "";
  1022. for (let i = 0; i < length; i++) {
  1023. randomString += chars[Math.floor(Math.random() * chars.length)];
  1024. }
  1025. return randomString;
  1026. },
  1027. async getNewSecret() {
  1028. this.loading(true);
  1029. await PromiseUtil.sleep(600);
  1030. const newSecret = this.generateRandomString(64);
  1031. this.user.loginSecret = newSecret;
  1032. document.getElementById("token").textContent = newSecret;
  1033. this.loading(false);
  1034. },
  1035. async toggleToken(value) {
  1036. if (value) {
  1037. await this.getNewSecret();
  1038. } else {
  1039. this.user.loginSecret = "";
  1040. }
  1041. },
  1042. async resetXrayConfigToDefault() {
  1043. this.loading(true);
  1044. const msg = await HttpUtil.get("/panel/setting/getDefaultJsonConfig");
  1045. this.loading(false);
  1046. if (msg.success) {
  1047. this.templateSettings = JSON.parse(JSON.stringify(msg.obj, null, 2));
  1048. this.saveBtnDisable = true;
  1049. }
  1050. },
  1051. changePage(pageKey) {
  1052. if(pageKey == 'tpl-advanced') this.changeCode();
  1053. if(pageKey == 'tpl-balancer') this.changeObsCode();
  1054. },
  1055. syncRulesWithOutbound(tag, setting) {
  1056. const newTemplateSettings = this.templateSettings;
  1057. const haveRules = newTemplateSettings.routing.rules.some((r) => r?.outboundTag === tag);
  1058. const outboundIndex = newTemplateSettings.outbounds.findIndex((o) => o.tag === tag);
  1059. if (!haveRules && outboundIndex > 0) {
  1060. newTemplateSettings.outbounds.splice(outboundIndex);
  1061. }
  1062. if (haveRules && outboundIndex < 0) {
  1063. newTemplateSettings.outbounds.push(setting);
  1064. }
  1065. this.templateSettings = newTemplateSettings;
  1066. },
  1067. templateRuleGetter(routeSettings) {
  1068. const { property, outboundTag } = routeSettings;
  1069. let result = [];
  1070. if (this.templateSettings != null) {
  1071. this.templateSettings.routing.rules.forEach(
  1072. (routingRule) => {
  1073. if (
  1074. routingRule.hasOwnProperty(property) &&
  1075. routingRule.hasOwnProperty("outboundTag") &&
  1076. routingRule.outboundTag === outboundTag
  1077. ) {
  1078. result.push(...routingRule[property]);
  1079. }
  1080. }
  1081. );
  1082. }
  1083. return result;
  1084. },
  1085. templateRuleSetter(routeSettings) {
  1086. const { data, property, outboundTag } = routeSettings;
  1087. const oldTemplateSettings = this.templateSettings;
  1088. const newTemplateSettings = oldTemplateSettings;
  1089. currentProperty = this.templateRuleGetter({ outboundTag, property })
  1090. if (currentProperty.length == 0) {
  1091. const propertyRule = {
  1092. type: "field",
  1093. outboundTag,
  1094. [property]: data
  1095. };
  1096. newTemplateSettings.routing.rules.push(propertyRule);
  1097. }
  1098. else {
  1099. const newRules = [];
  1100. insertedOnce = false;
  1101. newTemplateSettings.routing.rules.forEach(
  1102. (routingRule) => {
  1103. if (
  1104. routingRule.hasOwnProperty(property) &&
  1105. routingRule.hasOwnProperty("outboundTag") &&
  1106. routingRule.outboundTag === outboundTag
  1107. ) {
  1108. if (!insertedOnce && data.length > 0) {
  1109. insertedOnce = true;
  1110. routingRule[property] = data;
  1111. newRules.push(routingRule);
  1112. }
  1113. }
  1114. else {
  1115. newRules.push(routingRule);
  1116. }
  1117. }
  1118. );
  1119. newTemplateSettings.routing.rules = newRules;
  1120. }
  1121. this.templateSettings = newTemplateSettings;
  1122. },
  1123. changeCode() {
  1124. if(this.cm != null) {
  1125. this.cm.toTextArea();
  1126. }
  1127. textAreaObj = document.getElementById('xraySetting');
  1128. textAreaObj.value = this[this.advSettings];
  1129. this.cm = CodeMirror.fromTextArea(textAreaObj, this.cmOptions);
  1130. this.cm.on('change',editor => {
  1131. value = editor.getValue();
  1132. if (this.isJsonString(value)) {
  1133. this[this.advSettings] = value;
  1134. }
  1135. });
  1136. },
  1137. changeObsCode() {
  1138. if(this.cm != null) {
  1139. this.cm.toTextArea();
  1140. }
  1141. if (this.obsSettings == ''){
  1142. this.cm = null;
  1143. return
  1144. }
  1145. textAreaObj = document.getElementById('obsSetting');
  1146. textAreaObj.value = this[this.obsSettings];
  1147. this.cm = CodeMirror.fromTextArea(textAreaObj, this.cmOptions);
  1148. this.cm.on('change',editor => {
  1149. value = editor.getValue();
  1150. if(this.isJsonString(value)){
  1151. this[this.obsSettings] = value;
  1152. }
  1153. });
  1154. },
  1155. isJsonString(str) {
  1156. try {
  1157. JSON.parse(str);
  1158. } catch (e) {
  1159. return false;
  1160. }
  1161. return true;
  1162. },
  1163. findOutboundTraffic(o) {
  1164. for (const otraffic of this.outboundsTraffic) {
  1165. if (otraffic.tag == o.tag) {
  1166. return sizeFormat(otraffic.up) + ' / ' + sizeFormat(otraffic.down);
  1167. }
  1168. }
  1169. return sizeFormat(0) + ' / ' + sizeFormat(0);
  1170. },
  1171. findOutboundAddress(o) {
  1172. serverObj = null;
  1173. switch(o.protocol){
  1174. case Protocols.VMess:
  1175. case Protocols.VLESS:
  1176. serverObj = o.settings.vnext;
  1177. break;
  1178. case Protocols.HTTP:
  1179. case Protocols.Socks:
  1180. case Protocols.Shadowsocks:
  1181. case Protocols.Trojan:
  1182. serverObj = o.settings.servers;
  1183. break;
  1184. case Protocols.DNS:
  1185. return [o.settings?.address + ':' + o.settings?.port];
  1186. case Protocols.Wireguard:
  1187. return o.settings.peers.map(peer => peer.endpoint);
  1188. default:
  1189. return null;
  1190. }
  1191. return serverObj ? serverObj.map(obj => obj.address + ':' + obj.port) : null;
  1192. },
  1193. addOutbound(){
  1194. outModal.show({
  1195. title: '{{ i18n "pages.xray.outbound.addOutbound"}}',
  1196. okText: '{{ i18n "pages.xray.outbound.addOutbound" }}',
  1197. confirm: (outbound) => {
  1198. outModal.loading();
  1199. if(outbound.tag.length > 0){
  1200. this.templateSettings.outbounds.push(outbound);
  1201. this.outboundSettings = JSON.stringify(this.templateSettings.outbounds);
  1202. }
  1203. outModal.close();
  1204. },
  1205. isEdit: false,
  1206. tags: this.templateSettings.outbounds.map(obj => obj.tag)
  1207. });
  1208. },
  1209. editOutbound(index){
  1210. outModal.show({
  1211. title: '{{ i18n "pages.xray.outbound.editOutbound"}} ' + (index+1),
  1212. outbound: app.templateSettings.outbounds[index],
  1213. confirm: (outbound) => {
  1214. outModal.loading();
  1215. this.templateSettings.outbounds[index] = outbound;
  1216. this.outboundSettings = JSON.stringify(this.templateSettings.outbounds);
  1217. outModal.close();
  1218. },
  1219. isEdit: true,
  1220. tags: this.outboundData.filter((o) => o.key != index ).map(obj => obj.tag)
  1221. });
  1222. },
  1223. deleteOutbound(index){
  1224. outbounds = this.templateSettings.outbounds;
  1225. outbounds.splice(index,1);
  1226. this.outboundSettings = JSON.stringify(outbounds);
  1227. },
  1228. setFirstOutbound(index){
  1229. outbounds = this.templateSettings.outbounds;
  1230. outbounds.splice(0, 0, outbounds.splice(index, 1)[0]);
  1231. this.outboundSettings = JSON.stringify(outbounds);
  1232. },
  1233. addReverse(){
  1234. reverseModal.show({
  1235. title: '{{ i18n "pages.xray.outbound.addReverse"}}',
  1236. okText: '{{ i18n "pages.xray.outbound.addReverse" }}',
  1237. confirm: (reverse, rules) => {
  1238. reverseModal.loading();
  1239. if(reverse.tag.length > 0){
  1240. newTemplateSettings = this.templateSettings;
  1241. if(newTemplateSettings.reverse == undefined) newTemplateSettings.reverse = {};
  1242. if(newTemplateSettings.reverse[reverse.type+'s'] == undefined) newTemplateSettings.reverse[reverse.type+'s'] = [];
  1243. newTemplateSettings.reverse[reverse.type+'s'].push({ tag: reverse.tag, domain: reverse.domain });
  1244. this.templateSettings = newTemplateSettings;
  1245. // Add related rules
  1246. this.templateSettings.routing.rules.push(...rules);
  1247. this.routingRuleSettings = JSON.stringify(this.templateSettings.routing.rules);
  1248. }
  1249. reverseModal.close();
  1250. },
  1251. isEdit: false
  1252. });
  1253. },
  1254. editReverse(index){
  1255. if(this.reverseData[index].type == "bridge") {
  1256. oldRules = this.templateSettings.routing.rules.filter(r => r.inboundTag && r.inboundTag[0] == this.reverseData[index].tag);
  1257. } else {
  1258. oldRules = this.templateSettings.routing.rules.filter(r => r.outboundTag && r.outboundTag == this.reverseData[index].tag);
  1259. }
  1260. reverseModal.show({
  1261. title: '{{ i18n "pages.xray.outbound.editReverse"}} ' + (index+1),
  1262. reverse: this.reverseData[index],
  1263. rules: oldRules,
  1264. confirm: (reverse, rules) => {
  1265. reverseModal.loading();
  1266. if(reverse.tag.length > 0){
  1267. oldData = this.reverseData[index];
  1268. newTemplateSettings = this.templateSettings;
  1269. oldReverseIndex = newTemplateSettings.reverse[oldData.type+'s'].findIndex(rs => rs.tag == oldData.tag);
  1270. oldRuleIndex0 = oldRules.length>0 ? newTemplateSettings.routing.rules.findIndex(r => JSON.stringify(r) == JSON.stringify(oldRules[0])) : -1;
  1271. oldRuleIndex1 = oldRules.length==2 ? newTemplateSettings.routing.rules.findIndex(r => JSON.stringify(r) == JSON.stringify(oldRules[1])) : -1;
  1272. if(oldData.type == reverse.type){
  1273. newTemplateSettings.reverse[oldData.type + 's'][oldReverseIndex] = { tag: reverse.tag, domain: reverse.domain };
  1274. } else {
  1275. newTemplateSettings.reverse[oldData.type+'s'].splice(oldReverseIndex,1);
  1276. // delete empty object
  1277. if(newTemplateSettings.reverse[oldData.type+'s'].length == 0) Reflect.deleteProperty(newTemplateSettings.reverse, oldData.type+'s');
  1278. // add other type of reverse if it is not exist
  1279. if(!newTemplateSettings.reverse[reverse.type+'s']) newTemplateSettings.reverse[reverse.type+'s'] = [];
  1280. newTemplateSettings.reverse[reverse.type+'s'].push({ tag: reverse.tag, domain: reverse.domain });
  1281. }
  1282. this.templateSettings = newTemplateSettings;
  1283. // Adjust Rules
  1284. newRules = this.templateSettings.routing.rules;
  1285. oldRuleIndex0 != -1 ? newRules[oldRuleIndex0] = rules[0] : newRules.push(rules[0]);
  1286. oldRuleIndex1 != -1 ? newRules[oldRuleIndex1] = rules[1] : newRules.push(rules[1]);
  1287. this.routingRuleSettings = JSON.stringify(newRules);
  1288. }
  1289. reverseModal.close();
  1290. },
  1291. isEdit: true
  1292. });
  1293. },
  1294. deleteReverse(index){
  1295. oldData = this.reverseData[index];
  1296. newTemplateSettings = this.templateSettings;
  1297. reverseTypeObj = newTemplateSettings.reverse[oldData.type+'s'];
  1298. realIndex = reverseTypeObj.findIndex(r => r.tag==oldData.tag && r.domain==oldData.domain);
  1299. newTemplateSettings.reverse[oldData.type+'s'].splice(realIndex,1);
  1300. // delete empty objects
  1301. if(reverseTypeObj.length == 0) Reflect.deleteProperty(newTemplateSettings.reverse, oldData.type+'s');
  1302. if(Object.keys(newTemplateSettings.reverse).length === 0) Reflect.deleteProperty(newTemplateSettings, 'reverse');
  1303. // delete related routing rules
  1304. newRules = newTemplateSettings.routing.rules;
  1305. if(oldData.type == "bridge"){
  1306. newRules = newTemplateSettings.routing.rules.filter(r => !( r.inboundTag && r.inboundTag.length == 1 && r.inboundTag[0] == oldData.tag));
  1307. } else if(oldData.type == "portal"){
  1308. newRules = newTemplateSettings.routing.rules.filter(r => r.outboundTag != oldData.tag);
  1309. }
  1310. newTemplateSettings.routing.rules = newRules;
  1311. this.templateSettings = newTemplateSettings;
  1312. },
  1313. async refreshOutboundTraffic() {
  1314. if (!this.refreshing) {
  1315. this.refreshing = true;
  1316. await this.getOutboundsTraffic();
  1317. data = []
  1318. if (this.templateSettings != null) {
  1319. this.templateSettings.outbounds.forEach((o, index) => {
  1320. data.push({'key': index, ...o});
  1321. });
  1322. }
  1323. this.outboundData = data;
  1324. this.refreshing = false;
  1325. }
  1326. },
  1327. async resetOutboundTraffic(index) {
  1328. let tag = "-alltags-";
  1329. if (index >= 0) {
  1330. tag = this.outboundData[index].tag ? this.outboundData[index].tag : ""
  1331. }
  1332. const msg = await HttpUtil.post("/panel/xray/resetOutboundsTraffic", { tag: tag });
  1333. if (msg.success) {
  1334. await this.refreshOutboundTraffic();
  1335. }
  1336. },
  1337. addBalancer() {
  1338. balancerModal.show({
  1339. title: '{{ i18n "pages.xray.balancer.addBalancer"}}',
  1340. okText: '{{ i18n "pages.xray.balancer.addBalancer"}}',
  1341. balancerTags: this.balancersData.filter((o) => !ObjectUtil.isEmpty(o.tag)).map(obj => obj.tag),
  1342. balancer: {
  1343. tag: '',
  1344. strategy: 'random',
  1345. selector: [],
  1346. fallbackTag: ''
  1347. },
  1348. confirm: (balancer) => {
  1349. balancerModal.loading();
  1350. newTemplateSettings = this.templateSettings;
  1351. if (newTemplateSettings.routing.balancers == undefined) {
  1352. newTemplateSettings.routing.balancers = [];
  1353. }
  1354. let tmpBalancer = {
  1355. 'tag': balancer.tag,
  1356. 'selector': balancer.selector,
  1357. 'fallbackTag': balancer.fallbackTag
  1358. };
  1359. if (balancer.strategy && balancer.strategy != 'random') {
  1360. tmpBalancer.strategy = {
  1361. 'type': balancer.strategy
  1362. };
  1363. }
  1364. newTemplateSettings.routing.balancers.push(tmpBalancer);
  1365. this.templateSettings = newTemplateSettings;
  1366. if (balancer.strategy == 'leastPing' || balancer.strategy == 'leastLoad')
  1367. this.updateObservatorySelectors();
  1368. balancerModal.close();
  1369. this.changeObsCode();
  1370. },
  1371. isEdit: false
  1372. });
  1373. },
  1374. editBalancer(index) {
  1375. const oldTag = this.balancersData[index].tag;
  1376. balancerModal.show({
  1377. title: '{{ i18n "pages.xray.balancer.editBalancer"}}',
  1378. okText: '{{ i18n "sure" }}',
  1379. balancerTags: this.balancersData.filter((o) => !ObjectUtil.isEmpty(o.tag)).map(obj => obj.tag),
  1380. balancer: this.balancersData[index],
  1381. confirm: (balancer) => {
  1382. balancerModal.loading();
  1383. newTemplateSettings = this.templateSettings;
  1384. let tmpBalancer = {
  1385. 'tag': balancer.tag,
  1386. 'selector': balancer.selector,
  1387. 'fallbackTag': balancer.fallbackTag
  1388. };
  1389. // Remove old tag
  1390. if (newTemplateSettings.observatory){
  1391. newTemplateSettings.observatory.subjectSelector = newTemplateSettings.observatory.subjectSelector.filter(s => s != oldTag);
  1392. }
  1393. if (newTemplateSettings.burstObservatory){
  1394. newTemplateSettings.burstObservatory.subjectSelector = newTemplateSettings.burstObservatory.subjectSelector.filter(s => s != oldTag);
  1395. }
  1396. if (balancer.strategy && balancer.strategy != 'random') {
  1397. tmpBalancer.strategy = {
  1398. 'type': balancer.strategy
  1399. };
  1400. }
  1401. newTemplateSettings.routing.balancers[index] = tmpBalancer;
  1402. // change edited tag if used in rule section
  1403. if (oldTag != balancer.tag) {
  1404. newTemplateSettings.routing.rules.forEach((rule) => {
  1405. if (rule.balancerTag && rule.balancerTag == oldTag) {
  1406. rule.balancerTag = balancer.tag;
  1407. }
  1408. });
  1409. }
  1410. this.templateSettings = newTemplateSettings;
  1411. if (balancer.strategy == 'leastPing' || balancer.strategy == 'leastLoad')
  1412. this.updateObservatorySelectors();
  1413. balancerModal.close();
  1414. this.changeObsCode();
  1415. },
  1416. isEdit: true
  1417. });
  1418. },
  1419. updateObservatorySelectors(){
  1420. newTemplateSettings = this.templateSettings;
  1421. const leastPings = this.balancersData.filter((b) => b.strategy == 'leastPing');
  1422. const leastLoads = this.balancersData.filter((b) => b.strategy == 'leastLoad');
  1423. if (leastPings.length>0){
  1424. if (!newTemplateSettings.observatory)
  1425. newTemplateSettings.observatory = this.defaultObservatory;
  1426. newTemplateSettings.observatory.subjectSelector = [];
  1427. leastPings.forEach((b) => {
  1428. b.selector.forEach((s) => {
  1429. if (!newTemplateSettings.observatory.subjectSelector.includes(s))
  1430. newTemplateSettings.observatory.subjectSelector.push(s);
  1431. });
  1432. });
  1433. } else {
  1434. delete newTemplateSettings.observatory
  1435. }
  1436. if (leastLoads.length>0){
  1437. if (!newTemplateSettings.burstObservatory)
  1438. newTemplateSettings.burstObservatory = this.defaultBurstObservatory;
  1439. newTemplateSettings.burstObservatory.subjectSelector = [];
  1440. leastLoads.forEach((b) => {
  1441. b.selector.forEach((s) => {
  1442. if (!newTemplateSettings.burstObservatory.subjectSelector.includes(s))
  1443. newTemplateSettings.burstObservatory.subjectSelector.push(s);
  1444. });
  1445. });
  1446. } else {
  1447. delete newTemplateSettings.burstObservatory
  1448. }
  1449. this.templateSettings = newTemplateSettings;
  1450. this.changeObsCode();
  1451. },
  1452. deleteBalancer(index) {
  1453. newTemplateSettings = this.templateSettings;
  1454. // Remove from balancers
  1455. const removedBalancer = this.balancersData.splice(index, 1)[0];
  1456. // Remove from settings
  1457. let realIndex = newTemplateSettings.routing.balancers.findIndex((b) => b.tag === removedBalancer.tag);
  1458. newTemplateSettings.routing.balancers.splice(realIndex, 1);
  1459. // Update balancers property to an empty array if there are no more balancers
  1460. if (newTemplateSettings.routing.balancers.length === 0) {
  1461. delete newTemplateSettings.routing.balancers;
  1462. }
  1463. this.templateSettings = newTemplateSettings;
  1464. this.updateObservatorySelectors();
  1465. this.obsSettings = '';
  1466. this.changeObsCode()
  1467. },
  1468. addDNSServer(){
  1469. dnsModal.show({
  1470. title: '{{ i18n "pages.xray.dns.add" }}',
  1471. confirm: (dnsServer) => {
  1472. dnsServers = this.dnsServers;
  1473. dnsServers.push(dnsServer);
  1474. this.dnsServers = dnsServers;
  1475. dnsModal.close();
  1476. },
  1477. isEdit: false
  1478. });
  1479. },
  1480. editDNSServer(index){
  1481. dnsModal.show({
  1482. title: '{{ i18n "pages.xray.dns.edit" }} #' + (index+1),
  1483. dnsServer: this.dnsServers[index],
  1484. confirm: (dnsServer) => {
  1485. dnsServers = this.dnsServers;
  1486. dnsServers[index] = dnsServer;
  1487. this.dnsServers = dnsServers;
  1488. dnsModal.close();
  1489. },
  1490. isEdit: true
  1491. });
  1492. },
  1493. deleteDNSServer(index){
  1494. newDnsServers = this.dnsServers;
  1495. newDnsServers.splice(index,1);
  1496. this.dnsServers = newDnsServers;
  1497. },
  1498. addFakedns() {
  1499. fakednsModal.show({
  1500. title: '{{ i18n "pages.xray.fakedns.add" }}',
  1501. confirm: (item) => {
  1502. fakeDns = this.fakeDns?? [];
  1503. fakeDns.push(item);
  1504. this.fakeDns = fakeDns;
  1505. fakednsModal.close();
  1506. },
  1507. isEdit: false
  1508. });
  1509. },
  1510. editFakedns(index){
  1511. fakednsModal.show({
  1512. title: '{{ i18n "pages.xray.fakedns.edit" }} #' + (index+1),
  1513. fakeDns: this.fakeDns[index],
  1514. confirm: (item) => {
  1515. fakeDns = this.fakeDns;
  1516. fakeDns[index] = item;
  1517. this.fakeDns = fakeDns;
  1518. fakednsModal.close();
  1519. },
  1520. isEdit: true
  1521. });
  1522. },
  1523. deleteFakedns(index){
  1524. fakeDns = this.fakeDns;
  1525. fakeDns.splice(index,1);
  1526. this.fakeDns = fakeDns;
  1527. },
  1528. addRule(){
  1529. ruleModal.show({
  1530. title: '{{ i18n "pages.xray.rules.add"}}',
  1531. okText: '{{ i18n "pages.xray.rules.add" }}',
  1532. confirm: (rule) => {
  1533. ruleModal.loading();
  1534. if(JSON.stringify(rule).length > 3){
  1535. this.templateSettings.routing.rules.push(rule);
  1536. this.routingRuleSettings = JSON.stringify(this.templateSettings.routing.rules);
  1537. }
  1538. ruleModal.close();
  1539. },
  1540. isEdit: false
  1541. });
  1542. },
  1543. editRule(index){
  1544. ruleModal.show({
  1545. title: '{{ i18n "pages.xray.rules.edit"}} ' + (index+1),
  1546. rule: app.templateSettings.routing.rules[index],
  1547. confirm: (rule) => {
  1548. ruleModal.loading();
  1549. if(JSON.stringify(rule).length > 3){
  1550. this.templateSettings.routing.rules[index] = rule;
  1551. this.routingRuleSettings = JSON.stringify(this.templateSettings.routing.rules);
  1552. }
  1553. ruleModal.close();
  1554. },
  1555. isEdit: true
  1556. });
  1557. },
  1558. replaceRule(old_index,new_index){
  1559. rules = this.templateSettings.routing.rules;
  1560. if (new_index >= rules.length) rules.push(undefined);
  1561. rules.splice(new_index, 0, rules.splice(old_index, 1)[0]);
  1562. this.routingRuleSettings = JSON.stringify(rules);
  1563. },
  1564. deleteRule(index){
  1565. rules = this.templateSettings.routing.rules;
  1566. rules.splice(index,1);
  1567. this.routingRuleSettings = JSON.stringify(rules);
  1568. },
  1569. showWarp(){
  1570. warpModal.show();
  1571. }
  1572. },
  1573. async mounted() {
  1574. if (window.location.protocol !== "https:") {
  1575. this.showAlert = true;
  1576. }
  1577. await this.getXraySetting();
  1578. await this.getXrayResult();
  1579. await this.getOutboundsTraffic();
  1580. while (true) {
  1581. await PromiseUtil.sleep(800);
  1582. this.saveBtnDisable = this.oldXraySetting === this.xraySetting;
  1583. }
  1584. },
  1585. computed: {
  1586. templateSettings: {
  1587. get: function () {
  1588. const parsedSettings = this.xraySetting ? JSON.parse(this.xraySetting) : null;
  1589. return parsedSettings;
  1590. },
  1591. set: function (newValue) {
  1592. if (newValue) {
  1593. this.xraySetting = JSON.stringify(newValue, null, 2);
  1594. }
  1595. },
  1596. },
  1597. inboundSettings: {
  1598. get: function () { return this.templateSettings ? JSON.stringify(this.templateSettings.inbounds, null, 2) : null; },
  1599. set: function (newValue) {
  1600. newTemplateSettings = this.templateSettings;
  1601. newTemplateSettings.inbounds = JSON.parse(newValue);
  1602. this.templateSettings = newTemplateSettings;
  1603. },
  1604. },
  1605. outboundSettings: {
  1606. get: function () { return this.templateSettings ? JSON.stringify(this.templateSettings.outbounds, null, 2) : null; },
  1607. set: function (newValue) {
  1608. newTemplateSettings = this.templateSettings;
  1609. newTemplateSettings.outbounds = JSON.parse(newValue);
  1610. this.templateSettings = newTemplateSettings;
  1611. },
  1612. },
  1613. outboundData: {
  1614. get: function () {
  1615. data = []
  1616. if (this.templateSettings != null) {
  1617. this.templateSettings.outbounds.forEach((o, index) => {
  1618. data.push({'key': index, ...o});
  1619. });
  1620. }
  1621. return data;
  1622. },
  1623. },
  1624. reverseData: {
  1625. get: function () {
  1626. data = []
  1627. if (this.templateSettings != null && this.templateSettings.reverse != null) {
  1628. if(this.templateSettings.reverse.bridges) {
  1629. this.templateSettings.reverse.bridges.forEach((o, index) => {
  1630. data.push({'key': index, 'type':'bridge', ...o});
  1631. });
  1632. }
  1633. if(this.templateSettings.reverse.portals){
  1634. this.templateSettings.reverse.portals.forEach((o, index) => {
  1635. data.push({'key': index, 'type':'portal', ...o});
  1636. });
  1637. }
  1638. }
  1639. return data;
  1640. },
  1641. },
  1642. routingRuleSettings: {
  1643. get: function () { return this.templateSettings ? JSON.stringify(this.templateSettings.routing.rules, null, 2) : null; },
  1644. set: function (newValue) {
  1645. newTemplateSettings = this.templateSettings;
  1646. newTemplateSettings.routing.rules = JSON.parse(newValue);
  1647. this.templateSettings = newTemplateSettings;
  1648. },
  1649. },
  1650. routingRuleData: {
  1651. get: function () {
  1652. data = [];
  1653. if (this.templateSettings != null) {
  1654. this.templateSettings.routing.rules.forEach((r, index) => {
  1655. data.push({'key': index, ...r});
  1656. });
  1657. // Make rules readable
  1658. data.forEach(r => {
  1659. if(r.domain) r.domain = r.domain.join(',')
  1660. if(r.ip) r.ip = r.ip.join(',')
  1661. if(r.source) r.source = r.source.join(',');
  1662. if(r.user) r.user = r.user.join(',')
  1663. if(r.inboundTag) r.inboundTag = r.inboundTag.join(',')
  1664. if(r.protocol) r.protocol = r.protocol.join(',')
  1665. if(r.attrs) r.attrs = JSON.stringify(r.attrs, null, 2)
  1666. });
  1667. }
  1668. return data;
  1669. }
  1670. },
  1671. balancersData: {
  1672. get: function () {
  1673. data = []
  1674. if (this.templateSettings != null && this.templateSettings.routing != null && this.templateSettings.routing.balancers != null) {
  1675. this.templateSettings.routing.balancers.forEach((o, index) => {
  1676. data.push({
  1677. 'key': index,
  1678. 'tag': o.tag ? o.tag : "",
  1679. 'strategy': o.strategy?.type ?? "random",
  1680. 'selector': o.selector ? o.selector : [],
  1681. 'fallbackTag': o.fallbackTag?? '',
  1682. });
  1683. });
  1684. }
  1685. return data;
  1686. }
  1687. },
  1688. observatory: {
  1689. get: function () {
  1690. return this.templateSettings?.observatory ? JSON.stringify(this.templateSettings.observatory, null, 2) : null;
  1691. },
  1692. set: function (newValue) {
  1693. newTemplateSettings = this.templateSettings;
  1694. newTemplateSettings.observatory = JSON.parse(newValue);
  1695. this.templateSettings = newTemplateSettings;
  1696. },
  1697. },
  1698. burstObservatory: {
  1699. get: function () {
  1700. return this.templateSettings?.burstObservatory ? JSON.stringify(this.templateSettings.burstObservatory, null, 2) : null;
  1701. },
  1702. set: function (newValue) {
  1703. newTemplateSettings = this.templateSettings;
  1704. newTemplateSettings.burstObservatory = JSON.parse(newValue);
  1705. this.templateSettings = newTemplateSettings;
  1706. },
  1707. },
  1708. observatoryEnable: function () { return this.templateSettings != null && this.templateSettings.observatory != undefined },
  1709. burstObservatoryEnable: function () { return this.templateSettings != null && this.templateSettings.burstObservatory != undefined },
  1710. freedomStrategy: {
  1711. get: function () {
  1712. if (!this.templateSettings) return "AsIs";
  1713. freedomOutbound = this.templateSettings.outbounds.find((o) => o.protocol === "freedom" && o.tag == "direct");
  1714. if (!freedomOutbound) return "AsIs";
  1715. if (!freedomOutbound.settings || !freedomOutbound.settings.domainStrategy) return "AsIs";
  1716. return freedomOutbound.settings.domainStrategy;
  1717. },
  1718. set: function (newValue) {
  1719. newTemplateSettings = this.templateSettings;
  1720. freedomOutboundIndex = newTemplateSettings.outbounds.findIndex((o) => o.protocol === "freedom" && o.tag == "direct");
  1721. if(freedomOutboundIndex == -1){
  1722. newTemplateSettings.outbounds.push({protocol: "freedom", tag: "direct", settings: { "domainStrategy": newValue }});
  1723. } else if (!newTemplateSettings.outbounds[freedomOutboundIndex].settings) {
  1724. newTemplateSettings.outbounds[freedomOutboundIndex].settings = {"domainStrategy": newValue};
  1725. } else {
  1726. newTemplateSettings.outbounds[freedomOutboundIndex].settings.domainStrategy = newValue;
  1727. }
  1728. this.templateSettings = newTemplateSettings;
  1729. }
  1730. },
  1731. routingStrategy: {
  1732. get: function () {
  1733. if (!this.templateSettings || !this.templateSettings.routing || !this.templateSettings.routing.domainStrategy) return "AsIs";
  1734. return this.templateSettings.routing.domainStrategy;
  1735. },
  1736. set: function (newValue) {
  1737. newTemplateSettings = this.templateSettings;
  1738. newTemplateSettings.routing.domainStrategy = newValue;
  1739. this.templateSettings = newTemplateSettings;
  1740. }
  1741. },
  1742. logLevel: {
  1743. get: function () {
  1744. if (!this.templateSettings || !this.templateSettings.log || !this.templateSettings.log.loglevel) return "warning";
  1745. return this.templateSettings.log.loglevel;
  1746. },
  1747. set: function (newValue) {
  1748. newTemplateSettings = this.templateSettings;
  1749. newTemplateSettings.log.loglevel = newValue;
  1750. this.templateSettings = newTemplateSettings;
  1751. }
  1752. },
  1753. accessLog: {
  1754. get: function () {
  1755. if (!this.templateSettings || !this.templateSettings.log || !this.templateSettings.log.access) return "";
  1756. return this.templateSettings.log.access;
  1757. },
  1758. set: function (newValue) {
  1759. newTemplateSettings = this.templateSettings;
  1760. newTemplateSettings.log.access = newValue;
  1761. this.templateSettings = newTemplateSettings;
  1762. }
  1763. },
  1764. errorLog: {
  1765. get: function () {
  1766. if (!this.templateSettings || !this.templateSettings.log || !this.templateSettings.log.error) return "";
  1767. return this.templateSettings.log.error;
  1768. },
  1769. set: function (newValue) {
  1770. newTemplateSettings = this.templateSettings;
  1771. newTemplateSettings.log.error = newValue;
  1772. this.templateSettings = newTemplateSettings;
  1773. }
  1774. },
  1775. dnslog: {
  1776. get: function () {
  1777. if (!this.templateSettings || !this.templateSettings.log || !this.templateSettings.log.dnsLog) return false;
  1778. return this.templateSettings.log.dnsLog;
  1779. },
  1780. set: function (newValue) {
  1781. newTemplateSettings = this.templateSettings;
  1782. newTemplateSettings.log.dnsLog = newValue;
  1783. this.templateSettings = newTemplateSettings;
  1784. }
  1785. },
  1786. maskAddressLog: {
  1787. get: function () {
  1788. if (!this.templateSettings || !this.templateSettings.log || !this.templateSettings.log.maskAddress) return "";
  1789. return this.templateSettings.log.maskAddress;
  1790. },
  1791. set: function (newValue) {
  1792. newTemplateSettings = this.templateSettings;
  1793. newTemplateSettings.log.maskAddress = newValue;
  1794. this.templateSettings = newTemplateSettings;
  1795. }
  1796. },
  1797. blockedIPs: {
  1798. get: function () {
  1799. return this.templateRuleGetter({ outboundTag: "blocked", property: "ip" });
  1800. },
  1801. set: function (newValue) {
  1802. this.templateRuleSetter({ outboundTag: "blocked", property: "ip", data: newValue });
  1803. }
  1804. },
  1805. blockedDomains: {
  1806. get: function () {
  1807. return this.templateRuleGetter({ outboundTag: "blocked", property: "domain" });
  1808. },
  1809. set: function (newValue) {
  1810. this.templateRuleSetter({ outboundTag: "blocked", property: "domain", data: newValue });
  1811. }
  1812. },
  1813. blockedProtocols: {
  1814. get: function () {
  1815. return this.templateRuleGetter({ outboundTag: "blocked", property: "protocol" });
  1816. },
  1817. set: function (newValue) {
  1818. this.templateRuleSetter({ outboundTag: "blocked", property: "protocol", data: newValue });
  1819. }
  1820. },
  1821. directIPs: {
  1822. get: function () {
  1823. return this.templateRuleGetter({ outboundTag: "direct", property: "ip" });
  1824. },
  1825. set: function (newValue) {
  1826. this.templateRuleSetter({ outboundTag: "direct", property: "ip", data: newValue });
  1827. this.syncRulesWithOutbound("direct", this.directSettings);
  1828. }
  1829. },
  1830. directDomains: {
  1831. get: function () {
  1832. return this.templateRuleGetter({ outboundTag: "direct", property: "domain" });
  1833. },
  1834. set: function (newValue) {
  1835. this.templateRuleSetter({ outboundTag: "direct", property: "domain", data: newValue });
  1836. this.syncRulesWithOutbound("direct", this.directSettings);
  1837. }
  1838. },
  1839. ipv4Domains: {
  1840. get: function () {
  1841. return this.templateRuleGetter({ outboundTag: "IPv4", property: "domain" });
  1842. },
  1843. set: function (newValue) {
  1844. this.templateRuleSetter({ outboundTag: "IPv4", property: "domain", data: newValue });
  1845. this.syncRulesWithOutbound("IPv4", this.ipv4Settings);
  1846. }
  1847. },
  1848. warpDomains: {
  1849. get: function () {
  1850. return this.templateRuleGetter({ outboundTag: "warp", property: "domain" });
  1851. },
  1852. set: function (newValue) {
  1853. this.templateRuleSetter({ outboundTag: "warp", property: "domain", data: newValue });
  1854. }
  1855. },
  1856. torrentSettings: {
  1857. get: function () {
  1858. return doAllItemsExist(this.settingsData.protocols.bittorrent, this.blockedProtocols);
  1859. },
  1860. set: function (newValue) {
  1861. if (newValue) {
  1862. this.blockedProtocols = [...this.blockedProtocols, ...this.settingsData.protocols.bittorrent];
  1863. } else {
  1864. this.blockedProtocols = this.blockedProtocols.filter(data => !this.settingsData.protocols.bittorrent.includes(data));
  1865. }
  1866. },
  1867. },
  1868. familyProtectSettings: {
  1869. get: function () {
  1870. if (!this.templateSettings || !this.templateSettings.dns || !this.templateSettings.dns.servers) return false;
  1871. return doAllItemsExist(this.settingsData.familyProtectDNS.servers, this.templateSettings.dns.servers);
  1872. },
  1873. set: function (newValue) {
  1874. newTemplateSettings = this.templateSettings;
  1875. if (newValue) {
  1876. newTemplateSettings.dns = this.settingsData.familyProtectDNS;
  1877. } else {
  1878. newTemplateSettings.dns.servers = newTemplateSettings.dns?.servers?.filter(data => !this.settingsData.familyProtectDNS.servers.includes(data))
  1879. }
  1880. this.templateSettings = newTemplateSettings;
  1881. },
  1882. },
  1883. WarpExist: {
  1884. get: function() {
  1885. return this.templateSettings ? this.templateSettings.outbounds.findIndex((o) => o.tag == "warp")>=0 : false;
  1886. },
  1887. },
  1888. enableDNS: {
  1889. get: function () {
  1890. return this.templateSettings ? this.templateSettings.dns != null : false;
  1891. },
  1892. set: function (newValue) {
  1893. newTemplateSettings = this.templateSettings;
  1894. if (newValue) {
  1895. newTemplateSettings.dns = { servers: [], queryStrategy: "UseIP", tag: "dns_inbound" };
  1896. newTemplateSettings.fakedns = null;
  1897. } else {
  1898. delete newTemplateSettings.dns;
  1899. delete newTemplateSettings.fakedns;
  1900. }
  1901. this.templateSettings = newTemplateSettings;
  1902. }
  1903. },
  1904. dnsTag: {
  1905. get: function () {
  1906. return this.enableDNS ? this.templateSettings.dns.tag : "";
  1907. },
  1908. set: function (newValue) {
  1909. newTemplateSettings = this.templateSettings;
  1910. newTemplateSettings.dns.tag = newValue;
  1911. this.templateSettings = newTemplateSettings;
  1912. }
  1913. },
  1914. dnsStrategy: {
  1915. get: function () {
  1916. return this.enableDNS ? this.templateSettings.dns.queryStrategy : null;
  1917. },
  1918. set: function (newValue) {
  1919. newTemplateSettings = this.templateSettings;
  1920. newTemplateSettings.dns.queryStrategy = newValue;
  1921. this.templateSettings = newTemplateSettings;
  1922. }
  1923. },
  1924. dnsServers: {
  1925. get: function () { return this.enableDNS ? this.templateSettings.dns.servers : []; },
  1926. set: function (newValue) {
  1927. newTemplateSettings = this.templateSettings;
  1928. newTemplateSettings.dns.servers = newValue;
  1929. this.templateSettings = newTemplateSettings;
  1930. }
  1931. },
  1932. fakeDns: {
  1933. get: function () { return this.templateSettings && this.templateSettings.fakedns ? this.templateSettings.fakedns : []; },
  1934. set: function (newValue) {
  1935. newTemplateSettings = this.templateSettings;
  1936. if (this.enableDNS) {
  1937. newTemplateSettings.fakedns = newValue.length > 0 ? newValue : null;
  1938. } else {
  1939. delete newTemplateSettings.fakedns;
  1940. }
  1941. this.templateSettings = newTemplateSettings;
  1942. }
  1943. }
  1944. },
  1945. });
  1946. </script>
  1947. </body>
  1948. </html>