aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Startup.cs
diff options
context:
space:
mode:
authorJP Dillingham <jpdillingham@gmail.com>2021-01-20 22:26:31 -0600
committerJP Dillingham <jpdillingham@gmail.com>2021-01-20 22:26:31 -0600
commit4876d4a5f024e2223312e95999f9be12bd8511fc (patch)
treefe0e16fa2f4bb3873f321f9d5da244b0d2473a44 /src/slskd/Startup.cs
parentcec869b9456cf6fe5597847948b2d75b9846755a (diff)
downloadslskd-4876d4a5f024e2223312e95999f9be12bd8511fc.tar.gz
wip
Diffstat (limited to 'src/slskd/Startup.cs')
-rw-r--r--src/slskd/Startup.cs34
1 files changed, 30 insertions, 4 deletions
diff --git a/src/slskd/Startup.cs b/src/slskd/Startup.cs
index 37a3c7cd..9dd9f52d 100644
--- a/src/slskd/Startup.cs
+++ b/src/slskd/Startup.cs
@@ -32,6 +32,7 @@
using Microsoft.Extensions.Logging;
using Prometheus;
using Prometheus.SystemMetrics;
+ using Microsoft.Extensions.Options;
public class Startup
{
@@ -101,6 +102,20 @@
public void ConfigureServices(IServiceCollection services)
{
+ services.AddOptions<Options.Soulseek>()
+ .Bind(Configuration.GetSection("soulseek"));
+
+ services.PostConfigure<List<Options.User>>(slskd =>
+ {
+ Console.WriteLine($"config updated");
+ Console.WriteLine(JsonSerializer.Serialize(slskd));
+ });
+
+ services.AddOptions<List<string>>().Bind(Configuration.GetSection("sparse"));
+ services.PostConfigure<List<string>>(s => Console.WriteLine(JsonSerializer.Serialize(s)));
+
+ services.AddOptions<List<Options.User>>().Bind(Configuration.GetSection("users"));
+
services.AddCors(options => options.AddPolicy("AllowAll", builder => builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader()));
if (!Program.DisableAuthentication)
@@ -184,6 +199,9 @@
ITransferTracker tracker,
IBrowseTracker browseTracker,
IConversationTracker conversationTracker,
+ IOptionsMonitor<Options.Soulseek> optionsAccessor,
+ IOptionsMonitor<List<Options.User>> users,
+ IOptionsMonitor<List<string>> sparse,
IRoomTracker roomTracker)
{
if (!env.IsDevelopment())
@@ -191,6 +209,14 @@
app.UseHsts();
}
+ optionsAccessor.OnChange(options =>
+ {
+ Console.WriteLine(JsonSerializer.Serialize(optionsAccessor));
+ });
+
+ sparse.OnChange(v => Console.WriteLine(JsonSerializer.Serialize(v)));
+ users.OnChange(users => Console.WriteLine(JsonSerializer.Serialize(users)));
+
app.UseCors("AllowAll");
app.UsePathBase(BasePath);
@@ -395,10 +421,10 @@
}
};
- Task.Run(async () =>
- {
- await Client.ConnectAsync(Username, Password);
- }).GetAwaiter().GetResult();
+ //Task.Run(async () =>
+ //{
+ // await Client.ConnectAsync(Username, Password);
+ //}).GetAwaiter().GetResult();
logger.LogInformation("Connected and logged in as {Username}", Username);
}