xray.html 116 KB

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