xray.html 115 KB

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