xray.html 83 KB

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