xray.html 82 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473
  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. ],
  564. "queryStrategy": "UseIPv4"
  565. },
  566. }
  567. },
  568. methods: {
  569. loading(spinning = true) {
  570. this.spinning = spinning;
  571. },
  572. async getXraySetting() {
  573. this.loading(true);
  574. const msg = await HttpUtil.post("/panel/xray/");
  575. this.loading(false);
  576. if (msg.success) {
  577. result = JSON.parse(msg.obj);
  578. xs = JSON.stringify(result.xraySetting, null, 2);
  579. this.oldXraySetting = xs;
  580. this.xraySetting = xs;
  581. this.inboundTags = result.inboundTags;
  582. this.saveBtnDisable = true;
  583. }
  584. },
  585. async updateXraySetting() {
  586. this.loading(true);
  587. const msg = await HttpUtil.post("/panel/xray/update", {xraySetting : this.xraySetting});
  588. this.loading(false);
  589. if (msg.success) {
  590. await this.getXraySetting();
  591. }
  592. },
  593. async restartXray() {
  594. this.loading(true);
  595. const msg = await HttpUtil.post("server/restartXrayService");
  596. this.loading(false);
  597. if (msg.success) {
  598. await PromiseUtil.sleep(500);
  599. await this.getXrayResult();
  600. }
  601. this.loading(false);
  602. },
  603. async getXrayResult() {
  604. const msg = await HttpUtil.get("/panel/xray/getXrayResult");
  605. if(msg.success){
  606. this.restartResult=msg.obj;
  607. if(msg.obj.length > 1) Vue.prototype.$message.error(msg.obj);
  608. }
  609. },
  610. async fetchUserSecret() {
  611. this.loading(true);
  612. const userMessage = await HttpUtil.post("/panel/setting/getUserSecret", this.user);
  613. if (userMessage.success) {
  614. this.user = userMessage.obj;
  615. }
  616. this.loading(false);
  617. },
  618. async updateSecret() {
  619. this.loading(true);
  620. const msg = await HttpUtil.post("/panel/setting/updateUserSecret", this.user);
  621. if (msg.success) {
  622. this.user = msg.obj;
  623. window.location.replace(basePath + "logout");
  624. }
  625. this.loading(false);
  626. await this.updateXraySetting();
  627. },
  628. generateRandomString(length) {
  629. var chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
  630. let randomString = "";
  631. for (let i = 0; i < length; i++) {
  632. randomString += chars[Math.floor(Math.random() * chars.length)];
  633. }
  634. return randomString;
  635. },
  636. async getNewSecret() {
  637. this.loading(true);
  638. await PromiseUtil.sleep(600);
  639. const newSecret = this.generateRandomString(64);
  640. this.user.loginSecret = newSecret;
  641. document.getElementById("token").textContent = newSecret;
  642. this.loading(false);
  643. },
  644. async toggleToken(value) {
  645. if (value) {
  646. await this.getNewSecret();
  647. } else {
  648. this.user.loginSecret = "";
  649. }
  650. },
  651. async resetXrayConfigToDefault() {
  652. this.loading(true);
  653. const msg = await HttpUtil.get("/panel/setting/getDefaultJsonConfig");
  654. this.loading(false);
  655. if (msg.success) {
  656. this.templateSettings = JSON.parse(JSON.stringify(msg.obj, null, 2));
  657. this.saveBtnDisable = true;
  658. }
  659. },
  660. syncRulesWithOutbound(tag, setting) {
  661. const newTemplateSettings = this.templateSettings;
  662. const haveRules = newTemplateSettings.routing.rules.some((r) => r?.outboundTag === tag);
  663. const outboundIndex = newTemplateSettings.outbounds.findIndex((o) => o.tag === tag);
  664. if (!haveRules && outboundIndex > 0) {
  665. newTemplateSettings.outbounds.splice(outboundIndex);
  666. }
  667. if (haveRules && outboundIndex < 0) {
  668. newTemplateSettings.outbounds.push(setting);
  669. }
  670. this.templateSettings = newTemplateSettings;
  671. },
  672. templateRuleGetter(routeSettings) {
  673. const { property, outboundTag } = routeSettings;
  674. let result = [];
  675. if (this.templateSettings != null) {
  676. this.templateSettings.routing.rules.forEach(
  677. (routingRule) => {
  678. if (
  679. routingRule.hasOwnProperty(property) &&
  680. routingRule.hasOwnProperty("outboundTag") &&
  681. routingRule.outboundTag === outboundTag
  682. ) {
  683. result.push(...routingRule[property]);
  684. }
  685. }
  686. );
  687. }
  688. return result;
  689. },
  690. templateRuleSetter(routeSettings) {
  691. const { data, property, outboundTag } = routeSettings;
  692. const oldTemplateSettings = this.templateSettings;
  693. const newTemplateSettings = oldTemplateSettings;
  694. currentProperty = this.templateRuleGetter({ outboundTag, property })
  695. if (currentProperty.length == 0) {
  696. const propertyRule = {
  697. type: "field",
  698. outboundTag,
  699. [property]: data
  700. };
  701. newTemplateSettings.routing.rules.push(propertyRule);
  702. }
  703. else {
  704. const newRules = [];
  705. insertedOnce = false;
  706. newTemplateSettings.routing.rules.forEach(
  707. (routingRule) => {
  708. if (
  709. routingRule.hasOwnProperty(property) &&
  710. routingRule.hasOwnProperty("outboundTag") &&
  711. routingRule.outboundTag === outboundTag
  712. ) {
  713. if (!insertedOnce && data.length > 0) {
  714. insertedOnce = true;
  715. routingRule[property] = data;
  716. newRules.push(routingRule);
  717. }
  718. }
  719. else {
  720. newRules.push(routingRule);
  721. }
  722. }
  723. );
  724. newTemplateSettings.routing.rules = newRules;
  725. }
  726. this.templateSettings = newTemplateSettings;
  727. },
  728. changeCode() {
  729. if(this.cm != null) {
  730. this.cm.toTextArea();
  731. }
  732. textAreaObj = document.getElementById('xraySetting');
  733. textAreaObj.value = this[this.advSettings];
  734. this.cm = CodeMirror.fromTextArea(textAreaObj, this.cmOptions);
  735. this.cm.on('change',editor => {
  736. value = editor.getValue();
  737. if(this.isJsonString(value)){
  738. this[this.advSettings] = value;
  739. }
  740. });
  741. },
  742. isJsonString(str) {
  743. try {
  744. JSON.parse(str);
  745. } catch (e) {
  746. return false;
  747. }
  748. return true;
  749. },
  750. findOutboundAddress(o) {
  751. serverObj = null;
  752. switch(o.protocol){
  753. case Protocols.VMess:
  754. case Protocols.VLESS:
  755. serverObj = o.settings.vnext;
  756. break;
  757. case Protocols.HTTP:
  758. case Protocols.Socks:
  759. case Protocols.Shadowsocks:
  760. case Protocols.Trojan:
  761. serverObj = o.settings.servers;
  762. break;
  763. case Protocols.DNS:
  764. return [o.settings.address + ':' + o.settings.port];
  765. case Protocols.Wireguard:
  766. return o.settings.peers.map(peer => peer.endpoint);
  767. default:
  768. return null;
  769. }
  770. return serverObj ? serverObj.map(obj => obj.address + ':' + obj.port) : null;
  771. },
  772. addOutbound(){
  773. outModal.show({
  774. title: '{{ i18n "pages.xray.outbound.addOutbound"}}',
  775. okText: '{{ i18n "pages.xray.outbound.addOutbound" }}',
  776. confirm: (outbound) => {
  777. outModal.loading();
  778. if(outbound.tag.length > 0){
  779. this.templateSettings.outbounds.push(outbound);
  780. this.outboundSettings = JSON.stringify(this.templateSettings.outbounds);
  781. }
  782. outModal.close();
  783. },
  784. isEdit: false,
  785. tags: this.templateSettings.outbounds.map(obj => obj.tag)
  786. });
  787. },
  788. editOutbound(index){
  789. outModal.show({
  790. title: '{{ i18n "pages.xray.outbound.editOutbound"}} ' + (index+1),
  791. outbound: app.templateSettings.outbounds[index],
  792. confirm: (outbound) => {
  793. outModal.loading();
  794. this.templateSettings.outbounds[index] = outbound;
  795. this.outboundSettings = JSON.stringify(this.templateSettings.outbounds);
  796. outModal.close();
  797. },
  798. isEdit: true,
  799. tags: this.outboundData.filter((o) => o.key != index ).map(obj => obj.tag)
  800. });
  801. },
  802. deleteOutbound(index){
  803. outbounds = this.templateSettings.outbounds;
  804. outbounds.splice(index,1);
  805. this.outboundSettings = JSON.stringify(outbounds);
  806. },
  807. addReverse(){
  808. reverseModal.show({
  809. title: '{{ i18n "pages.xray.outbound.addReverse"}}',
  810. okText: '{{ i18n "pages.xray.outbound.addReverse" }}',
  811. confirm: (reverse, rules) => {
  812. reverseModal.loading();
  813. if(reverse.tag.length > 0){
  814. newTemplateSettings = this.templateSettings;
  815. if(newTemplateSettings.reverse == undefined) newTemplateSettings.reverse = {};
  816. if(newTemplateSettings.reverse[reverse.type+'s'] == undefined) newTemplateSettings.reverse[reverse.type+'s'] = [];
  817. newTemplateSettings.reverse[reverse.type+'s'].push({ tag: reverse.tag, domain: reverse.domain });
  818. this.templateSettings = newTemplateSettings;
  819. // Add related rules
  820. this.templateSettings.routing.rules.push(...rules);
  821. this.routingRuleSettings = JSON.stringify(this.templateSettings.routing.rules);
  822. }
  823. reverseModal.close();
  824. },
  825. isEdit: false
  826. });
  827. },
  828. editReverse(index){
  829. if(this.reverseData[index].type == "bridge") {
  830. oldRules = this.templateSettings.routing.rules.filter(r => r.inboundTag && r.inboundTag[0] == this.reverseData[index].tag);
  831. } else {
  832. oldRules = this.templateSettings.routing.rules.filter(r => r.outboundTag && r.outboundTag == this.reverseData[index].tag);
  833. }
  834. reverseModal.show({
  835. title: '{{ i18n "pages.xray.outbound.editReverse"}} ' + (index+1),
  836. reverse: this.reverseData[index],
  837. rules: oldRules,
  838. confirm: (reverse, rules) => {
  839. reverseModal.loading();
  840. if(reverse.tag.length > 0){
  841. oldData = this.reverseData[index];
  842. newTemplateSettings = this.templateSettings;
  843. oldReverseIndex = newTemplateSettings.reverse[oldData.type+'s'].findIndex(rs => rs.tag == oldData.tag);
  844. oldRuleIndex0 = oldRules.length>0 ? newTemplateSettings.routing.rules.findIndex(r => JSON.stringify(r) == JSON.stringify(oldRules[0])) : -1;
  845. oldRuleIndex1 = oldRules.length==2 ? newTemplateSettings.routing.rules.findIndex(r => JSON.stringify(r) == JSON.stringify(oldRules[1])) : -1;
  846. if(oldData.type == reverse.type){
  847. newTemplateSettings.reverse[oldData.type + 's'][oldReverseIndex] = { tag: reverse.tag, domain: reverse.domain };
  848. } else {
  849. newTemplateSettings.reverse[oldData.type+'s'].splice(oldReverseIndex,1);
  850. // delete empty object
  851. if(newTemplateSettings.reverse[oldData.type+'s'].length == 0) Reflect.deleteProperty(newTemplateSettings.reverse, oldData.type+'s');
  852. // add other type of reverse if it is not exist
  853. if(!newTemplateSettings.reverse[reverse.type+'s']) newTemplateSettings.reverse[reverse.type+'s'] = [];
  854. newTemplateSettings.reverse[reverse.type+'s'].push({ tag: reverse.tag, domain: reverse.domain });
  855. }
  856. this.templateSettings = newTemplateSettings;
  857. // Adjust Rules
  858. newRules = this.templateSettings.routing.rules;
  859. oldRuleIndex0 != -1 ? newRules[oldRuleIndex0] = rules[0] : newRules.push(rules[0]);
  860. oldRuleIndex1 != -1 ? newRules[oldRuleIndex1] = rules[1] : newRules.push(rules[1]);
  861. this.routingRuleSettings = JSON.stringify(newRules);
  862. }
  863. reverseModal.close();
  864. },
  865. isEdit: true
  866. });
  867. },
  868. deleteReverse(index){
  869. oldData = this.reverseData[index];
  870. newTemplateSettings = this.templateSettings;
  871. reverseTypeObj = newTemplateSettings.reverse[oldData.type+'s'];
  872. realIndex = reverseTypeObj.findIndex(r => r.tag==oldData.tag && r.domain==oldData.domain);
  873. newTemplateSettings.reverse[oldData.type+'s'].splice(realIndex,1);
  874. // delete empty objects
  875. if(reverseTypeObj.length == 0) Reflect.deleteProperty(newTemplateSettings.reverse, oldData.type+'s');
  876. if(Object.keys(newTemplateSettings.reverse).length === 0) Reflect.deleteProperty(newTemplateSettings, 'reverse');
  877. // delete related routing rules
  878. newRules = newTemplateSettings.routing.rules;
  879. if(oldData.type == "bridge"){
  880. newRules = newTemplateSettings.routing.rules.filter(r => !( r.inboundTag && r.inboundTag.length == 1 && r.inboundTag[0] == oldData.tag));
  881. } else if(oldData.type == "portal"){
  882. newRules = newTemplateSettings.routing.rules.filter(r => r.outboundTag != oldData.tag);
  883. }
  884. newTemplateSettings.routing.rules = newRules;
  885. this.templateSettings = newTemplateSettings;
  886. },
  887. addRule(){
  888. ruleModal.show({
  889. title: '{{ i18n "pages.xray.rules.add"}}',
  890. okText: '{{ i18n "pages.xray.rules.add" }}',
  891. confirm: (rule) => {
  892. ruleModal.loading();
  893. if(JSON.stringify(rule).length > 3){
  894. this.templateSettings.routing.rules.push(rule);
  895. this.routingRuleSettings = JSON.stringify(this.templateSettings.routing.rules);
  896. }
  897. ruleModal.close();
  898. },
  899. isEdit: false
  900. });
  901. },
  902. editRule(index){
  903. ruleModal.show({
  904. title: '{{ i18n "pages.xray.rules.edit"}} ' + (index+1),
  905. rule: app.templateSettings.routing.rules[index],
  906. confirm: (rule) => {
  907. ruleModal.loading();
  908. if(JSON.stringify(rule).length > 3){
  909. this.templateSettings.routing.rules[index] = rule;
  910. this.routingRuleSettings = JSON.stringify(this.templateSettings.routing.rules);
  911. }
  912. ruleModal.close();
  913. },
  914. isEdit: true
  915. });
  916. },
  917. replaceRule(old_index,new_index){
  918. rules = this.templateSettings.routing.rules;
  919. if (new_index >= rules.length) rules.push(undefined);
  920. rules.splice(new_index, 0, rules.splice(old_index, 1)[0]);
  921. this.routingRuleSettings = JSON.stringify(rules);
  922. },
  923. deleteRule(index){
  924. rules = this.templateSettings.routing.rules;
  925. rules.splice(index,1);
  926. this.routingRuleSettings = JSON.stringify(rules);
  927. },
  928. showWarp(){
  929. warpModal.show();
  930. }
  931. },
  932. async mounted() {
  933. await this.getXraySetting();
  934. await this.getXrayResult();
  935. while (true) {
  936. await PromiseUtil.sleep(800);
  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. }
  1109. },
  1110. torrentSettings: {
  1111. get: function () {
  1112. return doAllItemsExist(this.settingsData.protocols.bittorrent, this.blockedProtocols);
  1113. },
  1114. set: function (newValue) {
  1115. if (newValue) {
  1116. this.blockedProtocols = [...this.blockedProtocols, ...this.settingsData.protocols.bittorrent];
  1117. } else {
  1118. this.blockedProtocols = this.blockedProtocols.filter(data => !this.settingsData.protocols.bittorrent.includes(data));
  1119. }
  1120. },
  1121. },
  1122. privateIpSettings: {
  1123. get: function () {
  1124. return doAllItemsExist(this.settingsData.ips.local, this.blockedIPs);
  1125. },
  1126. set: function (newValue) {
  1127. if (newValue) {
  1128. this.blockedIPs = [...this.blockedIPs, ...this.settingsData.ips.local];
  1129. } else {
  1130. this.blockedIPs = this.blockedIPs.filter(data => !this.settingsData.ips.local.includes(data));
  1131. }
  1132. },
  1133. },
  1134. AdsSettings: {
  1135. get: function () {
  1136. return doAllItemsExist(this.settingsData.domains.ads, this.blockedDomains);
  1137. },
  1138. set: function (newValue) {
  1139. if (newValue) {
  1140. this.blockedDomains = [...this.blockedDomains, ...this.settingsData.domains.ads];
  1141. } else {
  1142. this.blockedDomains = this.blockedDomains.filter(data => !this.settingsData.domains.ads.includes(data));
  1143. }
  1144. },
  1145. },
  1146. SecuritySettings: {
  1147. get: function () {
  1148. return doAllItemsExist(this.settingsData.domains.security, this.blockedDomains);
  1149. },
  1150. set: function (newValue) {
  1151. if (newValue) {
  1152. this.blockedDomains = [...this.blockedDomains, ...this.settingsData.domains.security];
  1153. } else {
  1154. this.blockedDomains = this.blockedDomains.filter(data => !this.settingsData.domains.security.includes(data));
  1155. }
  1156. },
  1157. },
  1158. SpeedTestSettings: {
  1159. get: function () {
  1160. return doAllItemsExist(this.settingsData.domains.speedtest, this.blockedDomains);
  1161. },
  1162. set: function (newValue) {
  1163. if (newValue) {
  1164. this.blockedDomains = [...this.blockedDomains, ...this.settingsData.domains.speedtest];
  1165. } else {
  1166. this.blockedDomains = this.blockedDomains.filter(data => !this.settingsData.domains.speedtest.includes(data));
  1167. }
  1168. },
  1169. },
  1170. familyProtectSettings: {
  1171. get: function () {
  1172. if (!this.templateSettings || !this.templateSettings.dns || !this.templateSettings.dns.servers) return false;
  1173. return doAllItemsExist(this.templateSettings.dns.servers, this.settingsData.familyProtectDNS.servers);
  1174. },
  1175. set: function (newValue) {
  1176. newTemplateSettings = this.templateSettings;
  1177. if (newValue) {
  1178. newTemplateSettings.dns = this.settingsData.familyProtectDNS;
  1179. } else {
  1180. delete newTemplateSettings.dns;
  1181. }
  1182. this.templateSettings = newTemplateSettings;
  1183. },
  1184. },
  1185. GoogleIPv4Settings: {
  1186. get: function () {
  1187. return doAllItemsExist(this.settingsData.domains.google, this.ipv4Domains);
  1188. },
  1189. set: function (newValue) {
  1190. if (newValue) {
  1191. this.ipv4Domains = [...this.ipv4Domains, ...this.settingsData.domains.google];
  1192. } else {
  1193. this.ipv4Domains = this.ipv4Domains.filter(data => !this.settingsData.domains.google.includes(data));
  1194. }
  1195. },
  1196. },
  1197. NetflixIPv4Settings: {
  1198. get: function () {
  1199. return doAllItemsExist(this.settingsData.domains.netflix, this.ipv4Domains);
  1200. },
  1201. set: function (newValue) {
  1202. if (newValue) {
  1203. this.ipv4Domains = [...this.ipv4Domains, ...this.settingsData.domains.netflix];
  1204. } else {
  1205. this.ipv4Domains = this.ipv4Domains.filter(data => !this.settingsData.domains.netflix.includes(data));
  1206. }
  1207. },
  1208. },
  1209. IRIpSettings: {
  1210. get: function () {
  1211. return doAllItemsExist(this.settingsData.ips.ir, this.blockedIPs);
  1212. },
  1213. set: function (newValue) {
  1214. if (newValue) {
  1215. this.blockedIPs = [...this.blockedIPs, ...this.settingsData.ips.ir];
  1216. } else {
  1217. this.blockedIPs = this.blockedIPs.filter(data => !this.settingsData.ips.ir.includes(data));
  1218. }
  1219. }
  1220. },
  1221. IRDomainSettings: {
  1222. get: function () {
  1223. return doAllItemsExist(this.settingsData.domains.ir, this.blockedDomains);
  1224. },
  1225. set: function (newValue) {
  1226. if (newValue) {
  1227. this.blockedDomains = [...this.blockedDomains, ...this.settingsData.domains.ir];
  1228. } else {
  1229. this.blockedDomains = this.blockedDomains.filter(data => !this.settingsData.domains.ir.includes(data));
  1230. }
  1231. }
  1232. },
  1233. ChinaIpSettings: {
  1234. get: function () {
  1235. return doAllItemsExist(this.settingsData.ips.cn, this.blockedIPs);
  1236. },
  1237. set: function (newValue) {
  1238. if (newValue) {
  1239. this.blockedIPs = [...this.blockedIPs, ...this.settingsData.ips.cn];
  1240. } else {
  1241. this.blockedIPs = this.blockedIPs.filter(data => !this.settingsData.ips.cn.includes(data));
  1242. }
  1243. }
  1244. },
  1245. ChinaDomainSettings: {
  1246. get: function () {
  1247. return doAllItemsExist(this.settingsData.domains.cn, this.blockedDomains);
  1248. },
  1249. set: function (newValue) {
  1250. if (newValue) {
  1251. this.blockedDomains = [...this.blockedDomains, ...this.settingsData.domains.cn];
  1252. } else {
  1253. this.blockedDomains = this.blockedDomains.filter(data => !this.settingsData.domains.cn.includes(data));
  1254. }
  1255. }
  1256. },
  1257. RussiaIpSettings: {
  1258. get: function () {
  1259. return doAllItemsExist(this.settingsData.ips.ru, this.blockedIPs);
  1260. },
  1261. set: function (newValue) {
  1262. if (newValue) {
  1263. this.blockedIPs = [...this.blockedIPs, ...this.settingsData.ips.ru];
  1264. } else {
  1265. this.blockedIPs = this.blockedIPs.filter(data => !this.settingsData.ips.ru.includes(data));
  1266. }
  1267. }
  1268. },
  1269. RussiaDomainSettings: {
  1270. get: function () {
  1271. return doAllItemsExist(this.settingsData.domains.ru, this.blockedDomains);
  1272. },
  1273. set: function (newValue) {
  1274. if (newValue) {
  1275. this.blockedDomains = [...this.blockedDomains, ...this.settingsData.domains.ru];
  1276. } else {
  1277. this.blockedDomains = this.blockedDomains.filter(data => !this.settingsData.domains.ru.includes(data));
  1278. }
  1279. }
  1280. },
  1281. VNIpSettings: {
  1282. get: function () {
  1283. return doAllItemsExist(this.settingsData.ips.vn, this.blockedIPs);
  1284. },
  1285. set: function (newValue) {
  1286. if (newValue) {
  1287. this.blockedIPs = [...this.blockedIPs, ...this.settingsData.ips.vn];
  1288. } else {
  1289. this.blockedIPs = this.blockedIPs.filter(data => !this.settingsData.ips.vn.includes(data));
  1290. }
  1291. }
  1292. },
  1293. VNDomainSettings: {
  1294. get: function () {
  1295. return doAllItemsExist(this.settingsData.domains.vn, this.blockedDomains);
  1296. },
  1297. set: function (newValue) {
  1298. if (newValue) {
  1299. this.blockedDomains = [...this.blockedDomains, ...this.settingsData.domains.vn];
  1300. } else {
  1301. this.blockedDomains = this.blockedDomains.filter(data => !this.settingsData.domains.vn.includes(data));
  1302. }
  1303. }
  1304. },
  1305. IRIpDirectSettings: {
  1306. get: function () {
  1307. return doAllItemsExist(this.settingsData.ips.ir, this.directIPs);
  1308. },
  1309. set: function (newValue) {
  1310. if (newValue) {
  1311. this.directIPs = [...this.directIPs, ...this.settingsData.ips.ir];
  1312. } else {
  1313. this.directIPs = this.directIPs.filter(data => !this.settingsData.ips.ir.includes(data));
  1314. }
  1315. }
  1316. },
  1317. IRDomainDirectSettings: {
  1318. get: function () {
  1319. return doAllItemsExist(this.settingsData.domains.ir, this.directDomains);
  1320. },
  1321. set: function (newValue) {
  1322. if (newValue) {
  1323. this.directDomains = [...this.directDomains, ...this.settingsData.domains.ir];
  1324. } else {
  1325. this.directDomains = this.directDomains.filter(data => !this.settingsData.domains.ir.includes(data));
  1326. }
  1327. }
  1328. },
  1329. ChinaIpDirectSettings: {
  1330. get: function () {
  1331. return doAllItemsExist(this.settingsData.ips.cn, this.directIPs);
  1332. },
  1333. set: function (newValue) {
  1334. if (newValue) {
  1335. this.directIPs = [...this.directIPs, ...this.settingsData.ips.cn];
  1336. } else {
  1337. this.directIPs = this.directIPs.filter(data => !this.settingsData.ips.cn.includes(data));
  1338. }
  1339. }
  1340. },
  1341. ChinaDomainDirectSettings: {
  1342. get: function () {
  1343. return doAllItemsExist(this.settingsData.domains.cn, this.directDomains);
  1344. },
  1345. set: function (newValue) {
  1346. if (newValue) {
  1347. this.directDomains = [...this.directDomains, ...this.settingsData.domains.cn];
  1348. } else {
  1349. this.directDomains = this.directDomains.filter(data => !this.settingsData.domains.cn.includes(data));
  1350. }
  1351. }
  1352. },
  1353. RussiaIpDirectSettings: {
  1354. get: function () {
  1355. return doAllItemsExist(this.settingsData.ips.ru, this.directIPs);
  1356. },
  1357. set: function (newValue) {
  1358. if (newValue) {
  1359. this.directIPs = [...this.directIPs, ...this.settingsData.ips.ru];
  1360. } else {
  1361. this.directIPs = this.directIPs.filter(data => !this.settingsData.ips.ru.includes(data));
  1362. }
  1363. }
  1364. },
  1365. RussiaDomainDirectSettings: {
  1366. get: function () {
  1367. return doAllItemsExist(this.settingsData.domains.ru, this.directDomains);
  1368. },
  1369. set: function (newValue) {
  1370. if (newValue) {
  1371. this.directDomains = [...this.directDomains, ...this.settingsData.domains.ru];
  1372. } else {
  1373. this.directDomains = this.directDomains.filter(data => !this.settingsData.domains.ru.includes(data));
  1374. }
  1375. }
  1376. },
  1377. VNIpDirectSettings: {
  1378. get: function () {
  1379. return doAllItemsExist(this.settingsData.ips.vn, this.directIPs);
  1380. },
  1381. set: function (newValue) {
  1382. if (newValue) {
  1383. this.directIPs = [...this.directIPs, ...this.settingsData.ips.vn];
  1384. } else {
  1385. this.directIPs = this.directIPs.filter(data => !this.settingsData.ips.vn.includes(data));
  1386. }
  1387. }
  1388. },
  1389. VNDomainDirectSettings: {
  1390. get: function () {
  1391. return doAllItemsExist(this.settingsData.domains.vn, this.directDomains);
  1392. },
  1393. set: function (newValue) {
  1394. if (newValue) {
  1395. this.directDomains = [...this.directDomains, ...this.settingsData.domains.vn];
  1396. } else {
  1397. this.directDomains = this.directDomains.filter(data => !this.settingsData.domains.vn.includes(data));
  1398. }
  1399. }
  1400. },
  1401. WarpExist: {
  1402. get: function() {
  1403. return this.templateSettings ? this.templateSettings.outbounds.findIndex((o) => o.tag == "warp")>=0 : false;
  1404. },
  1405. },
  1406. GoogleWARPSettings: {
  1407. get: function () {
  1408. return doAllItemsExist(this.settingsData.domains.google, this.warpDomains);
  1409. },
  1410. set: function (newValue) {
  1411. if (newValue) {
  1412. this.warpDomains = [...this.warpDomains, ...this.settingsData.domains.google];
  1413. } else {
  1414. this.warpDomains = this.warpDomains.filter(data => !this.settingsData.domains.google.includes(data));
  1415. }
  1416. },
  1417. },
  1418. OpenAIWARPSettings: {
  1419. get: function () {
  1420. return doAllItemsExist(this.settingsData.domains.openai, this.warpDomains);
  1421. },
  1422. set: function (newValue) {
  1423. if (newValue) {
  1424. this.warpDomains = [...this.warpDomains, ...this.settingsData.domains.openai];
  1425. } else {
  1426. this.warpDomains = this.warpDomains.filter(data => !this.settingsData.domains.openai.includes(data));
  1427. }
  1428. },
  1429. },
  1430. NetflixWARPSettings: {
  1431. get: function () {
  1432. return doAllItemsExist(this.settingsData.domains.netflix, this.warpDomains);
  1433. },
  1434. set: function (newValue) {
  1435. if (newValue) {
  1436. this.warpDomains = [...this.warpDomains, ...this.settingsData.domains.netflix];
  1437. } else {
  1438. this.warpDomains = this.warpDomains.filter(data => !this.settingsData.domains.netflix.includes(data));
  1439. }
  1440. },
  1441. },
  1442. SpotifyWARPSettings: {
  1443. get: function () {
  1444. return doAllItemsExist(this.settingsData.domains.spotify, this.warpDomains);
  1445. },
  1446. set: function (newValue) {
  1447. if (newValue) {
  1448. this.warpDomains = [...this.warpDomains, ...this.settingsData.domains.spotify];
  1449. } else {
  1450. this.warpDomains = this.warpDomains.filter(data => !this.settingsData.domains.spotify.includes(data));
  1451. }
  1452. },
  1453. },
  1454. },
  1455. });
  1456. </script>
  1457. </body>
  1458. </html>