xray.html 115 KB

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