xray.html 82 KB

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