xray.html 84 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496
  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-4') 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()">{{ i18n "pages.xray.outbound.addOutbound" }}</a-button>
  331. <a-button type="primary" icon="plus" @click="addReverse()">{{ i18n "pages.xray.outbound.addReverse" }}</a-button>
  332. <a-row>
  333. <a-col :sm="24" :md="12">
  334. <p style="margin: 10px;">{{ i18n "pages.xray.Outbounds"}}</p>
  335. <a-table :columns="outboundColumns" bordered
  336. :row-key="r => r.key"
  337. :data-source="outboundData"
  338. :scroll="isMobile ? {} : { x: 200 }"
  339. :pagination="false"
  340. :indent-size="0"
  341. :style="isMobile ? 'padding: 5px 5px' : 'margin-right: 1px;'">
  342. <template slot="action" slot-scope="text, outbound, index">
  343. [[ index+1 ]]
  344. <a-dropdown :trigger="['click']">
  345. <a-icon @click="e => e.preventDefault()" type="more" style="font-size: 16px; text-decoration: bold;"></a-icon>
  346. <a-menu slot="overlay" :theme="themeSwitcher.currentTheme">
  347. <a-menu-item @click="editOutbound(index)">
  348. <a-icon type="edit"></a-icon>
  349. {{ i18n "edit" }}
  350. </a-menu-item>
  351. <a-menu-item @click="deleteOutbound(index)">
  352. <span style="color: #FF4D4F">
  353. <a-icon type="delete"></a-icon> {{ i18n "delete"}}
  354. </span>
  355. </a-menu-item>
  356. </a-menu>
  357. </a-dropdown>
  358. </template>
  359. <template slot="address" slot-scope="text, outbound, index">
  360. <p style="margin: 0 5px;" v-for="addr in findOutboundAddress(outbound)">[[ addr ]]</p>
  361. </template>
  362. <template slot="protocol" slot-scope="text, outbound, index">
  363. <a-tag style="margin:0;" color="purple">[[ outbound.protocol ]]</a-tag>
  364. <template v-if="[Protocols.VMess, Protocols.VLESS, Protocols.Trojan, Protocols.Shadowsocks].includes(outbound.protocol)">
  365. <a-tag style="margin:0;" color="blue">[[ outbound.streamSettings.network ]]</a-tag>
  366. <a-tag style="margin:0;" v-if="outbound.streamSettings.security=='tls'" color="green">tls</a-tag>
  367. <a-tag style="margin:0;" v-if="outbound.streamSettings.security=='reality'" color="green">reality</a-tag>
  368. </template>
  369. </template>
  370. </a-table>
  371. </a-col>
  372. <a-col :sm="24" :md="12" v-if="reverseData.length>0">
  373. <p style="margin: 10px;">{{ i18n "pages.xray.outbound.reverse"}}</p>
  374. <a-table :columns="reverseColumns" bordered
  375. :row-key="r => r.key"
  376. :data-source="reverseData"
  377. :scroll="isMobile ? {} : { x: 200 }"
  378. :pagination="false"
  379. :indent-size="0"
  380. :style="isMobile ? 'padding: 5px 0' : 'margin-left: 1px;'">
  381. <template slot="action" slot-scope="text, reverse, index">
  382. [[ index+1 ]]
  383. <a-dropdown :trigger="['click']">
  384. <a-icon @click="e => e.preventDefault()" type="more" style="font-size: 16px; text-decoration: bold;"></a-icon>
  385. <a-menu slot="overlay" :theme="themeSwitcher.currentTheme">
  386. <a-menu-item @click="editReverse(index)">
  387. <a-icon type="edit"></a-icon>
  388. {{ i18n "edit" }}
  389. </a-menu-item>
  390. <a-menu-item @click="deleteReverse(index)">
  391. <span style="color: #FF4D4F">
  392. <a-icon type="delete"></a-icon> {{ i18n "delete"}}
  393. </span>
  394. </a-menu-item>
  395. </a-menu>
  396. </a-dropdown>
  397. </template>
  398. </a-table>
  399. </a-col>
  400. </a-row>
  401. </a-tab-pane>
  402. <a-tab-pane key="tpl-4" tab='{{ i18n "pages.xray.advancedTemplate"}}' style="padding-top: 20px;" force-render="true">
  403. <a-list-item-meta title='{{ i18n "pages.xray.Template"}}' description='{{ i18n "pages.xray.TemplateDesc"}}'></a-list-item-meta>
  404. <a-radio-group v-model="advSettings" @change="changeCode" button-style="solid" style="margin: 10px 0;" :size="isMobile ? 'small' : ''">
  405. <a-radio-button value="xraySetting">{{ i18n "pages.xray.completeTemplate"}}</a-radio-button>
  406. <a-radio-button value="inboundSettings">{{ i18n "pages.xray.Inbounds" }}</a-radio-button>
  407. <a-radio-button value="outboundSettings">{{ i18n "pages.xray.Outbounds" }}</a-radio-button>
  408. <a-radio-button value="routingRuleSettings">{{ i18n "pages.xray.Routings" }}</a-radio-button>
  409. </a-radio-group>
  410. <textarea style="position:absolute; left: -800px;" id="xraySetting"></textarea>
  411. </a-tab-pane>
  412. </a-tabs>
  413. </a-space>
  414. </a-spin>
  415. </a-layout-content>
  416. </a-layout>
  417. </a-layout>
  418. {{template "js" .}}
  419. {{template "component/themeSwitcher" .}}
  420. {{template "component/setting"}}
  421. {{template "ruleModal"}}
  422. {{template "outModal"}}
  423. {{template "reverseModal"}}
  424. <script>
  425. const rulesColumns = [
  426. { title: "#", align: 'center', width: 15, scopedSlots: { customRender: 'action' } },
  427. { title: '{{ i18n "pages.xray.rules.source"}}', children: [
  428. { title: 'IP', dataIndex: "source", align: 'center', width: 20, ellipsis: true },
  429. { title: 'port', dataIndex: 'sourcePort', align: 'center', width: 10, ellipsis: true } ]},
  430. { title: '{{ i18n "pages.inbounds.network"}}', children: [
  431. { title: 'L4', dataIndex: 'network', align: 'center', width: 10 },
  432. { title: 'Protocol', dataIndex: 'protocol', align: 'center', width: 10, ellipsis: true },
  433. { title: 'Attrs', dataIndex: 'attrs', align: 'center', width: 20, ellipsis: true } ]},
  434. { title: '{{ i18n "pages.xray.rules.dest"}}', children: [
  435. { title: 'IP', dataIndex: 'ip', align: 'center', width: 20, ellipsis: true },
  436. { title: 'Domain', dataIndex: 'domain', align: 'center', width: 20, ellipsis: true },
  437. { title: 'Port', dataIndex: 'port', align: 'center', width: 10, ellipsis: true }]},
  438. { title: '{{ i18n "pages.xray.rules.inbound"}}', children: [
  439. { title: 'Inbound Tag', dataIndex: 'inboundTag', align: 'center', width: 20, ellipsis: true },
  440. { title: 'Client Email', dataIndex: 'user', align: 'center', width: 20, ellipsis: true }]},
  441. { title: '{{ i18n "pages.xray.rules.outbound"}}', dataIndex: 'outboundTag', align: 'center', width: 20 },
  442. ];
  443. const rulesMobileColumns = [
  444. { title: "#", align: 'center', width: 20, scopedSlots: { customRender: 'action' } },
  445. { title: '{{ i18n "pages.xray.rules.inbound"}}', align: 'center', width: 50, ellipsis: true, scopedSlots: { customRender: 'inbound' } },
  446. { title: '{{ i18n "pages.xray.rules.outbound"}}', align: 'center', width: 50, ellipsis: true, scopedSlots: { customRender: 'outbound' } },
  447. { title: '{{ i18n "pages.xray.rules.info"}}', align: 'center', width: 50, ellipsis: true, scopedSlots: { customRender: 'info' } },
  448. ];
  449. const outboundColumns = [
  450. { title: "#", align: 'center', width: 20, scopedSlots: { customRender: 'action' } },
  451. { title: '{{ i18n "pages.xray.outbound.tag"}}', dataIndex: 'tag', align: 'center', width: 50 },
  452. { title: '{{ i18n "protocol"}}', align: 'center', width: 50, scopedSlots: { customRender: 'protocol' } },
  453. { title: '{{ i18n "pages.xray.outbound.address"}}', align: 'center', width: 50, scopedSlots: { customRender: 'address' } },
  454. ];
  455. const reverseColumns = [
  456. { title: "#", align: 'center', width: 20, scopedSlots: { customRender: 'action' } },
  457. { title: '{{ i18n "pages.xray.outbound.type"}}', dataIndex: 'type', align: 'center', width: 50 },
  458. { title: '{{ i18n "pages.xray.outbound.tag"}}', dataIndex: 'tag', align: 'center', width: 50 },
  459. { title: '{{ i18n "pages.xray.outbound.domain"}}', dataIndex: 'domain', align: 'center', width: 50 },
  460. ];
  461. const app = new Vue({
  462. delimiters: ['[[', ']]'],
  463. el: '#app',
  464. data: {
  465. siderDrawer,
  466. themeSwitcher,
  467. isDarkTheme: themeSwitcher.isDarkTheme,
  468. spinning: false,
  469. oldXraySetting: '',
  470. xraySetting: '',
  471. inboundTags: [],
  472. saveBtnDisable: true,
  473. restartResult: '',
  474. isMobile: window.innerWidth <= 768,
  475. advSettings: 'xraySetting',
  476. cm: null,
  477. cmOptions: {
  478. lineNumbers: true,
  479. mode: "application/json",
  480. lint: true,
  481. styleActiveLine: true,
  482. matchBrackets: true,
  483. theme: "xq",
  484. autoCloseTags: true,
  485. lineWrapping: true,
  486. indentUnit: 2,
  487. indentWithTabs: true,
  488. smartIndent: true,
  489. tabSize: 2,
  490. lineWiseCopyCut: false,
  491. foldGutter: true,
  492. gutters: [
  493. "CodeMirror-lint-markers",
  494. "CodeMirror-linenumbers",
  495. "CodeMirror-foldgutter",
  496. ],
  497. },
  498. ipv4Settings: {
  499. tag: "IPv4",
  500. protocol: "freedom",
  501. settings: {
  502. domainStrategy: "UseIPv4"
  503. }
  504. },
  505. warpSettings: {
  506. tag: "WARP",
  507. protocol: "socks",
  508. settings: {
  509. servers: [
  510. {
  511. address: "127.0.0.1",
  512. port: 40000
  513. }
  514. ]
  515. }
  516. },
  517. directSettings: {
  518. tag: "direct",
  519. protocol: "freedom"
  520. },
  521. OutboundDomainStrategies: ["AsIs", "UseIP", "UseIPv4", "UseIPv6"],
  522. routingDomainStrategies: ["AsIs", "IPIfNonMatch", "IPOnDemand"],
  523. settingsData: {
  524. protocols: {
  525. bittorrent: ["bittorrent"],
  526. },
  527. ips: {
  528. local: ["geoip:private"],
  529. cn: ["geoip:cn"],
  530. ir: ["ext:geoip_IR.dat:ir"],
  531. ru: ["geoip:ru"],
  532. vn: ["ext:geoip_VN.dat:vn"],
  533. },
  534. domains: {
  535. ads: [
  536. "geosite:category-ads-all",
  537. "ext:geosite_IR.dat:category-ads-all"
  538. ],
  539. security: [
  540. "ext:geosite_IR.dat:malware",
  541. "ext:geosite_IR.dat:phishing",
  542. "ext:geosite_IR.dat:cryptominers"
  543. ],
  544. speedtest: ["geosite:speedtest"],
  545. openai: ["geosite:openai"],
  546. google: ["geosite:google"],
  547. spotify: ["geosite:spotify"],
  548. netflix: ["geosite:netflix"],
  549. cn: [
  550. "geosite:cn",
  551. "regexp:.*\\.cn$"
  552. ],
  553. ru: [
  554. "geosite:category-gov-ru",
  555. "regexp:.*\\.ru$"
  556. ],
  557. ir: [
  558. "regexp:.*\\.ir$",
  559. "regexp:.*\\.xn--mgba3a4f16a$", // .ایران
  560. "ext:geosite_IR.dat:ir"
  561. ],
  562. vn: [
  563. "regexp:.*\\.vn$",
  564. "ext:geosite_VN.dat:vn",
  565. "ext:geosite_VN.dat:ads"
  566. ]
  567. },
  568. familyProtectDNS: {
  569. "servers": [
  570. "1.1.1.3", // https://developers.cloudflare.com/1.1.1.1/setup/
  571. "1.0.0.3"
  572. ],
  573. "queryStrategy": "UseIPv4"
  574. },
  575. }
  576. },
  577. methods: {
  578. loading(spinning = true) {
  579. this.spinning = spinning;
  580. },
  581. async getXraySetting() {
  582. this.loading(true);
  583. const msg = await HttpUtil.post("/panel/xray/");
  584. this.loading(false);
  585. if (msg.success) {
  586. result = JSON.parse(msg.obj);
  587. xs = JSON.stringify(result.xraySetting, null, 2);
  588. this.oldXraySetting = xs;
  589. this.xraySetting = xs;
  590. this.inboundTags = result.inboundTags;
  591. this.saveBtnDisable = true;
  592. }
  593. },
  594. async updateXraySetting() {
  595. this.loading(true);
  596. const msg = await HttpUtil.post("/panel/xray/update", {xraySetting : this.xraySetting});
  597. this.loading(false);
  598. if (msg.success) {
  599. await this.getXraySetting();
  600. }
  601. },
  602. async restartXray() {
  603. this.loading(true);
  604. const msg = await HttpUtil.post("server/restartXrayService");
  605. this.loading(false);
  606. if (msg.success) {
  607. await PromiseUtil.sleep(500);
  608. await this.getXrayResult();
  609. }
  610. this.loading(false);
  611. },
  612. async getXrayResult() {
  613. const msg = await HttpUtil.get("/panel/xray/getXrayResult");
  614. if(msg.success){
  615. this.restartResult=msg.obj;
  616. if(msg.obj.length > 1) Vue.prototype.$message.error(msg.obj);
  617. }
  618. },
  619. async fetchUserSecret() {
  620. this.loading(true);
  621. const userMessage = await HttpUtil.post("/panel/setting/getUserSecret", this.user);
  622. if (userMessage.success) {
  623. this.user = userMessage.obj;
  624. }
  625. this.loading(false);
  626. },
  627. async updateSecret() {
  628. this.loading(true);
  629. const msg = await HttpUtil.post("/panel/setting/updateUserSecret", this.user);
  630. if (msg.success) {
  631. this.user = msg.obj;
  632. window.location.replace(basePath + "logout");
  633. }
  634. this.loading(false);
  635. await this.updateXraySetting();
  636. },
  637. generateRandomString(length) {
  638. var chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
  639. let randomString = "";
  640. for (let i = 0; i < length; i++) {
  641. randomString += chars[Math.floor(Math.random() * chars.length)];
  642. }
  643. return randomString;
  644. },
  645. async getNewSecret() {
  646. this.loading(true);
  647. await PromiseUtil.sleep(600);
  648. const newSecret = this.generateRandomString(64);
  649. this.user.loginSecret = newSecret;
  650. document.getElementById("token").textContent = newSecret;
  651. this.loading(false);
  652. },
  653. async toggleToken(value) {
  654. if (value) {
  655. await this.getNewSecret();
  656. } else {
  657. this.user.loginSecret = "";
  658. }
  659. },
  660. async resetXrayConfigToDefault() {
  661. this.loading(true);
  662. const msg = await HttpUtil.get("/panel/setting/getDefaultJsonConfig");
  663. this.loading(false);
  664. if (msg.success) {
  665. this.templateSettings = JSON.parse(JSON.stringify(msg.obj, null, 2));
  666. this.saveBtnDisable = true;
  667. }
  668. },
  669. syncRulesWithOutbound(tag, setting) {
  670. const newTemplateSettings = {...this.templateSettings};
  671. const haveRules = newTemplateSettings.routing.rules.some((r) => r?.outboundTag === tag);
  672. const outboundIndex = newTemplateSettings.outbounds.findIndex((o) => o.tag === tag);
  673. if (!haveRules && outboundIndex >= 0) {
  674. newTemplateSettings.outbounds.splice(outboundIndex, 1);
  675. }
  676. if (haveRules && outboundIndex === -1) {
  677. newTemplateSettings.outbounds.push(setting);
  678. }
  679. this.templateSettings = newTemplateSettings;
  680. },
  681. templateRuleGetter(routeSettings) {
  682. const { property, outboundTag } = routeSettings;
  683. let result = [];
  684. if (this.templateSettings != null) {
  685. this.templateSettings.routing.rules.forEach(
  686. (routingRule) => {
  687. if (
  688. routingRule.hasOwnProperty(property) &&
  689. routingRule.hasOwnProperty("outboundTag") &&
  690. routingRule.outboundTag === outboundTag
  691. ) {
  692. result.push(...routingRule[property]);
  693. }
  694. }
  695. );
  696. }
  697. return result;
  698. },
  699. templateRuleSetter(routeSettings) {
  700. const { data, property, outboundTag } = routeSettings;
  701. const oldTemplateSettings = this.templateSettings;
  702. const newTemplateSettings = oldTemplateSettings;
  703. currentProperty = this.templateRuleGetter({ outboundTag, property })
  704. if (currentProperty.length == 0) {
  705. const propertyRule = {
  706. type: "field",
  707. outboundTag,
  708. [property]: data
  709. };
  710. newTemplateSettings.routing.rules.push(propertyRule);
  711. }
  712. else {
  713. const newRules = [];
  714. insertedOnce = false;
  715. newTemplateSettings.routing.rules.forEach(
  716. (routingRule) => {
  717. if (
  718. routingRule.hasOwnProperty(property) &&
  719. routingRule.hasOwnProperty("outboundTag") &&
  720. routingRule.outboundTag === outboundTag
  721. ) {
  722. if (!insertedOnce && data.length > 0) {
  723. insertedOnce = true;
  724. routingRule[property] = data;
  725. newRules.push(routingRule);
  726. }
  727. }
  728. else {
  729. newRules.push(routingRule);
  730. }
  731. }
  732. );
  733. newTemplateSettings.routing.rules = newRules;
  734. }
  735. this.templateSettings = newTemplateSettings;
  736. },
  737. changeCode() {
  738. if(this.cm != null) {
  739. this.cm.toTextArea();
  740. }
  741. textAreaObj = document.getElementById('xraySetting');
  742. textAreaObj.value = this[this.advSettings];
  743. this.cm = CodeMirror.fromTextArea(textAreaObj, this.cmOptions);
  744. this.cm.on('change',editor => {
  745. value = editor.getValue();
  746. if(this.isJsonString(value)){
  747. this[this.advSettings] = value;
  748. }
  749. });
  750. },
  751. isJsonString(str) {
  752. try {
  753. JSON.parse(str);
  754. } catch (e) {
  755. return false;
  756. }
  757. return true;
  758. },
  759. findOutboundAddress(o) {
  760. serverObj = null;
  761. switch(o.protocol){
  762. case Protocols.VMess:
  763. case Protocols.VLESS:
  764. serverObj = o.settings.vnext;
  765. break;
  766. case Protocols.HTTP:
  767. case Protocols.Socks:
  768. case Protocols.Shadowsocks:
  769. case Protocols.Trojan:
  770. serverObj = o.settings.servers;
  771. break;
  772. case Protocols.DNS:
  773. return [o.settings.address + ':' + o.settings.port];
  774. default:
  775. return null;
  776. }
  777. return serverObj ? serverObj.map(obj => obj.address + ':' + obj.port) : null;
  778. },
  779. addOutbound(){
  780. outModal.show({
  781. title: '{{ i18n "pages.xray.outbound.addOutbound"}}',
  782. okText: '{{ i18n "pages.xray.outbound.addOutbound" }}',
  783. confirm: (outbound) => {
  784. outModal.loading();
  785. if(outbound.tag.length > 0){
  786. this.templateSettings.outbounds.push(outbound);
  787. this.outboundSettings = JSON.stringify(this.templateSettings.outbounds);
  788. }
  789. outModal.close();
  790. },
  791. isEdit: false,
  792. tags: this.templateSettings.outbounds.map(obj => obj.tag)
  793. });
  794. },
  795. editOutbound(index){
  796. outModal.show({
  797. title: '{{ i18n "pages.xray.outbound.editOutbound"}} ' + (index+1),
  798. outbound: app.templateSettings.outbounds[index],
  799. confirm: (outbound) => {
  800. outModal.loading();
  801. this.templateSettings.outbounds[index] = outbound;
  802. this.outboundSettings = JSON.stringify(this.templateSettings.outbounds);
  803. outModal.close();
  804. },
  805. isEdit: true,
  806. tags: this.outboundData.filter((o) => o.key != index ).map(obj => obj.tag)
  807. });
  808. },
  809. deleteOutbound(index){
  810. outbounds = this.templateSettings.outbounds;
  811. outbounds.splice(index,1);
  812. this.outboundSettings = JSON.stringify(outbounds);
  813. },
  814. addReverse(){
  815. reverseModal.show({
  816. title: '{{ i18n "pages.xray.outbound.addReverse"}}',
  817. okText: '{{ i18n "pages.xray.outbound.addReverse" }}',
  818. confirm: (reverse, rules) => {
  819. reverseModal.loading();
  820. if(reverse.tag.length > 0){
  821. newTemplateSettings = this.templateSettings;
  822. if(newTemplateSettings.reverse == undefined) newTemplateSettings.reverse = {};
  823. if(newTemplateSettings.reverse[reverse.type+'s'] == undefined) newTemplateSettings.reverse[reverse.type+'s'] = [];
  824. newTemplateSettings.reverse[reverse.type+'s'].push({ tag: reverse.tag, domain: reverse.domain });
  825. this.templateSettings = newTemplateSettings;
  826. // Add related rules
  827. this.templateSettings.routing.rules.push(...rules);
  828. this.routingRuleSettings = JSON.stringify(this.templateSettings.routing.rules);
  829. }
  830. reverseModal.close();
  831. },
  832. isEdit: false
  833. });
  834. },
  835. editReverse(index){
  836. if(this.reverseData[index].type == "bridge") {
  837. oldRules = this.templateSettings.routing.rules.filter(r => r.inboundTag && r.inboundTag[0] == this.reverseData[index].tag);
  838. } else {
  839. oldRules = this.templateSettings.routing.rules.filter(r => r.outboundTag && r.outboundTag == this.reverseData[index].tag);
  840. }
  841. reverseModal.show({
  842. title: '{{ i18n "pages.xray.outbound.editReverse"}} ' + (index+1),
  843. reverse: this.reverseData[index],
  844. rules: oldRules,
  845. confirm: (reverse, rules) => {
  846. reverseModal.loading();
  847. if(reverse.tag.length > 0){
  848. oldData = this.reverseData[index];
  849. newTemplateSettings = this.templateSettings;
  850. oldReverseIndex = newTemplateSettings.reverse[oldData.type+'s'].findIndex(rs => rs.tag == oldData.tag);
  851. oldRuleIndex0 = oldRules.length>0 ? newTemplateSettings.routing.rules.findIndex(r => JSON.stringify(r) == JSON.stringify(oldRules[0])) : -1;
  852. oldRuleIndex1 = oldRules.length==2 ? newTemplateSettings.routing.rules.findIndex(r => JSON.stringify(r) == JSON.stringify(oldRules[1])) : -1;
  853. if(oldData.type == reverse.type){
  854. newTemplateSettings.reverse[oldData.type + 's'][oldReverseIndex] = { tag: reverse.tag, domain: reverse.domain };
  855. } else {
  856. newTemplateSettings.reverse[oldData.type+'s'].splice(oldReverseIndex,1);
  857. // delete empty object
  858. if(newTemplateSettings.reverse[oldData.type+'s'].length == 0) Reflect.deleteProperty(newTemplateSettings.reverse, oldData.type+'s');
  859. // add other type of reverse if it is not exist
  860. if(!newTemplateSettings.reverse[reverse.type+'s']) newTemplateSettings.reverse[reverse.type+'s'] = [];
  861. newTemplateSettings.reverse[reverse.type+'s'].push({ tag: reverse.tag, domain: reverse.domain });
  862. }
  863. this.templateSettings = newTemplateSettings;
  864. // Adjust Rules
  865. newRules = this.templateSettings.routing.rules;
  866. oldRuleIndex0 != -1 ? newRules[oldRuleIndex0] = rules[0] : newRules.push(rules[0]);
  867. oldRuleIndex1 != -1 ? newRules[oldRuleIndex1] = rules[1] : newRules.push(rules[1]);
  868. this.routingRuleSettings = JSON.stringify(newRules);
  869. }
  870. reverseModal.close();
  871. },
  872. isEdit: true
  873. });
  874. },
  875. deleteReverse(index){
  876. oldData = this.reverseData[index];
  877. newTemplateSettings = this.templateSettings;
  878. reverseTypeObj = newTemplateSettings.reverse[oldData.type+'s'];
  879. realIndex = reverseTypeObj.findIndex(r => r.tag==oldData.tag && r.domain==oldData.domain);
  880. newTemplateSettings.reverse[oldData.type+'s'].splice(realIndex,1);
  881. // delete empty objects
  882. if(reverseTypeObj.length == 0) Reflect.deleteProperty(newTemplateSettings.reverse, oldData.type+'s');
  883. if(Object.keys(newTemplateSettings.reverse).length === 0) Reflect.deleteProperty(newTemplateSettings, 'reverse');
  884. // delete related routing rules
  885. newRules = newTemplateSettings.routing.rules;
  886. if(oldData.type == "bridge"){
  887. newRules = newTemplateSettings.routing.rules.filter(r => !( r.inboundTag && r.inboundTag.length == 1 && r.inboundTag[0] == oldData.tag));
  888. } else if(oldData.type == "portal"){
  889. newRules = newTemplateSettings.routing.rules.filter(r => r.outboundTag != oldData.tag);
  890. }
  891. newTemplateSettings.routing.rules = newRules;
  892. this.templateSettings = newTemplateSettings;
  893. },
  894. addRule(){
  895. ruleModal.show({
  896. title: '{{ i18n "pages.xray.rules.add"}}',
  897. okText: '{{ i18n "pages.xray.rules.add" }}',
  898. confirm: (rule) => {
  899. ruleModal.loading();
  900. if(JSON.stringify(rule).length > 3){
  901. this.templateSettings.routing.rules.push(rule);
  902. this.routingRuleSettings = JSON.stringify(this.templateSettings.routing.rules);
  903. }
  904. ruleModal.close();
  905. },
  906. isEdit: false
  907. });
  908. },
  909. editRule(index){
  910. ruleModal.show({
  911. title: '{{ i18n "pages.xray.rules.edit"}} ' + (index+1),
  912. rule: app.templateSettings.routing.rules[index],
  913. confirm: (rule) => {
  914. ruleModal.loading();
  915. if(JSON.stringify(rule).length > 3){
  916. this.templateSettings.routing.rules[index] = rule;
  917. this.routingRuleSettings = JSON.stringify(this.templateSettings.routing.rules);
  918. }
  919. ruleModal.close();
  920. },
  921. isEdit: true
  922. });
  923. },
  924. replaceRule(old_index,new_index){
  925. rules = this.templateSettings.routing.rules;
  926. if (new_index >= rules.length) rules.push(undefined);
  927. rules.splice(new_index, 0, rules.splice(old_index, 1)[0]);
  928. this.routingRuleSettings = JSON.stringify(rules);
  929. },
  930. deleteRule(index){
  931. rules = this.templateSettings.routing.rules;
  932. rules.splice(index,1);
  933. this.routingRuleSettings = JSON.stringify(rules);
  934. }
  935. },
  936. async mounted() {
  937. await this.getXraySetting();
  938. await this.getXrayResult();
  939. while (true) {
  940. await PromiseUtil.sleep(600);
  941. this.saveBtnDisable = this.oldXraySetting === this.xraySetting;
  942. }
  943. },
  944. computed: {
  945. templateSettings: {
  946. get: function () { return this.xraySetting ? JSON.parse(this.xraySetting) : null; },
  947. set: function (newValue) { this.xraySetting = JSON.stringify(newValue, null, 2); },
  948. },
  949. inboundSettings: {
  950. get: function () { return this.templateSettings ? JSON.stringify(this.templateSettings.inbounds, null, 2) : null; },
  951. set: function (newValue) {
  952. newTemplateSettings = this.templateSettings;
  953. newTemplateSettings.inbounds = JSON.parse(newValue);
  954. this.templateSettings = newTemplateSettings;
  955. },
  956. },
  957. outboundSettings: {
  958. get: function () { return this.templateSettings ? JSON.stringify(this.templateSettings.outbounds, null, 2) : null; },
  959. set: function (newValue) {
  960. newTemplateSettings = this.templateSettings;
  961. newTemplateSettings.outbounds = JSON.parse(newValue);
  962. this.templateSettings = newTemplateSettings;
  963. },
  964. },
  965. outboundData: {
  966. get: function () {
  967. data = []
  968. if (this.templateSettings != null) {
  969. this.templateSettings.outbounds.forEach((o, index) => {
  970. data.push({'key': index, ...o});
  971. });
  972. }
  973. return data;
  974. },
  975. },
  976. reverseData: {
  977. get: function () {
  978. data = []
  979. if (this.templateSettings != null && this.templateSettings.reverse != null) {
  980. if(this.templateSettings.reverse.bridges) {
  981. this.templateSettings.reverse.bridges.forEach((o, index) => {
  982. data.push({'key': index, 'type':'bridge', ...o});
  983. });
  984. }
  985. if(this.templateSettings.reverse.portals){
  986. this.templateSettings.reverse.portals.forEach((o, index) => {
  987. data.push({'key': index, 'type':'portal', ...o});
  988. });
  989. }
  990. }
  991. return data;
  992. },
  993. },
  994. routingRuleSettings: {
  995. get: function () { return this.templateSettings ? JSON.stringify(this.templateSettings.routing.rules, null, 2) : null; },
  996. set: function (newValue) {
  997. newTemplateSettings = this.templateSettings;
  998. newTemplateSettings.routing.rules = JSON.parse(newValue);
  999. this.templateSettings = newTemplateSettings;
  1000. },
  1001. },
  1002. routingRuleData: {
  1003. get: function () {
  1004. data = [];
  1005. if (this.templateSettings != null) {
  1006. this.templateSettings.routing.rules.forEach((r, index) => {
  1007. data.push({'key': index, ...r});
  1008. });
  1009. // Make rules readable
  1010. data.forEach(r => {
  1011. if(r.domain) r.domain = r.domain.join(',')
  1012. if(r.ip) r.ip = r.ip.join(',')
  1013. if(r.source) r.source = r.source.join(',');
  1014. if(r.user) r.user = r.user.join(',')
  1015. if(r.inboundTag) r.inboundTag = r.inboundTag.join(',')
  1016. if(r.protocol) r.protocol = r.protocol.join(',')
  1017. if(r.attrs) r.attrs = JSON.stringify(r.attrs, null, 2)
  1018. });
  1019. }
  1020. return data;
  1021. }
  1022. },
  1023. freedomStrategy: {
  1024. get: function () {
  1025. if (!this.templateSettings) return "AsIs";
  1026. freedomOutbound = this.templateSettings.outbounds.find((o) => o.protocol === "freedom" && o.tag == "direct");
  1027. if (!freedomOutbound) return "AsIs";
  1028. if (!freedomOutbound.settings || !freedomOutbound.settings.domainStrategy) return "AsIs";
  1029. return freedomOutbound.settings.domainStrategy;
  1030. },
  1031. set: function (newValue) {
  1032. newTemplateSettings = this.templateSettings;
  1033. freedomOutboundIndex = newTemplateSettings.outbounds.findIndex((o) => o.protocol === "freedom" && o.tag == "direct");
  1034. if(freedomOutboundIndex == -1){
  1035. newTemplateSettings.outbounds.push({protocol: "freedom", tag: "direct", settings: { "domainStrategy": newValue }});
  1036. } else if (!newTemplateSettings.outbounds[freedomOutboundIndex].settings) {
  1037. newTemplateSettings.outbounds[freedomOutboundIndex].settings = {"domainStrategy": newValue};
  1038. } else {
  1039. newTemplateSettings.outbounds[freedomOutboundIndex].settings.domainStrategy = newValue;
  1040. }
  1041. this.templateSettings = newTemplateSettings;
  1042. }
  1043. },
  1044. routingStrategy: {
  1045. get: function () {
  1046. if (!this.templateSettings || !this.templateSettings.routing || !this.templateSettings.routing.domainStrategy) return "AsIs";
  1047. return this.templateSettings.routing.domainStrategy;
  1048. },
  1049. set: function (newValue) {
  1050. newTemplateSettings = this.templateSettings;
  1051. newTemplateSettings.routing.domainStrategy = newValue;
  1052. this.templateSettings = newTemplateSettings;
  1053. }
  1054. },
  1055. blockedIPs: {
  1056. get: function () {
  1057. return this.templateRuleGetter({ outboundTag: "blocked", property: "ip" });
  1058. },
  1059. set: function (newValue) {
  1060. this.templateRuleSetter({ outboundTag: "blocked", property: "ip", data: newValue });
  1061. }
  1062. },
  1063. blockedDomains: {
  1064. get: function () {
  1065. return this.templateRuleGetter({ outboundTag: "blocked", property: "domain" });
  1066. },
  1067. set: function (newValue) {
  1068. this.templateRuleSetter({ outboundTag: "blocked", property: "domain", data: newValue });
  1069. }
  1070. },
  1071. blockedProtocols: {
  1072. get: function () {
  1073. return this.templateRuleGetter({ outboundTag: "blocked", property: "protocol" });
  1074. },
  1075. set: function (newValue) {
  1076. this.templateRuleSetter({ outboundTag: "blocked", property: "protocol", data: newValue });
  1077. }
  1078. },
  1079. directIPs: {
  1080. get: function () {
  1081. return this.templateRuleGetter({ outboundTag: "direct", property: "ip" });
  1082. },
  1083. set: function (newValue) {
  1084. this.templateRuleSetter({ outboundTag: "direct", property: "ip", data: newValue });
  1085. this.syncRulesWithOutbound("direct", this.directSettings);
  1086. }
  1087. },
  1088. directDomains: {
  1089. get: function () {
  1090. return this.templateRuleGetter({ outboundTag: "direct", property: "domain" });
  1091. },
  1092. set: function (newValue) {
  1093. this.templateRuleSetter({ outboundTag: "direct", property: "domain", data: newValue });
  1094. this.syncRulesWithOutbound("direct", this.directSettings);
  1095. }
  1096. },
  1097. ipv4Domains: {
  1098. get: function () {
  1099. return this.templateRuleGetter({ outboundTag: "IPv4", property: "domain" });
  1100. },
  1101. set: function (newValue) {
  1102. this.templateRuleSetter({ outboundTag: "IPv4", property: "domain", data: newValue });
  1103. this.syncRulesWithOutbound("IPv4", this.ipv4Settings);
  1104. }
  1105. },
  1106. warpDomains: {
  1107. get: function () {
  1108. return this.templateRuleGetter({ outboundTag: "WARP", property: "domain" });
  1109. },
  1110. set: function (newValue) {
  1111. this.templateRuleSetter({ outboundTag: "WARP", property: "domain", data: newValue });
  1112. this.syncRulesWithOutbound("WARP", this.warpSettings);
  1113. }
  1114. },
  1115. manualBlockedIPs: {
  1116. get: function () { return JSON.stringify(this.blockedIPs, null, 2); },
  1117. set: debounce(function (value) { this.blockedIPs = JSON.parse(value); }, 1000)
  1118. },
  1119. manualBlockedDomains: {
  1120. get: function () { return JSON.stringify(this.blockedDomains, null, 2); },
  1121. set: debounce(function (value) { this.blockedDomains = JSON.parse(value); }, 1000)
  1122. },
  1123. manualDirectIPs: {
  1124. get: function () { return JSON.stringify(this.directIPs, null, 2); },
  1125. set: debounce(function (value) { this.directIPs = JSON.parse(value); }, 1000)
  1126. },
  1127. manualDirectDomains: {
  1128. get: function () { return JSON.stringify(this.directDomains, null, 2); },
  1129. set: debounce(function (value) { this.directDomains = JSON.parse(value); }, 1000)
  1130. },
  1131. manualIPv4Domains: {
  1132. get: function () { return JSON.stringify(this.ipv4Domains, null, 2); },
  1133. set: debounce(function (value) { this.ipv4Domains = JSON.parse(value); }, 1000)
  1134. },
  1135. manualWARPDomains: {
  1136. get: function () { return JSON.stringify(this.warpDomains, null, 2); },
  1137. set: debounce(function (value) { this.warpDomains = JSON.parse(value); }, 1000)
  1138. },
  1139. torrentSettings: {
  1140. get: function () {
  1141. return doAllItemsExist(this.settingsData.protocols.bittorrent, this.blockedProtocols);
  1142. },
  1143. set: function (newValue) {
  1144. if (newValue) {
  1145. this.blockedProtocols = [...this.blockedProtocols, ...this.settingsData.protocols.bittorrent];
  1146. } else {
  1147. this.blockedProtocols = this.blockedProtocols.filter(data => !this.settingsData.protocols.bittorrent.includes(data));
  1148. }
  1149. },
  1150. },
  1151. privateIpSettings: {
  1152. get: function () {
  1153. return doAllItemsExist(this.settingsData.ips.local, this.blockedIPs);
  1154. },
  1155. set: function (newValue) {
  1156. if (newValue) {
  1157. this.blockedIPs = [...this.blockedIPs, ...this.settingsData.ips.local];
  1158. } else {
  1159. this.blockedIPs = this.blockedIPs.filter(data => !this.settingsData.ips.local.includes(data));
  1160. }
  1161. },
  1162. },
  1163. AdsSettings: {
  1164. get: function () {
  1165. return doAllItemsExist(this.settingsData.domains.ads, this.blockedDomains);
  1166. },
  1167. set: function (newValue) {
  1168. if (newValue) {
  1169. this.blockedDomains = [...this.blockedDomains, ...this.settingsData.domains.ads];
  1170. } else {
  1171. this.blockedDomains = this.blockedDomains.filter(data => !this.settingsData.domains.ads.includes(data));
  1172. }
  1173. },
  1174. },
  1175. SecuritySettings: {
  1176. get: function () {
  1177. return doAllItemsExist(this.settingsData.domains.security, this.blockedDomains);
  1178. },
  1179. set: function (newValue) {
  1180. if (newValue) {
  1181. this.blockedDomains = [...this.blockedDomains, ...this.settingsData.domains.security];
  1182. } else {
  1183. this.blockedDomains = this.blockedDomains.filter(data => !this.settingsData.domains.security.includes(data));
  1184. }
  1185. },
  1186. },
  1187. SpeedTestSettings: {
  1188. get: function () {
  1189. return doAllItemsExist(this.settingsData.domains.speedtest, this.blockedDomains);
  1190. },
  1191. set: function (newValue) {
  1192. if (newValue) {
  1193. this.blockedDomains = [...this.blockedDomains, ...this.settingsData.domains.speedtest];
  1194. } else {
  1195. this.blockedDomains = this.blockedDomains.filter(data => !this.settingsData.domains.speedtest.includes(data));
  1196. }
  1197. },
  1198. },
  1199. familyProtectSettings: {
  1200. get: function () {
  1201. if (!this.templateSettings || !this.templateSettings.dns || !this.templateSettings.dns.servers) return false;
  1202. return doAllItemsExist(this.templateSettings.dns.servers, this.settingsData.familyProtectDNS.servers);
  1203. },
  1204. set: function (newValue) {
  1205. newTemplateSettings = this.templateSettings;
  1206. if (newValue) {
  1207. newTemplateSettings.dns = this.settingsData.familyProtectDNS;
  1208. } else {
  1209. delete newTemplateSettings.dns;
  1210. }
  1211. this.templateSettings = newTemplateSettings;
  1212. },
  1213. },
  1214. GoogleIPv4Settings: {
  1215. get: function () {
  1216. return doAllItemsExist(this.settingsData.domains.google, this.ipv4Domains);
  1217. },
  1218. set: function (newValue) {
  1219. if (newValue) {
  1220. this.ipv4Domains = [...this.ipv4Domains, ...this.settingsData.domains.google];
  1221. } else {
  1222. this.ipv4Domains = this.ipv4Domains.filter(data => !this.settingsData.domains.google.includes(data));
  1223. }
  1224. },
  1225. },
  1226. NetflixIPv4Settings: {
  1227. get: function () {
  1228. return doAllItemsExist(this.settingsData.domains.netflix, this.ipv4Domains);
  1229. },
  1230. set: function (newValue) {
  1231. if (newValue) {
  1232. this.ipv4Domains = [...this.ipv4Domains, ...this.settingsData.domains.netflix];
  1233. } else {
  1234. this.ipv4Domains = this.ipv4Domains.filter(data => !this.settingsData.domains.netflix.includes(data));
  1235. }
  1236. },
  1237. },
  1238. IRIpSettings: {
  1239. get: function () {
  1240. return doAllItemsExist(this.settingsData.ips.ir, this.blockedIPs);
  1241. },
  1242. set: function (newValue) {
  1243. if (newValue) {
  1244. this.blockedIPs = [...this.blockedIPs, ...this.settingsData.ips.ir];
  1245. } else {
  1246. this.blockedIPs = this.blockedIPs.filter(data => !this.settingsData.ips.ir.includes(data));
  1247. }
  1248. }
  1249. },
  1250. IRDomainSettings: {
  1251. get: function () {
  1252. return doAllItemsExist(this.settingsData.domains.ir, this.blockedDomains);
  1253. },
  1254. set: function (newValue) {
  1255. if (newValue) {
  1256. this.blockedDomains = [...this.blockedDomains, ...this.settingsData.domains.ir];
  1257. } else {
  1258. this.blockedDomains = this.blockedDomains.filter(data => !this.settingsData.domains.ir.includes(data));
  1259. }
  1260. }
  1261. },
  1262. ChinaIpSettings: {
  1263. get: function () {
  1264. return doAllItemsExist(this.settingsData.ips.cn, this.blockedIPs);
  1265. },
  1266. set: function (newValue) {
  1267. if (newValue) {
  1268. this.blockedIPs = [...this.blockedIPs, ...this.settingsData.ips.cn];
  1269. } else {
  1270. this.blockedIPs = this.blockedIPs.filter(data => !this.settingsData.ips.cn.includes(data));
  1271. }
  1272. }
  1273. },
  1274. ChinaDomainSettings: {
  1275. get: function () {
  1276. return doAllItemsExist(this.settingsData.domains.cn, this.blockedDomains);
  1277. },
  1278. set: function (newValue) {
  1279. if (newValue) {
  1280. this.blockedDomains = [...this.blockedDomains, ...this.settingsData.domains.cn];
  1281. } else {
  1282. this.blockedDomains = this.blockedDomains.filter(data => !this.settingsData.domains.cn.includes(data));
  1283. }
  1284. }
  1285. },
  1286. RussiaIpSettings: {
  1287. get: function () {
  1288. return doAllItemsExist(this.settingsData.ips.ru, this.blockedIPs);
  1289. },
  1290. set: function (newValue) {
  1291. if (newValue) {
  1292. this.blockedIPs = [...this.blockedIPs, ...this.settingsData.ips.ru];
  1293. } else {
  1294. this.blockedIPs = this.blockedIPs.filter(data => !this.settingsData.ips.ru.includes(data));
  1295. }
  1296. }
  1297. },
  1298. RussiaDomainSettings: {
  1299. get: function () {
  1300. return doAllItemsExist(this.settingsData.domains.ru, this.blockedDomains);
  1301. },
  1302. set: function (newValue) {
  1303. if (newValue) {
  1304. this.blockedDomains = [...this.blockedDomains, ...this.settingsData.domains.ru];
  1305. } else {
  1306. this.blockedDomains = this.blockedDomains.filter(data => !this.settingsData.domains.ru.includes(data));
  1307. }
  1308. }
  1309. },
  1310. VNIpSettings: {
  1311. get: function () {
  1312. return doAllItemsExist(this.settingsData.ips.vn, this.blockedIPs);
  1313. },
  1314. set: function (newValue) {
  1315. if (newValue) {
  1316. this.blockedIPs = [...this.blockedIPs, ...this.settingsData.ips.vn];
  1317. } else {
  1318. this.blockedIPs = this.blockedIPs.filter(data => !this.settingsData.ips.vn.includes(data));
  1319. }
  1320. }
  1321. },
  1322. VNDomainSettings: {
  1323. get: function () {
  1324. return doAllItemsExist(this.settingsData.domains.vn, this.blockedDomains);
  1325. },
  1326. set: function (newValue) {
  1327. if (newValue) {
  1328. this.blockedDomains = [...this.blockedDomains, ...this.settingsData.domains.vn];
  1329. } else {
  1330. this.blockedDomains = this.blockedDomains.filter(data => !this.settingsData.domains.vn.includes(data));
  1331. }
  1332. }
  1333. },
  1334. IRIpDirectSettings: {
  1335. get: function () {
  1336. return doAllItemsExist(this.settingsData.ips.ir, this.directIPs);
  1337. },
  1338. set: function (newValue) {
  1339. if (newValue) {
  1340. this.directIPs = [...this.directIPs, ...this.settingsData.ips.ir];
  1341. } else {
  1342. this.directIPs = this.directIPs.filter(data => !this.settingsData.ips.ir.includes(data));
  1343. }
  1344. }
  1345. },
  1346. IRDomainDirectSettings: {
  1347. get: function () {
  1348. return doAllItemsExist(this.settingsData.domains.ir, this.directDomains);
  1349. },
  1350. set: function (newValue) {
  1351. if (newValue) {
  1352. this.directDomains = [...this.directDomains, ...this.settingsData.domains.ir];
  1353. } else {
  1354. this.directDomains = this.directDomains.filter(data => !this.settingsData.domains.ir.includes(data));
  1355. }
  1356. }
  1357. },
  1358. ChinaIpDirectSettings: {
  1359. get: function () {
  1360. return doAllItemsExist(this.settingsData.ips.cn, this.directIPs);
  1361. },
  1362. set: function (newValue) {
  1363. if (newValue) {
  1364. this.directIPs = [...this.directIPs, ...this.settingsData.ips.cn];
  1365. } else {
  1366. this.directIPs = this.directIPs.filter(data => !this.settingsData.ips.cn.includes(data));
  1367. }
  1368. }
  1369. },
  1370. ChinaDomainDirectSettings: {
  1371. get: function () {
  1372. return doAllItemsExist(this.settingsData.domains.cn, this.directDomains);
  1373. },
  1374. set: function (newValue) {
  1375. if (newValue) {
  1376. this.directDomains = [...this.directDomains, ...this.settingsData.domains.cn];
  1377. } else {
  1378. this.directDomains = this.directDomains.filter(data => !this.settingsData.domains.cn.includes(data));
  1379. }
  1380. }
  1381. },
  1382. RussiaIpDirectSettings: {
  1383. get: function () {
  1384. return doAllItemsExist(this.settingsData.ips.ru, this.directIPs);
  1385. },
  1386. set: function (newValue) {
  1387. if (newValue) {
  1388. this.directIPs = [...this.directIPs, ...this.settingsData.ips.ru];
  1389. } else {
  1390. this.directIPs = this.directIPs.filter(data => !this.settingsData.ips.ru.includes(data));
  1391. }
  1392. }
  1393. },
  1394. RussiaDomainDirectSettings: {
  1395. get: function () {
  1396. return doAllItemsExist(this.settingsData.domains.ru, this.directDomains);
  1397. },
  1398. set: function (newValue) {
  1399. if (newValue) {
  1400. this.directDomains = [...this.directDomains, ...this.settingsData.domains.ru];
  1401. } else {
  1402. this.directDomains = this.directDomains.filter(data => !this.settingsData.domains.ru.includes(data));
  1403. }
  1404. }
  1405. },
  1406. VNIpDirectSettings: {
  1407. get: function () {
  1408. return doAllItemsExist(this.settingsData.ips.vn, this.directIPs);
  1409. },
  1410. set: function (newValue) {
  1411. if (newValue) {
  1412. this.directIPs = [...this.directIPs, ...this.settingsData.ips.vn];
  1413. } else {
  1414. this.directIPs = this.directIPs.filter(data => !this.settingsData.ips.vn.includes(data));
  1415. }
  1416. }
  1417. },
  1418. VNDomainDirectSettings: {
  1419. get: function () {
  1420. return doAllItemsExist(this.settingsData.domains.vn, this.directDomains);
  1421. },
  1422. set: function (newValue) {
  1423. if (newValue) {
  1424. this.directDomains = [...this.directDomains, ...this.settingsData.domains.vn];
  1425. } else {
  1426. this.directDomains = this.directDomains.filter(data => !this.settingsData.domains.vn.includes(data));
  1427. }
  1428. }
  1429. },
  1430. GoogleWARPSettings: {
  1431. get: function () {
  1432. return doAllItemsExist(this.settingsData.domains.google, this.warpDomains);
  1433. },
  1434. set: function (newValue) {
  1435. if (newValue) {
  1436. this.warpDomains = [...this.warpDomains, ...this.settingsData.domains.google];
  1437. } else {
  1438. this.warpDomains = this.warpDomains.filter(data => !this.settingsData.domains.google.includes(data));
  1439. }
  1440. },
  1441. },
  1442. OpenAIWARPSettings: {
  1443. get: function () {
  1444. return doAllItemsExist(this.settingsData.domains.openai, this.warpDomains);
  1445. },
  1446. set: function (newValue) {
  1447. if (newValue) {
  1448. this.warpDomains = [...this.warpDomains, ...this.settingsData.domains.openai];
  1449. } else {
  1450. this.warpDomains = this.warpDomains.filter(data => !this.settingsData.domains.openai.includes(data));
  1451. }
  1452. },
  1453. },
  1454. NetflixWARPSettings: {
  1455. get: function () {
  1456. return doAllItemsExist(this.settingsData.domains.netflix, this.warpDomains);
  1457. },
  1458. set: function (newValue) {
  1459. if (newValue) {
  1460. this.warpDomains = [...this.warpDomains, ...this.settingsData.domains.netflix];
  1461. } else {
  1462. this.warpDomains = this.warpDomains.filter(data => !this.settingsData.domains.netflix.includes(data));
  1463. }
  1464. },
  1465. },
  1466. SpotifyWARPSettings: {
  1467. get: function () {
  1468. return doAllItemsExist(this.settingsData.domains.spotify, this.warpDomains);
  1469. },
  1470. set: function (newValue) {
  1471. if (newValue) {
  1472. this.warpDomains = [...this.warpDomains, ...this.settingsData.domains.spotify];
  1473. } else {
  1474. this.warpDomains = this.warpDomains.filter(data => !this.settingsData.domains.spotify.includes(data));
  1475. }
  1476. },
  1477. },
  1478. },
  1479. });
  1480. </script>
  1481. </body>
  1482. </html>