xray.html 83 KB

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