xray.html 125 KB

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