setting.ts 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. import { ObjectUtil } from '@/utils';
  2. export class AllSetting {
  3. webListen = '';
  4. webDomain = '';
  5. webPort = 2053;
  6. webCertFile = '';
  7. webKeyFile = '';
  8. webBasePath = '/';
  9. sessionMaxAge = 360;
  10. trustedProxyCIDRs = '127.0.0.1/32,::1/128';
  11. panelOutbound = '';
  12. pageSize = 25;
  13. expireDiff = 0;
  14. trafficDiff = 0;
  15. remarkTemplate = '{{INBOUND}}-{{EMAIL}}|📊{{TRAFFIC_LEFT}}|⏳{{DAYS_LEFT}}D';
  16. subShowIdentityOnAllLinks = false;
  17. datepicker: 'gregorian' | 'jalalian' = 'gregorian';
  18. tgBotEnable = false;
  19. tgBotToken = '';
  20. tgBotAPIServer = '';
  21. tgBotChatId = '';
  22. tgRunTime = '@daily';
  23. tgBotBackup = false;
  24. tgCpu = 80;
  25. tgMemory = 80;
  26. tgLang = 'en-US';
  27. twoFactorEnable = false;
  28. twoFactorToken = '';
  29. xrayTemplateConfig = '';
  30. subEnable = true;
  31. subJsonEnable = false;
  32. subJsonAutoDetect = false;
  33. subJsonAlwaysArray = false;
  34. subJsonUserAgentRegex = '';
  35. subClashAutoDetect = false;
  36. subClashUserAgentRegex = '';
  37. subTitle = '';
  38. subSupportUrl = '';
  39. subProfileUrl = '';
  40. subAnnounce = '';
  41. subEnableRouting = false;
  42. subRoutingRules = '';
  43. subIncyEnableRouting = false;
  44. subIncyRoutingRules = '';
  45. subListen = '';
  46. subPort = 2096;
  47. subPath = '/sub/';
  48. subJsonPath = '/json/';
  49. subClashEnable = false;
  50. subClashPath = '/clash/';
  51. subDomain = '';
  52. externalTrafficInformEnable = false;
  53. externalTrafficInformURI = '';
  54. restartXrayOnClientDisable = true;
  55. subCertFile = '';
  56. subKeyFile = '';
  57. subUpdates = 12;
  58. subEncrypt = true;
  59. subURI = '';
  60. subJsonURI = '';
  61. subClashURI = '';
  62. subClashEnableRouting = false;
  63. subClashRules = '';
  64. subJsonMux = '';
  65. subJsonRules = '';
  66. subJsonFinalMask = '';
  67. subThemeDir = '';
  68. subHideSettings = false;
  69. timeLocation = 'Local';
  70. ldapEnable = false;
  71. ldapHost = '';
  72. ldapPort = 389;
  73. ldapUseTLS = false;
  74. ldapInsecureSkipVerify = false;
  75. ldapBindDN = '';
  76. ldapPassword = '';
  77. ldapBaseDN = '';
  78. ldapUserFilter = '(objectClass=person)';
  79. ldapUserAttr = 'mail';
  80. ldapVlessField = 'vless_enabled';
  81. ldapSyncCron = '@every 1m';
  82. ldapFlagField = '';
  83. ldapTruthyValues = 'true,1,yes,on';
  84. ldapInvertFlag = false;
  85. ldapInboundTags = '';
  86. ldapAutoCreate = false;
  87. ldapAutoDelete = false;
  88. ldapDefaultTotalGB = 0;
  89. ldapDefaultExpiryDays = 0;
  90. ldapDefaultLimitIP = 0;
  91. tgEnabledEvents = '';
  92. smtpEnable = false;
  93. smtpHost = '';
  94. smtpPort = 587;
  95. smtpUsername = '';
  96. smtpPassword = '';
  97. smtpFrom = '';
  98. smtpFromName = '';
  99. smtpTo = '';
  100. smtpEncryptionType = 'starttls';
  101. smtpEnabledEvents = '';
  102. smtpCpu = 80;
  103. smtpMemory = 80;
  104. outboundDownThreshold = 3;
  105. hasTgBotToken = false;
  106. hasTwoFactorToken = false;
  107. hasLdapPassword = false;
  108. hasApiToken = false;
  109. hasWarpSecret = false;
  110. hasNordSecret = false;
  111. hasSmtpPassword = false;
  112. clearTgBotToken = false;
  113. clearLdapPassword = false;
  114. clearSmtpPassword = false;
  115. constructor(data?: unknown) {
  116. if (data != null) {
  117. ObjectUtil.cloneProps(this, data);
  118. }
  119. const cpu = Math.round(Number(this.tgCpu));
  120. this.tgCpu = Number.isFinite(cpu) ? Math.min(100, Math.max(0, cpu)) : 80;
  121. const threshold = Math.round(Number(this.outboundDownThreshold));
  122. this.outboundDownThreshold = Number.isFinite(threshold) ? Math.min(100, Math.max(1, threshold)) : 3;
  123. }
  124. equals(other: AllSetting): boolean {
  125. return ObjectUtil.equals(this, other);
  126. }
  127. }