From 01f33f56c103d6ba229856abffbf66292bed03ff Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Fri, 6 Jan 2023 15:53:30 -0600 Subject: tweak startup logic --- src/slskd/Application.cs | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs index 30fee1be..0da48ae5 100644 --- a/src/slskd/Application.cs +++ b/src/slskd/Application.cs @@ -400,32 +400,38 @@ namespace slskd } } - if (OptionsAtStartup.Flags.NoConnect) - { - Log.Warning("Not connecting to the Soulseek server; 'no-connect' option is enabled"); - } - else if (string.IsNullOrEmpty(OptionsAtStartup.Soulseek.Username) || string.IsNullOrEmpty(OptionsAtStartup.Soulseek.Password)) - { - Log.Warning($"Not connecting to the Soulseek server; username and/or password invalid. Specify valid credentials and manually connect, or update config and restart."); - } - else if (OptionsAtStartup.Relay.Enabled && OptionsAtStartup.Relay.Mode.ToEnum() == RelayMode.Agent) + if (OptionsAtStartup.Relay.Enabled && OptionsAtStartup.Relay.Mode.ToEnum() == RelayMode.Agent) { Log.Information("Running in Agent relay mode; not connecting to the Soulseek server."); await Relay.Client.StartAsync(cancellationToken); } else { - if (OptionsAtStartup.Relay.Enabled && OptionsAtStartup.Relay.Mode.ToEnum() == RelayMode.Debug) + if (OptionsAtStartup.Relay.Enabled) + { + if (OptionsAtStartup.Relay.Mode.ToEnum() == RelayMode.Debug) + { + Log.Warning("Running in Debug relay mode; connecting to controller"); + _ = Relay.Client.StartAsync(cancellationToken); + } + else + { + Log.Information("Running in Controller relay mode. Listening for incoming Agent connections."); + } + } + + if (OptionsAtStartup.Flags.NoConnect) { - Log.Warning("Running in Debug relay mode; connecting to controller"); - _ = Relay.Client.StartAsync(cancellationToken); + Log.Warning("Not connecting to the Soulseek server; 'no-connect' option is enabled"); + } + else if (string.IsNullOrEmpty(OptionsAtStartup.Soulseek.Username) || string.IsNullOrEmpty(OptionsAtStartup.Soulseek.Password)) + { + Log.Warning($"Not connecting to the Soulseek server; username and/or password invalid. Specify valid credentials and manually connect, or update config and restart."); } else { - Log.Information("Running in Controller relay mode. Listening for incoming Agent connections."); + await Client.ConnectAsync(OptionsAtStartup.Soulseek.Username, OptionsAtStartup.Soulseek.Password).ConfigureAwait(false); } - - await Client.ConnectAsync(OptionsAtStartup.Soulseek.Username, OptionsAtStartup.Soulseek.Password).ConfigureAwait(false); } } -- cgit v1.2.3