xray.html 83 KB

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