1
0

xray.html 116 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232
  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.obsSettings == ''){
  1050. return
  1051. }
  1052. if(this.cm != null) {
  1053. this.cm.toTextArea();
  1054. }
  1055. textAreaObj = document.getElementById('obsSetting');
  1056. textAreaObj.value = this[this.obsSettings];
  1057. this.cm = CodeMirror.fromTextArea(textAreaObj, this.cmOptions);
  1058. this.cm.on('change',editor => {
  1059. value = editor.getValue();
  1060. if(this.isJsonString(value)){
  1061. this[this.obsSettings] = value;
  1062. }
  1063. });
  1064. },
  1065. isJsonString(str) {
  1066. try {
  1067. JSON.parse(str);
  1068. } catch (e) {
  1069. return false;
  1070. }
  1071. return true;
  1072. },
  1073. findOutboundTraffic(o) {
  1074. for (const otraffic of this.outboundsTraffic) {
  1075. if (otraffic.tag == o.tag) {
  1076. return sizeFormat(otraffic.up) + ' / ' + sizeFormat(otraffic.down);
  1077. }
  1078. }
  1079. return sizeFormat(0) + ' / ' + sizeFormat(0);
  1080. },
  1081. findOutboundAddress(o) {
  1082. serverObj = null;
  1083. switch(o.protocol){
  1084. case Protocols.VMess:
  1085. case Protocols.VLESS:
  1086. serverObj = o.settings.vnext;
  1087. break;
  1088. case Protocols.HTTP:
  1089. case Protocols.Socks:
  1090. case Protocols.Shadowsocks:
  1091. case Protocols.Trojan:
  1092. serverObj = o.settings.servers;
  1093. break;
  1094. case Protocols.DNS:
  1095. return [o.settings?.address + ':' + o.settings?.port];
  1096. case Protocols.Wireguard:
  1097. return o.settings.peers.map(peer => peer.endpoint);
  1098. default:
  1099. return null;
  1100. }
  1101. return serverObj ? serverObj.map(obj => obj.address + ':' + obj.port) : null;
  1102. },
  1103. addOutbound(){
  1104. outModal.show({
  1105. title: '{{ i18n "pages.xray.outbound.addOutbound"}}',
  1106. okText: '{{ i18n "pages.xray.outbound.addOutbound" }}',
  1107. confirm: (outbound) => {
  1108. outModal.loading();
  1109. if(outbound.tag.length > 0){
  1110. this.templateSettings.outbounds.push(outbound);
  1111. this.outboundSettings = JSON.stringify(this.templateSettings.outbounds);
  1112. }
  1113. outModal.close();
  1114. },
  1115. isEdit: false,
  1116. tags: this.templateSettings.outbounds.map(obj => obj.tag)
  1117. });
  1118. },
  1119. editOutbound(index){
  1120. outModal.show({
  1121. title: '{{ i18n "pages.xray.outbound.editOutbound"}} ' + (index+1),
  1122. outbound: app.templateSettings.outbounds[index],
  1123. confirm: (outbound) => {
  1124. outModal.loading();
  1125. this.templateSettings.outbounds[index] = outbound;
  1126. this.outboundSettings = JSON.stringify(this.templateSettings.outbounds);
  1127. outModal.close();
  1128. },
  1129. isEdit: true,
  1130. tags: this.outboundData.filter((o) => o.key != index ).map(obj => obj.tag)
  1131. });
  1132. },
  1133. deleteOutbound(index){
  1134. outbounds = this.templateSettings.outbounds;
  1135. outbounds.splice(index,1);
  1136. this.outboundSettings = JSON.stringify(outbounds);
  1137. },
  1138. setFirstOutbound(index){
  1139. outbounds = this.templateSettings.outbounds;
  1140. outbounds.splice(0, 0, outbounds.splice(index, 1)[0]);
  1141. this.outboundSettings = JSON.stringify(outbounds);
  1142. },
  1143. addReverse(){
  1144. reverseModal.show({
  1145. title: '{{ i18n "pages.xray.outbound.addReverse"}}',
  1146. okText: '{{ i18n "pages.xray.outbound.addReverse" }}',
  1147. confirm: (reverse, rules) => {
  1148. reverseModal.loading();
  1149. if(reverse.tag.length > 0){
  1150. newTemplateSettings = this.templateSettings;
  1151. if(newTemplateSettings.reverse == undefined) newTemplateSettings.reverse = {};
  1152. if(newTemplateSettings.reverse[reverse.type+'s'] == undefined) newTemplateSettings.reverse[reverse.type+'s'] = [];
  1153. newTemplateSettings.reverse[reverse.type+'s'].push({ tag: reverse.tag, domain: reverse.domain });
  1154. this.templateSettings = newTemplateSettings;
  1155. // Add related rules
  1156. this.templateSettings.routing.rules.push(...rules);
  1157. this.routingRuleSettings = JSON.stringify(this.templateSettings.routing.rules);
  1158. }
  1159. reverseModal.close();
  1160. },
  1161. isEdit: false
  1162. });
  1163. },
  1164. editReverse(index){
  1165. if(this.reverseData[index].type == "bridge") {
  1166. oldRules = this.templateSettings.routing.rules.filter(r => r.inboundTag && r.inboundTag[0] == this.reverseData[index].tag);
  1167. } else {
  1168. oldRules = this.templateSettings.routing.rules.filter(r => r.outboundTag && r.outboundTag == this.reverseData[index].tag);
  1169. }
  1170. reverseModal.show({
  1171. title: '{{ i18n "pages.xray.outbound.editReverse"}} ' + (index+1),
  1172. reverse: this.reverseData[index],
  1173. rules: oldRules,
  1174. confirm: (reverse, rules) => {
  1175. reverseModal.loading();
  1176. if(reverse.tag.length > 0){
  1177. oldData = this.reverseData[index];
  1178. newTemplateSettings = this.templateSettings;
  1179. oldReverseIndex = newTemplateSettings.reverse[oldData.type+'s'].findIndex(rs => rs.tag == oldData.tag);
  1180. oldRuleIndex0 = oldRules.length>0 ? newTemplateSettings.routing.rules.findIndex(r => JSON.stringify(r) == JSON.stringify(oldRules[0])) : -1;
  1181. oldRuleIndex1 = oldRules.length==2 ? newTemplateSettings.routing.rules.findIndex(r => JSON.stringify(r) == JSON.stringify(oldRules[1])) : -1;
  1182. if(oldData.type == reverse.type){
  1183. newTemplateSettings.reverse[oldData.type + 's'][oldReverseIndex] = { tag: reverse.tag, domain: reverse.domain };
  1184. } else {
  1185. newTemplateSettings.reverse[oldData.type+'s'].splice(oldReverseIndex,1);
  1186. // delete empty object
  1187. if(newTemplateSettings.reverse[oldData.type+'s'].length == 0) Reflect.deleteProperty(newTemplateSettings.reverse, oldData.type+'s');
  1188. // add other type of reverse if it is not exist
  1189. if(!newTemplateSettings.reverse[reverse.type+'s']) newTemplateSettings.reverse[reverse.type+'s'] = [];
  1190. newTemplateSettings.reverse[reverse.type+'s'].push({ tag: reverse.tag, domain: reverse.domain });
  1191. }
  1192. this.templateSettings = newTemplateSettings;
  1193. // Adjust Rules
  1194. newRules = this.templateSettings.routing.rules;
  1195. oldRuleIndex0 != -1 ? newRules[oldRuleIndex0] = rules[0] : newRules.push(rules[0]);
  1196. oldRuleIndex1 != -1 ? newRules[oldRuleIndex1] = rules[1] : newRules.push(rules[1]);
  1197. this.routingRuleSettings = JSON.stringify(newRules);
  1198. }
  1199. reverseModal.close();
  1200. },
  1201. isEdit: true
  1202. });
  1203. },
  1204. deleteReverse(index){
  1205. oldData = this.reverseData[index];
  1206. newTemplateSettings = this.templateSettings;
  1207. reverseTypeObj = newTemplateSettings.reverse[oldData.type+'s'];
  1208. realIndex = reverseTypeObj.findIndex(r => r.tag==oldData.tag && r.domain==oldData.domain);
  1209. newTemplateSettings.reverse[oldData.type+'s'].splice(realIndex,1);
  1210. // delete empty objects
  1211. if(reverseTypeObj.length == 0) Reflect.deleteProperty(newTemplateSettings.reverse, oldData.type+'s');
  1212. if(Object.keys(newTemplateSettings.reverse).length === 0) Reflect.deleteProperty(newTemplateSettings, 'reverse');
  1213. // delete related routing rules
  1214. newRules = newTemplateSettings.routing.rules;
  1215. if(oldData.type == "bridge"){
  1216. newRules = newTemplateSettings.routing.rules.filter(r => !( r.inboundTag && r.inboundTag.length == 1 && r.inboundTag[0] == oldData.tag));
  1217. } else if(oldData.type == "portal"){
  1218. newRules = newTemplateSettings.routing.rules.filter(r => r.outboundTag != oldData.tag);
  1219. }
  1220. newTemplateSettings.routing.rules = newRules;
  1221. this.templateSettings = newTemplateSettings;
  1222. },
  1223. async refreshOutboundTraffic() {
  1224. if (!this.refreshing) {
  1225. this.refreshing = true;
  1226. await this.getOutboundsTraffic();
  1227. data = []
  1228. if (this.templateSettings != null) {
  1229. this.templateSettings.outbounds.forEach((o, index) => {
  1230. data.push({'key': index, ...o});
  1231. });
  1232. }
  1233. this.outboundData = data;
  1234. this.refreshing = false;
  1235. }
  1236. },
  1237. async resetOutboundTraffic(index) {
  1238. let tag = "-alltags-";
  1239. if (index >= 0) {
  1240. tag = this.outboundData[index].tag ? this.outboundData[index].tag : ""
  1241. }
  1242. const msg = await HttpUtil.post("/panel/xray/resetOutboundsTraffic", { tag: tag });
  1243. if (msg.success) {
  1244. await this.refreshOutboundTraffic();
  1245. }
  1246. },
  1247. addBalancer() {
  1248. balancerModal.show({
  1249. title: '{{ i18n "pages.xray.balancer.addBalancer"}}',
  1250. okText: '{{ i18n "pages.xray.balancer.addBalancer"}}',
  1251. balancerTags: this.balancersData.filter((o) => !ObjectUtil.isEmpty(o.tag)).map(obj => obj.tag),
  1252. balancer: {
  1253. tag: '',
  1254. strategy: 'random',
  1255. selector: []
  1256. },
  1257. confirm: (balancer) => {
  1258. balancerModal.loading();
  1259. newTemplateSettings = this.templateSettings;
  1260. if (newTemplateSettings.routing.balancers == undefined) {
  1261. newTemplateSettings.routing.balancers = [];
  1262. }
  1263. let tmpBalancer = {
  1264. 'tag': balancer.tag,
  1265. 'selector': balancer.selector
  1266. };
  1267. if (balancer.strategy && balancer.strategy != 'random') {
  1268. tmpBalancer.strategy = {
  1269. 'type': balancer.strategy
  1270. };
  1271. if (balancer.strategy == 'leastPing'){
  1272. if (!newTemplateSettings.observatory)
  1273. newTemplateSettings.observatory = this.defaultObservatory;
  1274. if (!newTemplateSettings.observatory.subjectSelector.includes(balancer.tag))
  1275. newTemplateSettings.observatory.subjectSelector.push(balancer.tag);
  1276. }
  1277. if (balancer.strategy == 'leastLoad'){
  1278. if (!newTemplateSettings.burstObservatory)
  1279. newTemplateSettings.burstObservatory = this.defaultBurstObservatory;
  1280. if (!newTemplateSettings.burstObservatory.subjectSelector.includes(balancer.tag))
  1281. newTemplateSettings.burstObservatory.subjectSelector.push(balancer.tag);
  1282. }
  1283. }
  1284. newTemplateSettings.routing.balancers.push(tmpBalancer);
  1285. this.templateSettings = newTemplateSettings;
  1286. balancerModal.close();
  1287. this.changeObsCode();
  1288. },
  1289. isEdit: false
  1290. });
  1291. },
  1292. editBalancer(index) {
  1293. const oldTag = this.balancersData[index].tag;
  1294. balancerModal.show({
  1295. title: '{{ i18n "pages.xray.balancer.editBalancer"}}',
  1296. okText: '{{ i18n "sure" }}',
  1297. balancerTags: this.balancersData.filter((o) => !ObjectUtil.isEmpty(o.tag)).map(obj => obj.tag),
  1298. balancer: this.balancersData[index],
  1299. confirm: (balancer) => {
  1300. balancerModal.loading();
  1301. newTemplateSettings = this.templateSettings;
  1302. let tmpBalancer = {
  1303. 'tag': balancer.tag,
  1304. 'selector': balancer.selector
  1305. };
  1306. // Remove old tag
  1307. if (newTemplateSettings.observatory){
  1308. newTemplateSettings.observatory.subjectSelector = newTemplateSettings.observatory.subjectSelector.filter(s => s != oldTag);
  1309. }
  1310. if (newTemplateSettings.burstObservatory){
  1311. newTemplateSettings.burstObservatory.subjectSelector = newTemplateSettings.burstObservatory.subjectSelector.filter(s => s != oldTag);
  1312. }
  1313. if (balancer.strategy && balancer.strategy != 'random') {
  1314. tmpBalancer.strategy = {
  1315. 'type': balancer.strategy
  1316. };
  1317. if (balancer.strategy == 'leastPing'){
  1318. if (!newTemplateSettings.observatory)
  1319. newTemplateSettings.observatory = this.defaultObservatory;
  1320. if (!newTemplateSettings.observatory.subjectSelector.includes(balancer.tag))
  1321. newTemplateSettings.observatory.subjectSelector.push(balancer.tag);
  1322. }
  1323. if (balancer.strategy == 'leastLoad'){
  1324. if (!newTemplateSettings.burstObservatory)
  1325. newTemplateSettings.burstObservatory = this.defaultBurstObservatory;
  1326. if (!newTemplateSettings.burstObservatory.subjectSelector.includes(balancer.tag))
  1327. newTemplateSettings.burstObservatory.subjectSelector.push(balancer.tag);
  1328. }
  1329. }
  1330. newTemplateSettings.routing.balancers[index] = tmpBalancer;
  1331. // change edited tag if used in rule section
  1332. if (oldTag != balancer.tag) {
  1333. newTemplateSettings.routing.rules.forEach((rule) => {
  1334. if (rule.balancerTag && rule.balancerTag == oldTag) {
  1335. rule.balancerTag = balancer.tag;
  1336. }
  1337. });
  1338. }
  1339. this.templateSettings = newTemplateSettings;
  1340. balancerModal.close();
  1341. this.changeObsCode();
  1342. },
  1343. isEdit: true
  1344. });
  1345. },
  1346. deleteBalancer(index) {
  1347. let newTemplateSettings = { ...this.templateSettings };
  1348. // Remove from balancers
  1349. const removedBalancer = this.balancersData.splice(index, 1)[0];
  1350. // Remove from settings
  1351. let realIndex = newTemplateSettings.routing.balancers.findIndex((b) => b.tag === removedBalancer.tag);
  1352. newTemplateSettings.routing.balancers.splice(realIndex, 1);
  1353. // Remove tag from observatory
  1354. if (newTemplateSettings.observatory){
  1355. newTemplateSettings.observatory.subjectSelector = newTemplateSettings.observatory.subjectSelector.filter(s => s != removedBalancer.tag);
  1356. }
  1357. if (newTemplateSettings.burstObservatory){
  1358. newTemplateSettings.burstObservatory.subjectSelector = newTemplateSettings.burstObservatory.subjectSelector.filter(s => s != removedBalancer.tag);
  1359. }
  1360. // Remove related routing rules
  1361. newTemplateSettings.routing.rules.forEach((rule) => {
  1362. if (rule.balancerTag === removedBalancer.tag) {
  1363. delete rule.balancerTag;
  1364. }
  1365. });
  1366. // Update balancers property to an empty array if there are no more balancers
  1367. if (newTemplateSettings.routing.balancers.length === 0) {
  1368. delete newTemplateSettings.routing.balancers;
  1369. }
  1370. this.templateSettings = newTemplateSettings;
  1371. this.changeObsCode()
  1372. },
  1373. addDNSServer(){
  1374. dnsModal.show({
  1375. title: '{{ i18n "pages.xray.dns.add" }}',
  1376. confirm: (dnsServer) => {
  1377. dnsServers = this.dnsServers;
  1378. dnsServers.push(dnsServer);
  1379. this.dnsServers = dnsServers;
  1380. dnsModal.close();
  1381. },
  1382. isEdit: false
  1383. });
  1384. },
  1385. editDNSServer(index){
  1386. dnsModal.show({
  1387. title: '{{ i18n "pages.xray.dns.edit" }} #' + (index+1),
  1388. dnsServer: this.dnsServers[index],
  1389. confirm: (dnsServer) => {
  1390. dnsServers = this.dnsServers;
  1391. dnsServers[index] = dnsServer;
  1392. this.dnsServers = dnsServers;
  1393. dnsModal.close();
  1394. },
  1395. isEdit: true
  1396. });
  1397. },
  1398. deleteDNSServer(index){
  1399. newDnsServers = this.dnsServers;
  1400. newDnsServers.splice(index,1);
  1401. this.dnsServers = newDnsServers;
  1402. },
  1403. addFakedns() {
  1404. fakednsModal.show({
  1405. title: '{{ i18n "pages.xray.fakedns.add" }}',
  1406. confirm: (item) => {
  1407. fakeDns = this.fakeDns?? [];
  1408. fakeDns.push(item);
  1409. this.fakeDns = fakeDns;
  1410. fakednsModal.close();
  1411. },
  1412. isEdit: false
  1413. });
  1414. },
  1415. editFakedns(index){
  1416. fakednsModal.show({
  1417. title: '{{ i18n "pages.xray.fakedns.edit" }} #' + (index+1),
  1418. fakeDns: this.fakeDns[index],
  1419. confirm: (item) => {
  1420. fakeDns = this.fakeDns;
  1421. fakeDns[index] = item;
  1422. this.fakeDns = fakeDns;
  1423. fakednsModal.close();
  1424. },
  1425. isEdit: true
  1426. });
  1427. },
  1428. deleteFakedns(index){
  1429. fakeDns = this.fakeDns;
  1430. fakeDns.splice(index,1);
  1431. this.fakeDns = fakeDns;
  1432. },
  1433. addRule(){
  1434. ruleModal.show({
  1435. title: '{{ i18n "pages.xray.rules.add"}}',
  1436. okText: '{{ i18n "pages.xray.rules.add" }}',
  1437. confirm: (rule) => {
  1438. ruleModal.loading();
  1439. if(JSON.stringify(rule).length > 3){
  1440. this.templateSettings.routing.rules.push(rule);
  1441. this.routingRuleSettings = JSON.stringify(this.templateSettings.routing.rules);
  1442. }
  1443. ruleModal.close();
  1444. },
  1445. isEdit: false
  1446. });
  1447. },
  1448. editRule(index){
  1449. ruleModal.show({
  1450. title: '{{ i18n "pages.xray.rules.edit"}} ' + (index+1),
  1451. rule: app.templateSettings.routing.rules[index],
  1452. confirm: (rule) => {
  1453. ruleModal.loading();
  1454. if(JSON.stringify(rule).length > 3){
  1455. this.templateSettings.routing.rules[index] = rule;
  1456. this.routingRuleSettings = JSON.stringify(this.templateSettings.routing.rules);
  1457. }
  1458. ruleModal.close();
  1459. },
  1460. isEdit: true
  1461. });
  1462. },
  1463. replaceRule(old_index,new_index){
  1464. rules = this.templateSettings.routing.rules;
  1465. if (new_index >= rules.length) rules.push(undefined);
  1466. rules.splice(new_index, 0, rules.splice(old_index, 1)[0]);
  1467. this.routingRuleSettings = JSON.stringify(rules);
  1468. },
  1469. deleteRule(index){
  1470. rules = this.templateSettings.routing.rules;
  1471. rules.splice(index,1);
  1472. this.routingRuleSettings = JSON.stringify(rules);
  1473. },
  1474. showWarp(){
  1475. warpModal.show();
  1476. }
  1477. },
  1478. async mounted() {
  1479. if (window.location.protocol !== "https:") {
  1480. this.showAlert = true;
  1481. }
  1482. await this.getXraySetting();
  1483. await this.getXrayResult();
  1484. await this.getOutboundsTraffic();
  1485. while (true) {
  1486. await PromiseUtil.sleep(800);
  1487. this.saveBtnDisable = this.oldXraySetting === this.xraySetting;
  1488. }
  1489. },
  1490. computed: {
  1491. templateSettings: {
  1492. get: function () {
  1493. const parsedSettings = this.xraySetting ? JSON.parse(this.xraySetting) : null;
  1494. let accessLogPath = "./access.log";
  1495. let errorLogPath = "./error.log";
  1496. if (parsedSettings && parsedSettings.log) {
  1497. if (parsedSettings.log.access && parsedSettings.log.access !== "none") {
  1498. accessLogPath = parsedSettings.log.access;
  1499. }
  1500. if (parsedSettings.log.error && parsedSettings.log.error !== "none") {
  1501. errorLogPath = parsedSettings.log.error;
  1502. }
  1503. }
  1504. this.access = ["none", accessLogPath];
  1505. this.error = ["none", errorLogPath];
  1506. return parsedSettings;
  1507. },
  1508. set: function (newValue) {
  1509. if (newValue && newValue.log) {
  1510. this.xraySetting = JSON.stringify(newValue, null, 2);
  1511. this.access = ["none", newValue.log.access || "./access.log"];
  1512. this.error = ["none", newValue.log.error || "./error.log"];
  1513. }
  1514. },
  1515. },
  1516. inboundSettings: {
  1517. get: function () { return this.templateSettings ? JSON.stringify(this.templateSettings.inbounds, null, 2) : null; },
  1518. set: function (newValue) {
  1519. newTemplateSettings = this.templateSettings;
  1520. newTemplateSettings.inbounds = JSON.parse(newValue);
  1521. this.templateSettings = newTemplateSettings;
  1522. },
  1523. },
  1524. outboundSettings: {
  1525. get: function () { return this.templateSettings ? JSON.stringify(this.templateSettings.outbounds, null, 2) : null; },
  1526. set: function (newValue) {
  1527. newTemplateSettings = this.templateSettings;
  1528. newTemplateSettings.outbounds = JSON.parse(newValue);
  1529. this.templateSettings = newTemplateSettings;
  1530. },
  1531. },
  1532. outboundData: {
  1533. get: function () {
  1534. data = []
  1535. if (this.templateSettings != null) {
  1536. this.templateSettings.outbounds.forEach((o, index) => {
  1537. data.push({'key': index, ...o});
  1538. });
  1539. }
  1540. return data;
  1541. },
  1542. },
  1543. reverseData: {
  1544. get: function () {
  1545. data = []
  1546. if (this.templateSettings != null && this.templateSettings.reverse != null) {
  1547. if(this.templateSettings.reverse.bridges) {
  1548. this.templateSettings.reverse.bridges.forEach((o, index) => {
  1549. data.push({'key': index, 'type':'bridge', ...o});
  1550. });
  1551. }
  1552. if(this.templateSettings.reverse.portals){
  1553. this.templateSettings.reverse.portals.forEach((o, index) => {
  1554. data.push({'key': index, 'type':'portal', ...o});
  1555. });
  1556. }
  1557. }
  1558. return data;
  1559. },
  1560. },
  1561. routingRuleSettings: {
  1562. get: function () { return this.templateSettings ? JSON.stringify(this.templateSettings.routing.rules, null, 2) : null; },
  1563. set: function (newValue) {
  1564. newTemplateSettings = this.templateSettings;
  1565. newTemplateSettings.routing.rules = JSON.parse(newValue);
  1566. this.templateSettings = newTemplateSettings;
  1567. },
  1568. },
  1569. routingRuleData: {
  1570. get: function () {
  1571. data = [];
  1572. if (this.templateSettings != null) {
  1573. this.templateSettings.routing.rules.forEach((r, index) => {
  1574. data.push({'key': index, ...r});
  1575. });
  1576. // Make rules readable
  1577. data.forEach(r => {
  1578. if(r.domain) r.domain = r.domain.join(',')
  1579. if(r.ip) r.ip = r.ip.join(',')
  1580. if(r.source) r.source = r.source.join(',');
  1581. if(r.user) r.user = r.user.join(',')
  1582. if(r.inboundTag) r.inboundTag = r.inboundTag.join(',')
  1583. if(r.protocol) r.protocol = r.protocol.join(',')
  1584. if(r.attrs) r.attrs = JSON.stringify(r.attrs, null, 2)
  1585. });
  1586. }
  1587. return data;
  1588. }
  1589. },
  1590. balancersData: {
  1591. get: function () {
  1592. data = []
  1593. if (this.templateSettings != null && this.templateSettings.routing != null && this.templateSettings.routing.balancers != null) {
  1594. this.templateSettings.routing.balancers.forEach((o, index) => {
  1595. data.push({
  1596. 'key': index,
  1597. 'tag': o.tag ? o.tag : "",
  1598. 'strategy': o.strategy?.type ?? "random",
  1599. 'selector': o.selector ? o.selector : []
  1600. });
  1601. });
  1602. }
  1603. return data;
  1604. }
  1605. },
  1606. observatory: {
  1607. get: function () {
  1608. return this.templateSettings?.observatory ? JSON.stringify(this.templateSettings.observatory, null, 2) : null;
  1609. },
  1610. set: function (newValue) {
  1611. newTemplateSettings = this.templateSettings;
  1612. newTemplateSettings.observatory = JSON.parse(newValue);
  1613. this.templateSettings = newTemplateSettings;
  1614. },
  1615. },
  1616. burstObservatory: {
  1617. get: function () {
  1618. return this.templateSettings?.burstObservatory ? JSON.stringify(this.templateSettings.burstObservatory, null, 2) : null;
  1619. },
  1620. set: function (newValue) {
  1621. newTemplateSettings = this.templateSettings;
  1622. newTemplateSettings.burstObservatory = JSON.parse(newValue);
  1623. this.templateSettings = newTemplateSettings;
  1624. },
  1625. },
  1626. observatoryEnable: {
  1627. get: function () { return this.templateSettings != null && this.templateSettings.observatory },
  1628. set: function (v) {
  1629. newTemplateSettings = this.templateSettings;
  1630. newTemplateSettings.observatory = v ? this.defaultObservatory : undefined;
  1631. this.templateSettings = newTemplateSettings;
  1632. }
  1633. },
  1634. burstObservatoryEnable: {
  1635. get: function () { return this.templateSettings != null && this.templateSettings.burstObservatory },
  1636. set: function (v) {
  1637. newTemplateSettings = this.templateSettings;
  1638. newTemplateSettings.burstObservatory = v ? this.defaultBurstObservatory : undefined;
  1639. this.templateSettings = newTemplateSettings;
  1640. }
  1641. },
  1642. freedomStrategy: {
  1643. get: function () {
  1644. if (!this.templateSettings) return "AsIs";
  1645. freedomOutbound = this.templateSettings.outbounds.find((o) => o.protocol === "freedom" && o.tag == "direct");
  1646. if (!freedomOutbound) return "AsIs";
  1647. if (!freedomOutbound.settings || !freedomOutbound.settings.domainStrategy) return "AsIs";
  1648. return freedomOutbound.settings.domainStrategy;
  1649. },
  1650. set: function (newValue) {
  1651. newTemplateSettings = this.templateSettings;
  1652. freedomOutboundIndex = newTemplateSettings.outbounds.findIndex((o) => o.protocol === "freedom" && o.tag == "direct");
  1653. if(freedomOutboundIndex == -1){
  1654. newTemplateSettings.outbounds.push({protocol: "freedom", tag: "direct", settings: { "domainStrategy": newValue }});
  1655. } else if (!newTemplateSettings.outbounds[freedomOutboundIndex].settings) {
  1656. newTemplateSettings.outbounds[freedomOutboundIndex].settings = {"domainStrategy": newValue};
  1657. } else {
  1658. newTemplateSettings.outbounds[freedomOutboundIndex].settings.domainStrategy = newValue;
  1659. }
  1660. this.templateSettings = newTemplateSettings;
  1661. }
  1662. },
  1663. routingStrategy: {
  1664. get: function () {
  1665. if (!this.templateSettings || !this.templateSettings.routing || !this.templateSettings.routing.domainStrategy) return "AsIs";
  1666. return this.templateSettings.routing.domainStrategy;
  1667. },
  1668. set: function (newValue) {
  1669. newTemplateSettings = this.templateSettings;
  1670. newTemplateSettings.routing.domainStrategy = newValue;
  1671. this.templateSettings = newTemplateSettings;
  1672. }
  1673. },
  1674. setLogLevel: {
  1675. get: function () {
  1676. if (!this.templateSettings || !this.templateSettings.log || !this.templateSettings.log.loglevel) return "warning";
  1677. return this.templateSettings.log.loglevel;
  1678. },
  1679. set: function (newValue) {
  1680. newTemplateSettings = this.templateSettings;
  1681. newTemplateSettings.log.loglevel = newValue;
  1682. this.templateSettings = newTemplateSettings;
  1683. }
  1684. },
  1685. accessLog: {
  1686. get: function () {
  1687. if (!this.templateSettings || !this.templateSettings.log || !this.templateSettings.log.access) return "";
  1688. return this.templateSettings.log.access;
  1689. },
  1690. set: function (newValue) {
  1691. newTemplateSettings = this.templateSettings;
  1692. newTemplateSettings.log.access = newValue;
  1693. this.templateSettings = newTemplateSettings;
  1694. }
  1695. },
  1696. errorLog: {
  1697. get: function () {
  1698. if (!this.templateSettings || !this.templateSettings.log || !this.templateSettings.log.error) return "";
  1699. return this.templateSettings.log.error;
  1700. },
  1701. set: function (newValue) {
  1702. newTemplateSettings = this.templateSettings;
  1703. newTemplateSettings.log.error = newValue;
  1704. this.templateSettings = newTemplateSettings;
  1705. }
  1706. },
  1707. blockedIPs: {
  1708. get: function () {
  1709. return this.templateRuleGetter({ outboundTag: "blocked", property: "ip" });
  1710. },
  1711. set: function (newValue) {
  1712. this.templateRuleSetter({ outboundTag: "blocked", property: "ip", data: newValue });
  1713. }
  1714. },
  1715. blockedDomains: {
  1716. get: function () {
  1717. return this.templateRuleGetter({ outboundTag: "blocked", property: "domain" });
  1718. },
  1719. set: function (newValue) {
  1720. this.templateRuleSetter({ outboundTag: "blocked", property: "domain", data: newValue });
  1721. }
  1722. },
  1723. blockedProtocols: {
  1724. get: function () {
  1725. return this.templateRuleGetter({ outboundTag: "blocked", property: "protocol" });
  1726. },
  1727. set: function (newValue) {
  1728. this.templateRuleSetter({ outboundTag: "blocked", property: "protocol", data: newValue });
  1729. }
  1730. },
  1731. directIPs: {
  1732. get: function () {
  1733. return this.templateRuleGetter({ outboundTag: "direct", property: "ip" });
  1734. },
  1735. set: function (newValue) {
  1736. this.templateRuleSetter({ outboundTag: "direct", property: "ip", data: newValue });
  1737. this.syncRulesWithOutbound("direct", this.directSettings);
  1738. }
  1739. },
  1740. directDomains: {
  1741. get: function () {
  1742. return this.templateRuleGetter({ outboundTag: "direct", property: "domain" });
  1743. },
  1744. set: function (newValue) {
  1745. this.templateRuleSetter({ outboundTag: "direct", property: "domain", data: newValue });
  1746. this.syncRulesWithOutbound("direct", this.directSettings);
  1747. }
  1748. },
  1749. ipv4Domains: {
  1750. get: function () {
  1751. return this.templateRuleGetter({ outboundTag: "IPv4", property: "domain" });
  1752. },
  1753. set: function (newValue) {
  1754. this.templateRuleSetter({ outboundTag: "IPv4", property: "domain", data: newValue });
  1755. this.syncRulesWithOutbound("IPv4", this.ipv4Settings);
  1756. }
  1757. },
  1758. warpDomains: {
  1759. get: function () {
  1760. return this.templateRuleGetter({ outboundTag: "warp", property: "domain" });
  1761. },
  1762. set: function (newValue) {
  1763. this.templateRuleSetter({ outboundTag: "warp", property: "domain", data: newValue });
  1764. }
  1765. },
  1766. torrentSettings: {
  1767. get: function () {
  1768. return doAllItemsExist(this.settingsData.protocols.bittorrent, this.blockedProtocols);
  1769. },
  1770. set: function (newValue) {
  1771. if (newValue) {
  1772. this.blockedProtocols = [...this.blockedProtocols, ...this.settingsData.protocols.bittorrent];
  1773. } else {
  1774. this.blockedProtocols = this.blockedProtocols.filter(data => !this.settingsData.protocols.bittorrent.includes(data));
  1775. }
  1776. },
  1777. },
  1778. privateIpSettings: {
  1779. get: function () {
  1780. return doAllItemsExist(this.settingsData.ips.local, this.blockedIPs);
  1781. },
  1782. set: function (newValue) {
  1783. if (newValue) {
  1784. this.blockedIPs = [...this.blockedIPs, ...this.settingsData.ips.local];
  1785. } else {
  1786. this.blockedIPs = this.blockedIPs.filter(data => !this.settingsData.ips.local.includes(data));
  1787. }
  1788. },
  1789. },
  1790. AdsSettings: {
  1791. get: function () {
  1792. return doAllItemsExist(this.settingsData.domains.ads, this.blockedDomains);
  1793. },
  1794. set: function (newValue) {
  1795. if (newValue) {
  1796. this.blockedDomains = [...this.blockedDomains, ...this.settingsData.domains.ads];
  1797. } else {
  1798. this.blockedDomains = this.blockedDomains.filter(data => !this.settingsData.domains.ads.includes(data));
  1799. }
  1800. },
  1801. },
  1802. SecuritySettings: {
  1803. get: function () {
  1804. return doAllItemsExist(this.settingsData.domains.security, this.blockedDomains);
  1805. },
  1806. set: function (newValue) {
  1807. if (newValue) {
  1808. this.blockedDomains = [...this.blockedDomains, ...this.settingsData.domains.security];
  1809. } else {
  1810. this.blockedDomains = this.blockedDomains.filter(data => !this.settingsData.domains.security.includes(data));
  1811. }
  1812. },
  1813. },
  1814. SpeedTestSettings: {
  1815. get: function () {
  1816. return doAllItemsExist(this.settingsData.domains.speedtest, this.blockedDomains);
  1817. },
  1818. set: function (newValue) {
  1819. if (newValue) {
  1820. this.blockedDomains = [...this.blockedDomains, ...this.settingsData.domains.speedtest];
  1821. } else {
  1822. this.blockedDomains = this.blockedDomains.filter(data => !this.settingsData.domains.speedtest.includes(data));
  1823. }
  1824. },
  1825. },
  1826. familyProtectSettings: {
  1827. get: function () {
  1828. if (!this.templateSettings || !this.templateSettings.dns || !this.templateSettings.dns.servers) return false;
  1829. return doAllItemsExist(this.settingsData.familyProtectDNS.servers, this.templateSettings.dns.servers);
  1830. },
  1831. set: function (newValue) {
  1832. newTemplateSettings = this.templateSettings;
  1833. if (newValue) {
  1834. newTemplateSettings.dns = this.settingsData.familyProtectDNS;
  1835. } else {
  1836. newTemplateSettings.dns.servers = newTemplateSettings.dns?.servers?.filter(data => !this.settingsData.familyProtectDNS.servers.includes(data))
  1837. }
  1838. this.templateSettings = newTemplateSettings;
  1839. },
  1840. },
  1841. GoogleIPv4Settings: {
  1842. get: function () {
  1843. return doAllItemsExist(this.settingsData.domains.google, this.ipv4Domains);
  1844. },
  1845. set: function (newValue) {
  1846. if (newValue) {
  1847. this.ipv4Domains = [...this.ipv4Domains, ...this.settingsData.domains.google];
  1848. } else {
  1849. this.ipv4Domains = this.ipv4Domains.filter(data => !this.settingsData.domains.google.includes(data));
  1850. }
  1851. },
  1852. },
  1853. NetflixIPv4Settings: {
  1854. get: function () {
  1855. return doAllItemsExist(this.settingsData.domains.netflix, this.ipv4Domains);
  1856. },
  1857. set: function (newValue) {
  1858. if (newValue) {
  1859. this.ipv4Domains = [...this.ipv4Domains, ...this.settingsData.domains.netflix];
  1860. } else {
  1861. this.ipv4Domains = this.ipv4Domains.filter(data => !this.settingsData.domains.netflix.includes(data));
  1862. }
  1863. },
  1864. },
  1865. IRIpSettings: {
  1866. get: function () {
  1867. return doAllItemsExist(this.settingsData.ips.ir, this.blockedIPs);
  1868. },
  1869. set: function (newValue) {
  1870. if (newValue) {
  1871. this.blockedIPs = [...this.blockedIPs, ...this.settingsData.ips.ir];
  1872. } else {
  1873. this.blockedIPs = this.blockedIPs.filter(data => !this.settingsData.ips.ir.includes(data));
  1874. }
  1875. }
  1876. },
  1877. IRDomainSettings: {
  1878. get: function () {
  1879. return doAllItemsExist(this.settingsData.domains.ir, this.blockedDomains);
  1880. },
  1881. set: function (newValue) {
  1882. if (newValue) {
  1883. this.blockedDomains = [...this.blockedDomains, ...this.settingsData.domains.ir];
  1884. } else {
  1885. this.blockedDomains = this.blockedDomains.filter(data => !this.settingsData.domains.ir.includes(data));
  1886. }
  1887. }
  1888. },
  1889. ChinaIpSettings: {
  1890. get: function () {
  1891. return doAllItemsExist(this.settingsData.ips.cn, this.blockedIPs);
  1892. },
  1893. set: function (newValue) {
  1894. if (newValue) {
  1895. this.blockedIPs = [...this.blockedIPs, ...this.settingsData.ips.cn];
  1896. } else {
  1897. this.blockedIPs = this.blockedIPs.filter(data => !this.settingsData.ips.cn.includes(data));
  1898. }
  1899. }
  1900. },
  1901. ChinaDomainSettings: {
  1902. get: function () {
  1903. return doAllItemsExist(this.settingsData.domains.cn, this.blockedDomains);
  1904. },
  1905. set: function (newValue) {
  1906. if (newValue) {
  1907. this.blockedDomains = [...this.blockedDomains, ...this.settingsData.domains.cn];
  1908. } else {
  1909. this.blockedDomains = this.blockedDomains.filter(data => !this.settingsData.domains.cn.includes(data));
  1910. }
  1911. }
  1912. },
  1913. RussiaIpSettings: {
  1914. get: function () {
  1915. return doAllItemsExist(this.settingsData.ips.ru, this.blockedIPs);
  1916. },
  1917. set: function (newValue) {
  1918. if (newValue) {
  1919. this.blockedIPs = [...this.blockedIPs, ...this.settingsData.ips.ru];
  1920. } else {
  1921. this.blockedIPs = this.blockedIPs.filter(data => !this.settingsData.ips.ru.includes(data));
  1922. }
  1923. }
  1924. },
  1925. RussiaDomainSettings: {
  1926. get: function () {
  1927. return doAllItemsExist(this.settingsData.domains.ru, this.blockedDomains);
  1928. },
  1929. set: function (newValue) {
  1930. if (newValue) {
  1931. this.blockedDomains = [...this.blockedDomains, ...this.settingsData.domains.ru];
  1932. } else {
  1933. this.blockedDomains = this.blockedDomains.filter(data => !this.settingsData.domains.ru.includes(data));
  1934. }
  1935. }
  1936. },
  1937. VNIpSettings: {
  1938. get: function () {
  1939. return doAllItemsExist(this.settingsData.ips.vn, this.blockedIPs);
  1940. },
  1941. set: function (newValue) {
  1942. if (newValue) {
  1943. this.blockedIPs = [...this.blockedIPs, ...this.settingsData.ips.vn];
  1944. } else {
  1945. this.blockedIPs = this.blockedIPs.filter(data => !this.settingsData.ips.vn.includes(data));
  1946. }
  1947. }
  1948. },
  1949. VNDomainSettings: {
  1950. get: function () {
  1951. return doAllItemsExist(this.settingsData.domains.vn, this.blockedDomains);
  1952. },
  1953. set: function (newValue) {
  1954. if (newValue) {
  1955. this.blockedDomains = [...this.blockedDomains, ...this.settingsData.domains.vn];
  1956. } else {
  1957. this.blockedDomains = this.blockedDomains.filter(data => !this.settingsData.domains.vn.includes(data));
  1958. }
  1959. }
  1960. },
  1961. IRIpDirectSettings: {
  1962. get: function () {
  1963. return doAllItemsExist(this.settingsData.ips.ir, this.directIPs);
  1964. },
  1965. set: function (newValue) {
  1966. if (newValue) {
  1967. this.directIPs = [...this.directIPs, ...this.settingsData.ips.ir];
  1968. } else {
  1969. this.directIPs = this.directIPs.filter(data => !this.settingsData.ips.ir.includes(data));
  1970. }
  1971. }
  1972. },
  1973. IRDomainDirectSettings: {
  1974. get: function () {
  1975. return doAllItemsExist(this.settingsData.domains.ir, this.directDomains);
  1976. },
  1977. set: function (newValue) {
  1978. if (newValue) {
  1979. this.directDomains = [...this.directDomains, ...this.settingsData.domains.ir];
  1980. } else {
  1981. this.directDomains = this.directDomains.filter(data => !this.settingsData.domains.ir.includes(data));
  1982. }
  1983. }
  1984. },
  1985. ChinaIpDirectSettings: {
  1986. get: function () {
  1987. return doAllItemsExist(this.settingsData.ips.cn, this.directIPs);
  1988. },
  1989. set: function (newValue) {
  1990. if (newValue) {
  1991. this.directIPs = [...this.directIPs, ...this.settingsData.ips.cn];
  1992. } else {
  1993. this.directIPs = this.directIPs.filter(data => !this.settingsData.ips.cn.includes(data));
  1994. }
  1995. }
  1996. },
  1997. ChinaDomainDirectSettings: {
  1998. get: function () {
  1999. return doAllItemsExist(this.settingsData.domains.cn, this.directDomains);
  2000. },
  2001. set: function (newValue) {
  2002. if (newValue) {
  2003. this.directDomains = [...this.directDomains, ...this.settingsData.domains.cn];
  2004. } else {
  2005. this.directDomains = this.directDomains.filter(data => !this.settingsData.domains.cn.includes(data));
  2006. }
  2007. }
  2008. },
  2009. RussiaIpDirectSettings: {
  2010. get: function () {
  2011. return doAllItemsExist(this.settingsData.ips.ru, this.directIPs);
  2012. },
  2013. set: function (newValue) {
  2014. if (newValue) {
  2015. this.directIPs = [...this.directIPs, ...this.settingsData.ips.ru];
  2016. } else {
  2017. this.directIPs = this.directIPs.filter(data => !this.settingsData.ips.ru.includes(data));
  2018. }
  2019. }
  2020. },
  2021. RussiaDomainDirectSettings: {
  2022. get: function () {
  2023. return doAllItemsExist(this.settingsData.domains.ru, this.directDomains);
  2024. },
  2025. set: function (newValue) {
  2026. if (newValue) {
  2027. this.directDomains = [...this.directDomains, ...this.settingsData.domains.ru];
  2028. } else {
  2029. this.directDomains = this.directDomains.filter(data => !this.settingsData.domains.ru.includes(data));
  2030. }
  2031. }
  2032. },
  2033. VNIpDirectSettings: {
  2034. get: function () {
  2035. return doAllItemsExist(this.settingsData.ips.vn, this.directIPs);
  2036. },
  2037. set: function (newValue) {
  2038. if (newValue) {
  2039. this.directIPs = [...this.directIPs, ...this.settingsData.ips.vn];
  2040. } else {
  2041. this.directIPs = this.directIPs.filter(data => !this.settingsData.ips.vn.includes(data));
  2042. }
  2043. }
  2044. },
  2045. VNDomainDirectSettings: {
  2046. get: function () {
  2047. return doAllItemsExist(this.settingsData.domains.vn, this.directDomains);
  2048. },
  2049. set: function (newValue) {
  2050. if (newValue) {
  2051. this.directDomains = [...this.directDomains, ...this.settingsData.domains.vn];
  2052. } else {
  2053. this.directDomains = this.directDomains.filter(data => !this.settingsData.domains.vn.includes(data));
  2054. }
  2055. }
  2056. },
  2057. WarpExist: {
  2058. get: function() {
  2059. return this.templateSettings ? this.templateSettings.outbounds.findIndex((o) => o.tag == "warp")>=0 : false;
  2060. },
  2061. },
  2062. GoogleWARPSettings: {
  2063. get: function () {
  2064. return doAllItemsExist(this.settingsData.domains.google, this.warpDomains);
  2065. },
  2066. set: function (newValue) {
  2067. if (newValue) {
  2068. this.warpDomains = [...this.warpDomains, ...this.settingsData.domains.google];
  2069. } else {
  2070. this.warpDomains = this.warpDomains.filter(data => !this.settingsData.domains.google.includes(data));
  2071. }
  2072. },
  2073. },
  2074. OpenAIWARPSettings: {
  2075. get: function () {
  2076. return doAllItemsExist(this.settingsData.domains.openai, this.warpDomains);
  2077. },
  2078. set: function (newValue) {
  2079. if (newValue) {
  2080. this.warpDomains = [...this.warpDomains, ...this.settingsData.domains.openai];
  2081. } else {
  2082. this.warpDomains = this.warpDomains.filter(data => !this.settingsData.domains.openai.includes(data));
  2083. }
  2084. },
  2085. },
  2086. NetflixWARPSettings: {
  2087. get: function () {
  2088. return doAllItemsExist(this.settingsData.domains.netflix, this.warpDomains);
  2089. },
  2090. set: function (newValue) {
  2091. if (newValue) {
  2092. this.warpDomains = [...this.warpDomains, ...this.settingsData.domains.netflix];
  2093. } else {
  2094. this.warpDomains = this.warpDomains.filter(data => !this.settingsData.domains.netflix.includes(data));
  2095. }
  2096. },
  2097. },
  2098. MetaWARPSettings: {
  2099. get: function () {
  2100. return doAllItemsExist(this.settingsData.domains.meta, this.warpDomains);
  2101. },
  2102. set: function (newValue) {
  2103. if (newValue) {
  2104. this.warpDomains = [...this.warpDomains, ...this.settingsData.domains.meta];
  2105. } else {
  2106. this.warpDomains = this.warpDomains.filter(data => !this.settingsData.domains.meta.includes(data));
  2107. }
  2108. },
  2109. },
  2110. AppleWARPSettings: {
  2111. get: function () {
  2112. return doAllItemsExist(this.settingsData.domains.apple, this.warpDomains);
  2113. },
  2114. set: function (newValue) {
  2115. if (newValue) {
  2116. this.warpDomains = [...this.warpDomains, ...this.settingsData.domains.apple];
  2117. } else {
  2118. this.warpDomains = this.warpDomains.filter(data => !this.settingsData.domains.apple.includes(data));
  2119. }
  2120. },
  2121. },
  2122. RedditWARPSettings: {
  2123. get: function () {
  2124. return doAllItemsExist(this.settingsData.domains.reddit, this.warpDomains);
  2125. },
  2126. set: function (newValue) {
  2127. if (newValue) {
  2128. this.warpDomains = [...this.warpDomains, ...this.settingsData.domains.reddit];
  2129. } else {
  2130. this.warpDomains = this.warpDomains.filter(data => !this.settingsData.domains.reddit.includes(data));
  2131. }
  2132. },
  2133. },
  2134. SpotifyWARPSettings: {
  2135. get: function () {
  2136. return doAllItemsExist(this.settingsData.domains.spotify, this.warpDomains);
  2137. },
  2138. set: function (newValue) {
  2139. if (newValue) {
  2140. this.warpDomains = [...this.warpDomains, ...this.settingsData.domains.spotify];
  2141. } else {
  2142. this.warpDomains = this.warpDomains.filter(data => !this.settingsData.domains.spotify.includes(data));
  2143. }
  2144. },
  2145. },
  2146. enableDNS: {
  2147. get: function () {
  2148. return this.templateSettings ? this.templateSettings.dns != null : false;
  2149. },
  2150. set: function (newValue) {
  2151. newTemplateSettings = this.templateSettings;
  2152. if (newValue) {
  2153. newTemplateSettings.dns = { servers: [], queryStrategy: "UseIP", tag: "dns_inbound" };
  2154. newTemplateSettings.fakedns = null;
  2155. } else {
  2156. delete newTemplateSettings.dns;
  2157. delete newTemplateSettings.fakedns;
  2158. }
  2159. this.templateSettings = newTemplateSettings;
  2160. }
  2161. },
  2162. dnsTag: {
  2163. get: function () {
  2164. return this.enableDNS ? this.templateSettings.dns.tag : "";
  2165. },
  2166. set: function (newValue) {
  2167. newTemplateSettings = this.templateSettings;
  2168. newTemplateSettings.dns.tag = newValue;
  2169. this.templateSettings = newTemplateSettings;
  2170. }
  2171. },
  2172. dnsStrategy: {
  2173. get: function () {
  2174. return this.enableDNS ? this.templateSettings.dns.queryStrategy : null;
  2175. },
  2176. set: function (newValue) {
  2177. newTemplateSettings = this.templateSettings;
  2178. newTemplateSettings.dns.queryStrategy = newValue;
  2179. this.templateSettings = newTemplateSettings;
  2180. }
  2181. },
  2182. dnsServers: {
  2183. get: function () { return this.enableDNS ? this.templateSettings.dns.servers : []; },
  2184. set: function (newValue) {
  2185. newTemplateSettings = this.templateSettings;
  2186. newTemplateSettings.dns.servers = newValue;
  2187. this.templateSettings = newTemplateSettings;
  2188. }
  2189. },
  2190. fakeDns: {
  2191. get: function () { return this.templateSettings && this.templateSettings.fakedns ? this.templateSettings.fakedns : []; },
  2192. set: function (newValue) {
  2193. newTemplateSettings = this.templateSettings;
  2194. if (this.enableDNS) {
  2195. newTemplateSettings.fakedns = newValue.length > 0 ? newValue : null;
  2196. } else {
  2197. delete newTemplateSettings.fakedns;
  2198. }
  2199. this.templateSettings = newTemplateSettings;
  2200. }
  2201. }
  2202. },
  2203. });
  2204. </script>
  2205. </body>
  2206. </html>