xray.html 115 KB

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