xray.html 117 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251
  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" }}' desc='{{ i18n "pages.xray.dns.enableDesc" }}' v-model="enableDNS"></setting-list-item>
  591. <template v-if="enableDNS">
  592. <setting-list-item style="padding: 10px 20px" type="text" title='{{ i18n "pages.xray.dns.tag" }}' desc='{{ i18n "pages.xray.dns.tagDesc" }}' v-model="dnsTag"></setting-list-item>
  593. <a-list-item style="padding: 10px 20px">
  594. <a-row>
  595. <a-col :lg="24" :xl="12">
  596. <a-list-item-meta title='{{ i18n "pages.xray.dns.strategy" }}' description='{{ i18n "pages.xray.dns.strategyDesc" }}' />
  597. </a-col>
  598. <a-col :lg="24" :xl="12">
  599. <a-select
  600. v-model="dnsStrategy"
  601. style="width: 100%"
  602. :dropdown-class-name="themeSwitcher.currentTheme">
  603. <a-select-option :value="l" :label="l" v-for="l in ['UseIP', 'UseIPv4', 'UseIPv6']">
  604. [[ l ]]
  605. </a-select-option>
  606. </a-select>
  607. </a-col>
  608. </a-row>
  609. </a-list-item>
  610. <a-divider>DNS</a-divider>
  611. <a-button type="primary" icon="plus" @click="addDNSServer()" style="margin-bottom: 10px;">{{ i18n "pages.xray.dns.add" }}</a-button>
  612. <a-table :columns="dnsColumns" bordered v-if="dnsServers.length>0"
  613. :row-key="r => r.key"
  614. :data-source="dnsServers"
  615. :scroll="isMobile ? {} : { x: 200 }"
  616. :pagination="false"
  617. :indent-size="0"
  618. :style="isMobile ? 'padding: 5px 0' : 'margin-left: 1px;'">
  619. <template slot="action" slot-scope="text,dns,index">
  620. [[ index+1 ]]
  621. <a-dropdown :trigger="['click']">
  622. <a-icon @click="e => e.preventDefault()" type="more" style="font-size: 16px; text-decoration: bold;"></a-icon>
  623. <a-menu slot="overlay" :theme="themeSwitcher.currentTheme">
  624. <a-menu-item @click="editDNSServer(index)">
  625. <a-icon type="edit"></a-icon>
  626. {{ i18n "edit" }}
  627. </a-menu-item>
  628. <a-menu-item @click="deleteDNSServer(index)">
  629. <span style="color: #FF4D4F">
  630. <a-icon type="delete"></a-icon> {{ i18n "delete"}}
  631. </span>
  632. </a-menu-item>
  633. </a-menu>
  634. </a-dropdown>
  635. </template>
  636. <template slot="address" slot-scope="dns,index">
  637. <span v-if="typeof dns == 'object'">[[ dns.address ]]</span>
  638. <span v-else>[[ dns ]]</span>
  639. </template>
  640. <template slot="domain" slot-scope="dns,index">
  641. <span v-if="typeof dns == 'object'">[[ dns.domains.join(",") ]]</span>
  642. </template>
  643. </a-table>
  644. <a-divider>Fake DNS</a-divider>
  645. <a-button type="primary" icon="plus" @click="addFakedns()" style="margin-bottom: 10px;">{{ i18n "pages.xray.fakedns.add" }}</a-button>
  646. <a-table :columns="fakednsColumns" bordered v-if="fakeDns && fakeDns.length>0" :row-key="r => r.key"
  647. :data-source="fakeDns" :scroll="isMobile ? {} : { x: 200 }" :pagination="false" :indent-size="0"
  648. :style="isMobile ? 'padding: 5px 0' : 'margin-left: 1px;'">
  649. <template slot="action" slot-scope="text,fakedns,index">
  650. [[ index+1 ]]
  651. <a-dropdown :trigger="['click']">
  652. <a-icon @click="e => e.preventDefault()" type="more" style="font-size: 16px; text-decoration: bold;"></a-icon>
  653. <a-menu slot="overlay" :theme="themeSwitcher.currentTheme">
  654. <a-menu-item @click="editFakedns(index)">
  655. <a-icon type="edit"></a-icon>
  656. {{ i18n "edit" }}
  657. </a-menu-item>
  658. <a-menu-item @click="deleteFakedns(index)">
  659. <span style="color: #FF4D4F">
  660. <a-icon type="delete"></a-icon> {{ i18n "delete"}}
  661. </span>
  662. </a-menu-item>
  663. </a-menu>
  664. </a-dropdown>
  665. </template>
  666. </a-table>
  667. </template>
  668. </a-tab-pane>
  669. <a-tab-pane key="tpl-advanced" tab='{{ i18n "pages.xray.advancedTemplate"}}' style="padding-top: 20px;" force-render="true">
  670. <a-list-item-meta title='{{ i18n "pages.xray.Template"}}' description='{{ i18n "pages.xray.TemplateDesc"}}'></a-list-item-meta>
  671. <a-radio-group v-model="advSettings" @change="changeCode" button-style="solid" style="margin: 10px 0;" :size="isMobile ? 'small' : ''">
  672. <a-radio-button value="xraySetting">{{ i18n "pages.xray.completeTemplate"}}</a-radio-button>
  673. <a-radio-button value="inboundSettings">{{ i18n "pages.xray.Inbounds" }}</a-radio-button>
  674. <a-radio-button value="outboundSettings">{{ i18n "pages.xray.Outbounds" }}</a-radio-button>
  675. <a-radio-button value="routingRuleSettings">{{ i18n "pages.xray.Routings" }}</a-radio-button>
  676. </a-radio-group>
  677. <textarea style="position:absolute; left: -800px;" id="xraySetting"></textarea>
  678. </a-tab-pane>
  679. </a-tabs>
  680. </a-space>
  681. </a-spin>
  682. </a-layout-content>
  683. </a-layout>
  684. </a-layout>
  685. {{template "js" .}}
  686. {{template "component/themeSwitcher" .}}
  687. {{template "component/sortableTable" .}}
  688. {{template "component/setting"}}
  689. {{template "ruleModal"}}
  690. {{template "outModal"}}
  691. {{template "reverseModal"}}
  692. {{template "balancerModal"}}
  693. {{template "dnsModal"}}
  694. {{template "fakednsModal"}}
  695. {{template "warpModal"}}
  696. <script>
  697. const rulesColumns = [
  698. { title: "#", align: 'center', width: 15, scopedSlots: { customRender: 'action' } },
  699. { title: '{{ i18n "pages.xray.rules.source"}}', children: [
  700. { title: 'IP', dataIndex: "source", align: 'center', width: 20, ellipsis: true },
  701. { title: 'Port', dataIndex: 'sourcePort', align: 'center', width: 10, ellipsis: true } ]},
  702. { title: '{{ i18n "pages.inbounds.network"}}', children: [
  703. { title: 'L4', dataIndex: 'network', align: 'center', width: 10 },
  704. { title: 'Protocol', dataIndex: 'protocol', align: 'center', width: 10, ellipsis: true },
  705. { title: 'Attrs', dataIndex: 'attrs', align: 'center', width: 20, ellipsis: true } ]},
  706. { title: '{{ i18n "pages.xray.rules.dest"}}', children: [
  707. { title: 'IP', dataIndex: 'ip', align: 'center', width: 20, ellipsis: true },
  708. { title: 'Domain', dataIndex: 'domain', align: 'center', width: 20, ellipsis: true },
  709. { title: 'Port', dataIndex: 'port', align: 'center', width: 10, ellipsis: true }]},
  710. { title: '{{ i18n "pages.xray.rules.inbound"}}', children: [
  711. { title: 'Inbound Tag', dataIndex: 'inboundTag', align: 'center', width: 15, ellipsis: true },
  712. { title: 'Client Email', dataIndex: 'user', align: 'center', width: 20, ellipsis: true }]},
  713. { title: '{{ i18n "pages.xray.rules.outbound"}}', dataIndex: 'outboundTag', align: 'center', width: 15 },
  714. { title: '{{ i18n "pages.xray.rules.balancer"}}', dataIndex: 'balancerTag', align: 'center', width: 15 },
  715. ];
  716. const rulesMobileColumns = [
  717. { title: "#", align: 'center', width: 20, scopedSlots: { customRender: 'action' } },
  718. { title: '{{ i18n "pages.xray.rules.inbound"}}', align: 'center', width: 50, ellipsis: true, scopedSlots: { customRender: 'inbound' } },
  719. { title: '{{ i18n "pages.xray.rules.outbound"}}', align: 'center', width: 50, ellipsis: true, scopedSlots: { customRender: 'outbound' } },
  720. { title: '{{ i18n "pages.xray.rules.info"}}', align: 'center', width: 50, ellipsis: true, scopedSlots: { customRender: 'info' } },
  721. ];
  722. const outboundColumns = [
  723. { title: "#", align: 'center', width: 20, scopedSlots: { customRender: 'action' } },
  724. { title: '{{ i18n "pages.xray.outbound.tag"}}', dataIndex: 'tag', align: 'center', width: 50 },
  725. { title: '{{ i18n "protocol"}}', align: 'center', width: 50, scopedSlots: { customRender: 'protocol' } },
  726. { title: '{{ i18n "pages.xray.outbound.address"}}', align: 'center', width: 50, scopedSlots: { customRender: 'address' } },
  727. { title: '{{ i18n "pages.inbounds.traffic" }}', align: 'center', width: 50, scopedSlots: { customRender: 'traffic' } },
  728. ];
  729. const reverseColumns = [
  730. { title: "#", align: 'center', width: 20, scopedSlots: { customRender: 'action' } },
  731. { title: '{{ i18n "pages.xray.outbound.type"}}', dataIndex: 'type', align: 'center', width: 50 },
  732. { title: '{{ i18n "pages.xray.outbound.tag"}}', dataIndex: 'tag', align: 'center', width: 50 },
  733. { title: '{{ i18n "pages.xray.outbound.domain"}}', dataIndex: 'domain', align: 'center', width: 50 },
  734. ];
  735. const balancerColumns = [
  736. { title: "#", align: 'center', width: 20, scopedSlots: { customRender: 'action' } },
  737. { title: '{{ i18n "pages.xray.balancer.tag"}}', dataIndex: 'tag', align: 'center', width: 50 },
  738. { title: '{{ i18n "pages.xray.balancer.balancerStrategy"}}', align: 'center', width: 50, scopedSlots: { customRender: 'strategy' }},
  739. { title: '{{ i18n "pages.xray.balancer.balancerSelectors"}}', align: 'center', width: 100, scopedSlots: { customRender: 'selector' }},
  740. ];
  741. const dnsColumns = [
  742. { title: "#", align: 'center', width: 20, scopedSlots: { customRender: 'action' } },
  743. { title: '{{ i18n "pages.xray.outbound.address"}}', align: 'center', width: 50, scopedSlots: { customRender: 'address' } },
  744. { title: '{{ i18n "pages.xray.dns.domains"}}', align: 'center', width: 50, scopedSlots: { customRender: 'domain' } },
  745. ];
  746. const fakednsColumns = [
  747. { title: "#", align: 'center', width: 20, scopedSlots: { customRender: 'action' } },
  748. { title: '{{ i18n "pages.xray.fakedns.ipPool"}}', dataIndex: 'ipPool', align: 'center', width: 50 },
  749. { title: '{{ i18n "pages.xray.fakedns.poolSize"}}', dataIndex: 'poolSize', align: 'center', width: 50 },
  750. ];
  751. const app = new Vue({
  752. delimiters: ['[[', ']]'],
  753. el: '#app',
  754. data: {
  755. siderDrawer,
  756. themeSwitcher,
  757. isDarkTheme: themeSwitcher.isDarkTheme,
  758. spinning: false,
  759. oldXraySetting: '',
  760. xraySetting: '',
  761. inboundTags: [],
  762. outboundsTraffic: [],
  763. saveBtnDisable: true,
  764. refreshing: false,
  765. restartResult: '',
  766. showAlert: false,
  767. isMobile: window.innerWidth <= 768,
  768. advSettings: 'xraySetting',
  769. obsSettings: '',
  770. cm: null,
  771. cmOptions: {
  772. lineNumbers: true,
  773. mode: "application/json",
  774. lint: true,
  775. styleActiveLine: true,
  776. matchBrackets: true,
  777. theme: "xq",
  778. autoCloseTags: true,
  779. lineWrapping: true,
  780. indentUnit: 2,
  781. indentWithTabs: true,
  782. smartIndent: true,
  783. tabSize: 2,
  784. lineWiseCopyCut: false,
  785. foldGutter: true,
  786. gutters: [
  787. "CodeMirror-lint-markers",
  788. "CodeMirror-linenumbers",
  789. "CodeMirror-foldgutter",
  790. ],
  791. },
  792. ipv4Settings: {
  793. tag: "IPv4",
  794. protocol: "freedom",
  795. settings: {
  796. domainStrategy: "UseIPv4"
  797. }
  798. },
  799. directSettings: {
  800. tag: "direct",
  801. protocol: "freedom"
  802. },
  803. routingDomainStrategies: ["AsIs", "IPIfNonMatch", "IPOnDemand"],
  804. log: {
  805. loglevel: ["none", "debug", "info", "warning", "error"],
  806. access: ["none", "./access.log"],
  807. error: ["none", "./error.log"],
  808. dnsLog: false,
  809. maskAddress: ["quarter", "half", "full"],
  810. },
  811. settingsData: {
  812. protocols: {
  813. bittorrent: ["bittorrent"],
  814. },
  815. ips: {
  816. local: ["geoip:private"],
  817. cn: ["geoip:cn"],
  818. ir: ["ext:geoip_IR.dat:ir"],
  819. ru: ["geoip:ru"],
  820. vn: ["ext:geoip_VN.dat:vn"],
  821. },
  822. domains: {
  823. ads: [
  824. "geosite:category-ads-all",
  825. "ext:geosite_IR.dat:category-ads-all"
  826. ],
  827. security: [
  828. "ext:geosite_IR.dat:malware",
  829. "ext:geosite_IR.dat:phishing",
  830. "ext:geosite_IR.dat:cryptominers"
  831. ],
  832. speedtest: ["geosite:speedtest"],
  833. openai: ["geosite:openai"],
  834. google: ["geosite:google"],
  835. spotify: ["geosite:spotify"],
  836. netflix: ["geosite:netflix"],
  837. meta: ["geosite:meta"],
  838. apple: ["geosite:apple"],
  839. reddit: ["geosite:reddit"],
  840. cn: [
  841. "geosite:cn",
  842. "regexp:.*\\.cn$"
  843. ],
  844. ru: [
  845. "geosite:category-gov-ru",
  846. "regexp:.*\\.ru$"
  847. ],
  848. ir: [
  849. "regexp:.*\\.ir$",
  850. "regexp:.*\\.xn--mgba3a4f16a$", // .ایران
  851. "ext:geosite_IR.dat:ir"
  852. ],
  853. vn: [
  854. "regexp:.*\\.vn$",
  855. "ext:geosite_VN.dat:vn",
  856. "ext:geosite_VN.dat:ads"
  857. ]
  858. },
  859. familyProtectDNS: {
  860. "servers": [
  861. "1.1.1.3", // https://developers.cloudflare.com/1.1.1.1/setup/
  862. "1.0.0.3",
  863. "2606:4700:4700::1113",
  864. "2606:4700:4700::1003"
  865. ],
  866. "queryStrategy": "UseIP"
  867. },
  868. },
  869. defaultObservatory: {
  870. subjectSelector: [],
  871. probeURL: "http://www.google.com/gen_204",
  872. probeInterval: "10m",
  873. enableConcurrency: true
  874. },
  875. defaultBurstObservatory: {
  876. subjectSelector: [],
  877. pingConfig: {
  878. destination: "http://www.google.com/gen_204",
  879. interval: "30m",
  880. connectivity: "http://connectivitycheck.platform.hicloud.com/generate_204",
  881. timeout: "10s",
  882. sampling: 2
  883. }
  884. }
  885. },
  886. methods: {
  887. loading(spinning = true) {
  888. this.spinning = spinning;
  889. },
  890. async getOutboundsTraffic() {
  891. const msg = await HttpUtil.get("/panel/xray/getOutboundsTraffic");
  892. if (msg.success) {
  893. this.outboundsTraffic = msg.obj;
  894. }
  895. },
  896. async getXraySetting() {
  897. this.loading(true);
  898. const msg = await HttpUtil.post("/panel/xray/");
  899. this.loading(false);
  900. if (msg.success) {
  901. result = JSON.parse(msg.obj);
  902. xs = JSON.stringify(result.xraySetting, null, 2);
  903. this.oldXraySetting = xs;
  904. this.xraySetting = xs;
  905. this.inboundTags = result.inboundTags;
  906. this.saveBtnDisable = true;
  907. }
  908. },
  909. async updateXraySetting() {
  910. this.loading(true);
  911. const msg = await HttpUtil.post("/panel/xray/update", {xraySetting : this.xraySetting});
  912. this.loading(false);
  913. if (msg.success) {
  914. await this.getXraySetting();
  915. }
  916. },
  917. async restartXray() {
  918. this.loading(true);
  919. const msg = await HttpUtil.post("server/restartXrayService");
  920. this.loading(false);
  921. if (msg.success) {
  922. await PromiseUtil.sleep(500);
  923. await this.getXrayResult();
  924. }
  925. this.loading(false);
  926. },
  927. async getXrayResult() {
  928. const msg = await HttpUtil.get("/panel/xray/getXrayResult");
  929. if (msg.success) {
  930. this.restartResult=msg.obj;
  931. if(msg.obj.length > 1) Vue.prototype.$message.error(msg.obj);
  932. }
  933. },
  934. async fetchUserSecret() {
  935. this.loading(true);
  936. const userMessage = await HttpUtil.post("/panel/setting/getUserSecret", this.user);
  937. if (userMessage.success) {
  938. this.user = userMessage.obj;
  939. }
  940. this.loading(false);
  941. },
  942. async updateSecret() {
  943. this.loading(true);
  944. const msg = await HttpUtil.post("/panel/setting/updateUserSecret", this.user);
  945. if (msg.success) {
  946. this.user = msg.obj;
  947. window.location.replace(basePath + "logout");
  948. }
  949. this.loading(false);
  950. await this.updateXraySetting();
  951. },
  952. generateRandomString(length) {
  953. var chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
  954. let randomString = "";
  955. for (let i = 0; i < length; i++) {
  956. randomString += chars[Math.floor(Math.random() * chars.length)];
  957. }
  958. return randomString;
  959. },
  960. async getNewSecret() {
  961. this.loading(true);
  962. await PromiseUtil.sleep(600);
  963. const newSecret = this.generateRandomString(64);
  964. this.user.loginSecret = newSecret;
  965. document.getElementById("token").textContent = newSecret;
  966. this.loading(false);
  967. },
  968. async toggleToken(value) {
  969. if (value) {
  970. await this.getNewSecret();
  971. } else {
  972. this.user.loginSecret = "";
  973. }
  974. },
  975. async resetXrayConfigToDefault() {
  976. this.loading(true);
  977. const msg = await HttpUtil.get("/panel/setting/getDefaultJsonConfig");
  978. this.loading(false);
  979. if (msg.success) {
  980. this.templateSettings = JSON.parse(JSON.stringify(msg.obj, null, 2));
  981. this.saveBtnDisable = true;
  982. }
  983. },
  984. changePage(pageKey) {
  985. if(pageKey == 'tpl-advanced') this.changeCode();
  986. if(pageKey == 'tpl-balancer') this.changeObsCode();
  987. },
  988. syncRulesWithOutbound(tag, setting) {
  989. const newTemplateSettings = this.templateSettings;
  990. const haveRules = newTemplateSettings.routing.rules.some((r) => r?.outboundTag === tag);
  991. const outboundIndex = newTemplateSettings.outbounds.findIndex((o) => o.tag === tag);
  992. if (!haveRules && outboundIndex > 0) {
  993. newTemplateSettings.outbounds.splice(outboundIndex);
  994. }
  995. if (haveRules && outboundIndex < 0) {
  996. newTemplateSettings.outbounds.push(setting);
  997. }
  998. this.templateSettings = newTemplateSettings;
  999. },
  1000. templateRuleGetter(routeSettings) {
  1001. const { property, outboundTag } = routeSettings;
  1002. let result = [];
  1003. if (this.templateSettings != null) {
  1004. this.templateSettings.routing.rules.forEach(
  1005. (routingRule) => {
  1006. if (
  1007. routingRule.hasOwnProperty(property) &&
  1008. routingRule.hasOwnProperty("outboundTag") &&
  1009. routingRule.outboundTag === outboundTag
  1010. ) {
  1011. result.push(...routingRule[property]);
  1012. }
  1013. }
  1014. );
  1015. }
  1016. return result;
  1017. },
  1018. templateRuleSetter(routeSettings) {
  1019. const { data, property, outboundTag } = routeSettings;
  1020. const oldTemplateSettings = this.templateSettings;
  1021. const newTemplateSettings = oldTemplateSettings;
  1022. currentProperty = this.templateRuleGetter({ outboundTag, property })
  1023. if (currentProperty.length == 0) {
  1024. const propertyRule = {
  1025. type: "field",
  1026. outboundTag,
  1027. [property]: data
  1028. };
  1029. newTemplateSettings.routing.rules.push(propertyRule);
  1030. }
  1031. else {
  1032. const newRules = [];
  1033. insertedOnce = false;
  1034. newTemplateSettings.routing.rules.forEach(
  1035. (routingRule) => {
  1036. if (
  1037. routingRule.hasOwnProperty(property) &&
  1038. routingRule.hasOwnProperty("outboundTag") &&
  1039. routingRule.outboundTag === outboundTag
  1040. ) {
  1041. if (!insertedOnce && data.length > 0) {
  1042. insertedOnce = true;
  1043. routingRule[property] = data;
  1044. newRules.push(routingRule);
  1045. }
  1046. }
  1047. else {
  1048. newRules.push(routingRule);
  1049. }
  1050. }
  1051. );
  1052. newTemplateSettings.routing.rules = newRules;
  1053. }
  1054. this.templateSettings = newTemplateSettings;
  1055. },
  1056. changeCode() {
  1057. if(this.cm != null) {
  1058. this.cm.toTextArea();
  1059. }
  1060. textAreaObj = document.getElementById('xraySetting');
  1061. textAreaObj.value = this[this.advSettings];
  1062. this.cm = CodeMirror.fromTextArea(textAreaObj, this.cmOptions);
  1063. this.cm.on('change',editor => {
  1064. value = editor.getValue();
  1065. if (this.isJsonString(value)) {
  1066. this[this.advSettings] = value;
  1067. }
  1068. });
  1069. },
  1070. changeObsCode() {
  1071. if(this.cm != null) {
  1072. this.cm.toTextArea();
  1073. }
  1074. if (this.obsSettings == ''){
  1075. this.cm = null;
  1076. return
  1077. }
  1078. textAreaObj = document.getElementById('obsSetting');
  1079. textAreaObj.value = this[this.obsSettings];
  1080. this.cm = CodeMirror.fromTextArea(textAreaObj, this.cmOptions);
  1081. this.cm.on('change',editor => {
  1082. value = editor.getValue();
  1083. if(this.isJsonString(value)){
  1084. this[this.obsSettings] = value;
  1085. }
  1086. });
  1087. },
  1088. isJsonString(str) {
  1089. try {
  1090. JSON.parse(str);
  1091. } catch (e) {
  1092. return false;
  1093. }
  1094. return true;
  1095. },
  1096. findOutboundTraffic(o) {
  1097. for (const otraffic of this.outboundsTraffic) {
  1098. if (otraffic.tag == o.tag) {
  1099. return sizeFormat(otraffic.up) + ' / ' + sizeFormat(otraffic.down);
  1100. }
  1101. }
  1102. return sizeFormat(0) + ' / ' + sizeFormat(0);
  1103. },
  1104. findOutboundAddress(o) {
  1105. serverObj = null;
  1106. switch(o.protocol){
  1107. case Protocols.VMess:
  1108. case Protocols.VLESS:
  1109. serverObj = o.settings.vnext;
  1110. break;
  1111. case Protocols.HTTP:
  1112. case Protocols.Socks:
  1113. case Protocols.Shadowsocks:
  1114. case Protocols.Trojan:
  1115. serverObj = o.settings.servers;
  1116. break;
  1117. case Protocols.DNS:
  1118. return [o.settings?.address + ':' + o.settings?.port];
  1119. case Protocols.Wireguard:
  1120. return o.settings.peers.map(peer => peer.endpoint);
  1121. default:
  1122. return null;
  1123. }
  1124. return serverObj ? serverObj.map(obj => obj.address + ':' + obj.port) : null;
  1125. },
  1126. addOutbound(){
  1127. outModal.show({
  1128. title: '{{ i18n "pages.xray.outbound.addOutbound"}}',
  1129. okText: '{{ i18n "pages.xray.outbound.addOutbound" }}',
  1130. confirm: (outbound) => {
  1131. outModal.loading();
  1132. if(outbound.tag.length > 0){
  1133. this.templateSettings.outbounds.push(outbound);
  1134. this.outboundSettings = JSON.stringify(this.templateSettings.outbounds);
  1135. }
  1136. outModal.close();
  1137. },
  1138. isEdit: false,
  1139. tags: this.templateSettings.outbounds.map(obj => obj.tag)
  1140. });
  1141. },
  1142. editOutbound(index){
  1143. outModal.show({
  1144. title: '{{ i18n "pages.xray.outbound.editOutbound"}} ' + (index+1),
  1145. outbound: app.templateSettings.outbounds[index],
  1146. confirm: (outbound) => {
  1147. outModal.loading();
  1148. this.templateSettings.outbounds[index] = outbound;
  1149. this.outboundSettings = JSON.stringify(this.templateSettings.outbounds);
  1150. outModal.close();
  1151. },
  1152. isEdit: true,
  1153. tags: this.outboundData.filter((o) => o.key != index ).map(obj => obj.tag)
  1154. });
  1155. },
  1156. deleteOutbound(index){
  1157. outbounds = this.templateSettings.outbounds;
  1158. outbounds.splice(index,1);
  1159. this.outboundSettings = JSON.stringify(outbounds);
  1160. },
  1161. setFirstOutbound(index){
  1162. outbounds = this.templateSettings.outbounds;
  1163. outbounds.splice(0, 0, outbounds.splice(index, 1)[0]);
  1164. this.outboundSettings = JSON.stringify(outbounds);
  1165. },
  1166. addReverse(){
  1167. reverseModal.show({
  1168. title: '{{ i18n "pages.xray.outbound.addReverse"}}',
  1169. okText: '{{ i18n "pages.xray.outbound.addReverse" }}',
  1170. confirm: (reverse, rules) => {
  1171. reverseModal.loading();
  1172. if(reverse.tag.length > 0){
  1173. newTemplateSettings = this.templateSettings;
  1174. if(newTemplateSettings.reverse == undefined) newTemplateSettings.reverse = {};
  1175. if(newTemplateSettings.reverse[reverse.type+'s'] == undefined) newTemplateSettings.reverse[reverse.type+'s'] = [];
  1176. newTemplateSettings.reverse[reverse.type+'s'].push({ tag: reverse.tag, domain: reverse.domain });
  1177. this.templateSettings = newTemplateSettings;
  1178. // Add related rules
  1179. this.templateSettings.routing.rules.push(...rules);
  1180. this.routingRuleSettings = JSON.stringify(this.templateSettings.routing.rules);
  1181. }
  1182. reverseModal.close();
  1183. },
  1184. isEdit: false
  1185. });
  1186. },
  1187. editReverse(index){
  1188. if(this.reverseData[index].type == "bridge") {
  1189. oldRules = this.templateSettings.routing.rules.filter(r => r.inboundTag && r.inboundTag[0] == this.reverseData[index].tag);
  1190. } else {
  1191. oldRules = this.templateSettings.routing.rules.filter(r => r.outboundTag && r.outboundTag == this.reverseData[index].tag);
  1192. }
  1193. reverseModal.show({
  1194. title: '{{ i18n "pages.xray.outbound.editReverse"}} ' + (index+1),
  1195. reverse: this.reverseData[index],
  1196. rules: oldRules,
  1197. confirm: (reverse, rules) => {
  1198. reverseModal.loading();
  1199. if(reverse.tag.length > 0){
  1200. oldData = this.reverseData[index];
  1201. newTemplateSettings = this.templateSettings;
  1202. oldReverseIndex = newTemplateSettings.reverse[oldData.type+'s'].findIndex(rs => rs.tag == oldData.tag);
  1203. oldRuleIndex0 = oldRules.length>0 ? newTemplateSettings.routing.rules.findIndex(r => JSON.stringify(r) == JSON.stringify(oldRules[0])) : -1;
  1204. oldRuleIndex1 = oldRules.length==2 ? newTemplateSettings.routing.rules.findIndex(r => JSON.stringify(r) == JSON.stringify(oldRules[1])) : -1;
  1205. if(oldData.type == reverse.type){
  1206. newTemplateSettings.reverse[oldData.type + 's'][oldReverseIndex] = { tag: reverse.tag, domain: reverse.domain };
  1207. } else {
  1208. newTemplateSettings.reverse[oldData.type+'s'].splice(oldReverseIndex,1);
  1209. // delete empty object
  1210. if(newTemplateSettings.reverse[oldData.type+'s'].length == 0) Reflect.deleteProperty(newTemplateSettings.reverse, oldData.type+'s');
  1211. // add other type of reverse if it is not exist
  1212. if(!newTemplateSettings.reverse[reverse.type+'s']) newTemplateSettings.reverse[reverse.type+'s'] = [];
  1213. newTemplateSettings.reverse[reverse.type+'s'].push({ tag: reverse.tag, domain: reverse.domain });
  1214. }
  1215. this.templateSettings = newTemplateSettings;
  1216. // Adjust Rules
  1217. newRules = this.templateSettings.routing.rules;
  1218. oldRuleIndex0 != -1 ? newRules[oldRuleIndex0] = rules[0] : newRules.push(rules[0]);
  1219. oldRuleIndex1 != -1 ? newRules[oldRuleIndex1] = rules[1] : newRules.push(rules[1]);
  1220. this.routingRuleSettings = JSON.stringify(newRules);
  1221. }
  1222. reverseModal.close();
  1223. },
  1224. isEdit: true
  1225. });
  1226. },
  1227. deleteReverse(index){
  1228. oldData = this.reverseData[index];
  1229. newTemplateSettings = this.templateSettings;
  1230. reverseTypeObj = newTemplateSettings.reverse[oldData.type+'s'];
  1231. realIndex = reverseTypeObj.findIndex(r => r.tag==oldData.tag && r.domain==oldData.domain);
  1232. newTemplateSettings.reverse[oldData.type+'s'].splice(realIndex,1);
  1233. // delete empty objects
  1234. if(reverseTypeObj.length == 0) Reflect.deleteProperty(newTemplateSettings.reverse, oldData.type+'s');
  1235. if(Object.keys(newTemplateSettings.reverse).length === 0) Reflect.deleteProperty(newTemplateSettings, 'reverse');
  1236. // delete related routing rules
  1237. newRules = newTemplateSettings.routing.rules;
  1238. if(oldData.type == "bridge"){
  1239. newRules = newTemplateSettings.routing.rules.filter(r => !( r.inboundTag && r.inboundTag.length == 1 && r.inboundTag[0] == oldData.tag));
  1240. } else if(oldData.type == "portal"){
  1241. newRules = newTemplateSettings.routing.rules.filter(r => r.outboundTag != oldData.tag);
  1242. }
  1243. newTemplateSettings.routing.rules = newRules;
  1244. this.templateSettings = newTemplateSettings;
  1245. },
  1246. async refreshOutboundTraffic() {
  1247. if (!this.refreshing) {
  1248. this.refreshing = true;
  1249. await this.getOutboundsTraffic();
  1250. data = []
  1251. if (this.templateSettings != null) {
  1252. this.templateSettings.outbounds.forEach((o, index) => {
  1253. data.push({'key': index, ...o});
  1254. });
  1255. }
  1256. this.outboundData = data;
  1257. this.refreshing = false;
  1258. }
  1259. },
  1260. async resetOutboundTraffic(index) {
  1261. let tag = "-alltags-";
  1262. if (index >= 0) {
  1263. tag = this.outboundData[index].tag ? this.outboundData[index].tag : ""
  1264. }
  1265. const msg = await HttpUtil.post("/panel/xray/resetOutboundsTraffic", { tag: tag });
  1266. if (msg.success) {
  1267. await this.refreshOutboundTraffic();
  1268. }
  1269. },
  1270. addBalancer() {
  1271. balancerModal.show({
  1272. title: '{{ i18n "pages.xray.balancer.addBalancer"}}',
  1273. okText: '{{ i18n "pages.xray.balancer.addBalancer"}}',
  1274. balancerTags: this.balancersData.filter((o) => !ObjectUtil.isEmpty(o.tag)).map(obj => obj.tag),
  1275. balancer: {
  1276. tag: '',
  1277. strategy: 'random',
  1278. selector: [],
  1279. fallbackTag: ''
  1280. },
  1281. confirm: (balancer) => {
  1282. balancerModal.loading();
  1283. newTemplateSettings = this.templateSettings;
  1284. if (newTemplateSettings.routing.balancers == undefined) {
  1285. newTemplateSettings.routing.balancers = [];
  1286. }
  1287. let tmpBalancer = {
  1288. 'tag': balancer.tag,
  1289. 'selector': balancer.selector,
  1290. 'fallbackTag': balancer.fallbackTag
  1291. };
  1292. if (balancer.strategy && balancer.strategy != 'random') {
  1293. tmpBalancer.strategy = {
  1294. 'type': balancer.strategy
  1295. };
  1296. }
  1297. newTemplateSettings.routing.balancers.push(tmpBalancer);
  1298. this.templateSettings = newTemplateSettings;
  1299. if (balancer.strategy == 'leastPing' || balancer.strategy == 'leastLoad')
  1300. this.updateObservatorySelectors();
  1301. balancerModal.close();
  1302. this.changeObsCode();
  1303. },
  1304. isEdit: false
  1305. });
  1306. },
  1307. editBalancer(index) {
  1308. const oldTag = this.balancersData[index].tag;
  1309. balancerModal.show({
  1310. title: '{{ i18n "pages.xray.balancer.editBalancer"}}',
  1311. okText: '{{ i18n "sure" }}',
  1312. balancerTags: this.balancersData.filter((o) => !ObjectUtil.isEmpty(o.tag)).map(obj => obj.tag),
  1313. balancer: this.balancersData[index],
  1314. confirm: (balancer) => {
  1315. balancerModal.loading();
  1316. newTemplateSettings = this.templateSettings;
  1317. let tmpBalancer = {
  1318. 'tag': balancer.tag,
  1319. 'selector': balancer.selector,
  1320. 'fallbackTag': balancer.fallbackTag
  1321. };
  1322. // Remove old tag
  1323. if (newTemplateSettings.observatory){
  1324. newTemplateSettings.observatory.subjectSelector = newTemplateSettings.observatory.subjectSelector.filter(s => s != oldTag);
  1325. }
  1326. if (newTemplateSettings.burstObservatory){
  1327. newTemplateSettings.burstObservatory.subjectSelector = newTemplateSettings.burstObservatory.subjectSelector.filter(s => s != oldTag);
  1328. }
  1329. if (balancer.strategy && balancer.strategy != 'random') {
  1330. tmpBalancer.strategy = {
  1331. 'type': balancer.strategy
  1332. };
  1333. }
  1334. newTemplateSettings.routing.balancers[index] = tmpBalancer;
  1335. // change edited tag if used in rule section
  1336. if (oldTag != balancer.tag) {
  1337. newTemplateSettings.routing.rules.forEach((rule) => {
  1338. if (rule.balancerTag && rule.balancerTag == oldTag) {
  1339. rule.balancerTag = balancer.tag;
  1340. }
  1341. });
  1342. }
  1343. this.templateSettings = newTemplateSettings;
  1344. if (balancer.strategy == 'leastPing' || balancer.strategy == 'leastLoad')
  1345. this.updateObservatorySelectors();
  1346. balancerModal.close();
  1347. this.changeObsCode();
  1348. },
  1349. isEdit: true
  1350. });
  1351. },
  1352. updateObservatorySelectors(){
  1353. newTemplateSettings = this.templateSettings;
  1354. const leastPings = this.balancersData.filter((b) => b.strategy == 'leastPing');
  1355. const leastLoads = this.balancersData.filter((b) => b.strategy == 'leastLoad');
  1356. if (leastPings.length>0){
  1357. if (!newTemplateSettings.observatory)
  1358. newTemplateSettings.observatory = this.defaultObservatory;
  1359. newTemplateSettings.observatory.subjectSelector = [];
  1360. leastPings.forEach((b) => {
  1361. b.selector.forEach((s) => {
  1362. if (!newTemplateSettings.observatory.subjectSelector.includes(s))
  1363. newTemplateSettings.observatory.subjectSelector.push(s);
  1364. });
  1365. });
  1366. } else {
  1367. delete newTemplateSettings.observatory
  1368. }
  1369. if (leastLoads.length>0){
  1370. if (!newTemplateSettings.burstObservatory)
  1371. newTemplateSettings.burstObservatory = this.defaultBurstObservatory;
  1372. newTemplateSettings.burstObservatory.subjectSelector = [];
  1373. leastLoads.forEach((b) => {
  1374. b.selector.forEach((s) => {
  1375. if (!newTemplateSettings.burstObservatory.subjectSelector.includes(s))
  1376. newTemplateSettings.burstObservatory.subjectSelector.push(s);
  1377. });
  1378. });
  1379. } else {
  1380. delete newTemplateSettings.burstObservatory
  1381. }
  1382. this.templateSettings = newTemplateSettings;
  1383. this.changeObsCode();
  1384. },
  1385. deleteBalancer(index) {
  1386. newTemplateSettings = this.templateSettings;
  1387. // Remove from balancers
  1388. const removedBalancer = this.balancersData.splice(index, 1)[0];
  1389. // Remove from settings
  1390. let realIndex = newTemplateSettings.routing.balancers.findIndex((b) => b.tag === removedBalancer.tag);
  1391. newTemplateSettings.routing.balancers.splice(realIndex, 1);
  1392. // Update balancers property to an empty array if there are no more balancers
  1393. if (newTemplateSettings.routing.balancers.length === 0) {
  1394. delete newTemplateSettings.routing.balancers;
  1395. }
  1396. this.templateSettings = newTemplateSettings;
  1397. this.updateObservatorySelectors();
  1398. this.obsSettings = '';
  1399. this.changeObsCode()
  1400. },
  1401. addDNSServer(){
  1402. dnsModal.show({
  1403. title: '{{ i18n "pages.xray.dns.add" }}',
  1404. confirm: (dnsServer) => {
  1405. dnsServers = this.dnsServers;
  1406. dnsServers.push(dnsServer);
  1407. this.dnsServers = dnsServers;
  1408. dnsModal.close();
  1409. },
  1410. isEdit: false
  1411. });
  1412. },
  1413. editDNSServer(index){
  1414. dnsModal.show({
  1415. title: '{{ i18n "pages.xray.dns.edit" }} #' + (index+1),
  1416. dnsServer: this.dnsServers[index],
  1417. confirm: (dnsServer) => {
  1418. dnsServers = this.dnsServers;
  1419. dnsServers[index] = dnsServer;
  1420. this.dnsServers = dnsServers;
  1421. dnsModal.close();
  1422. },
  1423. isEdit: true
  1424. });
  1425. },
  1426. deleteDNSServer(index){
  1427. newDnsServers = this.dnsServers;
  1428. newDnsServers.splice(index,1);
  1429. this.dnsServers = newDnsServers;
  1430. },
  1431. addFakedns() {
  1432. fakednsModal.show({
  1433. title: '{{ i18n "pages.xray.fakedns.add" }}',
  1434. confirm: (item) => {
  1435. fakeDns = this.fakeDns?? [];
  1436. fakeDns.push(item);
  1437. this.fakeDns = fakeDns;
  1438. fakednsModal.close();
  1439. },
  1440. isEdit: false
  1441. });
  1442. },
  1443. editFakedns(index){
  1444. fakednsModal.show({
  1445. title: '{{ i18n "pages.xray.fakedns.edit" }} #' + (index+1),
  1446. fakeDns: this.fakeDns[index],
  1447. confirm: (item) => {
  1448. fakeDns = this.fakeDns;
  1449. fakeDns[index] = item;
  1450. this.fakeDns = fakeDns;
  1451. fakednsModal.close();
  1452. },
  1453. isEdit: true
  1454. });
  1455. },
  1456. deleteFakedns(index){
  1457. fakeDns = this.fakeDns;
  1458. fakeDns.splice(index,1);
  1459. this.fakeDns = fakeDns;
  1460. },
  1461. addRule(){
  1462. ruleModal.show({
  1463. title: '{{ i18n "pages.xray.rules.add"}}',
  1464. okText: '{{ i18n "pages.xray.rules.add" }}',
  1465. confirm: (rule) => {
  1466. ruleModal.loading();
  1467. if(JSON.stringify(rule).length > 3){
  1468. this.templateSettings.routing.rules.push(rule);
  1469. this.routingRuleSettings = JSON.stringify(this.templateSettings.routing.rules);
  1470. }
  1471. ruleModal.close();
  1472. },
  1473. isEdit: false
  1474. });
  1475. },
  1476. editRule(index){
  1477. ruleModal.show({
  1478. title: '{{ i18n "pages.xray.rules.edit"}} ' + (index+1),
  1479. rule: app.templateSettings.routing.rules[index],
  1480. confirm: (rule) => {
  1481. ruleModal.loading();
  1482. if(JSON.stringify(rule).length > 3){
  1483. this.templateSettings.routing.rules[index] = rule;
  1484. this.routingRuleSettings = JSON.stringify(this.templateSettings.routing.rules);
  1485. }
  1486. ruleModal.close();
  1487. },
  1488. isEdit: true
  1489. });
  1490. },
  1491. replaceRule(old_index,new_index){
  1492. rules = this.templateSettings.routing.rules;
  1493. if (new_index >= rules.length) rules.push(undefined);
  1494. rules.splice(new_index, 0, rules.splice(old_index, 1)[0]);
  1495. this.routingRuleSettings = JSON.stringify(rules);
  1496. },
  1497. deleteRule(index){
  1498. rules = this.templateSettings.routing.rules;
  1499. rules.splice(index,1);
  1500. this.routingRuleSettings = JSON.stringify(rules);
  1501. },
  1502. showWarp(){
  1503. warpModal.show();
  1504. }
  1505. },
  1506. async mounted() {
  1507. if (window.location.protocol !== "https:") {
  1508. this.showAlert = true;
  1509. }
  1510. await this.getXraySetting();
  1511. await this.getXrayResult();
  1512. await this.getOutboundsTraffic();
  1513. while (true) {
  1514. await PromiseUtil.sleep(800);
  1515. this.saveBtnDisable = this.oldXraySetting === this.xraySetting;
  1516. }
  1517. },
  1518. computed: {
  1519. templateSettings: {
  1520. get: function () {
  1521. const parsedSettings = this.xraySetting ? JSON.parse(this.xraySetting) : null;
  1522. return parsedSettings;
  1523. },
  1524. set: function (newValue) {
  1525. if (newValue) {
  1526. this.xraySetting = JSON.stringify(newValue, null, 2);
  1527. }
  1528. },
  1529. },
  1530. inboundSettings: {
  1531. get: function () { return this.templateSettings ? JSON.stringify(this.templateSettings.inbounds, null, 2) : null; },
  1532. set: function (newValue) {
  1533. newTemplateSettings = this.templateSettings;
  1534. newTemplateSettings.inbounds = JSON.parse(newValue);
  1535. this.templateSettings = newTemplateSettings;
  1536. },
  1537. },
  1538. outboundSettings: {
  1539. get: function () { return this.templateSettings ? JSON.stringify(this.templateSettings.outbounds, null, 2) : null; },
  1540. set: function (newValue) {
  1541. newTemplateSettings = this.templateSettings;
  1542. newTemplateSettings.outbounds = JSON.parse(newValue);
  1543. this.templateSettings = newTemplateSettings;
  1544. },
  1545. },
  1546. outboundData: {
  1547. get: function () {
  1548. data = []
  1549. if (this.templateSettings != null) {
  1550. this.templateSettings.outbounds.forEach((o, index) => {
  1551. data.push({'key': index, ...o});
  1552. });
  1553. }
  1554. return data;
  1555. },
  1556. },
  1557. reverseData: {
  1558. get: function () {
  1559. data = []
  1560. if (this.templateSettings != null && this.templateSettings.reverse != null) {
  1561. if(this.templateSettings.reverse.bridges) {
  1562. this.templateSettings.reverse.bridges.forEach((o, index) => {
  1563. data.push({'key': index, 'type':'bridge', ...o});
  1564. });
  1565. }
  1566. if(this.templateSettings.reverse.portals){
  1567. this.templateSettings.reverse.portals.forEach((o, index) => {
  1568. data.push({'key': index, 'type':'portal', ...o});
  1569. });
  1570. }
  1571. }
  1572. return data;
  1573. },
  1574. },
  1575. routingRuleSettings: {
  1576. get: function () { return this.templateSettings ? JSON.stringify(this.templateSettings.routing.rules, null, 2) : null; },
  1577. set: function (newValue) {
  1578. newTemplateSettings = this.templateSettings;
  1579. newTemplateSettings.routing.rules = JSON.parse(newValue);
  1580. this.templateSettings = newTemplateSettings;
  1581. },
  1582. },
  1583. routingRuleData: {
  1584. get: function () {
  1585. data = [];
  1586. if (this.templateSettings != null) {
  1587. this.templateSettings.routing.rules.forEach((r, index) => {
  1588. data.push({'key': index, ...r});
  1589. });
  1590. // Make rules readable
  1591. data.forEach(r => {
  1592. if(r.domain) r.domain = r.domain.join(',')
  1593. if(r.ip) r.ip = r.ip.join(',')
  1594. if(r.source) r.source = r.source.join(',');
  1595. if(r.user) r.user = r.user.join(',')
  1596. if(r.inboundTag) r.inboundTag = r.inboundTag.join(',')
  1597. if(r.protocol) r.protocol = r.protocol.join(',')
  1598. if(r.attrs) r.attrs = JSON.stringify(r.attrs, null, 2)
  1599. });
  1600. }
  1601. return data;
  1602. }
  1603. },
  1604. balancersData: {
  1605. get: function () {
  1606. data = []
  1607. if (this.templateSettings != null && this.templateSettings.routing != null && this.templateSettings.routing.balancers != null) {
  1608. this.templateSettings.routing.balancers.forEach((o, index) => {
  1609. data.push({
  1610. 'key': index,
  1611. 'tag': o.tag ? o.tag : "",
  1612. 'strategy': o.strategy?.type ?? "random",
  1613. 'selector': o.selector ? o.selector : [],
  1614. 'fallbackTag': o.fallbackTag?? '',
  1615. });
  1616. });
  1617. }
  1618. return data;
  1619. }
  1620. },
  1621. observatory: {
  1622. get: function () {
  1623. return this.templateSettings?.observatory ? JSON.stringify(this.templateSettings.observatory, null, 2) : null;
  1624. },
  1625. set: function (newValue) {
  1626. newTemplateSettings = this.templateSettings;
  1627. newTemplateSettings.observatory = JSON.parse(newValue);
  1628. this.templateSettings = newTemplateSettings;
  1629. },
  1630. },
  1631. burstObservatory: {
  1632. get: function () {
  1633. return this.templateSettings?.burstObservatory ? JSON.stringify(this.templateSettings.burstObservatory, null, 2) : null;
  1634. },
  1635. set: function (newValue) {
  1636. newTemplateSettings = this.templateSettings;
  1637. newTemplateSettings.burstObservatory = JSON.parse(newValue);
  1638. this.templateSettings = newTemplateSettings;
  1639. },
  1640. },
  1641. observatoryEnable: function () { return this.templateSettings != null && this.templateSettings.observatory != undefined },
  1642. burstObservatoryEnable: function () { return this.templateSettings != null && this.templateSettings.burstObservatory != undefined },
  1643. freedomStrategy: {
  1644. get: function () {
  1645. if (!this.templateSettings) return "AsIs";
  1646. freedomOutbound = this.templateSettings.outbounds.find((o) => o.protocol === "freedom" && o.tag == "direct");
  1647. if (!freedomOutbound) return "AsIs";
  1648. if (!freedomOutbound.settings || !freedomOutbound.settings.domainStrategy) return "AsIs";
  1649. return freedomOutbound.settings.domainStrategy;
  1650. },
  1651. set: function (newValue) {
  1652. newTemplateSettings = this.templateSettings;
  1653. freedomOutboundIndex = newTemplateSettings.outbounds.findIndex((o) => o.protocol === "freedom" && o.tag == "direct");
  1654. if(freedomOutboundIndex == -1){
  1655. newTemplateSettings.outbounds.push({protocol: "freedom", tag: "direct", settings: { "domainStrategy": newValue }});
  1656. } else if (!newTemplateSettings.outbounds[freedomOutboundIndex].settings) {
  1657. newTemplateSettings.outbounds[freedomOutboundIndex].settings = {"domainStrategy": newValue};
  1658. } else {
  1659. newTemplateSettings.outbounds[freedomOutboundIndex].settings.domainStrategy = newValue;
  1660. }
  1661. this.templateSettings = newTemplateSettings;
  1662. }
  1663. },
  1664. routingStrategy: {
  1665. get: function () {
  1666. if (!this.templateSettings || !this.templateSettings.routing || !this.templateSettings.routing.domainStrategy) return "AsIs";
  1667. return this.templateSettings.routing.domainStrategy;
  1668. },
  1669. set: function (newValue) {
  1670. newTemplateSettings = this.templateSettings;
  1671. newTemplateSettings.routing.domainStrategy = newValue;
  1672. this.templateSettings = newTemplateSettings;
  1673. }
  1674. },
  1675. logLevel: {
  1676. get: function () {
  1677. if (!this.templateSettings || !this.templateSettings.log || !this.templateSettings.log.loglevel) return "warning";
  1678. return this.templateSettings.log.loglevel;
  1679. },
  1680. set: function (newValue) {
  1681. newTemplateSettings = this.templateSettings;
  1682. newTemplateSettings.log.loglevel = newValue;
  1683. this.templateSettings = newTemplateSettings;
  1684. }
  1685. },
  1686. accessLog: {
  1687. get: function () {
  1688. if (!this.templateSettings || !this.templateSettings.log || !this.templateSettings.log.access) return "";
  1689. return this.templateSettings.log.access;
  1690. },
  1691. set: function (newValue) {
  1692. newTemplateSettings = this.templateSettings;
  1693. newTemplateSettings.log.access = newValue;
  1694. this.templateSettings = newTemplateSettings;
  1695. }
  1696. },
  1697. errorLog: {
  1698. get: function () {
  1699. if (!this.templateSettings || !this.templateSettings.log || !this.templateSettings.log.error) return "";
  1700. return this.templateSettings.log.error;
  1701. },
  1702. set: function (newValue) {
  1703. newTemplateSettings = this.templateSettings;
  1704. newTemplateSettings.log.error = newValue;
  1705. this.templateSettings = newTemplateSettings;
  1706. }
  1707. },
  1708. dnslog: {
  1709. get: function () {
  1710. if (!this.templateSettings || !this.templateSettings.log || !this.templateSettings.log.dnsLog) return false;
  1711. return this.templateSettings.log.dnsLog;
  1712. },
  1713. set: function (newValue) {
  1714. newTemplateSettings = this.templateSettings;
  1715. newTemplateSettings.log.dnsLog = newValue;
  1716. this.templateSettings = newTemplateSettings;
  1717. }
  1718. },
  1719. maskAddressLog: {
  1720. get: function () {
  1721. if (!this.templateSettings || !this.templateSettings.log || !this.templateSettings.log.maskAddress) return "";
  1722. return this.templateSettings.log.maskAddress;
  1723. },
  1724. set: function (newValue) {
  1725. newTemplateSettings = this.templateSettings;
  1726. newTemplateSettings.log.maskAddress = newValue;
  1727. this.templateSettings = newTemplateSettings;
  1728. }
  1729. },
  1730. blockedIPs: {
  1731. get: function () {
  1732. return this.templateRuleGetter({ outboundTag: "blocked", property: "ip" });
  1733. },
  1734. set: function (newValue) {
  1735. this.templateRuleSetter({ outboundTag: "blocked", property: "ip", data: newValue });
  1736. }
  1737. },
  1738. blockedDomains: {
  1739. get: function () {
  1740. return this.templateRuleGetter({ outboundTag: "blocked", property: "domain" });
  1741. },
  1742. set: function (newValue) {
  1743. this.templateRuleSetter({ outboundTag: "blocked", property: "domain", data: newValue });
  1744. }
  1745. },
  1746. blockedProtocols: {
  1747. get: function () {
  1748. return this.templateRuleGetter({ outboundTag: "blocked", property: "protocol" });
  1749. },
  1750. set: function (newValue) {
  1751. this.templateRuleSetter({ outboundTag: "blocked", property: "protocol", data: newValue });
  1752. }
  1753. },
  1754. directIPs: {
  1755. get: function () {
  1756. return this.templateRuleGetter({ outboundTag: "direct", property: "ip" });
  1757. },
  1758. set: function (newValue) {
  1759. this.templateRuleSetter({ outboundTag: "direct", property: "ip", data: newValue });
  1760. this.syncRulesWithOutbound("direct", this.directSettings);
  1761. }
  1762. },
  1763. directDomains: {
  1764. get: function () {
  1765. return this.templateRuleGetter({ outboundTag: "direct", property: "domain" });
  1766. },
  1767. set: function (newValue) {
  1768. this.templateRuleSetter({ outboundTag: "direct", property: "domain", data: newValue });
  1769. this.syncRulesWithOutbound("direct", this.directSettings);
  1770. }
  1771. },
  1772. ipv4Domains: {
  1773. get: function () {
  1774. return this.templateRuleGetter({ outboundTag: "IPv4", property: "domain" });
  1775. },
  1776. set: function (newValue) {
  1777. this.templateRuleSetter({ outboundTag: "IPv4", property: "domain", data: newValue });
  1778. this.syncRulesWithOutbound("IPv4", this.ipv4Settings);
  1779. }
  1780. },
  1781. warpDomains: {
  1782. get: function () {
  1783. return this.templateRuleGetter({ outboundTag: "warp", property: "domain" });
  1784. },
  1785. set: function (newValue) {
  1786. this.templateRuleSetter({ outboundTag: "warp", property: "domain", data: newValue });
  1787. }
  1788. },
  1789. torrentSettings: {
  1790. get: function () {
  1791. return doAllItemsExist(this.settingsData.protocols.bittorrent, this.blockedProtocols);
  1792. },
  1793. set: function (newValue) {
  1794. if (newValue) {
  1795. this.blockedProtocols = [...this.blockedProtocols, ...this.settingsData.protocols.bittorrent];
  1796. } else {
  1797. this.blockedProtocols = this.blockedProtocols.filter(data => !this.settingsData.protocols.bittorrent.includes(data));
  1798. }
  1799. },
  1800. },
  1801. privateIpSettings: {
  1802. get: function () {
  1803. return doAllItemsExist(this.settingsData.ips.local, this.blockedIPs);
  1804. },
  1805. set: function (newValue) {
  1806. if (newValue) {
  1807. this.blockedIPs = [...this.blockedIPs, ...this.settingsData.ips.local];
  1808. } else {
  1809. this.blockedIPs = this.blockedIPs.filter(data => !this.settingsData.ips.local.includes(data));
  1810. }
  1811. },
  1812. },
  1813. AdsSettings: {
  1814. get: function () {
  1815. return doAllItemsExist(this.settingsData.domains.ads, this.blockedDomains);
  1816. },
  1817. set: function (newValue) {
  1818. if (newValue) {
  1819. this.blockedDomains = [...this.blockedDomains, ...this.settingsData.domains.ads];
  1820. } else {
  1821. this.blockedDomains = this.blockedDomains.filter(data => !this.settingsData.domains.ads.includes(data));
  1822. }
  1823. },
  1824. },
  1825. SecuritySettings: {
  1826. get: function () {
  1827. return doAllItemsExist(this.settingsData.domains.security, this.blockedDomains);
  1828. },
  1829. set: function (newValue) {
  1830. if (newValue) {
  1831. this.blockedDomains = [...this.blockedDomains, ...this.settingsData.domains.security];
  1832. } else {
  1833. this.blockedDomains = this.blockedDomains.filter(data => !this.settingsData.domains.security.includes(data));
  1834. }
  1835. },
  1836. },
  1837. SpeedTestSettings: {
  1838. get: function () {
  1839. return doAllItemsExist(this.settingsData.domains.speedtest, this.blockedDomains);
  1840. },
  1841. set: function (newValue) {
  1842. if (newValue) {
  1843. this.blockedDomains = [...this.blockedDomains, ...this.settingsData.domains.speedtest];
  1844. } else {
  1845. this.blockedDomains = this.blockedDomains.filter(data => !this.settingsData.domains.speedtest.includes(data));
  1846. }
  1847. },
  1848. },
  1849. familyProtectSettings: {
  1850. get: function () {
  1851. if (!this.templateSettings || !this.templateSettings.dns || !this.templateSettings.dns.servers) return false;
  1852. return doAllItemsExist(this.settingsData.familyProtectDNS.servers, this.templateSettings.dns.servers);
  1853. },
  1854. set: function (newValue) {
  1855. newTemplateSettings = this.templateSettings;
  1856. if (newValue) {
  1857. newTemplateSettings.dns = this.settingsData.familyProtectDNS;
  1858. } else {
  1859. newTemplateSettings.dns.servers = newTemplateSettings.dns?.servers?.filter(data => !this.settingsData.familyProtectDNS.servers.includes(data))
  1860. }
  1861. this.templateSettings = newTemplateSettings;
  1862. },
  1863. },
  1864. GoogleIPv4Settings: {
  1865. get: function () {
  1866. return doAllItemsExist(this.settingsData.domains.google, this.ipv4Domains);
  1867. },
  1868. set: function (newValue) {
  1869. if (newValue) {
  1870. this.ipv4Domains = [...this.ipv4Domains, ...this.settingsData.domains.google];
  1871. } else {
  1872. this.ipv4Domains = this.ipv4Domains.filter(data => !this.settingsData.domains.google.includes(data));
  1873. }
  1874. },
  1875. },
  1876. NetflixIPv4Settings: {
  1877. get: function () {
  1878. return doAllItemsExist(this.settingsData.domains.netflix, this.ipv4Domains);
  1879. },
  1880. set: function (newValue) {
  1881. if (newValue) {
  1882. this.ipv4Domains = [...this.ipv4Domains, ...this.settingsData.domains.netflix];
  1883. } else {
  1884. this.ipv4Domains = this.ipv4Domains.filter(data => !this.settingsData.domains.netflix.includes(data));
  1885. }
  1886. },
  1887. },
  1888. IRIpSettings: {
  1889. get: function () {
  1890. return doAllItemsExist(this.settingsData.ips.ir, this.blockedIPs);
  1891. },
  1892. set: function (newValue) {
  1893. if (newValue) {
  1894. this.blockedIPs = [...this.blockedIPs, ...this.settingsData.ips.ir];
  1895. } else {
  1896. this.blockedIPs = this.blockedIPs.filter(data => !this.settingsData.ips.ir.includes(data));
  1897. }
  1898. }
  1899. },
  1900. IRDomainSettings: {
  1901. get: function () {
  1902. return doAllItemsExist(this.settingsData.domains.ir, this.blockedDomains);
  1903. },
  1904. set: function (newValue) {
  1905. if (newValue) {
  1906. this.blockedDomains = [...this.blockedDomains, ...this.settingsData.domains.ir];
  1907. } else {
  1908. this.blockedDomains = this.blockedDomains.filter(data => !this.settingsData.domains.ir.includes(data));
  1909. }
  1910. }
  1911. },
  1912. ChinaIpSettings: {
  1913. get: function () {
  1914. return doAllItemsExist(this.settingsData.ips.cn, this.blockedIPs);
  1915. },
  1916. set: function (newValue) {
  1917. if (newValue) {
  1918. this.blockedIPs = [...this.blockedIPs, ...this.settingsData.ips.cn];
  1919. } else {
  1920. this.blockedIPs = this.blockedIPs.filter(data => !this.settingsData.ips.cn.includes(data));
  1921. }
  1922. }
  1923. },
  1924. ChinaDomainSettings: {
  1925. get: function () {
  1926. return doAllItemsExist(this.settingsData.domains.cn, this.blockedDomains);
  1927. },
  1928. set: function (newValue) {
  1929. if (newValue) {
  1930. this.blockedDomains = [...this.blockedDomains, ...this.settingsData.domains.cn];
  1931. } else {
  1932. this.blockedDomains = this.blockedDomains.filter(data => !this.settingsData.domains.cn.includes(data));
  1933. }
  1934. }
  1935. },
  1936. RussiaIpSettings: {
  1937. get: function () {
  1938. return doAllItemsExist(this.settingsData.ips.ru, this.blockedIPs);
  1939. },
  1940. set: function (newValue) {
  1941. if (newValue) {
  1942. this.blockedIPs = [...this.blockedIPs, ...this.settingsData.ips.ru];
  1943. } else {
  1944. this.blockedIPs = this.blockedIPs.filter(data => !this.settingsData.ips.ru.includes(data));
  1945. }
  1946. }
  1947. },
  1948. RussiaDomainSettings: {
  1949. get: function () {
  1950. return doAllItemsExist(this.settingsData.domains.ru, this.blockedDomains);
  1951. },
  1952. set: function (newValue) {
  1953. if (newValue) {
  1954. this.blockedDomains = [...this.blockedDomains, ...this.settingsData.domains.ru];
  1955. } else {
  1956. this.blockedDomains = this.blockedDomains.filter(data => !this.settingsData.domains.ru.includes(data));
  1957. }
  1958. }
  1959. },
  1960. VNIpSettings: {
  1961. get: function () {
  1962. return doAllItemsExist(this.settingsData.ips.vn, this.blockedIPs);
  1963. },
  1964. set: function (newValue) {
  1965. if (newValue) {
  1966. this.blockedIPs = [...this.blockedIPs, ...this.settingsData.ips.vn];
  1967. } else {
  1968. this.blockedIPs = this.blockedIPs.filter(data => !this.settingsData.ips.vn.includes(data));
  1969. }
  1970. }
  1971. },
  1972. VNDomainSettings: {
  1973. get: function () {
  1974. return doAllItemsExist(this.settingsData.domains.vn, this.blockedDomains);
  1975. },
  1976. set: function (newValue) {
  1977. if (newValue) {
  1978. this.blockedDomains = [...this.blockedDomains, ...this.settingsData.domains.vn];
  1979. } else {
  1980. this.blockedDomains = this.blockedDomains.filter(data => !this.settingsData.domains.vn.includes(data));
  1981. }
  1982. }
  1983. },
  1984. IRIpDirectSettings: {
  1985. get: function () {
  1986. return doAllItemsExist(this.settingsData.ips.ir, this.directIPs);
  1987. },
  1988. set: function (newValue) {
  1989. if (newValue) {
  1990. this.directIPs = [...this.directIPs, ...this.settingsData.ips.ir];
  1991. } else {
  1992. this.directIPs = this.directIPs.filter(data => !this.settingsData.ips.ir.includes(data));
  1993. }
  1994. }
  1995. },
  1996. IRDomainDirectSettings: {
  1997. get: function () {
  1998. return doAllItemsExist(this.settingsData.domains.ir, this.directDomains);
  1999. },
  2000. set: function (newValue) {
  2001. if (newValue) {
  2002. this.directDomains = [...this.directDomains, ...this.settingsData.domains.ir];
  2003. } else {
  2004. this.directDomains = this.directDomains.filter(data => !this.settingsData.domains.ir.includes(data));
  2005. }
  2006. }
  2007. },
  2008. ChinaIpDirectSettings: {
  2009. get: function () {
  2010. return doAllItemsExist(this.settingsData.ips.cn, this.directIPs);
  2011. },
  2012. set: function (newValue) {
  2013. if (newValue) {
  2014. this.directIPs = [...this.directIPs, ...this.settingsData.ips.cn];
  2015. } else {
  2016. this.directIPs = this.directIPs.filter(data => !this.settingsData.ips.cn.includes(data));
  2017. }
  2018. }
  2019. },
  2020. ChinaDomainDirectSettings: {
  2021. get: function () {
  2022. return doAllItemsExist(this.settingsData.domains.cn, this.directDomains);
  2023. },
  2024. set: function (newValue) {
  2025. if (newValue) {
  2026. this.directDomains = [...this.directDomains, ...this.settingsData.domains.cn];
  2027. } else {
  2028. this.directDomains = this.directDomains.filter(data => !this.settingsData.domains.cn.includes(data));
  2029. }
  2030. }
  2031. },
  2032. RussiaIpDirectSettings: {
  2033. get: function () {
  2034. return doAllItemsExist(this.settingsData.ips.ru, this.directIPs);
  2035. },
  2036. set: function (newValue) {
  2037. if (newValue) {
  2038. this.directIPs = [...this.directIPs, ...this.settingsData.ips.ru];
  2039. } else {
  2040. this.directIPs = this.directIPs.filter(data => !this.settingsData.ips.ru.includes(data));
  2041. }
  2042. }
  2043. },
  2044. RussiaDomainDirectSettings: {
  2045. get: function () {
  2046. return doAllItemsExist(this.settingsData.domains.ru, this.directDomains);
  2047. },
  2048. set: function (newValue) {
  2049. if (newValue) {
  2050. this.directDomains = [...this.directDomains, ...this.settingsData.domains.ru];
  2051. } else {
  2052. this.directDomains = this.directDomains.filter(data => !this.settingsData.domains.ru.includes(data));
  2053. }
  2054. }
  2055. },
  2056. VNIpDirectSettings: {
  2057. get: function () {
  2058. return doAllItemsExist(this.settingsData.ips.vn, this.directIPs);
  2059. },
  2060. set: function (newValue) {
  2061. if (newValue) {
  2062. this.directIPs = [...this.directIPs, ...this.settingsData.ips.vn];
  2063. } else {
  2064. this.directIPs = this.directIPs.filter(data => !this.settingsData.ips.vn.includes(data));
  2065. }
  2066. }
  2067. },
  2068. VNDomainDirectSettings: {
  2069. get: function () {
  2070. return doAllItemsExist(this.settingsData.domains.vn, this.directDomains);
  2071. },
  2072. set: function (newValue) {
  2073. if (newValue) {
  2074. this.directDomains = [...this.directDomains, ...this.settingsData.domains.vn];
  2075. } else {
  2076. this.directDomains = this.directDomains.filter(data => !this.settingsData.domains.vn.includes(data));
  2077. }
  2078. }
  2079. },
  2080. WarpExist: {
  2081. get: function() {
  2082. return this.templateSettings ? this.templateSettings.outbounds.findIndex((o) => o.tag == "warp")>=0 : false;
  2083. },
  2084. },
  2085. GoogleWARPSettings: {
  2086. get: function () {
  2087. return doAllItemsExist(this.settingsData.domains.google, this.warpDomains);
  2088. },
  2089. set: function (newValue) {
  2090. if (newValue) {
  2091. this.warpDomains = [...this.warpDomains, ...this.settingsData.domains.google];
  2092. } else {
  2093. this.warpDomains = this.warpDomains.filter(data => !this.settingsData.domains.google.includes(data));
  2094. }
  2095. },
  2096. },
  2097. OpenAIWARPSettings: {
  2098. get: function () {
  2099. return doAllItemsExist(this.settingsData.domains.openai, this.warpDomains);
  2100. },
  2101. set: function (newValue) {
  2102. if (newValue) {
  2103. this.warpDomains = [...this.warpDomains, ...this.settingsData.domains.openai];
  2104. } else {
  2105. this.warpDomains = this.warpDomains.filter(data => !this.settingsData.domains.openai.includes(data));
  2106. }
  2107. },
  2108. },
  2109. NetflixWARPSettings: {
  2110. get: function () {
  2111. return doAllItemsExist(this.settingsData.domains.netflix, this.warpDomains);
  2112. },
  2113. set: function (newValue) {
  2114. if (newValue) {
  2115. this.warpDomains = [...this.warpDomains, ...this.settingsData.domains.netflix];
  2116. } else {
  2117. this.warpDomains = this.warpDomains.filter(data => !this.settingsData.domains.netflix.includes(data));
  2118. }
  2119. },
  2120. },
  2121. MetaWARPSettings: {
  2122. get: function () {
  2123. return doAllItemsExist(this.settingsData.domains.meta, this.warpDomains);
  2124. },
  2125. set: function (newValue) {
  2126. if (newValue) {
  2127. this.warpDomains = [...this.warpDomains, ...this.settingsData.domains.meta];
  2128. } else {
  2129. this.warpDomains = this.warpDomains.filter(data => !this.settingsData.domains.meta.includes(data));
  2130. }
  2131. },
  2132. },
  2133. AppleWARPSettings: {
  2134. get: function () {
  2135. return doAllItemsExist(this.settingsData.domains.apple, this.warpDomains);
  2136. },
  2137. set: function (newValue) {
  2138. if (newValue) {
  2139. this.warpDomains = [...this.warpDomains, ...this.settingsData.domains.apple];
  2140. } else {
  2141. this.warpDomains = this.warpDomains.filter(data => !this.settingsData.domains.apple.includes(data));
  2142. }
  2143. },
  2144. },
  2145. RedditWARPSettings: {
  2146. get: function () {
  2147. return doAllItemsExist(this.settingsData.domains.reddit, this.warpDomains);
  2148. },
  2149. set: function (newValue) {
  2150. if (newValue) {
  2151. this.warpDomains = [...this.warpDomains, ...this.settingsData.domains.reddit];
  2152. } else {
  2153. this.warpDomains = this.warpDomains.filter(data => !this.settingsData.domains.reddit.includes(data));
  2154. }
  2155. },
  2156. },
  2157. SpotifyWARPSettings: {
  2158. get: function () {
  2159. return doAllItemsExist(this.settingsData.domains.spotify, this.warpDomains);
  2160. },
  2161. set: function (newValue) {
  2162. if (newValue) {
  2163. this.warpDomains = [...this.warpDomains, ...this.settingsData.domains.spotify];
  2164. } else {
  2165. this.warpDomains = this.warpDomains.filter(data => !this.settingsData.domains.spotify.includes(data));
  2166. }
  2167. },
  2168. },
  2169. enableDNS: {
  2170. get: function () {
  2171. return this.templateSettings ? this.templateSettings.dns != null : false;
  2172. },
  2173. set: function (newValue) {
  2174. newTemplateSettings = this.templateSettings;
  2175. if (newValue) {
  2176. newTemplateSettings.dns = { servers: [], queryStrategy: "UseIP", tag: "dns_inbound" };
  2177. newTemplateSettings.fakedns = null;
  2178. } else {
  2179. delete newTemplateSettings.dns;
  2180. delete newTemplateSettings.fakedns;
  2181. }
  2182. this.templateSettings = newTemplateSettings;
  2183. }
  2184. },
  2185. dnsTag: {
  2186. get: function () {
  2187. return this.enableDNS ? this.templateSettings.dns.tag : "";
  2188. },
  2189. set: function (newValue) {
  2190. newTemplateSettings = this.templateSettings;
  2191. newTemplateSettings.dns.tag = newValue;
  2192. this.templateSettings = newTemplateSettings;
  2193. }
  2194. },
  2195. dnsStrategy: {
  2196. get: function () {
  2197. return this.enableDNS ? this.templateSettings.dns.queryStrategy : null;
  2198. },
  2199. set: function (newValue) {
  2200. newTemplateSettings = this.templateSettings;
  2201. newTemplateSettings.dns.queryStrategy = newValue;
  2202. this.templateSettings = newTemplateSettings;
  2203. }
  2204. },
  2205. dnsServers: {
  2206. get: function () { return this.enableDNS ? this.templateSettings.dns.servers : []; },
  2207. set: function (newValue) {
  2208. newTemplateSettings = this.templateSettings;
  2209. newTemplateSettings.dns.servers = newValue;
  2210. this.templateSettings = newTemplateSettings;
  2211. }
  2212. },
  2213. fakeDns: {
  2214. get: function () { return this.templateSettings && this.templateSettings.fakedns ? this.templateSettings.fakedns : []; },
  2215. set: function (newValue) {
  2216. newTemplateSettings = this.templateSettings;
  2217. if (this.enableDNS) {
  2218. newTemplateSettings.fakedns = newValue.length > 0 ? newValue : null;
  2219. } else {
  2220. delete newTemplateSettings.fakedns;
  2221. }
  2222. this.templateSettings = newTemplateSettings;
  2223. }
  2224. }
  2225. },
  2226. });
  2227. </script>
  2228. </body>
  2229. </html>