From 865fcbc4fed85e9eac58125092838f08dbd55430 Mon Sep 17 00:00:00 2001 From: xovi Date: Wed, 26 Nov 2025 15:23:43 +0100 Subject: Added configurable ip address for the Web GUI (useful for ipv6 only users) --- config/slskd.example.yml | 2 ++ src/slskd/Core/Options.cs | 22 +++++++++++++++++++++- src/slskd/Program.cs | 10 ++++++---- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/config/slskd.example.yml b/config/slskd.example.yml index a0ca4f3f..f923afbf 100644 --- a/config/slskd.example.yml +++ b/config/slskd.example.yml @@ -137,10 +137,12 @@ # - ^.{1,2}$ # web: # port: 5030 +# listen_ip_address: 0.0.0.0 # socket: ~ # https: # disabled: false # port: 5031 +# listen_ip_address: 0.0.0.0 # force: false # certificate: # pfx: ~ diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs index 254adcab..ab08be04 100644 --- a/src/slskd/Core/Options.cs +++ b/src/slskd/Core/Options.cs @@ -1832,6 +1832,16 @@ namespace slskd [RequiresRestart] public int Port { get; init; } = 5030; + /// + /// Gets the IP address on which to listen for HTTP requests. + /// + [Argument(default, "http-listen-ip-address")] + [EnvironmentVariable("HTTP_LISTEN_IP_ADDRESS")] + [Description("IP address on which to listen for HTTP requests")] + [IPAddress] + [RequiresRestart] + public string ListenIpAddress { get; init; } = "0.0.0.0"; + /// /// Gets the HTTP listen unix domain socket (UDS) path. /// @@ -2032,7 +2042,17 @@ namespace slskd [Range(1, 65535)] [RequiresRestart] public int Port { get; init; } = 5031; - + + /// + /// Gets the IP address on which to listen for HTTPS requests. + /// + [Argument(default, "https-listen-ip-address")] + [EnvironmentVariable("HTTPS_LISTEN_IP_ADDRESS")] + [Description("IP address on which to listen for HTTPS requests")] + [IPAddress] + [RequiresRestart] + public string ListenIpAddress { get; init; } = "0.0.0.0"; + /// /// Gets a value indicating whether HTTP requests should be redirected to HTTPS. /// diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs index 6b50aedb..e693db63 100644 --- a/src/slskd/Program.cs +++ b/src/slskd/Program.cs @@ -474,8 +474,9 @@ namespace slskd .UseUrls() .UseKestrel(options => { - Log.Information($"Listening for HTTP requests at http://{IPAddress.Any}:{OptionsAtStartup.Web.Port}/"); - options.Listen(IPAddress.Any, OptionsAtStartup.Web.Port); + var httpIpAddress = IPAddress.Parse(OptionsAtStartup.Web.ListenIpAddress); + Log.Information($"Listening for HTTP requests at http://{httpIpAddress}:{OptionsAtStartup.Web.Port}/"); + options.Listen(httpIpAddress, OptionsAtStartup.Web.Port); if (OptionsAtStartup.Web.Socket != null) { @@ -485,8 +486,9 @@ namespace slskd if (!OptionsAtStartup.Web.Https.Disabled) { - Log.Information($"Listening for HTTPS requests at https://{IPAddress.Any}:{OptionsAtStartup.Web.Https.Port}/"); - options.Listen(IPAddress.Any, OptionsAtStartup.Web.Https.Port, listenOptions => + var httpsIpAddress = IPAddress.Parse(OptionsAtStartup.Web.Https.ListenIpAddress); + Log.Information($"Listening for HTTPS requests at https://{httpsIpAddress}:{OptionsAtStartup.Web.Https.Port}/"); + options.Listen(httpsIpAddress, OptionsAtStartup.Web.Https.Port, listenOptions => { var cert = OptionsAtStartup.Web.Https.Certificate; -- cgit v1.2.3 From 90779a98863f95672841451febbf22b0e119ee41 Mon Sep 17 00:00:00 2001 From: xovi Date: Wed, 3 Dec 2025 12:14:37 +0100 Subject: Added Documentation --- docs/config.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/config.md b/docs/config.md index 2646dd94..55505111 100644 --- a/docs/config.md +++ b/docs/config.md @@ -809,6 +809,7 @@ Logging of HTTP requests is disabled by default. | Command-Line | Environment Variable | Description | | ----------------- | -------------------------- | ------------------------------------------------- | | `-l\|--http-port` | `SLSKD_HTTP_PORT` | The HTTP listen port | +| `--http-listen-ip-address` | `SLSKD_HTTP_LISTEN_IP_ADDRESS` | The IP address on which to listen for HTTP requests | | `--http-socket` | `SLSKD_HTTP_SOCKET` | The HTTP listen unix domain socket (UDS) path | | `--url-base` | `SLSKD_URL_BASE` | The base url for web requests | | `--content-path` | `SLSKD_CONTENT_PATH` | The path to static web content | @@ -835,6 +836,7 @@ The application can produce a self-signed `.pfx` file and random password using | Command-Line | Environment Variable | Description | | ----------------------- | --------------------------- | -------------------------------------------------------------- | | `-L\|--https-port` | `SLSKD_HTTPS_PORT` | The HTTPS listen port | +| `--https-listen-ip-address` | `SLSKD_HTTPS_LISTEN_IP_ADDRESS` | The IP address on which to listen for HTTPS requests | | `-f\|--force-https` | `SLSKD_HTTPS_FORCE` | Determines whether HTTP requests are to be redirected to HTTPS | | `--https-cert-pfx` | `SLSKD_HTTPS_CERT_PFX` | The path to the X509 certificate .pfx file | | `--https-cert-password` | `SLSKD_HTTPS_CERT_PASSWORD` | The password for the X509 certificate | -- cgit v1.2.3 From 49514db326bef9cf21a1e84f3c1e13934b4c3a9a Mon Sep 17 00:00:00 2001 From: xovi Date: Wed, 3 Dec 2025 12:21:10 +0100 Subject: Corrected markdown tables alignment --- docs/config.md | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/docs/config.md b/docs/config.md index 55505111..c0a545f9 100644 --- a/docs/config.md +++ b/docs/config.md @@ -806,14 +806,14 @@ The content path can be used to force the application to serve static web conten Logging of HTTP requests is disabled by default. -| Command-Line | Environment Variable | Description | -| ----------------- | -------------------------- | ------------------------------------------------- | -| `-l\|--http-port` | `SLSKD_HTTP_PORT` | The HTTP listen port | +| Command-Line | Environment Variable | Description | +| -------------------------- | ------------------------------ | --------------------------------------------------- | +| `-l\|--http-port` | `SLSKD_HTTP_PORT` | The HTTP listen port | | `--http-listen-ip-address` | `SLSKD_HTTP_LISTEN_IP_ADDRESS` | The IP address on which to listen for HTTP requests | -| `--http-socket` | `SLSKD_HTTP_SOCKET` | The HTTP listen unix domain socket (UDS) path | -| `--url-base` | `SLSKD_URL_BASE` | The base url for web requests | -| `--content-path` | `SLSKD_CONTENT_PATH` | The path to static web content | -| `--http-logging` | `SLSKD_HTTP_LOGGING` | Determines whether HTTP requests are to be logged | +| `--http-socket` | `SLSKD_HTTP_SOCKET` | The HTTP listen unix domain socket (UDS) path | +| `--url-base` | `SLSKD_URL_BASE` | The base url for web requests | +| `--content-path` | `SLSKD_CONTENT_PATH` | The path to static web content | +| `--http-logging` | `SLSKD_HTTP_LOGGING` | Determines whether HTTP requests are to be logged | #### **YAML** ```yaml @@ -833,14 +833,14 @@ By default, the application generates a new, self-signed X509 certificate at eac The application can produce a self-signed `.pfx` file and random password using the `--generate-cert` command. -| Command-Line | Environment Variable | Description | -| ----------------------- | --------------------------- | -------------------------------------------------------------- | -| `-L\|--https-port` | `SLSKD_HTTPS_PORT` | The HTTPS listen port | -| `--https-listen-ip-address` | `SLSKD_HTTPS_LISTEN_IP_ADDRESS` | The IP address on which to listen for HTTPS requests | -| `-f\|--force-https` | `SLSKD_HTTPS_FORCE` | Determines whether HTTP requests are to be redirected to HTTPS | -| `--https-cert-pfx` | `SLSKD_HTTPS_CERT_PFX` | The path to the X509 certificate .pfx file | -| `--https-cert-password` | `SLSKD_HTTPS_CERT_PASSWORD` | The password for the X509 certificate | -| `--no-https` | `SLSKD_NO_HTTPS` | Determines whether HTTPS is to be disabled | +| Command-Line | Environment Variable | Description | +| --------------------------- | ------------------------------- | -------------------------------------------------------------- | +| `-L\|--https-port` | `SLSKD_HTTPS_PORT` | The HTTPS listen port | +| `--https-listen-ip-address` | `SLSKD_HTTPS_LISTEN_IP_ADDRESS` | The IP address on which to listen for HTTPS requests | +| `-f\|--force-https` | `SLSKD_HTTPS_FORCE` | Determines whether HTTP requests are to be redirected to HTTPS | +| `--https-cert-pfx` | `SLSKD_HTTPS_CERT_PFX` | The path to the X509 certificate .pfx file | +| `--https-cert-password` | `SLSKD_HTTPS_CERT_PASSWORD` | The password for the X509 certificate | +| `--no-https` | `SLSKD_NO_HTTPS` | Determines whether HTTPS is to be disabled | #### **YAML** ```yaml -- cgit v1.2.3