setting.html 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532
  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. checkRequiredOutbounds() {
  279. const newTemplateSettings = this.templateSettings;
  280. const haveIPv4Outbounds = newTemplateSettings.outbounds.some((o) => o?.tag === "IPv4");
  281. const haveIPv4Rules = newTemplateSettings.routing.rules.some((r) => r?.outboundTag === "IPv4");
  282. const haveWARPOutbounds = newTemplateSettings.outbounds.some((o) => o?.tag === "WARP");
  283. const haveWARPRules = newTemplateSettings.routing.rules.some((r) => r?.outboundTag === "WARP");
  284. if (haveWARPRules && !haveWARPOutbounds) {
  285. newTemplateSettings.outbounds.push(this.warpSettings);
  286. }
  287. if (haveIPv4Rules && !haveIPv4Outbounds) {
  288. newTemplateSettings.outbounds.push(this.ipv4Settings);
  289. }
  290. this.templateSettings = newTemplateSettings;
  291. },
  292. templateRuleGetter(routeSettings) {
  293. const { data, property, outboundTag } = routeSettings;
  294. let result = false;
  295. if (this.templateSettings != null) {
  296. this.templateSettings.routing.rules.forEach(
  297. (routingRule) => {
  298. if (
  299. routingRule.hasOwnProperty(property) &&
  300. routingRule.hasOwnProperty("outboundTag") &&
  301. routingRule.outboundTag === outboundTag
  302. ) {
  303. if (data.includes(routingRule[property][0])) {
  304. result = true;
  305. }
  306. }
  307. }
  308. );
  309. }
  310. return result;
  311. },
  312. templateRuleSetter(routeSettings) {
  313. const { newValue, data, property, outboundTag } = routeSettings;
  314. const oldTemplateSettings = this.templateSettings;
  315. const newTemplateSettings = oldTemplateSettings;
  316. if (newValue) {
  317. const propertyRule = {
  318. type: "field",
  319. outboundTag,
  320. [property]: data
  321. };
  322. newTemplateSettings.routing.rules.push(propertyRule);
  323. }
  324. else {
  325. const newRules = [];
  326. newTemplateSettings.routing.rules.forEach(
  327. (routingRule) => {
  328. if (
  329. routingRule.hasOwnProperty(property) &&
  330. routingRule.hasOwnProperty("outboundTag") &&
  331. routingRule.outboundTag === outboundTag
  332. ) {
  333. if (data.includes(routingRule[property][0])) {
  334. return;
  335. }
  336. }
  337. newRules.push(routingRule);
  338. }
  339. );
  340. newTemplateSettings.routing.rules = newRules;
  341. }
  342. this.templateSettings = newTemplateSettings;
  343. this.checkRequiredOutbounds();
  344. }
  345. },
  346. async mounted() {
  347. await this.getAllSetting();
  348. while (true) {
  349. await PromiseUtil.sleep(1000);
  350. this.saveBtnDisable = this.oldAllSetting.equals(this.allSetting);
  351. }
  352. },
  353. computed: {
  354. templateSettings: {
  355. get: function () { return this.allSetting.xrayTemplateConfig ? JSON.parse(this.allSetting.xrayTemplateConfig) : null ; },
  356. set: function (newValue) { this.allSetting.xrayTemplateConfig = JSON.stringify(newValue, null, 2) },
  357. },
  358. inboundSettings: {
  359. get: function () { return this.templateSettings ? JSON.stringify(this.templateSettings.inbounds, null, 2) : null; },
  360. set: function (newValue) {
  361. newTemplateSettings = this.templateSettings;
  362. newTemplateSettings.inbounds = JSON.parse(newValue)
  363. this.templateSettings = newTemplateSettings
  364. },
  365. },
  366. outboundSettings: {
  367. get: function () { return this.templateSettings ? JSON.stringify(this.templateSettings.outbounds, null, 2) : null; },
  368. set: function (newValue) {
  369. newTemplateSettings = this.templateSettings;
  370. newTemplateSettings.outbounds = JSON.parse(newValue)
  371. this.templateSettings = newTemplateSettings
  372. },
  373. },
  374. routingRuleSettings: {
  375. get: function () { return this.templateSettings ? JSON.stringify(this.templateSettings.routing.rules, null, 2) : null; },
  376. set: function (newValue) {
  377. newTemplateSettings = this.templateSettings;
  378. newTemplateSettings.routing.rules = JSON.parse(newValue)
  379. this.templateSettings = newTemplateSettings
  380. },
  381. },
  382. torrentSettings: {
  383. get: function () {
  384. torrentFilter = false
  385. if(this.templateSettings != null){
  386. this.templateSettings.routing.rules.forEach(routingRule => {
  387. if(routingRule.hasOwnProperty("protocol")){
  388. if (routingRule.protocol[0] === "bittorrent" && routingRule.outboundTag == "blocked"){
  389. torrentFilter = true
  390. }
  391. }
  392. });
  393. }
  394. return torrentFilter
  395. },
  396. set: function (newValue) {
  397. newTemplateSettings = JSON.parse(this.allSetting.xrayTemplateConfig);
  398. if (newValue){
  399. newTemplateSettings.routing.rules.push(JSON.parse("{\"outboundTag\": \"blocked\",\"protocol\": [\"bittorrent\"],\"type\": \"field\"}"))
  400. }
  401. else {
  402. newTemplateSettings.routing.rules = [];
  403. this.templateSettings.routing.rules.forEach(routingRule => {
  404. if (routingRule.hasOwnProperty('protocol')){
  405. if (routingRule.protocol[0] === "bittorrent" && routingRule.outboundTag == "blocked"){
  406. return;
  407. }
  408. }
  409. newTemplateSettings.routing.rules.push(routingRule);
  410. });
  411. }
  412. this.templateSettings = newTemplateSettings
  413. },
  414. },
  415. privateIpSettings: {
  416. get: function () {
  417. localIpFilter = false
  418. if(this.templateSettings != null){
  419. this.templateSettings.routing.rules.forEach(routingRule => {
  420. if(routingRule.hasOwnProperty("ip")){
  421. if (routingRule.ip[0] === "geoip:private" && routingRule.outboundTag == "blocked"){
  422. localIpFilter = true
  423. }
  424. }
  425. });
  426. }
  427. return localIpFilter
  428. },
  429. set: function (newValue) {
  430. newTemplateSettings = JSON.parse(this.allSetting.xrayTemplateConfig);
  431. if (newValue){
  432. newTemplateSettings.routing.rules.push(JSON.parse("{\"outboundTag\": \"blocked\",\"ip\": [\"geoip:private\"],\"type\": \"field\"}"))
  433. }
  434. else {
  435. newTemplateSettings.routing.rules = [];
  436. this.templateSettings.routing.rules.forEach(routingRule => {
  437. if (routingRule.hasOwnProperty('ip')){
  438. if (routingRule.ip[0] === "geoip:private" && routingRule.outboundTag == "blocked"){
  439. return;
  440. }
  441. }
  442. newTemplateSettings.routing.rules.push(routingRule);
  443. });
  444. }
  445. this.templateSettings = newTemplateSettings
  446. },
  447. },
  448. IRIpSettings: {
  449. get: function () {
  450. localIpFilter = false
  451. if(this.templateSettings != null){
  452. this.templateSettings.routing.rules.forEach(routingRule => {
  453. if(routingRule.hasOwnProperty("ip")){
  454. if (routingRule.ip[0] === "geoip:ir" && routingRule.outboundTag == "blocked"){
  455. localIpFilter = true
  456. }
  457. }
  458. });
  459. }
  460. return localIpFilter
  461. },
  462. set: function (newValue) {
  463. newTemplateSettings = JSON.parse(this.allSetting.xrayTemplateConfig);
  464. if (newValue){
  465. newTemplateSettings.routing.rules.push(JSON.parse("{\"outboundTag\": \"blocked\",\"ip\": [\"geoip:ir\"],\"type\": \"field\"}"))
  466. }
  467. else {
  468. newTemplateSettings.routing.rules = [];
  469. this.templateSettings.routing.rules.forEach(routingRule => {
  470. if (routingRule.hasOwnProperty('ip')){
  471. if (routingRule.ip[0] === "geoip:ir" && routingRule.outboundTag == "blocked"){
  472. return;
  473. }
  474. }
  475. newTemplateSettings.routing.rules.push(routingRule);
  476. });
  477. }
  478. this.templateSettings = newTemplateSettings
  479. },
  480. },
  481. IRdomainSettings: {
  482. get: function () {
  483. localdomainFilter = false
  484. if(this.templateSettings != null){
  485. this.templateSettings.routing.rules.forEach(routingRule => {
  486. if(routingRule.hasOwnProperty("domain")){
  487. if ((routingRule.domain[0] === "regexp:.+.ir$" || routingRule.domain[0] === "ext:iran.dat:ir" || routingRule.domain[0] === "ext:iran.dat:other") && routingRule.outboundTag == "blocked") {
  488. localdomainFilter = true
  489. }
  490. }
  491. });
  492. }
  493. return localdomainFilter
  494. },
  495. set: function (newValue) {
  496. newTemplateSettings = JSON.parse(this.allSetting.xrayTemplateConfig);
  497. if (newValue){
  498. newTemplateSettings.routing.rules.push(JSON.parse("{\"outboundTag\": \"blocked\",\"domain\": [\"regexp:.+.ir$\", \"ext:iran.dat:ir\", \"ext:iran.dat:other\"],\"type\": \"field\"}"))
  499. }
  500. else {
  501. newTemplateSettings.routing.rules = [];
  502. this.templateSettings.routing.rules.forEach(routingRule => {
  503. if (routingRule.hasOwnProperty('domain')){
  504. if ((routingRule.domain[0] === "regexp:.+.ir$" || routingRule.domain[0] === "ext:iran.dat:ir" || routingRule.domain[0] === "ext:iran.dat:other") && routingRule.outboundTag == "blocked"){
  505. return;
  506. }
  507. }
  508. newTemplateSettings.routing.rules.push(routingRule);
  509. });
  510. }
  511. this.templateSettings = newTemplateSettings
  512. },
  513. },
  514. }
  515. });
  516. </script>
  517. </body>
  518. </html>