xray.html 114 KB

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