xray.html 117 KB

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