xray.html 117 KB

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