xray.html 104 KB

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