mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2024-11-14 10:49:41 +01:00
hactoolnet: Don't output unknown key warnings by default
This commit is contained in:
parent
33446b4fbd
commit
cd4004af19
3 changed files with 31 additions and 2 deletions
|
@ -18,6 +18,7 @@ internal static class CliParser
|
||||||
new CliOption("dev", 'd', 0, (o, _) => o.UseDevKeys = true),
|
new CliOption("dev", 'd', 0, (o, _) => o.UseDevKeys = true),
|
||||||
new CliOption("enablehash", 'h', 0, (o, _) => o.EnableHash = true),
|
new CliOption("enablehash", 'h', 0, (o, _) => o.EnableHash = true),
|
||||||
new CliOption("disablekeywarns", 0, (o, _) => o.DisableKeyWarns = true),
|
new CliOption("disablekeywarns", 0, (o, _) => o.DisableKeyWarns = true),
|
||||||
|
new CliOption("enableallkeywarns", 0, (o, _) => o.EnableAllKeyWarns = true),
|
||||||
new CliOption("keyset", 'k', 1, (o, a) => o.Keyfile = a[0]),
|
new CliOption("keyset", 'k', 1, (o, a) => o.Keyfile = a[0]),
|
||||||
new CliOption("titlekeys", 1, (o, a) => o.TitleKeyFile = a[0]),
|
new CliOption("titlekeys", 1, (o, a) => o.TitleKeyFile = a[0]),
|
||||||
new CliOption("consolekeys", 1, (o, a) => o.ConsoleKeyFile = a[0]),
|
new CliOption("consolekeys", 1, (o, a) => o.ConsoleKeyFile = a[0]),
|
||||||
|
@ -254,6 +255,7 @@ internal static class CliParser
|
||||||
sb.AppendLine(" --titlekeys <file> Load title keys from an external file.");
|
sb.AppendLine(" --titlekeys <file> Load title keys from an external file.");
|
||||||
sb.AppendLine(" --accesslog <file> Specify the access log file path.");
|
sb.AppendLine(" --accesslog <file> Specify the access log file path.");
|
||||||
sb.AppendLine(" --disablekeywarns Disables warning output when loading external keys.");
|
sb.AppendLine(" --disablekeywarns Disables warning output when loading external keys.");
|
||||||
|
sb.AppendLine(" --enableallkeywarns Enables warning output when loading unknown external keys.");
|
||||||
sb.AppendLine(" --version Display version information and exit.");
|
sb.AppendLine(" --version Display version information and exit.");
|
||||||
sb.AppendLine(" --help Display this help and exit.");
|
sb.AppendLine(" --help Display this help and exit.");
|
||||||
sb.AppendLine("NCA options:");
|
sb.AppendLine("NCA options:");
|
||||||
|
|
|
@ -17,6 +17,7 @@ internal class Options
|
||||||
public bool UseDevKeys;
|
public bool UseDevKeys;
|
||||||
public bool EnableHash;
|
public bool EnableHash;
|
||||||
public bool DisableKeyWarns;
|
public bool DisableKeyWarns;
|
||||||
|
public bool EnableAllKeyWarns;
|
||||||
public string Keyfile;
|
public string Keyfile;
|
||||||
public string TitleKeyFile;
|
public string TitleKeyFile;
|
||||||
public string ConsoleKeyFile;
|
public string ConsoleKeyFile;
|
||||||
|
|
|
@ -190,7 +190,7 @@ public static class Program
|
||||||
private static void OpenKeySet(Context ctx)
|
private static void OpenKeySet(Context ctx)
|
||||||
{
|
{
|
||||||
#if NATIVEAOT_NO_REFLECTION
|
#if NATIVEAOT_NO_REFLECTION
|
||||||
string home = HomeFolder.GetFolderPath(Environment.SpecialFolder.UserProfile);
|
string home = HomeFolder.GetFolderPath(Environment.SpecialFolder.UserProfile);
|
||||||
#else
|
#else
|
||||||
string home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
|
string home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
|
||||||
#endif
|
#endif
|
||||||
|
@ -224,7 +224,7 @@ public static class Program
|
||||||
|
|
||||||
var keySet = KeySet.CreateDefaultKeySet();
|
var keySet = KeySet.CreateDefaultKeySet();
|
||||||
|
|
||||||
IProgressReport logger = ctx.Options.DisableKeyWarns ? null : ctx.Logger;
|
IProgressReport logger = GetKeySetReaderLogger(ctx);
|
||||||
|
|
||||||
// If the user specifies a key file then only load that file into the mode they specified,
|
// If the user specifies a key file then only load that file into the mode they specified,
|
||||||
// otherwise load both prod.keys and dev.keys.
|
// otherwise load both prod.keys and dev.keys.
|
||||||
|
@ -283,6 +283,32 @@ public static class Program
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static IProgressReport GetKeySetReaderLogger(Context ctx)
|
||||||
|
{
|
||||||
|
if (ctx.Options.DisableKeyWarns) return null;
|
||||||
|
if (ctx.Options.EnableAllKeyWarns) return ctx.Logger;
|
||||||
|
return new UnknownKeyFilteringLogger(ctx.Logger);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Key dumpers output keys LibHac doesn't read. This can cause a lot of noise in the CLI output,
|
||||||
|
// so we'll remove those messages.
|
||||||
|
private class UnknownKeyFilteringLogger : IProgressReport
|
||||||
|
{
|
||||||
|
private IProgressReport _baseLogger;
|
||||||
|
public UnknownKeyFilteringLogger(IProgressReport baseLogger) => _baseLogger = baseLogger;
|
||||||
|
|
||||||
|
public void Report(long value) => _baseLogger.Report(value);
|
||||||
|
public void ReportAdd(long value) => _baseLogger.ReportAdd(value);
|
||||||
|
public void SetTotal(long value) => _baseLogger.SetTotal(value);
|
||||||
|
|
||||||
|
public void LogMessage(string message)
|
||||||
|
{
|
||||||
|
if (!message.StartsWith("Failed to match key"))
|
||||||
|
_baseLogger.LogMessage(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// For running random stuff
|
// For running random stuff
|
||||||
// ReSharper disable once UnusedParameter.Local
|
// ReSharper disable once UnusedParameter.Local
|
||||||
private static void CustomTask(Context ctx)
|
private static void CustomTask(Context ctx)
|
||||||
|
|
Loading…
Reference in a new issue