xray.html 83 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. {{template "head" .}}
  4. <link rel="stylesheet" href="{{ .base_path }}assets/codemirror/codemirror.css">
  5. <link rel="stylesheet" href="{{ .base_path }}assets/codemirror/fold/foldgutter.css">
  6. <link rel="stylesheet" href="{{ .base_path }}assets/codemirror/xq.css?{{ .cur_ver }}">
  7. <link rel="stylesheet" href="{{ .base_path }}assets/codemirror/lint/lint.css">
  8. <script src="{{ .base_path }}assets/js/model/outbound.js"></script>
  9. <script src="{{ .base_path }}assets/codemirror/codemirror.js"></script>
  10. <script src="{{ .base_path }}assets/codemirror/javascript.js"></script>
  11. <script src="{{ .base_path }}assets/codemirror/jshint.js"></script>
  12. <script src="{{ .base_path }}assets/codemirror/jsonlint.js"></script>
  13. <script src="{{ .base_path }}assets/codemirror/lint/lint.js"></script>
  14. <script src="{{ .base_path }}assets/codemirror/lint/javascript-lint.js"></script>
  15. <script src="{{ .base_path }}assets/codemirror/hint/javascript-hint.js"></script>
  16. <script src="{{ .base_path }}assets/codemirror/fold/foldcode.js"></script>
  17. <script src="{{ .base_path }}assets/codemirror/fold/foldgutter.js"></script>
  18. <script src="{{ .base_path }}assets/codemirror/fold/brace-fold.js"></script>
  19. <style>
  20. @media (min-width: 769px) {
  21. .ant-layout-content {
  22. margin: 24px 16px;
  23. }
  24. }
  25. @media (max-width: 768px) {
  26. .ant-tabs-nav .ant-tabs-tab {
  27. margin: 0;
  28. padding: 12px .5rem;
  29. }
  30. .ant-table-thead > tr > th,
  31. .ant-table-tbody > tr > td {
  32. padding: 10px 0px;
  33. }
  34. }
  35. .ant-tabs-bar {
  36. margin: 0;
  37. }
  38. .ant-list-item {
  39. display: block;
  40. }
  41. .collapse-title {
  42. color: inherit;
  43. font-weight: bold;
  44. font-size: 18px;
  45. padding: 10px 20px;
  46. border-bottom: 2px solid;
  47. }
  48. .collapse-title > i {
  49. color: inherit;
  50. font-size: 24px;
  51. }
  52. </style>
  53. <body>
  54. <a-layout id="app" v-cloak :class="themeSwitcher.currentTheme">
  55. {{ template "commonSider" . }}
  56. <a-layout id="content-layout">
  57. <a-layout-content>
  58. <a-spin :spinning="spinning" :delay="500" tip='{{ i18n "loading"}}'>
  59. <a-space direction="vertical">
  60. <a-card hoverable style="margin-bottom: .5rem;">
  61. <a-row>
  62. <a-col :xs="24" :sm="8" style="padding: 4px;">
  63. <a-space direction="horizontal">
  64. <a-button type="primary" :disabled="saveBtnDisable" @click="updateXraySetting">{{ i18n "pages.xray.save" }}</a-button>
  65. <a-button type="danger" :disabled="!saveBtnDisable" @click="restartXray">{{ i18n "pages.xray.restart" }}</a-button>
  66. <a-popover v-if="restartResult"
  67. :overlay-class-name="themeSwitcher.currentTheme">
  68. <span slot="title" style="font-size: 12pt">Error in running xray-core</span>
  69. <template slot="content">
  70. <p style="max-width: 400px" v-for="line in restartResult.split('\n')">[[ line ]]</p>
  71. </template>
  72. <a-icon type="question-circle"></a-icon>
  73. </a-popover>
  74. </a-space>
  75. </a-col>
  76. <a-col :xs="24" :sm="16">
  77. <a-back-top :target="() => document.getElementById('content-layout')" visibility-height="200">
  78. </a-back-top>
  79. <a-alert type="warning" style="float: right; width: fit-content"
  80. message='{{ i18n "pages.settings.infoDesc" }}'
  81. show-icon
  82. >
  83. </a-col>
  84. </a-row>
  85. </a-card>
  86. <a-tabs class="ant-card-dark-box-nohover" default-active-key="tpl-1"
  87. @change="(activeKey) => { if(activeKey == 'tpl-advanced') this.changeCode(); }"
  88. :class="themeSwitcher.currentTheme">
  89. <a-tab-pane key="tpl-1" tab='{{ i18n "pages.xray.basicTemplate"}}'>
  90. <a-space direction="horizontal" style="padding: 20px 20px">
  91. <a-button type="primary" @click="resetXrayConfigToDefault">{{ i18n "pages.settings.resetDefaultConfig" }}</a-button>
  92. </a-space>
  93. <a-collapse>
  94. <a-collapse-panel header='{{ i18n "pages.xray.generalConfigs"}}'>
  95. <a-row :xs="24" :sm="24" :lg="12">
  96. <a-alert type="warning" style="text-align: center;">
  97. <template slot="message">
  98. <a-icon type="exclamation-circle" theme="filled" style="color: #FFA031"></a-icon>
  99. {{ i18n "pages.xray.generalConfigsDesc" }}
  100. </template>
  101. </a-alert>
  102. </a-row>
  103. <a-list-item>
  104. <a-row style="padding: 20px">
  105. <a-col :lg="24" :xl="12">
  106. <a-list-item-meta
  107. title='{{ i18n "pages.xray.FreedomStrategy" }}'
  108. description='{{ i18n "pages.xray.FreedomStrategyDesc" }}'/>
  109. </a-col>
  110. <a-col :lg="24" :xl="12">
  111. <template>
  112. <a-select
  113. v-model="freedomStrategy"
  114. :dropdown-class-name="themeSwitcher.currentTheme"
  115. style="width: 100%">
  116. <a-select-option v-for="s in OutboundDomainStrategies" :value="s">[[ s ]]</a-select-option>
  117. </a-select>
  118. </template>
  119. </a-col>
  120. </a-row>
  121. </a-list-item>
  122. <a-row style="padding: 20px">
  123. <a-col :lg="24" :xl="12">
  124. <a-list-item-meta
  125. title='{{ i18n "pages.xray.RoutingStrategy" }}'
  126. description='{{ i18n "pages.xray.RoutingStrategyDesc" }}'/>
  127. </a-col>
  128. <a-col :lg="24" :xl="12">
  129. <template>
  130. <a-select
  131. v-model="routingStrategy"
  132. :dropdown-class-name="themeSwitcher.currentTheme"
  133. style="width: 100%">
  134. <a-select-option v-for="s in routingDomainStrategies" :value="s">[[ s ]]</a-select-option>
  135. </a-select>
  136. </template>
  137. </a-col>
  138. </a-row>
  139. </a-list-item>
  140. </a-collapse-panel>
  141. <a-collapse-panel header='{{ i18n "pages.xray.blockConfigs"}}'>
  142. <a-row :xs="24" :sm="24" :lg="12">
  143. <a-alert type="warning" style="text-align: center;">
  144. <template slot="message">
  145. <a-icon type="exclamation-circle" theme="filled" style="color: #FFA031"></a-icon>
  146. {{ i18n "pages.xray.blockConfigsDesc" }}
  147. </template>
  148. </a-alert>
  149. </a-row>
  150. <setting-list-item type="switch" title='{{ i18n "pages.xray.Torrent"}}' desc='{{ i18n "pages.xray.TorrentDesc"}}' v-model="torrentSettings"></setting-list-item>
  151. <setting-list-item type="switch" title='{{ i18n "pages.xray.PrivateIp"}}' desc='{{ i18n "pages.xray.PrivateIpDesc"}}' v-model="privateIpSettings"></setting-list-item>
  152. <setting-list-item type="switch" title='{{ i18n "pages.xray.Ads"}}' desc='{{ i18n "pages.xray.AdsDesc"}}' v-model="AdsSettings"></setting-list-item>
  153. <setting-list-item type="switch" title='{{ i18n "pages.xray.Family"}}' desc='{{ i18n "pages.xray.FamilyDesc"}}' v-model="familyProtectSettings"></setting-list-item>
  154. <setting-list-item type="switch" title='{{ i18n "pages.xray.Security"}}' desc='{{ i18n "pages.xray.SecurityDesc"}}' v-model="SecuritySettings"></setting-list-item>
  155. <setting-list-item type="switch" title='{{ i18n "pages.xray.Speedtest"}}' desc='{{ i18n "pages.xray.SpeedtestDesc"}}' v-model="SpeedTestSettings"></setting-list-item>
  156. </a-collapse-panel>
  157. <a-collapse-panel header='{{ i18n "pages.xray.blockCountryConfigs"}}'>
  158. <a-row :xs="24" :sm="24" :lg="12">
  159. <a-alert type="warning" style="text-align: center;">
  160. <template slot="message">
  161. <a-icon type="exclamation-circle" theme="filled" style="color: #FFA031"></a-icon>
  162. {{ i18n "pages.xray.blockCountryConfigsDesc" }}
  163. </template>
  164. </a-alert>
  165. </a-row>
  166. <setting-list-item type="switch" title='{{ i18n "pages.xray.IRIp"}}' desc='{{ i18n "pages.xray.IRIpDesc"}}' v-model="IRIpSettings"></setting-list-item>
  167. <setting-list-item type="switch" title='{{ i18n "pages.xray.IRDomain"}}' desc='{{ i18n "pages.xray.IRDomainDesc"}}' v-model="IRDomainSettings"></setting-list-item>
  168. <setting-list-item type="switch" title='{{ i18n "pages.xray.ChinaIp"}}' desc='{{ i18n "pages.xray.ChinaIpDesc"}}' v-model="ChinaIpSettings"></setting-list-item>
  169. <setting-list-item type="switch" title='{{ i18n "pages.xray.ChinaDomain"}}' desc='{{ i18n "pages.xray.ChinaDomainDesc"}}' v-model="ChinaDomainSettings"></setting-list-item>
  170. <setting-list-item type="switch" title='{{ i18n "pages.xray.RussiaIp"}}' desc='{{ i18n "pages.xray.RussiaIpDesc"}}' v-model="RussiaIpSettings"></setting-list-item>
  171. <setting-list-item type="switch" title='{{ i18n "pages.xray.RussiaDomain"}}' desc='{{ i18n "pages.xray.RussiaDomainDesc"}}' v-model="RussiaDomainSettings"></setting-list-item>
  172. <setting-list-item type="switch" title='{{ i18n "pages.xray.VNIp"}}' desc='{{ i18n "pages.xray.VNIpDesc"}}' v-model="VNIpSettings"></setting-list-item>
  173. <setting-list-item type="switch" title='{{ i18n "pages.xray.VNDomain"}}' desc='{{ i18n "pages.xray.VNDomainDesc"}}' v-model="VNDomainSettings"></setting-list-item>
  174. </a-collapse-panel>
  175. <a-collapse-panel header='{{ i18n "pages.xray.directCountryConfigs"}}'>
  176. <a-row :xs="24" :sm="24" :lg="12">
  177. <a-alert type="warning" style="text-align: center;">
  178. <template slot="message">
  179. <a-icon type="exclamation-circle" theme="filled" style="color: #FFA031"></a-icon>
  180. {{ i18n "pages.xray.directCountryConfigsDesc" }}
  181. </template>
  182. </a-alert>
  183. </a-row>
  184. <setting-list-item type="switch" title='{{ i18n "pages.xray.DirectIRIp"}}' desc='{{ i18n "pages.xray.DirectIRIpDesc"}}' v-model="IRIpDirectSettings"></setting-list-item>
  185. <setting-list-item type="switch" title='{{ i18n "pages.xray.DirectIRDomain"}}' desc='{{ i18n "pages.xray.DirectIRDomainDesc"}}' v-model="IRDomainDirectSettings"></setting-list-item>
  186. <setting-list-item type="switch" title='{{ i18n "pages.xray.DirectChinaIp"}}' desc='{{ i18n "pages.xray.DirectChinaIpDesc"}}' v-model="ChinaIpDirectSettings"></setting-list-item>
  187. <setting-list-item type="switch" title='{{ i18n "pages.xray.DirectChinaDomain"}}' desc='{{ i18n "pages.xray.DirectChinaDomainDesc"}}' v-model="ChinaDomainDirectSettings"></setting-list-item>
  188. <setting-list-item type="switch" title='{{ i18n "pages.xray.DirectRussiaIp"}}' desc='{{ i18n "pages.xray.DirectRussiaIpDesc"}}' v-model="RussiaIpDirectSettings"></setting-list-item>
  189. <setting-list-item type="switch" title='{{ i18n "pages.xray.DirectRussiaDomain"}}' desc='{{ i18n "pages.xray.DirectRussiaDomainDesc"}}' v-model="RussiaDomainDirectSettings"></setting-list-item>
  190. <setting-list-item type="switch" title='{{ i18n "pages.xray.DirectVNIp"}}' desc='{{ i18n "pages.xray.DirectVNIpDesc"}}' v-model="VNIpDirectSettings"></setting-list-item>
  191. <setting-list-item type="switch" title='{{ i18n "pages.xray.DirectVNDomain"}}' desc='{{ i18n "pages.xray.DirectVNDomainDesc"}}' v-model="VNDomainDirectSettings"></setting-list-item>
  192. </a-collapse-panel>
  193. <a-collapse-panel header='{{ i18n "pages.xray.ipv4Configs"}}'>
  194. <a-row :xs="24" :sm="24" :lg="12">
  195. <a-alert type="warning" style="text-align: center;">
  196. <template slot="message">
  197. <a-icon type="exclamation-circle" theme="filled" style="color: #FFA031"></a-icon>
  198. {{ i18n "pages.xray.ipv4ConfigsDesc" }}
  199. </template>
  200. </a-alert>
  201. </a-row>
  202. <setting-list-item type="switch" title='{{ i18n "pages.xray.GoogleIPv4"}}' desc='{{ i18n "pages.xray.GoogleIPv4Desc"}}' v-model="GoogleIPv4Settings"></setting-list-item>
  203. <setting-list-item type="switch" title='{{ i18n "pages.xray.NetflixIPv4"}}' desc='{{ i18n "pages.xray.NetflixIPv4Desc"}}' v-model="NetflixIPv4Settings"></setting-list-item>
  204. </a-collapse-panel>
  205. <a-collapse-panel header='{{ i18n "pages.xray.warpConfigs"}}'>
  206. <a-row :xs="24" :sm="24" :lg="12">
  207. <a-alert type="warning" style="text-align: center;">
  208. <template slot="message">
  209. <a-icon type="exclamation-circle" theme="filled" style="color: #FFA031"></a-icon>
  210. {{ i18n "pages.xray.warpConfigsDesc" }}
  211. </template>
  212. </a-alert>
  213. </a-row>
  214. <setting-list-item type="switch" title='{{ i18n "pages.xray.GoogleWARP"}}' desc='{{ i18n "pages.xray.GoogleWARPDesc"}}' v-model="GoogleWARPSettings"></setting-list-item>
  215. <setting-list-item type="switch" title='{{ i18n "pages.xray.OpenAIWARP"}}' desc='{{ i18n "pages.xray.OpenAIWARPDesc"}}' v-model="OpenAIWARPSettings"></setting-list-item>
  216. <setting-list-item type="switch" title='{{ i18n "pages.xray.NetflixWARP"}}' desc='{{ i18n "pages.xray.NetflixWARPDesc"}}' v-model="NetflixWARPSettings"></setting-list-item>
  217. <setting-list-item type="switch" title='{{ i18n "pages.xray.SpotifyWARP"}}' desc='{{ i18n "pages.xray.SpotifyWARPDesc"}}' v-model="SpotifyWARPSettings"></setting-list-item>
  218. </a-collapse-panel>
  219. </a-collapse>
  220. </a-tab-pane>
  221. <a-tab-pane key="tpl-2" tab='{{ i18n "pages.xray.Routings"}}' style="padding-top: 20px;">
  222. <a-alert type="warning" style="margin-bottom: 10px; width: fit-content"
  223. message='{{ i18n "pages.xray.RoutingsDesc"}}' show-icon></a-alert>
  224. <a-button type="primary" icon="plus" @click="addRule">{{ i18n "pages.xray.rules.add" }}</a-button>
  225. <a-table :columns="isMobile ? rulesMobileColumns : rulesColumns" bordered
  226. :row-key="r => r.key"
  227. :data-source="routingRuleData"
  228. :scroll="isMobile ? {} : { x: 1000 }"
  229. :pagination="false"
  230. :indent-size="0"
  231. :style="isMobile ? 'padding: 5px 0' : 'margin-top: 10px;'">
  232. <template slot="action" slot-scope="text, rule, index">
  233. [[ index+1 ]]
  234. <a-dropdown :trigger="['click']">
  235. <a-icon @click="e => e.preventDefault()" type="more" style="font-size: 16px; text-decoration: bold;"></a-icon>
  236. <a-menu slot="overlay" :theme="themeSwitcher.currentTheme">
  237. <a-menu-item v-if="index>0" @click="replaceRule(index,0)">
  238. <a-icon type="vertical-align-top"></a-icon>
  239. {{ i18n "pages.xray.rules.first"}}
  240. </a-menu-item>
  241. <a-menu-item v-if="index>0" @click="replaceRule(index,index-1)">
  242. <a-icon type="arrow-up"></a-icon>
  243. {{ i18n "pages.xray.rules.up"}}
  244. </a-menu-item>
  245. <a-menu-item v-if="index<routingRuleData.length-1" @click="replaceRule(index,index+1)">
  246. <a-icon type="arrow-down"></a-icon>
  247. {{ i18n "pages.xray.rules.down"}}
  248. </a-menu-item>
  249. <a-menu-item v-if="index<routingRuleData.length-1" @click="replaceRule(index,routingRuleData.length-1)">
  250. <a-icon type="vertical-align-bottom"></a-icon>
  251. {{ i18n "pages.xray.rules.last"}}
  252. </a-menu-item>
  253. <a-menu-item @click="editRule(index)">
  254. <a-icon type="edit"></a-icon>
  255. {{ i18n "edit" }}
  256. </a-menu-item>
  257. <a-menu-item @click="deleteRule(index)">
  258. <span style="color: #FF4D4F">
  259. <a-icon type="delete"></a-icon> {{ i18n "delete"}}
  260. </span>
  261. </a-menu-item>
  262. </a-menu>
  263. </a-dropdown>
  264. </template>
  265. <template slot="inbound" slot-scope="text, rule, index">
  266. <a-popover :overlay-class-name="themeSwitcher.currentTheme">
  267. <template slot="content">
  268. <p v-if="rule.inboundTag">Inbound Tag: [[ rule.inboundTag ]]</p>
  269. <p v-if="rule.user">User email: [[ rule.user ]]</p>
  270. </template>
  271. [[ [rule.inboundTag,rule.user].join('\n') ]]
  272. </a-popover>
  273. </template>
  274. <template slot="outbound" slot-scope="text, rule, index">
  275. <a-popover :overlay-class-name="themeSwitcher.currentTheme">
  276. <template slot="content">
  277. <p v-if="rule.outboundTag">Outbound Tag: [[ rule.outboundTag ]]</p>
  278. </template>
  279. [[ rule.outboundTag ]]
  280. </a-popover>
  281. </template>
  282. <template slot="info" slot-scope="text, rule, index">
  283. <a-popover placement="bottomRight"
  284. v-if="(rule.source+rule.sourcePort+rule.network+rule.protocol+rule.attrs+rule.ip+rule.domain+rule.port).length>0"
  285. :overlay-class-name="themeSwitcher.currentTheme" trigger="click">
  286. <template slot="content">
  287. <table cellpadding="2" style="max-width: 300px;">
  288. <tr v-if="rule.source">
  289. <td>Source</td>
  290. <td><a-tag color="blue" v-for="r in rule.source.split(',')">[[ r ]]</a-tag></td>
  291. </tr>
  292. <tr v-if="rule.sourcePort">
  293. <td>Source Port</td>
  294. <td><a-tag color="green" v-for="r in rule.sourcePort.split(',')">[[ r ]]</a-tag></td>
  295. </tr>
  296. <tr v-if="rule.network">
  297. <td>Network</td>
  298. <td><a-tag color="blue" v-for="r in rule.network.split(',')">[[ r ]]</a-tag></td>
  299. </tr>
  300. <tr v-if="rule.protocol">
  301. <td>Protocol</td>
  302. <td><a-tag color="green" v-for="r in rule.protocol.split(',')">[[ r ]]</a-tag></td>
  303. </tr>
  304. <tr v-if="rule.attrs">
  305. <td>Attrs</td>
  306. <td><a-tag color="blue" v-for="r in rule.attrs.split(',')">[[ r ]]</a-tag></td>
  307. </tr>
  308. <tr v-if="rule.ip">
  309. <td>IP</td>
  310. <td><a-tag color="green" v-for="r in rule.ip.split(',')">[[ r ]]</a-tag></td>
  311. </tr>
  312. <tr v-if="rule.domain">
  313. <td>Domain</td>
  314. <td><a-tag color="blue" v-for="r in rule.domain.split(',')">[[ r ]]</a-tag></td>
  315. </tr>
  316. <tr v-if="rule.port">
  317. <td>Port</td>
  318. <td><a-tag color="green" v-for="r in rule.port.split(',')">[[ r ]]</a-tag></td>
  319. </tr>
  320. </table>
  321. </template>
  322. <a-button shape="round" size="small" style="font-size: 14px; padding: 0 10px;">
  323. <a-icon type="info"></a-icon>
  324. </a-button>
  325. </a-popover>
  326. </template>
  327. </a-table>
  328. </a-tab-pane>
  329. <a-tab-pane key="tpl-3" tab='{{ i18n "pages.xray.Outbounds"}}' style="padding-top: 20px;" force-render="true">
  330. <a-button type="primary" icon="plus" @click="addOutbound()" style="margin-bottom: 10px;">{{ i18n "pages.xray.outbound.addOutbound" }}</a-button>
  331. <a-table :columns="outboundColumns" bordered
  332. :row-key="r => r.key"
  333. :data-source="outboundData"
  334. :scroll="isMobile ? {} : { x: 200 }"
  335. :pagination="false"
  336. :indent-size="0"
  337. :style="isMobile ? 'padding: 5px 5px' : 'margin-right: 1px;'">
  338. <template slot="action" slot-scope="text, outbound, index">
  339. [[ index+1 ]]
  340. <a-dropdown :trigger="['click']">
  341. <a-icon @click="e => e.preventDefault()" type="more" style="font-size: 16px; text-decoration: bold;"></a-icon>
  342. <a-menu slot="overlay" :theme="themeSwitcher.currentTheme">
  343. <a-menu-item @click="editOutbound(index)">
  344. <a-icon type="edit"></a-icon>
  345. {{ i18n "edit" }}
  346. </a-menu-item>
  347. <a-menu-item @click="deleteOutbound(index)">
  348. <span style="color: #FF4D4F">
  349. <a-icon type="delete"></a-icon> {{ i18n "delete"}}
  350. </span>
  351. </a-menu-item>
  352. </a-menu>
  353. </a-dropdown>
  354. </template>
  355. <template slot="address" slot-scope="text, outbound, index">
  356. <p style="margin: 0 5px;" v-for="addr in findOutboundAddress(outbound)">[[ addr ]]</p>
  357. </template>
  358. <template slot="protocol" slot-scope="text, outbound, index">
  359. <a-tag style="margin:0;" color="purple">[[ outbound.protocol ]]</a-tag>
  360. <template v-if="[Protocols.VMess, Protocols.VLESS, Protocols.Trojan, Protocols.Shadowsocks].includes(outbound.protocol)">
  361. <a-tag style="margin:0;" color="blue">[[ outbound.streamSettings.network ]]</a-tag>
  362. <a-tag style="margin:0;" v-if="outbound.streamSettings.security=='tls'" color="green">tls</a-tag>
  363. <a-tag style="margin:0;" v-if="outbound.streamSettings.security=='reality'" color="green">reality</a-tag>
  364. </template>
  365. </template>
  366. </a-table>
  367. </a-tab-pane>
  368. <a-tab-pane key="tpl-4" tab='{{ i18n "pages.xray.outbound.reverse"}}' style="padding-top: 20px;" force-render="true">
  369. <a-button type="primary" icon="plus" @click="addReverse()" style="margin-bottom: 10px;">{{ i18n "pages.xray.outbound.addReverse" }}</a-button>
  370. <a-table :columns="reverseColumns" bordered
  371. :row-key="r => r.key"
  372. :data-source="reverseData"
  373. :scroll="isMobile ? {} : { x: 200 }"
  374. :pagination="false"
  375. :indent-size="0"
  376. :style="isMobile ? 'padding: 5px 0' : 'margin-left: 1px;'">
  377. <template slot="action" slot-scope="text, reverse, index">
  378. [[ index+1 ]]
  379. <a-dropdown :trigger="['click']">
  380. <a-icon @click="e => e.preventDefault()" type="more" style="font-size: 16px; text-decoration: bold;"></a-icon>
  381. <a-menu slot="overlay" :theme="themeSwitcher.currentTheme">
  382. <a-menu-item @click="editReverse(index)">
  383. <a-icon type="edit"></a-icon>
  384. {{ i18n "edit" }}
  385. </a-menu-item>
  386. <a-menu-item @click="deleteReverse(index)">
  387. <span style="color: #FF4D4F">
  388. <a-icon type="delete"></a-icon> {{ i18n "delete"}}
  389. </span>
  390. </a-menu-item>
  391. </a-menu>
  392. </a-dropdown>
  393. </template>
  394. </a-table>
  395. </a-tab-pane>
  396. <a-tab-pane key="tpl-advanced" tab='{{ i18n "pages.xray.advancedTemplate"}}' style="padding-top: 20px;" force-render="true">
  397. <a-list-item-meta title='{{ i18n "pages.xray.Template"}}' description='{{ i18n "pages.xray.TemplateDesc"}}'></a-list-item-meta>
  398. <a-radio-group v-model="advSettings" @change="changeCode" button-style="solid" style="margin: 10px 0;" :size="isMobile ? 'small' : ''">
  399. <a-radio-button value="xraySetting">{{ i18n "pages.xray.completeTemplate"}}</a-radio-button>
  400. <a-radio-button value="inboundSettings">{{ i18n "pages.xray.Inbounds" }}</a-radio-button>
  401. <a-radio-button value="outboundSettings">{{ i18n "pages.xray.Outbounds" }}</a-radio-button>
  402. <a-radio-button value="routingRuleSettings">{{ i18n "pages.xray.Routings" }}</a-radio-button>
  403. </a-radio-group>
  404. <textarea style="position:absolute; left: -800px;" id="xraySetting"></textarea>
  405. </a-tab-pane>
  406. </a-tabs>
  407. </a-space>
  408. </a-spin>
  409. </a-layout-content>
  410. </a-layout>
  411. </a-layout>
  412. {{template "js" .}}
  413. {{template "component/themeSwitcher" .}}
  414. {{template "component/setting"}}
  415. {{template "ruleModal"}}
  416. {{template "outModal"}}
  417. {{template "reverseModal"}}
  418. <script>
  419. const rulesColumns = [
  420. { title: "#", align: 'center', width: 15, scopedSlots: { customRender: 'action' } },
  421. { title: '{{ i18n "pages.xray.rules.source"}}', children: [
  422. { title: 'IP', dataIndex: "source", align: 'center', width: 20, ellipsis: true },
  423. { title: 'port', dataIndex: 'sourcePort', align: 'center', width: 10, ellipsis: true } ]},
  424. { title: '{{ i18n "pages.inbounds.network"}}', children: [
  425. { title: 'L4', dataIndex: 'network', align: 'center', width: 10 },
  426. { title: 'Protocol', dataIndex: 'protocol', align: 'center', width: 10, ellipsis: true },
  427. { title: 'Attrs', dataIndex: 'attrs', align: 'center', width: 20, ellipsis: true } ]},
  428. { title: '{{ i18n "pages.xray.rules.dest"}}', children: [
  429. { title: 'IP', dataIndex: 'ip', align: 'center', width: 20, ellipsis: true },
  430. { title: 'Domain', dataIndex: 'domain', align: 'center', width: 20, ellipsis: true },
  431. { title: 'Port', dataIndex: 'port', align: 'center', width: 10, ellipsis: true }]},
  432. { title: '{{ i18n "pages.xray.rules.inbound"}}', children: [
  433. { title: 'Inbound Tag', dataIndex: 'inboundTag', align: 'center', width: 20, ellipsis: true },
  434. { title: 'Client Email', dataIndex: 'user', align: 'center', width: 20, ellipsis: true }]},
  435. { title: '{{ i18n "pages.xray.rules.outbound"}}', dataIndex: 'outboundTag', align: 'center', width: 20 },
  436. ];
  437. const rulesMobileColumns = [
  438. { title: "#", align: 'center', width: 20, scopedSlots: { customRender: 'action' } },
  439. { title: '{{ i18n "pages.xray.rules.inbound"}}', align: 'center', width: 50, ellipsis: true, scopedSlots: { customRender: 'inbound' } },
  440. { title: '{{ i18n "pages.xray.rules.outbound"}}', align: 'center', width: 50, ellipsis: true, scopedSlots: { customRender: 'outbound' } },
  441. { title: '{{ i18n "pages.xray.rules.info"}}', align: 'center', width: 50, ellipsis: true, scopedSlots: { customRender: 'info' } },
  442. ];
  443. const outboundColumns = [
  444. { title: "#", align: 'center', width: 20, scopedSlots: { customRender: 'action' } },
  445. { title: '{{ i18n "pages.xray.outbound.tag"}}', dataIndex: 'tag', align: 'center', width: 50 },
  446. { title: '{{ i18n "protocol"}}', align: 'center', width: 50, scopedSlots: { customRender: 'protocol' } },
  447. { title: '{{ i18n "pages.xray.outbound.address"}}', align: 'center', width: 50, scopedSlots: { customRender: 'address' } },
  448. ];
  449. const reverseColumns = [
  450. { title: "#", align: 'center', width: 20, scopedSlots: { customRender: 'action' } },
  451. { title: '{{ i18n "pages.xray.outbound.type"}}', dataIndex: 'type', align: 'center', width: 50 },
  452. { title: '{{ i18n "pages.xray.outbound.tag"}}', dataIndex: 'tag', align: 'center', width: 50 },
  453. { title: '{{ i18n "pages.xray.outbound.domain"}}', dataIndex: 'domain', align: 'center', width: 50 },
  454. ];
  455. const app = new Vue({
  456. delimiters: ['[[', ']]'],
  457. el: '#app',
  458. data: {
  459. siderDrawer,
  460. themeSwitcher,
  461. isDarkTheme: themeSwitcher.isDarkTheme,
  462. spinning: false,
  463. oldXraySetting: '',
  464. xraySetting: '',
  465. inboundTags: [],
  466. saveBtnDisable: true,
  467. restartResult: '',
  468. isMobile: window.innerWidth <= 768,
  469. advSettings: 'xraySetting',
  470. cm: null,
  471. cmOptions: {
  472. lineNumbers: true,
  473. mode: "application/json",
  474. lint: true,
  475. styleActiveLine: true,
  476. matchBrackets: true,
  477. theme: "xq",
  478. autoCloseTags: true,
  479. lineWrapping: true,
  480. indentUnit: 2,
  481. indentWithTabs: true,
  482. smartIndent: true,
  483. tabSize: 2,
  484. lineWiseCopyCut: false,
  485. foldGutter: true,
  486. gutters: [
  487. "CodeMirror-lint-markers",
  488. "CodeMirror-linenumbers",
  489. "CodeMirror-foldgutter",
  490. ],
  491. },
  492. ipv4Settings: {
  493. tag: "IPv4",
  494. protocol: "freedom",
  495. settings: {
  496. domainStrategy: "UseIPv4"
  497. }
  498. },
  499. warpSettings: {
  500. tag: "WARP",
  501. protocol: "socks",
  502. settings: {
  503. servers: [
  504. {
  505. address: "127.0.0.1",
  506. port: 40000
  507. }
  508. ]
  509. }
  510. },
  511. directSettings: {
  512. tag: "direct",
  513. protocol: "freedom"
  514. },
  515. OutboundDomainStrategies: ["AsIs", "UseIP", "UseIPv4", "UseIPv6"],
  516. routingDomainStrategies: ["AsIs", "IPIfNonMatch", "IPOnDemand"],
  517. settingsData: {
  518. protocols: {
  519. bittorrent: ["bittorrent"],
  520. },
  521. ips: {
  522. local: ["geoip:private"],
  523. cn: ["geoip:cn"],
  524. ir: ["ext:geoip_IR.dat:ir"],
  525. ru: ["geoip:ru"],
  526. vn: ["ext:geoip_VN.dat:vn"],
  527. },
  528. domains: {
  529. ads: [
  530. "geosite:category-ads-all",
  531. "ext:geosite_IR.dat:category-ads-all"
  532. ],
  533. security: [
  534. "ext:geosite_IR.dat:malware",
  535. "ext:geosite_IR.dat:phishing",
  536. "ext:geosite_IR.dat:cryptominers"
  537. ],
  538. speedtest: ["geosite:speedtest"],
  539. openai: ["geosite:openai"],
  540. google: ["geosite:google"],
  541. spotify: ["geosite:spotify"],
  542. netflix: ["geosite:netflix"],
  543. cn: [
  544. "geosite:cn",
  545. "regexp:.*\\.cn$"
  546. ],
  547. ru: [
  548. "geosite:category-gov-ru",
  549. "regexp:.*\\.ru$"
  550. ],
  551. ir: [
  552. "regexp:.*\\.ir$",
  553. "regexp:.*\\.xn--mgba3a4f16a$", // .ایران
  554. "ext:geosite_IR.dat:ir"
  555. ],
  556. vn: [
  557. "regexp:.*\\.vn$",
  558. "ext:geosite_VN.dat:vn",
  559. "ext:geosite_VN.dat:ads"
  560. ]
  561. },
  562. familyProtectDNS: {
  563. "servers": [
  564. "1.1.1.3", // https://developers.cloudflare.com/1.1.1.1/setup/
  565. "1.0.0.3"
  566. ],
  567. "queryStrategy": "UseIPv4"
  568. },
  569. }
  570. },
  571. methods: {
  572. loading(spinning = true) {
  573. this.spinning = spinning;
  574. },
  575. async getXraySetting() {
  576. this.loading(true);
  577. const msg = await HttpUtil.post("/panel/xray/");
  578. this.loading(false);
  579. if (msg.success) {
  580. result = JSON.parse(msg.obj);
  581. xs = JSON.stringify(result.xraySetting, null, 2);
  582. this.oldXraySetting = xs;
  583. this.xraySetting = xs;
  584. this.inboundTags = result.inboundTags;
  585. this.saveBtnDisable = true;
  586. }
  587. },
  588. async updateXraySetting() {
  589. this.loading(true);
  590. const msg = await HttpUtil.post("/panel/xray/update", {xraySetting : this.xraySetting});
  591. this.loading(false);
  592. if (msg.success) {
  593. await this.getXraySetting();
  594. }
  595. },
  596. async restartXray() {
  597. this.loading(true);
  598. const msg = await HttpUtil.post("server/restartXrayService");
  599. this.loading(false);
  600. if (msg.success) {
  601. await PromiseUtil.sleep(500);
  602. await this.getXrayResult();
  603. }
  604. this.loading(false);
  605. },
  606. async getXrayResult() {
  607. const msg = await HttpUtil.get("/panel/xray/getXrayResult");
  608. if(msg.success){
  609. this.restartResult=msg.obj;
  610. if(msg.obj.length > 1) Vue.prototype.$message.error(msg.obj);
  611. }
  612. },
  613. async fetchUserSecret() {
  614. this.loading(true);
  615. const userMessage = await HttpUtil.post("/panel/setting/getUserSecret", this.user);
  616. if (userMessage.success) {
  617. this.user = userMessage.obj;
  618. }
  619. this.loading(false);
  620. },
  621. async updateSecret() {
  622. this.loading(true);
  623. const msg = await HttpUtil.post("/panel/setting/updateUserSecret", this.user);
  624. if (msg.success) {
  625. this.user = msg.obj;
  626. window.location.replace(basePath + "logout");
  627. }
  628. this.loading(false);
  629. await this.updateXraySetting();
  630. },
  631. generateRandomString(length) {
  632. var chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
  633. let randomString = "";
  634. for (let i = 0; i < length; i++) {
  635. randomString += chars[Math.floor(Math.random() * chars.length)];
  636. }
  637. return randomString;
  638. },
  639. async getNewSecret() {
  640. this.loading(true);
  641. await PromiseUtil.sleep(600);
  642. const newSecret = this.generateRandomString(64);
  643. this.user.loginSecret = newSecret;
  644. document.getElementById("token").textContent = newSecret;
  645. this.loading(false);
  646. },
  647. async toggleToken(value) {
  648. if (value) {
  649. await this.getNewSecret();
  650. } else {
  651. this.user.loginSecret = "";
  652. }
  653. },
  654. async resetXrayConfigToDefault() {
  655. this.loading(true);
  656. const msg = await HttpUtil.get("/panel/setting/getDefaultJsonConfig");
  657. this.loading(false);
  658. if (msg.success) {
  659. this.templateSettings = JSON.parse(JSON.stringify(msg.obj, null, 2));
  660. this.saveBtnDisable = true;
  661. }
  662. },
  663. syncRulesWithOutbound(tag, setting) {
  664. const newTemplateSettings = {...this.templateSettings};
  665. const haveRules = newTemplateSettings.routing.rules.some((r) => r?.outboundTag === tag);
  666. const outboundIndex = newTemplateSettings.outbounds.findIndex((o) => o.tag === tag);
  667. if (!haveRules && outboundIndex >= 0) {
  668. newTemplateSettings.outbounds.splice(outboundIndex, 1);
  669. }
  670. if (haveRules && outboundIndex === -1) {
  671. newTemplateSettings.outbounds.push(setting);
  672. }
  673. this.templateSettings = newTemplateSettings;
  674. },
  675. templateRuleGetter(routeSettings) {
  676. const { property, outboundTag } = routeSettings;
  677. let result = [];
  678. if (this.templateSettings != null) {
  679. this.templateSettings.routing.rules.forEach(
  680. (routingRule) => {
  681. if (
  682. routingRule.hasOwnProperty(property) &&
  683. routingRule.hasOwnProperty("outboundTag") &&
  684. routingRule.outboundTag === outboundTag
  685. ) {
  686. result.push(...routingRule[property]);
  687. }
  688. }
  689. );
  690. }
  691. return result;
  692. },
  693. templateRuleSetter(routeSettings) {
  694. const { data, property, outboundTag } = routeSettings;
  695. const oldTemplateSettings = this.templateSettings;
  696. const newTemplateSettings = oldTemplateSettings;
  697. currentProperty = this.templateRuleGetter({ outboundTag, property })
  698. if (currentProperty.length == 0) {
  699. const propertyRule = {
  700. type: "field",
  701. outboundTag,
  702. [property]: data
  703. };
  704. newTemplateSettings.routing.rules.push(propertyRule);
  705. }
  706. else {
  707. const newRules = [];
  708. insertedOnce = false;
  709. newTemplateSettings.routing.rules.forEach(
  710. (routingRule) => {
  711. if (
  712. routingRule.hasOwnProperty(property) &&
  713. routingRule.hasOwnProperty("outboundTag") &&
  714. routingRule.outboundTag === outboundTag
  715. ) {
  716. if (!insertedOnce && data.length > 0) {
  717. insertedOnce = true;
  718. routingRule[property] = data;
  719. newRules.push(routingRule);
  720. }
  721. }
  722. else {
  723. newRules.push(routingRule);
  724. }
  725. }
  726. );
  727. newTemplateSettings.routing.rules = newRules;
  728. }
  729. this.templateSettings = newTemplateSettings;
  730. },
  731. changeCode() {
  732. if(this.cm != null) {
  733. this.cm.toTextArea();
  734. }
  735. textAreaObj = document.getElementById('xraySetting');
  736. textAreaObj.value = this[this.advSettings];
  737. this.cm = CodeMirror.fromTextArea(textAreaObj, this.cmOptions);
  738. this.cm.on('change',editor => {
  739. value = editor.getValue();
  740. if(this.isJsonString(value)){
  741. this[this.advSettings] = value;
  742. }
  743. });
  744. },
  745. isJsonString(str) {
  746. try {
  747. JSON.parse(str);
  748. } catch (e) {
  749. return false;
  750. }
  751. return true;
  752. },
  753. findOutboundAddress(o) {
  754. serverObj = null;
  755. switch(o.protocol){
  756. case Protocols.VMess:
  757. case Protocols.VLESS:
  758. serverObj = o.settings.vnext;
  759. break;
  760. case Protocols.HTTP:
  761. case Protocols.Socks:
  762. case Protocols.Shadowsocks:
  763. case Protocols.Trojan:
  764. serverObj = o.settings.servers;
  765. break;
  766. case Protocols.DNS:
  767. return [o.settings.address + ':' + o.settings.port];
  768. default:
  769. return null;
  770. }
  771. return serverObj ? serverObj.map(obj => obj.address + ':' + obj.port) : null;
  772. },
  773. addOutbound(){
  774. outModal.show({
  775. title: '{{ i18n "pages.xray.outbound.addOutbound"}}',
  776. okText: '{{ i18n "pages.xray.outbound.addOutbound" }}',
  777. confirm: (outbound) => {
  778. outModal.loading();
  779. if(outbound.tag.length > 0){
  780. this.templateSettings.outbounds.push(outbound);
  781. this.outboundSettings = JSON.stringify(this.templateSettings.outbounds);
  782. }
  783. outModal.close();
  784. },
  785. isEdit: false,
  786. tags: this.templateSettings.outbounds.map(obj => obj.tag)
  787. });
  788. },
  789. editOutbound(index){
  790. outModal.show({
  791. title: '{{ i18n "pages.xray.outbound.editOutbound"}} ' + (index+1),
  792. outbound: app.templateSettings.outbounds[index],
  793. confirm: (outbound) => {
  794. outModal.loading();
  795. this.templateSettings.outbounds[index] = outbound;
  796. this.outboundSettings = JSON.stringify(this.templateSettings.outbounds);
  797. outModal.close();
  798. },
  799. isEdit: true,
  800. tags: this.outboundData.filter((o) => o.key != index ).map(obj => obj.tag)
  801. });
  802. },
  803. deleteOutbound(index){
  804. outbounds = this.templateSettings.outbounds;
  805. outbounds.splice(index,1);
  806. this.outboundSettings = JSON.stringify(outbounds);
  807. },
  808. addReverse(){
  809. reverseModal.show({
  810. title: '{{ i18n "pages.xray.outbound.addReverse"}}',
  811. okText: '{{ i18n "pages.xray.outbound.addReverse" }}',
  812. confirm: (reverse, rules) => {
  813. reverseModal.loading();
  814. if(reverse.tag.length > 0){
  815. newTemplateSettings = this.templateSettings;
  816. if(newTemplateSettings.reverse == undefined) newTemplateSettings.reverse = {};
  817. if(newTemplateSettings.reverse[reverse.type+'s'] == undefined) newTemplateSettings.reverse[reverse.type+'s'] = [];
  818. newTemplateSettings.reverse[reverse.type+'s'].push({ tag: reverse.tag, domain: reverse.domain });
  819. this.templateSettings = newTemplateSettings;
  820. // Add related rules
  821. this.templateSettings.routing.rules.push(...rules);
  822. this.routingRuleSettings = JSON.stringify(this.templateSettings.routing.rules);
  823. }
  824. reverseModal.close();
  825. },
  826. isEdit: false
  827. });
  828. },
  829. editReverse(index){
  830. if(this.reverseData[index].type == "bridge") {
  831. oldRules = this.templateSettings.routing.rules.filter(r => r.inboundTag && r.inboundTag[0] == this.reverseData[index].tag);
  832. } else {
  833. oldRules = this.templateSettings.routing.rules.filter(r => r.outboundTag && r.outboundTag == this.reverseData[index].tag);
  834. }
  835. reverseModal.show({
  836. title: '{{ i18n "pages.xray.outbound.editReverse"}} ' + (index+1),
  837. reverse: this.reverseData[index],
  838. rules: oldRules,
  839. confirm: (reverse, rules) => {
  840. reverseModal.loading();
  841. if(reverse.tag.length > 0){
  842. oldData = this.reverseData[index];
  843. newTemplateSettings = this.templateSettings;
  844. oldReverseIndex = newTemplateSettings.reverse[oldData.type+'s'].findIndex(rs => rs.tag == oldData.tag);
  845. oldRuleIndex0 = oldRules.length>0 ? newTemplateSettings.routing.rules.findIndex(r => JSON.stringify(r) == JSON.stringify(oldRules[0])) : -1;
  846. oldRuleIndex1 = oldRules.length==2 ? newTemplateSettings.routing.rules.findIndex(r => JSON.stringify(r) == JSON.stringify(oldRules[1])) : -1;
  847. if(oldData.type == reverse.type){
  848. newTemplateSettings.reverse[oldData.type + 's'][oldReverseIndex] = { tag: reverse.tag, domain: reverse.domain };
  849. } else {
  850. newTemplateSettings.reverse[oldData.type+'s'].splice(oldReverseIndex,1);
  851. // delete empty object
  852. if(newTemplateSettings.reverse[oldData.type+'s'].length == 0) Reflect.deleteProperty(newTemplateSettings.reverse, oldData.type+'s');
  853. // add other type of reverse if it is not exist
  854. if(!newTemplateSettings.reverse[reverse.type+'s']) newTemplateSettings.reverse[reverse.type+'s'] = [];
  855. newTemplateSettings.reverse[reverse.type+'s'].push({ tag: reverse.tag, domain: reverse.domain });
  856. }
  857. this.templateSettings = newTemplateSettings;
  858. // Adjust Rules
  859. newRules = this.templateSettings.routing.rules;
  860. oldRuleIndex0 != -1 ? newRules[oldRuleIndex0] = rules[0] : newRules.push(rules[0]);
  861. oldRuleIndex1 != -1 ? newRules[oldRuleIndex1] = rules[1] : newRules.push(rules[1]);
  862. this.routingRuleSettings = JSON.stringify(newRules);
  863. }
  864. reverseModal.close();
  865. },
  866. isEdit: true
  867. });
  868. },
  869. deleteReverse(index){
  870. oldData = this.reverseData[index];
  871. newTemplateSettings = this.templateSettings;
  872. reverseTypeObj = newTemplateSettings.reverse[oldData.type+'s'];
  873. realIndex = reverseTypeObj.findIndex(r => r.tag==oldData.tag && r.domain==oldData.domain);
  874. newTemplateSettings.reverse[oldData.type+'s'].splice(realIndex,1);
  875. // delete empty objects
  876. if(reverseTypeObj.length == 0) Reflect.deleteProperty(newTemplateSettings.reverse, oldData.type+'s');
  877. if(Object.keys(newTemplateSettings.reverse).length === 0) Reflect.deleteProperty(newTemplateSettings, 'reverse');
  878. // delete related routing rules
  879. newRules = newTemplateSettings.routing.rules;
  880. if(oldData.type == "bridge"){
  881. newRules = newTemplateSettings.routing.rules.filter(r => !( r.inboundTag && r.inboundTag.length == 1 && r.inboundTag[0] == oldData.tag));
  882. } else if(oldData.type == "portal"){
  883. newRules = newTemplateSettings.routing.rules.filter(r => r.outboundTag != oldData.tag);
  884. }
  885. newTemplateSettings.routing.rules = newRules;
  886. this.templateSettings = newTemplateSettings;
  887. },
  888. addRule(){
  889. ruleModal.show({
  890. title: '{{ i18n "pages.xray.rules.add"}}',
  891. okText: '{{ i18n "pages.xray.rules.add" }}',
  892. confirm: (rule) => {
  893. ruleModal.loading();
  894. if(JSON.stringify(rule).length > 3){
  895. this.templateSettings.routing.rules.push(rule);
  896. this.routingRuleSettings = JSON.stringify(this.templateSettings.routing.rules);
  897. }
  898. ruleModal.close();
  899. },
  900. isEdit: false
  901. });
  902. },
  903. editRule(index){
  904. ruleModal.show({
  905. title: '{{ i18n "pages.xray.rules.edit"}} ' + (index+1),
  906. rule: app.templateSettings.routing.rules[index],
  907. confirm: (rule) => {
  908. ruleModal.loading();
  909. if(JSON.stringify(rule).length > 3){
  910. this.templateSettings.routing.rules[index] = rule;
  911. this.routingRuleSettings = JSON.stringify(this.templateSettings.routing.rules);
  912. }
  913. ruleModal.close();
  914. },
  915. isEdit: true
  916. });
  917. },
  918. replaceRule(old_index,new_index){
  919. rules = this.templateSettings.routing.rules;
  920. if (new_index >= rules.length) rules.push(undefined);
  921. rules.splice(new_index, 0, rules.splice(old_index, 1)[0]);
  922. this.routingRuleSettings = JSON.stringify(rules);
  923. },
  924. deleteRule(index){
  925. rules = this.templateSettings.routing.rules;
  926. rules.splice(index,1);
  927. this.routingRuleSettings = JSON.stringify(rules);
  928. }
  929. },
  930. async mounted() {
  931. await this.getXraySetting();
  932. await this.getXrayResult();
  933. while (true) {
  934. await PromiseUtil.sleep(600);
  935. this.saveBtnDisable = this.oldXraySetting === this.xraySetting;
  936. }
  937. },
  938. computed: {
  939. templateSettings: {
  940. get: function () { return this.xraySetting ? JSON.parse(this.xraySetting) : null; },
  941. set: function (newValue) { this.xraySetting = JSON.stringify(newValue, null, 2); },
  942. },
  943. inboundSettings: {
  944. get: function () { return this.templateSettings ? JSON.stringify(this.templateSettings.inbounds, null, 2) : null; },
  945. set: function (newValue) {
  946. newTemplateSettings = this.templateSettings;
  947. newTemplateSettings.inbounds = JSON.parse(newValue);
  948. this.templateSettings = newTemplateSettings;
  949. },
  950. },
  951. outboundSettings: {
  952. get: function () { return this.templateSettings ? JSON.stringify(this.templateSettings.outbounds, null, 2) : null; },
  953. set: function (newValue) {
  954. newTemplateSettings = this.templateSettings;
  955. newTemplateSettings.outbounds = JSON.parse(newValue);
  956. this.templateSettings = newTemplateSettings;
  957. },
  958. },
  959. outboundData: {
  960. get: function () {
  961. data = []
  962. if (this.templateSettings != null) {
  963. this.templateSettings.outbounds.forEach((o, index) => {
  964. data.push({'key': index, ...o});
  965. });
  966. }
  967. return data;
  968. },
  969. },
  970. reverseData: {
  971. get: function () {
  972. data = []
  973. if (this.templateSettings != null && this.templateSettings.reverse != null) {
  974. if(this.templateSettings.reverse.bridges) {
  975. this.templateSettings.reverse.bridges.forEach((o, index) => {
  976. data.push({'key': index, 'type':'bridge', ...o});
  977. });
  978. }
  979. if(this.templateSettings.reverse.portals){
  980. this.templateSettings.reverse.portals.forEach((o, index) => {
  981. data.push({'key': index, 'type':'portal', ...o});
  982. });
  983. }
  984. }
  985. return data;
  986. },
  987. },
  988. routingRuleSettings: {
  989. get: function () { return this.templateSettings ? JSON.stringify(this.templateSettings.routing.rules, null, 2) : null; },
  990. set: function (newValue) {
  991. newTemplateSettings = this.templateSettings;
  992. newTemplateSettings.routing.rules = JSON.parse(newValue);
  993. this.templateSettings = newTemplateSettings;
  994. },
  995. },
  996. routingRuleData: {
  997. get: function () {
  998. data = [];
  999. if (this.templateSettings != null) {
  1000. this.templateSettings.routing.rules.forEach((r, index) => {
  1001. data.push({'key': index, ...r});
  1002. });
  1003. // Make rules readable
  1004. data.forEach(r => {
  1005. if(r.domain) r.domain = r.domain.join(',')
  1006. if(r.ip) r.ip = r.ip.join(',')
  1007. if(r.source) r.source = r.source.join(',');
  1008. if(r.user) r.user = r.user.join(',')
  1009. if(r.inboundTag) r.inboundTag = r.inboundTag.join(',')
  1010. if(r.protocol) r.protocol = r.protocol.join(',')
  1011. if(r.attrs) r.attrs = JSON.stringify(r.attrs, null, 2)
  1012. });
  1013. }
  1014. return data;
  1015. }
  1016. },
  1017. freedomStrategy: {
  1018. get: function () {
  1019. if (!this.templateSettings) return "AsIs";
  1020. freedomOutbound = this.templateSettings.outbounds.find((o) => o.protocol === "freedom" && o.tag == "direct");
  1021. if (!freedomOutbound) return "AsIs";
  1022. if (!freedomOutbound.settings || !freedomOutbound.settings.domainStrategy) return "AsIs";
  1023. return freedomOutbound.settings.domainStrategy;
  1024. },
  1025. set: function (newValue) {
  1026. newTemplateSettings = this.templateSettings;
  1027. freedomOutboundIndex = newTemplateSettings.outbounds.findIndex((o) => o.protocol === "freedom" && o.tag == "direct");
  1028. if(freedomOutboundIndex == -1){
  1029. newTemplateSettings.outbounds.push({protocol: "freedom", tag: "direct", settings: { "domainStrategy": newValue }});
  1030. } else if (!newTemplateSettings.outbounds[freedomOutboundIndex].settings) {
  1031. newTemplateSettings.outbounds[freedomOutboundIndex].settings = {"domainStrategy": newValue};
  1032. } else {
  1033. newTemplateSettings.outbounds[freedomOutboundIndex].settings.domainStrategy = newValue;
  1034. }
  1035. this.templateSettings = newTemplateSettings;
  1036. }
  1037. },
  1038. routingStrategy: {
  1039. get: function () {
  1040. if (!this.templateSettings || !this.templateSettings.routing || !this.templateSettings.routing.domainStrategy) return "AsIs";
  1041. return this.templateSettings.routing.domainStrategy;
  1042. },
  1043. set: function (newValue) {
  1044. newTemplateSettings = this.templateSettings;
  1045. newTemplateSettings.routing.domainStrategy = newValue;
  1046. this.templateSettings = newTemplateSettings;
  1047. }
  1048. },
  1049. blockedIPs: {
  1050. get: function () {
  1051. return this.templateRuleGetter({ outboundTag: "blocked", property: "ip" });
  1052. },
  1053. set: function (newValue) {
  1054. this.templateRuleSetter({ outboundTag: "blocked", property: "ip", data: newValue });
  1055. }
  1056. },
  1057. blockedDomains: {
  1058. get: function () {
  1059. return this.templateRuleGetter({ outboundTag: "blocked", property: "domain" });
  1060. },
  1061. set: function (newValue) {
  1062. this.templateRuleSetter({ outboundTag: "blocked", property: "domain", data: newValue });
  1063. }
  1064. },
  1065. blockedProtocols: {
  1066. get: function () {
  1067. return this.templateRuleGetter({ outboundTag: "blocked", property: "protocol" });
  1068. },
  1069. set: function (newValue) {
  1070. this.templateRuleSetter({ outboundTag: "blocked", property: "protocol", data: newValue });
  1071. }
  1072. },
  1073. directIPs: {
  1074. get: function () {
  1075. return this.templateRuleGetter({ outboundTag: "direct", property: "ip" });
  1076. },
  1077. set: function (newValue) {
  1078. this.templateRuleSetter({ outboundTag: "direct", property: "ip", data: newValue });
  1079. this.syncRulesWithOutbound("direct", this.directSettings);
  1080. }
  1081. },
  1082. directDomains: {
  1083. get: function () {
  1084. return this.templateRuleGetter({ outboundTag: "direct", property: "domain" });
  1085. },
  1086. set: function (newValue) {
  1087. this.templateRuleSetter({ outboundTag: "direct", property: "domain", data: newValue });
  1088. this.syncRulesWithOutbound("direct", this.directSettings);
  1089. }
  1090. },
  1091. ipv4Domains: {
  1092. get: function () {
  1093. return this.templateRuleGetter({ outboundTag: "IPv4", property: "domain" });
  1094. },
  1095. set: function (newValue) {
  1096. this.templateRuleSetter({ outboundTag: "IPv4", property: "domain", data: newValue });
  1097. this.syncRulesWithOutbound("IPv4", this.ipv4Settings);
  1098. }
  1099. },
  1100. warpDomains: {
  1101. get: function () {
  1102. return this.templateRuleGetter({ outboundTag: "WARP", property: "domain" });
  1103. },
  1104. set: function (newValue) {
  1105. this.templateRuleSetter({ outboundTag: "WARP", property: "domain", data: newValue });
  1106. this.syncRulesWithOutbound("WARP", this.warpSettings);
  1107. }
  1108. },
  1109. manualBlockedIPs: {
  1110. get: function () { return JSON.stringify(this.blockedIPs, null, 2); },
  1111. set: debounce(function (value) { this.blockedIPs = JSON.parse(value); }, 1000)
  1112. },
  1113. manualBlockedDomains: {
  1114. get: function () { return JSON.stringify(this.blockedDomains, null, 2); },
  1115. set: debounce(function (value) { this.blockedDomains = JSON.parse(value); }, 1000)
  1116. },
  1117. manualDirectIPs: {
  1118. get: function () { return JSON.stringify(this.directIPs, null, 2); },
  1119. set: debounce(function (value) { this.directIPs = JSON.parse(value); }, 1000)
  1120. },
  1121. manualDirectDomains: {
  1122. get: function () { return JSON.stringify(this.directDomains, null, 2); },
  1123. set: debounce(function (value) { this.directDomains = JSON.parse(value); }, 1000)
  1124. },
  1125. manualIPv4Domains: {
  1126. get: function () { return JSON.stringify(this.ipv4Domains, null, 2); },
  1127. set: debounce(function (value) { this.ipv4Domains = JSON.parse(value); }, 1000)
  1128. },
  1129. manualWARPDomains: {
  1130. get: function () { return JSON.stringify(this.warpDomains, null, 2); },
  1131. set: debounce(function (value) { this.warpDomains = JSON.parse(value); }, 1000)
  1132. },
  1133. torrentSettings: {
  1134. get: function () {
  1135. return doAllItemsExist(this.settingsData.protocols.bittorrent, this.blockedProtocols);
  1136. },
  1137. set: function (newValue) {
  1138. if (newValue) {
  1139. this.blockedProtocols = [...this.blockedProtocols, ...this.settingsData.protocols.bittorrent];
  1140. } else {
  1141. this.blockedProtocols = this.blockedProtocols.filter(data => !this.settingsData.protocols.bittorrent.includes(data));
  1142. }
  1143. },
  1144. },
  1145. privateIpSettings: {
  1146. get: function () {
  1147. return doAllItemsExist(this.settingsData.ips.local, this.blockedIPs);
  1148. },
  1149. set: function (newValue) {
  1150. if (newValue) {
  1151. this.blockedIPs = [...this.blockedIPs, ...this.settingsData.ips.local];
  1152. } else {
  1153. this.blockedIPs = this.blockedIPs.filter(data => !this.settingsData.ips.local.includes(data));
  1154. }
  1155. },
  1156. },
  1157. AdsSettings: {
  1158. get: function () {
  1159. return doAllItemsExist(this.settingsData.domains.ads, this.blockedDomains);
  1160. },
  1161. set: function (newValue) {
  1162. if (newValue) {
  1163. this.blockedDomains = [...this.blockedDomains, ...this.settingsData.domains.ads];
  1164. } else {
  1165. this.blockedDomains = this.blockedDomains.filter(data => !this.settingsData.domains.ads.includes(data));
  1166. }
  1167. },
  1168. },
  1169. SecuritySettings: {
  1170. get: function () {
  1171. return doAllItemsExist(this.settingsData.domains.security, this.blockedDomains);
  1172. },
  1173. set: function (newValue) {
  1174. if (newValue) {
  1175. this.blockedDomains = [...this.blockedDomains, ...this.settingsData.domains.security];
  1176. } else {
  1177. this.blockedDomains = this.blockedDomains.filter(data => !this.settingsData.domains.security.includes(data));
  1178. }
  1179. },
  1180. },
  1181. SpeedTestSettings: {
  1182. get: function () {
  1183. return doAllItemsExist(this.settingsData.domains.speedtest, this.blockedDomains);
  1184. },
  1185. set: function (newValue) {
  1186. if (newValue) {
  1187. this.blockedDomains = [...this.blockedDomains, ...this.settingsData.domains.speedtest];
  1188. } else {
  1189. this.blockedDomains = this.blockedDomains.filter(data => !this.settingsData.domains.speedtest.includes(data));
  1190. }
  1191. },
  1192. },
  1193. familyProtectSettings: {
  1194. get: function () {
  1195. if (!this.templateSettings || !this.templateSettings.dns || !this.templateSettings.dns.servers) return false;
  1196. return doAllItemsExist(this.templateSettings.dns.servers, this.settingsData.familyProtectDNS.servers);
  1197. },
  1198. set: function (newValue) {
  1199. newTemplateSettings = this.templateSettings;
  1200. if (newValue) {
  1201. newTemplateSettings.dns = this.settingsData.familyProtectDNS;
  1202. } else {
  1203. delete newTemplateSettings.dns;
  1204. }
  1205. this.templateSettings = newTemplateSettings;
  1206. },
  1207. },
  1208. GoogleIPv4Settings: {
  1209. get: function () {
  1210. return doAllItemsExist(this.settingsData.domains.google, this.ipv4Domains);
  1211. },
  1212. set: function (newValue) {
  1213. if (newValue) {
  1214. this.ipv4Domains = [...this.ipv4Domains, ...this.settingsData.domains.google];
  1215. } else {
  1216. this.ipv4Domains = this.ipv4Domains.filter(data => !this.settingsData.domains.google.includes(data));
  1217. }
  1218. },
  1219. },
  1220. NetflixIPv4Settings: {
  1221. get: function () {
  1222. return doAllItemsExist(this.settingsData.domains.netflix, this.ipv4Domains);
  1223. },
  1224. set: function (newValue) {
  1225. if (newValue) {
  1226. this.ipv4Domains = [...this.ipv4Domains, ...this.settingsData.domains.netflix];
  1227. } else {
  1228. this.ipv4Domains = this.ipv4Domains.filter(data => !this.settingsData.domains.netflix.includes(data));
  1229. }
  1230. },
  1231. },
  1232. IRIpSettings: {
  1233. get: function () {
  1234. return doAllItemsExist(this.settingsData.ips.ir, this.blockedIPs);
  1235. },
  1236. set: function (newValue) {
  1237. if (newValue) {
  1238. this.blockedIPs = [...this.blockedIPs, ...this.settingsData.ips.ir];
  1239. } else {
  1240. this.blockedIPs = this.blockedIPs.filter(data => !this.settingsData.ips.ir.includes(data));
  1241. }
  1242. }
  1243. },
  1244. IRDomainSettings: {
  1245. get: function () {
  1246. return doAllItemsExist(this.settingsData.domains.ir, this.blockedDomains);
  1247. },
  1248. set: function (newValue) {
  1249. if (newValue) {
  1250. this.blockedDomains = [...this.blockedDomains, ...this.settingsData.domains.ir];
  1251. } else {
  1252. this.blockedDomains = this.blockedDomains.filter(data => !this.settingsData.domains.ir.includes(data));
  1253. }
  1254. }
  1255. },
  1256. ChinaIpSettings: {
  1257. get: function () {
  1258. return doAllItemsExist(this.settingsData.ips.cn, this.blockedIPs);
  1259. },
  1260. set: function (newValue) {
  1261. if (newValue) {
  1262. this.blockedIPs = [...this.blockedIPs, ...this.settingsData.ips.cn];
  1263. } else {
  1264. this.blockedIPs = this.blockedIPs.filter(data => !this.settingsData.ips.cn.includes(data));
  1265. }
  1266. }
  1267. },
  1268. ChinaDomainSettings: {
  1269. get: function () {
  1270. return doAllItemsExist(this.settingsData.domains.cn, this.blockedDomains);
  1271. },
  1272. set: function (newValue) {
  1273. if (newValue) {
  1274. this.blockedDomains = [...this.blockedDomains, ...this.settingsData.domains.cn];
  1275. } else {
  1276. this.blockedDomains = this.blockedDomains.filter(data => !this.settingsData.domains.cn.includes(data));
  1277. }
  1278. }
  1279. },
  1280. RussiaIpSettings: {
  1281. get: function () {
  1282. return doAllItemsExist(this.settingsData.ips.ru, this.blockedIPs);
  1283. },
  1284. set: function (newValue) {
  1285. if (newValue) {
  1286. this.blockedIPs = [...this.blockedIPs, ...this.settingsData.ips.ru];
  1287. } else {
  1288. this.blockedIPs = this.blockedIPs.filter(data => !this.settingsData.ips.ru.includes(data));
  1289. }
  1290. }
  1291. },
  1292. RussiaDomainSettings: {
  1293. get: function () {
  1294. return doAllItemsExist(this.settingsData.domains.ru, this.blockedDomains);
  1295. },
  1296. set: function (newValue) {
  1297. if (newValue) {
  1298. this.blockedDomains = [...this.blockedDomains, ...this.settingsData.domains.ru];
  1299. } else {
  1300. this.blockedDomains = this.blockedDomains.filter(data => !this.settingsData.domains.ru.includes(data));
  1301. }
  1302. }
  1303. },
  1304. VNIpSettings: {
  1305. get: function () {
  1306. return doAllItemsExist(this.settingsData.ips.vn, this.blockedIPs);
  1307. },
  1308. set: function (newValue) {
  1309. if (newValue) {
  1310. this.blockedIPs = [...this.blockedIPs, ...this.settingsData.ips.vn];
  1311. } else {
  1312. this.blockedIPs = this.blockedIPs.filter(data => !this.settingsData.ips.vn.includes(data));
  1313. }
  1314. }
  1315. },
  1316. VNDomainSettings: {
  1317. get: function () {
  1318. return doAllItemsExist(this.settingsData.domains.vn, this.blockedDomains);
  1319. },
  1320. set: function (newValue) {
  1321. if (newValue) {
  1322. this.blockedDomains = [...this.blockedDomains, ...this.settingsData.domains.vn];
  1323. } else {
  1324. this.blockedDomains = this.blockedDomains.filter(data => !this.settingsData.domains.vn.includes(data));
  1325. }
  1326. }
  1327. },
  1328. IRIpDirectSettings: {
  1329. get: function () {
  1330. return doAllItemsExist(this.settingsData.ips.ir, this.directIPs);
  1331. },
  1332. set: function (newValue) {
  1333. if (newValue) {
  1334. this.directIPs = [...this.directIPs, ...this.settingsData.ips.ir];
  1335. } else {
  1336. this.directIPs = this.directIPs.filter(data => !this.settingsData.ips.ir.includes(data));
  1337. }
  1338. }
  1339. },
  1340. IRDomainDirectSettings: {
  1341. get: function () {
  1342. return doAllItemsExist(this.settingsData.domains.ir, this.directDomains);
  1343. },
  1344. set: function (newValue) {
  1345. if (newValue) {
  1346. this.directDomains = [...this.directDomains, ...this.settingsData.domains.ir];
  1347. } else {
  1348. this.directDomains = this.directDomains.filter(data => !this.settingsData.domains.ir.includes(data));
  1349. }
  1350. }
  1351. },
  1352. ChinaIpDirectSettings: {
  1353. get: function () {
  1354. return doAllItemsExist(this.settingsData.ips.cn, this.directIPs);
  1355. },
  1356. set: function (newValue) {
  1357. if (newValue) {
  1358. this.directIPs = [...this.directIPs, ...this.settingsData.ips.cn];
  1359. } else {
  1360. this.directIPs = this.directIPs.filter(data => !this.settingsData.ips.cn.includes(data));
  1361. }
  1362. }
  1363. },
  1364. ChinaDomainDirectSettings: {
  1365. get: function () {
  1366. return doAllItemsExist(this.settingsData.domains.cn, this.directDomains);
  1367. },
  1368. set: function (newValue) {
  1369. if (newValue) {
  1370. this.directDomains = [...this.directDomains, ...this.settingsData.domains.cn];
  1371. } else {
  1372. this.directDomains = this.directDomains.filter(data => !this.settingsData.domains.cn.includes(data));
  1373. }
  1374. }
  1375. },
  1376. RussiaIpDirectSettings: {
  1377. get: function () {
  1378. return doAllItemsExist(this.settingsData.ips.ru, this.directIPs);
  1379. },
  1380. set: function (newValue) {
  1381. if (newValue) {
  1382. this.directIPs = [...this.directIPs, ...this.settingsData.ips.ru];
  1383. } else {
  1384. this.directIPs = this.directIPs.filter(data => !this.settingsData.ips.ru.includes(data));
  1385. }
  1386. }
  1387. },
  1388. RussiaDomainDirectSettings: {
  1389. get: function () {
  1390. return doAllItemsExist(this.settingsData.domains.ru, this.directDomains);
  1391. },
  1392. set: function (newValue) {
  1393. if (newValue) {
  1394. this.directDomains = [...this.directDomains, ...this.settingsData.domains.ru];
  1395. } else {
  1396. this.directDomains = this.directDomains.filter(data => !this.settingsData.domains.ru.includes(data));
  1397. }
  1398. }
  1399. },
  1400. VNIpDirectSettings: {
  1401. get: function () {
  1402. return doAllItemsExist(this.settingsData.ips.vn, this.directIPs);
  1403. },
  1404. set: function (newValue) {
  1405. if (newValue) {
  1406. this.directIPs = [...this.directIPs, ...this.settingsData.ips.vn];
  1407. } else {
  1408. this.directIPs = this.directIPs.filter(data => !this.settingsData.ips.vn.includes(data));
  1409. }
  1410. }
  1411. },
  1412. VNDomainDirectSettings: {
  1413. get: function () {
  1414. return doAllItemsExist(this.settingsData.domains.vn, this.directDomains);
  1415. },
  1416. set: function (newValue) {
  1417. if (newValue) {
  1418. this.directDomains = [...this.directDomains, ...this.settingsData.domains.vn];
  1419. } else {
  1420. this.directDomains = this.directDomains.filter(data => !this.settingsData.domains.vn.includes(data));
  1421. }
  1422. }
  1423. },
  1424. GoogleWARPSettings: {
  1425. get: function () {
  1426. return doAllItemsExist(this.settingsData.domains.google, this.warpDomains);
  1427. },
  1428. set: function (newValue) {
  1429. if (newValue) {
  1430. this.warpDomains = [...this.warpDomains, ...this.settingsData.domains.google];
  1431. } else {
  1432. this.warpDomains = this.warpDomains.filter(data => !this.settingsData.domains.google.includes(data));
  1433. }
  1434. },
  1435. },
  1436. OpenAIWARPSettings: {
  1437. get: function () {
  1438. return doAllItemsExist(this.settingsData.domains.openai, this.warpDomains);
  1439. },
  1440. set: function (newValue) {
  1441. if (newValue) {
  1442. this.warpDomains = [...this.warpDomains, ...this.settingsData.domains.openai];
  1443. } else {
  1444. this.warpDomains = this.warpDomains.filter(data => !this.settingsData.domains.openai.includes(data));
  1445. }
  1446. },
  1447. },
  1448. NetflixWARPSettings: {
  1449. get: function () {
  1450. return doAllItemsExist(this.settingsData.domains.netflix, this.warpDomains);
  1451. },
  1452. set: function (newValue) {
  1453. if (newValue) {
  1454. this.warpDomains = [...this.warpDomains, ...this.settingsData.domains.netflix];
  1455. } else {
  1456. this.warpDomains = this.warpDomains.filter(data => !this.settingsData.domains.netflix.includes(data));
  1457. }
  1458. },
  1459. },
  1460. SpotifyWARPSettings: {
  1461. get: function () {
  1462. return doAllItemsExist(this.settingsData.domains.spotify, this.warpDomains);
  1463. },
  1464. set: function (newValue) {
  1465. if (newValue) {
  1466. this.warpDomains = [...this.warpDomains, ...this.settingsData.domains.spotify];
  1467. } else {
  1468. this.warpDomains = this.warpDomains.filter(data => !this.settingsData.domains.spotify.includes(data));
  1469. }
  1470. },
  1471. },
  1472. },
  1473. });
  1474. </script>
  1475. </body>
  1476. </html>