1
0

xray.html 88 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. {{template "head" .}}
  4. <link rel="stylesheet" href="{{ .base_path }}assets/codemirror/codemirror.css">
  5. <link rel="stylesheet" href="{{ .base_path }}assets/codemirror/fold/foldgutter.css">
  6. <link rel="stylesheet" href="{{ .base_path }}assets/codemirror/xq.css?{{ .cur_ver }}">
  7. <link rel="stylesheet" href="{{ .base_path }}assets/codemirror/lint/lint.css">
  8. <script src="{{ .base_path }}assets/base64/base64.min.js"></script>
  9. <script src="{{ .base_path }}assets/js/model/outbound.js?{{ .cur_ver }}"></script>
  10. <script src="{{ .base_path }}assets/codemirror/codemirror.js"></script>
  11. <script src="{{ .base_path }}assets/codemirror/javascript.js"></script>
  12. <script src="{{ .base_path }}assets/codemirror/jshint.js"></script>
  13. <script src="{{ .base_path }}assets/codemirror/jsonlint.js"></script>
  14. <script src="{{ .base_path }}assets/codemirror/lint/lint.js"></script>
  15. <script src="{{ .base_path }}assets/codemirror/lint/javascript-lint.js"></script>
  16. <script src="{{ .base_path }}assets/codemirror/hint/javascript-hint.js"></script>
  17. <script src="{{ .base_path }}assets/codemirror/fold/foldcode.js"></script>
  18. <script src="{{ .base_path }}assets/codemirror/fold/foldgutter.js"></script>
  19. <script src="{{ .base_path }}assets/codemirror/fold/brace-fold.js"></script>
  20. <style>
  21. @media (min-width: 769px) {
  22. .ant-layout-content {
  23. margin: 24px 16px;
  24. }
  25. }
  26. @media (max-width: 768px) {
  27. .ant-tabs-nav .ant-tabs-tab {
  28. margin: 0;
  29. padding: 12px .5rem;
  30. }
  31. .ant-table-thead > tr > th,
  32. .ant-table-tbody > tr > td {
  33. padding: 10px 0px;
  34. }
  35. }
  36. .ant-tabs-bar {
  37. margin: 0;
  38. }
  39. .ant-list-item {
  40. display: block;
  41. }
  42. .collapse-title {
  43. color: inherit;
  44. font-weight: bold;
  45. font-size: 18px;
  46. padding: 10px 20px;
  47. border-bottom: 2px solid;
  48. }
  49. .collapse-title > i {
  50. color: inherit;
  51. font-size: 24px;
  52. }
  53. </style>
  54. <body>
  55. <a-layout id="app" v-cloak :class="themeSwitcher.currentTheme">
  56. {{ template "commonSider" . }}
  57. <a-layout id="content-layout">
  58. <a-layout-content>
  59. <a-spin :spinning="spinning" :delay="500" tip='{{ i18n "loading"}}'>
  60. <a-space direction="vertical">
  61. <a-card hoverable style="margin-bottom: .5rem;">
  62. <a-row>
  63. <a-col :xs="24" :sm="8" style="padding: 4px;">
  64. <a-space direction="horizontal">
  65. <a-button type="primary" :disabled="saveBtnDisable" @click="updateXraySetting">{{ i18n "pages.xray.save" }}</a-button>
  66. <a-button type="danger" :disabled="!saveBtnDisable" @click="restartXray">{{ i18n "pages.xray.restart" }}</a-button>
  67. <a-popover v-if="restartResult"
  68. :overlay-class-name="themeSwitcher.currentTheme">
  69. <span slot="title" style="font-size: 12pt">Error in running xray-core</span>
  70. <template slot="content">
  71. <p style="max-width: 400px" v-for="line in restartResult.split('\n')">[[ line ]]</p>
  72. </template>
  73. <a-icon type="question-circle"></a-icon>
  74. </a-popover>
  75. </a-space>
  76. </a-col>
  77. <a-col :xs="24" :sm="16">
  78. <template>
  79. <div>
  80. <a-back-top :target="() => document.getElementById('content-layout')" visibility-height="200">
  81. </a-back-top>
  82. <a-alert type="warning" style="float: right; width: fit-content"
  83. message='{{ i18n "pages.settings.infoDesc" }}'
  84. show-icon
  85. >
  86. </div>
  87. </template>
  88. </a-col>
  89. </a-row>
  90. </a-card>
  91. <a-tabs class="ant-card-dark-box-nohover" default-active-key="tpl-1"
  92. @change="(activeKey) => { if(activeKey == 'tpl-advanced') this.changeCode(); }"
  93. :class="themeSwitcher.currentTheme">
  94. <a-tab-pane key="tpl-1" tab='{{ i18n "pages.xray.basicTemplate"}}'>
  95. <a-space direction="horizontal" style="padding: 20px 20px">
  96. <a-button type="primary" @click="resetXrayConfigToDefault">{{ i18n "pages.settings.resetDefaultConfig" }}</a-button>
  97. </a-space>
  98. <a-collapse>
  99. <a-collapse-panel header='{{ i18n "pages.xray.generalConfigs"}}'>
  100. <a-row :xs="24" :sm="24" :lg="12">
  101. <a-alert type="warning" style="text-align: center;">
  102. <template slot="message">
  103. <a-icon type="exclamation-circle" theme="filled" style="color: #FFA031"></a-icon>
  104. {{ i18n "pages.xray.generalConfigsDesc" }}
  105. </template>
  106. </a-alert>
  107. </a-row>
  108. <a-list-item>
  109. <a-row style="padding: 20px">
  110. <a-col :lg="24" :xl="12">
  111. <a-list-item-meta
  112. title='{{ i18n "pages.xray.FreedomStrategy" }}'
  113. description='{{ i18n "pages.xray.FreedomStrategyDesc" }}'/>
  114. </a-col>
  115. <a-col :lg="24" :xl="12">
  116. <template>
  117. <a-select
  118. v-model="freedomStrategy"
  119. :dropdown-class-name="themeSwitcher.currentTheme"
  120. style="width: 100%">
  121. <a-select-option v-for="s in OutboundDomainStrategies" :value="s">[[ s ]]</a-select-option>
  122. </a-select>
  123. </template>
  124. </a-col>
  125. </a-row>
  126. </a-list-item>
  127. <a-row style="padding: 20px">
  128. <a-col :lg="24" :xl="12">
  129. <a-list-item-meta
  130. title='{{ i18n "pages.xray.RoutingStrategy" }}'
  131. description='{{ i18n "pages.xray.RoutingStrategyDesc" }}'/>
  132. </a-col>
  133. <a-col :lg="24" :xl="12">
  134. <template>
  135. <a-select
  136. v-model="routingStrategy"
  137. :dropdown-class-name="themeSwitcher.currentTheme"
  138. style="width: 100%">
  139. <a-select-option v-for="s in routingDomainStrategies" :value="s">[[ s ]]</a-select-option>
  140. </a-select>
  141. </template>
  142. </a-col>
  143. </a-row>
  144. <a-row style="padding: 20px">
  145. <a-col :lg="24" :xl="12">
  146. <a-list-item-meta
  147. title='{{ i18n "pages.xray.logLevel" }}'
  148. description='{{ i18n "pages.xray.logLevelDesc" }}'/>
  149. </a-col>
  150. <a-col :lg="24" :xl="12">
  151. <template>
  152. <a-select
  153. v-model="setLogLevel"
  154. :dropdown-class-name="themeSwitcher.currentTheme"
  155. style="width: 100%">
  156. <a-select-option v-for="s in logLevel" :value="s">[[ s ]]</a-select-option>
  157. </a-select>
  158. </template>
  159. </a-col>
  160. </a-row>
  161. <a-row style="padding: 20px">
  162. <a-col :lg="24" :xl="12">
  163. <a-list-item-meta
  164. title='{{ i18n "pages.xray.accessLog" }}'
  165. description='{{ i18n "pages.xray.accessLogDesc" }}'/>
  166. </a-col>
  167. <a-col :lg="24" :xl="12">
  168. <template>
  169. <a-select
  170. v-model="setAccessLog"
  171. :dropdown-class-name="themeSwitcher.currentTheme"
  172. style="width: 100%">
  173. <a-select-option v-for="s in access" :value="s">[[ s ]]</a-select-option>
  174. </a-select>
  175. </template>
  176. </a-col>
  177. </a-row>
  178. </a-list-item>
  179. </a-collapse-panel>
  180. <a-collapse-panel header='{{ i18n "pages.xray.blockConfigs"}}'>
  181. <a-row :xs="24" :sm="24" :lg="12">
  182. <a-alert type="warning" style="text-align: center;">
  183. <template slot="message">
  184. <a-icon type="exclamation-circle" theme="filled" style="color: #FFA031"></a-icon>
  185. {{ i18n "pages.xray.blockConfigsDesc" }}
  186. </template>
  187. </a-alert>
  188. </a-row>
  189. <setting-list-item type="switch" title='{{ i18n "pages.xray.Torrent"}}' desc='{{ i18n "pages.xray.TorrentDesc"}}' v-model="torrentSettings"></setting-list-item>
  190. <setting-list-item type="switch" title='{{ i18n "pages.xray.PrivateIp"}}' desc='{{ i18n "pages.xray.PrivateIpDesc"}}' v-model="privateIpSettings"></setting-list-item>
  191. <setting-list-item type="switch" title='{{ i18n "pages.xray.Ads"}}' desc='{{ i18n "pages.xray.AdsDesc"}}' v-model="AdsSettings"></setting-list-item>
  192. <setting-list-item type="switch" title='{{ i18n "pages.xray.Family"}}' desc='{{ i18n "pages.xray.FamilyDesc"}}' v-model="familyProtectSettings"></setting-list-item>
  193. <setting-list-item type="switch" title='{{ i18n "pages.xray.Security"}}' desc='{{ i18n "pages.xray.SecurityDesc"}}' v-model="SecuritySettings"></setting-list-item>
  194. <setting-list-item type="switch" title='{{ i18n "pages.xray.Speedtest"}}' desc='{{ i18n "pages.xray.SpeedtestDesc"}}' v-model="SpeedTestSettings"></setting-list-item>
  195. </a-collapse-panel>
  196. <a-collapse-panel header='{{ i18n "pages.xray.blockCountryConfigs"}}'>
  197. <a-row :xs="24" :sm="24" :lg="12">
  198. <a-alert type="warning" style="text-align: center;">
  199. <template slot="message">
  200. <a-icon type="exclamation-circle" theme="filled" style="color: #FFA031"></a-icon>
  201. {{ i18n "pages.xray.blockCountryConfigsDesc" }}
  202. </template>
  203. </a-alert>
  204. </a-row>
  205. <setting-list-item type="switch" title='{{ i18n "pages.xray.IRIp"}}' desc='{{ i18n "pages.xray.IRIpDesc"}}' v-model="IRIpSettings"></setting-list-item>
  206. <setting-list-item type="switch" title='{{ i18n "pages.xray.IRDomain"}}' desc='{{ i18n "pages.xray.IRDomainDesc"}}' v-model="IRDomainSettings"></setting-list-item>
  207. <setting-list-item type="switch" title='{{ i18n "pages.xray.ChinaIp"}}' desc='{{ i18n "pages.xray.ChinaIpDesc"}}' v-model="ChinaIpSettings"></setting-list-item>
  208. <setting-list-item type="switch" title='{{ i18n "pages.xray.ChinaDomain"}}' desc='{{ i18n "pages.xray.ChinaDomainDesc"}}' v-model="ChinaDomainSettings"></setting-list-item>
  209. <setting-list-item type="switch" title='{{ i18n "pages.xray.RussiaIp"}}' desc='{{ i18n "pages.xray.RussiaIpDesc"}}' v-model="RussiaIpSettings"></setting-list-item>
  210. <setting-list-item type="switch" title='{{ i18n "pages.xray.RussiaDomain"}}' desc='{{ i18n "pages.xray.RussiaDomainDesc"}}' v-model="RussiaDomainSettings"></setting-list-item>
  211. <setting-list-item type="switch" title='{{ i18n "pages.xray.VNIp"}}' desc='{{ i18n "pages.xray.VNIpDesc"}}' v-model="VNIpSettings"></setting-list-item>
  212. <setting-list-item type="switch" title='{{ i18n "pages.xray.VNDomain"}}' desc='{{ i18n "pages.xray.VNDomainDesc"}}' v-model="VNDomainSettings"></setting-list-item>
  213. </a-collapse-panel>
  214. <a-collapse-panel header='{{ i18n "pages.xray.directCountryConfigs"}}'>
  215. <a-row :xs="24" :sm="24" :lg="12">
  216. <a-alert type="warning" style="text-align: center;">
  217. <template slot="message">
  218. <a-icon type="exclamation-circle" theme="filled" style="color: #FFA031"></a-icon>
  219. {{ i18n "pages.xray.directCountryConfigsDesc" }}
  220. </template>
  221. </a-alert>
  222. </a-row>
  223. <setting-list-item type="switch" title='{{ i18n "pages.xray.DirectIRIp"}}' desc='{{ i18n "pages.xray.DirectIRIpDesc"}}' v-model="IRIpDirectSettings"></setting-list-item>
  224. <setting-list-item type="switch" title='{{ i18n "pages.xray.DirectIRDomain"}}' desc='{{ i18n "pages.xray.DirectIRDomainDesc"}}' v-model="IRDomainDirectSettings"></setting-list-item>
  225. <setting-list-item type="switch" title='{{ i18n "pages.xray.DirectChinaIp"}}' desc='{{ i18n "pages.xray.DirectChinaIpDesc"}}' v-model="ChinaIpDirectSettings"></setting-list-item>
  226. <setting-list-item type="switch" title='{{ i18n "pages.xray.DirectChinaDomain"}}' desc='{{ i18n "pages.xray.DirectChinaDomainDesc"}}' v-model="ChinaDomainDirectSettings"></setting-list-item>
  227. <setting-list-item type="switch" title='{{ i18n "pages.xray.DirectRussiaIp"}}' desc='{{ i18n "pages.xray.DirectRussiaIpDesc"}}' v-model="RussiaIpDirectSettings"></setting-list-item>
  228. <setting-list-item type="switch" title='{{ i18n "pages.xray.DirectRussiaDomain"}}' desc='{{ i18n "pages.xray.DirectRussiaDomainDesc"}}' v-model="RussiaDomainDirectSettings"></setting-list-item>
  229. <setting-list-item type="switch" title='{{ i18n "pages.xray.DirectVNIp"}}' desc='{{ i18n "pages.xray.DirectVNIpDesc"}}' v-model="VNIpDirectSettings"></setting-list-item>
  230. <setting-list-item type="switch" title='{{ i18n "pages.xray.DirectVNDomain"}}' desc='{{ i18n "pages.xray.DirectVNDomainDesc"}}' v-model="VNDomainDirectSettings"></setting-list-item>
  231. </a-collapse-panel>
  232. <a-collapse-panel header='{{ i18n "pages.xray.ipv4Configs"}}'>
  233. <a-row :xs="24" :sm="24" :lg="12">
  234. <a-alert type="warning" style="text-align: center;">
  235. <template slot="message">
  236. <a-icon type="exclamation-circle" theme="filled" style="color: #FFA031"></a-icon>
  237. {{ i18n "pages.xray.ipv4ConfigsDesc" }}
  238. </template>
  239. </a-alert>
  240. </a-row>
  241. <setting-list-item type="switch" title='{{ i18n "pages.xray.GoogleIPv4"}}' desc='{{ i18n "pages.xray.GoogleIPv4Desc"}}' v-model="GoogleIPv4Settings"></setting-list-item>
  242. <setting-list-item type="switch" title='{{ i18n "pages.xray.NetflixIPv4"}}' desc='{{ i18n "pages.xray.NetflixIPv4Desc"}}' v-model="NetflixIPv4Settings"></setting-list-item>
  243. </a-collapse-panel>
  244. <a-collapse-panel header='{{ i18n "pages.xray.warpConfigs"}}'>
  245. <a-row :xs="24" :sm="24" :lg="12">
  246. <a-alert type="warning" style="text-align: center;">
  247. <template slot="message">
  248. <a-icon type="exclamation-circle" theme="filled" style="color: #FFA031"></a-icon>
  249. {{ i18n "pages.xray.warpConfigsDesc" }}
  250. </template>
  251. </a-alert>
  252. </a-row>
  253. <template v-if="WarpExist">
  254. <setting-list-item type="switch" title='{{ i18n "pages.xray.GoogleWARP"}}' desc='{{ i18n "pages.xray.GoogleWARPDesc"}}' v-model="GoogleWARPSettings"></setting-list-item>
  255. <setting-list-item type="switch" title='{{ i18n "pages.xray.OpenAIWARP"}}' desc='{{ i18n "pages.xray.OpenAIWARPDesc"}}' v-model="OpenAIWARPSettings"></setting-list-item>
  256. <setting-list-item type="switch" title='{{ i18n "pages.xray.NetflixWARP"}}' desc='{{ i18n "pages.xray.NetflixWARPDesc"}}' v-model="NetflixWARPSettings"></setting-list-item>
  257. <setting-list-item type="switch" title='{{ i18n "pages.xray.SpotifyWARP"}}' desc='{{ i18n "pages.xray.SpotifyWARPDesc"}}' v-model="SpotifyWARPSettings"></setting-list-item>
  258. </template>
  259. <a-button v-else style="margin: 10px 0;" @click="showWarp">WARP {{ i18n "pages.xray.rules.outbound" }}</a-button>
  260. </a-collapse-panel>
  261. </a-collapse>
  262. </a-tab-pane>
  263. <a-tab-pane key="tpl-2" tab='{{ i18n "pages.xray.Routings"}}' style="padding-top: 20px;">
  264. <a-alert type="warning" style="margin-bottom: 10px; width: fit-content"
  265. message='{{ i18n "pages.xray.RoutingsDesc"}}' show-icon></a-alert>
  266. <a-button type="primary" icon="plus" @click="addRule">{{ i18n "pages.xray.rules.add" }}</a-button>
  267. <a-table :columns="isMobile ? rulesMobileColumns : rulesColumns" bordered
  268. :row-key="r => r.key"
  269. :data-source="routingRuleData"
  270. :scroll="isMobile ? {} : { x: 1000 }"
  271. :pagination="false"
  272. :indent-size="0"
  273. :style="isMobile ? 'padding: 5px 0' : 'margin-top: 10px;'">
  274. <template slot="action" slot-scope="text, rule, index">
  275. [[ index+1 ]]
  276. <a-dropdown :trigger="['click']">
  277. <a-icon @click="e => e.preventDefault()" type="more" style="font-size: 16px; text-decoration: bold;"></a-icon>
  278. <a-menu slot="overlay" :theme="themeSwitcher.currentTheme">
  279. <a-menu-item v-if="index>0" @click="replaceRule(index,0)">
  280. <a-icon type="vertical-align-top"></a-icon>
  281. {{ i18n "pages.xray.rules.first"}}
  282. </a-menu-item>
  283. <a-menu-item v-if="index>0" @click="replaceRule(index,index-1)">
  284. <a-icon type="arrow-up"></a-icon>
  285. {{ i18n "pages.xray.rules.up"}}
  286. </a-menu-item>
  287. <a-menu-item v-if="index<routingRuleData.length-1" @click="replaceRule(index,index+1)">
  288. <a-icon type="arrow-down"></a-icon>
  289. {{ i18n "pages.xray.rules.down"}}
  290. </a-menu-item>
  291. <a-menu-item v-if="index<routingRuleData.length-1" @click="replaceRule(index,routingRuleData.length-1)">
  292. <a-icon type="vertical-align-bottom"></a-icon>
  293. {{ i18n "pages.xray.rules.last"}}
  294. </a-menu-item>
  295. <a-menu-item @click="editRule(index)">
  296. <a-icon type="edit"></a-icon>
  297. {{ i18n "edit" }}
  298. </a-menu-item>
  299. <a-menu-item @click="deleteRule(index)">
  300. <span style="color: #FF4D4F">
  301. <a-icon type="delete"></a-icon> {{ i18n "delete"}}
  302. </span>
  303. </a-menu-item>
  304. </a-menu>
  305. </a-dropdown>
  306. </template>
  307. <template slot="inbound" slot-scope="text, rule, index">
  308. <a-popover :overlay-class-name="themeSwitcher.currentTheme">
  309. <template slot="content">
  310. <p v-if="rule.inboundTag">Inbound Tag: [[ rule.inboundTag ]]</p>
  311. <p v-if="rule.user">User email: [[ rule.user ]]</p>
  312. </template>
  313. [[ [rule.inboundTag,rule.user].join('\n') ]]
  314. </a-popover>
  315. </template>
  316. <template slot="outbound" slot-scope="text, rule, index">
  317. <a-popover :overlay-class-name="themeSwitcher.currentTheme">
  318. <template slot="content">
  319. <p v-if="rule.outboundTag">Outbound Tag: [[ rule.outboundTag ]]</p>
  320. </template>
  321. [[ rule.outboundTag ]]
  322. </a-popover>
  323. </template>
  324. <template slot="info" slot-scope="text, rule, index">
  325. <a-popover placement="bottomRight"
  326. v-if="(rule.source+rule.sourcePort+rule.network+rule.protocol+rule.attrs+rule.ip+rule.domain+rule.port).length>0"
  327. :overlay-class-name="themeSwitcher.currentTheme" trigger="click">
  328. <template slot="content">
  329. <table cellpadding="2" style="max-width: 300px;">
  330. <tr v-if="rule.source">
  331. <td>Source</td>
  332. <td><a-tag color="blue" v-for="r in rule.source.split(',')">[[ r ]]</a-tag></td>
  333. </tr>
  334. <tr v-if="rule.sourcePort">
  335. <td>Source Port</td>
  336. <td><a-tag color="green" v-for="r in rule.sourcePort.split(',')">[[ r ]]</a-tag></td>
  337. </tr>
  338. <tr v-if="rule.network">
  339. <td>Network</td>
  340. <td><a-tag color="blue" v-for="r in rule.network.split(',')">[[ r ]]</a-tag></td>
  341. </tr>
  342. <tr v-if="rule.protocol">
  343. <td>Protocol</td>
  344. <td><a-tag color="green" v-for="r in rule.protocol.split(',')">[[ r ]]</a-tag></td>
  345. </tr>
  346. <tr v-if="rule.attrs">
  347. <td>Attrs</td>
  348. <td><a-tag color="blue" v-for="r in rule.attrs.split(',')">[[ r ]]</a-tag></td>
  349. </tr>
  350. <tr v-if="rule.ip">
  351. <td>IP</td>
  352. <td><a-tag color="green" v-for="r in rule.ip.split(',')">[[ r ]]</a-tag></td>
  353. </tr>
  354. <tr v-if="rule.domain">
  355. <td>Domain</td>
  356. <td><a-tag color="blue" v-for="r in rule.domain.split(',')">[[ r ]]</a-tag></td>
  357. </tr>
  358. <tr v-if="rule.port">
  359. <td>Port</td>
  360. <td><a-tag color="green" v-for="r in rule.port.split(',')">[[ r ]]</a-tag></td>
  361. </tr>
  362. </table>
  363. </template>
  364. <a-button shape="round" size="small" style="font-size: 14px; padding: 0 10px;">
  365. <a-icon type="info"></a-icon>
  366. </a-button>
  367. </a-popover>
  368. </template>
  369. </a-table>
  370. </a-tab-pane>
  371. <a-tab-pane key="tpl-3" tab='{{ i18n "pages.xray.Outbounds"}}' style="padding-top: 20px;" force-render="true">
  372. <a-row>
  373. <a-col :xs="12" :sm="12" :lg="12">
  374. <a-button type="primary" icon="plus" @click="addOutbound()" style="margin-bottom: 10px;">{{ i18n "pages.xray.outbound.addOutbound" }}</a-button>
  375. <a-button type="primary" @click="showWarp()" style="margin-bottom: 10px;">WARP</a-button>
  376. </a-col>
  377. <a-col :xs="12" :sm="12" :lg="12" style="text-align: right;">
  378. <a-icon type="sync" :spin="refreshing" @click="refreshOutboundTraffic()" style="margin: 0 5px;"/>
  379. </a-col>
  380. </a-row>
  381. <a-table :columns="outboundColumns" bordered
  382. :row-key="r => r.key"
  383. :data-source="outboundData"
  384. :scroll="isMobile ? {} : { x: 200 }"
  385. :pagination="false"
  386. :indent-size="0"
  387. :style="isMobile ? 'padding: 5px 5px' : 'margin-right: 1px;'">
  388. <template slot="action" slot-scope="text, outbound, index">
  389. [[ index+1 ]]
  390. <a-dropdown :trigger="['click']">
  391. <a-icon @click="e => e.preventDefault()" type="more" style="font-size: 16px; text-decoration: bold;"></a-icon>
  392. <a-menu slot="overlay" :theme="themeSwitcher.currentTheme">
  393. <a-menu-item @click="editOutbound(index)">
  394. <a-icon type="edit"></a-icon>
  395. {{ i18n "edit" }}
  396. </a-menu-item>
  397. <a-menu-item @click="deleteOutbound(index)">
  398. <span style="color: #FF4D4F">
  399. <a-icon type="delete"></a-icon> {{ i18n "delete"}}
  400. </span>
  401. </a-menu-item>
  402. </a-menu>
  403. </a-dropdown>
  404. </template>
  405. <template slot="address" slot-scope="text, outbound, index">
  406. <p style="margin: 0 5px;" v-for="addr in findOutboundAddress(outbound)">[[ addr ]]</p>
  407. </template>
  408. <template slot="protocol" slot-scope="text, outbound, index">
  409. <a-tag style="margin:0;" color="purple">[[ outbound.protocol ]]</a-tag>
  410. <template v-if="[Protocols.VMess, Protocols.VLESS, Protocols.Trojan, Protocols.Shadowsocks].includes(outbound.protocol)">
  411. <a-tag style="margin:0;" color="blue">[[ outbound.streamSettings.network ]]</a-tag>
  412. <a-tag style="margin:0;" v-if="outbound.streamSettings.security=='tls'" color="green">tls</a-tag>
  413. <a-tag style="margin:0;" v-if="outbound.streamSettings.security=='reality'" color="green">reality</a-tag>
  414. </template>
  415. </template>
  416. <template slot="traffic" slot-scope="text, outbound, index">
  417. <a-tag color="green">[[ findOutboundTraffic(outbound) ]]</a-tag>
  418. </template>
  419. </a-table>
  420. </a-tab-pane>
  421. <a-tab-pane key="tpl-4" tab='{{ i18n "pages.xray.outbound.reverse"}}' style="padding-top: 20px;" force-render="true">
  422. <a-button type="primary" icon="plus" @click="addReverse()" style="margin-bottom: 10px;">{{ i18n "pages.xray.outbound.addReverse" }}</a-button>
  423. <a-table :columns="reverseColumns" bordered
  424. :row-key="r => r.key"
  425. :data-source="reverseData"
  426. :scroll="isMobile ? {} : { x: 200 }"
  427. :pagination="false"
  428. :indent-size="0"
  429. :style="isMobile ? 'padding: 5px 0' : 'margin-left: 1px;'">
  430. <template slot="action" slot-scope="text, reverse, index">
  431. [[ index+1 ]]
  432. <a-dropdown :trigger="['click']">
  433. <a-icon @click="e => e.preventDefault()" type="more" style="font-size: 16px; text-decoration: bold;"></a-icon>
  434. <a-menu slot="overlay" :theme="themeSwitcher.currentTheme">
  435. <a-menu-item @click="editReverse(index)">
  436. <a-icon type="edit"></a-icon>
  437. {{ i18n "edit" }}
  438. </a-menu-item>
  439. <a-menu-item @click="deleteReverse(index)">
  440. <span style="color: #FF4D4F">
  441. <a-icon type="delete"></a-icon> {{ i18n "delete"}}
  442. </span>
  443. </a-menu-item>
  444. </a-menu>
  445. </a-dropdown>
  446. </template>
  447. </a-table>
  448. </a-tab-pane>
  449. <a-tab-pane key="tpl-advanced" tab='{{ i18n "pages.xray.advancedTemplate"}}' style="padding-top: 20px;" force-render="true">
  450. <a-list-item-meta title='{{ i18n "pages.xray.Template"}}' description='{{ i18n "pages.xray.TemplateDesc"}}'></a-list-item-meta>
  451. <a-radio-group v-model="advSettings" @change="changeCode" button-style="solid" style="margin: 10px 0;" :size="isMobile ? 'small' : ''">
  452. <a-radio-button value="xraySetting">{{ i18n "pages.xray.completeTemplate"}}</a-radio-button>
  453. <a-radio-button value="inboundSettings">{{ i18n "pages.xray.Inbounds" }}</a-radio-button>
  454. <a-radio-button value="outboundSettings">{{ i18n "pages.xray.Outbounds" }}</a-radio-button>
  455. <a-radio-button value="routingRuleSettings">{{ i18n "pages.xray.Routings" }}</a-radio-button>
  456. </a-radio-group>
  457. <textarea style="position:absolute; left: -800px;" id="xraySetting"></textarea>
  458. </a-tab-pane>
  459. </a-tabs>
  460. </a-space>
  461. </a-spin>
  462. </a-layout-content>
  463. </a-layout>
  464. </a-layout>
  465. {{template "js" .}}
  466. {{template "component/themeSwitcher" .}}
  467. {{template "component/setting"}}
  468. {{template "ruleModal"}}
  469. {{template "outModal"}}
  470. {{template "reverseModal"}}
  471. {{template "warpModal"}}
  472. <script>
  473. const rulesColumns = [
  474. { title: "#", align: 'center', width: 15, scopedSlots: { customRender: 'action' } },
  475. { title: '{{ i18n "pages.xray.rules.source"}}', children: [
  476. { title: 'IP', dataIndex: "source", align: 'center', width: 20, ellipsis: true },
  477. { title: 'Port', dataIndex: 'sourcePort', align: 'center', width: 10, ellipsis: true } ]},
  478. { title: '{{ i18n "pages.inbounds.network"}}', children: [
  479. { title: 'L4', dataIndex: 'network', align: 'center', width: 10 },
  480. { title: 'Protocol', dataIndex: 'protocol', align: 'center', width: 10, ellipsis: true },
  481. { title: 'Attrs', dataIndex: 'attrs', align: 'center', width: 20, ellipsis: true } ]},
  482. { title: '{{ i18n "pages.xray.rules.dest"}}', children: [
  483. { title: 'IP', dataIndex: 'ip', align: 'center', width: 20, ellipsis: true },
  484. { title: 'Domain', dataIndex: 'domain', align: 'center', width: 20, ellipsis: true },
  485. { title: 'Port', dataIndex: 'port', align: 'center', width: 10, ellipsis: true }]},
  486. { title: '{{ i18n "pages.xray.rules.inbound"}}', children: [
  487. { title: 'Inbound Tag', dataIndex: 'inboundTag', align: 'center', width: 20, ellipsis: true },
  488. { title: 'Client Email', dataIndex: 'user', align: 'center', width: 20, ellipsis: true }]},
  489. { title: '{{ i18n "pages.xray.rules.outbound"}}', dataIndex: 'outboundTag', align: 'center', width: 20 },
  490. ];
  491. const rulesMobileColumns = [
  492. { title: "#", align: 'center', width: 20, scopedSlots: { customRender: 'action' } },
  493. { title: '{{ i18n "pages.xray.rules.inbound"}}', align: 'center', width: 50, ellipsis: true, scopedSlots: { customRender: 'inbound' } },
  494. { title: '{{ i18n "pages.xray.rules.outbound"}}', align: 'center', width: 50, ellipsis: true, scopedSlots: { customRender: 'outbound' } },
  495. { title: '{{ i18n "pages.xray.rules.info"}}', align: 'center', width: 50, ellipsis: true, scopedSlots: { customRender: 'info' } },
  496. ];
  497. const outboundColumns = [
  498. { title: "#", align: 'center', width: 20, scopedSlots: { customRender: 'action' } },
  499. { title: '{{ i18n "pages.xray.outbound.tag"}}', dataIndex: 'tag', align: 'center', width: 50 },
  500. { title: '{{ i18n "protocol"}}', align: 'center', width: 50, scopedSlots: { customRender: 'protocol' } },
  501. { title: '{{ i18n "pages.xray.outbound.address"}}', align: 'center', width: 50, scopedSlots: { customRender: 'address' } },
  502. { title: '{{ i18n "pages.inbounds.traffic" }}', align: 'center', width: 50, scopedSlots: { customRender: 'traffic' } },
  503. ];
  504. const reverseColumns = [
  505. { title: "#", align: 'center', width: 20, scopedSlots: { customRender: 'action' } },
  506. { title: '{{ i18n "pages.xray.outbound.type"}}', dataIndex: 'type', align: 'center', width: 50 },
  507. { title: '{{ i18n "pages.xray.outbound.tag"}}', dataIndex: 'tag', align: 'center', width: 50 },
  508. { title: '{{ i18n "pages.xray.outbound.domain"}}', dataIndex: 'domain', align: 'center', width: 50 },
  509. ];
  510. const app = new Vue({
  511. delimiters: ['[[', ']]'],
  512. el: '#app',
  513. data: {
  514. siderDrawer,
  515. themeSwitcher,
  516. isDarkTheme: themeSwitcher.isDarkTheme,
  517. spinning: false,
  518. oldXraySetting: '',
  519. xraySetting: '',
  520. inboundTags: [],
  521. outboundsTraffic: [],
  522. saveBtnDisable: true,
  523. refreshing: false,
  524. restartResult: '',
  525. isMobile: window.innerWidth <= 768,
  526. advSettings: 'xraySetting',
  527. cm: null,
  528. cmOptions: {
  529. lineNumbers: true,
  530. mode: "application/json",
  531. lint: true,
  532. styleActiveLine: true,
  533. matchBrackets: true,
  534. theme: "xq",
  535. autoCloseTags: true,
  536. lineWrapping: true,
  537. indentUnit: 2,
  538. indentWithTabs: true,
  539. smartIndent: true,
  540. tabSize: 2,
  541. lineWiseCopyCut: false,
  542. foldGutter: true,
  543. gutters: [
  544. "CodeMirror-lint-markers",
  545. "CodeMirror-linenumbers",
  546. "CodeMirror-foldgutter",
  547. ],
  548. },
  549. ipv4Settings: {
  550. tag: "IPv4",
  551. protocol: "freedom",
  552. settings: {
  553. domainStrategy: "UseIPv4"
  554. }
  555. },
  556. directSettings: {
  557. tag: "direct",
  558. protocol: "freedom"
  559. },
  560. routingDomainStrategies: ["AsIs", "IPIfNonMatch", "IPOnDemand"],
  561. logLevel: ["none" , "debug" , "info" , "warning", "error"],
  562. access: ["none" , "./access.log" ],
  563. settingsData: {
  564. protocols: {
  565. bittorrent: ["bittorrent"],
  566. },
  567. ips: {
  568. local: ["geoip:private"],
  569. cn: ["geoip:cn"],
  570. ir: ["ext:geoip_IR.dat:ir"],
  571. ru: ["geoip:ru"],
  572. vn: ["ext:geoip_VN.dat:vn"],
  573. },
  574. domains: {
  575. ads: [
  576. "geosite:category-ads-all",
  577. "ext:geosite_IR.dat:category-ads-all"
  578. ],
  579. security: [
  580. "ext:geosite_IR.dat:malware",
  581. "ext:geosite_IR.dat:phishing",
  582. "ext:geosite_IR.dat:cryptominers"
  583. ],
  584. speedtest: ["geosite:speedtest"],
  585. openai: ["geosite:openai"],
  586. google: ["geosite:google"],
  587. spotify: ["geosite:spotify"],
  588. netflix: ["geosite:netflix"],
  589. cn: [
  590. "geosite:cn",
  591. "regexp:.*\\.cn$"
  592. ],
  593. ru: [
  594. "geosite:category-gov-ru",
  595. "regexp:.*\\.ru$"
  596. ],
  597. ir: [
  598. "regexp:.*\\.ir$",
  599. "regexp:.*\\.xn--mgba3a4f16a$", // .ایران
  600. "ext:geosite_IR.dat:ir"
  601. ],
  602. vn: [
  603. "regexp:.*\\.vn$",
  604. "ext:geosite_VN.dat:vn",
  605. "ext:geosite_VN.dat:ads"
  606. ]
  607. },
  608. familyProtectDNS: {
  609. "servers": [
  610. "1.1.1.3", // https://developers.cloudflare.com/1.1.1.1/setup/
  611. "1.0.0.3",
  612. "2606:4700:4700::1113",
  613. "2606:4700:4700::1003"
  614. ],
  615. "queryStrategy": "UseIP"
  616. },
  617. }
  618. },
  619. methods: {
  620. loading(spinning = true) {
  621. this.spinning = spinning;
  622. },
  623. async getOutboundsTraffic() {
  624. const msg = await HttpUtil.get("/panel/xray/getOutboundsTraffic");
  625. if (msg.success) {
  626. this.outboundsTraffic = msg.obj;
  627. }
  628. },
  629. async getXraySetting() {
  630. this.loading(true);
  631. const msg = await HttpUtil.post("/panel/xray/");
  632. this.loading(false);
  633. if (msg.success) {
  634. result = JSON.parse(msg.obj);
  635. xs = JSON.stringify(result.xraySetting, null, 2);
  636. this.oldXraySetting = xs;
  637. this.xraySetting = xs;
  638. this.inboundTags = result.inboundTags;
  639. this.saveBtnDisable = true;
  640. }
  641. },
  642. async updateXraySetting() {
  643. this.loading(true);
  644. const msg = await HttpUtil.post("/panel/xray/update", {xraySetting : this.xraySetting});
  645. this.loading(false);
  646. if (msg.success) {
  647. await this.getXraySetting();
  648. }
  649. },
  650. async restartXray() {
  651. this.loading(true);
  652. const msg = await HttpUtil.post("server/restartXrayService");
  653. this.loading(false);
  654. if (msg.success) {
  655. await PromiseUtil.sleep(500);
  656. await this.getXrayResult();
  657. }
  658. this.loading(false);
  659. },
  660. async getXrayResult() {
  661. const msg = await HttpUtil.get("/panel/xray/getXrayResult");
  662. if(msg.success){
  663. this.restartResult=msg.obj;
  664. if(msg.obj.length > 1) Vue.prototype.$message.error(msg.obj);
  665. }
  666. },
  667. async fetchUserSecret() {
  668. this.loading(true);
  669. const userMessage = await HttpUtil.post("/panel/setting/getUserSecret", this.user);
  670. if (userMessage.success) {
  671. this.user = userMessage.obj;
  672. }
  673. this.loading(false);
  674. },
  675. async updateSecret() {
  676. this.loading(true);
  677. const msg = await HttpUtil.post("/panel/setting/updateUserSecret", this.user);
  678. if (msg.success) {
  679. this.user = msg.obj;
  680. window.location.replace(basePath + "logout");
  681. }
  682. this.loading(false);
  683. await this.updateXraySetting();
  684. },
  685. generateRandomString(length) {
  686. var chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
  687. let randomString = "";
  688. for (let i = 0; i < length; i++) {
  689. randomString += chars[Math.floor(Math.random() * chars.length)];
  690. }
  691. return randomString;
  692. },
  693. async getNewSecret() {
  694. this.loading(true);
  695. await PromiseUtil.sleep(600);
  696. const newSecret = this.generateRandomString(64);
  697. this.user.loginSecret = newSecret;
  698. document.getElementById("token").textContent = newSecret;
  699. this.loading(false);
  700. },
  701. async toggleToken(value) {
  702. if (value) {
  703. await this.getNewSecret();
  704. } else {
  705. this.user.loginSecret = "";
  706. }
  707. },
  708. async resetXrayConfigToDefault() {
  709. this.loading(true);
  710. const msg = await HttpUtil.get("/panel/setting/getDefaultJsonConfig");
  711. this.loading(false);
  712. if (msg.success) {
  713. this.templateSettings = JSON.parse(JSON.stringify(msg.obj, null, 2));
  714. this.saveBtnDisable = true;
  715. }
  716. },
  717. syncRulesWithOutbound(tag, setting) {
  718. const newTemplateSettings = this.templateSettings;
  719. const haveRules = newTemplateSettings.routing.rules.some((r) => r?.outboundTag === tag);
  720. const outboundIndex = newTemplateSettings.outbounds.findIndex((o) => o.tag === tag);
  721. if (!haveRules && outboundIndex > 0) {
  722. newTemplateSettings.outbounds.splice(outboundIndex);
  723. }
  724. if (haveRules && outboundIndex < 0) {
  725. newTemplateSettings.outbounds.push(setting);
  726. }
  727. this.templateSettings = newTemplateSettings;
  728. },
  729. templateRuleGetter(routeSettings) {
  730. const { property, outboundTag } = routeSettings;
  731. let result = [];
  732. if (this.templateSettings != null) {
  733. this.templateSettings.routing.rules.forEach(
  734. (routingRule) => {
  735. if (
  736. routingRule.hasOwnProperty(property) &&
  737. routingRule.hasOwnProperty("outboundTag") &&
  738. routingRule.outboundTag === outboundTag
  739. ) {
  740. result.push(...routingRule[property]);
  741. }
  742. }
  743. );
  744. }
  745. return result;
  746. },
  747. templateRuleSetter(routeSettings) {
  748. const { data, property, outboundTag } = routeSettings;
  749. const oldTemplateSettings = this.templateSettings;
  750. const newTemplateSettings = oldTemplateSettings;
  751. currentProperty = this.templateRuleGetter({ outboundTag, property })
  752. if (currentProperty.length == 0) {
  753. const propertyRule = {
  754. type: "field",
  755. outboundTag,
  756. [property]: data
  757. };
  758. newTemplateSettings.routing.rules.push(propertyRule);
  759. }
  760. else {
  761. const newRules = [];
  762. insertedOnce = false;
  763. newTemplateSettings.routing.rules.forEach(
  764. (routingRule) => {
  765. if (
  766. routingRule.hasOwnProperty(property) &&
  767. routingRule.hasOwnProperty("outboundTag") &&
  768. routingRule.outboundTag === outboundTag
  769. ) {
  770. if (!insertedOnce && data.length > 0) {
  771. insertedOnce = true;
  772. routingRule[property] = data;
  773. newRules.push(routingRule);
  774. }
  775. }
  776. else {
  777. newRules.push(routingRule);
  778. }
  779. }
  780. );
  781. newTemplateSettings.routing.rules = newRules;
  782. }
  783. this.templateSettings = newTemplateSettings;
  784. },
  785. changeCode() {
  786. if(this.cm != null) {
  787. this.cm.toTextArea();
  788. }
  789. textAreaObj = document.getElementById('xraySetting');
  790. textAreaObj.value = this[this.advSettings];
  791. this.cm = CodeMirror.fromTextArea(textAreaObj, this.cmOptions);
  792. this.cm.on('change',editor => {
  793. value = editor.getValue();
  794. if(this.isJsonString(value)){
  795. this[this.advSettings] = value;
  796. }
  797. });
  798. },
  799. isJsonString(str) {
  800. try {
  801. JSON.parse(str);
  802. } catch (e) {
  803. return false;
  804. }
  805. return true;
  806. },
  807. findOutboundTraffic(o) {
  808. for (const otraffic of this.outboundsTraffic) {
  809. if (otraffic.tag == o.tag) {
  810. return sizeFormat(otraffic.up) + ' / ' + sizeFormat(otraffic.down);
  811. }
  812. }
  813. return sizeFormat(0) + ' / ' + sizeFormat(0);
  814. },
  815. findOutboundAddress(o) {
  816. serverObj = null;
  817. switch(o.protocol){
  818. case Protocols.VMess:
  819. case Protocols.VLESS:
  820. serverObj = o.settings.vnext;
  821. break;
  822. case Protocols.HTTP:
  823. case Protocols.Socks:
  824. case Protocols.Shadowsocks:
  825. case Protocols.Trojan:
  826. serverObj = o.settings.servers;
  827. break;
  828. case Protocols.DNS:
  829. return [o.settings.address + ':' + o.settings.port];
  830. case Protocols.Wireguard:
  831. return o.settings.peers.map(peer => peer.endpoint);
  832. default:
  833. return null;
  834. }
  835. return serverObj ? serverObj.map(obj => obj.address + ':' + obj.port) : null;
  836. },
  837. addOutbound(){
  838. outModal.show({
  839. title: '{{ i18n "pages.xray.outbound.addOutbound"}}',
  840. okText: '{{ i18n "pages.xray.outbound.addOutbound" }}',
  841. confirm: (outbound) => {
  842. outModal.loading();
  843. if(outbound.tag.length > 0){
  844. this.templateSettings.outbounds.push(outbound);
  845. this.outboundSettings = JSON.stringify(this.templateSettings.outbounds);
  846. }
  847. outModal.close();
  848. },
  849. isEdit: false,
  850. tags: this.templateSettings.outbounds.map(obj => obj.tag)
  851. });
  852. },
  853. editOutbound(index){
  854. outModal.show({
  855. title: '{{ i18n "pages.xray.outbound.editOutbound"}} ' + (index+1),
  856. outbound: app.templateSettings.outbounds[index],
  857. confirm: (outbound) => {
  858. outModal.loading();
  859. this.templateSettings.outbounds[index] = outbound;
  860. this.outboundSettings = JSON.stringify(this.templateSettings.outbounds);
  861. outModal.close();
  862. },
  863. isEdit: true,
  864. tags: this.outboundData.filter((o) => o.key != index ).map(obj => obj.tag)
  865. });
  866. },
  867. deleteOutbound(index){
  868. outbounds = this.templateSettings.outbounds;
  869. outbounds.splice(index,1);
  870. this.outboundSettings = JSON.stringify(outbounds);
  871. },
  872. async refreshOutboundTraffic() {
  873. if (!this.refreshing) {
  874. this.refreshing = true;
  875. await this.getOutboundsTraffic();
  876. data = []
  877. if (this.templateSettings != null) {
  878. this.templateSettings.outbounds.forEach((o, index) => {
  879. data.push({'key': index, ...o});
  880. });
  881. }
  882. this.outboundData = data;
  883. this.refreshing = false;
  884. }
  885. },
  886. addReverse(){
  887. reverseModal.show({
  888. title: '{{ i18n "pages.xray.outbound.addReverse"}}',
  889. okText: '{{ i18n "pages.xray.outbound.addReverse" }}',
  890. confirm: (reverse, rules) => {
  891. reverseModal.loading();
  892. if(reverse.tag.length > 0){
  893. newTemplateSettings = this.templateSettings;
  894. if(newTemplateSettings.reverse == undefined) newTemplateSettings.reverse = {};
  895. if(newTemplateSettings.reverse[reverse.type+'s'] == undefined) newTemplateSettings.reverse[reverse.type+'s'] = [];
  896. newTemplateSettings.reverse[reverse.type+'s'].push({ tag: reverse.tag, domain: reverse.domain });
  897. this.templateSettings = newTemplateSettings;
  898. // Add related rules
  899. this.templateSettings.routing.rules.push(...rules);
  900. this.routingRuleSettings = JSON.stringify(this.templateSettings.routing.rules);
  901. }
  902. reverseModal.close();
  903. },
  904. isEdit: false
  905. });
  906. },
  907. editReverse(index){
  908. if(this.reverseData[index].type == "bridge") {
  909. oldRules = this.templateSettings.routing.rules.filter(r => r.inboundTag && r.inboundTag[0] == this.reverseData[index].tag);
  910. } else {
  911. oldRules = this.templateSettings.routing.rules.filter(r => r.outboundTag && r.outboundTag == this.reverseData[index].tag);
  912. }
  913. reverseModal.show({
  914. title: '{{ i18n "pages.xray.outbound.editReverse"}} ' + (index+1),
  915. reverse: this.reverseData[index],
  916. rules: oldRules,
  917. confirm: (reverse, rules) => {
  918. reverseModal.loading();
  919. if(reverse.tag.length > 0){
  920. oldData = this.reverseData[index];
  921. newTemplateSettings = this.templateSettings;
  922. oldReverseIndex = newTemplateSettings.reverse[oldData.type+'s'].findIndex(rs => rs.tag == oldData.tag);
  923. oldRuleIndex0 = oldRules.length>0 ? newTemplateSettings.routing.rules.findIndex(r => JSON.stringify(r) == JSON.stringify(oldRules[0])) : -1;
  924. oldRuleIndex1 = oldRules.length==2 ? newTemplateSettings.routing.rules.findIndex(r => JSON.stringify(r) == JSON.stringify(oldRules[1])) : -1;
  925. if(oldData.type == reverse.type){
  926. newTemplateSettings.reverse[oldData.type + 's'][oldReverseIndex] = { tag: reverse.tag, domain: reverse.domain };
  927. } else {
  928. newTemplateSettings.reverse[oldData.type+'s'].splice(oldReverseIndex,1);
  929. // delete empty object
  930. if(newTemplateSettings.reverse[oldData.type+'s'].length == 0) Reflect.deleteProperty(newTemplateSettings.reverse, oldData.type+'s');
  931. // add other type of reverse if it is not exist
  932. if(!newTemplateSettings.reverse[reverse.type+'s']) newTemplateSettings.reverse[reverse.type+'s'] = [];
  933. newTemplateSettings.reverse[reverse.type+'s'].push({ tag: reverse.tag, domain: reverse.domain });
  934. }
  935. this.templateSettings = newTemplateSettings;
  936. // Adjust Rules
  937. newRules = this.templateSettings.routing.rules;
  938. oldRuleIndex0 != -1 ? newRules[oldRuleIndex0] = rules[0] : newRules.push(rules[0]);
  939. oldRuleIndex1 != -1 ? newRules[oldRuleIndex1] = rules[1] : newRules.push(rules[1]);
  940. this.routingRuleSettings = JSON.stringify(newRules);
  941. }
  942. reverseModal.close();
  943. },
  944. isEdit: true
  945. });
  946. },
  947. deleteReverse(index){
  948. oldData = this.reverseData[index];
  949. newTemplateSettings = this.templateSettings;
  950. reverseTypeObj = newTemplateSettings.reverse[oldData.type+'s'];
  951. realIndex = reverseTypeObj.findIndex(r => r.tag==oldData.tag && r.domain==oldData.domain);
  952. newTemplateSettings.reverse[oldData.type+'s'].splice(realIndex,1);
  953. // delete empty objects
  954. if(reverseTypeObj.length == 0) Reflect.deleteProperty(newTemplateSettings.reverse, oldData.type+'s');
  955. if(Object.keys(newTemplateSettings.reverse).length === 0) Reflect.deleteProperty(newTemplateSettings, 'reverse');
  956. // delete related routing rules
  957. newRules = newTemplateSettings.routing.rules;
  958. if(oldData.type == "bridge"){
  959. newRules = newTemplateSettings.routing.rules.filter(r => !( r.inboundTag && r.inboundTag.length == 1 && r.inboundTag[0] == oldData.tag));
  960. } else if(oldData.type == "portal"){
  961. newRules = newTemplateSettings.routing.rules.filter(r => r.outboundTag != oldData.tag);
  962. }
  963. newTemplateSettings.routing.rules = newRules;
  964. this.templateSettings = newTemplateSettings;
  965. },
  966. addRule(){
  967. ruleModal.show({
  968. title: '{{ i18n "pages.xray.rules.add"}}',
  969. okText: '{{ i18n "pages.xray.rules.add" }}',
  970. confirm: (rule) => {
  971. ruleModal.loading();
  972. if(JSON.stringify(rule).length > 3){
  973. this.templateSettings.routing.rules.push(rule);
  974. this.routingRuleSettings = JSON.stringify(this.templateSettings.routing.rules);
  975. }
  976. ruleModal.close();
  977. },
  978. isEdit: false
  979. });
  980. },
  981. editRule(index){
  982. ruleModal.show({
  983. title: '{{ i18n "pages.xray.rules.edit"}} ' + (index+1),
  984. rule: app.templateSettings.routing.rules[index],
  985. confirm: (rule) => {
  986. ruleModal.loading();
  987. if(JSON.stringify(rule).length > 3){
  988. this.templateSettings.routing.rules[index] = rule;
  989. this.routingRuleSettings = JSON.stringify(this.templateSettings.routing.rules);
  990. }
  991. ruleModal.close();
  992. },
  993. isEdit: true
  994. });
  995. },
  996. replaceRule(old_index,new_index){
  997. rules = this.templateSettings.routing.rules;
  998. if (new_index >= rules.length) rules.push(undefined);
  999. rules.splice(new_index, 0, rules.splice(old_index, 1)[0]);
  1000. this.routingRuleSettings = JSON.stringify(rules);
  1001. },
  1002. deleteRule(index){
  1003. rules = this.templateSettings.routing.rules;
  1004. rules.splice(index,1);
  1005. this.routingRuleSettings = JSON.stringify(rules);
  1006. },
  1007. showWarp(){
  1008. warpModal.show();
  1009. }
  1010. },
  1011. async mounted() {
  1012. await this.getXraySetting();
  1013. await this.getXrayResult();
  1014. await this.getOutboundsTraffic();
  1015. while (true) {
  1016. await PromiseUtil.sleep(800);
  1017. this.saveBtnDisable = this.oldXraySetting === this.xraySetting;
  1018. }
  1019. },
  1020. computed: {
  1021. templateSettings: {
  1022. get: function () { return this.xraySetting ? JSON.parse(this.xraySetting) : null; },
  1023. set: function (newValue) { this.xraySetting = JSON.stringify(newValue, null, 2); },
  1024. },
  1025. inboundSettings: {
  1026. get: function () { return this.templateSettings ? JSON.stringify(this.templateSettings.inbounds, null, 2) : null; },
  1027. set: function (newValue) {
  1028. newTemplateSettings = this.templateSettings;
  1029. newTemplateSettings.inbounds = JSON.parse(newValue);
  1030. this.templateSettings = newTemplateSettings;
  1031. },
  1032. },
  1033. outboundSettings: {
  1034. get: function () { return this.templateSettings ? JSON.stringify(this.templateSettings.outbounds, null, 2) : null; },
  1035. set: function (newValue) {
  1036. newTemplateSettings = this.templateSettings;
  1037. newTemplateSettings.outbounds = JSON.parse(newValue);
  1038. this.templateSettings = newTemplateSettings;
  1039. },
  1040. },
  1041. outboundData: {
  1042. get: function () {
  1043. data = []
  1044. if (this.templateSettings != null) {
  1045. this.templateSettings.outbounds.forEach((o, index) => {
  1046. data.push({'key': index, ...o});
  1047. });
  1048. }
  1049. return data;
  1050. },
  1051. },
  1052. reverseData: {
  1053. get: function () {
  1054. data = []
  1055. if (this.templateSettings != null && this.templateSettings.reverse != null) {
  1056. if(this.templateSettings.reverse.bridges) {
  1057. this.templateSettings.reverse.bridges.forEach((o, index) => {
  1058. data.push({'key': index, 'type':'bridge', ...o});
  1059. });
  1060. }
  1061. if(this.templateSettings.reverse.portals){
  1062. this.templateSettings.reverse.portals.forEach((o, index) => {
  1063. data.push({'key': index, 'type':'portal', ...o});
  1064. });
  1065. }
  1066. }
  1067. return data;
  1068. },
  1069. },
  1070. routingRuleSettings: {
  1071. get: function () { return this.templateSettings ? JSON.stringify(this.templateSettings.routing.rules, null, 2) : null; },
  1072. set: function (newValue) {
  1073. newTemplateSettings = this.templateSettings;
  1074. newTemplateSettings.routing.rules = JSON.parse(newValue);
  1075. this.templateSettings = newTemplateSettings;
  1076. },
  1077. },
  1078. routingRuleData: {
  1079. get: function () {
  1080. data = [];
  1081. if (this.templateSettings != null) {
  1082. this.templateSettings.routing.rules.forEach((r, index) => {
  1083. data.push({'key': index, ...r});
  1084. });
  1085. // Make rules readable
  1086. data.forEach(r => {
  1087. if(r.domain) r.domain = r.domain.join(',')
  1088. if(r.ip) r.ip = r.ip.join(',')
  1089. if(r.source) r.source = r.source.join(',');
  1090. if(r.user) r.user = r.user.join(',')
  1091. if(r.inboundTag) r.inboundTag = r.inboundTag.join(',')
  1092. if(r.protocol) r.protocol = r.protocol.join(',')
  1093. if(r.attrs) r.attrs = JSON.stringify(r.attrs, null, 2)
  1094. });
  1095. }
  1096. return data;
  1097. }
  1098. },
  1099. freedomStrategy: {
  1100. get: function () {
  1101. if (!this.templateSettings) return "AsIs";
  1102. freedomOutbound = this.templateSettings.outbounds.find((o) => o.protocol === "freedom" && o.tag == "direct");
  1103. if (!freedomOutbound) return "AsIs";
  1104. if (!freedomOutbound.settings || !freedomOutbound.settings.domainStrategy) return "AsIs";
  1105. return freedomOutbound.settings.domainStrategy;
  1106. },
  1107. set: function (newValue) {
  1108. newTemplateSettings = this.templateSettings;
  1109. freedomOutboundIndex = newTemplateSettings.outbounds.findIndex((o) => o.protocol === "freedom" && o.tag == "direct");
  1110. if(freedomOutboundIndex == -1){
  1111. newTemplateSettings.outbounds.push({protocol: "freedom", tag: "direct", settings: { "domainStrategy": newValue }});
  1112. } else if (!newTemplateSettings.outbounds[freedomOutboundIndex].settings) {
  1113. newTemplateSettings.outbounds[freedomOutboundIndex].settings = {"domainStrategy": newValue};
  1114. } else {
  1115. newTemplateSettings.outbounds[freedomOutboundIndex].settings.domainStrategy = newValue;
  1116. }
  1117. this.templateSettings = newTemplateSettings;
  1118. }
  1119. },
  1120. routingStrategy: {
  1121. get: function () {
  1122. if (!this.templateSettings || !this.templateSettings.routing || !this.templateSettings.routing.domainStrategy) return "AsIs";
  1123. return this.templateSettings.routing.domainStrategy;
  1124. },
  1125. set: function (newValue) {
  1126. newTemplateSettings = this.templateSettings;
  1127. newTemplateSettings.routing.domainStrategy = newValue;
  1128. this.templateSettings = newTemplateSettings;
  1129. }
  1130. },
  1131. setLogLevel: {
  1132. get: function () {
  1133. if (!this.templateSettings || !this.templateSettings.log || !this.templateSettings.log.loglevel) return "warning";
  1134. return this.templateSettings.log.loglevel;
  1135. },
  1136. set: function (newValue) {
  1137. newTemplateSettings = this.templateSettings;
  1138. newTemplateSettings.log.loglevel = newValue;
  1139. this.templateSettings = newTemplateSettings;
  1140. }
  1141. },
  1142. setAccessLog: {
  1143. get: function () {
  1144. if (!this.templateSettings || !this.templateSettings.log || !this.templateSettings.log.access) return "none";
  1145. return this.templateSettings.log.access;
  1146. },
  1147. set: function (newValue) {
  1148. newTemplateSettings = this.templateSettings;
  1149. newTemplateSettings.log.access = newValue;
  1150. this.templateSettings = newTemplateSettings;
  1151. }
  1152. },
  1153. blockedIPs: {
  1154. get: function () {
  1155. return this.templateRuleGetter({ outboundTag: "blocked", property: "ip" });
  1156. },
  1157. set: function (newValue) {
  1158. this.templateRuleSetter({ outboundTag: "blocked", property: "ip", data: newValue });
  1159. }
  1160. },
  1161. blockedDomains: {
  1162. get: function () {
  1163. return this.templateRuleGetter({ outboundTag: "blocked", property: "domain" });
  1164. },
  1165. set: function (newValue) {
  1166. this.templateRuleSetter({ outboundTag: "blocked", property: "domain", data: newValue });
  1167. }
  1168. },
  1169. blockedProtocols: {
  1170. get: function () {
  1171. return this.templateRuleGetter({ outboundTag: "blocked", property: "protocol" });
  1172. },
  1173. set: function (newValue) {
  1174. this.templateRuleSetter({ outboundTag: "blocked", property: "protocol", data: newValue });
  1175. }
  1176. },
  1177. directIPs: {
  1178. get: function () {
  1179. return this.templateRuleGetter({ outboundTag: "direct", property: "ip" });
  1180. },
  1181. set: function (newValue) {
  1182. this.templateRuleSetter({ outboundTag: "direct", property: "ip", data: newValue });
  1183. this.syncRulesWithOutbound("direct", this.directSettings);
  1184. }
  1185. },
  1186. directDomains: {
  1187. get: function () {
  1188. return this.templateRuleGetter({ outboundTag: "direct", property: "domain" });
  1189. },
  1190. set: function (newValue) {
  1191. this.templateRuleSetter({ outboundTag: "direct", property: "domain", data: newValue });
  1192. this.syncRulesWithOutbound("direct", this.directSettings);
  1193. }
  1194. },
  1195. ipv4Domains: {
  1196. get: function () {
  1197. return this.templateRuleGetter({ outboundTag: "IPv4", property: "domain" });
  1198. },
  1199. set: function (newValue) {
  1200. this.templateRuleSetter({ outboundTag: "IPv4", property: "domain", data: newValue });
  1201. this.syncRulesWithOutbound("IPv4", this.ipv4Settings);
  1202. }
  1203. },
  1204. warpDomains: {
  1205. get: function () {
  1206. return this.templateRuleGetter({ outboundTag: "warp", property: "domain" });
  1207. },
  1208. set: function (newValue) {
  1209. this.templateRuleSetter({ outboundTag: "warp", property: "domain", data: newValue });
  1210. }
  1211. },
  1212. torrentSettings: {
  1213. get: function () {
  1214. return doAllItemsExist(this.settingsData.protocols.bittorrent, this.blockedProtocols);
  1215. },
  1216. set: function (newValue) {
  1217. if (newValue) {
  1218. this.blockedProtocols = [...this.blockedProtocols, ...this.settingsData.protocols.bittorrent];
  1219. } else {
  1220. this.blockedProtocols = this.blockedProtocols.filter(data => !this.settingsData.protocols.bittorrent.includes(data));
  1221. }
  1222. },
  1223. },
  1224. privateIpSettings: {
  1225. get: function () {
  1226. return doAllItemsExist(this.settingsData.ips.local, this.blockedIPs);
  1227. },
  1228. set: function (newValue) {
  1229. if (newValue) {
  1230. this.blockedIPs = [...this.blockedIPs, ...this.settingsData.ips.local];
  1231. } else {
  1232. this.blockedIPs = this.blockedIPs.filter(data => !this.settingsData.ips.local.includes(data));
  1233. }
  1234. },
  1235. },
  1236. AdsSettings: {
  1237. get: function () {
  1238. return doAllItemsExist(this.settingsData.domains.ads, this.blockedDomains);
  1239. },
  1240. set: function (newValue) {
  1241. if (newValue) {
  1242. this.blockedDomains = [...this.blockedDomains, ...this.settingsData.domains.ads];
  1243. } else {
  1244. this.blockedDomains = this.blockedDomains.filter(data => !this.settingsData.domains.ads.includes(data));
  1245. }
  1246. },
  1247. },
  1248. SecuritySettings: {
  1249. get: function () {
  1250. return doAllItemsExist(this.settingsData.domains.security, this.blockedDomains);
  1251. },
  1252. set: function (newValue) {
  1253. if (newValue) {
  1254. this.blockedDomains = [...this.blockedDomains, ...this.settingsData.domains.security];
  1255. } else {
  1256. this.blockedDomains = this.blockedDomains.filter(data => !this.settingsData.domains.security.includes(data));
  1257. }
  1258. },
  1259. },
  1260. SpeedTestSettings: {
  1261. get: function () {
  1262. return doAllItemsExist(this.settingsData.domains.speedtest, this.blockedDomains);
  1263. },
  1264. set: function (newValue) {
  1265. if (newValue) {
  1266. this.blockedDomains = [...this.blockedDomains, ...this.settingsData.domains.speedtest];
  1267. } else {
  1268. this.blockedDomains = this.blockedDomains.filter(data => !this.settingsData.domains.speedtest.includes(data));
  1269. }
  1270. },
  1271. },
  1272. familyProtectSettings: {
  1273. get: function () {
  1274. if (!this.templateSettings || !this.templateSettings.dns || !this.templateSettings.dns.servers) return false;
  1275. return doAllItemsExist(this.templateSettings.dns.servers, this.settingsData.familyProtectDNS.servers);
  1276. },
  1277. set: function (newValue) {
  1278. newTemplateSettings = this.templateSettings;
  1279. if (newValue) {
  1280. newTemplateSettings.dns = this.settingsData.familyProtectDNS;
  1281. } else {
  1282. delete newTemplateSettings.dns;
  1283. }
  1284. this.templateSettings = newTemplateSettings;
  1285. },
  1286. },
  1287. GoogleIPv4Settings: {
  1288. get: function () {
  1289. return doAllItemsExist(this.settingsData.domains.google, this.ipv4Domains);
  1290. },
  1291. set: function (newValue) {
  1292. if (newValue) {
  1293. this.ipv4Domains = [...this.ipv4Domains, ...this.settingsData.domains.google];
  1294. } else {
  1295. this.ipv4Domains = this.ipv4Domains.filter(data => !this.settingsData.domains.google.includes(data));
  1296. }
  1297. },
  1298. },
  1299. NetflixIPv4Settings: {
  1300. get: function () {
  1301. return doAllItemsExist(this.settingsData.domains.netflix, this.ipv4Domains);
  1302. },
  1303. set: function (newValue) {
  1304. if (newValue) {
  1305. this.ipv4Domains = [...this.ipv4Domains, ...this.settingsData.domains.netflix];
  1306. } else {
  1307. this.ipv4Domains = this.ipv4Domains.filter(data => !this.settingsData.domains.netflix.includes(data));
  1308. }
  1309. },
  1310. },
  1311. IRIpSettings: {
  1312. get: function () {
  1313. return doAllItemsExist(this.settingsData.ips.ir, this.blockedIPs);
  1314. },
  1315. set: function (newValue) {
  1316. if (newValue) {
  1317. this.blockedIPs = [...this.blockedIPs, ...this.settingsData.ips.ir];
  1318. } else {
  1319. this.blockedIPs = this.blockedIPs.filter(data => !this.settingsData.ips.ir.includes(data));
  1320. }
  1321. }
  1322. },
  1323. IRDomainSettings: {
  1324. get: function () {
  1325. return doAllItemsExist(this.settingsData.domains.ir, this.blockedDomains);
  1326. },
  1327. set: function (newValue) {
  1328. if (newValue) {
  1329. this.blockedDomains = [...this.blockedDomains, ...this.settingsData.domains.ir];
  1330. } else {
  1331. this.blockedDomains = this.blockedDomains.filter(data => !this.settingsData.domains.ir.includes(data));
  1332. }
  1333. }
  1334. },
  1335. ChinaIpSettings: {
  1336. get: function () {
  1337. return doAllItemsExist(this.settingsData.ips.cn, this.blockedIPs);
  1338. },
  1339. set: function (newValue) {
  1340. if (newValue) {
  1341. this.blockedIPs = [...this.blockedIPs, ...this.settingsData.ips.cn];
  1342. } else {
  1343. this.blockedIPs = this.blockedIPs.filter(data => !this.settingsData.ips.cn.includes(data));
  1344. }
  1345. }
  1346. },
  1347. ChinaDomainSettings: {
  1348. get: function () {
  1349. return doAllItemsExist(this.settingsData.domains.cn, this.blockedDomains);
  1350. },
  1351. set: function (newValue) {
  1352. if (newValue) {
  1353. this.blockedDomains = [...this.blockedDomains, ...this.settingsData.domains.cn];
  1354. } else {
  1355. this.blockedDomains = this.blockedDomains.filter(data => !this.settingsData.domains.cn.includes(data));
  1356. }
  1357. }
  1358. },
  1359. RussiaIpSettings: {
  1360. get: function () {
  1361. return doAllItemsExist(this.settingsData.ips.ru, this.blockedIPs);
  1362. },
  1363. set: function (newValue) {
  1364. if (newValue) {
  1365. this.blockedIPs = [...this.blockedIPs, ...this.settingsData.ips.ru];
  1366. } else {
  1367. this.blockedIPs = this.blockedIPs.filter(data => !this.settingsData.ips.ru.includes(data));
  1368. }
  1369. }
  1370. },
  1371. RussiaDomainSettings: {
  1372. get: function () {
  1373. return doAllItemsExist(this.settingsData.domains.ru, this.blockedDomains);
  1374. },
  1375. set: function (newValue) {
  1376. if (newValue) {
  1377. this.blockedDomains = [...this.blockedDomains, ...this.settingsData.domains.ru];
  1378. } else {
  1379. this.blockedDomains = this.blockedDomains.filter(data => !this.settingsData.domains.ru.includes(data));
  1380. }
  1381. }
  1382. },
  1383. VNIpSettings: {
  1384. get: function () {
  1385. return doAllItemsExist(this.settingsData.ips.vn, this.blockedIPs);
  1386. },
  1387. set: function (newValue) {
  1388. if (newValue) {
  1389. this.blockedIPs = [...this.blockedIPs, ...this.settingsData.ips.vn];
  1390. } else {
  1391. this.blockedIPs = this.blockedIPs.filter(data => !this.settingsData.ips.vn.includes(data));
  1392. }
  1393. }
  1394. },
  1395. VNDomainSettings: {
  1396. get: function () {
  1397. return doAllItemsExist(this.settingsData.domains.vn, this.blockedDomains);
  1398. },
  1399. set: function (newValue) {
  1400. if (newValue) {
  1401. this.blockedDomains = [...this.blockedDomains, ...this.settingsData.domains.vn];
  1402. } else {
  1403. this.blockedDomains = this.blockedDomains.filter(data => !this.settingsData.domains.vn.includes(data));
  1404. }
  1405. }
  1406. },
  1407. IRIpDirectSettings: {
  1408. get: function () {
  1409. return doAllItemsExist(this.settingsData.ips.ir, this.directIPs);
  1410. },
  1411. set: function (newValue) {
  1412. if (newValue) {
  1413. this.directIPs = [...this.directIPs, ...this.settingsData.ips.ir];
  1414. } else {
  1415. this.directIPs = this.directIPs.filter(data => !this.settingsData.ips.ir.includes(data));
  1416. }
  1417. }
  1418. },
  1419. IRDomainDirectSettings: {
  1420. get: function () {
  1421. return doAllItemsExist(this.settingsData.domains.ir, this.directDomains);
  1422. },
  1423. set: function (newValue) {
  1424. if (newValue) {
  1425. this.directDomains = [...this.directDomains, ...this.settingsData.domains.ir];
  1426. } else {
  1427. this.directDomains = this.directDomains.filter(data => !this.settingsData.domains.ir.includes(data));
  1428. }
  1429. }
  1430. },
  1431. ChinaIpDirectSettings: {
  1432. get: function () {
  1433. return doAllItemsExist(this.settingsData.ips.cn, this.directIPs);
  1434. },
  1435. set: function (newValue) {
  1436. if (newValue) {
  1437. this.directIPs = [...this.directIPs, ...this.settingsData.ips.cn];
  1438. } else {
  1439. this.directIPs = this.directIPs.filter(data => !this.settingsData.ips.cn.includes(data));
  1440. }
  1441. }
  1442. },
  1443. ChinaDomainDirectSettings: {
  1444. get: function () {
  1445. return doAllItemsExist(this.settingsData.domains.cn, this.directDomains);
  1446. },
  1447. set: function (newValue) {
  1448. if (newValue) {
  1449. this.directDomains = [...this.directDomains, ...this.settingsData.domains.cn];
  1450. } else {
  1451. this.directDomains = this.directDomains.filter(data => !this.settingsData.domains.cn.includes(data));
  1452. }
  1453. }
  1454. },
  1455. RussiaIpDirectSettings: {
  1456. get: function () {
  1457. return doAllItemsExist(this.settingsData.ips.ru, this.directIPs);
  1458. },
  1459. set: function (newValue) {
  1460. if (newValue) {
  1461. this.directIPs = [...this.directIPs, ...this.settingsData.ips.ru];
  1462. } else {
  1463. this.directIPs = this.directIPs.filter(data => !this.settingsData.ips.ru.includes(data));
  1464. }
  1465. }
  1466. },
  1467. RussiaDomainDirectSettings: {
  1468. get: function () {
  1469. return doAllItemsExist(this.settingsData.domains.ru, this.directDomains);
  1470. },
  1471. set: function (newValue) {
  1472. if (newValue) {
  1473. this.directDomains = [...this.directDomains, ...this.settingsData.domains.ru];
  1474. } else {
  1475. this.directDomains = this.directDomains.filter(data => !this.settingsData.domains.ru.includes(data));
  1476. }
  1477. }
  1478. },
  1479. VNIpDirectSettings: {
  1480. get: function () {
  1481. return doAllItemsExist(this.settingsData.ips.vn, this.directIPs);
  1482. },
  1483. set: function (newValue) {
  1484. if (newValue) {
  1485. this.directIPs = [...this.directIPs, ...this.settingsData.ips.vn];
  1486. } else {
  1487. this.directIPs = this.directIPs.filter(data => !this.settingsData.ips.vn.includes(data));
  1488. }
  1489. }
  1490. },
  1491. VNDomainDirectSettings: {
  1492. get: function () {
  1493. return doAllItemsExist(this.settingsData.domains.vn, this.directDomains);
  1494. },
  1495. set: function (newValue) {
  1496. if (newValue) {
  1497. this.directDomains = [...this.directDomains, ...this.settingsData.domains.vn];
  1498. } else {
  1499. this.directDomains = this.directDomains.filter(data => !this.settingsData.domains.vn.includes(data));
  1500. }
  1501. }
  1502. },
  1503. WarpExist: {
  1504. get: function() {
  1505. return this.templateSettings ? this.templateSettings.outbounds.findIndex((o) => o.tag == "warp")>=0 : false;
  1506. },
  1507. },
  1508. GoogleWARPSettings: {
  1509. get: function () {
  1510. return doAllItemsExist(this.settingsData.domains.google, this.warpDomains);
  1511. },
  1512. set: function (newValue) {
  1513. if (newValue) {
  1514. this.warpDomains = [...this.warpDomains, ...this.settingsData.domains.google];
  1515. } else {
  1516. this.warpDomains = this.warpDomains.filter(data => !this.settingsData.domains.google.includes(data));
  1517. }
  1518. },
  1519. },
  1520. OpenAIWARPSettings: {
  1521. get: function () {
  1522. return doAllItemsExist(this.settingsData.domains.openai, this.warpDomains);
  1523. },
  1524. set: function (newValue) {
  1525. if (newValue) {
  1526. this.warpDomains = [...this.warpDomains, ...this.settingsData.domains.openai];
  1527. } else {
  1528. this.warpDomains = this.warpDomains.filter(data => !this.settingsData.domains.openai.includes(data));
  1529. }
  1530. },
  1531. },
  1532. NetflixWARPSettings: {
  1533. get: function () {
  1534. return doAllItemsExist(this.settingsData.domains.netflix, this.warpDomains);
  1535. },
  1536. set: function (newValue) {
  1537. if (newValue) {
  1538. this.warpDomains = [...this.warpDomains, ...this.settingsData.domains.netflix];
  1539. } else {
  1540. this.warpDomains = this.warpDomains.filter(data => !this.settingsData.domains.netflix.includes(data));
  1541. }
  1542. },
  1543. },
  1544. SpotifyWARPSettings: {
  1545. get: function () {
  1546. return doAllItemsExist(this.settingsData.domains.spotify, this.warpDomains);
  1547. },
  1548. set: function (newValue) {
  1549. if (newValue) {
  1550. this.warpDomains = [...this.warpDomains, ...this.settingsData.domains.spotify];
  1551. } else {
  1552. this.warpDomains = this.warpDomains.filter(data => !this.settingsData.domains.spotify.includes(data));
  1553. }
  1554. },
  1555. },
  1556. },
  1557. });
  1558. </script>
  1559. </body>
  1560. </html>