setting.html 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. {{template "head" .}}
  4. <style>
  5. @media (min-width: 769px) {
  6. .ant-layout-content {
  7. margin: 24px 16px;
  8. }
  9. }
  10. .ant-col-sm-24 {
  11. margin-top: 10px;
  12. }
  13. .ant-tabs-bar {
  14. margin: 0;
  15. }
  16. .ant-list-item {
  17. display: block;
  18. }
  19. :not(.ant-card-dark)>.ant-tabs-top-bar {
  20. background: white;
  21. }
  22. </style>
  23. <body>
  24. <a-layout id="app" v-cloak>
  25. {{ template "commonSider" . }}
  26. <a-layout id="content-layout" :style="siderDrawer.isDarkTheme ? bgDarkStyle : ''">
  27. <a-layout-content>
  28. <a-spin :spinning="spinning" :delay="500" tip="loading">
  29. <a-space direction="vertical">
  30. <a-space direction="horizontal">
  31. <a-button type="primary" :disabled="saveBtnDisable" @click="updateAllSetting">{{ i18n "pages.setting.save" }}</a-button>
  32. <a-button type="danger" :disabled="!saveBtnDisable" @click="restartPanel">{{ i18n "pages.setting.restartPanel" }}</a-button>
  33. </a-space>
  34. <a-tabs default-active-key="1" :class="siderDrawer.isDarkTheme ? darkClass : ''">
  35. <a-tab-pane key="1" tab='{{ i18n "pages.setting.panelConfig"}}'>
  36. <a-list item-layout="horizontal" :style="siderDrawer.isDarkTheme ? 'color: hsla(0,0%,100%,.65);': 'background: white;'">
  37. <setting-list-item type="text" title='{{ i18n "pages.setting.panelListeningIP"}}' desc='{{ i18n "pages.setting.panelListeningIPDesc"}}' v-model="allSetting.webListen"></setting-list-item>
  38. <setting-list-item type="number" title='{{ i18n "pages.setting.panelPort"}}' desc='{{ i18n "pages.setting.panelPortDesc"}}' v-model.number="allSetting.webPort"></setting-list-item>
  39. <setting-list-item type="text" title='{{ i18n "pages.setting.publicKeyPath"}}' desc='{{ i18n "pages.setting.publicKeyPathDesc"}}' v-model="allSetting.webCertFile"></setting-list-item>
  40. <setting-list-item type="text" title='{{ i18n "pages.setting.privateKeyPath"}}' desc='{{ i18n "pages.setting.privateKeyPathDesc"}}' v-model="allSetting.webKeyFile"></setting-list-item>
  41. <setting-list-item type="text" title='{{ i18n "pages.setting.panelUrlPath"}}' desc='{{ i18n "pages.setting.panelUrlPathDesc"}}' v-model="allSetting.webBasePath"></setting-list-item>
  42. <setting-list-item type="number" title='{{ i18n "pages.setting.expireTimeDiff" }}' desc='{{ i18n "pages.setting.expireTimeDiffDesc" }}' v-model="allSetting.expireDiff" :min="0"></setting-list-item>
  43. <setting-list-item type="number" title='{{ i18n "pages.setting.trafficDiff" }}' desc='{{ i18n "pages.setting.trafficDiffDesc" }}' v-model="allSetting.trafficDiff" :min="0"></setting-list-item>
  44. <a-list-item>
  45. <a-row style="padding: 20px">
  46. <a-col :lg="24" :xl="12">
  47. <a-list-item-meta title="Language" />
  48. </a-col>
  49. <a-col :lg="24" :xl="12">
  50. <template>
  51. <a-select
  52. ref="selectLang"
  53. v-model="lang"
  54. @change="setLang(lang)"
  55. :dropdown-class-name="siderDrawer.isDarkTheme ? 'ant-card-dark' : ''"
  56. style="width: 100%"
  57. >
  58. <a-select-option :value="l.value" :label="l.value" v-for="l in supportLangs">
  59. <span role="img" aria-label="l.name" v-text="l.icon"></span>&nbsp;&nbsp;<span v-text="l.name"></span>
  60. </a-select-option>
  61. </a-select>
  62. </template>
  63. </a-col>
  64. </a-row>
  65. </a-list-item>
  66. </a-list>
  67. </a-tab-pane>
  68. <a-tab-pane key="2" tab='{{ i18n "pages.setting.userSetting"}}'>
  69. <a-form :style="siderDrawer.isDarkTheme ? 'color: hsla(0,0%,100%,.65); padding: 20px;': 'background: white; padding: 20px;'">
  70. <a-form-item label='{{ i18n "pages.setting.oldUsername"}}'>
  71. <a-input v-model="user.oldUsername" style="max-width: 300px"></a-input>
  72. </a-form-item>
  73. <a-form-item label='{{ i18n "pages.setting.currentPassword"}}'>
  74. <a-input type="password" v-model="user.oldPassword" style="max-width: 300px"></a-input>
  75. </a-form-item>
  76. <a-form-item label='{{ i18n "pages.setting.newUsername"}}'>
  77. <a-input v-model="user.newUsername" style="max-width: 300px"></a-input>
  78. </a-form-item>
  79. <a-form-item label='{{ i18n "pages.setting.newPassword"}}'>
  80. <a-input type="password" v-model="user.newPassword" style="max-width: 300px"></a-input>
  81. </a-form-item>
  82. <a-form-item>
  83. <a-button type="primary" @click="updateUser">{{ i18n "confirm" }}</a-button>
  84. </a-form-item>
  85. </a-form>
  86. </a-tab-pane>
  87. <a-tab-pane key="3" tab='{{ i18n "pages.setting.xrayConfiguration"}}'>
  88. <a-list item-layout="horizontal" :style="siderDrawer.isDarkTheme ? 'color: hsla(0,0%,100%,.65);': 'background: white;'">
  89. <a-divider>{{ i18n "pages.setting.generalConfigs"}}</a-divider>
  90. <setting-list-item type="switch" title='{{ i18n "pages.setting.xrayConfigTorrent"}}' desc='{{ i18n "pages.setting.xrayConfigTorrentDesc"}}' v-model="torrentSettings"></setting-list-item>
  91. <setting-list-item type="switch" title='{{ i18n "pages.setting.xrayConfigPrivateIp"}}' desc='{{ i18n "pages.setting.xrayConfigPrivateIpDesc"}}' v-model="privateIpSettings"></setting-list-item>
  92. <setting-list-item type="switch" title='{{ i18n "pages.setting.xrayConfigAds"}}' desc='{{ i18n "pages.setting.xrayConfigAdsDesc"}}' v-model="AdsSettings"></setting-list-item>
  93. <setting-list-item type="switch" title='{{ i18n "pages.setting.xrayConfigPorn"}}' desc='{{ i18n "pages.setting.xrayConfigPornDesc"}}' v-model="PornSettings"></setting-list-item>
  94. <a-divider>{{ i18n "pages.setting.countryConfigs"}}</a-divider>
  95. <setting-list-item type="switch" title='{{ i18n "pages.setting.xrayConfigIRIp"}}' desc='{{ i18n "pages.setting.xrayConfigIRIpDesc"}}' v-model="IRIpSettings"></setting-list-item>
  96. <setting-list-item type="switch" title='{{ i18n "pages.setting.xrayConfigIRDomain"}}' desc='{{ i18n "pages.setting.xrayConfigIRDomainDesc"}}' v-model="IRDomainSettings"></setting-list-item>
  97. <setting-list-item type="switch" title='{{ i18n "pages.setting.xrayConfigChinaIp"}}' desc='{{ i18n "pages.setting.xrayConfigChinaIpDesc"}}' v-model="ChinaIpSettings"></setting-list-item>
  98. <setting-list-item type="switch" title='{{ i18n "pages.setting.xrayConfigChinaDomain"}}' desc='{{ i18n "pages.setting.xrayConfigChinaDomainDesc"}}' v-model="ChinaDomainSettings"></setting-list-item>
  99. <a-divider>{{ i18n "pages.setting.ipv4Configs"}}</a-divider>
  100. <setting-list-item type="switch" title='{{ i18n "pages.setting.xrayConfigGoogleIPv4"}}' desc='{{ i18n "pages.setting.xrayConfigGoogleIPv4Desc"}}' v-model="GoogleIPv4Settings"></setting-list-item>
  101. <setting-list-item type="switch" title='{{ i18n "pages.setting.xrayConfigNetflixIPv4"}}' desc='{{ i18n "pages.setting.xrayConfigNetflixIPv4Desc"}}' v-model="NetflixIPv4Settings"></setting-list-item>
  102. <a-divider>{{ i18n "pages.setting.warpConfigs"}}</a-divider>
  103. <setting-list-item type="switch" title='{{ i18n "pages.setting.xrayConfigGoogleWARP"}}' desc='{{ i18n "pages.setting.xrayConfigGoogleWARPDesc"}}' v-model="GoogleWARPSettings"></setting-list-item>
  104. <setting-list-item type="switch" title='{{ i18n "pages.setting.xrayConfigOpenAIWARP"}}' desc='{{ i18n "pages.setting.xrayConfigOpenAIWARPDesc"}}' v-model="OpenAIWARPSettings"></setting-list-item>
  105. <setting-list-item type="switch" title='{{ i18n "pages.setting.xrayConfigNetflixWARP"}}' desc='{{ i18n "pages.setting.xrayConfigNetflixWARPDesc"}}' v-model="NetflixWARPSettings"></setting-list-item>
  106. <setting-list-item type="switch" title='{{ i18n "pages.setting.xrayConfigSpotifyWARP"}}' desc='{{ i18n "pages.setting.xrayConfigSpotifyWARPDesc"}}' v-model="SpotifyWARPSettings"></setting-list-item>
  107. <setting-list-item type="switch" title='{{ i18n "pages.setting.xrayConfigIRWARP"}}' desc='{{ i18n "pages.setting.xrayConfigIRWARPDesc"}}' v-model="IRWARPSettings"></setting-list-item>
  108. <a-divider>{{ i18n "pages.setting.advancedTemplate"}}</a-divider>
  109. <a-collapse>
  110. <a-collapse-panel header='{{ i18n "pages.setting.xrayConfigInbounds"}}'>
  111. <setting-list-item type="textarea" title='{{ i18n "pages.setting.xrayConfigInbounds"}}' desc='{{ i18n "pages.setting.xrayConfigInboundsDesc"}}' v-model="inboundSettings"></setting-list-item>
  112. </a-collapse-panel>
  113. <a-collapse-panel header='{{ i18n "pages.setting.xrayConfigOutbounds"}}'>
  114. <setting-list-item type="textarea" title='{{ i18n "pages.setting.xrayConfigOutbounds"}}' desc='{{ i18n "pages.setting.xrayConfigOutboundsDesc"}}' v-model="outboundSettings"></setting-list-item>
  115. </a-collapse-panel>
  116. <a-collapse-panel header='{{ i18n "pages.setting.xrayConfigRoutings"}}'>
  117. <setting-list-item type="textarea" title='{{ i18n "pages.setting.xrayConfigRoutings"}}' desc='{{ i18n "pages.setting.xrayConfigRoutingsDesc"}}' v-model="routingRuleSettings"></setting-list-item>
  118. </a-collapse-panel>
  119. </a-collapse>
  120. <a-divider>{{ i18n "pages.setting.completeTemplate"}}</a-divider>
  121. <setting-list-item type="textarea" title='{{ i18n "pages.setting.xrayConfigTemplate"}}' desc='{{ i18n "pages.setting.xrayConfigTemplateDesc"}}' v-model="allSetting.xrayTemplateConfig"></setting-list-item>
  122. </a-list>
  123. </a-tab-pane>
  124. <a-tab-pane key="4" tab='{{ i18n "pages.setting.TGReminder"}}'>
  125. <a-list item-layout="horizontal" :style="siderDrawer.isDarkTheme ? 'color: hsla(0,0%,100%,.65);': 'background: white;'">
  126. <setting-list-item type="switch" title='{{ i18n "pages.setting.telegramBotEnable" }}' desc='{{ i18n "pages.setting.telegramBotEnableDesc" }}' v-model="allSetting.tgBotEnable"></setting-list-item>
  127. <setting-list-item type="text" title='{{ i18n "pages.setting.telegramToken"}}' desc='{{ i18n "pages.setting.telegramTokenDesc"}}' v-model="allSetting.tgBotToken"></setting-list-item>
  128. <setting-list-item type="text" title='{{ i18n "pages.setting.telegramChatId"}}' desc='{{ i18n "pages.setting.telegramChatIdDesc"}}' v-model="allSetting.tgBotChatId"></setting-list-item>
  129. <setting-list-item type="text" title='{{ i18n "pages.setting.telegramNotifyTime"}}' desc='{{ i18n "pages.setting.telegramNotifyTimeDesc"}}' v-model="allSetting.tgRunTime"></setting-list-item>
  130. <setting-list-item type="switch" title='{{ i18n "pages.setting.tgNotifyBackup" }}' desc='{{ i18n "pages.setting.tgNotifyBackupDesc" }}' v-model="allSetting.tgBotBackup"></setting-list-item>
  131. <setting-list-item type="number" title='{{ i18n "pages.setting.tgNotifyCpu" }}' desc='{{ i18n "pages.setting.tgNotifyCpuDesc" }}' v-model="allSetting.tgCpu" :min="0" :max="100"></setting-list-item>
  132. </a-list>
  133. </a-tab-pane>
  134. <a-tab-pane key="5" tab='{{ i18n "pages.setting.otherSetting"}}'>
  135. <a-list item-layout="horizontal" :style="siderDrawer.isDarkTheme ? 'color: hsla(0,0%,100%,.65);': 'background: white;'">
  136. <setting-list-item type="text" title='{{ i18n "pages.setting.timeZonee"}}' desc='{{ i18n "pages.setting.timeZoneDesc"}}' v-model="allSetting.timeLocation"></setting-list-item>
  137. </a-list>
  138. </a-tab-pane>
  139. </a-tabs>
  140. </a-space>
  141. </a-spin>
  142. </a-layout-content>
  143. </a-layout>
  144. </a-layout>
  145. {{template "js" .}}
  146. {{template "component/setting"}}
  147. <script>
  148. const app = new Vue({
  149. delimiters: ['[[', ']]'],
  150. el: '#app',
  151. data: {
  152. siderDrawer,
  153. spinning: false,
  154. oldAllSetting: new AllSetting(),
  155. allSetting: new AllSetting(),
  156. saveBtnDisable: true,
  157. user: {},
  158. lang: getLang(),
  159. ipv4Settings: {
  160. tag: "IPv4",
  161. protocol: "freedom",
  162. settings: {
  163. domainStrategy: "UseIPv4"
  164. }
  165. },
  166. warpSettings: {
  167. tag: "WARP",
  168. protocol: "socks",
  169. settings: {
  170. servers: [
  171. {
  172. address: "127.0.0.1",
  173. port: 40000
  174. }
  175. ]
  176. }
  177. },
  178. settingsData: {
  179. protocols: {
  180. bittorrent: ["bittorrent"],
  181. },
  182. ips: {
  183. local: ["geoip:private"],
  184. google: ["geoip:google"],
  185. cn: ["geoip:cn"],
  186. ir: ["geoip:ir"],
  187. },
  188. domains: {
  189. ads: [
  190. "geosite:category-ads-all",
  191. "geosite:category-ads",
  192. "geosite:google-ads",
  193. "geosite:spotify-ads"
  194. ],
  195. porn: ["geosite:category-porn"],
  196. openai: ["geosite:openai"],
  197. google: ["geosite:google"],
  198. spotify: ["geosite:spotify"],
  199. netflix: ["geosite:netflix"],
  200. cn: ["geosite:cn"],
  201. ir: [
  202. "regexp:.*\\.ir$",
  203. "ext:iran.dat:ir",
  204. "ext:iran.dat:other",
  205. "geosite:category-ir",
  206. "bank",
  207. "tapsi",
  208. "snapp",
  209. "blogfa",
  210. "digikala",
  211. "Torob.com",
  212. "sheypoor.com",
  213. "Tgju.org",
  214. "sb24.com",
  215. "tebyan.net",
  216. "beytoote.com",
  217. "telewebion.com",
  218. "Film2movie.ws",
  219. "Setare.com",
  220. "Filimo.com",
  221. "downloadha.com",
  222. "P30download.com",
  223. "Sarzamindownload.com",
  224. "Sanjesh.org"
  225. ]
  226. },
  227. }
  228. },
  229. methods: {
  230. loading(spinning = true) {
  231. this.spinning = spinning;
  232. },
  233. async getAllSetting() {
  234. this.loading(true);
  235. const msg = await HttpUtil.post("/xui/setting/all");
  236. this.loading(false);
  237. if (msg.success) {
  238. this.oldAllSetting = new AllSetting(msg.obj);
  239. this.allSetting = new AllSetting(msg.obj);
  240. this.saveBtnDisable = true;
  241. }
  242. },
  243. async updateAllSetting() {
  244. this.loading(true);
  245. const msg = await HttpUtil.post("/xui/setting/update", this.allSetting);
  246. this.loading(false);
  247. if (msg.success) {
  248. await this.getAllSetting();
  249. }
  250. },
  251. async updateUser() {
  252. this.loading(true);
  253. const msg = await HttpUtil.post("/xui/setting/updateUser", this.user);
  254. this.loading(false);
  255. if (msg.success) {
  256. this.user = {};
  257. }
  258. },
  259. async restartPanel() {
  260. await new Promise(resolve => {
  261. this.$confirm({
  262. title: '{{ i18n "pages.setting.restartPanel" }}',
  263. content: '{{ i18n "pages.setting.restartPanelDesc" }}',
  264. okText: '{{ i18n "sure" }}',
  265. cancelText: '{{ i18n "cancel" }}',
  266. onOk: () => resolve(),
  267. });
  268. });
  269. this.loading(true);
  270. const msg = await HttpUtil.post("/xui/setting/restartPanel");
  271. this.loading(false);
  272. if (msg.success) {
  273. this.loading(true);
  274. await PromiseUtil.sleep(5000);
  275. location.reload();
  276. }
  277. }
  278. },
  279. async mounted() {
  280. await this.getAllSetting();
  281. while (true) {
  282. await PromiseUtil.sleep(1000);
  283. this.saveBtnDisable = this.oldAllSetting.equals(this.allSetting);
  284. }
  285. },
  286. computed: {
  287. templateSettings: {
  288. get: function () { return this.allSetting.xrayTemplateConfig ? JSON.parse(this.allSetting.xrayTemplateConfig) : null ; },
  289. set: function (newValue) { this.allSetting.xrayTemplateConfig = JSON.stringify(newValue, null, 2) },
  290. },
  291. inboundSettings: {
  292. get: function () { return this.templateSettings ? JSON.stringify(this.templateSettings.inbounds, null, 2) : null; },
  293. set: function (newValue) {
  294. newTemplateSettings = this.templateSettings;
  295. newTemplateSettings.inbounds = JSON.parse(newValue)
  296. this.templateSettings = newTemplateSettings
  297. },
  298. },
  299. outboundSettings: {
  300. get: function () { return this.templateSettings ? JSON.stringify(this.templateSettings.outbounds, null, 2) : null; },
  301. set: function (newValue) {
  302. newTemplateSettings = this.templateSettings;
  303. newTemplateSettings.outbounds = JSON.parse(newValue)
  304. this.templateSettings = newTemplateSettings
  305. },
  306. },
  307. routingRuleSettings: {
  308. get: function () { return this.templateSettings ? JSON.stringify(this.templateSettings.routing.rules, null, 2) : null; },
  309. set: function (newValue) {
  310. newTemplateSettings = this.templateSettings;
  311. newTemplateSettings.routing.rules = JSON.parse(newValue)
  312. this.templateSettings = newTemplateSettings
  313. },
  314. },
  315. torrentSettings: {
  316. get: function () {
  317. torrentFilter = false
  318. if(this.templateSettings != null){
  319. this.templateSettings.routing.rules.forEach(routingRule => {
  320. if(routingRule.hasOwnProperty("protocol")){
  321. if (routingRule.protocol[0] === "bittorrent" && routingRule.outboundTag == "blocked"){
  322. torrentFilter = true
  323. }
  324. }
  325. });
  326. }
  327. return torrentFilter
  328. },
  329. set: function (newValue) {
  330. newTemplateSettings = JSON.parse(this.allSetting.xrayTemplateConfig);
  331. if (newValue){
  332. newTemplateSettings.routing.rules.push(JSON.parse("{\"outboundTag\": \"blocked\",\"protocol\": [\"bittorrent\"],\"type\": \"field\"}"))
  333. }
  334. else {
  335. newTemplateSettings.routing.rules = [];
  336. this.templateSettings.routing.rules.forEach(routingRule => {
  337. if (routingRule.hasOwnProperty('protocol')){
  338. if (routingRule.protocol[0] === "bittorrent" && routingRule.outboundTag == "blocked"){
  339. return;
  340. }
  341. }
  342. newTemplateSettings.routing.rules.push(routingRule);
  343. });
  344. }
  345. this.templateSettings = newTemplateSettings
  346. },
  347. },
  348. privateIpSettings: {
  349. get: function () {
  350. localIpFilter = false
  351. if(this.templateSettings != null){
  352. this.templateSettings.routing.rules.forEach(routingRule => {
  353. if(routingRule.hasOwnProperty("ip")){
  354. if (routingRule.ip[0] === "geoip:private" && routingRule.outboundTag == "blocked"){
  355. localIpFilter = true
  356. }
  357. }
  358. });
  359. }
  360. return localIpFilter
  361. },
  362. set: function (newValue) {
  363. newTemplateSettings = JSON.parse(this.allSetting.xrayTemplateConfig);
  364. if (newValue){
  365. newTemplateSettings.routing.rules.push(JSON.parse("{\"outboundTag\": \"blocked\",\"ip\": [\"geoip:private\"],\"type\": \"field\"}"))
  366. }
  367. else {
  368. newTemplateSettings.routing.rules = [];
  369. this.templateSettings.routing.rules.forEach(routingRule => {
  370. if (routingRule.hasOwnProperty('ip')){
  371. if (routingRule.ip[0] === "geoip:private" && routingRule.outboundTag == "blocked"){
  372. return;
  373. }
  374. }
  375. newTemplateSettings.routing.rules.push(routingRule);
  376. });
  377. }
  378. this.templateSettings = newTemplateSettings
  379. },
  380. },
  381. IRIpSettings: {
  382. get: function () {
  383. localIpFilter = false
  384. if(this.templateSettings != null){
  385. this.templateSettings.routing.rules.forEach(routingRule => {
  386. if(routingRule.hasOwnProperty("ip")){
  387. if (routingRule.ip[0] === "geoip:ir" && routingRule.outboundTag == "blocked"){
  388. localIpFilter = true
  389. }
  390. }
  391. });
  392. }
  393. return localIpFilter
  394. },
  395. set: function (newValue) {
  396. newTemplateSettings = JSON.parse(this.allSetting.xrayTemplateConfig);
  397. if (newValue){
  398. newTemplateSettings.routing.rules.push(JSON.parse("{\"outboundTag\": \"blocked\",\"ip\": [\"geoip:ir\"],\"type\": \"field\"}"))
  399. }
  400. else {
  401. newTemplateSettings.routing.rules = [];
  402. this.templateSettings.routing.rules.forEach(routingRule => {
  403. if (routingRule.hasOwnProperty('ip')){
  404. if (routingRule.ip[0] === "geoip:ir" && routingRule.outboundTag == "blocked"){
  405. return;
  406. }
  407. }
  408. newTemplateSettings.routing.rules.push(routingRule);
  409. });
  410. }
  411. this.templateSettings = newTemplateSettings
  412. },
  413. },
  414. IRdomainSettings: {
  415. get: function () {
  416. localdomainFilter = false
  417. if(this.templateSettings != null){
  418. this.templateSettings.routing.rules.forEach(routingRule => {
  419. if(routingRule.hasOwnProperty("domain")){
  420. if ((routingRule.domain[0] === "regexp:.+.ir$" || routingRule.domain[0] === "ext:iran.dat:ir" || routingRule.domain[0] === "ext:iran.dat:other") && routingRule.outboundTag == "blocked") {
  421. localdomainFilter = true
  422. }
  423. }
  424. });
  425. }
  426. return localdomainFilter
  427. },
  428. set: function (newValue) {
  429. newTemplateSettings = JSON.parse(this.allSetting.xrayTemplateConfig);
  430. if (newValue){
  431. newTemplateSettings.routing.rules.push(JSON.parse("{\"outboundTag\": \"blocked\",\"domain\": [\"regexp:.+.ir$\", \"ext:iran.dat:ir\", \"ext:iran.dat:other\"],\"type\": \"field\"}"))
  432. }
  433. else {
  434. newTemplateSettings.routing.rules = [];
  435. this.templateSettings.routing.rules.forEach(routingRule => {
  436. if (routingRule.hasOwnProperty('domain')){
  437. if ((routingRule.domain[0] === "regexp:.+.ir$" || routingRule.domain[0] === "ext:iran.dat:ir" || routingRule.domain[0] === "ext:iran.dat:other") && routingRule.outboundTag == "blocked"){
  438. return;
  439. }
  440. }
  441. newTemplateSettings.routing.rules.push(routingRule);
  442. });
  443. }
  444. this.templateSettings = newTemplateSettings
  445. },
  446. },
  447. }
  448. });
  449. </script>
  450. </body>
  451. </html>