xray.html 118 KB

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