From 09fef11e1fedf129756bf36f754ff16dc561f417 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 28 Nov 2021 18:31:51 -0600 Subject: document flags and commands --- src/slskd/Options.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/slskd/Options.cs b/src/slskd/Options.cs index 4a9df941..13fb1455 100644 --- a/src/slskd/Options.cs +++ b/src/slskd/Options.cs @@ -118,7 +118,7 @@ namespace slskd /// Gets a value indicating whether to generate an X509 certificate and password. /// [Argument('g', "generate-cert")] - [Description("generate X509 certificate and password for HTTPs")] + [Description("generate X509 certificate and password for HTTPS")] [Obsolete("Used only for documentation; see Program for actual implementation")] [YamlIgnore] public bool GenerateCertificate { get; private set; } = false; -- cgit v1.2.3 From c1078f799cac48ab402752ba57fe26edd93b368e Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 28 Nov 2021 22:33:40 -0600 Subject: consistently apply jsonignore/yamlignore --- src/slskd/Options.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src') diff --git a/src/slskd/Options.cs b/src/slskd/Options.cs index 13fb1455..32d7cd6f 100644 --- a/src/slskd/Options.cs +++ b/src/slskd/Options.cs @@ -93,6 +93,7 @@ namespace slskd [Argument('v', "version")] [Description("display version information")] [Obsolete("Used only for documentation; see Program for actual implementation")] + [JsonIgnore] [YamlIgnore] public bool ShowVersion { get; private set; } = false; @@ -102,6 +103,7 @@ namespace slskd [Argument('h', "help")] [Description("display command line usage")] [Obsolete("Used only for documentation; see Program for actual implementation")] + [JsonIgnore] [YamlIgnore] public bool ShowHelp { get; private set; } = false; @@ -111,6 +113,7 @@ namespace slskd [Argument('e', "envars")] [Description("display environment variables")] [Obsolete("Used only for documentation; see Program for actual implementation")] + [JsonIgnore] [YamlIgnore] public bool ShowEnvironmentVariables { get; private set; } = false; @@ -120,6 +123,7 @@ namespace slskd [Argument('g', "generate-cert")] [Description("generate X509 certificate and password for HTTPS")] [Obsolete("Used only for documentation; see Program for actual implementation")] + [JsonIgnore] [YamlIgnore] public bool GenerateCertificate { get; private set; } = false; @@ -201,6 +205,7 @@ namespace slskd [EnvironmentVariable("APP_DIR")] [Description("path where application data is saved")] [Obsolete("Used only for documentation; see Program for actual implementation")] + [JsonIgnore] [YamlIgnore] public string AppDirectory { get; private set; } = Program.DefaultAppDirectory; @@ -457,6 +462,7 @@ namespace slskd [Description("password for the Soulseek network")] [RequiresReconnect] [JsonIgnore] + [YamlIgnore] public string Password { get; private set; } = null; /// @@ -626,6 +632,7 @@ namespace slskd [Description("connection proxy password")] [StringLength(255, MinimumLength = 1)] [JsonIgnore] + [YamlIgnore] public string Password { get; private set; } /// @@ -771,6 +778,7 @@ namespace slskd [Description("password for web UI")] [StringLength(255, MinimumLength = 1)] [JsonIgnore] + [YamlIgnore] public string Password { get; private set; } = Program.AppName; /// @@ -862,6 +870,7 @@ namespace slskd [Description("X509 certificate password")] [RequiresRestart] [JsonIgnore] + [YamlIgnore] public string Password { get; private set; } } } @@ -946,6 +955,7 @@ namespace slskd [EnvironmentVariable("FTP_PASSWORD")] [Description("FTP password")] [JsonIgnore] + [YamlIgnore] public string Password { get; private set; } /// -- cgit v1.2.3 From a26810b0ebed15d61539eaddd0cdb5b75b9a4147 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 28 Nov 2021 22:37:00 -0600 Subject: app -> app-dir --- docs/config.md | 2 +- src/slskd/Program.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/docs/config.md b/docs/config.md index 7015ac31..8d6ca1f6 100644 --- a/docs/config.md +++ b/docs/config.md @@ -44,7 +44,7 @@ Command line arguments are useful for security options, such as remote configura The application directory configuration option determines the location of the YAML file, the default locations of the download and incomplete directories, and the location of application working data, such as logs and SQLite databases. -Because the location of the YAML file is derived from this value, it can't be specified within the YAML file and must instead be specified with the `APP_DIR` environment variable or `--app` command line argument. +Because the location of the YAML file is derived from this value, it can't be specified within the YAML file and must instead be specified with the `APP_DIR` environment variable or `--app-dir` command line argument. If no value is specified, the location defaults to either `~/.local/share/slskd` (on Linux and macOS) or `%localappdata%/slskd` (on Windows). diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs index c70db953..3c14006a 100644 --- a/src/slskd/Program.cs +++ b/src/slskd/Program.cs @@ -117,7 +117,7 @@ namespace slskd /// /// Gets the path where application data is saved. /// - [Argument(default, "app", "path where application data is saved")] + [Argument(default, "app-dir", "path where application data is saved")] [EnvironmentVariable("APP_DIR")] public static string AppDirectory { get; private set; } = DefaultAppDirectory; -- cgit v1.2.3 From 90ef6ed12964653474ad5a66e42a4b8032eaaa63 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Mon, 29 Nov 2021 09:04:06 -0600 Subject: wip --- docs/config.md | 54 ++++++++++++++++++++++++++++++++++++++++++++++++---- src/slskd/Options.cs | 6 +++--- 2 files changed, 53 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/docs/config.md b/docs/config.md index b941d836..f85bc6fd 100644 --- a/docs/config.md +++ b/docs/config.md @@ -62,7 +62,7 @@ Changing either of these values requires the server connection to be reset. The password field is not included when serializing options to Json or YAML to avoid inadvertently exposing the value. -|Option|Environment Variable|Description| +|Command Line|Environment Variable|Description| |----|-----|-----------| |`--slsk-username`|`SLSK_USERNAME`|The username for the Soulseek network| |`--slsk-password`|`SLSK_PASSWORD`|The password for the Soulseek network| @@ -84,7 +84,7 @@ Child connections should generally only be disabled on low spec systems or situa Changing these values may require the server connection to be reset, depending on the current state. -|Option|Environment Variable|Description| +|Command Line|Environment Variable|Description| |----|-----|-----------| |`--slsk-no-dnet`|`SLSK_NO_DNET`|Determines whether the distributed network is disabled. If disabled, the client will not obtain a parent or any child connections, and will not receive distributed search requests.| |`--slsk-dnet-no-children`|`SLSK_DNET_NO_CHILDREN`|Determines whether to disallow distributed children| @@ -107,7 +107,7 @@ As with any other Soulseek client, properly configuring the listen port and port Symptoms of a misconfigured listen port include poor search results and inability to browse or retrieve user information for some users. -|Option|Environment Variable|Description| +|Command Line|Environment Variable|Description| |----|-----|-----------| |`--slsk-listen-port`|`SLSK_LISTEN_PORT`|The port on which to listen for incoming connections| @@ -119,10 +119,20 @@ soulseek: ## Connection +### Timeouts +Timeout options control how long the application waits for connections to connect, and how long connections can be inactive before they are disconnected. -### Timeouts +Higher connect timeout values will help ensure that operations (browse, download requests, etc) are successful the first time, but also decrease responsiveness of commands that will ultimately fail. + +Inactivity timeouts help the application determine when a distributed parent connection has stopped sending data, and when connections that have delivered search results (and are unlikely to be used further) from remaining open longer than needed. Reducing this timeout can help on low spec systems if port exhaustion is a concern, but may result in the application "hunting" for a distributed parent connection needlessly. +|Command Line|Environment Variable|Description| +|----|-----|-----------| +|`--slsk-connection-timeout`|`SLSK_CONNECTION_TIMEOUT`|The connection timeout value, in milliseconds| +|`--slsk-inactivity-timeout`|`SLSK_INACTIVITY_TIMEOUT`|The connection inactivity value, in milliseconds| + +#### **YAML** ```yaml soulseek: connection: @@ -133,6 +143,22 @@ soulseek: ### Buffers +Buffer options control the internal buffer the application uses to batch socket reads and writes. Actual socket buffer sizes are controlled by the OS (.NET is not great in this department currently, and the behavior of these is not consistent cross-platform). + +Larger buffer sizes can improve performance, especially for file transfers, but result in increased memory usage. + +The transfer buffer size is used for file transfers (both read and write), and the read and write buffer sizes are used for all other connection types. The transfer buffer size is directly correlated with transfer speed; setting this value much lower than the default will result in slow uploads (which may be a good thing for low spec hardware). + +The write queue option is the hard limit for the number of concurrent writes for a connection. This generally only applies to distributed child connections, and prevents a memory leak if the application continues to try and send data after a connection has gone "bad". This value can be set as low as 5 if memory is a constraint, though the default has been tested extensively and should be good for most scenarios, including low spec. + +|Command Line|Environment Variable|Description| +|----|-----|-----------| +|`--slsk-read-buffer`|`SLSK_READ_BUFFER`|The connection read buffer size, in bytes| +|`--slsk-write-buffer`|`SLSK_WRITE_BUFFER`|The connection write buffer size, in bytes| +|`--slsk-transfer-buffer`|`SLSK_TRANSFER_BUFFER`|The read/write buffer size for transfers, in bytes| +|`--slsk-write-queue`|`SLSK_WRITE_QUEUE`|The connection write buffer size, in bytes| + +#### **YAML** ```yaml soulseek: connection: @@ -145,6 +171,19 @@ soulseek: ### Proxy +Connections can optionally use a SOCKS5 proxy, with or without username and password authentication. + +If the proxy is enabled, an address and port must also be specified. + +|Command Line|Environment Variable|Description| +|----|-----|-----------| +|`--slsk-proxy`|`SLSK_PROXY`|Determines whether a proxy is to be used| +|`--slsk-proxy-address`|`SLSK_PROXY_ADDRESS`|The proxy address| +|`--slsk-proxy-port`|`SLSK_PROXY_PORT`|The proxy port| +|`--slsk-proxy-username`|`SLSK_PROXY_USERNAME`|The proxy username, if applicable| +|`--slsk-proxy-password`|`SLSK_PROXY_PASSWORD`|The proxy password, if applicable| + +#### **YAML** ```yaml soulseek: connection: @@ -158,6 +197,13 @@ soulseek: ## Diagnostic Level +The diagnostic level option is passed to the Soulseek.NET configuration, and determines the level of detail at which the library produces diagnostic messages. This should generally be left set to `Info` or `Warning`, but can be set to `Debug` if more verbose logging is desired. + +|Command Line|Environment Variable|Description| +|----|-----|-----------| +|`--slsk-diag-level`|`SLSK_DIAG_LEVEL`|The minimum diagnostic level (None, Warning, Info, Debug)| + +#### **YAML** ```yaml soulseek: diagnostic_level: Info diff --git a/src/slskd/Options.cs b/src/slskd/Options.cs index 32d7cd6f..2ca4c4df 100644 --- a/src/slskd/Options.cs +++ b/src/slskd/Options.cs @@ -524,7 +524,7 @@ namespace slskd public class BufferOptions { /// - /// Gets the connection read buffer size. + /// Gets the connection read buffer size, in bytes. /// [Argument(default, "slsk-read-buffer")] [EnvironmentVariable("SLSK_READ_BUFFER")] @@ -533,7 +533,7 @@ namespace slskd public int Read { get; private set; } = 16384; /// - /// Gets the connection write buffer size. + /// Gets the connection write buffer size, in bytes. /// [Argument(default, "slsk-write-buffer")] [EnvironmentVariable("SLSK_WRITE_BUFFER")] @@ -542,7 +542,7 @@ namespace slskd public int Write { get; private set; } = 16384; /// - /// Gets the read/write buffer size for transfers. + /// Gets the read/write buffer size for transfers, in bytes. /// [Argument(default, "slsk-transfer-buffer")] [EnvironmentVariable("SLSK_TRANSFER_BUFFER")] -- cgit v1.2.3 From c381bd32cb23e641b0f59a4a60db172fed992fbf Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Tue, 30 Nov 2021 08:26:25 -0600 Subject: wip --- docs/config.md | 97 +++++++++++++++++++++++++++++++++++++++++++++++++--- src/slskd/Options.cs | 4 +-- 2 files changed, 95 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/docs/config.md b/docs/config.md index a4a368e1..3bd09bfa 100644 --- a/docs/config.md +++ b/docs/config.md @@ -22,6 +22,12 @@ Environment variables are loaded after defaults. Each environment variable name Environment variables are ideal for use cases involving Docker where remote configuration will be disabled, and where configuration is not expected to change often. +Some options are backed by arrays or lists and allow multiple options to be set via a single environment variable. To achieve this, separate each list item by a semicolon `;` in the value: + +``` +SLSKD_SOME_OPTION=1;2;3 +``` + ## YAML Configuration File Configuration is loaded from the YAML file located at `/slskd.yml` after environment variables. @@ -40,6 +46,12 @@ Command line arguments are loaded last, override all other configuration options Command line arguments are useful for security options, such as remote configuration, HTTPS JWT secret and certificate. Choosing this source for sensitive options can prevent a remote attacker from gaining full control over the application. +Some options are backed by arrays or lists and allow multiple options to be set via command line. To achieve this, repeat the command line argument: + +``` +--some-option 1 --some-option 2 --some-option 3 +``` + # Application Directory Configuration The application directory configuration option determines the location of the YAML file, the default locations of the download and incomplete directories, and the location of application working data, such as logs and SQLite databases. @@ -50,6 +62,12 @@ If no value is specified, the location defaults to either `~/.local/share/slskd` Within the official Docker image, this value is set to `/app`. +# Other Directory Configuration + +## Incomplete and Downloads + +## Shares + # Soulseek Configuration The Soulseek configuration determines how slskd will interact with the Soulseek network and underlying [Soulseek.NET](https://github.com/jpdillingham/Soulseek.NET) library. @@ -223,7 +241,7 @@ Logging of HTTP requests is disabled by default. |Command Line|Environment Variable|Description| |----|-----|-----------| -|`-l\--http-port`|`HTTP_PORT`|The HTTP listen port| +|`-l\|--http-port`|`HTTP_PORT`|The HTTP listen port| |`--url-base`|`URL_BASE`|The base url for web requests| |`--content-path`|`CONTENT_PATH`|The path to static web content| |`--http-logging`|`HTTP_LOGGING`|Determines whether HTTP requests are to be logged| @@ -265,6 +283,21 @@ web: ## Authentication +Authentication for the web UI (and underlying API) is enabled by default, and the default username and password are both `slskd`. Changing both the username and password during initial configuration are highly recommended. + +By default, a random JWT secret key is generated at each start. This is convenient and secure, but it means that restarting the application will invalidate any issued JWTs, causing users to have to sign in again. To avoid this supply a custom secret at least 16 characters in length. Note that the secret can be used to generate valid JWTs for the application, so keep this value secret. + +The JWT TTL option determines how long issued JWTs are valid, defaulting to 7 days. + +|Command Line|Environment Variable|Description| +|----|-----|-----------| +|`-X\|--no-auth`|`NO_AUTH`|Determines whether authentication is to be disabled| +|`-u\|--username`|`USERNAME`|The username for the web UI| +|`-p\|--password`|`PASSWORD`|The password for the web UI| +|`--jwt-key`|`JWT_KEY`|The secret key used to sign JWTs| +|`--jwt-ttl`|`JWT_TTL`|The TTL (duration) of JWTs, in milliseconds| + +#### **YAML** ```yaml web: authentication: @@ -276,6 +309,25 @@ web: ttl: 604800000 ``` +# Filters + +A number of filters can be configured to control various aspects of how the application interacts with the Soulseek network. + +The share filters can be used to prevent certain types of files from being shared. This option is an array that can take any number of filters. Filters must be a valid regular expression; a few examples are included below and in the example configuration included with the application, but the list is empty by default. + +|Command Line|Environment Variable|Description| +|----|-----|-----------| +|`--share-filter`|`SHARE_FILTER`|A list of regular expressions used to filter files from shares| + +#### **YAML** +```yaml +filters: + share: + - \.ini$ + - Thumbs.db$ + - \.DS_Store$ +``` + # Integrations ## FTP @@ -286,15 +338,52 @@ web: ## Instance Name +The instance name uniquely identifies the running instance of the application. This is primarily useful for structured logging in cases where multiple instances are logging to the same remote source. + +|Command Line|Environment Variable|Description| +|----|-----|-----------| +|`-i\|--instance-name`|`INSTANCE_NAME`|The unique name for the running instance| + +#### **YAML** +```yaml +instance_name: default +``` + ## Loggers -### Loki +The application logs to disk (`/logs` in the application directory) by default. Logs can optionally be forwarded to external services, and the targets can be expanded to any service supported by a [Serilog Sink](https://github.com/serilog/serilog/wiki/Provided-Sinks). Support for targets are added on an as-needed basis, and within reason. + +The current list of available targets is: + +|Command Line|Environment Variable|Description| +|----|-----|-----------| +|`--loki`|`LOKI`|The URL to a Grafana Loki instance| + +#### **YAML** +```yaml +logger: + loki: ~ +``` ## Features -### Swagger +Several features have been added that aid in the development, debugging and operation of the application, but are generally not of much use to most users. + +The application can publish Prometheus metrics to `/metrics` using [prometheus-net](https://github.com/prometheus-net/prometheus-net). This is especially useful for anyone attempting to tune performance characteristics. + +The application can publish a Swagger (OpenAPI) definition and host SwaggerUI at `/swagger` using [Swashbuckle](https://github.com/domaindrivendev/Swashbuckle.AspNetCore). This is useful for anyone developing against the application API and/or creating a new web interface. -### Prometheus +|Command Line|Environment Variable|Description| +|----|-----|-----------| +|`--prometheus`|`PROMETHEUS`|Determines whether Prometheus metrics are published to `/metrics`| +|`--swagger`|`SWAGGER`|Determines whether Swagger (OpenAPI) definitions and UI should be available at `/swagger`| + +#### **YAML** +```yaml +feature: + prometheus: false + swagger: false +``` ## Development Flags diff --git a/src/slskd/Options.cs b/src/slskd/Options.cs index 2ca4c4df..40b59fca 100644 --- a/src/slskd/Options.cs +++ b/src/slskd/Options.cs @@ -755,7 +755,7 @@ namespace slskd /// /// Gets a value indicating whether authentication should be disabled. /// - [Argument('x', "no-auth")] + [Argument('X', "no-auth")] [EnvironmentVariable("NO_AUTH")] [Description("disable authentication for web requests")] [RequiresRestart] @@ -804,7 +804,7 @@ namespace slskd public string Key { get; private set; } = Guid.NewGuid().ToString(); /// - /// Gets the TTL for JWTs. + /// Gets the TTL for JWTs, in milliseconds. /// [Argument(default, "jwt-ttl")] [EnvironmentVariable("JWT_TTL")] -- cgit v1.2.3 From d3acd6eef23ccfe0549c0f052159748689dc77a1 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Wed, 1 Dec 2021 09:14:33 -0600 Subject: prevent pushbullet token serialization --- src/slskd/Options.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/slskd/Options.cs b/src/slskd/Options.cs index 40b59fca..dbcd13b3 100644 --- a/src/slskd/Options.cs +++ b/src/slskd/Options.cs @@ -1029,6 +1029,8 @@ namespace slskd [Argument(default, "pushbullet-token")] [EnvironmentVariable("PUSHBULLET_ACCESS_TOKEN")] [Description("Pushbullet access token")] + [JsonIgnore] + [YamlIgnore] public string AccessToken { get; private set; } /// -- cgit v1.2.3 From 2c856e441c57623d5a4fa157a803b589416629e6 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Wed, 1 Dec 2021 09:22:57 -0600 Subject: default remote configuration to false again --- config/slskd.example.yml | 2 +- src/slskd/Core/API/Controllers/OptionsController.cs | 4 ++-- src/slskd/Options.cs | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/config/slskd.example.yml b/config/slskd.example.yml index 73278cff..16b1188e 100644 --- a/config/slskd.example.yml +++ b/config/slskd.example.yml @@ -4,7 +4,7 @@ # no_connect: false # no_share_scan: false # no_version_check: false -# no_remote_configuration: false +# remote_configuration: false # instance_name: default # directories: # incomplete: ~ diff --git a/src/slskd/Core/API/Controllers/OptionsController.cs b/src/slskd/Core/API/Controllers/OptionsController.cs index aa5ffc3a..60237878 100644 --- a/src/slskd/Core/API/Controllers/OptionsController.cs +++ b/src/slskd/Core/API/Controllers/OptionsController.cs @@ -86,7 +86,7 @@ namespace slskd.Core.API [Route("yaml")] public IActionResult GetYamlFile() { - if (!OptionsSnapshot.Value.NoRemoteConfiguration) + if (!OptionsSnapshot.Value.RemoteConfiguration) { return Forbid(); } @@ -100,7 +100,7 @@ namespace slskd.Core.API [Route("yaml")] public IActionResult UpdateYamlFile([FromBody] string yaml) { - if (!OptionsSnapshot.Value.NoRemoteConfiguration) + if (!OptionsSnapshot.Value.RemoteConfiguration) { return Forbid(); } diff --git a/src/slskd/Options.cs b/src/slskd/Options.cs index c4d675f3..dbcd13b3 100644 --- a/src/slskd/Options.cs +++ b/src/slskd/Options.cs @@ -184,10 +184,10 @@ namespace slskd /// /// Gets a value indicating whether remote configuration of options is allowed. /// - [Argument(default, "no-remote-configuration")] - [EnvironmentVariable("NO_REMOTE_CONFIGURATION")] - [Description("do not allow remote configuration")] - public bool NoRemoteConfiguration { get; private set; } = false; + [Argument(default, "remote-configuration")] + [EnvironmentVariable("REMOTE_CONFIGURATION")] + [Description("allow remote configuration")] + public bool RemoteConfiguration { get; private set; } = false; /// /// Gets the unique name for this instance. -- cgit v1.2.3 From de01b4f7fff0da0841ef4d55a34f4cd1067aedf4 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Fri, 3 Dec 2021 08:16:43 -0600 Subject: reduce write_queue to 50 --- src/slskd/Options.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/slskd/Options.cs b/src/slskd/Options.cs index dbcd13b3..7546449f 100644 --- a/src/slskd/Options.cs +++ b/src/slskd/Options.cs @@ -557,7 +557,7 @@ namespace slskd [EnvironmentVariable("SLSK_WRITE_QUEUE")] [Description("queue size for double buffered writes")] [Range(5, 5000)] - public int WriteQueue { get; private set; } = 250; + public int WriteQueue { get; private set; } = 50; } /// -- cgit v1.2.3