Files
MoShiro/backend/src/MoShiro.Backend.Application/BackendOptions.cs
T
2026-10-07 20:02:38 +08:00

90 lines
4.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
namespace MoShiro.Backend.Application;
/// <summary>Backend 的可调参数(保留期等也可以通过 settings 改,这里是默认值与硬上限)。</summary>
public sealed class BackendOptions
{
/// <summary>数据目录:<c>moshiro.db</c> 与 <c>raw/</c>。</summary>
public string DataDirectory { get; set; } = "data";
/// <summary>Backend 更新通道:auto 按镜像的构建 tag 识别 dev/release,Compose 可以显式覆盖。</summary>
public string UpdateChannel { get; set; } = "auto";
/// <summary>容器使用的 OCI repository namespace;Compose 默认 moshiro,开发镜像使用 moshiro-dev。</summary>
public string ImageNamespace { get; set; } = "";
/// <summary>节点镜像所在的仓库地址(管理端「添加 Agent / Probe」生成的容器命令用它拼镜像名)。</summary>
public string NodeImageRegistry { get; set; } = "registry.oeo.one";
/// <summary>容器内更新请求目录;留空使用数据目录下的 update/。</summary>
public string? BackendUpdateDirectory { get; set; }
/// <summary>宿主机更新器的只读状态目录;留空使用数据目录下的 update-status/。</summary>
public string? BackendUpdateStatusDirectory { get; set; }
/// <summary>面板的对外地址(用于生成安装命令)。</summary>
public string? PublicUrl { get; set; }
public int Pbkdf2Iterations { get; set; } = 600_000;
/// <summary>会话 Cookie 带 Secure 标记(只提供 HTTPS)。本机用 HTTP 调试时才关闭。</summary>
public bool SecureCookies { get; set; } = true;
/// <summary>
/// 允许跨域调用 API 的前端来源,逗号分隔(如 <c>http://localhost:5173,https://panel.example.com</c>,或 <c>*</c>);空 = 不允许,只有同源。
/// 跨域只支持 Bearer 令牌(不带 Cookie),所以不影响会话的安全。
/// </summary>
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;
/// <summary>分钟窗口在结束之后再等一会儿,让迟到的块先到。</summary>
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;
/// <summary>
/// 测试方案里「固定时长」阶段(没有 <c>duration_s</c> 参数的,例如 connect、hold)的缩放比例,缺省 1。
/// 只给自动化测试用:端到端测试里把 30 秒的阶段缩短,不用真等。
/// </summary>
public double PhaseDurationScale { get; set; } = 1.0;
/// <summary>
/// IP 归属查询服务的地址(`GET {地址}/lookup?ip=…`):Backend 用 Probe、Agent 的来源地址查一次国家和运营商,
/// 只留下国家代码和运营商名,IP 不对外。留空 = 不查。服务的使用条款(公益、不能商用、保留署名)由部署的人自己遵守。
/// </summary>
public string? GeoLookupUrl { get; set; } = "https://ip.007995.xyz";
/// <summary>初始管理员(只在没有任何用户时创建)。</summary>
public string? InitialAdminUser { get; set; }
public string? InitialAdminPassword { get; set; }
}