aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Common/Extensions.cs
diff options
context:
space:
mode:
authorJP Dillingham <jpdillingham@gmail.com>2021-12-08 20:04:16 -0600
committerJP Dillingham <jpdillingham@gmail.com>2021-12-08 20:04:16 -0600
commit731e2599f2bd5128a85ecd612982f5b1cfd60705 (patch)
tree2286c1c2c8c09c3e1bb8d58118b7ef5cbba31db6 /src/slskd/Common/Extensions.cs
parent81e9f82a0476dd98452681a887756a07ec5ab85f (diff)
downloadslskd-731e2599f2bd5128a85ecd612982f5b1cfd60705.tar.gz
finish Redactor and add extension
Diffstat (limited to 'src/slskd/Common/Extensions.cs')
-rw-r--r--src/slskd/Common/Extensions.cs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/slskd/Common/Extensions.cs b/src/slskd/Common/Extensions.cs
index d678541d..be5bcf16 100644
--- a/src/slskd/Common/Extensions.cs
+++ b/src/slskd/Common/Extensions.cs
@@ -308,6 +308,21 @@ namespace slskd
}
/// <summary>
+ /// Redacts this instance of Options, replacing properties marked with <see cref="SecretAttribute"/> with '*****'.
+ /// </summary>
+ /// <remarks>
+ /// Creates a deep clone before redacting.
+ /// </remarks>
+ /// <param name="options">The Options instance to redact.</param>
+ /// <returns>A redacted instance.</returns>
+ public static Options Redact(this Options options)
+ {
+ var redacted = options.ToJson().FromJson<Options>();
+ Redactor.Redact(redacted);
+ return redacted;
+ }
+
+ /// <summary>
/// Creates a copy of this instance with the specified parameters changed.
/// </summary>
/// <param name="o">The options instance to copy.</param>
@@ -350,6 +365,7 @@ namespace slskd
var options = new JsonSerializerOptions();
options.Converters.Add(new IPAddressConverter());
options.Converters.Add(new JsonStringEnumConverter());
+ options.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
options.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;
return options;
}