namespace MoShiro.Backend.Application;
/// Backend 的可调参数(保留期等也可以通过 settings 改,这里是默认值与硬上限)。
public sealed class BackendOptions
{
/// 数据目录:moshiro.db 与 raw/。
public string DataDirectory { get; set; } = "data";
/// Backend 更新通道:auto 按镜像的构建 tag 识别 dev/release,Compose 可以显式覆盖。
public string UpdateChannel { get; set; } = "auto";
/// 容器使用的 OCI repository namespace;Compose 默认 moshiro,开发镜像使用 moshiro-dev。
public string ImageNamespace { get; set; } = "";
/// 节点镜像所在的仓库地址(管理端「添加 Agent / Probe」生成的容器命令用它拼镜像名)。
public string NodeImageRegistry { get; set; } = "registry.oeo.one";
/// 容器内更新请求目录;留空使用数据目录下的 update/。
public string? BackendUpdateDirectory { get; set; }
/// 宿主机更新器的只读状态目录;留空使用数据目录下的 update-status/。
public string? BackendUpdateStatusDirectory { get; set; }
/// 面板的对外地址(用于生成安装命令)。
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;
///
/// IP 归属查询服务的地址(`GET {地址}/lookup?ip=…`):Backend 用 Probe、Agent 的来源地址查一次国家和运营商,
/// 只留下国家代码和运营商名,IP 不对外。留空 = 不查。服务的使用条款(公益、不能商用、保留署名)由部署的人自己遵守。
///
public string? GeoLookupUrl { get; set; } = "https://ip.007995.xyz";
/// 初始管理员(只在没有任何用户时创建)。
public string? InitialAdminUser { get; set; }
public string? InitialAdminPassword { get; set; }
}