added config to diagnose, while censoring sensitive data
This commit is contained in:
@@ -1,4 +1,7 @@
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Text.Json;
|
||||||
|
using MoonCore.Helpers;
|
||||||
|
using Moonlight.ApiServer.Configuration;
|
||||||
using Moonlight.ApiServer.Interfaces;
|
using Moonlight.ApiServer.Interfaces;
|
||||||
using Moonlight.ApiServer.Models.Diagnose;
|
using Moonlight.ApiServer.Models.Diagnose;
|
||||||
|
|
||||||
@@ -8,13 +11,58 @@ public class CoreDiagnoseProvider : IDiagnoseProvider
|
|||||||
{
|
{
|
||||||
public DiagnoseEntry[] GetFiles()
|
public DiagnoseEntry[] GetFiles()
|
||||||
{
|
{
|
||||||
|
// TODO:
|
||||||
|
// - read logs out from file for the diagnose below
|
||||||
|
|
||||||
return
|
return
|
||||||
[
|
[
|
||||||
new DiagnoseFile()
|
new DiagnoseDirectory()
|
||||||
{
|
{
|
||||||
Name = "test.txt",
|
Name = "core",
|
||||||
GetContent = () => Encoding.UTF8.GetBytes("hello world")
|
Children = [
|
||||||
|
|
||||||
|
new DiagnoseFile()
|
||||||
|
{
|
||||||
|
Name = "logs.txt",
|
||||||
|
GetContent = () => Encoding.UTF8.GetBytes("placeholder")
|
||||||
|
},
|
||||||
|
|
||||||
|
new DiagnoseFile()
|
||||||
|
{
|
||||||
|
Name = "logs.txt",
|
||||||
|
GetContent = () =>
|
||||||
|
{
|
||||||
|
|
||||||
|
var configJson = File.ReadAllText(PathBuilder.File("storage", "app.json"));
|
||||||
|
|
||||||
|
var config = JsonSerializer.Deserialize<AppConfiguration>(configJson);
|
||||||
|
|
||||||
|
if (config == null)
|
||||||
|
{
|
||||||
|
return Encoding.UTF8.GetBytes("could not fetch config");
|
||||||
|
}
|
||||||
|
|
||||||
|
config.Database.Password = CheckForNullOrEmpty(config.Database.Password);
|
||||||
|
|
||||||
|
config.Authentication.OAuth2.ClientSecret = CheckForNullOrEmpty(config.Authentication.OAuth2.ClientSecret);
|
||||||
|
|
||||||
|
config.Authentication.OAuth2.Secret = CheckForNullOrEmpty(config.Authentication.OAuth2.Secret);
|
||||||
|
|
||||||
|
config.Authentication.Secret = CheckForNullOrEmpty(config.Authentication.Secret);
|
||||||
|
|
||||||
|
return Encoding.UTF8.GetBytes(JsonSerializer.Serialize(config));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
]
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string CheckForNullOrEmpty(string? content)
|
||||||
|
{
|
||||||
|
return string.IsNullOrEmpty(content)
|
||||||
|
? "ISEMPTY"
|
||||||
|
: "ISNOTEMPTY";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user