xray.html 118 KB

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