aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJP Dillingham <jpdillingham@gmail.com>2021-01-31 22:34:29 -0600
committerJP Dillingham <jpdillingham@gmail.com>2021-01-31 22:34:29 -0600
commit2ae3d78e9bc56de3dde214d647ee9d0ec5008194 (patch)
tree0eaa6b77c8bc3f4352e1a12290ee96a79539a32f /src
parent35eda81d130f84912396de9f2e4771ff03aad20e (diff)
downloadslskd-2ae3d78e9bc56de3dde214d647ee9d0ec5008194.tar.gz
remove remaining legacy options
Diffstat (limited to 'src')
-rw-r--r--src/slskd/Controllers/TransfersController.cs7
-rw-r--r--src/slskd/Startup.cs37
2 files changed, 16 insertions, 28 deletions
diff --git a/src/slskd/Controllers/TransfersController.cs b/src/slskd/Controllers/TransfersController.cs
index d4fa3f79..505e84e5 100644
--- a/src/slskd/Controllers/TransfersController.cs
+++ b/src/slskd/Controllers/TransfersController.cs
@@ -12,6 +12,7 @@
using System.Threading.Tasks;
using slskd.DTO;
using slskd.Trackers;
+ using Microsoft.Extensions.Options;
/// <summary>
/// Transfers
@@ -26,12 +27,12 @@
/// <summary>
/// Initializes a new instance of the <see cref="TransfersController"/> class.
/// </summary>
- /// <param name="configuration"></param>
+ /// <param name="options"></param>
/// <param name="client"></param>
/// <param name="tracker"></param>
- public TransfersController(IConfiguration configuration, ISoulseekClient client, ITransferTracker tracker)
+ public TransfersController(IOptionsSnapshot<slskd.Options> options, ISoulseekClient client, ITransferTracker tracker)
{
- OutputDirectory = configuration.GetValue<string>("OUTPUT_DIR");
+ OutputDirectory = options.Value.Directories.Downloads;
Client = client;
Tracker = tracker;
}
diff --git a/src/slskd/Startup.cs b/src/slskd/Startup.cs
index 3479926b..31542f1a 100644
--- a/src/slskd/Startup.cs
+++ b/src/slskd/Startup.cs
@@ -36,13 +36,7 @@
{
private readonly int MaxReconnectAttempts = 3;
private int CurrentReconnectAttempts = 0;
-
- internal static string OutputDirectory { get; set; }
- internal static string SharedDirectory { get; set; }
- internal static long SharedCacheTTL { get; set; }
- internal static DiagnosticLevel DiagnosticLevel { get; set; }
- internal static int RoomMessageLimit { get; set; }
- internal static string XmlDocFile { get; set; }
+ private static readonly string XmlDocFile = Path.Combine(AppContext.BaseDirectory, typeof(Startup).GetTypeInfo().Assembly.GetName().Name + ".xml");
private SoulseekClient Client { get; set; }
private ISharedFileCache SharedFileCache { get; set; }
@@ -60,14 +54,14 @@
o.BindNonPublicProperties = true;
});
- OutputDirectory = Configuration.GetValue<string>("OUTPUT_DIR");
- SharedDirectory = Configuration.GetValue<string>("SHARED_DIR");
- SharedCacheTTL = Configuration.GetValue<long>("SHARED_CACHE_TTL", 3600000); // 1 hour
- DiagnosticLevel = Configuration.GetValue<DiagnosticLevel>("DIAGNOSTIC", DiagnosticLevel.Info);
- RoomMessageLimit = Configuration.GetValue<int>("ROOM_MESSAGE_LIMIT", 250);
- XmlDocFile = Configuration.GetValue<string>("XML_DOC_FILE", Path.Combine(AppContext.BaseDirectory, typeof(Startup).GetTypeInfo().Assembly.GetName().Name + ".xml"));
-
- SharedFileCache = new SharedFileCache(SharedDirectory, SharedCacheTTL);
+ SharedFileCache = new SharedFileCache(Options.Directories.Shared, 3600000);
+
+ UrlBase = Options.Web.UrlBase;
+ UrlBase = UrlBase.StartsWith("/") ? UrlBase : "/" + UrlBase;
+
+ ContentPath = Path.GetFullPath(Options.Web.ContentPath);
+
+ JwtSigningKey = new SymmetricSecurityKey(PBKDF2.GetKey(Options.Web.Jwt.Key));
}
private IConfiguration Configuration { get; }
@@ -81,13 +75,6 @@
services.AddOptions<Options>()
.Bind(Configuration.GetSection("slskd"), o => { o.BindNonPublicProperties = true; });
- UrlBase = Options.Web.UrlBase;
- UrlBase = UrlBase.StartsWith("/") ? UrlBase : "/" + UrlBase;
-
- ContentPath = Path.GetFullPath(Options.Web.ContentPath);
-
- JwtSigningKey = new SymmetricSecurityKey(PBKDF2.GetKey(Options.Web.Jwt.Key));
-
services.AddCors(options => options.AddPolicy("AllowAll", builder => builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader()));
services.AddSingleton(JwtSigningKey);
@@ -164,7 +151,7 @@
services.AddSingleton<ISearchTracker, SearchTracker>();
services.AddSingleton<IBrowseTracker, BrowseTracker>();
services.AddSingleton<IConversationTracker, ConversationTracker>();
- services.AddSingleton<IRoomTracker, RoomTracker>(_ => new RoomTracker(messageLimit: RoomMessageLimit));
+ services.AddSingleton<IRoomTracker, RoomTracker>(_ => new RoomTracker(messageLimit: 250));
}
public void Configure(
@@ -296,7 +283,7 @@
userEndPointCache: new UserEndPointCache(),
distributedChildLimit: Options.Soulseek.DistributedNetwork.ChildLimit,
enableDistributedNetwork: !Options.Soulseek.DistributedNetwork.Disabled,
- minimumDiagnosticLevel: DiagnosticLevel,
+ minimumDiagnosticLevel: Options.Soulseek.DiagnosticLevel,
autoAcknowledgePrivateMessages: false,
acceptPrivateRoomInvitations: true,
serverConnectionOptions: connectionOptions,
@@ -465,7 +452,7 @@
private Task<BrowseResponse> BrowseResponseResolver(string username, IPEndPoint endpoint)
{
var directories = System.IO.Directory
- .GetDirectories(SharedDirectory, "*", SearchOption.AllDirectories)
+ .GetDirectories(Options.Directories.Shared, "*", SearchOption.AllDirectories)
.Select(dir => new Soulseek.Directory(dir, System.IO.Directory.GetFiles(dir)
.Select(f => new Soulseek.File(1, Path.GetFileName(f), new FileInfo(f).Length, Path.GetExtension(f)))));