Problem: a flaky outbound produces hundreds of false-positive "outbound down" notifications overnight — each fires the moment xray's observatory reports a single failed probe, and the next successful probe fires an "up". applyObservatory forwarded every raw alive:true->false transition straight to EventOutboundDown; xray's observatory has effectively no hysteresis, and nothing on the panel side debounced it (the email/Telegram subscribers are pure formatters). Fix: debounce per outbound. outbound.down now fires only after outboundDownThreshold consecutive FAILED probes (new setting, default 3); outbound.up fires immediately on the first successful probe and only when a down was actually notified. The threshold gates the event itself, so email and Telegram share one knob (exposed next to the outbound.down toggle). The streak counts genuinely new probes (last_try_time advancing), not sampler polls — the sampler runs every 2s but the observatory re-probes per its probeInterval, so counting samples would trip the threshold instantly. outboundDownThreshold=1 reproduces the legacy notify-on-first-failure behaviour. Tuning the observatory's probe interval/timeout is not a workaround: those probes also drive the load balancer's outbound selection, so loosening them to quiet notifications would slow real failover away from a genuinely dead outbound. Notifications don't need observatory-grade latency, so the tolerance belongs at the notification layer, leaving the observatory (and balancer) untouched. Adds TestApplyObservatoryDebounce covering the threshold, probe-vs-sample counting, single-blip suppression and the legacy path. Co-authored-by: Yuriy Khachaturian <y.khachaturian@souzmult.ru> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
132 lines
3.2 KiB
TypeScript
132 lines
3.2 KiB
TypeScript
import { ObjectUtil } from '@/utils';
|
|
|
|
export class AllSetting {
|
|
webListen = '';
|
|
webDomain = '';
|
|
webPort = 2053;
|
|
webCertFile = '';
|
|
webKeyFile = '';
|
|
webBasePath = '/';
|
|
sessionMaxAge = 360;
|
|
trustedProxyCIDRs = '127.0.0.1/32,::1/128';
|
|
panelOutbound = '';
|
|
pageSize = 25;
|
|
expireDiff = 0;
|
|
trafficDiff = 0;
|
|
remarkTemplate = '{{INBOUND}}-{{EMAIL}}|📊{{TRAFFIC_LEFT}}|⏳{{DAYS_LEFT}}D';
|
|
datepicker: 'gregorian' | 'jalalian' = 'gregorian';
|
|
tgBotEnable = false;
|
|
tgBotToken = '';
|
|
tgBotAPIServer = '';
|
|
tgBotChatId = '';
|
|
tgRunTime = '@daily';
|
|
tgBotBackup = false;
|
|
tgCpu = 80;
|
|
tgMemory = 80;
|
|
tgLang = 'en-US';
|
|
twoFactorEnable = false;
|
|
twoFactorToken = '';
|
|
xrayTemplateConfig = '';
|
|
subEnable = true;
|
|
subJsonEnable = false;
|
|
subJsonAutoDetect = false;
|
|
subJsonAlwaysArray = false;
|
|
subJsonUserAgentRegex = '';
|
|
subClashAutoDetect = false;
|
|
subClashUserAgentRegex = '';
|
|
subTitle = '';
|
|
subSupportUrl = '';
|
|
subProfileUrl = '';
|
|
subAnnounce = '';
|
|
subEnableRouting = false;
|
|
subRoutingRules = '';
|
|
subIncyEnableRouting = false;
|
|
subIncyRoutingRules = '';
|
|
subListen = '';
|
|
subPort = 2096;
|
|
subPath = '/sub/';
|
|
subJsonPath = '/json/';
|
|
subClashEnable = false;
|
|
subClashPath = '/clash/';
|
|
subDomain = '';
|
|
externalTrafficInformEnable = false;
|
|
externalTrafficInformURI = '';
|
|
restartXrayOnClientDisable = true;
|
|
subCertFile = '';
|
|
subKeyFile = '';
|
|
subUpdates = 12;
|
|
subEncrypt = true;
|
|
subURI = '';
|
|
subJsonURI = '';
|
|
subClashURI = '';
|
|
subClashEnableRouting = false;
|
|
subClashRules = '';
|
|
subJsonMux = '';
|
|
subJsonRules = '';
|
|
subJsonFinalMask = '';
|
|
subThemeDir = '';
|
|
subHideSettings = false;
|
|
|
|
timeLocation = 'Local';
|
|
|
|
ldapEnable = false;
|
|
ldapHost = '';
|
|
ldapPort = 389;
|
|
ldapUseTLS = false;
|
|
ldapInsecureSkipVerify = false;
|
|
ldapBindDN = '';
|
|
ldapPassword = '';
|
|
ldapBaseDN = '';
|
|
ldapUserFilter = '(objectClass=person)';
|
|
ldapUserAttr = 'mail';
|
|
ldapVlessField = 'vless_enabled';
|
|
ldapSyncCron = '@every 1m';
|
|
ldapFlagField = '';
|
|
ldapTruthyValues = 'true,1,yes,on';
|
|
ldapInvertFlag = false;
|
|
ldapInboundTags = '';
|
|
ldapAutoCreate = false;
|
|
ldapAutoDelete = false;
|
|
ldapDefaultTotalGB = 0;
|
|
ldapDefaultExpiryDays = 0;
|
|
ldapDefaultLimitIP = 0;
|
|
tgEnabledEvents = '';
|
|
smtpEnable = false;
|
|
smtpHost = '';
|
|
smtpPort = 587;
|
|
smtpUsername = '';
|
|
smtpPassword = '';
|
|
smtpFrom = '';
|
|
smtpFromName = '';
|
|
smtpTo = '';
|
|
smtpEncryptionType = 'starttls';
|
|
smtpEnabledEvents = '';
|
|
smtpCpu = 80;
|
|
smtpMemory = 80;
|
|
outboundDownThreshold = 3;
|
|
hasTgBotToken = false;
|
|
hasTwoFactorToken = false;
|
|
hasLdapPassword = false;
|
|
hasApiToken = false;
|
|
hasWarpSecret = false;
|
|
hasNordSecret = false;
|
|
hasSmtpPassword = false;
|
|
clearTgBotToken = false;
|
|
clearLdapPassword = false;
|
|
clearSmtpPassword = false;
|
|
|
|
constructor(data?: unknown) {
|
|
if (data != null) {
|
|
ObjectUtil.cloneProps(this, data);
|
|
}
|
|
const cpu = Math.round(Number(this.tgCpu));
|
|
this.tgCpu = Number.isFinite(cpu) ? Math.min(100, Math.max(0, cpu)) : 80;
|
|
const threshold = Math.round(Number(this.outboundDownThreshold));
|
|
this.outboundDownThreshold = Number.isFinite(threshold) ? Math.min(100, Math.max(1, threshold)) : 3;
|
|
}
|
|
|
|
equals(other: AllSetting): boolean {
|
|
return ObjectUtil.equals(this, other);
|
|
}
|
|
}
|