aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJP Dillingham <jpdillingham@gmail.com>2021-01-23 22:02:30 -0600
committerJP Dillingham <jpdillingham@gmail.com>2021-01-23 22:02:30 -0600
commit0f76728a60e16acae2aab0e3c661d32ab7e5a01c (patch)
tree45c906cffaef0813ff9c8632d6991778027e5c9d /src
parent01b69a964a5162b5fcbf91774ee39d8a4e429dd6 (diff)
downloadslskd-0f76728a60e16acae2aab0e3c661d32ab7e5a01c.tar.gz
tweak config layout
Diffstat (limited to 'src')
-rw-r--r--src/slskd/Configuration.cs117
-rw-r--r--src/slskd/Controllers/SessionController.cs4
-rw-r--r--src/slskd/Program.cs2
-rw-r--r--src/slskd/Startup.cs22
-rw-r--r--src/slskd/config.yml39
5 files changed, 98 insertions, 86 deletions
diff --git a/src/slskd/Configuration.cs b/src/slskd/Configuration.cs
index c09896a5..e02670df 100644
--- a/src/slskd/Configuration.cs
+++ b/src/slskd/Configuration.cs
@@ -65,27 +65,6 @@
Key: "slskd:instancename",
Description: "optional; a unique name for this instance"),
new(
- ShortName: 'm',
- LongName: "prometheus",
- EnvironmentVariable: "PROMETHEUS",
- Type: typeof(bool),
- Key: "slskd:feature:prometheus",
- Description: "enable collection and publishing of prometheus metrics"),
- new(
- ShortName: 's',
- LongName: "swagger",
- EnvironmentVariable: "SWAGGER",
- Type: typeof(bool),
- Key: "slskd:feature:swagger",
- Description: "enable swagger documentation and UI"),
- new(
- ShortName: 'l',
- LongName: "loki",
- EnvironmentVariable: "LOKI",
- Type: typeof(string),
- Key: "slskd:logger:loki",
- Description: "optional; the url to a Grafana Loki instance to which to log"),
- new(
ShortName: 'b',
LongName: "url-base",
EnvironmentVariable: "URL_BASE",
@@ -118,15 +97,57 @@
LongName: "username",
EnvironmentVariable: "USERNAME",
Type: typeof(string),
- Key: "soulseek:username",
+ Key: "slskd:soulseek:username",
Description: "the username for the Soulseek network"),
new(
ShortName: 'p',
LongName: "password",
EnvironmentVariable: "PASSWORD",
Type: typeof(string),
- Key: "soulseek:password",
- Description: "the password for the Soulseek network")
+ Key: "slskd:soulseek:password",
+ Description: "the password for the Soulseek network"),
+ new(
+ ShortName: 'l',
+ LongName: "listen-port",
+ EnvironmentVariable: "LISTEN_PORT",
+ Type: typeof(int),
+ Key: "slskd:soulseek:listenport",
+ Description: "the port on which to listen"),
+ new(
+ ShortName: 'n',
+ LongName: "distributed-network",
+ EnvironmentVariable: "DNET",
+ Type: typeof(bool),
+ Key: "slskd:soulseek:distributednetwork:enabled",
+ Description: "enables the distributed network"),
+ new(
+ ShortName: 'c',
+ LongName: "child-limit",
+ EnvironmentVariable: "DNET_CHILDREN",
+ Type: typeof(int),
+ Key: "slskd:soulseek:distributednetwork:childlimit",
+ Description: "sets the limit for the number of distributed children"),
+ new(
+ ShortName: default,
+ LongName: "prometheus",
+ EnvironmentVariable: "PROMETHEUS",
+ Type: typeof(bool),
+ Key: "slskd:feature:prometheus",
+ Description: "enable collection and publishing of prometheus metrics"),
+ new(
+ ShortName: default,
+ LongName: "swagger",
+ EnvironmentVariable: "SWAGGER",
+ Type: typeof(bool),
+ Key: "slskd:feature:swagger",
+ Description: "enable swagger documentation and UI"),
+ new(
+ ShortName: default,
+ LongName: "loki",
+ EnvironmentVariable: "LOKI",
+ Type: typeof(string),
+ Key: "slskd:logger:loki",
+ Description: "optional; the url to a Grafana Loki instance to which to log"),
};
public class Program
@@ -138,6 +159,7 @@
public FeatureOptions Feature { get; private set; } = new FeatureOptions();
public LoggerOptions Logger { get; private set; } = new LoggerOptions();
public WebOptions Web { get; private set; } = new WebOptions();
+ public SoulseekOptions Soulseek { get; private set; } = new SoulseekOptions();
public class FeatureOptions
{
@@ -162,37 +184,38 @@
public string Key { get; private set; } = Guid.NewGuid().ToString();
}
}
- }
-
- public class Soulseek
- {
- public string Username { get; set; }
- public string Password { get; set; }
- public int ListenPort { get; set; } = 50000;
- public DistributedNetworkOptions DistributedNetwork { get; set; }
- public ConnectionOptions Connection { get; set; }
- public class DistributedNetworkOptions
- {
- public bool Enabled { get; set; } = true;
- public int ChildLimit { get; set; } = 10;
- }
- public class ConnectionOptions
+ public class SoulseekOptions
{
- public TimeoutOptions Timeout { get; set; }
- public BufferOptions Buffer { get; set; }
+ public string Username { get; set; }
+ public string Password { get; set; }
+ public int ListenPort { get; set; } = 50000;
+ public DistributedNetworkOptions DistributedNetwork { get; set; }
+ public ConnectionOptions Connection { get; set; }
- public class TimeoutOptions
+ public class DistributedNetworkOptions
{
- public int Connect { get; set; } = 5000;
- public int Inactivity { get; set; } = 15000;
+ public bool Enabled { get; set; } = true;
+ public int ChildLimit { get; set; } = 10;
}
- public class BufferOptions
+ public class ConnectionOptions
{
- public int Read { get; set; } = 16384;
- public int Write { get; set; } = 16384;
+ public TimeoutOptions Timeout { get; set; }
+ public BufferOptions Buffer { get; set; }
+
+ public class TimeoutOptions
+ {
+ public int Connect { get; set; } = 5000;
+ public int Inactivity { get; set; } = 15000;
+ }
+
+ public class BufferOptions
+ {
+ public int Read { get; set; } = 16384;
+ public int Write { get; set; } = 16384;
+ }
}
}
}
diff --git a/src/slskd/Controllers/SessionController.cs b/src/slskd/Controllers/SessionController.cs
index e223032e..c0f17645 100644
--- a/src/slskd/Controllers/SessionController.cs
+++ b/src/slskd/Controllers/SessionController.cs
@@ -22,12 +22,12 @@
[Consumes("application/json")]
public class SessionController : ControllerBase
{
- private IOptionsSnapshot<Configuration.Soulseek> SoulseekOptions { get; set; }
+ private IOptionsSnapshot<Configuration.Program> SoulseekOptions { get; set; }
private IOptionsSnapshot<Configuration.Authentication> AuthenticationOptions { get; set; }
private SymmetricSecurityKey JwtSigningKey { get; set; }
public SessionController(
- IOptionsSnapshot<Configuration.Soulseek> soulseekOptions,
+ IOptionsSnapshot<Configuration.Program> soulseekOptions,
IOptionsSnapshot<Configuration.Authentication> authenticationOptions,
SymmetricSecurityKey jwtSigningKey)
{
diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs
index 33429dad..ebeaea24 100644
--- a/src/slskd/Program.cs
+++ b/src/slskd/Program.cs
@@ -240,7 +240,7 @@
continue;
}
- var result = $" {shortName}|--{GetLongName(longName, type).PadRight(longestName + 3)}{description}";
+ var result = $" {shortName}{(shortName == default ? string.Empty : "|")}--{GetLongName(longName, type).PadRight(longestName + 3)}{description}";
Console.WriteLine(result);
}
}
diff --git a/src/slskd/Startup.cs b/src/slskd/Startup.cs
index eb9c8bed..c6ff1b23 100644
--- a/src/slskd/Startup.cs
+++ b/src/slskd/Startup.cs
@@ -68,7 +68,7 @@
public void ConfigureServices(IServiceCollection services)
{
- services.AddOptions<Configuration.Soulseek>()
+ services.AddOptions<Configuration.Program>()
.Bind(Configuration.GetSection("soulseek"));
services.AddOptions<Configuration.Authentication>()
@@ -165,7 +165,7 @@
ITransferTracker tracker,
IBrowseTracker browseTracker,
IConversationTracker conversationTracker,
- IOptionsMonitor<Configuration.Soulseek> soulseekOptions,
+ IOptionsMonitor<Configuration.Program> soulseekOptions,
IOptionsMonitor<Configuration.Authentication> authenticationOptions,
IRoomTracker roomTracker)
{
@@ -272,18 +272,18 @@
// ---------------------------------------------------------------------------------------------------------------------------------------------
var connectionOptions = new ConnectionOptions(
- readBufferSize: soulseekOptions.CurrentValue.Connection.Buffer.Read,
- writeBufferSize: soulseekOptions.CurrentValue.Connection.Buffer.Write,
- connectTimeout: soulseekOptions.CurrentValue.Connection.Timeout.Connect,
- inactivityTimeout: soulseekOptions.CurrentValue.Connection.Timeout.Inactivity);
+ readBufferSize: soulseekOptions.CurrentValue.Soulseek.Connection.Buffer.Read,
+ writeBufferSize: soulseekOptions.CurrentValue.Soulseek.Connection.Buffer.Write,
+ connectTimeout: soulseekOptions.CurrentValue.Soulseek.Connection.Timeout.Connect,
+ inactivityTimeout: soulseekOptions.CurrentValue.Soulseek.Connection.Timeout.Inactivity);
// create options for the client.
// see the implementation of Func<> and Action<> options for detailed info.
var clientOptions = new SoulseekClientOptions(
- listenPort: soulseekOptions.CurrentValue.ListenPort,
+ listenPort: soulseekOptions.CurrentValue.Soulseek.ListenPort,
userEndPointCache: new UserEndPointCache(),
- distributedChildLimit: soulseekOptions.CurrentValue.DistributedNetwork.ChildLimit,
- enableDistributedNetwork: soulseekOptions.CurrentValue.DistributedNetwork.Enabled,
+ distributedChildLimit: soulseekOptions.CurrentValue.Soulseek.DistributedNetwork.ChildLimit,
+ enableDistributedNetwork: soulseekOptions.CurrentValue.Soulseek.DistributedNetwork.Enabled,
minimumDiagnosticLevel: DiagnosticLevel,
autoAcknowledgePrivateMessages: false,
acceptPrivateRoomInvitations: true,
@@ -296,8 +296,8 @@
enqueueDownloadAction: (username, endpoint, filename) => EnqueueDownloadAction(username, endpoint, filename, tracker),
searchResponseResolver: SearchResponseResolver);
- var username = soulseekOptions.CurrentValue.Username;
- var password = soulseekOptions.CurrentValue.Password;
+ var username = soulseekOptions.CurrentValue.Soulseek.Username;
+ var password = soulseekOptions.CurrentValue.Soulseek.Password;
Client = new SoulseekClient(options: clientOptions);
diff --git a/src/slskd/config.yml b/src/slskd/config.yml
index df1514d0..9a19f276 100644
--- a/src/slskd/config.yml
+++ b/src/slskd/config.yml
@@ -14,28 +14,17 @@ slskd:
jwt:
ttl: 604800000
key: ~
-soulseek:
- username: ~
- password: ~
- listen_port: 50000
- distributed_network:
- enabled: true
- child_limit: 10
- connection:
- timeout:
- connect: 5000
- inactivity: 15000
- buffer:
- read: 16384
- write: 16384
-authentication:
- users:
- - name: admin
- password: admin
- role: Administrator
- - name: user
- password: user
- role: User
- api_keys:
- - key: 1234567890
- role: ReadOnly \ No newline at end of file
+ soulseek:
+ username: ~
+ password: ~
+ listen_port: 50000
+ distributed_network:
+ enabled: true
+ child_limit: 10
+ connection:
+ timeout:
+ connect: 5000
+ inactivity: 15000
+ buffer:
+ read: 16384
+ write: 16384 \ No newline at end of file