Switched to new config system
This commit is contained in:
226
Moonlight/App/Configuration/ConfigV1.cs
Normal file
226
Moonlight/App/Configuration/ConfigV1.cs
Normal file
@@ -0,0 +1,226 @@
|
|||||||
|
namespace Moonlight.App.Configuration;
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
public class ConfigV1
|
||||||
|
{
|
||||||
|
[JsonProperty("Moonlight")] public MoonlightData Moonlight { get; set; } = new();
|
||||||
|
|
||||||
|
public class MoonlightData
|
||||||
|
{
|
||||||
|
[JsonProperty("AppUrl")] public string AppUrl { get; set; } = "http://your-moonlight-url-without-slash";
|
||||||
|
|
||||||
|
[JsonProperty("Database")] public DatabaseData Database { get; set; } = new();
|
||||||
|
|
||||||
|
[JsonProperty("DiscordBotApi")] public DiscordBotData DiscordBotApi { get; set; } = new();
|
||||||
|
|
||||||
|
[JsonProperty("DiscordBot")] public DiscordBotData DiscordBot { get; set; } = new();
|
||||||
|
|
||||||
|
[JsonProperty("Domains")] public DomainsData Domains { get; set; } = new();
|
||||||
|
|
||||||
|
[JsonProperty("Html")] public HtmlData Html { get; set; } = new();
|
||||||
|
|
||||||
|
[JsonProperty("Marketing")] public MarketingData Marketing { get; set; } = new();
|
||||||
|
|
||||||
|
[JsonProperty("OAuth2")] public OAuth2Data OAuth2 { get; set; } = new();
|
||||||
|
|
||||||
|
[JsonProperty("Security")] public SecurityData Security { get; set; } = new();
|
||||||
|
|
||||||
|
[JsonProperty("Mail")] public MailData Mail { get; set; } = new();
|
||||||
|
|
||||||
|
[JsonProperty("Cleanup")] public CleanupData Cleanup { get; set; } = new();
|
||||||
|
|
||||||
|
[JsonProperty("Subscriptions")] public SubscriptionsData Subscriptions { get; set; } = new();
|
||||||
|
|
||||||
|
[JsonProperty("DiscordNotifications")]
|
||||||
|
public DiscordNotificationsData DiscordNotifications { get; set; } = new();
|
||||||
|
|
||||||
|
[JsonProperty("Statistics")] public StatisticsData Statistics { get; set; } = new();
|
||||||
|
|
||||||
|
[JsonProperty("Rating")] public RatingData Rating { get; set; } = new();
|
||||||
|
|
||||||
|
[JsonProperty("SmartDeploy")] public SmartDeployData SmartDeploy { get; set; } = new();
|
||||||
|
|
||||||
|
[JsonProperty("Sentry")] public SentryData Sentry { get; set; } = new();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class CleanupData
|
||||||
|
{
|
||||||
|
[JsonProperty("Cpu")] public long Cpu { get; set; } = 90;
|
||||||
|
|
||||||
|
[JsonProperty("Memory")] public long Memory { get; set; } = 8192;
|
||||||
|
|
||||||
|
[JsonProperty("Wait")] public long Wait { get; set; } = 15;
|
||||||
|
|
||||||
|
[JsonProperty("Uptime")] public long Uptime { get; set; } = 6;
|
||||||
|
|
||||||
|
[JsonProperty("Enable")] public bool Enable { get; set; } = false;
|
||||||
|
|
||||||
|
[JsonProperty("MinUptime")] public long MinUptime { get; set; } = 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class DatabaseData
|
||||||
|
{
|
||||||
|
[JsonProperty("Database")] public string Database { get; set; } = "moonlight_db";
|
||||||
|
|
||||||
|
[JsonProperty("Host")] public string Host { get; set; } = "your.database.host";
|
||||||
|
|
||||||
|
[JsonProperty("Password")] public string Password { get; set; } = "secret";
|
||||||
|
|
||||||
|
[JsonProperty("Port")] public long Port { get; set; } = 3306;
|
||||||
|
|
||||||
|
[JsonProperty("Username")] public string Username { get; set; } = "moonlight_user";
|
||||||
|
}
|
||||||
|
|
||||||
|
public class DiscordBotData
|
||||||
|
{
|
||||||
|
[JsonProperty("Enable")] public bool Enable { get; set; } = false;
|
||||||
|
|
||||||
|
[JsonProperty("Token")] public string Token { get; set; } = "discord token here";
|
||||||
|
|
||||||
|
[JsonProperty("PowerActions")] public bool PowerActions { get; set; } = false;
|
||||||
|
[JsonProperty("SendCommands")] public bool SendCommands { get; set; } = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class DiscordNotificationsData
|
||||||
|
{
|
||||||
|
[JsonProperty("Enable")] public bool Enable { get; set; } = false;
|
||||||
|
|
||||||
|
[JsonProperty("WebHook")] public string WebHook { get; set; } = "http://your-discord-webhook-url";
|
||||||
|
}
|
||||||
|
|
||||||
|
public class DomainsData
|
||||||
|
{
|
||||||
|
[JsonProperty("Enable")] public bool Enable { get; set; } = false;
|
||||||
|
[JsonProperty("AccountId")] public string AccountId { get; set; } = "cloudflare acc id";
|
||||||
|
|
||||||
|
[JsonProperty("Email")] public string Email { get; set; } = "cloudflare@acc.email";
|
||||||
|
|
||||||
|
[JsonProperty("Key")] public string Key { get; set; } = "secret";
|
||||||
|
}
|
||||||
|
|
||||||
|
public class HtmlData
|
||||||
|
{
|
||||||
|
[JsonProperty("Headers")] public HeadersData Headers { get; set; } = new();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class HeadersData
|
||||||
|
{
|
||||||
|
[JsonProperty("Color")] public string Color { get; set; } = "#4b27e8";
|
||||||
|
|
||||||
|
[JsonProperty("Description")] public string Description { get; set; } = "the next generation hosting panel";
|
||||||
|
|
||||||
|
[JsonProperty("Keywords")] public string Keywords { get; set; } = "moonlight";
|
||||||
|
|
||||||
|
[JsonProperty("Title")] public string Title { get; set; } = "Moonlight - endelon.link";
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MailData
|
||||||
|
{
|
||||||
|
[JsonProperty("Email")] public string Email { get; set; } = "username@your.mail.host";
|
||||||
|
|
||||||
|
[JsonProperty("Server")] public string Server { get; set; } = "your.mail.host";
|
||||||
|
|
||||||
|
[JsonProperty("Password")] public string Password { get; set; } = "secret";
|
||||||
|
|
||||||
|
[JsonProperty("Port")] public int Port { get; set; } = 465;
|
||||||
|
|
||||||
|
[JsonProperty("Ssl")] public bool Ssl { get; set; } = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MarketingData
|
||||||
|
{
|
||||||
|
[JsonProperty("BrandName")] public string BrandName { get; set; } = "Endelon Hosting";
|
||||||
|
|
||||||
|
[JsonProperty("Imprint")] public string Imprint { get; set; } = "https://your-site.xyz/imprint";
|
||||||
|
|
||||||
|
[JsonProperty("Privacy")] public string Privacy { get; set; } = "https://your-site.xyz/privacy";
|
||||||
|
[JsonProperty("About")] public string About { get; set; } = "https://your-site.xyz/about";
|
||||||
|
[JsonProperty("Website")] public string Website { get; set; } = "https://your-site.xyz";
|
||||||
|
}
|
||||||
|
|
||||||
|
public class OAuth2Data
|
||||||
|
{
|
||||||
|
[JsonProperty("OverrideUrl")] public string OverrideUrl { get; set; } = "https://only-for-development.cases";
|
||||||
|
|
||||||
|
[JsonProperty("EnableOverrideUrl")] public bool EnableOverrideUrl { get; set; } = false;
|
||||||
|
|
||||||
|
[JsonProperty("Providers")]
|
||||||
|
public OAuth2ProviderData[] Providers { get; set; } = Array.Empty<OAuth2ProviderData>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class OAuth2ProviderData
|
||||||
|
{
|
||||||
|
[JsonProperty("Id")] public string Id { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("ClientId")] public string ClientId { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("ClientSecret")] public string ClientSecret { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class RatingData
|
||||||
|
{
|
||||||
|
[JsonProperty("Enabled")] public bool Enabled { get; set; } = false;
|
||||||
|
|
||||||
|
[JsonProperty("Url")] public string Url { get; set; } = "https://link-to-google-or-smth";
|
||||||
|
|
||||||
|
[JsonProperty("MinRating")] public int MinRating { get; set; } = 4;
|
||||||
|
|
||||||
|
[JsonProperty("DaysSince")] public int DaysSince { get; set; } = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class SecurityData
|
||||||
|
{
|
||||||
|
[JsonProperty("Token")] public string Token { get; set; } = Guid.NewGuid().ToString();
|
||||||
|
|
||||||
|
[JsonProperty("ReCaptcha")] public ReCaptchaData ReCaptcha { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ReCaptchaData
|
||||||
|
{
|
||||||
|
[JsonProperty("Enable")] public bool Enable { get; set; } = false;
|
||||||
|
|
||||||
|
[JsonProperty("SiteKey")] public string SiteKey { get; set; } = "recaptcha site key here";
|
||||||
|
|
||||||
|
[JsonProperty("SecretKey")] public string SecretKey { get; set; } = "recaptcha secret here";
|
||||||
|
}
|
||||||
|
|
||||||
|
public class SentryData
|
||||||
|
{
|
||||||
|
[JsonProperty("Enable")] public bool Enable { get; set; } = false;
|
||||||
|
|
||||||
|
[JsonProperty("Dsn")] public string Dsn { get; set; } = "http://your-sentry-url-here";
|
||||||
|
}
|
||||||
|
|
||||||
|
public class SmartDeployData
|
||||||
|
{
|
||||||
|
[JsonProperty("Server")] public SmartDeployServerData Server { get; set; } = new();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class SmartDeployServerData
|
||||||
|
{
|
||||||
|
[JsonProperty("EnableOverride")] public bool EnableOverride { get; set; } = false;
|
||||||
|
|
||||||
|
[JsonProperty("OverrideNode")] public long OverrideNode { get; set; } = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class StatisticsData
|
||||||
|
{
|
||||||
|
[JsonProperty("Enabled")] public bool Enabled { get; set; } = false;
|
||||||
|
|
||||||
|
[JsonProperty("Wait")] public long Wait { get; set; } = 15;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class SubscriptionsData
|
||||||
|
{
|
||||||
|
[JsonProperty("SellPass")] public SellPassData SellPass { get; set; } = new();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class SellPassData
|
||||||
|
{
|
||||||
|
[JsonProperty("Enable")] public bool Enable { get; set; } = false;
|
||||||
|
|
||||||
|
[JsonProperty("Url")] public string Url { get; set; } = "https://not-implemented-yet";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -52,14 +52,14 @@ public class DataContext : DbContext
|
|||||||
if (!optionsBuilder.IsConfigured)
|
if (!optionsBuilder.IsConfigured)
|
||||||
{
|
{
|
||||||
var config = ConfigService
|
var config = ConfigService
|
||||||
.GetSection("Moonlight")
|
.Get()
|
||||||
.GetSection("Database");
|
.Moonlight.Database;
|
||||||
|
|
||||||
var connectionString = $"host={config.GetValue<string>("Host")};" +
|
var connectionString = $"host={config.Host};" +
|
||||||
$"port={config.GetValue<int>("Port")};" +
|
$"port={config.Port};" +
|
||||||
$"database={config.GetValue<string>("Database")};" +
|
$"database={config.Database};" +
|
||||||
$"uid={config.GetValue<string>("Username")};" +
|
$"uid={config.Username};" +
|
||||||
$"pwd={config.GetValue<string>("Password")}";
|
$"pwd={config.Password}";
|
||||||
|
|
||||||
optionsBuilder.UseMySql(
|
optionsBuilder.UseMySql(
|
||||||
connectionString,
|
connectionString,
|
||||||
|
|||||||
@@ -66,15 +66,13 @@ public class DatabaseCheckupService
|
|||||||
var configService = new ConfigService(new StorageService());
|
var configService = new ConfigService(new StorageService());
|
||||||
var dateTimeService = new DateTimeService();
|
var dateTimeService = new DateTimeService();
|
||||||
|
|
||||||
var config = configService
|
var config = configService.Get().Moonlight.Database;
|
||||||
.GetSection("Moonlight")
|
|
||||||
.GetSection("Database");
|
|
||||||
|
|
||||||
var connectionString = $"host={config.GetValue<string>("Host")};" +
|
var connectionString = $"host={config.Host};" +
|
||||||
$"port={config.GetValue<int>("Port")};" +
|
$"port={config.Port};" +
|
||||||
$"database={config.GetValue<string>("Database")};" +
|
$"database={config.Database};" +
|
||||||
$"uid={config.GetValue<string>("Username")};" +
|
$"uid={config.Username};" +
|
||||||
$"pwd={config.GetValue<string>("Password")}";
|
$"pwd={config.Password}";
|
||||||
|
|
||||||
string file = PathBuilder.File("storage", "backups", $"{dateTimeService.GetCurrentUnix()}-mysql.sql");
|
string file = PathBuilder.File("storage", "backups", $"{dateTimeService.GetCurrentUnix()}-mysql.sql");
|
||||||
|
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ public class WingsFileAccess : FileAccess
|
|||||||
request.AddParameter("name", "files");
|
request.AddParameter("name", "files");
|
||||||
request.AddParameter("filename", name);
|
request.AddParameter("filename", name);
|
||||||
request.AddHeader("Content-Type", "multipart/form-data");
|
request.AddHeader("Content-Type", "multipart/form-data");
|
||||||
request.AddHeader("Origin", ConfigService.GetSection("Moonlight").GetValue<string>("AppUrl"));
|
request.AddHeader("Origin", ConfigService.Get().Moonlight.AppUrl);
|
||||||
request.AddFile("files", () =>
|
request.AddFile("files", () =>
|
||||||
{
|
{
|
||||||
return new StreamProgressHelper(dataStream)
|
return new StreamProgressHelper(dataStream)
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public class WingsConsoleHelper
|
|||||||
{
|
{
|
||||||
ServerRepository = serverRepository;
|
ServerRepository = serverRepository;
|
||||||
|
|
||||||
AppUrl = configService.GetSection("Moonlight").GetValue<string>("AppUrl");
|
AppUrl = configService.Get().Moonlight.AppUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task ConnectWings(WingsConsole console, Server server)
|
public async Task ConnectWings(WingsConsole console, Server server)
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ public class WingsJwtHelper
|
|||||||
{
|
{
|
||||||
ConfigService = configService;
|
ConfigService = configService;
|
||||||
|
|
||||||
AppUrl = ConfigService.GetSection("Moonlight").GetValue<string>("AppUrl");
|
AppUrl = ConfigService.Get().Moonlight.AppUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Generate(string secret, Action<Dictionary<string, string>> claimsAction)
|
public string Generate(string secret, Action<Dictionary<string, string>> claimsAction)
|
||||||
|
|||||||
@@ -30,14 +30,14 @@ public class DiscordBotController : Controller
|
|||||||
ServerService = serverService;
|
ServerService = serverService;
|
||||||
|
|
||||||
var config = configService
|
var config = configService
|
||||||
.GetSection("Moonlight")
|
.Get()
|
||||||
.GetSection("DiscordBotApi");
|
.Moonlight.DiscordBotApi;
|
||||||
|
|
||||||
Enable = config.GetValue<bool>("Enable");
|
Enable = config.Enable;
|
||||||
|
|
||||||
if (Enable)
|
if (Enable)
|
||||||
{
|
{
|
||||||
Token = config.GetValue<string>("Token");
|
Token = config.Token;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,15 +43,15 @@ public class CleanupService
|
|||||||
CompletedAt = DateTimeService.GetCurrent();
|
CompletedAt = DateTimeService.GetCurrent();
|
||||||
IsRunning = false;
|
IsRunning = false;
|
||||||
|
|
||||||
var config = ConfigService.GetSection("Moonlight").GetSection("Cleanup");
|
var config = ConfigService.Get().Moonlight.Cleanup;
|
||||||
|
|
||||||
if (!config.GetValue<bool>("Enable") || ConfigService.DebugMode)
|
if (!config.Enable || ConfigService.DebugMode)
|
||||||
{
|
{
|
||||||
Logger.Info("Disabling cleanup service");
|
Logger.Info("Disabling cleanup service");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer = new(TimeSpan.FromMinutes(config.GetValue<int>("Wait")));
|
Timer = new(TimeSpan.FromMinutes(config.Wait));
|
||||||
|
|
||||||
Task.Run(Run);
|
Task.Run(Run);
|
||||||
}
|
}
|
||||||
@@ -63,12 +63,12 @@ public class CleanupService
|
|||||||
IsRunning = true;
|
IsRunning = true;
|
||||||
|
|
||||||
using var scope = ServiceScopeFactory.CreateScope();
|
using var scope = ServiceScopeFactory.CreateScope();
|
||||||
var config = ConfigService.GetSection("Moonlight").GetSection("Cleanup");
|
var config = ConfigService.Get().Moonlight.Cleanup;
|
||||||
|
|
||||||
var maxCpu = config.GetValue<int>("Cpu");
|
var maxCpu = config.Cpu;
|
||||||
var minMemory = config.GetValue<int>("Memory");
|
var minMemory = config.Memory;
|
||||||
var maxUptime = config.GetValue<int>("Uptime");
|
var maxUptime = config.Uptime;
|
||||||
var minUptime = config.GetValue<int>("MinUptime");
|
var minUptime = config.MinUptime;
|
||||||
|
|
||||||
var nodeRepository = scope.ServiceProvider.GetRequiredService<NodeRepository>();
|
var nodeRepository = scope.ServiceProvider.GetRequiredService<NodeRepository>();
|
||||||
var nodeService = scope.ServiceProvider.GetRequiredService<NodeService>();
|
var nodeService = scope.ServiceProvider.GetRequiredService<NodeService>();
|
||||||
|
|||||||
@@ -22,14 +22,14 @@ public class DiscordNotificationService
|
|||||||
Event = eventSystem;
|
Event = eventSystem;
|
||||||
ResourceService = resourceService;
|
ResourceService = resourceService;
|
||||||
|
|
||||||
var config = configService.GetSection("Moonlight").GetSection("DiscordNotifications");
|
var config = configService.Get().Moonlight.DiscordNotifications;
|
||||||
|
|
||||||
if (config.GetValue<bool>("Enable"))
|
if (config.Enable)
|
||||||
{
|
{
|
||||||
Logger.Info("Discord notifications enabled");
|
Logger.Info("Discord notifications enabled");
|
||||||
|
|
||||||
Client = new(config.GetValue<string>("WebHook"));
|
Client = new(config.WebHook);
|
||||||
AppUrl = configService.GetSection("Moonlight").GetValue<string>("AppUrl");
|
AppUrl = configService.Get().Moonlight.AppUrl;
|
||||||
|
|
||||||
Event.On<User>("supportChat.new", this, OnNewSupportChat);
|
Event.On<User>("supportChat.new", this, OnNewSupportChat);
|
||||||
Event.On<SupportChatMessage>("supportChat.message", this, OnSupportChatMessage);
|
Event.On<SupportChatMessage>("supportChat.message", this, OnSupportChatMessage);
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
using System.Text;
|
using Moonlight.App.Configuration;
|
||||||
using Microsoft.Extensions.Primitives;
|
|
||||||
using Moonlight.App.Helpers;
|
using Moonlight.App.Helpers;
|
||||||
using Moonlight.App.Services.Files;
|
using Moonlight.App.Services.Files;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace Moonlight.App.Services;
|
namespace Moonlight.App.Services;
|
||||||
|
|
||||||
public class ConfigService : IConfiguration
|
public class ConfigService
|
||||||
{
|
{
|
||||||
private readonly StorageService StorageService;
|
private readonly StorageService StorageService;
|
||||||
|
private ConfigV1 Configuration;
|
||||||
private IConfiguration Configuration;
|
|
||||||
|
|
||||||
public bool DebugMode { get; private set; } = false;
|
public bool DebugMode { get; private set; } = false;
|
||||||
public bool SqlDebugMode { get; private set; } = false;
|
public bool SqlDebugMode { get; private set; } = false;
|
||||||
@@ -41,33 +40,22 @@ public class ConfigService : IConfiguration
|
|||||||
|
|
||||||
public void Reload()
|
public void Reload()
|
||||||
{
|
{
|
||||||
Configuration = new ConfigurationBuilder().AddJsonStream(
|
var path = PathBuilder.File("storage", "configs", "config.json");
|
||||||
new MemoryStream(Encoding.ASCII.GetBytes(
|
|
||||||
File.ReadAllText(
|
if (!File.Exists(path))
|
||||||
PathBuilder.File("storage", "configs", "config.json")
|
{
|
||||||
)
|
File.WriteAllText(path, "{}");
|
||||||
)
|
|
||||||
)).Build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<IConfigurationSection> GetChildren()
|
Configuration = JsonConvert.DeserializeObject<ConfigV1>(
|
||||||
{
|
File.ReadAllText(path)
|
||||||
return Configuration.GetChildren();
|
) ?? new ConfigV1();
|
||||||
|
|
||||||
|
File.WriteAllText(path, JsonConvert.SerializeObject(Configuration));
|
||||||
}
|
}
|
||||||
|
|
||||||
public IChangeToken GetReloadToken()
|
public ConfigV1 Get()
|
||||||
{
|
{
|
||||||
return Configuration.GetReloadToken();
|
return Configuration;
|
||||||
}
|
|
||||||
|
|
||||||
public IConfigurationSection GetSection(string key)
|
|
||||||
{
|
|
||||||
return Configuration.GetSection(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public string this[string key]
|
|
||||||
{
|
|
||||||
get => Configuration[key];
|
|
||||||
set => Configuration[key] = value;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -29,7 +29,7 @@ public class ServerListCommand : BaseModule
|
|||||||
{
|
{
|
||||||
embed = dcs.EmbedBuilderModule.StandardEmbed("Sorry ;( \n Please first create and/or link a Account to Discord! \n Press the Button to register/log in.", Color.Red, command.User);
|
embed = dcs.EmbedBuilderModule.StandardEmbed("Sorry ;( \n Please first create and/or link a Account to Discord! \n Press the Button to register/log in.", Color.Red, command.User);
|
||||||
components = new ComponentBuilder();
|
components = new ComponentBuilder();
|
||||||
components.WithButton("Click Here", style: ButtonStyle.Link, url: ConfigService.GetSection("Moonlight").GetValue<String>("AppUrl"));
|
components.WithButton("Click Here", style: ButtonStyle.Link, url: ConfigService.Get().Moonlight.AppUrl);
|
||||||
|
|
||||||
await command.RespondAsync(embed: embed.Build(), components: components.Build(), ephemeral: true);
|
await command.RespondAsync(embed: embed.Build(), components: components.Build(), ephemeral: true);
|
||||||
return;
|
return;
|
||||||
@@ -57,7 +57,7 @@ public class ServerListCommand : BaseModule
|
|||||||
components.WithButton("Panel",
|
components.WithButton("Panel",
|
||||||
emote: Emote.Parse("<a:Earth:1092814004113657927>"),
|
emote: Emote.Parse("<a:Earth:1092814004113657927>"),
|
||||||
style: ButtonStyle.Link,
|
style: ButtonStyle.Link,
|
||||||
url: $"{ConfigService.GetSection("Moonlight").GetValue<string>("AppUrl")}");
|
url: $"{ConfigService.Get().Moonlight.AppUrl}");
|
||||||
|
|
||||||
if (servers.Count > 25)
|
if (servers.Count > 25)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -44,10 +44,10 @@ public DiscordBotService(
|
|||||||
ServiceScope = ServiceScopeFactory.CreateScope();
|
ServiceScope = ServiceScopeFactory.CreateScope();
|
||||||
|
|
||||||
var discordConfig = ConfigService
|
var discordConfig = ConfigService
|
||||||
.GetSection("Moonlight")
|
.Get()
|
||||||
.GetSection("DiscordBot");
|
.Moonlight.DiscordBot;
|
||||||
|
|
||||||
if (!discordConfig.GetValue<bool>("Enable"))
|
if (!discordConfig.Enable)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Client.Log += Log;
|
Client.Log += Log;
|
||||||
@@ -67,7 +67,7 @@ public DiscordBotService(
|
|||||||
|
|
||||||
await ActivityStatusModule.UpdateActivityStatusList();
|
await ActivityStatusModule.UpdateActivityStatusList();
|
||||||
|
|
||||||
await Client.LoginAsync(TokenType.Bot, discordConfig.GetValue<string>("Token"));
|
await Client.LoginAsync(TokenType.Bot, discordConfig.Token);
|
||||||
await Client.StartAsync();
|
await Client.StartAsync();
|
||||||
|
|
||||||
await Task.Delay(-1);
|
await Task.Delay(-1);
|
||||||
|
|||||||
@@ -87,8 +87,8 @@ public class EmbedBuilderModule : BaseModule
|
|||||||
int[] randomNumbers = new int[] { 1, 3, 8, 11, 20 };
|
int[] randomNumbers = new int[] { 1, 3, 8, 11, 20 };
|
||||||
|
|
||||||
if (randomNumbers.Contains(random.Next(1, 24)))
|
if (randomNumbers.Contains(random.Next(1, 24)))
|
||||||
return new EmbedAuthorBuilder().WithName(Client.CurrentUser.Username + " - The Rick version").WithUrl(ConfigService.GetSection("Moonlight").GetValue<string>("AppUrl")).WithIconUrl("https://cdn.discordapp.com/attachments/750696464014901268/1092783310129860618/rick.gif");
|
return new EmbedAuthorBuilder().WithName(Client.CurrentUser.Username + " - The Rick version").WithUrl(ConfigService.Get().Moonlight.AppUrl).WithIconUrl("https://cdn.discordapp.com/attachments/750696464014901268/1092783310129860618/rick.gif");
|
||||||
|
|
||||||
return new EmbedAuthorBuilder().WithName(Client.CurrentUser.Username).WithUrl(ConfigService.GetSection("Moonlight").GetValue<string>("AppUrl")).WithIconUrl(Client.CurrentUser.GetAvatarUrl());
|
return new EmbedAuthorBuilder().WithName(Client.CurrentUser.Username).WithUrl(ConfigService.Get().Moonlight.AppUrl).WithIconUrl(Client.CurrentUser.GetAvatarUrl());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ public class ServerListComponentHandlerModule : BaseModule
|
|||||||
// stopping
|
// stopping
|
||||||
// offline
|
// offline
|
||||||
// installing
|
// installing
|
||||||
if (!ConfigService.GetSection("Moonlight").GetSection("DiscordBot").GetValue<bool>("PowerActions") && costomId[1] is "Start" or "Restart" or "Stop" or "Kill" or "Update")
|
if (!ConfigService.Get().Moonlight.DiscordBot.PowerActions && costomId[1] is "Start" or "Restart" or "Stop" or "Kill" or "Update")
|
||||||
{
|
{
|
||||||
embed = dcs.EmbedBuilderModule.StandardEmbed($"This feature is disabled for Security reasons! \n If you believe this is a error please contact the Administrators from this panel.", Color.Red, component.User);
|
embed = dcs.EmbedBuilderModule.StandardEmbed($"This feature is disabled for Security reasons! \n If you believe this is a error please contact the Administrators from this panel.", Color.Red, component.User);
|
||||||
await component.RespondAsync(embed: embed.Build(), ephemeral: true);
|
await component.RespondAsync(embed: embed.Build(), ephemeral: true);
|
||||||
@@ -80,7 +80,7 @@ public class ServerListComponentHandlerModule : BaseModule
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ConfigService.GetSection("Moonlight").GetSection("DiscordBot").GetValue<bool>("SendCommands") && costomId[1] is "SendCommand")
|
if (!ConfigService.Get().Moonlight.DiscordBot.SendCommands && costomId[1] is "SendCommand")
|
||||||
{
|
{
|
||||||
embed = dcs.EmbedBuilderModule.StandardEmbed($"This feature is disabled for Security reasons! \n If you believe this is a error please contact the Administrators from this panel.", Color.Red, component.User);
|
embed = dcs.EmbedBuilderModule.StandardEmbed($"This feature is disabled for Security reasons! \n If you believe this is a error please contact the Administrators from this panel.", Color.Red, component.User);
|
||||||
await component.RespondAsync(embed: embed.Build(), ephemeral: true);
|
await component.RespondAsync(embed: embed.Build(), ephemeral: true);
|
||||||
@@ -302,7 +302,7 @@ public class ServerListComponentHandlerModule : BaseModule
|
|||||||
{
|
{
|
||||||
embed = dcs.EmbedBuilderModule.StandardEmbed("Sorry ;( \n Please first create and/or link a Account to Discord! \n Press the Button to register/log in.", Color.Red, component.User);
|
embed = dcs.EmbedBuilderModule.StandardEmbed("Sorry ;( \n Please first create and/or link a Account to Discord! \n Press the Button to register/log in.", Color.Red, component.User);
|
||||||
components = new ComponentBuilder();
|
components = new ComponentBuilder();
|
||||||
components.WithButton("Click Here", style: ButtonStyle.Link, url: ConfigService.GetSection("Moonlight").GetValue<String>("AppUrl"));
|
components.WithButton("Click Here", style: ButtonStyle.Link, url: ConfigService.Get().Moonlight.AppUrl);
|
||||||
|
|
||||||
await component.RespondAsync(embed: embed.Build(), components: components.Build(), ephemeral: true);
|
await component.RespondAsync(embed: embed.Build(), components: components.Build(), ephemeral: true);
|
||||||
return;
|
return;
|
||||||
@@ -332,7 +332,7 @@ public class ServerListComponentHandlerModule : BaseModule
|
|||||||
components.WithButton("Panel",
|
components.WithButton("Panel",
|
||||||
emote: Emote.Parse("<a:Earth:1092814004113657927>"),
|
emote: Emote.Parse("<a:Earth:1092814004113657927>"),
|
||||||
style: ButtonStyle.Link,
|
style: ButtonStyle.Link,
|
||||||
url: $"{ConfigService.GetSection("Moonlight").GetValue<string>("AppUrl")}");
|
url: $"{ConfigService.Get().Moonlight.AppUrl}");
|
||||||
|
|
||||||
components.WithButton("Previous-page",
|
components.WithButton("Previous-page",
|
||||||
emote: Emote.Parse("<:ArrowLeft:1101547474180649030>"),
|
emote: Emote.Parse("<:ArrowLeft:1101547474180649030>"),
|
||||||
@@ -378,7 +378,7 @@ public class ServerListComponentHandlerModule : BaseModule
|
|||||||
|
|
||||||
var components = new ComponentBuilder();
|
var components = new ComponentBuilder();
|
||||||
|
|
||||||
if (ConfigService.GetSection("Moonlight").GetSection("DiscordBot").GetValue<bool>("PowerActions"))
|
if (ConfigService.Get().Moonlight.DiscordBot.PowerActions)
|
||||||
{
|
{
|
||||||
components.WithButton("Start", style: ButtonStyle.Success, customId: $"Sm.Start.{server.Id}", disabled: false);
|
components.WithButton("Start", style: ButtonStyle.Success, customId: $"Sm.Start.{server.Id}", disabled: false);
|
||||||
components.WithButton("Restart", style: ButtonStyle.Primary, customId: $"Sm.Restart.{server.Id}", disabled: false);
|
components.WithButton("Restart", style: ButtonStyle.Primary, customId: $"Sm.Restart.{server.Id}", disabled: false);
|
||||||
@@ -389,14 +389,14 @@ public class ServerListComponentHandlerModule : BaseModule
|
|||||||
components.WithButton("Way2Server",
|
components.WithButton("Way2Server",
|
||||||
emote: Emote.Parse("<a:Earth:1092814004113657927>"),
|
emote: Emote.Parse("<a:Earth:1092814004113657927>"),
|
||||||
style: ButtonStyle.Link,
|
style: ButtonStyle.Link,
|
||||||
url: $"{ConfigService.GetSection("Moonlight").GetValue<string>("AppUrl")}/server/{server.Uuid}");
|
url: $"{ConfigService.Get().Moonlight.AppUrl}/server/{server.Uuid}");
|
||||||
|
|
||||||
components.WithButton("Update",
|
components.WithButton("Update",
|
||||||
emote: Emote.Parse("<:refresh:1101547898803605605>"),
|
emote: Emote.Parse("<:refresh:1101547898803605605>"),
|
||||||
style: ButtonStyle.Secondary,
|
style: ButtonStyle.Secondary,
|
||||||
customId: $"Sm.Update.{server.Id}");
|
customId: $"Sm.Update.{server.Id}");
|
||||||
|
|
||||||
if (ConfigService.GetSection("Moonlight").GetSection("DiscordBot").GetValue<bool>("SendCommands"))
|
if (ConfigService.Get().Moonlight.DiscordBot.SendCommands)
|
||||||
{
|
{
|
||||||
components.WithButton("SendCommand",
|
components.WithButton("SendCommand",
|
||||||
emote: Emote.Parse("<:Console:1101547358157819944>"),
|
emote: Emote.Parse("<:Console:1101547358157819944>"),
|
||||||
|
|||||||
@@ -33,15 +33,15 @@ public class DomainService
|
|||||||
SharedDomainRepository = sharedDomainRepository;
|
SharedDomainRepository = sharedDomainRepository;
|
||||||
|
|
||||||
var config = configService
|
var config = configService
|
||||||
.GetSection("Moonlight")
|
.Get()
|
||||||
.GetSection("Domains");
|
.Moonlight.Domains;
|
||||||
|
|
||||||
AccountId = config.GetValue<string>("AccountId");
|
AccountId = config.AccountId;
|
||||||
|
|
||||||
Client = new(
|
Client = new(
|
||||||
new ApiKeyAuthentication(
|
new ApiKeyAuthentication(
|
||||||
config.GetValue<string>("Email"),
|
config.Email,
|
||||||
config.GetValue<string>("Key")
|
config.Key
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ public class ResourceService
|
|||||||
|
|
||||||
public ResourceService(ConfigService configService)
|
public ResourceService(ConfigService configService)
|
||||||
{
|
{
|
||||||
AppUrl = configService.GetSection("Moonlight").GetValue<string>("AppUrl");
|
AppUrl = configService.Get().Moonlight.AppUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Image(string name)
|
public string Image(string name)
|
||||||
|
|||||||
@@ -25,16 +25,15 @@ public class ReCaptchaService
|
|||||||
ConfigService = configService;
|
ConfigService = configService;
|
||||||
|
|
||||||
var recaptchaConfig = ConfigService
|
var recaptchaConfig = ConfigService
|
||||||
.GetSection("Moonlight")
|
.Get()
|
||||||
.GetSection("Security")
|
.Moonlight.Security.ReCaptcha;
|
||||||
.GetSection("ReCaptcha");
|
|
||||||
|
|
||||||
Enable = recaptchaConfig.GetValue<bool>("Enable");
|
Enable = recaptchaConfig.Enable;
|
||||||
|
|
||||||
if (Enable)
|
if (Enable)
|
||||||
{
|
{
|
||||||
SiteKey = recaptchaConfig.GetValue<string>("SiteKey");
|
SiteKey = recaptchaConfig.SiteKey;
|
||||||
SecretKey = recaptchaConfig.GetValue<string>("SecretKey");
|
SecretKey = recaptchaConfig.SecretKey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,14 +17,14 @@ public class MailService
|
|||||||
public MailService(ConfigService configService)
|
public MailService(ConfigService configService)
|
||||||
{
|
{
|
||||||
var mailConfig = configService
|
var mailConfig = configService
|
||||||
.GetSection("Moonlight")
|
.Get()
|
||||||
.GetSection("Mail");
|
.Moonlight.Mail;
|
||||||
|
|
||||||
Server = mailConfig.GetValue<string>("Server");
|
Server = mailConfig.Server;
|
||||||
Password = mailConfig.GetValue<string>("Password");
|
Password = mailConfig.Password;
|
||||||
Email = mailConfig.GetValue<string>("Email");
|
Email = mailConfig.Email;
|
||||||
Port = mailConfig.GetValue<int>("Port");
|
Port = mailConfig.Port;
|
||||||
Ssl = mailConfig.GetValue<bool>("Ssl");
|
Ssl = mailConfig.Ssl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task SendMail(
|
public async Task SendMail(
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Moonlight.App.Database.Entities;
|
using Mappy.Net;
|
||||||
|
using Moonlight.App.Database.Entities;
|
||||||
using Moonlight.App.Exceptions;
|
using Moonlight.App.Exceptions;
|
||||||
using Moonlight.App.Helpers;
|
using Moonlight.App.Helpers;
|
||||||
using Moonlight.App.Models.Misc;
|
using Moonlight.App.Models.Misc;
|
||||||
@@ -24,14 +25,17 @@ public class OAuth2Service
|
|||||||
ConfigService = configService;
|
ConfigService = configService;
|
||||||
ServiceScopeFactory = serviceScopeFactory;
|
ServiceScopeFactory = serviceScopeFactory;
|
||||||
|
|
||||||
var config = ConfigService.GetSection("Moonlight").GetSection("OAuth2");
|
var config = ConfigService
|
||||||
|
.Get()
|
||||||
|
.Moonlight.OAuth2;
|
||||||
|
|
||||||
Configs = config.GetSection("Providers").Get<OAuth2ProviderConfig[]>()
|
Configs = config.Providers
|
||||||
?? Array.Empty<OAuth2ProviderConfig>();
|
.Select(Mapper.Map<OAuth2ProviderConfig>)
|
||||||
|
.ToArray();
|
||||||
|
|
||||||
OverrideUrl = config.GetValue<string>("OverrideUrl");
|
OverrideUrl = config.OverrideUrl;
|
||||||
EnableOverrideUrl = config.GetValue<bool>("EnableOverrideUrl");
|
EnableOverrideUrl = config.EnableOverrideUrl;
|
||||||
AppUrl = configService.GetSection("Moonlight").GetValue<string>("AppUrl");
|
AppUrl = configService.Get().Moonlight.AppUrl;
|
||||||
|
|
||||||
// Register additional providers here
|
// Register additional providers here
|
||||||
RegisterOAuth2<DiscordOAuth2Provider>("discord");
|
RegisterOAuth2<DiscordOAuth2Provider>("discord");
|
||||||
|
|||||||
@@ -25,10 +25,9 @@ public class OneTimeJwtService
|
|||||||
var opt = new Dictionary<string, string>();
|
var opt = new Dictionary<string, string>();
|
||||||
options.Invoke(opt);
|
options.Invoke(opt);
|
||||||
|
|
||||||
string secret = ConfigService
|
var secret = ConfigService
|
||||||
.GetSection("Moonlight")
|
.Get()
|
||||||
.GetSection("Security")
|
.Moonlight.Security.Token;
|
||||||
.GetValue<string>("Token");
|
|
||||||
|
|
||||||
var id = StringHelper.GenerateString(16);
|
var id = StringHelper.GenerateString(16);
|
||||||
|
|
||||||
@@ -55,10 +54,9 @@ public class OneTimeJwtService
|
|||||||
|
|
||||||
public async Task<Dictionary<string, string>?> Validate(string token)
|
public async Task<Dictionary<string, string>?> Validate(string token)
|
||||||
{
|
{
|
||||||
string secret = ConfigService
|
var secret = ConfigService
|
||||||
.GetSection("Moonlight")
|
.Get()
|
||||||
.GetSection("Security")
|
.Moonlight.Security.Token;
|
||||||
.GetValue<string>("Token");
|
|
||||||
|
|
||||||
string json;
|
string json;
|
||||||
|
|
||||||
|
|||||||
@@ -26,12 +26,12 @@ public class RatingService
|
|||||||
Event = eventSystem;
|
Event = eventSystem;
|
||||||
UserRepository = userRepository;
|
UserRepository = userRepository;
|
||||||
|
|
||||||
var config = configService.GetSection("Moonlight").GetSection("Rating");
|
var config = configService.Get().Moonlight.Rating;
|
||||||
|
|
||||||
Enabled = config.GetValue<bool>("Enabled");
|
Enabled = config.Enabled;
|
||||||
Url = config.GetValue<string>("Url");
|
Url = config.Url;
|
||||||
MinRating = config.GetValue<int>("MinRating");
|
MinRating = config.MinRating;
|
||||||
DaysSince = config.GetValue<int>("DaysSince");
|
DaysSince = config.DaysSince;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> ShouldRate()
|
public async Task<bool> ShouldRate()
|
||||||
|
|||||||
@@ -30,9 +30,8 @@ public class IdentityService
|
|||||||
HttpContextAccessor = httpContextAccessor;
|
HttpContextAccessor = httpContextAccessor;
|
||||||
|
|
||||||
Secret = configService
|
Secret = configService
|
||||||
.GetSection("Moonlight")
|
.Get()
|
||||||
.GetSection("Security")
|
.Moonlight.Security.Token;
|
||||||
.GetValue<string>("Token");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<User?> Get()
|
public async Task<User?> Get()
|
||||||
|
|||||||
@@ -28,13 +28,12 @@ public class SmartDeployService
|
|||||||
public async Task<Node?> GetNode()
|
public async Task<Node?> GetNode()
|
||||||
{
|
{
|
||||||
var config = ConfigService
|
var config = ConfigService
|
||||||
.GetSection("Moonlight")
|
.Get()
|
||||||
.GetSection("SmartDeploy")
|
.Moonlight.SmartDeploy.Server;
|
||||||
.GetSection("Server");
|
|
||||||
|
|
||||||
if (config.GetValue<bool>("EnableOverride"))
|
if (config.EnableOverride)
|
||||||
{
|
{
|
||||||
var nodeId = config.GetValue<int>("OverrideNode");
|
var nodeId = config.OverrideNode;
|
||||||
|
|
||||||
return NodeRepository.Get().FirstOrDefault(x => x.Id == nodeId);
|
return NodeRepository.Get().FirstOrDefault(x => x.Id == nodeId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,13 +17,13 @@ public class StatisticsCaptureService
|
|||||||
DateTimeService = dateTimeService;
|
DateTimeService = dateTimeService;
|
||||||
|
|
||||||
var config = configService
|
var config = configService
|
||||||
.GetSection("Moonlight")
|
.Get()
|
||||||
.GetSection("Statistics");
|
.Moonlight.Statistics;
|
||||||
|
|
||||||
if(!config.GetValue<bool>("Enabled"))
|
if(!config.Enabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var period = TimeSpan.FromMinutes(config.GetValue<int>("Wait"));
|
var period = TimeSpan.FromMinutes(config.Wait);
|
||||||
Timer = new(period);
|
Timer = new(period);
|
||||||
|
|
||||||
Logger.Info("Starting statistics system");
|
Logger.Info("Starting statistics system");
|
||||||
|
|||||||
@@ -38,9 +38,8 @@ public class UserService
|
|||||||
DateTimeService = dateTimeService;
|
DateTimeService = dateTimeService;
|
||||||
|
|
||||||
JwtSecret = configService
|
JwtSecret = configService
|
||||||
.GetSection("Moonlight")
|
.Get()
|
||||||
.GetSection("Security")
|
.Moonlight.Security.Token;
|
||||||
.GetValue<string>("Token");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<string> Register(string email, string password, string firstname, string lastname)
|
public async Task<string> Register(string email, string password, string firstname, string lastname)
|
||||||
|
|||||||
@@ -103,4 +103,12 @@
|
|||||||
<AdditionalFiles Include="Shared\Views\Server\Settings\ServerResetSetting.razor" />
|
<AdditionalFiles Include="Shared\Views\Server\Settings\ServerResetSetting.razor" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Update="storage\configs\config.json.bak">
|
||||||
|
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||||
|
</Content>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -11,12 +11,12 @@
|
|||||||
|
|
||||||
@{
|
@{
|
||||||
var headerConfig = ConfigService
|
var headerConfig = ConfigService
|
||||||
.GetSection("Moonlight")
|
.Get()
|
||||||
.GetSection("Html")
|
.Moonlight.Html.Headers;
|
||||||
.GetSection("Headers");
|
|
||||||
|
|
||||||
var moonlightConfig = ConfigService
|
var moonlightConfig = ConfigService
|
||||||
.GetSection("Moonlight");
|
.Get()
|
||||||
|
.Moonlight;
|
||||||
}
|
}
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
@@ -26,16 +26,16 @@
|
|||||||
|
|
||||||
<meta property="og:locale" content="de_DE"/>
|
<meta property="og:locale" content="de_DE"/>
|
||||||
<meta property="og:type" content="article"/>
|
<meta property="og:type" content="article"/>
|
||||||
<meta content="@(headerConfig.GetValue<string>("Title"))" property="og:title"/>
|
<meta content="@(headerConfig.Title)" property="og:title"/>
|
||||||
<meta content="@(headerConfig.GetValue<string>("Description"))" property="og:description"/>
|
<meta content="@(headerConfig.Description)" property="og:description"/>
|
||||||
<meta content="@(moonlightConfig.GetValue<string>("AppUrl"))" property="og:url"/>
|
<meta content="@(moonlightConfig.AppUrl)" property="og:url"/>
|
||||||
<meta content="@(moonlightConfig.GetValue<string>("AppUrl"))/api/moonlight/resources/images/logolong.png" property="og:image"/>
|
<meta content="@(moonlightConfig.AppUrl)/api/moonlight/resources/images/logolong.png" property="og:image"/>
|
||||||
<meta content="@(headerConfig.GetValue<string>("Color"))" data-react-helmet="true" name="theme-color"/>
|
<meta content="@(headerConfig.Color)" data-react-helmet="true" name="theme-color"/>
|
||||||
|
|
||||||
<meta content="@(headerConfig.GetValue<string>("Description"))" name="description"/>
|
<meta content="@(headerConfig.Description)" name="description"/>
|
||||||
<meta content="@(headerConfig.GetValue<string>("Keywords"))" name="keywords"/>
|
<meta content="@(headerConfig.Keywords)" name="keywords"/>
|
||||||
|
|
||||||
<link rel="shortcut icon" href="@(moonlightConfig.GetValue<string>("AppUrl"))/api/moonlight/resources/images/logo.svg"/>
|
<link rel="shortcut icon" href="@(moonlightConfig.AppUrl)/api/moonlight/resources/images/logo.svg"/>
|
||||||
|
|
||||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Poppins:300,400,500,600,700"/>
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Poppins:300,400,500,600,700"/>
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@
|
|||||||
<div id="flashbang" class="flashbanglight"></div>
|
<div id="flashbang" class="flashbanglight"></div>
|
||||||
|
|
||||||
<div class="app-page-loader flex-column">
|
<div class="app-page-loader flex-column">
|
||||||
<img alt="Logo" src="@(moonlightConfig.GetValue<string>("AppUrl"))/api/moonlight/resources/images/logo.svg" class="h-25px"/>
|
<img alt="Logo" src="@(moonlightConfig.AppUrl)/api/moonlight/resources/images/logo.svg" class="h-25px"/>
|
||||||
|
|
||||||
@{
|
@{
|
||||||
string loadingMessage;
|
string loadingMessage;
|
||||||
|
|||||||
@@ -43,9 +43,8 @@ namespace Moonlight
|
|||||||
// This will also copy all default config files
|
// This will also copy all default config files
|
||||||
var configService = new ConfigService(new StorageService());
|
var configService = new ConfigService(new StorageService());
|
||||||
var shouldUseSentry = configService
|
var shouldUseSentry = configService
|
||||||
.GetSection("Moonlight")
|
.Get()
|
||||||
.GetSection("Sentry")
|
.Moonlight.Sentry.Enable;
|
||||||
.GetValue<bool>("Enable");
|
|
||||||
|
|
||||||
if (configService.DebugMode)
|
if (configService.DebugMode)
|
||||||
{
|
{
|
||||||
@@ -139,9 +138,8 @@ namespace Moonlight
|
|||||||
builder.WebHost.UseSentry(options =>
|
builder.WebHost.UseSentry(options =>
|
||||||
{
|
{
|
||||||
options.Dsn = configService
|
options.Dsn = configService
|
||||||
.GetSection("Moonlight")
|
.Get()
|
||||||
.GetSection("Sentry")
|
.Moonlight.Sentry.Dsn;
|
||||||
.GetValue<string>("Dsn");
|
|
||||||
|
|
||||||
options.Debug = configService.DebugMode;
|
options.Debug = configService.DebugMode;
|
||||||
options.DiagnosticLevel = SentryLevel.Warning;
|
options.DiagnosticLevel = SentryLevel.Warning;
|
||||||
|
|||||||
@@ -1,16 +1,12 @@
|
|||||||
@using Moonlight.App.Services
|
@using Moonlight.App.Services
|
||||||
|
@using Moonlight.App.Services.Files
|
||||||
|
|
||||||
@inject ConfigService ConfigService
|
@inject ResourceService ResourceService
|
||||||
|
|
||||||
@{
|
|
||||||
var moonlightConfig = ConfigService
|
|
||||||
.GetSection("Moonlight");
|
|
||||||
}
|
|
||||||
|
|
||||||
<div class="card card-flush w-lg-650px py-5">
|
<div class="card card-flush w-lg-650px py-5">
|
||||||
<div class="card-body py-15 py-lg-20">
|
<div class="card-body py-15 py-lg-20">
|
||||||
<div class="mb-14">
|
<div class="mb-14">
|
||||||
<img alt="Logo" src="@(moonlightConfig.GetValue<string>("AppUrl"))/api/moonlight/resources/images/logolong.png" class="h-40px">
|
<img alt="Logo" src="@(ResourceService.Image("logolong.png"))" class="h-40px">
|
||||||
</div>
|
</div>
|
||||||
<h1 class="fw-bolder text-gray-900 mb-5"><TL>Your account is banned from moonlight</TL></h1>
|
<h1 class="fw-bolder text-gray-900 mb-5"><TL>Your account is banned from moonlight</TL></h1>
|
||||||
<div class="fw-semibold fs-6 text-gray-500 mb-8">
|
<div class="fw-semibold fs-6 text-gray-500 mb-8">
|
||||||
|
|||||||
@@ -1,16 +1,12 @@
|
|||||||
@using Moonlight.App.Services
|
@using Moonlight.App.Services
|
||||||
|
@using Moonlight.App.Services.Files
|
||||||
|
|
||||||
@inject ConfigService ConfigService
|
@inject ResourceService ResourceService
|
||||||
|
|
||||||
@{
|
|
||||||
var moonlightConfig = ConfigService
|
|
||||||
.GetSection("Moonlight");
|
|
||||||
}
|
|
||||||
|
|
||||||
<div class="card card-flush w-lg-650px py-5">
|
<div class="card card-flush w-lg-650px py-5">
|
||||||
<div class="card-body py-15 py-lg-20">
|
<div class="card-body py-15 py-lg-20">
|
||||||
<div class="mb-14">
|
<div class="mb-14">
|
||||||
<img alt="Logo" src="@(moonlightConfig.GetValue<string>("AppUrl"))/api/moonlight/resources/images/logolong.png" class="h-40px">
|
<img alt="Logo" src="@(ResourceService.Image("logolong.png"))" class="h-40px">
|
||||||
</div>
|
</div>
|
||||||
<h1 class="fw-bolder text-gray-900 mb-5"><TL>Your moonlight account is disabled</TL></h1>
|
<h1 class="fw-bolder text-gray-900 mb-5"><TL>Your moonlight account is disabled</TL></h1>
|
||||||
<div class="fw-semibold fs-6 text-gray-500 mb-8">
|
<div class="fw-semibold fs-6 text-gray-500 mb-8">
|
||||||
|
|||||||
@@ -4,31 +4,31 @@
|
|||||||
|
|
||||||
@{
|
@{
|
||||||
var marketingConfig = ConfigService
|
var marketingConfig = ConfigService
|
||||||
.GetSection("Moonlight")
|
.Get()
|
||||||
.GetSection("Marketing");
|
.Moonlight.Marketing;
|
||||||
}
|
}
|
||||||
|
|
||||||
<div id="kt_app_footer" class="app-footer">
|
<div id="kt_app_footer" class="app-footer">
|
||||||
<div class="app-container container-fluid d-flex flex-column flex-md-row flex-center flex-md-stack py-3">
|
<div class="app-container container-fluid d-flex flex-column flex-md-row flex-center flex-md-stack py-3">
|
||||||
<div class="text-dark order-2 order-md-1">
|
<div class="text-dark order-2 order-md-1">
|
||||||
<span class="text-muted fw-semibold me-1">2022 - @DateTime.Now.Year©</span>
|
<span class="text-muted fw-semibold me-1">2022 - @DateTime.Now.Year©</span>
|
||||||
<a href="@(marketingConfig.GetValue<string>("Website"))" target="_blank" class="text-gray-800 text-hover-primary">
|
<a href="@(marketingConfig.Website)" target="_blank" class="text-gray-800 text-hover-primary">
|
||||||
@(marketingConfig.GetValue<string>("BrandName"))
|
@(marketingConfig.BrandName)
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<ul class="menu menu-gray-600 menu-hover-primary fw-semibold order-1">
|
<ul class="menu menu-gray-600 menu-hover-primary fw-semibold order-1">
|
||||||
<li class="menu-item">
|
<li class="menu-item">
|
||||||
<a href="@(marketingConfig.GetValue<string>("About"))" target="_blank" class="menu-link px-2">
|
<a href="@(marketingConfig.About)" target="_blank" class="menu-link px-2">
|
||||||
<TL>About us</TL>
|
<TL>About us</TL>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="menu-item">
|
<li class="menu-item">
|
||||||
<a href="@(marketingConfig.GetValue<string>("Imprint"))" target="_blank" class="menu-link px-2">
|
<a href="@(marketingConfig.Imprint)" target="_blank" class="menu-link px-2">
|
||||||
<TL>Imprint</TL>
|
<TL>Imprint</TL>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="menu-item">
|
<li class="menu-item">
|
||||||
<a href="@(marketingConfig.GetValue<string>("Privacy"))" target="_blank" class="menu-link px-2">
|
<a href="@(marketingConfig.Privacy)" target="_blank" class="menu-link px-2">
|
||||||
<TL>Privacy</TL>
|
<TL>Privacy</TL>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -1,10 +1,6 @@
|
|||||||
@using Moonlight.App.Services
|
@using Moonlight.App.Services.Files
|
||||||
|
|
||||||
@inject ConfigService ConfigService
|
@inject ResourceService ResourceService
|
||||||
|
|
||||||
@{
|
|
||||||
var moonlightConfig = ConfigService.GetSection("Moonlight");
|
|
||||||
}
|
|
||||||
|
|
||||||
<div id="kt_app_header" class="app-header">
|
<div id="kt_app_header" class="app-header">
|
||||||
<div class="app-container container-fluid d-flex align-items-stretch justify-content-between">
|
<div class="app-container container-fluid d-flex align-items-stretch justify-content-between">
|
||||||
@@ -15,7 +11,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="d-flex align-items-center flex-grow-1 flex-lg-grow-0">
|
<div class="d-flex align-items-center flex-grow-1 flex-lg-grow-0">
|
||||||
<a href="/" class="d-lg-none">
|
<a href="/" class="d-lg-none">
|
||||||
<img alt="Logo" src="@(moonlightConfig.GetValue<string>("AppUrl"))/api/moonlight/resources/images/logo.svg" class="h-30px"/>
|
<img alt="Logo" src="@(ResourceService.Image("logo.svg"))" class="h-30px"/>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="d-flex align-items-stretch justify-content-between flex-lg-grow-1" id="kt_app_header_wrapper">
|
<div class="d-flex align-items-stretch justify-content-between flex-lg-grow-1" id="kt_app_header_wrapper">
|
||||||
|
|||||||
@@ -1,32 +1,28 @@
|
|||||||
@using Moonlight.App.Services.Sessions
|
@using Moonlight.App.Services.Sessions
|
||||||
@using Moonlight.App.Database.Entities
|
@using Moonlight.App.Database.Entities
|
||||||
@using Moonlight.App.Services
|
@using Moonlight.App.Services
|
||||||
|
@using Moonlight.App.Services.Files
|
||||||
|
|
||||||
@inject IdentityService IdentityService
|
@inject IdentityService IdentityService
|
||||||
@inject ConfigService ConfigService
|
@inject ResourceService ResourceService
|
||||||
@inject IJSRuntime JsRuntime
|
@inject IJSRuntime JsRuntime
|
||||||
|
|
||||||
@{
|
|
||||||
var moonlightConfig = ConfigService
|
|
||||||
.GetSection("Moonlight");
|
|
||||||
}
|
|
||||||
|
|
||||||
<div id="kt_app_sidebar" class="app-sidebar flex-column" data-kt-drawer="true" data-kt-drawer-name="app-sidebar" data-kt-drawer-activate="{default: true, lg: false}" data-kt-drawer-overlay="true" data-kt-drawer-width="225px" data-kt-drawer-direction="start" data-kt-drawer-toggle="#kt_app_sidebar_mobile_toggle">
|
<div id="kt_app_sidebar" class="app-sidebar flex-column" data-kt-drawer="true" data-kt-drawer-name="app-sidebar" data-kt-drawer-activate="{default: true, lg: false}" data-kt-drawer-overlay="true" data-kt-drawer-width="225px" data-kt-drawer-direction="start" data-kt-drawer-toggle="#kt_app_sidebar_mobile_toggle">
|
||||||
<div class="app-sidebar-logo px-6" id="kt_app_sidebar_logo">
|
<div class="app-sidebar-logo px-6" id="kt_app_sidebar_logo">
|
||||||
<a href="@(User != null ? "/" : "/login")">
|
<a href="@(User != null ? "/" : "/login")">
|
||||||
@if (sidebar == "dark-sidebar")
|
@if (sidebar == "dark-sidebar")
|
||||||
{
|
{
|
||||||
<img alt="Logo" src="@(moonlightConfig.GetValue<string>("AppUrl"))/api/moonlight/resources/images/logolong.png" class="h-45px app-sidebar-logo-default"/>
|
<img alt="Logo" src="@(ResourceService.Image("logolong.png"))" class="h-45px app-sidebar-logo-default"/>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (sidebar == "light-sidebar")
|
if (sidebar == "light-sidebar")
|
||||||
{
|
{
|
||||||
<img alt="Logo" src="@(moonlightConfig.GetValue<string>("AppUrl"))/api/moonlight/resources/images/logo.svg" class="theme-light-show h-20px app-sidebar-logo-default"/>
|
<img alt="Logo" src="@(ResourceService.Image("logo.svg"))" class="theme-light-show h-20px app-sidebar-logo-default"/>
|
||||||
<img alt="Logo" src="@(moonlightConfig.GetValue<string>("AppUrl"))/api/moonlight/resources/images/logo.svg" class="theme-dark-show h-20px app-sidebar-logo-default"/>
|
<img alt="Logo" src="@(ResourceService.Image("logo.svg"))" class="theme-dark-show h-20px app-sidebar-logo-default"/>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
<img alt="Logo" src="@(moonlightConfig.GetValue<string>("AppUrl"))/api/moonlight/resources/images/logo.svg" class="h-20px app-sidebar-logo-minimize"/>
|
<img alt="Logo" src="@(ResourceService.Image("logo.svg"))" class="h-20px app-sidebar-logo-minimize"/>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<div id="kt_app_sidebar_toggle" class="app-sidebar-toggle btn btn-icon btn-shadow btn-sm btn-color-muted btn-active-color-primary body-bg h-30px w-30px position-absolute top-50 start-100 translate-middle rotate" data-kt-toggle="true" data-kt-toggle-state="active" data-kt-toggle-target="body" data-kt-toggle-name="app-sidebar-minimize">
|
<div id="kt_app_sidebar_toggle" class="app-sidebar-toggle btn btn-icon btn-shadow btn-sm btn-color-muted btn-active-color-primary body-bg h-30px w-30px position-absolute top-50 start-100 translate-middle rotate" data-kt-toggle="true" data-kt-toggle-state="active" data-kt-toggle-target="body" data-kt-toggle-name="app-sidebar-minimize">
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
@using Moonlight.App.Services
|
|
||||||
|
|
||||||
@inject ConfigService ConfigService
|
|
||||||
|
|
||||||
@{
|
|
||||||
var setupComplete = ConfigService
|
|
||||||
.GetSection("Moonlight")
|
|
||||||
.GetValue<bool>("SetupComplete");
|
|
||||||
}
|
|
||||||
|
|
||||||
@if (!setupComplete)
|
|
||||||
{
|
|
||||||
@ChildContent
|
|
||||||
}
|
|
||||||
|
|
||||||
@code
|
|
||||||
{
|
|
||||||
[Parameter]
|
|
||||||
public RenderFragment ChildContent { get; set; }
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
@using Moonlight.App.Services
|
|
||||||
|
|
||||||
@inject ConfigService ConfigService
|
|
||||||
|
|
||||||
@{
|
|
||||||
var setupComplete = ConfigService
|
|
||||||
.GetSection("Moonlight")
|
|
||||||
.GetValue<bool>("SetupComplete");
|
|
||||||
}
|
|
||||||
|
|
||||||
@if (setupComplete)
|
|
||||||
{
|
|
||||||
@ChildContent
|
|
||||||
}
|
|
||||||
|
|
||||||
@code
|
|
||||||
{
|
|
||||||
[Parameter]
|
|
||||||
public RenderFragment ChildContent { get; set; }
|
|
||||||
}
|
|
||||||
@@ -151,8 +151,8 @@
|
|||||||
await lazyLoader.SetText("Loading health check data");
|
await lazyLoader.SetText("Loading health check data");
|
||||||
|
|
||||||
var appUrl = ConfigService
|
var appUrl = ConfigService
|
||||||
.GetSection("Moonlight")
|
.Get()
|
||||||
.GetValue<string>("AppUrl");
|
.Moonlight.AppUrl;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,12 +4,10 @@
|
|||||||
@using Moonlight.App.Services
|
@using Moonlight.App.Services
|
||||||
|
|
||||||
@inject NodeRepository NodeRepository
|
@inject NodeRepository NodeRepository
|
||||||
@inject SmartTranslateService SmartTranslateService
|
|
||||||
@inject ConfigService ConfigService
|
@inject ConfigService ConfigService
|
||||||
@inject NavigationManager NavigationManager
|
|
||||||
|
|
||||||
@{
|
@{
|
||||||
var appUrl = ConfigService.GetSection("Moonlight").GetValue<string>("AppUrl");
|
var appUrl = ConfigService.Get().Moonlight.AppUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
<OnlyAdmin>
|
<OnlyAdmin>
|
||||||
|
|||||||
@@ -24,12 +24,11 @@
|
|||||||
@if (Subscription == null)
|
@if (Subscription == null)
|
||||||
{
|
{
|
||||||
var config = ConfigService
|
var config = ConfigService
|
||||||
.GetSection("Moonlight")
|
.Get()
|
||||||
.GetSection("Subscriptions")
|
.Moonlight.Subscriptions.SellPass;
|
||||||
.GetSection("Sellpass");
|
|
||||||
|
|
||||||
var enableSellpass = config.GetValue<bool>("Enable");
|
var enableSellpass = config.Enable;
|
||||||
var url = config.GetValue<string>("Url");
|
var url = config.Url;
|
||||||
|
|
||||||
<h3 class="mb-2">
|
<h3 class="mb-2">
|
||||||
<div class="input-group mb-3">
|
<div class="input-group mb-3">
|
||||||
|
|||||||
@@ -1,101 +0,0 @@
|
|||||||
{
|
|
||||||
"Moonlight": {
|
|
||||||
"AppUrl": "http://your-moonlight-url.test",
|
|
||||||
"Database": {
|
|
||||||
"Database": "database_name",
|
|
||||||
"Host": "your-moonlight-database-host.de",
|
|
||||||
"Password": "s3cr3t",
|
|
||||||
"Port": "10324",
|
|
||||||
"Username": "user_name"
|
|
||||||
},
|
|
||||||
"DiscordBotApi": {
|
|
||||||
"Enable": false,
|
|
||||||
"Token": "you api key here"
|
|
||||||
},
|
|
||||||
"DiscordBot": {
|
|
||||||
"Enable": false,
|
|
||||||
"Token": "Discord.Token.Here",
|
|
||||||
"PowerActions": false
|
|
||||||
},
|
|
||||||
"Domains": {
|
|
||||||
"_comment": "Cloudflare Api Credentials",
|
|
||||||
"AccountId": "Account Id here",
|
|
||||||
"Email": "Cloudflare Email here",
|
|
||||||
"Key": "Api Key Here"
|
|
||||||
},
|
|
||||||
"Html": {
|
|
||||||
"Headers": {
|
|
||||||
"Color": "#4b27e8",
|
|
||||||
"Description": "the next generation hosting panel",
|
|
||||||
"Keywords": "moonlight",
|
|
||||||
"Title": "Moonlight - moonlight.tld"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Marketing": {
|
|
||||||
"BrandName": "My cool project",
|
|
||||||
"Imprint": "https://mycoolproject.de/imprint",
|
|
||||||
"Privacy": "https://mycoolproject.de/privacy",
|
|
||||||
"Website": "https://mycoolproject.de/"
|
|
||||||
},
|
|
||||||
"OAuth2": {
|
|
||||||
"_exampleProviders": [
|
|
||||||
{
|
|
||||||
"Id": "discord",
|
|
||||||
"ClientId": "",
|
|
||||||
"ClientSecret": ""
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"Id": "google",
|
|
||||||
"ClientId": "",
|
|
||||||
"ClientSecret": ""
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"Providers": [],
|
|
||||||
"EnableOverrideUrl": false,
|
|
||||||
"OverrideUrl": "http://your-moonlight-url.test"
|
|
||||||
},
|
|
||||||
"Security": {
|
|
||||||
"Token": "RANDOM UUID HERE"
|
|
||||||
},
|
|
||||||
"Mail": {
|
|
||||||
"Email": "no-reply@mycoolproject.de",
|
|
||||||
"Server": "mycoolproject.de",
|
|
||||||
"Password": "s3cr3t",
|
|
||||||
"Port": 465,
|
|
||||||
"Ssl": true
|
|
||||||
},
|
|
||||||
"Cleanup": {
|
|
||||||
"Cpu": 90,
|
|
||||||
"Memory": 8192,
|
|
||||||
"Wait": 15,
|
|
||||||
"Uptime": 6,
|
|
||||||
"Enable": false,
|
|
||||||
"MinUptime": 10
|
|
||||||
},
|
|
||||||
"Subscriptions": {
|
|
||||||
"_comment": "Not implemented",
|
|
||||||
"SellPass": {
|
|
||||||
"Enable": false,
|
|
||||||
"Url": ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"DiscordNotifications": {
|
|
||||||
"Enable": false,
|
|
||||||
"WebHook": ""
|
|
||||||
},
|
|
||||||
"Statistics": {
|
|
||||||
"Enabled": true,
|
|
||||||
"Wait": 15
|
|
||||||
},
|
|
||||||
"Rating": {
|
|
||||||
"Enabled": true,
|
|
||||||
"Url": "link-to-google.page",
|
|
||||||
"MinRating": 4,
|
|
||||||
"DaysSince": 5
|
|
||||||
},
|
|
||||||
"Sentry": {
|
|
||||||
"Enable": false,
|
|
||||||
"Dsn": ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user