2024-10-12 18:36:00 -05:00
|
|
|
|
using LANCommander.Server.Data.Enums;
|
2024-12-28 03:48:15 -06:00
|
|
|
|
using System.Text.RegularExpressions;
|
2025-01-06 20:34:11 -06:00
|
|
|
|
using Microsoft.AspNetCore.Http;
|
2025-02-05 18:45:00 -06:00
|
|
|
|
using Microsoft.Extensions.Logging;
|
2024-10-07 18:52:22 -05:00
|
|
|
|
|
2024-10-12 18:36:00 -05:00
|
|
|
|
namespace LANCommander.Server.Services.Models
|
|
|
|
|
|
{
|
2023-09-05 19:41:11 -05:00
|
|
|
|
public enum LANCommanderTheme
|
|
|
|
|
|
{
|
|
|
|
|
|
Light,
|
|
|
|
|
|
Dark
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-10-07 18:04:26 -05:00
|
|
|
|
public enum LogInterval
|
|
|
|
|
|
{
|
|
|
|
|
|
Infinite,
|
|
|
|
|
|
Year,
|
|
|
|
|
|
Month,
|
|
|
|
|
|
Day,
|
|
|
|
|
|
Hour,
|
|
|
|
|
|
Minute
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-28 05:20:46 -06:00
|
|
|
|
public enum AuthenticationProviderType
|
|
|
|
|
|
{
|
|
|
|
|
|
OAuth2,
|
|
|
|
|
|
OpenIdConnect,
|
|
|
|
|
|
Saml
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-02-05 18:45:00 -06:00
|
|
|
|
public enum LoggingProviderType
|
|
|
|
|
|
{
|
|
|
|
|
|
File,
|
|
|
|
|
|
Console,
|
|
|
|
|
|
SignalR,
|
|
|
|
|
|
Seq,
|
|
|
|
|
|
ElasticSearch,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-02-13 02:04:09 -06:00
|
|
|
|
public enum ReleaseChannel
|
|
|
|
|
|
{
|
|
|
|
|
|
Stable,
|
|
|
|
|
|
Prerelease,
|
|
|
|
|
|
Nightly,
|
|
|
|
|
|
}
|
2025-02-15 23:45:51 -06:00
|
|
|
|
|
|
|
|
|
|
public enum LauncherPlatform
|
|
|
|
|
|
{
|
|
|
|
|
|
Windows,
|
|
|
|
|
|
Linux,
|
|
|
|
|
|
macOS,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public enum LauncherArchitecture
|
|
|
|
|
|
{
|
|
|
|
|
|
x64,
|
|
|
|
|
|
arm64,
|
|
|
|
|
|
}
|
2025-02-13 02:04:09 -06:00
|
|
|
|
|
2024-10-07 18:38:27 -05:00
|
|
|
|
public class Settings
|
2023-01-09 18:58:27 -06:00
|
|
|
|
{
|
2023-03-20 00:15:22 -05:00
|
|
|
|
public int Port { get; set; } = 1337;
|
2024-10-12 18:36:00 -05:00
|
|
|
|
public DatabaseProvider DatabaseProvider { get; set; } = DatabaseProvider.Unknown;
|
|
|
|
|
|
public string DatabaseConnectionString { get; set; } = "";
|
2023-03-20 00:15:22 -05:00
|
|
|
|
public string IGDBClientId { get; set; } = "";
|
|
|
|
|
|
public string IGDBClientSecret { get; set; } = "";
|
2024-03-09 17:26:13 -06:00
|
|
|
|
public LANCommanderTheme Theme { get; set; } = LANCommanderTheme.Dark;
|
2025-01-25 01:57:17 -06:00
|
|
|
|
public bool UseSSL { get; set; } = false;
|
|
|
|
|
|
public string CertificatePath { get; set; } = "";
|
|
|
|
|
|
public string CertificatePassword { get; set; } = "";
|
2025-01-25 02:40:36 -06:00
|
|
|
|
public int SSLPort { get; set; } = 31337;
|
2025-01-25 01:57:17 -06:00
|
|
|
|
|
2024-10-07 18:38:27 -05:00
|
|
|
|
public BeaconSettings Beacon { get; set; } = new BeaconSettings();
|
|
|
|
|
|
public AuthenticationSettings Authentication { get; set; } = new AuthenticationSettings();
|
|
|
|
|
|
public RoleSettings Roles { get; set; } = new RoleSettings();
|
|
|
|
|
|
public UserSaveSettings UserSaves { get; set; } = new UserSaveSettings();
|
|
|
|
|
|
public ArchiveSettings Archives { get; set; } = new ArchiveSettings();
|
|
|
|
|
|
public MediaSettings Media { get; set; } = new MediaSettings();
|
|
|
|
|
|
public IPXRelaySettings IPXRelay { get; set; } = new IPXRelaySettings();
|
|
|
|
|
|
public ServerSettings Servers { get; set; } = new ServerSettings();
|
2025-03-09 00:15:47 -06:00
|
|
|
|
public BackupSettings Backups { get; set; } = new BackupSettings();
|
2024-10-07 18:38:27 -05:00
|
|
|
|
public UpdateSettings Update { get; set; } = new UpdateSettings();
|
|
|
|
|
|
public LauncherSettings Launcher { get; set; } = new LauncherSettings();
|
|
|
|
|
|
public LogSettings Logs { get; set; } = new LogSettings();
|
2025-02-22 00:26:54 -06:00
|
|
|
|
public LibrarySettings Library { get; set; } = new LibrarySettings();
|
2025-08-02 00:22:16 -05:00
|
|
|
|
public ScriptSettings Scripts { get; set; } = new ScriptSettings();
|
2023-12-18 20:33:35 -06:00
|
|
|
|
|
|
|
|
|
|
private DriveInfo[] Drives { get; set; } = DriveInfo.GetDrives();
|
|
|
|
|
|
public DriveInfo[] GetDrives()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (Drives == null || Drives.Length == 0)
|
|
|
|
|
|
Drives = DriveInfo.GetDrives();
|
|
|
|
|
|
|
|
|
|
|
|
return Drives;
|
|
|
|
|
|
}
|
2023-03-20 00:15:22 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-10-07 18:38:27 -05:00
|
|
|
|
public class BeaconSettings
|
2023-10-30 18:45:11 -05:00
|
|
|
|
{
|
|
|
|
|
|
public bool Enabled { get; set; } = true;
|
2024-08-26 21:29:25 -05:00
|
|
|
|
public string Name { get; set; } = "LANCommander";
|
2023-10-30 18:45:11 -05:00
|
|
|
|
public string Address { get; set; } = "";
|
2025-04-13 03:16:19 -05:00
|
|
|
|
public int Port { get; set; } = 35891;
|
2023-10-30 18:45:11 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-10-07 18:38:27 -05:00
|
|
|
|
public class AuthenticationSettings
|
2023-03-20 00:15:22 -05:00
|
|
|
|
{
|
2023-08-11 13:40:51 -05:00
|
|
|
|
public bool RequireApproval { get; set; } = false;
|
2023-09-12 17:32:17 -05:00
|
|
|
|
public string TokenSecret { get; set; } = Guid.NewGuid().ToString();
|
2023-03-20 00:15:22 -05:00
|
|
|
|
public int TokenLifetime { get; set; } = 30;
|
2023-09-08 22:25:12 -05:00
|
|
|
|
public bool PasswordRequireNonAlphanumeric { get; set; } = false;
|
|
|
|
|
|
public bool PasswordRequireLowercase { get; set; } = false;
|
|
|
|
|
|
public bool PasswordRequireUppercase { get; set; } = false;
|
|
|
|
|
|
public bool PasswordRequireDigit { get; set; } = true;
|
2023-03-20 00:15:22 -05:00
|
|
|
|
public int PasswordRequiredLength { get; set; } = 8;
|
2025-02-15 09:06:29 -06:00
|
|
|
|
public SameSiteMode MinimumSameSitePolicy { get; set; } = SameSiteMode.Lax;
|
|
|
|
|
|
public CookieSecurePolicy CookieSecurePolicy { get; set; } = CookieSecurePolicy.SameAsRequest;
|
2024-12-28 05:20:46 -06:00
|
|
|
|
public IEnumerable<AuthenticationProvider> AuthenticationProviders { get; set; } = new List<AuthenticationProvider>();
|
2024-12-28 03:48:15 -06:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-28 05:20:46 -06:00
|
|
|
|
public class AuthenticationProvider
|
2024-12-28 03:48:15 -06:00
|
|
|
|
{
|
|
|
|
|
|
public string Name { get; set; }
|
2024-12-29 18:58:01 -06:00
|
|
|
|
public string Slug { get; set; }
|
2024-12-28 05:20:46 -06:00
|
|
|
|
public AuthenticationProviderType Type { get; set; } = AuthenticationProviderType.OAuth2;
|
2024-12-29 18:58:01 -06:00
|
|
|
|
public string Color { get; set; }
|
|
|
|
|
|
public string Icon { get; set; }
|
2024-12-28 03:48:15 -06:00
|
|
|
|
public string Documentation { get; set; }
|
|
|
|
|
|
public string ClientId { get; set; }
|
|
|
|
|
|
public string ClientSecret { get; set; }
|
|
|
|
|
|
public string Authority { get; set; }
|
|
|
|
|
|
public string AuthorizationEndpoint { get; set; }
|
|
|
|
|
|
public string TokenEndpoint { get; set; }
|
|
|
|
|
|
public string UserInfoEndpoint { get; set; }
|
|
|
|
|
|
public IEnumerable<string> Scopes { get; set; } = new List<string>();
|
2024-12-28 05:20:46 -06:00
|
|
|
|
public IEnumerable<ClaimMapping> ClaimMappings { get; set; } = new List<ClaimMapping>();
|
2024-12-30 01:05:58 -06:00
|
|
|
|
|
|
|
|
|
|
public string GetCustomFieldName()
|
|
|
|
|
|
{
|
|
|
|
|
|
return $"ExternalId/{Slug}";
|
|
|
|
|
|
}
|
2023-01-09 18:58:27 -06:00
|
|
|
|
}
|
2023-09-08 22:26:28 -05:00
|
|
|
|
|
2024-12-28 05:20:46 -06:00
|
|
|
|
public class ClaimMapping
|
|
|
|
|
|
{
|
|
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
|
public string Value { get; set; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-10-07 18:38:27 -05:00
|
|
|
|
public class RoleSettings
|
2023-12-04 17:40:21 -06:00
|
|
|
|
{
|
|
|
|
|
|
public Guid DefaultRoleId { get; set; }
|
|
|
|
|
|
public bool RestrictGamesByCollection { get; set; } = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-10-07 18:38:27 -05:00
|
|
|
|
public class UserSaveSettings
|
2023-09-13 19:32:36 -05:00
|
|
|
|
{
|
|
|
|
|
|
public int MaxSize { get; set; } = 25;
|
2024-02-07 17:53:07 -06:00
|
|
|
|
public int MaxSaves { get; set; } = 0;
|
2023-09-13 19:32:36 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-10-07 18:38:27 -05:00
|
|
|
|
public class ArchiveSettings
|
2023-09-12 19:24:04 -05:00
|
|
|
|
{
|
|
|
|
|
|
public bool EnablePatching { get; set; } = false;
|
2023-12-20 12:15:47 -06:00
|
|
|
|
public bool AllowInsecureDownloads { get; set; } = false;
|
2024-05-01 21:32:21 -05:00
|
|
|
|
public int MaxChunkSize { get; set; } = 50;
|
2023-09-12 19:24:04 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-10-07 18:38:27 -05:00
|
|
|
|
public class MediaSettings
|
2023-11-02 01:24:42 -05:00
|
|
|
|
{
|
|
|
|
|
|
public string SteamGridDbApiKey { get; set; } = "";
|
2023-11-02 23:18:19 -05:00
|
|
|
|
public long MaxSize { get; set; } = 25;
|
2023-11-02 01:24:42 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-10-07 18:38:27 -05:00
|
|
|
|
public class IPXRelaySettings
|
2023-09-08 22:26:28 -05:00
|
|
|
|
{
|
|
|
|
|
|
public bool Enabled { get; set; } = false;
|
2024-01-02 20:46:28 -06:00
|
|
|
|
public string Host { get; set; } = "";
|
2023-09-08 22:26:28 -05:00
|
|
|
|
public int Port { get; set; } = 213;
|
|
|
|
|
|
public bool Logging { get; set; } = false;
|
|
|
|
|
|
}
|
2024-01-06 16:49:21 -06:00
|
|
|
|
|
2025-03-09 00:15:47 -06:00
|
|
|
|
public class BackupSettings
|
|
|
|
|
|
{
|
|
|
|
|
|
public string StoragePath { get; set; } = "Backups";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-10-07 18:38:27 -05:00
|
|
|
|
public class ServerSettings
|
2024-07-04 16:34:30 -05:00
|
|
|
|
{
|
|
|
|
|
|
public string StoragePath { get; set; } = "Servers";
|
2025-03-25 18:07:03 -05:00
|
|
|
|
public IEnumerable<ServerEngineConfiguration> ServerEngines { get; set; } = new List<ServerEngineConfiguration>()
|
|
|
|
|
|
{
|
|
|
|
|
|
new ServerEngineConfiguration
|
|
|
|
|
|
{
|
|
|
|
|
|
Name = "Local",
|
|
|
|
|
|
Type = ServerEngine.Local,
|
|
|
|
|
|
},
|
|
|
|
|
|
new ServerEngineConfiguration
|
|
|
|
|
|
{
|
|
|
|
|
|
Name = "Docker",
|
|
|
|
|
|
Type = ServerEngine.Docker,
|
|
|
|
|
|
Address = "unix:///var/run/docker.sock",
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class ServerEngineConfiguration
|
2025-03-23 17:30:50 -05:00
|
|
|
|
{
|
2025-03-23 20:19:18 -05:00
|
|
|
|
public Guid Id { get; set; } = Guid.NewGuid();
|
2025-03-23 17:30:50 -05:00
|
|
|
|
public string Name { get; set; } = "Local";
|
2025-03-25 18:07:03 -05:00
|
|
|
|
public ServerEngine Type { get; set; } = ServerEngine.Local;
|
|
|
|
|
|
public string Address { get; set; } = "";
|
2024-07-04 16:34:30 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-10-07 18:38:27 -05:00
|
|
|
|
public class UpdateSettings
|
2024-01-13 03:52:08 -06:00
|
|
|
|
{
|
|
|
|
|
|
public string StoragePath { get; set; } = "Updates";
|
2025-02-13 02:04:09 -06:00
|
|
|
|
public ReleaseChannel ReleaseChannel { get; set; } = ReleaseChannel.Stable;
|
2024-07-25 19:22:37 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-10-07 18:38:27 -05:00
|
|
|
|
public class LauncherSettings
|
2024-07-25 19:22:37 -05:00
|
|
|
|
{
|
|
|
|
|
|
public string StoragePath { get; set; } = "Launcher";
|
2025-04-12 19:53:34 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Whether to include locally downloaded launcher files and provide these for download
|
|
|
|
|
|
/// </summary>
|
2024-07-25 19:22:37 -05:00
|
|
|
|
public bool HostUpdates { get; set; } = true;
|
2025-04-12 19:53:34 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Whether to include online launcher files to link to for download
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public bool IncludeOnlineUpdates { get; set; } = false;
|
2025-02-15 23:45:51 -06:00
|
|
|
|
public string VersionOverride { get; set; } = "";
|
|
|
|
|
|
public IEnumerable<LauncherArchitecture> Architectures { get; set; } = new[] { LauncherArchitecture.x64, LauncherArchitecture.arm64 };
|
|
|
|
|
|
public IEnumerable<LauncherPlatform> Platforms { get; set; } = new[] { LauncherPlatform.Windows };
|
2024-01-13 03:52:08 -06:00
|
|
|
|
}
|
2024-01-29 22:29:47 -06:00
|
|
|
|
|
2025-02-05 18:45:00 -06:00
|
|
|
|
public class LoggingProvider
|
|
|
|
|
|
{
|
2025-02-08 19:27:59 -06:00
|
|
|
|
public string Name { get; set; }
|
2025-02-05 18:45:00 -06:00
|
|
|
|
public LogLevel MinimumLevel { get; set; } = LogLevel.Information;
|
|
|
|
|
|
public bool Enabled { get; set; } = true;
|
|
|
|
|
|
public LoggingProviderType Type { get; set; } = LoggingProviderType.Console;
|
2025-02-08 19:27:59 -06:00
|
|
|
|
public LogInterval? ArchiveEvery { get; set; }
|
|
|
|
|
|
public int MaxArchiveFiles { get; set; } = 10;
|
2025-02-05 18:45:00 -06:00
|
|
|
|
public string ConnectionString { get; set; } = "";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-10-07 18:38:27 -05:00
|
|
|
|
public class LogSettings
|
2024-01-29 22:29:47 -06:00
|
|
|
|
{
|
2025-02-05 18:45:00 -06:00
|
|
|
|
public bool IgnorePings { get; set; } = true;
|
|
|
|
|
|
public IEnumerable<LoggingProvider> Providers { get; set; } = [
|
2025-02-08 19:27:59 -06:00
|
|
|
|
new()
|
|
|
|
|
|
{
|
|
|
|
|
|
Name = "Console",
|
|
|
|
|
|
MinimumLevel = LogLevel.Information, Type = LoggingProviderType.Console
|
|
|
|
|
|
},
|
|
|
|
|
|
new()
|
|
|
|
|
|
{
|
|
|
|
|
|
Name = "File",
|
|
|
|
|
|
MinimumLevel = LogLevel.Information,
|
|
|
|
|
|
Type = LoggingProviderType.File,
|
|
|
|
|
|
ConnectionString = "Logs"
|
|
|
|
|
|
},
|
|
|
|
|
|
new()
|
|
|
|
|
|
{
|
|
|
|
|
|
Name = "Server Console",
|
|
|
|
|
|
MinimumLevel = LogLevel.Information,
|
|
|
|
|
|
Type = LoggingProviderType.SignalR
|
|
|
|
|
|
},
|
2025-02-05 18:45:00 -06:00
|
|
|
|
];
|
2024-01-29 22:29:47 -06:00
|
|
|
|
}
|
2025-02-22 00:26:54 -06:00
|
|
|
|
|
|
|
|
|
|
public class LibrarySettings
|
|
|
|
|
|
{
|
|
|
|
|
|
public bool EnableUserLibraries { get; set; } = true;
|
|
|
|
|
|
}
|
2025-08-02 00:22:16 -05:00
|
|
|
|
|
|
|
|
|
|
public class ScriptSettings
|
|
|
|
|
|
{
|
|
|
|
|
|
public bool EnableAutomaticRepackaging { get; set; } = false;
|
|
|
|
|
|
public int RepackageEvery { get; set; } = 24;
|
|
|
|
|
|
}
|
2023-01-09 18:58:27 -06:00
|
|
|
|
}
|