xray.html 84 KB

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