aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2025-12-09 19:08:30 -0600
committerGitHub <noreply@github.com>2025-12-09 19:08:30 -0600
commitc06e61b83bbc857b9b648792846a03900cb4b705 (patch)
tree55e675412db1eafc781a5f3da0eb8533de70ae68
parenta55adb37e3c5bc2d249a6a8cb23873c0391f4580 (diff)
parentae1c3c7aee14e7f7fe1e6470cf9353c5f3731d24 (diff)
downloadslskd-c06e61b83bbc857b9b648792846a03900cb4b705.tar.gz
Merge pull request #1555 from x0vi/feature/configurable-ip-address
feature: configurable ip address
-rw-r--r--config/slskd.example.yml2
-rw-r--r--docs/config.md30
-rw-r--r--src/slskd/Core/Options.cs22
-rw-r--r--src/slskd/Program.cs10
4 files changed, 45 insertions, 19 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/docs/config.md b/docs/config.md
index 2646dd94..c0a545f9 100644
--- a/docs/config.md
+++ b/docs/config.md
@@ -806,13 +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 |
-| `--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 |
+| 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 |
#### **YAML**
```yaml
@@ -832,13 +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 |
-| `-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
diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs
index 76dcd45c..d3e302a5 100644
--- a/src/slskd/Core/Options.cs
+++ b/src/slskd/Core/Options.cs
@@ -1839,6 +1839,16 @@ namespace slskd
public int Port { get; init; } = 5030;
/// <summary>
+ /// Gets the IP address on which to listen for HTTP requests.
+ /// </summary>
+ [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";
+
+ /// <summary>
/// Gets the HTTP listen unix domain socket (UDS) path.
/// </summary>
[Argument(default, "http-socket")]
@@ -2038,7 +2048,17 @@ namespace slskd
[Range(1, 65535)]
[RequiresRestart]
public int Port { get; init; } = 5031;
-
+
+ /// <summary>
+ /// Gets the IP address on which to listen for HTTPS requests.
+ /// </summary>
+ [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";
+
/// <summary>
/// Gets a value indicating whether HTTP requests should be redirected to HTTPS.
/// </summary>
diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs
index aa320961..a56c8afc 100644
--- a/src/slskd/Program.cs
+++ b/src/slskd/Program.cs
@@ -478,8 +478,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)
{
@@ -489,8 +490,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;