Skip to content

Commit

Permalink
remove additional logging and tries
Browse files Browse the repository at this point in the history
  • Loading branch information
forsthug committed Jan 11, 2024
1 parent 23328cd commit 4237dc3
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 25 deletions.
13 changes: 3 additions & 10 deletions src/fiskaltrust.Launcher/Commands/Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,11 @@ public static async Task<int> HandleAsync<O, S>(
Func<CommonOptions, CommonProperties, O, S, Task<int>> handler) where S : notnull
{
Log.Verbose("call CommonHandler HandleAsync");
/*

var collectionSink = new CollectionSink();
Log.Logger = new LoggerConfiguration()
.WriteTo.Sink(collectionSink)
.CreateLogger();
*/

var launcherConfiguration = new LauncherConfiguration();

Expand Down Expand Up @@ -203,7 +202,6 @@ public static async Task<int> HandleAsync<O, S>(
.Enrich.FromLogContext()
.CreateLogger();

/*
foreach (var logEvent in collectionSink.Events)
{
Log.Write(logEvent);
Expand All @@ -212,27 +210,22 @@ public static async Task<int> HandleAsync<O, S>(
if (collectionSink.Events.Where(e => e.Level == LogEventLevel.Fatal).Any())
{
return 1;
}*/
}

Log.Debug("Launcher Configuration File: {LauncherConfigurationFile}", options.LauncherConfigurationFile);
Log.Debug("Cashbox Configuration File: {CashboxConfigurationFile}", launcherConfiguration.CashboxConfigurationFile);
Log.Debug("Launcher Configuration: {@LauncherConfiguration}", launcherConfiguration.Redacted());


var dataProtectionProvider = DataProtectionExtensions.Create(launcherConfiguration.AccessToken, useFallback: launcherConfiguration.UseLegacyDataProtection!.Value);
Log.Verbose($"dataProtectionProvider is null: {dataProtectionProvider == null}");
try
{
if (!launcherConfiguration.UseLegacyDataProtection!.Value)
{
launcherConfiguration.Decrypt(dataProtectionProvider.CreateProtector(LauncherConfiguration.DATA_PROTECTION_DATA_PURPOSE));
}
launcherConfiguration.Decrypt(dataProtectionProvider.CreateProtector(LauncherConfiguration.DATA_PROTECTION_DATA_PURPOSE));
}
catch (Exception e)
{
Log.Warning(e, "Error decrypring launcher configuration file.");
}
Log.Verbose($"finished handler");

return await handler(options, new CommonProperties(launcherConfiguration, cashboxConfiguration, clientEcdh, dataProtectionProvider), specificOptions, host.Services.GetRequiredService<S>());
}
Expand Down
2 changes: 1 addition & 1 deletion src/fiskaltrust.Launcher/Commands/DoctorCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public static async Task<int> HandleAsync(CommonOptions commonOptions, CommonPro
}

var dataProtectionProvider = checkUp.Check("Setup data protection", () => DataProtectionExtensions.Create(launcherConfiguration.AccessToken, useFallback: launcherConfiguration.UseLegacyDataProtection!.Value));
if (dataProtectionProvider is not null && !launcherConfiguration.UseLegacyDataProtection!.Value)
if (dataProtectionProvider is not null)
{
checkUp.Check("Decrypt launcher configuration", () => launcherConfiguration.Decrypt(dataProtectionProvider.CreateProtector(LauncherConfiguration.DATA_PROTECTION_DATA_PURPOSE)));
}
Expand Down
13 changes: 3 additions & 10 deletions src/fiskaltrust.Launcher/Commands/RunCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,7 @@ public static class RunHandler
{
public static async Task<int> HandleAsync(CommonOptions commonOptions, CommonProperties commonProperties, RunOptions _, RunServices runServices)
{
Log.Verbose($"RunHandler call");
Log.Verbose($"runServices.LauncherExecutablePath {runServices.LauncherExecutablePath.Path}");
var builder = WebApplication.CreateBuilder();
Log.Verbose($"WebApplication.CreateBuilder()");
builder.Host
.UseSystemd()
.UseSerilog()
Expand All @@ -87,7 +84,6 @@ public static async Task<int> HandleAsync(CommonOptions commonOptions, CommonPro
services.AddSingleton(_ => runServices.LauncherExecutablePath);
});

Log.Verbose($"RunHandler builder.Host");
builder.WebHost.ConfigureBinding(new Uri($"http://[::1]:{commonProperties.LauncherConfiguration.LauncherPort}"), protocols: HttpProtocols.Http2);

builder.Services.AddCodeFirstGrpc();
Expand All @@ -98,11 +94,9 @@ public static async Task<int> HandleAsync(CommonOptions commonOptions, CommonPro
#pragma warning disable ASP0014
app.UseEndpoints(endpoints => endpoints.MapGrpcService<ProcessHostService>());
#pragma warning restore ASP0014
Log.Verbose($"RunHandler PrepareSelfUpdate.call");
try {
await runServices.SelfUpdater.PrepareSelfUpdate(Log.Logger, commonProperties.LauncherConfiguration, app.Services.GetRequiredService<PackageDownloader>());
} catch (Exception e) { Log.Error(e, "An unhandled exception occured."); return 1;}
Log.Verbose($"RunHandler PrepareSelfUpdate.end");

await runServices.SelfUpdater.PrepareSelfUpdate(Log.Logger, commonProperties.LauncherConfiguration, app.Services.GetRequiredService<PackageDownloader>());

try
{
await app.RunAsync(runServices.Lifetime.ApplicationLifetime.ApplicationStopping);
Expand All @@ -118,7 +112,6 @@ public static async Task<int> HandleAsync(CommonOptions commonOptions, CommonPro
{
Log.CloseAndFlush();
}
Log.Verbose($"RunHandler end");
return 0;
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/fiskaltrust.Launcher/Download/PackageDownloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ public async Task DownloadAsync(string name, string version, string platform, st
return request;
});
_logger?.LogInformation("response1");
response.EnsureSuccessStatusCode();

await using var fileStream = new FileStream(sourcePath, FileMode.Create, FileAccess.Write, FileShare.None);
Expand All @@ -163,7 +162,6 @@ public async Task DownloadAsync(string name, string version, string platform, st
return request;
});
_logger?.LogInformation("response2");
response.EnsureSuccessStatusCode();
await File.WriteAllTextAsync($"{sourcePath}.hash", await response.Content.ReadAsStringAsync());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public static IDataProtectionBuilder ProtectKeysCustom(this IDataProtectionBuild
}
else if (OperatingSystem.IsLinux())
{
Log.Warning("Fallback config encryption mechanism used.");
Log.Warning("Fallback config encryption mechanism is used on linux.");
}
else if (OperatingSystem.IsMacOS())
{
Expand All @@ -210,7 +210,6 @@ public static IDataProtectionBuilder ProtectKeysCustom(this IDataProtectionBuild

Log.Debug("Fallback config encryption mechanism used.");
builder.Services.Configure<KeyManagementOptions>(options => options.XmlEncryptor = new LegacyXmlEncryptor(builder.Services));
Log.Verbose("config KeyManagementOptions");
return builder;
}
}
Expand Down

0 comments on commit 4237dc3

Please sign in to comment.