Reimplemented config in diagnose file and added node data
This commit is contained in:
22
Moonlight/Core/Extensions/ConfigServiceExtensions.cs
Normal file
22
Moonlight/Core/Extensions/ConfigServiceExtensions.cs
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
using MoonCore.Services;
|
||||||
|
using Moonlight.Core.Configuration;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace Moonlight.Core.Extensions;
|
||||||
|
|
||||||
|
public static class ConfigServiceExtensions
|
||||||
|
{
|
||||||
|
public static string GetDiagnosticJson(this ConfigService<ConfigV1> configService)
|
||||||
|
{
|
||||||
|
var jsonUnsafe = JsonConvert.SerializeObject(configService.Get());
|
||||||
|
var configUnsafe = JsonConvert.DeserializeObject<ConfigV1>(jsonUnsafe)!;
|
||||||
|
|
||||||
|
// Remote sensitive data
|
||||||
|
configUnsafe.Database.Password =
|
||||||
|
string.IsNullOrEmpty(configUnsafe.Database.Password) ? "IS EMPTY" : "IS NOT EMPTY";
|
||||||
|
configUnsafe.Security.Token = string.IsNullOrEmpty(configUnsafe.Security.Token) ? "IS EMPTY" : "IS NOT EMPTY";
|
||||||
|
configUnsafe.MailServer.Password =string.IsNullOrEmpty(configUnsafe.MailServer.Password) ? "IS EMPTY" : "IS NOT EMPTY";
|
||||||
|
|
||||||
|
return JsonConvert.SerializeObject(configUnsafe, Formatting.Indented);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,11 +1,14 @@
|
|||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
|
using MoonCore.Abstractions;
|
||||||
using MoonCore.Attributes;
|
using MoonCore.Attributes;
|
||||||
using MoonCore.Helpers;
|
using MoonCore.Helpers;
|
||||||
using MoonCore.Services;
|
using MoonCore.Services;
|
||||||
using Moonlight.Core.Configuration;
|
using Moonlight.Core.Configuration;
|
||||||
using Moonlight.Core.Event;
|
using Moonlight.Core.Event;
|
||||||
using Moonlight.Core.Extensions;
|
using Moonlight.Core.Extensions;
|
||||||
|
using Moonlight.Features.Servers.Entities;
|
||||||
using Moonlight.Features.Theming.Services;
|
using Moonlight.Features.Theming.Services;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace Moonlight.Core.Services;
|
namespace Moonlight.Core.Services;
|
||||||
|
|
||||||
@@ -55,13 +58,22 @@ public class MoonlightService // This service can be used to perform strictly pa
|
|||||||
|
|
||||||
await zip.AddFromText("log.txt", log);
|
await zip.AddFromText("log.txt", log);
|
||||||
|
|
||||||
// TODO: Add node settings here
|
// Add node config
|
||||||
|
var nodeRepo = scope.ServiceProvider.GetRequiredService<Repository<ServerNode>>();
|
||||||
|
var nodes = nodeRepo.Get().ToArray();
|
||||||
|
|
||||||
// TODO: Reimplement as extension here
|
foreach (var node in nodes)
|
||||||
|
{
|
||||||
|
// Remove sensitive data
|
||||||
|
node.Token = string.IsNullOrEmpty(node.Token) ? "IS EMPTY" : "IS NOT EMPTY";
|
||||||
|
}
|
||||||
|
|
||||||
|
var nodesJson = JsonConvert.SerializeObject(nodes, Formatting.Indented);
|
||||||
|
await zip.AddFromText("nodes.json", nodesJson);
|
||||||
|
|
||||||
// Add config
|
// Add config
|
||||||
//var config = ConfigService.GetDiagnoseJson();
|
var configJson = ConfigService.GetDiagnosticJson();
|
||||||
//await zip.AddFromText("config.json", config);
|
await zip.AddFromText("config.json", configJson);
|
||||||
|
|
||||||
// Make a list of plugins
|
// Make a list of plugins
|
||||||
var pluginService = scope.ServiceProvider.GetRequiredService<PluginService>();
|
var pluginService = scope.ServiceProvider.GetRequiredService<PluginService>();
|
||||||
|
|||||||
Reference in New Issue
Block a user