xray.html 118 KB

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