From b27dd4d219621b20f1cd9606dff5ddeb02c2757a Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 18 Nov 2023 19:10:47 -0600 Subject: add address and port options --- src/slskd/Core/Options.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src') diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs index 62334742..1d4742da 100644 --- a/src/slskd/Core/Options.cs +++ b/src/slskd/Core/Options.cs @@ -1248,6 +1248,25 @@ namespace slskd /// public class SoulseekOptions { + /// + /// Gets the address of the Soulseek server. + /// + [Argument(default, "slsk-address")] + [EnvironmentVariable("SLSK_ADDRESS")] + [Description("address of the Soulseek server")] + [RequiresReconnect] + public string Address { get; init; } = "vps.slsknet.org"; + + /// + /// Gets the port of the Soulseek server. + /// + [Argument(default, "slsk-port")] + [EnvironmentVariable("SLSK_PORT")] + [Description("port of the Soulseek server")] + [RequiresReconnect] + [Range(1024, 65535)] + public int Port { get; init; } = 2271; + /// /// Gets the username for the Soulseek network. /// -- cgit v1.2.3 From bc835a977728b1cafcee41a94440c17c397f3f3a Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 18 Nov 2023 19:11:24 -0600 Subject: update application code to use address and password --- src/slskd/Application.cs | 8 +++++++- src/slskd/Core/API/Controllers/ServerController.cs | 8 +++++++- src/slskd/Core/ConnectionWatchdog.cs | 9 ++++++++- 3 files changed, 22 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs index aca75418..b6d11914 100644 --- a/src/slskd/Application.cs +++ b/src/slskd/Application.cs @@ -438,7 +438,13 @@ namespace slskd } else { - await Client.ConnectAsync(OptionsAtStartup.Soulseek.Username, OptionsAtStartup.Soulseek.Password).ConfigureAwait(false); + var opt = OptionsAtStartup.Soulseek; + + await Client.ConnectAsync( + address: opt.Address, + port: opt.Port, + username: opt.Username, + password: opt.Password).ConfigureAwait(false); } } } diff --git a/src/slskd/Core/API/Controllers/ServerController.cs b/src/slskd/Core/API/Controllers/ServerController.cs index 983fd0a0..0caded00 100644 --- a/src/slskd/Core/API/Controllers/ServerController.cs +++ b/src/slskd/Core/API/Controllers/ServerController.cs @@ -67,7 +67,13 @@ namespace slskd.Core.API if (!Client.State.HasFlag(SoulseekClientStates.Connected)) { - await Client.ConnectAsync(OptionsSnapshot.Value.Soulseek.Username, OptionsSnapshot.Value.Soulseek.Password); + var opt = OptionsSnapshot.Value.Soulseek; + + await Client.ConnectAsync( + address: opt.Address, + port: opt.Port, + username: opt.Username, + password: opt.Password); } return Ok(); diff --git a/src/slskd/Core/ConnectionWatchdog.cs b/src/slskd/Core/ConnectionWatchdog.cs index 6a48c0e4..19e2d47c 100644 --- a/src/slskd/Core/ConnectionWatchdog.cs +++ b/src/slskd/Core/ConnectionWatchdog.cs @@ -165,7 +165,14 @@ namespace slskd // reconnect with the latest configuration values we have for username and password, instead of the // options that were captured at startup. if a user has updated these values prior to the disconnect, // the changes will take effect now. - await Client.ConnectAsync(Options.CurrentValue.Soulseek.Username, Options.CurrentValue.Soulseek.Password); + var opt = Options.CurrentValue.Soulseek; + + await Client.ConnectAsync( + address: opt.Address, + port: opt.Port, + username: opt.Username, + password: opt.Password); + break; } catch (Exception ex) -- cgit v1.2.3