Migration to a ServiceWorker for most tasks.
Implementation of basic PatchComplianceTask. First real iteration, basic/raw asf.
This commit is contained in:
47
OversightService/Config.cs
Normal file
47
OversightService/Config.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
#nullable disable
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace OversightService
|
||||
{
|
||||
public class AppConfig
|
||||
{
|
||||
[JsonProperty("ServerUrl")] public string ServerUrl { get; set; } = "https://yourserver.com/api/status";
|
||||
[JsonProperty("EnableLogging")] public bool EnableLogging { get; set; } = true;
|
||||
[JsonProperty("KeepAlivePeriod")] public int KeepAlivePeriod { get; set; } = 30;
|
||||
[JsonProperty("SystemInfoInterval")] public int SystemInfoInterval { get; set; } = 60;
|
||||
[JsonProperty("ClientIdentifier")] public string ClientIdentifier { get; set; } = "your-default-client-id";
|
||||
[JsonProperty("Auth")] public AuthConfig Auth { get; set; } = new();
|
||||
[JsonProperty("PatchCompliance")] public PatchComplianceConfig PatchCompliance { get; set; } = new();
|
||||
}
|
||||
|
||||
public class PatchComplianceConfig
|
||||
{
|
||||
[JsonProperty("Enabled")] public bool Enabled { get; set; } = false;
|
||||
[JsonProperty("CheckIntervalHours")] public int CheckIntervalHours { get; set; } = 24;
|
||||
[JsonProperty("LastCheckTime")] public DateTime? LastCheckTime { get; set; } = null;
|
||||
}
|
||||
|
||||
public class AuthConfig
|
||||
{
|
||||
[JsonProperty("Username")] public string Username { get; set; } = "testuser";
|
||||
[JsonProperty("Password")] public string Password { get; set; } = "testpassword";
|
||||
}
|
||||
|
||||
public static class ConfigManager
|
||||
{
|
||||
private static readonly string ConfigPath = Path.Combine(AppContext.BaseDirectory, "config.json");
|
||||
|
||||
public static AppConfig LoadConfig(string? pathOverride = null)
|
||||
{
|
||||
string path = pathOverride ?? ConfigPath;
|
||||
if (!File.Exists(path))
|
||||
throw new FileNotFoundException($"Config file not found at {path}");
|
||||
|
||||
string json = File.ReadAllText(path);
|
||||
return JsonConvert.DeserializeObject<AppConfig>(json) ?? new AppConfig();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user