xray.html 114 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032
  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. <transition name="list" appear>
  61. <a-alert type="error" v-if="showAlert" style="margin-bottom: 10px"
  62. message='{{ i18n "secAlertTitle" }}'
  63. color="red"
  64. description='{{ i18n "secAlertSsl" }}'
  65. show-icon closable
  66. >
  67. </a-alert>
  68. </transition>
  69. <a-space direction="vertical">
  70. <a-card hoverable style="margin-bottom: .5rem;">
  71. <a-row>
  72. <a-col :xs="24" :sm="8" style="padding: 4px;">
  73. <a-space direction="horizontal">
  74. <a-button type="primary" :disabled="saveBtnDisable" @click="updateXraySetting">{{ i18n "pages.xray.save" }}</a-button>
  75. <a-button type="danger" :disabled="!saveBtnDisable" @click="restartXray">{{ i18n "pages.xray.restart" }}</a-button>
  76. <a-popover v-if="restartResult"
  77. :overlay-class-name="themeSwitcher.currentTheme">
  78. <span slot="title" style="font-size: 12pt">Error in running xray-core</span>
  79. <template slot="content">
  80. <p style="max-width: 400px" v-for="line in restartResult.split('\n')">[[ line ]]</p>
  81. </template>
  82. <a-icon type="question-circle"></a-icon>
  83. </a-popover>
  84. </a-space>
  85. </a-col>
  86. <a-col :xs="24" :sm="16">
  87. <template>
  88. <div>
  89. <a-back-top :target="() => document.getElementById('content-layout')" visibility-height="200">
  90. </a-back-top>
  91. <a-alert type="warning" style="float: right; width: fit-content"
  92. message='{{ i18n "pages.settings.infoDesc" }}'
  93. show-icon
  94. >
  95. </div>
  96. </template>
  97. </a-col>
  98. </a-row>
  99. </a-card>
  100. <a-tabs class="ant-card-dark-box-nohover" default-active-key="tpl-1"
  101. @change="(activeKey) => { if(activeKey == 'tpl-advanced') this.changeCode(); }"
  102. :class="themeSwitcher.currentTheme">
  103. <a-tab-pane key="tpl-1" tab='{{ i18n "pages.xray.basicTemplate"}}'>
  104. <a-space direction="horizontal" style="padding: 20px 20px">
  105. <a-button type="danger" @click="resetXrayConfigToDefault">{{ i18n "pages.settings.resetDefaultConfig" }}</a-button>
  106. </a-space>
  107. <a-collapse>
  108. <a-collapse-panel header='{{ i18n "pages.xray.generalConfigs"}}'>
  109. <a-row :xs="24" :sm="24" :lg="12">
  110. <a-alert type="warning" style="text-align: center;">
  111. <template slot="message">
  112. <a-icon type="exclamation-circle" theme="filled" style="color: #FFA031"></a-icon>
  113. {{ i18n "pages.xray.generalConfigsDesc" }}
  114. </template>
  115. </a-alert>
  116. </a-row>
  117. <a-list-item>
  118. <a-row style="padding: 20px">
  119. <a-col :lg="24" :xl="12">
  120. <a-list-item-meta title='{{ i18n "pages.xray.FreedomStrategy" }}'
  121. description='{{ i18n "pages.xray.FreedomStrategyDesc" }}' />
  122. </a-col>
  123. <a-col :lg="24" :xl="12">
  124. <template>
  125. <a-select v-model="freedomStrategy" :dropdown-class-name="themeSwitcher.currentTheme"
  126. style="width: 100%">
  127. <a-select-option v-for="s in OutboundDomainStrategies" :value="s">[[ s ]]</a-select-option>
  128. </a-select>
  129. </template>
  130. </a-col>
  131. </a-row>
  132. </a-list-item>
  133. <a-row style="padding: 20px">
  134. <a-col :lg="24" :xl="12">
  135. <a-list-item-meta title='{{ i18n "pages.xray.RoutingStrategy" }}'
  136. description='{{ i18n "pages.xray.RoutingStrategyDesc" }}' />
  137. </a-col>
  138. <a-col :lg="24" :xl="12">
  139. <a-select v-model="routingStrategy" :dropdown-class-name="themeSwitcher.currentTheme"
  140. style="width: 100%">
  141. <a-select-option v-for="s in routingDomainStrategies" :value="s">[[ s ]]</a-select-option>
  142. </a-select>
  143. </a-col>
  144. </a-row>
  145. </a-list-item>
  146. </a-collapse-panel>
  147. <a-collapse-panel header='{{ i18n "pages.xray.logConfigs" }}'>
  148. <a-row :xs="24" :sm="24" :lg="12">
  149. <a-alert type="warning" style="text-align: center;">
  150. <template slot="message">
  151. <a-icon type="exclamation-circle" theme="filled" style="color: #FFA031"></a-icon>
  152. {{ i18n "pages.xray.logConfigsDesc" }}
  153. </template>
  154. </a-alert>
  155. </a-row>
  156. <a-row style="padding: 20px">
  157. <a-col :lg="24" :xl="12">
  158. <a-list-item-meta title='{{ i18n "pages.xray.logLevel" }}'
  159. description='{{ i18n "pages.xray.logLevelDesc" }}' />
  160. </a-col>
  161. <a-col :lg="24" :xl="12">
  162. <template>
  163. <a-select v-model="setLogLevel" :dropdown-class-name="themeSwitcher.currentTheme" style="width: 100%">
  164. <a-select-option v-for="s in logLevel" :value="s">[[ s ]]</a-select-option>
  165. </a-select>
  166. </template>
  167. </a-col>
  168. </a-row>
  169. <a-row style="padding: 20px">
  170. <a-col :lg="24" :xl="12">
  171. <a-list-item-meta title='{{ i18n "pages.xray.accessLog" }}'
  172. description='{{ i18n "pages.xray.accessLogDesc" }}' />
  173. </a-col>
  174. <a-col :lg="24" :xl="12">
  175. <template>
  176. <a-select v-model="accessLog" :dropdown-class-name="themeSwitcher.currentTheme" style="width: 100%">
  177. <a-select-option v-for="s in access" :value="s">[[ s ]]</a-select-option>
  178. </a-select>
  179. </template>
  180. </a-col>
  181. </a-row>
  182. <a-row style="padding: 20px">
  183. <a-col :lg="24" :xl="12">
  184. <a-list-item-meta title='{{ i18n "pages.xray.errorLog" }}'
  185. description='{{ i18n "pages.xray.errorLogDesc" }}' />
  186. </a-col>
  187. <a-col :lg="24" :xl="12">
  188. <template>
  189. <a-select v-model="errorLog" :dropdown-class-name="themeSwitcher.currentTheme" style="width: 100%">
  190. <a-select-option v-for="s in error" :value="s">[[ s ]]</a-select-option>
  191. </a-select>
  192. </template>
  193. </a-col>
  194. </a-row>
  195. </a-list-item>
  196. </a-collapse-panel>
  197. <a-collapse-panel header='{{ i18n "pages.xray.blockConfigs"}}'>
  198. <a-row :xs="24" :sm="24" :lg="12">
  199. <a-alert type="warning" style="text-align: center;">
  200. <template slot="message">
  201. <a-icon type="exclamation-circle" theme="filled" style="color: #FFA031"></a-icon>
  202. {{ i18n "pages.xray.blockConfigsDesc" }}
  203. </template>
  204. </a-alert>
  205. </a-row>
  206. <setting-list-item type="switch" title='{{ i18n "pages.xray.Torrent"}}' desc='{{ i18n "pages.xray.TorrentDesc"}}' v-model="torrentSettings"></setting-list-item>
  207. <setting-list-item type="switch" title='{{ i18n "pages.xray.PrivateIp"}}' desc='{{ i18n "pages.xray.PrivateIpDesc"}}' v-model="privateIpSettings"></setting-list-item>
  208. <setting-list-item type="switch" title='{{ i18n "pages.xray.Ads"}}' desc='{{ i18n "pages.xray.AdsDesc"}}' v-model="AdsSettings"></setting-list-item>
  209. <setting-list-item type="switch" title='{{ i18n "pages.xray.Family"}}' desc='{{ i18n "pages.xray.FamilyDesc"}}' v-model="familyProtectSettings"></setting-list-item>
  210. <setting-list-item type="switch" title='{{ i18n "pages.xray.Security"}}' desc='{{ i18n "pages.xray.SecurityDesc"}}' v-model="SecuritySettings"></setting-list-item>
  211. <setting-list-item type="switch" title='{{ i18n "pages.xray.Speedtest"}}' desc='{{ i18n "pages.xray.SpeedtestDesc"}}' v-model="SpeedTestSettings"></setting-list-item>
  212. </a-collapse-panel>
  213. <a-collapse-panel header='{{ i18n "pages.xray.blockCountryConfigs"}}'>
  214. <a-row :xs="24" :sm="24" :lg="12">
  215. <a-alert type="warning" style="text-align: center;">
  216. <template slot="message">
  217. <a-icon type="exclamation-circle" theme="filled" style="color: #FFA031"></a-icon>
  218. {{ i18n "pages.xray.blockCountryConfigsDesc" }}
  219. </template>
  220. </a-alert>
  221. </a-row>
  222. <setting-list-item type="switch" title='{{ i18n "pages.xray.IRIp"}}' desc='{{ i18n "pages.xray.IRIpDesc"}}' v-model="IRIpSettings"></setting-list-item>
  223. <setting-list-item type="switch" title='{{ i18n "pages.xray.IRDomain"}}' desc='{{ i18n "pages.xray.IRDomainDesc"}}' v-model="IRDomainSettings"></setting-list-item>
  224. <setting-list-item type="switch" title='{{ i18n "pages.xray.ChinaIp"}}' desc='{{ i18n "pages.xray.ChinaIpDesc"}}' v-model="ChinaIpSettings"></setting-list-item>
  225. <setting-list-item type="switch" title='{{ i18n "pages.xray.ChinaDomain"}}' desc='{{ i18n "pages.xray.ChinaDomainDesc"}}' v-model="ChinaDomainSettings"></setting-list-item>
  226. <setting-list-item type="switch" title='{{ i18n "pages.xray.RussiaIp"}}' desc='{{ i18n "pages.xray.RussiaIpDesc"}}' v-model="RussiaIpSettings"></setting-list-item>
  227. <setting-list-item type="switch" title='{{ i18n "pages.xray.RussiaDomain"}}' desc='{{ i18n "pages.xray.RussiaDomainDesc"}}' v-model="RussiaDomainSettings"></setting-list-item>
  228. <setting-list-item type="switch" title='{{ i18n "pages.xray.VNIp"}}' desc='{{ i18n "pages.xray.VNIpDesc"}}' v-model="VNIpSettings"></setting-list-item>
  229. <setting-list-item type="switch" title='{{ i18n "pages.xray.VNDomain"}}' desc='{{ i18n "pages.xray.VNDomainDesc"}}' v-model="VNDomainSettings"></setting-list-item>
  230. </a-collapse-panel>
  231. <a-collapse-panel header='{{ i18n "pages.xray.directCountryConfigs"}}'>
  232. <a-row :xs="24" :sm="24" :lg="12">
  233. <a-alert type="warning" style="text-align: center;">
  234. <template slot="message">
  235. <a-icon type="exclamation-circle" theme="filled" style="color: #FFA031"></a-icon>
  236. {{ i18n "pages.xray.directCountryConfigsDesc" }}
  237. </template>
  238. </a-alert>
  239. </a-row>
  240. <setting-list-item type="switch" title='{{ i18n "pages.xray.DirectIRIp"}}' desc='{{ i18n "pages.xray.DirectIRIpDesc"}}' v-model="IRIpDirectSettings"></setting-list-item>
  241. <setting-list-item type="switch" title='{{ i18n "pages.xray.DirectIRDomain"}}' desc='{{ i18n "pages.xray.DirectIRDomainDesc"}}' v-model="IRDomainDirectSettings"></setting-list-item>
  242. <setting-list-item type="switch" title='{{ i18n "pages.xray.DirectChinaIp"}}' desc='{{ i18n "pages.xray.DirectChinaIpDesc"}}' v-model="ChinaIpDirectSettings"></setting-list-item>
  243. <setting-list-item type="switch" title='{{ i18n "pages.xray.DirectChinaDomain"}}' desc='{{ i18n "pages.xray.DirectChinaDomainDesc"}}' v-model="ChinaDomainDirectSettings"></setting-list-item>
  244. <setting-list-item type="switch" title='{{ i18n "pages.xray.DirectRussiaIp"}}' desc='{{ i18n "pages.xray.DirectRussiaIpDesc"}}' v-model="RussiaIpDirectSettings"></setting-list-item>
  245. <setting-list-item type="switch" title='{{ i18n "pages.xray.DirectRussiaDomain"}}' desc='{{ i18n "pages.xray.DirectRussiaDomainDesc"}}' v-model="RussiaDomainDirectSettings"></setting-list-item>
  246. <setting-list-item type="switch" title='{{ i18n "pages.xray.DirectVNIp"}}' desc='{{ i18n "pages.xray.DirectVNIpDesc"}}' v-model="VNIpDirectSettings"></setting-list-item>
  247. <setting-list-item type="switch" title='{{ i18n "pages.xray.DirectVNDomain"}}' desc='{{ i18n "pages.xray.DirectVNDomainDesc"}}' v-model="VNDomainDirectSettings"></setting-list-item>
  248. </a-collapse-panel>
  249. <a-collapse-panel header='{{ i18n "pages.xray.ipv4Configs"}}'>
  250. <a-row :xs="24" :sm="24" :lg="12">
  251. <a-alert type="warning" style="text-align: center;">
  252. <template slot="message">
  253. <a-icon type="exclamation-circle" theme="filled" style="color: #FFA031"></a-icon>
  254. {{ i18n "pages.xray.ipv4ConfigsDesc" }}
  255. </template>
  256. </a-alert>
  257. </a-row>
  258. <setting-list-item type="switch" title='{{ i18n "pages.xray.GoogleIPv4"}}' desc='{{ i18n "pages.xray.GoogleIPv4Desc"}}' v-model="GoogleIPv4Settings"></setting-list-item>
  259. <setting-list-item type="switch" title='{{ i18n "pages.xray.NetflixIPv4"}}' desc='{{ i18n "pages.xray.NetflixIPv4Desc"}}' v-model="NetflixIPv4Settings"></setting-list-item>
  260. </a-collapse-panel>
  261. <a-collapse-panel header='{{ i18n "pages.xray.warpConfigs"}}'>
  262. <a-row :xs="24" :sm="24" :lg="12">
  263. <a-alert type="warning" style="text-align: center;">
  264. <template slot="message">
  265. <a-icon type="exclamation-circle" theme="filled" style="color: #FFA031"></a-icon>
  266. {{ i18n "pages.xray.warpConfigsDesc" }}
  267. </template>
  268. </a-alert>
  269. </a-row>
  270. <template v-if="WarpExist">
  271. <setting-list-item type="switch" title='{{ i18n "pages.xray.GoogleWARP"}}' desc='{{ i18n "pages.xray.GoogleWARPDesc"}}' v-model="GoogleWARPSettings"></setting-list-item>
  272. <setting-list-item type="switch" title='{{ i18n "pages.xray.OpenAIWARP"}}' desc='{{ i18n "pages.xray.OpenAIWARPDesc"}}' v-model="OpenAIWARPSettings"></setting-list-item>
  273. <setting-list-item type="switch" title='{{ i18n "pages.xray.NetflixWARP"}}' desc='{{ i18n "pages.xray.NetflixWARPDesc"}}' v-model="NetflixWARPSettings"></setting-list-item>
  274. <setting-list-item type="switch" title='{{ i18n "pages.xray.SpotifyWARP"}}' desc='{{ i18n "pages.xray.SpotifyWARPDesc"}}' v-model="SpotifyWARPSettings"></setting-list-item>
  275. <setting-list-item type="switch" title='{{ i18n "pages.xray.MetaWARP"}}' desc='{{ i18n "pages.xray.MetaWARPDesc"}}' v-model="MetaWARPSettings"></setting-list-item>
  276. <setting-list-item type="switch" title='{{ i18n "pages.xray.AppleWARP"}}' desc='{{ i18n "pages.xray.AppleWARPDesc"}}' v-model="AppleWARPSettings"></setting-list-item>
  277. <setting-list-item type="switch" title='{{ i18n "pages.xray.RedditWARP"}}' desc='{{ i18n "pages.xray.RedditWARPDesc"}}' v-model="RedditWARPSettings"></setting-list-item>
  278. </template>
  279. <a-button v-else type="primary" icon="cloud" style="margin: 15px 20px;" @click="showWarp()">WARP</a-button>
  280. </a-collapse-panel>
  281. </a-collapse>
  282. </a-tab-pane>
  283. <a-tab-pane key="tpl-2" tab='{{ i18n "pages.xray.Routings"}}' style="padding-top: 20px;">
  284. <a-alert type="warning" style="margin-bottom: 10px; width: fit-content"
  285. message='{{ i18n "pages.xray.RoutingsDesc"}}' show-icon></a-alert>
  286. <a-button type="primary" icon="plus" @click="addRule">{{ i18n "pages.xray.rules.add" }}</a-button>
  287. <a-table :columns="isMobile ? rulesMobileColumns : rulesColumns" bordered
  288. :row-key="r => r.key"
  289. :data-source="routingRuleData"
  290. :scroll="isMobile ? {} : { x: 1000 }"
  291. :pagination="false"
  292. :indent-size="0"
  293. :style="isMobile ? 'padding: 5px 0' : 'margin-top: 10px;'">
  294. <template slot="action" slot-scope="text, rule, index">
  295. [[ index+1 ]]
  296. <a-dropdown :trigger="['click']">
  297. <a-icon @click="e => e.preventDefault()" type="more" style="font-size: 16px; text-decoration: bold;"></a-icon>
  298. <a-menu slot="overlay" :theme="themeSwitcher.currentTheme">
  299. <a-menu-item v-if="index>0" @click="replaceRule(index,0)">
  300. <a-icon type="vertical-align-top"></a-icon>
  301. {{ i18n "pages.xray.rules.first"}}
  302. </a-menu-item>
  303. <a-menu-item v-if="index>0" @click="replaceRule(index,index-1)">
  304. <a-icon type="arrow-up"></a-icon>
  305. {{ i18n "pages.xray.rules.up"}}
  306. </a-menu-item>
  307. <a-menu-item v-if="index<routingRuleData.length-1" @click="replaceRule(index,index+1)">
  308. <a-icon type="arrow-down"></a-icon>
  309. {{ i18n "pages.xray.rules.down"}}
  310. </a-menu-item>
  311. <a-menu-item v-if="index<routingRuleData.length-1" @click="replaceRule(index,routingRuleData.length-1)">
  312. <a-icon type="vertical-align-bottom"></a-icon>
  313. {{ i18n "pages.xray.rules.last"}}
  314. </a-menu-item>
  315. <a-menu-item @click="editRule(index)">
  316. <a-icon type="edit"></a-icon>
  317. {{ i18n "edit" }}
  318. </a-menu-item>
  319. <a-menu-item @click="deleteRule(index)">
  320. <span style="color: #FF4D4F">
  321. <a-icon type="delete"></a-icon> {{ i18n "delete"}}
  322. </span>
  323. </a-menu-item>
  324. </a-menu>
  325. </a-dropdown>
  326. </template>
  327. <template slot="inbound" slot-scope="text, rule, index">
  328. <a-popover :overlay-class-name="themeSwitcher.currentTheme">
  329. <template slot="content">
  330. <p v-if="rule.inboundTag">Inbound Tag: [[ rule.inboundTag ]]</p>
  331. <p v-if="rule.user">User email: [[ rule.user ]]</p>
  332. </template>
  333. [[ [rule.inboundTag,rule.user].join('\n') ]]
  334. </a-popover>
  335. </template>
  336. <template slot="outbound" slot-scope="text, rule, index">
  337. <a-popover :overlay-class-name="themeSwitcher.currentTheme">
  338. <template slot="content">
  339. <p v-if="rule.outboundTag">Outbound Tag: [[ rule.outboundTag ]]</p>
  340. </template>
  341. [[ rule.outboundTag ]]
  342. </a-popover>
  343. </template>
  344. <template slot="balancer" slot-scope="text, rule, index">
  345. <a-popover :overlay-class-name="themeSwitcher.currentTheme">
  346. <template slot="content">
  347. <p v-if="rule.balancerTag">Balancer Tag: [[ rule.balancerTag ]]</p>
  348. </template>
  349. [[ rule.balancerTag ]]
  350. </a-popover>
  351. </template>
  352. <template slot="info" slot-scope="text, rule, index">
  353. <a-popover placement="bottomRight"
  354. v-if="(rule.source+rule.sourcePort+rule.network+rule.protocol+rule.attrs+rule.ip+rule.domain+rule.port).length>0"
  355. :overlay-class-name="themeSwitcher.currentTheme" trigger="click">
  356. <template slot="content">
  357. <table cellpadding="2" style="max-width: 300px;">
  358. <tr v-if="rule.source">
  359. <td>Source</td>
  360. <td><a-tag color="blue" v-for="r in rule.source.split(',')">[[ r ]]</a-tag></td>
  361. </tr>
  362. <tr v-if="rule.sourcePort">
  363. <td>Source Port</td>
  364. <td><a-tag color="green" v-for="r in rule.sourcePort.split(',')">[[ r ]]</a-tag></td>
  365. </tr>
  366. <tr v-if="rule.network">
  367. <td>Network</td>
  368. <td><a-tag color="blue" v-for="r in rule.network.split(',')">[[ r ]]</a-tag></td>
  369. </tr>
  370. <tr v-if="rule.protocol">
  371. <td>Protocol</td>
  372. <td><a-tag color="green" v-for="r in rule.protocol.split(',')">[[ r ]]</a-tag></td>
  373. </tr>
  374. <tr v-if="rule.attrs">
  375. <td>Attrs</td>
  376. <td><a-tag color="blue" v-for="r in rule.attrs.split(',')">[[ r ]]</a-tag></td>
  377. </tr>
  378. <tr v-if="rule.ip">
  379. <td>IP</td>
  380. <td><a-tag color="green" v-for="r in rule.ip.split(',')">[[ r ]]</a-tag></td>
  381. </tr>
  382. <tr v-if="rule.domain">
  383. <td>Domain</td>
  384. <td><a-tag color="blue" v-for="r in rule.domain.split(',')">[[ r ]]</a-tag></td>
  385. </tr>
  386. <tr v-if="rule.port">
  387. <td>Port</td>
  388. <td><a-tag color="green" v-for="r in rule.port.split(',')">[[ r ]]</a-tag></td>
  389. </tr>
  390. </table>
  391. </template>
  392. <a-button shape="round" size="small" style="font-size: 14px; padding: 0 10px;">
  393. <a-icon type="info"></a-icon>
  394. </a-button>
  395. </a-popover>
  396. </template>
  397. </a-table>
  398. </a-tab-pane>
  399. <a-tab-pane key="tpl-3" tab='{{ i18n "pages.xray.Outbounds"}}' style="padding-top: 20px;" force-render="true">
  400. <a-row>
  401. <a-col :xs="12" :sm="12" :lg="12">
  402. <a-button type="primary" icon="plus" @click="addOutbound()" style="margin-bottom: 10px;">{{ i18n
  403. "pages.xray.outbound.addOutbound" }}</a-button>
  404. <a-button type="primary" icon="cloud" @click="showWarp()" style="margin-bottom: 10px;">WARP</a-button>
  405. </a-col>
  406. <a-col :xs="12" :sm="12" :lg="12" style="text-align: right;">
  407. <a-icon type="sync" :spin="refreshing" @click="refreshOutboundTraffic()" style="margin: 0 5px;"></a-icon>
  408. <a-icon type="retweet" @click="resetOutboundTraffic(-1)"></a-icon>
  409. </a-col>
  410. </a-row>
  411. <a-table :columns="outboundColumns" bordered
  412. :row-key="r => r.key"
  413. :data-source="outboundData"
  414. :scroll="isMobile ? {} : { x: 200 }"
  415. :pagination="false"
  416. :indent-size="0"
  417. :style="isMobile ? 'padding: 5px 5px' : 'margin-right: 1px;'">
  418. <template slot="action" slot-scope="text, outbound, index">
  419. [[ index+1 ]]
  420. <a-dropdown :trigger="['click']">
  421. <a-icon @click="e => e.preventDefault()" type="more" style="font-size: 16px; text-decoration: bold;"></a-icon>
  422. <a-menu slot="overlay" :theme="themeSwitcher.currentTheme">
  423. <a-menu-item v-if="index>0" @click="setFirstOutbound(index)">
  424. <a-icon type="vertical-align-top"></a-icon>
  425. {{ i18n "pages.xray.rules.first"}}
  426. </a-menu-item>
  427. <a-menu-item @click="editOutbound(index)">
  428. <a-icon type="edit"></a-icon>
  429. {{ i18n "edit" }}
  430. </a-menu-item>
  431. <a-menu-item @click="resetOutboundTraffic(index)">
  432. <span>
  433. <a-icon type="retweet"></a-icon> {{ i18n "pages.inbounds.resetTraffic"}}
  434. </span>
  435. </a-menu-item>
  436. <a-menu-item @click="deleteOutbound(index)">
  437. <span style="color: #FF4D4F">
  438. <a-icon type="delete"></a-icon> {{ i18n "delete"}}
  439. </span>
  440. </a-menu-item>
  441. </a-menu>
  442. </a-dropdown>
  443. </template>
  444. <template slot="address" slot-scope="text, outbound, index">
  445. <p style="margin: 0 5px;" v-for="addr in findOutboundAddress(outbound)">[[ addr ]]</p>
  446. </template>
  447. <template slot="protocol" slot-scope="text, outbound, index">
  448. <a-tag style="margin:0;" color="purple">[[ outbound.protocol ]]</a-tag>
  449. <template v-if="[Protocols.VMess, Protocols.VLESS, Protocols.Trojan, Protocols.Shadowsocks].includes(outbound.protocol)">
  450. <a-tag style="margin:0;" color="blue">[[ outbound.streamSettings.network ]]</a-tag>
  451. <a-tag style="margin:0;" v-if="outbound.streamSettings.security=='tls'" color="green">tls</a-tag>
  452. <a-tag style="margin:0;" v-if="outbound.streamSettings.security=='reality'" color="green">reality</a-tag>
  453. </template>
  454. </template>
  455. <template slot="traffic" slot-scope="text, outbound, index">
  456. <a-tag color="green">[[ findOutboundTraffic(outbound) ]]</a-tag>
  457. </template>
  458. </a-table>
  459. </a-tab-pane>
  460. <a-tab-pane key="tpl-4" tab='{{ i18n "pages.xray.outbound.reverse"}}' style="padding-top: 20px;" force-render="true">
  461. <a-button type="primary" icon="plus" @click="addReverse()" style="margin-bottom: 10px;">{{ i18n "pages.xray.outbound.addReverse" }}</a-button>
  462. <a-table :columns="reverseColumns" bordered v-if="reverseData.length>0"
  463. :row-key="r => r.key"
  464. :data-source="reverseData"
  465. :scroll="isMobile ? {} : { x: 200 }"
  466. :pagination="false"
  467. :indent-size="0"
  468. :style="isMobile ? 'padding: 5px 0' : 'margin-left: 1px;'">
  469. <template slot="action" slot-scope="text, reverse, index">
  470. [[ index+1 ]]
  471. <a-dropdown :trigger="['click']">
  472. <a-icon @click="e => e.preventDefault()" type="more" style="font-size: 16px; text-decoration: bold;"></a-icon>
  473. <a-menu slot="overlay" :theme="themeSwitcher.currentTheme">
  474. <a-menu-item @click="editReverse(index)">
  475. <a-icon type="edit"></a-icon>
  476. {{ i18n "edit" }}
  477. </a-menu-item>
  478. <a-menu-item @click="deleteReverse(index)">
  479. <span style="color: #FF4D4F">
  480. <a-icon type="delete"></a-icon> {{ i18n "delete"}}
  481. </span>
  482. </a-menu-item>
  483. </a-menu>
  484. </a-dropdown>
  485. </template>
  486. </a-table>
  487. </a-tab-pane>
  488. <a-tab-pane key="tpl-5" tab='{{ i18n "pages.xray.Balancers"}}' style="padding-top: 20px;" force-render="true">
  489. <a-alert type="warning" style="margin-bottom: 10px; width: fit-content"
  490. message='{{ i18n "pages.xray.balancer.balancerDesc" }}' show-icon></a-alert>
  491. <a-button type="primary" icon="plus" @click="addBalancer()" style="margin-bottom: 10px;">{{ i18n "pages.xray.balancer.addBalancer"}}</a-button>
  492. <a-table :columns="balancerColumns" bordered v-if="balancersData.length>0"
  493. :row-key="r => r.key"
  494. :data-source="balancersData"
  495. :scroll="isMobile ? {} : { x: 200 }"
  496. :pagination="false"
  497. :indent-size="0"
  498. :style="isMobile ? 'padding: 5px 0' : 'margin-left: 1px;'">
  499. <template slot="action" slot-scope="text, balancer, index">
  500. [[ index+1 ]]
  501. <a-dropdown :trigger="['click']">
  502. <a-icon @click="e => e.preventDefault()" type="more" style="font-size: 16px; text-decoration: bold;"></a-icon>
  503. <a-menu slot="overlay" :theme="themeSwitcher.currentTheme">
  504. <a-menu-item @click="editBalancer(index)">
  505. <a-icon type="edit"></a-icon>
  506. {{ i18n "edit" }}
  507. </a-menu-item>
  508. <a-menu-item @click="deleteBalancer(index)">
  509. <span style="color: #FF4D4F">
  510. <a-icon type="delete"></a-icon> {{ i18n "delete"}}
  511. </span>
  512. </a-menu-item>
  513. </a-menu>
  514. </a-dropdown>
  515. </template>
  516. <template slot="strategy" slot-scope="text, balancer, index">
  517. <a-tag style="margin:0;" v-if="balancer.strategy=='random'" color="purple">Random</a-tag>
  518. <a-tag style="margin:0;" v-if="balancer.strategy=='roundRobin'" color="green">Round Robin</a-tag>
  519. </template>
  520. <template slot="selector" slot-scope="text, balancer, index">
  521. <a-tag class="info-large-tag" style="margin:1;" v-for="sel in balancer.selector">[[ sel ]]</a-tag>
  522. </template>
  523. </a-table>
  524. </a-tab-pane>
  525. <a-tab-pane key="tpl-6" tab='DNS' style="padding-top: 20px;" force-render="true">
  526. <setting-list-item type="switch" title='{{ i18n "pages.xray.dns.enable" }}' desc='{{ i18n "pages.xray.dns.enableDesc" }}' v-model="enableDNS"></setting-list-item>
  527. <template v-if="enableDNS">
  528. <a-list-item>
  529. <a-row style="padding: 20px">
  530. <a-col :lg="24" :xl="12">
  531. <a-list-item-meta title='{{ i18n "pages.xray.dns.strategy" }}' description='{{ i18n "pages.xray.dns.strategyDesc" }}' />
  532. </a-col>
  533. <a-col :lg="24" :xl="12">
  534. <a-select
  535. v-model="dnsStrategy"
  536. style="width: 100%"
  537. :dropdown-class-name="themeSwitcher.currentTheme">
  538. <a-select-option :value="l" :label="l" v-for="l in ['UseIP', 'UseIPv4', 'UseIPv6']">
  539. [[ l ]]
  540. </a-select-option>
  541. </a-select>
  542. </a-col>
  543. </a-row>
  544. </a-list-item>
  545. <a-divider>DNS</a-divider>
  546. <a-button type="primary" icon="plus" @click="addDNSServer()" style="margin-bottom: 10px;">{{ i18n "pages.xray.dns.add" }}</a-button>
  547. <a-table :columns="dnsColumns" bordered v-if="dnsServers.length>0"
  548. :row-key="r => r.key"
  549. :data-source="dnsServers"
  550. :scroll="isMobile ? {} : { x: 200 }"
  551. :pagination="false"
  552. :indent-size="0"
  553. :style="isMobile ? 'padding: 5px 0' : 'margin-left: 1px;'">
  554. <template slot="action" slot-scope="text,dns,index">
  555. [[ index+1 ]]
  556. <a-dropdown :trigger="['click']">
  557. <a-icon @click="e => e.preventDefault()" type="more" style="font-size: 16px; text-decoration: bold;"></a-icon>
  558. <a-menu slot="overlay" :theme="themeSwitcher.currentTheme">
  559. <a-menu-item @click="editDNSServer(index)">
  560. <a-icon type="edit"></a-icon>
  561. {{ i18n "edit" }}
  562. </a-menu-item>
  563. <a-menu-item @click="deleteDNSServer(index)">
  564. <span style="color: #FF4D4F">
  565. <a-icon type="delete"></a-icon> {{ i18n "delete"}}
  566. </span>
  567. </a-menu-item>
  568. </a-menu>
  569. </a-dropdown>
  570. </template>
  571. <template slot="address" slot-scope="dns,index">
  572. <span v-if="typeof dns == 'object'">[[ dns.address ]]</span>
  573. <span v-else>[[ dns ]]</span>
  574. </template>
  575. <template slot="domain" slot-scope="dns,index">
  576. <span v-if="typeof dns == 'object'">[[ dns.domains.join(",") ]]</span>
  577. </template>
  578. </a-table>
  579. <a-divider>Fake DNS</a-divider>
  580. <a-button type="primary" icon="plus" @click="addFakedns()" style="margin-bottom: 10px;">{{ i18n "pages.xray.fakedns.add" }}</a-button>
  581. <a-table :columns="fakednsColumns" bordered v-if="fakeDns && fakeDns.length>0" :row-key="r => r.key"
  582. :data-source="fakeDns" :scroll="isMobile ? {} : { x: 200 }" :pagination="false" :indent-size="0"
  583. :style="isMobile ? 'padding: 5px 0' : 'margin-left: 1px;'">
  584. <template slot="action" slot-scope="text,fakedns,index">
  585. [[ index+1 ]]
  586. <a-dropdown :trigger="['click']">
  587. <a-icon @click="e => e.preventDefault()" type="more"
  588. style="font-size: 16px; text-decoration: bold;"></a-icon>
  589. <a-menu slot="overlay" :theme="themeSwitcher.currentTheme">
  590. <a-menu-item @click="editFakedns(index)">
  591. <a-icon type="edit"></a-icon>
  592. {{ i18n "edit" }}
  593. </a-menu-item>
  594. <a-menu-item @click="deleteFakedns(index)">
  595. <span style="color: #FF4D4F">
  596. <a-icon type="delete"></a-icon> {{ i18n "delete"}}
  597. </span>
  598. </a-menu-item>
  599. </a-menu>
  600. </a-dropdown>
  601. </template>
  602. </a-table>
  603. </template>
  604. </a-tab-pane>
  605. <a-tab-pane key="tpl-advanced" tab='{{ i18n "pages.xray.advancedTemplate"}}' style="padding-top: 20px;" force-render="true">
  606. <a-list-item-meta title='{{ i18n "pages.xray.Template"}}' description='{{ i18n "pages.xray.TemplateDesc"}}'></a-list-item-meta>
  607. <a-radio-group v-model="advSettings" @change="changeCode" button-style="solid" style="margin: 10px 0;" :size="isMobile ? 'small' : ''">
  608. <a-radio-button value="xraySetting">{{ i18n "pages.xray.completeTemplate"}}</a-radio-button>
  609. <a-radio-button value="inboundSettings">{{ i18n "pages.xray.Inbounds" }}</a-radio-button>
  610. <a-radio-button value="outboundSettings">{{ i18n "pages.xray.Outbounds" }}</a-radio-button>
  611. <a-radio-button value="routingRuleSettings">{{ i18n "pages.xray.Routings" }}</a-radio-button>
  612. </a-radio-group>
  613. <textarea style="position:absolute; left: -800px;" id="xraySetting"></textarea>
  614. </a-tab-pane>
  615. </a-tabs>
  616. </a-space>
  617. </a-spin>
  618. </a-layout-content>
  619. </a-layout>
  620. </a-layout>
  621. {{template "js" .}}
  622. {{template "component/themeSwitcher" .}}
  623. {{template "component/setting"}}
  624. {{template "ruleModal"}}
  625. {{template "outModal"}}
  626. {{template "reverseModal"}}
  627. {{template "balancerModal"}}
  628. {{template "dnsModal"}}
  629. {{template "fakednsModal"}}
  630. {{template "warpModal"}}
  631. <script>
  632. const rulesColumns = [
  633. { title: "#", align: 'center', width: 15, scopedSlots: { customRender: 'action' } },
  634. { title: '{{ i18n "pages.xray.rules.source"}}', children: [
  635. { title: 'IP', dataIndex: "source", align: 'center', width: 20, ellipsis: true },
  636. { title: 'Port', dataIndex: 'sourcePort', align: 'center', width: 10, ellipsis: true } ]},
  637. { title: '{{ i18n "pages.inbounds.network"}}', children: [
  638. { title: 'L4', dataIndex: 'network', align: 'center', width: 10 },
  639. { title: 'Protocol', dataIndex: 'protocol', align: 'center', width: 10, ellipsis: true },
  640. { title: 'Attrs', dataIndex: 'attrs', align: 'center', width: 20, ellipsis: true } ]},
  641. { title: '{{ i18n "pages.xray.rules.dest"}}', children: [
  642. { title: 'IP', dataIndex: 'ip', align: 'center', width: 20, ellipsis: true },
  643. { title: 'Domain', dataIndex: 'domain', align: 'center', width: 20, ellipsis: true },
  644. { title: 'Port', dataIndex: 'port', align: 'center', width: 10, ellipsis: true }]},
  645. { title: '{{ i18n "pages.xray.rules.inbound"}}', children: [
  646. { title: 'Inbound Tag', dataIndex: 'inboundTag', align: 'center', width: 15, ellipsis: true },
  647. { title: 'Client Email', dataIndex: 'user', align: 'center', width: 20, ellipsis: true }]},
  648. { title: '{{ i18n "pages.xray.rules.outbound"}}', dataIndex: 'outboundTag', align: 'center', width: 15 },
  649. { title: '{{ i18n "pages.xray.rules.balancer"}}', dataIndex: 'balancerTag', align: 'center', width: 15 },
  650. ];
  651. const rulesMobileColumns = [
  652. { title: "#", align: 'center', width: 20, scopedSlots: { customRender: 'action' } },
  653. { title: '{{ i18n "pages.xray.rules.inbound"}}', align: 'center', width: 50, ellipsis: true, scopedSlots: { customRender: 'inbound' } },
  654. { title: '{{ i18n "pages.xray.rules.outbound"}}', align: 'center', width: 50, ellipsis: true, scopedSlots: { customRender: 'outbound' } },
  655. { title: '{{ i18n "pages.xray.rules.info"}}', align: 'center', width: 50, ellipsis: true, scopedSlots: { customRender: 'info' } },
  656. ];
  657. const outboundColumns = [
  658. { title: "#", align: 'center', width: 20, scopedSlots: { customRender: 'action' } },
  659. { title: '{{ i18n "pages.xray.outbound.tag"}}', dataIndex: 'tag', align: 'center', width: 50 },
  660. { title: '{{ i18n "protocol"}}', align: 'center', width: 50, scopedSlots: { customRender: 'protocol' } },
  661. { title: '{{ i18n "pages.xray.outbound.address"}}', align: 'center', width: 50, scopedSlots: { customRender: 'address' } },
  662. { title: '{{ i18n "pages.inbounds.traffic" }}', align: 'center', width: 50, scopedSlots: { customRender: 'traffic' } },
  663. ];
  664. const reverseColumns = [
  665. { title: "#", align: 'center', width: 20, scopedSlots: { customRender: 'action' } },
  666. { title: '{{ i18n "pages.xray.outbound.type"}}', dataIndex: 'type', align: 'center', width: 50 },
  667. { title: '{{ i18n "pages.xray.outbound.tag"}}', dataIndex: 'tag', align: 'center', width: 50 },
  668. { title: '{{ i18n "pages.xray.outbound.domain"}}', dataIndex: 'domain', align: 'center', width: 50 },
  669. ];
  670. const dnsColumns = [
  671. { title: "#", align: 'center', width: 20, scopedSlots: { customRender: 'action' } },
  672. { title: '{{ i18n "pages.xray.outbound.address"}}', align: 'center', width: 50, scopedSlots: { customRender: 'address' } },
  673. { title: '{{ i18n "pages.xray.dns.domains"}}', align: 'center', width: 50, scopedSlots: { customRender: 'domain' } },
  674. ];
  675. const fakednsColumns = [
  676. { title: "#", align: 'center', width: 20, scopedSlots: { customRender: 'action' } },
  677. { title: '{{ i18n "pages.xray.fakedns.ipPool"}}', dataIndex: 'ipPool', align: 'center', width: 50 },
  678. { title: '{{ i18n "pages.xray.fakedns.poolSize"}}', dataIndex: 'poolSize', align: 'center', width: 50 },
  679. ];
  680. const balancerColumns = [
  681. { title: "#", align: 'center', width: 20, scopedSlots: { customRender: 'action' } },
  682. { title: '{{ i18n "pages.xray.balancer.tag"}}', dataIndex: 'tag', align: 'center', width: 50 },
  683. { title: '{{ i18n "pages.xray.balancer.balancerStrategy"}}', align: 'center', width: 50, scopedSlots: { customRender: 'strategy' }},
  684. { title: '{{ i18n "pages.xray.balancer.balancerSelectors"}}', align: 'center', width: 100, scopedSlots: { customRender: 'selector' }},
  685. ];
  686. const app = new Vue({
  687. delimiters: ['[[', ']]'],
  688. el: '#app',
  689. data: {
  690. siderDrawer,
  691. themeSwitcher,
  692. isDarkTheme: themeSwitcher.isDarkTheme,
  693. spinning: false,
  694. oldXraySetting: '',
  695. xraySetting: '',
  696. inboundTags: [],
  697. outboundsTraffic: [],
  698. saveBtnDisable: true,
  699. refreshing: false,
  700. restartResult: '',
  701. showAlert: false,
  702. isMobile: window.innerWidth <= 768,
  703. advSettings: 'xraySetting',
  704. cm: null,
  705. cmOptions: {
  706. lineNumbers: true,
  707. mode: "application/json",
  708. lint: true,
  709. styleActiveLine: true,
  710. matchBrackets: true,
  711. theme: "xq",
  712. autoCloseTags: true,
  713. lineWrapping: true,
  714. indentUnit: 2,
  715. indentWithTabs: true,
  716. smartIndent: true,
  717. tabSize: 2,
  718. lineWiseCopyCut: false,
  719. foldGutter: true,
  720. gutters: [
  721. "CodeMirror-lint-markers",
  722. "CodeMirror-linenumbers",
  723. "CodeMirror-foldgutter",
  724. ],
  725. },
  726. ipv4Settings: {
  727. tag: "IPv4",
  728. protocol: "freedom",
  729. settings: {
  730. domainStrategy: "UseIPv4"
  731. }
  732. },
  733. directSettings: {
  734. tag: "direct",
  735. protocol: "freedom"
  736. },
  737. routingDomainStrategies: ["AsIs", "IPIfNonMatch", "IPOnDemand"],
  738. logLevel: ["none" , "debug" , "info" , "warning", "error"],
  739. access: ["none" , "./access.log" ],
  740. error: ["none" , "./error.log" ],
  741. settingsData: {
  742. protocols: {
  743. bittorrent: ["bittorrent"],
  744. },
  745. ips: {
  746. local: ["geoip:private"],
  747. cn: ["geoip:cn"],
  748. ir: ["ext:geoip_IR.dat:ir"],
  749. ru: ["geoip:ru"],
  750. vn: ["ext:geoip_VN.dat:vn"],
  751. },
  752. domains: {
  753. ads: [
  754. "geosite:category-ads-all",
  755. "ext:geosite_IR.dat:category-ads-all"
  756. ],
  757. security: [
  758. "ext:geosite_IR.dat:malware",
  759. "ext:geosite_IR.dat:phishing",
  760. "ext:geosite_IR.dat:cryptominers"
  761. ],
  762. speedtest: ["geosite:speedtest"],
  763. openai: ["geosite:openai"],
  764. google: ["geosite:google"],
  765. spotify: ["geosite:spotify"],
  766. netflix: ["geosite:netflix"],
  767. meta: ["geosite:meta"],
  768. apple: ["geosite:apple"],
  769. reddit: ["geosite:reddit"],
  770. cn: [
  771. "geosite:cn",
  772. "regexp:.*\\.cn$"
  773. ],
  774. ru: [
  775. "geosite:category-gov-ru",
  776. "regexp:.*\\.ru$"
  777. ],
  778. ir: [
  779. "regexp:.*\\.ir$",
  780. "regexp:.*\\.xn--mgba3a4f16a$", // .ایران
  781. "ext:geosite_IR.dat:ir"
  782. ],
  783. vn: [
  784. "regexp:.*\\.vn$",
  785. "ext:geosite_VN.dat:vn",
  786. "ext:geosite_VN.dat:ads"
  787. ]
  788. },
  789. familyProtectDNS: {
  790. "servers": [
  791. "1.1.1.3", // https://developers.cloudflare.com/1.1.1.1/setup/
  792. "1.0.0.3",
  793. "2606:4700:4700::1113",
  794. "2606:4700:4700::1003"
  795. ],
  796. "queryStrategy": "UseIP"
  797. },
  798. }
  799. },
  800. methods: {
  801. loading(spinning = true) {
  802. this.spinning = spinning;
  803. },
  804. async getOutboundsTraffic() {
  805. const msg = await HttpUtil.get("/panel/xray/getOutboundsTraffic");
  806. if (msg.success) {
  807. this.outboundsTraffic = msg.obj;
  808. }
  809. },
  810. async getXraySetting() {
  811. this.loading(true);
  812. const msg = await HttpUtil.post("/panel/xray/");
  813. this.loading(false);
  814. if (msg.success) {
  815. result = JSON.parse(msg.obj);
  816. xs = JSON.stringify(result.xraySetting, null, 2);
  817. this.oldXraySetting = xs;
  818. this.xraySetting = xs;
  819. this.inboundTags = result.inboundTags;
  820. this.saveBtnDisable = true;
  821. }
  822. },
  823. async updateXraySetting() {
  824. this.loading(true);
  825. const msg = await HttpUtil.post("/panel/xray/update", {xraySetting : this.xraySetting});
  826. this.loading(false);
  827. if (msg.success) {
  828. await this.getXraySetting();
  829. }
  830. },
  831. async restartXray() {
  832. this.loading(true);
  833. const msg = await HttpUtil.post("server/restartXrayService");
  834. this.loading(false);
  835. if (msg.success) {
  836. await PromiseUtil.sleep(500);
  837. await this.getXrayResult();
  838. }
  839. this.loading(false);
  840. },
  841. async getXrayResult() {
  842. const msg = await HttpUtil.get("/panel/xray/getXrayResult");
  843. if(msg.success){
  844. this.restartResult=msg.obj;
  845. if(msg.obj.length > 1) Vue.prototype.$message.error(msg.obj);
  846. }
  847. },
  848. async fetchUserSecret() {
  849. this.loading(true);
  850. const userMessage = await HttpUtil.post("/panel/setting/getUserSecret", this.user);
  851. if (userMessage.success) {
  852. this.user = userMessage.obj;
  853. }
  854. this.loading(false);
  855. },
  856. async updateSecret() {
  857. this.loading(true);
  858. const msg = await HttpUtil.post("/panel/setting/updateUserSecret", this.user);
  859. if (msg.success) {
  860. this.user = msg.obj;
  861. window.location.replace(basePath + "logout");
  862. }
  863. this.loading(false);
  864. await this.updateXraySetting();
  865. },
  866. generateRandomString(length) {
  867. var chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
  868. let randomString = "";
  869. for (let i = 0; i < length; i++) {
  870. randomString += chars[Math.floor(Math.random() * chars.length)];
  871. }
  872. return randomString;
  873. },
  874. async getNewSecret() {
  875. this.loading(true);
  876. await PromiseUtil.sleep(600);
  877. const newSecret = this.generateRandomString(64);
  878. this.user.loginSecret = newSecret;
  879. document.getElementById("token").textContent = newSecret;
  880. this.loading(false);
  881. },
  882. async toggleToken(value) {
  883. if (value) {
  884. await this.getNewSecret();
  885. } else {
  886. this.user.loginSecret = "";
  887. }
  888. },
  889. async resetXrayConfigToDefault() {
  890. this.loading(true);
  891. const msg = await HttpUtil.get("/panel/setting/getDefaultJsonConfig");
  892. this.loading(false);
  893. if (msg.success) {
  894. this.templateSettings = JSON.parse(JSON.stringify(msg.obj, null, 2));
  895. this.saveBtnDisable = true;
  896. }
  897. },
  898. syncRulesWithOutbound(tag, setting) {
  899. const newTemplateSettings = this.templateSettings;
  900. const haveRules = newTemplateSettings.routing.rules.some((r) => r?.outboundTag === tag);
  901. const outboundIndex = newTemplateSettings.outbounds.findIndex((o) => o.tag === tag);
  902. if (!haveRules && outboundIndex > 0) {
  903. newTemplateSettings.outbounds.splice(outboundIndex);
  904. }
  905. if (haveRules && outboundIndex < 0) {
  906. newTemplateSettings.outbounds.push(setting);
  907. }
  908. this.templateSettings = newTemplateSettings;
  909. },
  910. templateRuleGetter(routeSettings) {
  911. const { property, outboundTag } = routeSettings;
  912. let result = [];
  913. if (this.templateSettings != null) {
  914. this.templateSettings.routing.rules.forEach(
  915. (routingRule) => {
  916. if (
  917. routingRule.hasOwnProperty(property) &&
  918. routingRule.hasOwnProperty("outboundTag") &&
  919. routingRule.outboundTag === outboundTag
  920. ) {
  921. result.push(...routingRule[property]);
  922. }
  923. }
  924. );
  925. }
  926. return result;
  927. },
  928. templateRuleSetter(routeSettings) {
  929. const { data, property, outboundTag } = routeSettings;
  930. const oldTemplateSettings = this.templateSettings;
  931. const newTemplateSettings = oldTemplateSettings;
  932. currentProperty = this.templateRuleGetter({ outboundTag, property })
  933. if (currentProperty.length == 0) {
  934. const propertyRule = {
  935. type: "field",
  936. outboundTag,
  937. [property]: data
  938. };
  939. newTemplateSettings.routing.rules.push(propertyRule);
  940. }
  941. else {
  942. const newRules = [];
  943. insertedOnce = false;
  944. newTemplateSettings.routing.rules.forEach(
  945. (routingRule) => {
  946. if (
  947. routingRule.hasOwnProperty(property) &&
  948. routingRule.hasOwnProperty("outboundTag") &&
  949. routingRule.outboundTag === outboundTag
  950. ) {
  951. if (!insertedOnce && data.length > 0) {
  952. insertedOnce = true;
  953. routingRule[property] = data;
  954. newRules.push(routingRule);
  955. }
  956. }
  957. else {
  958. newRules.push(routingRule);
  959. }
  960. }
  961. );
  962. newTemplateSettings.routing.rules = newRules;
  963. }
  964. this.templateSettings = newTemplateSettings;
  965. },
  966. changeCode() {
  967. if(this.cm != null) {
  968. this.cm.toTextArea();
  969. }
  970. textAreaObj = document.getElementById('xraySetting');
  971. textAreaObj.value = this[this.advSettings];
  972. this.cm = CodeMirror.fromTextArea(textAreaObj, this.cmOptions);
  973. this.cm.on('change',editor => {
  974. value = editor.getValue();
  975. if(this.isJsonString(value)){
  976. this[this.advSettings] = value;
  977. }
  978. });
  979. },
  980. isJsonString(str) {
  981. try {
  982. JSON.parse(str);
  983. } catch (e) {
  984. return false;
  985. }
  986. return true;
  987. },
  988. findOutboundTraffic(o) {
  989. for (const otraffic of this.outboundsTraffic) {
  990. if (otraffic.tag == o.tag) {
  991. return sizeFormat(otraffic.up) + ' / ' + sizeFormat(otraffic.down);
  992. }
  993. }
  994. return sizeFormat(0) + ' / ' + sizeFormat(0);
  995. },
  996. findOutboundAddress(o) {
  997. serverObj = null;
  998. switch(o.protocol){
  999. case Protocols.VMess:
  1000. case Protocols.VLESS:
  1001. serverObj = o.settings.vnext;
  1002. break;
  1003. case Protocols.HTTP:
  1004. case Protocols.Socks:
  1005. case Protocols.Shadowsocks:
  1006. case Protocols.Trojan:
  1007. serverObj = o.settings.servers;
  1008. break;
  1009. case Protocols.DNS:
  1010. return [o.settings.address + ':' + o.settings.port];
  1011. case Protocols.Wireguard:
  1012. return o.settings.peers.map(peer => peer.endpoint);
  1013. default:
  1014. return null;
  1015. }
  1016. return serverObj ? serverObj.map(obj => obj.address + ':' + obj.port) : null;
  1017. },
  1018. addOutbound(){
  1019. outModal.show({
  1020. title: '{{ i18n "pages.xray.outbound.addOutbound"}}',
  1021. okText: '{{ i18n "pages.xray.outbound.addOutbound" }}',
  1022. confirm: (outbound) => {
  1023. outModal.loading();
  1024. if(outbound.tag.length > 0){
  1025. this.templateSettings.outbounds.push(outbound);
  1026. this.outboundSettings = JSON.stringify(this.templateSettings.outbounds);
  1027. }
  1028. outModal.close();
  1029. },
  1030. isEdit: false,
  1031. tags: this.templateSettings.outbounds.map(obj => obj.tag)
  1032. });
  1033. },
  1034. editOutbound(index){
  1035. outModal.show({
  1036. title: '{{ i18n "pages.xray.outbound.editOutbound"}} ' + (index+1),
  1037. outbound: app.templateSettings.outbounds[index],
  1038. confirm: (outbound) => {
  1039. outModal.loading();
  1040. this.templateSettings.outbounds[index] = outbound;
  1041. this.outboundSettings = JSON.stringify(this.templateSettings.outbounds);
  1042. outModal.close();
  1043. },
  1044. isEdit: true,
  1045. tags: this.outboundData.filter((o) => o.key != index ).map(obj => obj.tag)
  1046. });
  1047. },
  1048. deleteOutbound(index){
  1049. outbounds = this.templateSettings.outbounds;
  1050. outbounds.splice(index,1);
  1051. this.outboundSettings = JSON.stringify(outbounds);
  1052. },
  1053. setFirstOutbound(index){
  1054. outbounds = this.templateSettings.outbounds;
  1055. outbounds.splice(0, 0, outbounds.splice(index, 1)[0]);
  1056. this.outboundSettings = JSON.stringify(outbounds);
  1057. },
  1058. async refreshOutboundTraffic() {
  1059. if (!this.refreshing) {
  1060. this.refreshing = true;
  1061. await this.getOutboundsTraffic();
  1062. data = []
  1063. if (this.templateSettings != null) {
  1064. this.templateSettings.outbounds.forEach((o, index) => {
  1065. data.push({'key': index, ...o});
  1066. });
  1067. }
  1068. this.outboundData = data;
  1069. this.refreshing = false;
  1070. }
  1071. },
  1072. async resetOutboundTraffic(index) {
  1073. let tag = "-alltags-";
  1074. if (index >= 0) {
  1075. tag = this.outboundData[index].tag ? this.outboundData[index].tag : ""
  1076. }
  1077. const msg = await HttpUtil.post("/panel/xray/resetOutboundsTraffic", { tag: tag });
  1078. if (msg.success) {
  1079. await this.refreshOutboundTraffic();
  1080. }
  1081. },
  1082. addBalancer() {
  1083. balancerModal.show({
  1084. title: '{{ i18n "pages.xray.balancer.addBalancer"}}',
  1085. okText: '{{ i18n "pages.xray.balancer.addBalancer"}}',
  1086. balancerTags: this.balancersData.filter((o) => !ObjectUtil.isEmpty(o.tag)).map(obj => obj.tag),
  1087. balancer: {
  1088. tag: '',
  1089. strategy: 'random',
  1090. selector: []
  1091. },
  1092. confirm: (balancer) => {
  1093. balancerModal.loading();
  1094. newTemplateSettings = this.templateSettings;
  1095. if (newTemplateSettings.routing.balancers == undefined) {
  1096. newTemplateSettings.routing.balancers = [];
  1097. }
  1098. let tmpBalancer = {
  1099. 'tag': balancer.tag,
  1100. 'selector': balancer.selector
  1101. };
  1102. if (balancer.strategy == 'roundRobin') {
  1103. tmpBalancer.strategy = {
  1104. 'type': balancer.strategy
  1105. };
  1106. }
  1107. newTemplateSettings.routing.balancers.push(tmpBalancer);
  1108. this.templateSettings = newTemplateSettings;
  1109. balancerModal.close();
  1110. },
  1111. isEdit: false
  1112. });
  1113. },
  1114. editBalancer(index) {
  1115. const oldTag = this.balancersData[index].tag;
  1116. balancerModal.show({
  1117. title: '{{ i18n "pages.xray.balancer.editBalancer"}}',
  1118. okText: '{{ i18n "sure" }}',
  1119. balancerTags: this.balancersData.filter((o) => !ObjectUtil.isEmpty(o.tag)).map(obj => obj.tag),
  1120. balancer: this.balancersData[index],
  1121. confirm: (balancer) => {
  1122. balancerModal.loading();
  1123. newTemplateSettings = this.templateSettings;
  1124. let tmpBalancer = {
  1125. 'tag': balancer.tag,
  1126. 'selector': balancer.selector
  1127. };
  1128. if (balancer.strategy == 'roundRobin') {
  1129. tmpBalancer.strategy = {
  1130. 'type': balancer.strategy
  1131. };
  1132. }
  1133. newTemplateSettings.routing.balancers[index] = tmpBalancer;
  1134. // change edited tag if used in rule section
  1135. if (oldTag != balancer.tag) {
  1136. newTemplateSettings.routing.rules.forEach((rule) => {
  1137. if (rule.balancerTag && rule.balancerTag == oldTag) {
  1138. rule.balancerTag = balancer.tag;
  1139. }
  1140. });
  1141. }
  1142. this.templateSettings = newTemplateSettings;
  1143. balancerModal.close();
  1144. },
  1145. isEdit: true
  1146. });
  1147. },
  1148. deleteBalancer(index) {
  1149. newTemplateSettings = this.templateSettings;
  1150. //remove from balancers
  1151. const oldTag = this.balancersData[index].tag;
  1152. this.balancersData.splice(index, 1);
  1153. // remove from settings
  1154. let realIndex = newTemplateSettings.routing.balancers.findIndex((b) => b.tag == oldTag);
  1155. newTemplateSettings.routing.balancers.splice(realIndex, 1);
  1156. // remove related routing rules
  1157. let rules = [];
  1158. newTemplateSettings.routing.rules.forEach((r) => {
  1159. if (!r.balancerTag || r.balancerTag != oldTag) {
  1160. rules.push(r);
  1161. }
  1162. });
  1163. newTemplateSettings.routing.rules = rules;
  1164. this.templateSettings = newTemplateSettings;
  1165. },
  1166. addReverse(){
  1167. reverseModal.show({
  1168. title: '{{ i18n "pages.xray.outbound.addReverse"}}',
  1169. okText: '{{ i18n "pages.xray.outbound.addReverse" }}',
  1170. confirm: (reverse, rules) => {
  1171. reverseModal.loading();
  1172. if(reverse.tag.length > 0){
  1173. newTemplateSettings = this.templateSettings;
  1174. if(newTemplateSettings.reverse == undefined) newTemplateSettings.reverse = {};
  1175. if(newTemplateSettings.reverse[reverse.type+'s'] == undefined) newTemplateSettings.reverse[reverse.type+'s'] = [];
  1176. newTemplateSettings.reverse[reverse.type+'s'].push({ tag: reverse.tag, domain: reverse.domain });
  1177. this.templateSettings = newTemplateSettings;
  1178. // Add related rules
  1179. this.templateSettings.routing.rules.push(...rules);
  1180. this.routingRuleSettings = JSON.stringify(this.templateSettings.routing.rules);
  1181. }
  1182. reverseModal.close();
  1183. },
  1184. isEdit: false
  1185. });
  1186. },
  1187. editReverse(index){
  1188. if(this.reverseData[index].type == "bridge") {
  1189. oldRules = this.templateSettings.routing.rules.filter(r => r.inboundTag && r.inboundTag[0] == this.reverseData[index].tag);
  1190. } else {
  1191. oldRules = this.templateSettings.routing.rules.filter(r => r.outboundTag && r.outboundTag == this.reverseData[index].tag);
  1192. }
  1193. reverseModal.show({
  1194. title: '{{ i18n "pages.xray.outbound.editReverse"}} ' + (index+1),
  1195. reverse: this.reverseData[index],
  1196. rules: oldRules,
  1197. confirm: (reverse, rules) => {
  1198. reverseModal.loading();
  1199. if(reverse.tag.length > 0){
  1200. oldData = this.reverseData[index];
  1201. newTemplateSettings = this.templateSettings;
  1202. oldReverseIndex = newTemplateSettings.reverse[oldData.type+'s'].findIndex(rs => rs.tag == oldData.tag);
  1203. oldRuleIndex0 = oldRules.length>0 ? newTemplateSettings.routing.rules.findIndex(r => JSON.stringify(r) == JSON.stringify(oldRules[0])) : -1;
  1204. oldRuleIndex1 = oldRules.length==2 ? newTemplateSettings.routing.rules.findIndex(r => JSON.stringify(r) == JSON.stringify(oldRules[1])) : -1;
  1205. if(oldData.type == reverse.type){
  1206. newTemplateSettings.reverse[oldData.type + 's'][oldReverseIndex] = { tag: reverse.tag, domain: reverse.domain };
  1207. } else {
  1208. newTemplateSettings.reverse[oldData.type+'s'].splice(oldReverseIndex,1);
  1209. // delete empty object
  1210. if(newTemplateSettings.reverse[oldData.type+'s'].length == 0) Reflect.deleteProperty(newTemplateSettings.reverse, oldData.type+'s');
  1211. // add other type of reverse if it is not exist
  1212. if(!newTemplateSettings.reverse[reverse.type+'s']) newTemplateSettings.reverse[reverse.type+'s'] = [];
  1213. newTemplateSettings.reverse[reverse.type+'s'].push({ tag: reverse.tag, domain: reverse.domain });
  1214. }
  1215. this.templateSettings = newTemplateSettings;
  1216. // Adjust Rules
  1217. newRules = this.templateSettings.routing.rules;
  1218. oldRuleIndex0 != -1 ? newRules[oldRuleIndex0] = rules[0] : newRules.push(rules[0]);
  1219. oldRuleIndex1 != -1 ? newRules[oldRuleIndex1] = rules[1] : newRules.push(rules[1]);
  1220. this.routingRuleSettings = JSON.stringify(newRules);
  1221. }
  1222. reverseModal.close();
  1223. },
  1224. isEdit: true
  1225. });
  1226. },
  1227. deleteReverse(index){
  1228. oldData = this.reverseData[index];
  1229. newTemplateSettings = this.templateSettings;
  1230. reverseTypeObj = newTemplateSettings.reverse[oldData.type+'s'];
  1231. realIndex = reverseTypeObj.findIndex(r => r.tag==oldData.tag && r.domain==oldData.domain);
  1232. newTemplateSettings.reverse[oldData.type+'s'].splice(realIndex,1);
  1233. // delete empty objects
  1234. if(reverseTypeObj.length == 0) Reflect.deleteProperty(newTemplateSettings.reverse, oldData.type+'s');
  1235. if(Object.keys(newTemplateSettings.reverse).length === 0) Reflect.deleteProperty(newTemplateSettings, 'reverse');
  1236. // delete related routing rules
  1237. newRules = newTemplateSettings.routing.rules;
  1238. if(oldData.type == "bridge"){
  1239. newRules = newTemplateSettings.routing.rules.filter(r => !( r.inboundTag && r.inboundTag.length == 1 && r.inboundTag[0] == oldData.tag));
  1240. } else if(oldData.type == "portal"){
  1241. newRules = newTemplateSettings.routing.rules.filter(r => r.outboundTag != oldData.tag);
  1242. }
  1243. newTemplateSettings.routing.rules = newRules;
  1244. this.templateSettings = newTemplateSettings;
  1245. },
  1246. addDNSServer(){
  1247. dnsModal.show({
  1248. title: '{{ i18n "pages.xray.dns.add" }}',
  1249. confirm: (dnsServer) => {
  1250. dnsServers = this.dnsServers;
  1251. dnsServers.push(dnsServer);
  1252. this.dnsServers = dnsServers;
  1253. dnsModal.close();
  1254. },
  1255. isEdit: false
  1256. });
  1257. },
  1258. editDNSServer(index){
  1259. dnsModal.show({
  1260. title: '{{ i18n "pages.xray.dns.edit" }} #' + (index+1),
  1261. dnsServer: this.dnsServers[index],
  1262. confirm: (dnsServer) => {
  1263. dnsServers = this.dnsServers;
  1264. dnsServers[index] = dnsServer;
  1265. this.dnsServers = dnsServers;
  1266. dnsModal.close();
  1267. },
  1268. isEdit: true
  1269. });
  1270. },
  1271. deleteDNSServer(index){
  1272. newDnsServers = this.dnsServers;
  1273. newDnsServers.splice(index,1);
  1274. this.dnsServers = newDnsServers;
  1275. },
  1276. addFakedns() {
  1277. fakednsModal.show({
  1278. title: '{{ i18n "pages.xray.fakedns.add" }}',
  1279. confirm: (item) => {
  1280. fakeDns = this.fakeDns?? [];
  1281. fakeDns.push(item);
  1282. this.fakeDns = fakeDns;
  1283. fakednsModal.close();
  1284. },
  1285. isEdit: false
  1286. });
  1287. },
  1288. editFakedns(index){
  1289. fakednsModal.show({
  1290. title: '{{ i18n "pages.xray.fakedns.edit" }} #' + (index+1),
  1291. fakeDns: this.fakeDns[index],
  1292. confirm: (item) => {
  1293. fakeDns = this.fakeDns;
  1294. fakeDns[index] = item;
  1295. this.fakeDns = fakeDns;
  1296. fakednsModal.close();
  1297. },
  1298. isEdit: true
  1299. });
  1300. },
  1301. deleteFakedns(index){
  1302. fakeDns = this.fakeDns;
  1303. fakeDns.splice(index,1);
  1304. this.fakeDns = fakeDns;
  1305. },
  1306. addRule(){
  1307. ruleModal.show({
  1308. title: '{{ i18n "pages.xray.rules.add"}}',
  1309. okText: '{{ i18n "pages.xray.rules.add" }}',
  1310. confirm: (rule) => {
  1311. ruleModal.loading();
  1312. if(JSON.stringify(rule).length > 3){
  1313. this.templateSettings.routing.rules.push(rule);
  1314. this.routingRuleSettings = JSON.stringify(this.templateSettings.routing.rules);
  1315. }
  1316. ruleModal.close();
  1317. },
  1318. isEdit: false
  1319. });
  1320. },
  1321. editRule(index){
  1322. ruleModal.show({
  1323. title: '{{ i18n "pages.xray.rules.edit"}} ' + (index+1),
  1324. rule: app.templateSettings.routing.rules[index],
  1325. confirm: (rule) => {
  1326. ruleModal.loading();
  1327. if(JSON.stringify(rule).length > 3){
  1328. this.templateSettings.routing.rules[index] = rule;
  1329. this.routingRuleSettings = JSON.stringify(this.templateSettings.routing.rules);
  1330. }
  1331. ruleModal.close();
  1332. },
  1333. isEdit: true
  1334. });
  1335. },
  1336. replaceRule(old_index,new_index){
  1337. rules = this.templateSettings.routing.rules;
  1338. if (new_index >= rules.length) rules.push(undefined);
  1339. rules.splice(new_index, 0, rules.splice(old_index, 1)[0]);
  1340. this.routingRuleSettings = JSON.stringify(rules);
  1341. },
  1342. deleteRule(index){
  1343. rules = this.templateSettings.routing.rules;
  1344. rules.splice(index,1);
  1345. this.routingRuleSettings = JSON.stringify(rules);
  1346. },
  1347. showWarp(){
  1348. warpModal.show();
  1349. }
  1350. },
  1351. async mounted() {
  1352. if (window.location.protocol !== "https:") {
  1353. this.showAlert = true;
  1354. }
  1355. await this.getXraySetting();
  1356. await this.getXrayResult();
  1357. await this.getOutboundsTraffic();
  1358. while (true) {
  1359. await PromiseUtil.sleep(800);
  1360. this.saveBtnDisable = this.oldXraySetting === this.xraySetting;
  1361. }
  1362. },
  1363. computed: {
  1364. templateSettings: {
  1365. get: function () { return this.xraySetting ? JSON.parse(this.xraySetting) : null; },
  1366. set: function (newValue) { this.xraySetting = JSON.stringify(newValue, null, 2); },
  1367. },
  1368. inboundSettings: {
  1369. get: function () { return this.templateSettings ? JSON.stringify(this.templateSettings.inbounds, null, 2) : null; },
  1370. set: function (newValue) {
  1371. newTemplateSettings = this.templateSettings;
  1372. newTemplateSettings.inbounds = JSON.parse(newValue);
  1373. this.templateSettings = newTemplateSettings;
  1374. },
  1375. },
  1376. outboundSettings: {
  1377. get: function () { return this.templateSettings ? JSON.stringify(this.templateSettings.outbounds, null, 2) : null; },
  1378. set: function (newValue) {
  1379. newTemplateSettings = this.templateSettings;
  1380. newTemplateSettings.outbounds = JSON.parse(newValue);
  1381. this.templateSettings = newTemplateSettings;
  1382. },
  1383. },
  1384. outboundData: {
  1385. get: function () {
  1386. data = []
  1387. if (this.templateSettings != null) {
  1388. this.templateSettings.outbounds.forEach((o, index) => {
  1389. data.push({'key': index, ...o});
  1390. });
  1391. }
  1392. return data;
  1393. },
  1394. },
  1395. reverseData: {
  1396. get: function () {
  1397. data = []
  1398. if (this.templateSettings != null && this.templateSettings.reverse != null) {
  1399. if(this.templateSettings.reverse.bridges) {
  1400. this.templateSettings.reverse.bridges.forEach((o, index) => {
  1401. data.push({'key': index, 'type':'bridge', ...o});
  1402. });
  1403. }
  1404. if(this.templateSettings.reverse.portals){
  1405. this.templateSettings.reverse.portals.forEach((o, index) => {
  1406. data.push({'key': index, 'type':'portal', ...o});
  1407. });
  1408. }
  1409. }
  1410. return data;
  1411. },
  1412. },
  1413. balancersData: {
  1414. get: function () {
  1415. data = []
  1416. if (this.templateSettings != null && this.templateSettings.routing != null && this.templateSettings.routing.balancers != null) {
  1417. this.templateSettings.routing.balancers.forEach((o, index) => {
  1418. let strategy = "random"
  1419. if (o.strategy && o.strategy.type == "roundRobin") {
  1420. strategy = o.strategy.type
  1421. }
  1422. data.push({
  1423. 'key': index,
  1424. 'tag': o.tag ? o.tag : "",
  1425. 'strategy': strategy,
  1426. 'selector': o.selector ? o.selector : []
  1427. });
  1428. });
  1429. }
  1430. return data;
  1431. }
  1432. },
  1433. routingRuleSettings: {
  1434. get: function () { return this.templateSettings ? JSON.stringify(this.templateSettings.routing.rules, null, 2) : null; },
  1435. set: function (newValue) {
  1436. newTemplateSettings = this.templateSettings;
  1437. newTemplateSettings.routing.rules = JSON.parse(newValue);
  1438. this.templateSettings = newTemplateSettings;
  1439. },
  1440. },
  1441. routingRuleData: {
  1442. get: function () {
  1443. data = [];
  1444. if (this.templateSettings != null) {
  1445. this.templateSettings.routing.rules.forEach((r, index) => {
  1446. data.push({'key': index, ...r});
  1447. });
  1448. // Make rules readable
  1449. data.forEach(r => {
  1450. if(r.domain) r.domain = r.domain.join(',')
  1451. if(r.ip) r.ip = r.ip.join(',')
  1452. if(r.source) r.source = r.source.join(',');
  1453. if(r.user) r.user = r.user.join(',')
  1454. if(r.inboundTag) r.inboundTag = r.inboundTag.join(',')
  1455. if(r.protocol) r.protocol = r.protocol.join(',')
  1456. if(r.attrs) r.attrs = JSON.stringify(r.attrs, null, 2)
  1457. });
  1458. }
  1459. return data;
  1460. }
  1461. },
  1462. freedomStrategy: {
  1463. get: function () {
  1464. if (!this.templateSettings) return "AsIs";
  1465. freedomOutbound = this.templateSettings.outbounds.find((o) => o.protocol === "freedom" && o.tag == "direct");
  1466. if (!freedomOutbound) return "AsIs";
  1467. if (!freedomOutbound.settings || !freedomOutbound.settings.domainStrategy) return "AsIs";
  1468. return freedomOutbound.settings.domainStrategy;
  1469. },
  1470. set: function (newValue) {
  1471. newTemplateSettings = this.templateSettings;
  1472. freedomOutboundIndex = newTemplateSettings.outbounds.findIndex((o) => o.protocol === "freedom" && o.tag == "direct");
  1473. if(freedomOutboundIndex == -1){
  1474. newTemplateSettings.outbounds.push({protocol: "freedom", tag: "direct", settings: { "domainStrategy": newValue }});
  1475. } else if (!newTemplateSettings.outbounds[freedomOutboundIndex].settings) {
  1476. newTemplateSettings.outbounds[freedomOutboundIndex].settings = {"domainStrategy": newValue};
  1477. } else {
  1478. newTemplateSettings.outbounds[freedomOutboundIndex].settings.domainStrategy = newValue;
  1479. }
  1480. this.templateSettings = newTemplateSettings;
  1481. }
  1482. },
  1483. routingStrategy: {
  1484. get: function () {
  1485. if (!this.templateSettings || !this.templateSettings.routing || !this.templateSettings.routing.domainStrategy) return "AsIs";
  1486. return this.templateSettings.routing.domainStrategy;
  1487. },
  1488. set: function (newValue) {
  1489. newTemplateSettings = this.templateSettings;
  1490. newTemplateSettings.routing.domainStrategy = newValue;
  1491. this.templateSettings = newTemplateSettings;
  1492. }
  1493. },
  1494. setLogLevel: {
  1495. get: function () {
  1496. if (!this.templateSettings || !this.templateSettings.log || !this.templateSettings.log.loglevel) return "warning";
  1497. return this.templateSettings.log.loglevel;
  1498. },
  1499. set: function (newValue) {
  1500. newTemplateSettings = this.templateSettings;
  1501. newTemplateSettings.log.loglevel = newValue;
  1502. this.templateSettings = newTemplateSettings;
  1503. }
  1504. },
  1505. accessLog: {
  1506. get: function () {
  1507. if (!this.templateSettings || !this.templateSettings.log || !this.templateSettings.log.access) return "";
  1508. return this.templateSettings.log.access;
  1509. },
  1510. set: function (newValue) {
  1511. newTemplateSettings = this.templateSettings;
  1512. newTemplateSettings.log.access = newValue;
  1513. this.templateSettings = newTemplateSettings;
  1514. }
  1515. },
  1516. errorLog: {
  1517. get: function () {
  1518. if (!this.templateSettings || !this.templateSettings.log || !this.templateSettings.log.error) return "";
  1519. return this.templateSettings.log.error;
  1520. },
  1521. set: function (newValue) {
  1522. newTemplateSettings = this.templateSettings;
  1523. newTemplateSettings.log.error = newValue;
  1524. this.templateSettings = newTemplateSettings;
  1525. }
  1526. },
  1527. blockedIPs: {
  1528. get: function () {
  1529. return this.templateRuleGetter({ outboundTag: "blocked", property: "ip" });
  1530. },
  1531. set: function (newValue) {
  1532. this.templateRuleSetter({ outboundTag: "blocked", property: "ip", data: newValue });
  1533. }
  1534. },
  1535. blockedDomains: {
  1536. get: function () {
  1537. return this.templateRuleGetter({ outboundTag: "blocked", property: "domain" });
  1538. },
  1539. set: function (newValue) {
  1540. this.templateRuleSetter({ outboundTag: "blocked", property: "domain", data: newValue });
  1541. }
  1542. },
  1543. blockedProtocols: {
  1544. get: function () {
  1545. return this.templateRuleGetter({ outboundTag: "blocked", property: "protocol" });
  1546. },
  1547. set: function (newValue) {
  1548. this.templateRuleSetter({ outboundTag: "blocked", property: "protocol", data: newValue });
  1549. }
  1550. },
  1551. directIPs: {
  1552. get: function () {
  1553. return this.templateRuleGetter({ outboundTag: "direct", property: "ip" });
  1554. },
  1555. set: function (newValue) {
  1556. this.templateRuleSetter({ outboundTag: "direct", property: "ip", data: newValue });
  1557. this.syncRulesWithOutbound("direct", this.directSettings);
  1558. }
  1559. },
  1560. directDomains: {
  1561. get: function () {
  1562. return this.templateRuleGetter({ outboundTag: "direct", property: "domain" });
  1563. },
  1564. set: function (newValue) {
  1565. this.templateRuleSetter({ outboundTag: "direct", property: "domain", data: newValue });
  1566. this.syncRulesWithOutbound("direct", this.directSettings);
  1567. }
  1568. },
  1569. ipv4Domains: {
  1570. get: function () {
  1571. return this.templateRuleGetter({ outboundTag: "IPv4", property: "domain" });
  1572. },
  1573. set: function (newValue) {
  1574. this.templateRuleSetter({ outboundTag: "IPv4", property: "domain", data: newValue });
  1575. this.syncRulesWithOutbound("IPv4", this.ipv4Settings);
  1576. }
  1577. },
  1578. warpDomains: {
  1579. get: function () {
  1580. return this.templateRuleGetter({ outboundTag: "warp", property: "domain" });
  1581. },
  1582. set: function (newValue) {
  1583. this.templateRuleSetter({ outboundTag: "warp", property: "domain", data: newValue });
  1584. }
  1585. },
  1586. torrentSettings: {
  1587. get: function () {
  1588. return doAllItemsExist(this.settingsData.protocols.bittorrent, this.blockedProtocols);
  1589. },
  1590. set: function (newValue) {
  1591. if (newValue) {
  1592. this.blockedProtocols = [...this.blockedProtocols, ...this.settingsData.protocols.bittorrent];
  1593. } else {
  1594. this.blockedProtocols = this.blockedProtocols.filter(data => !this.settingsData.protocols.bittorrent.includes(data));
  1595. }
  1596. },
  1597. },
  1598. privateIpSettings: {
  1599. get: function () {
  1600. return doAllItemsExist(this.settingsData.ips.local, this.blockedIPs);
  1601. },
  1602. set: function (newValue) {
  1603. if (newValue) {
  1604. this.blockedIPs = [...this.blockedIPs, ...this.settingsData.ips.local];
  1605. } else {
  1606. this.blockedIPs = this.blockedIPs.filter(data => !this.settingsData.ips.local.includes(data));
  1607. }
  1608. },
  1609. },
  1610. AdsSettings: {
  1611. get: function () {
  1612. return doAllItemsExist(this.settingsData.domains.ads, this.blockedDomains);
  1613. },
  1614. set: function (newValue) {
  1615. if (newValue) {
  1616. this.blockedDomains = [...this.blockedDomains, ...this.settingsData.domains.ads];
  1617. } else {
  1618. this.blockedDomains = this.blockedDomains.filter(data => !this.settingsData.domains.ads.includes(data));
  1619. }
  1620. },
  1621. },
  1622. SecuritySettings: {
  1623. get: function () {
  1624. return doAllItemsExist(this.settingsData.domains.security, this.blockedDomains);
  1625. },
  1626. set: function (newValue) {
  1627. if (newValue) {
  1628. this.blockedDomains = [...this.blockedDomains, ...this.settingsData.domains.security];
  1629. } else {
  1630. this.blockedDomains = this.blockedDomains.filter(data => !this.settingsData.domains.security.includes(data));
  1631. }
  1632. },
  1633. },
  1634. SpeedTestSettings: {
  1635. get: function () {
  1636. return doAllItemsExist(this.settingsData.domains.speedtest, this.blockedDomains);
  1637. },
  1638. set: function (newValue) {
  1639. if (newValue) {
  1640. this.blockedDomains = [...this.blockedDomains, ...this.settingsData.domains.speedtest];
  1641. } else {
  1642. this.blockedDomains = this.blockedDomains.filter(data => !this.settingsData.domains.speedtest.includes(data));
  1643. }
  1644. },
  1645. },
  1646. familyProtectSettings: {
  1647. get: function () {
  1648. if (!this.templateSettings || !this.templateSettings.dns || !this.templateSettings.dns.servers) return false;
  1649. return doAllItemsExist(this.settingsData.familyProtectDNS.servers, this.templateSettings.dns.servers);
  1650. },
  1651. set: function (newValue) {
  1652. newTemplateSettings = this.templateSettings;
  1653. if (newValue) {
  1654. newTemplateSettings.dns = this.settingsData.familyProtectDNS;
  1655. } else {
  1656. newTemplateSettings.dns.servers = newTemplateSettings.dns?.servers?.filter(data => !this.settingsData.familyProtectDNS.servers.includes(data))
  1657. }
  1658. this.templateSettings = newTemplateSettings;
  1659. },
  1660. },
  1661. GoogleIPv4Settings: {
  1662. get: function () {
  1663. return doAllItemsExist(this.settingsData.domains.google, this.ipv4Domains);
  1664. },
  1665. set: function (newValue) {
  1666. if (newValue) {
  1667. this.ipv4Domains = [...this.ipv4Domains, ...this.settingsData.domains.google];
  1668. } else {
  1669. this.ipv4Domains = this.ipv4Domains.filter(data => !this.settingsData.domains.google.includes(data));
  1670. }
  1671. },
  1672. },
  1673. NetflixIPv4Settings: {
  1674. get: function () {
  1675. return doAllItemsExist(this.settingsData.domains.netflix, this.ipv4Domains);
  1676. },
  1677. set: function (newValue) {
  1678. if (newValue) {
  1679. this.ipv4Domains = [...this.ipv4Domains, ...this.settingsData.domains.netflix];
  1680. } else {
  1681. this.ipv4Domains = this.ipv4Domains.filter(data => !this.settingsData.domains.netflix.includes(data));
  1682. }
  1683. },
  1684. },
  1685. IRIpSettings: {
  1686. get: function () {
  1687. return doAllItemsExist(this.settingsData.ips.ir, this.blockedIPs);
  1688. },
  1689. set: function (newValue) {
  1690. if (newValue) {
  1691. this.blockedIPs = [...this.blockedIPs, ...this.settingsData.ips.ir];
  1692. } else {
  1693. this.blockedIPs = this.blockedIPs.filter(data => !this.settingsData.ips.ir.includes(data));
  1694. }
  1695. }
  1696. },
  1697. IRDomainSettings: {
  1698. get: function () {
  1699. return doAllItemsExist(this.settingsData.domains.ir, this.blockedDomains);
  1700. },
  1701. set: function (newValue) {
  1702. if (newValue) {
  1703. this.blockedDomains = [...this.blockedDomains, ...this.settingsData.domains.ir];
  1704. } else {
  1705. this.blockedDomains = this.blockedDomains.filter(data => !this.settingsData.domains.ir.includes(data));
  1706. }
  1707. }
  1708. },
  1709. ChinaIpSettings: {
  1710. get: function () {
  1711. return doAllItemsExist(this.settingsData.ips.cn, this.blockedIPs);
  1712. },
  1713. set: function (newValue) {
  1714. if (newValue) {
  1715. this.blockedIPs = [...this.blockedIPs, ...this.settingsData.ips.cn];
  1716. } else {
  1717. this.blockedIPs = this.blockedIPs.filter(data => !this.settingsData.ips.cn.includes(data));
  1718. }
  1719. }
  1720. },
  1721. ChinaDomainSettings: {
  1722. get: function () {
  1723. return doAllItemsExist(this.settingsData.domains.cn, this.blockedDomains);
  1724. },
  1725. set: function (newValue) {
  1726. if (newValue) {
  1727. this.blockedDomains = [...this.blockedDomains, ...this.settingsData.domains.cn];
  1728. } else {
  1729. this.blockedDomains = this.blockedDomains.filter(data => !this.settingsData.domains.cn.includes(data));
  1730. }
  1731. }
  1732. },
  1733. RussiaIpSettings: {
  1734. get: function () {
  1735. return doAllItemsExist(this.settingsData.ips.ru, this.blockedIPs);
  1736. },
  1737. set: function (newValue) {
  1738. if (newValue) {
  1739. this.blockedIPs = [...this.blockedIPs, ...this.settingsData.ips.ru];
  1740. } else {
  1741. this.blockedIPs = this.blockedIPs.filter(data => !this.settingsData.ips.ru.includes(data));
  1742. }
  1743. }
  1744. },
  1745. RussiaDomainSettings: {
  1746. get: function () {
  1747. return doAllItemsExist(this.settingsData.domains.ru, this.blockedDomains);
  1748. },
  1749. set: function (newValue) {
  1750. if (newValue) {
  1751. this.blockedDomains = [...this.blockedDomains, ...this.settingsData.domains.ru];
  1752. } else {
  1753. this.blockedDomains = this.blockedDomains.filter(data => !this.settingsData.domains.ru.includes(data));
  1754. }
  1755. }
  1756. },
  1757. VNIpSettings: {
  1758. get: function () {
  1759. return doAllItemsExist(this.settingsData.ips.vn, this.blockedIPs);
  1760. },
  1761. set: function (newValue) {
  1762. if (newValue) {
  1763. this.blockedIPs = [...this.blockedIPs, ...this.settingsData.ips.vn];
  1764. } else {
  1765. this.blockedIPs = this.blockedIPs.filter(data => !this.settingsData.ips.vn.includes(data));
  1766. }
  1767. }
  1768. },
  1769. VNDomainSettings: {
  1770. get: function () {
  1771. return doAllItemsExist(this.settingsData.domains.vn, this.blockedDomains);
  1772. },
  1773. set: function (newValue) {
  1774. if (newValue) {
  1775. this.blockedDomains = [...this.blockedDomains, ...this.settingsData.domains.vn];
  1776. } else {
  1777. this.blockedDomains = this.blockedDomains.filter(data => !this.settingsData.domains.vn.includes(data));
  1778. }
  1779. }
  1780. },
  1781. IRIpDirectSettings: {
  1782. get: function () {
  1783. return doAllItemsExist(this.settingsData.ips.ir, this.directIPs);
  1784. },
  1785. set: function (newValue) {
  1786. if (newValue) {
  1787. this.directIPs = [...this.directIPs, ...this.settingsData.ips.ir];
  1788. } else {
  1789. this.directIPs = this.directIPs.filter(data => !this.settingsData.ips.ir.includes(data));
  1790. }
  1791. }
  1792. },
  1793. IRDomainDirectSettings: {
  1794. get: function () {
  1795. return doAllItemsExist(this.settingsData.domains.ir, this.directDomains);
  1796. },
  1797. set: function (newValue) {
  1798. if (newValue) {
  1799. this.directDomains = [...this.directDomains, ...this.settingsData.domains.ir];
  1800. } else {
  1801. this.directDomains = this.directDomains.filter(data => !this.settingsData.domains.ir.includes(data));
  1802. }
  1803. }
  1804. },
  1805. ChinaIpDirectSettings: {
  1806. get: function () {
  1807. return doAllItemsExist(this.settingsData.ips.cn, this.directIPs);
  1808. },
  1809. set: function (newValue) {
  1810. if (newValue) {
  1811. this.directIPs = [...this.directIPs, ...this.settingsData.ips.cn];
  1812. } else {
  1813. this.directIPs = this.directIPs.filter(data => !this.settingsData.ips.cn.includes(data));
  1814. }
  1815. }
  1816. },
  1817. ChinaDomainDirectSettings: {
  1818. get: function () {
  1819. return doAllItemsExist(this.settingsData.domains.cn, this.directDomains);
  1820. },
  1821. set: function (newValue) {
  1822. if (newValue) {
  1823. this.directDomains = [...this.directDomains, ...this.settingsData.domains.cn];
  1824. } else {
  1825. this.directDomains = this.directDomains.filter(data => !this.settingsData.domains.cn.includes(data));
  1826. }
  1827. }
  1828. },
  1829. RussiaIpDirectSettings: {
  1830. get: function () {
  1831. return doAllItemsExist(this.settingsData.ips.ru, this.directIPs);
  1832. },
  1833. set: function (newValue) {
  1834. if (newValue) {
  1835. this.directIPs = [...this.directIPs, ...this.settingsData.ips.ru];
  1836. } else {
  1837. this.directIPs = this.directIPs.filter(data => !this.settingsData.ips.ru.includes(data));
  1838. }
  1839. }
  1840. },
  1841. RussiaDomainDirectSettings: {
  1842. get: function () {
  1843. return doAllItemsExist(this.settingsData.domains.ru, this.directDomains);
  1844. },
  1845. set: function (newValue) {
  1846. if (newValue) {
  1847. this.directDomains = [...this.directDomains, ...this.settingsData.domains.ru];
  1848. } else {
  1849. this.directDomains = this.directDomains.filter(data => !this.settingsData.domains.ru.includes(data));
  1850. }
  1851. }
  1852. },
  1853. VNIpDirectSettings: {
  1854. get: function () {
  1855. return doAllItemsExist(this.settingsData.ips.vn, this.directIPs);
  1856. },
  1857. set: function (newValue) {
  1858. if (newValue) {
  1859. this.directIPs = [...this.directIPs, ...this.settingsData.ips.vn];
  1860. } else {
  1861. this.directIPs = this.directIPs.filter(data => !this.settingsData.ips.vn.includes(data));
  1862. }
  1863. }
  1864. },
  1865. VNDomainDirectSettings: {
  1866. get: function () {
  1867. return doAllItemsExist(this.settingsData.domains.vn, this.directDomains);
  1868. },
  1869. set: function (newValue) {
  1870. if (newValue) {
  1871. this.directDomains = [...this.directDomains, ...this.settingsData.domains.vn];
  1872. } else {
  1873. this.directDomains = this.directDomains.filter(data => !this.settingsData.domains.vn.includes(data));
  1874. }
  1875. }
  1876. },
  1877. WarpExist: {
  1878. get: function() {
  1879. return this.templateSettings ? this.templateSettings.outbounds.findIndex((o) => o.tag == "warp")>=0 : false;
  1880. },
  1881. },
  1882. GoogleWARPSettings: {
  1883. get: function () {
  1884. return doAllItemsExist(this.settingsData.domains.google, this.warpDomains);
  1885. },
  1886. set: function (newValue) {
  1887. if (newValue) {
  1888. this.warpDomains = [...this.warpDomains, ...this.settingsData.domains.google];
  1889. } else {
  1890. this.warpDomains = this.warpDomains.filter(data => !this.settingsData.domains.google.includes(data));
  1891. }
  1892. },
  1893. },
  1894. OpenAIWARPSettings: {
  1895. get: function () {
  1896. return doAllItemsExist(this.settingsData.domains.openai, this.warpDomains);
  1897. },
  1898. set: function (newValue) {
  1899. if (newValue) {
  1900. this.warpDomains = [...this.warpDomains, ...this.settingsData.domains.openai];
  1901. } else {
  1902. this.warpDomains = this.warpDomains.filter(data => !this.settingsData.domains.openai.includes(data));
  1903. }
  1904. },
  1905. },
  1906. NetflixWARPSettings: {
  1907. get: function () {
  1908. return doAllItemsExist(this.settingsData.domains.netflix, this.warpDomains);
  1909. },
  1910. set: function (newValue) {
  1911. if (newValue) {
  1912. this.warpDomains = [...this.warpDomains, ...this.settingsData.domains.netflix];
  1913. } else {
  1914. this.warpDomains = this.warpDomains.filter(data => !this.settingsData.domains.netflix.includes(data));
  1915. }
  1916. },
  1917. },
  1918. MetaWARPSettings: {
  1919. get: function () {
  1920. return doAllItemsExist(this.settingsData.domains.meta, this.warpDomains);
  1921. },
  1922. set: function (newValue) {
  1923. if (newValue) {
  1924. this.warpDomains = [...this.warpDomains, ...this.settingsData.domains.meta];
  1925. } else {
  1926. this.warpDomains = this.warpDomains.filter(data => !this.settingsData.domains.meta.includes(data));
  1927. }
  1928. },
  1929. },
  1930. AppleWARPSettings: {
  1931. get: function () {
  1932. return doAllItemsExist(this.settingsData.domains.apple, this.warpDomains);
  1933. },
  1934. set: function (newValue) {
  1935. if (newValue) {
  1936. this.warpDomains = [...this.warpDomains, ...this.settingsData.domains.apple];
  1937. } else {
  1938. this.warpDomains = this.warpDomains.filter(data => !this.settingsData.domains.apple.includes(data));
  1939. }
  1940. },
  1941. },
  1942. RedditWARPSettings: {
  1943. get: function () {
  1944. return doAllItemsExist(this.settingsData.domains.reddit, this.warpDomains);
  1945. },
  1946. set: function (newValue) {
  1947. if (newValue) {
  1948. this.warpDomains = [...this.warpDomains, ...this.settingsData.domains.reddit];
  1949. } else {
  1950. this.warpDomains = this.warpDomains.filter(data => !this.settingsData.domains.reddit.includes(data));
  1951. }
  1952. },
  1953. },
  1954. SpotifyWARPSettings: {
  1955. get: function () {
  1956. return doAllItemsExist(this.settingsData.domains.spotify, this.warpDomains);
  1957. },
  1958. set: function (newValue) {
  1959. if (newValue) {
  1960. this.warpDomains = [...this.warpDomains, ...this.settingsData.domains.spotify];
  1961. } else {
  1962. this.warpDomains = this.warpDomains.filter(data => !this.settingsData.domains.spotify.includes(data));
  1963. }
  1964. },
  1965. },
  1966. enableDNS: {
  1967. get: function () {
  1968. return this.templateSettings ? this.templateSettings.dns != null : false;
  1969. },
  1970. set: function (newValue) {
  1971. newTemplateSettings = this.templateSettings;
  1972. newTemplateSettings.dns = newValue ? { servers: [], queryStrategy: "UseIP" } : null;
  1973. this.templateSettings = newTemplateSettings;
  1974. }
  1975. },
  1976. dnsStrategy: {
  1977. get: function () {
  1978. return this.enableDNS ? this.templateSettings.dns.queryStrategy : null;
  1979. },
  1980. set: function (newValue) {
  1981. newTemplateSettings = this.templateSettings;
  1982. newTemplateSettings.dns.queryStrategy = newValue;
  1983. this.templateSettings = newTemplateSettings;
  1984. }
  1985. },
  1986. dnsServers: {
  1987. get: function () { return this.enableDNS ? this.templateSettings.dns.servers : []; },
  1988. set: function (newValue) {
  1989. newTemplateSettings = this.templateSettings;
  1990. newTemplateSettings.dns.servers = newValue;
  1991. this.templateSettings = newTemplateSettings;
  1992. }
  1993. },
  1994. fakeDns: {
  1995. get: function () { return this.templateSettings && this.templateSettings.fakedns ? this.templateSettings.fakedns : []; },
  1996. set: function (newValue) {
  1997. newTemplateSettings = this.templateSettings;
  1998. newTemplateSettings.fakedns = newValue.length >0 ? newValue : null;
  1999. this.templateSettings = newTemplateSettings;
  2000. }
  2001. }
  2002. },
  2003. });
  2004. </script>
  2005. </body>
  2006. </html>