namespace Monitor.Backend.Application; /// Backend 的可调参数(保留期等也可以通过 settings 改,这里是默认值与硬上限)。 public sealed class BackendOptions { /// 数据目录:monitor.db 与 raw/。 public string DataDirectory { get; set; } = "data"; /// 面板的对外地址(用于生成安装命令)。 public string? PublicUrl { get; set; } public int Pbkdf2Iterations { get; set; } = 600_000; /// 会话 Cookie 带 Secure 标记(只提供 HTTPS)。本机用 HTTP 调试时才关闭。 public bool SecureCookies { get; set; } = true; /// /// 允许跨域调用 API 的前端来源,逗号分隔(如 http://localhost:5173,https://panel.example.com,或 *);空 = 不允许,只有同源。 /// 跨域只支持 Bearer 令牌(不带 Cookie),所以不影响会话的安全。 /// public string? CorsOrigins { get; set; } public TimeSpan SessionLifetime { get; set; } = TimeSpan.FromHours(12); public int LoginAttemptsPerMinute { get; set; } = 10; public int RawRetentionDays { get; set; } = 30; public int TestRawRetentionDays { get; set; } = 90; public int Metric10sRetentionHours { get; set; } = 48; public int Metric1mRetentionDays { get; set; } = 30; public int Metric5mRetentionDays { get; set; } = 365; public int EventRetentionDays { get; set; } = 365; public int HostRetentionDays { get; set; } = 7; /// 分钟窗口在结束之后再等一会儿,让迟到的块先到。 public TimeSpan WindowGrace { get; set; } = TimeSpan.FromSeconds(60); public TimeSpan AnalysisPollInterval { get; set; } = TimeSpan.FromSeconds(5); public TimeSpan QueryTimeout { get; set; } = TimeSpan.FromSeconds(10); public int MaxSsePerClient { get; set; } = 4; public int MaxSseTopics { get; set; } = 32; public int MaxPointsPerSeries { get; set; } = 2000; public int MaxMetricsPerQuery { get; set; } = 32; public int MaxCompareAgents { get; set; } = 20; /// /// 测试方案里「固定时长」阶段(没有 duration_s 参数的,例如 connect、hold)的缩放比例,缺省 1。 /// 只给自动化测试用:端到端测试里把 30 秒的阶段缩短,不用真等。 /// public double PhaseDurationScale { get; set; } = 1.0; /// 初始管理员(只在没有任何用户时创建)。 public string? InitialAdminUser { get; set; } public string? InitialAdminPassword { get; set; } }