xray.html 117 KB

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