xray.html 115 KB

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