diff options
| author | JP Dillingham <jp@dillingham.me> | 2026-02-08 13:08:39 -0600 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2026-02-08 13:08:39 -0600 |
| commit | c3d69a12a52d2ca550aa2f7345fd6e0cc6c8a41d (patch) | |
| tree | c9818cce24d72b1137e6b477d08ff611af2f2af7 /src/slskd/Integrations | |
| parent | 29d7927982da0cc26484410ead30758f242b3dfc (diff) | |
| download | slskd-c3d69a12a52d2ca550aa2f7345fd6e0cc6c8a41d.tar.gz | |
remove required option; if vpn is enabled it is required
Diffstat (limited to 'src/slskd/Integrations')
| -rw-r--r-- | src/slskd/Integrations/VPN/VPNService.cs | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/src/slskd/Integrations/VPN/VPNService.cs b/src/slskd/Integrations/VPN/VPNService.cs index 2c42ff97..bc3eb668 100644 --- a/src/slskd/Integrations/VPN/VPNService.cs +++ b/src/slskd/Integrations/VPN/VPNService.cs @@ -149,6 +149,7 @@ public class VPNService : IDisposable private async Task CheckConnection() { + var options = OptionsMonitor.CurrentValue.Integration.Vpn; bool isReadyNow = false; VPNStatus status = new VPNStatus(); @@ -172,7 +173,7 @@ public class VPNService : IDisposable if (status is not null && status.IsConnected) { - if (OptionsMonitor.CurrentValue.Integration.Vpn.PortForwarding) + if (options.PortForwarding) { if (status.ForwardedPort.HasValue) { @@ -202,8 +203,14 @@ public class VPNService : IDisposable if (!IsReady && isReadyNow) { - string port = OptionsMonitor.CurrentValue.Integration.Vpn.PortForwarding ? status.ForwardedPort.ToString() : "N/A"; - Log.Information("VPN client connected and ready. IP: {PublicIP} ({Location}), Forwarded port: {Port}", status.PublicIPAddress, status.Location, status.ForwardedPort.ToString() ?? "N/A"); + if (options.PortForwarding) + { + Log.Information("VPN client connected and ready. IP: {PublicIP} ({Location}), Forwarded port: {Port}", status.PublicIPAddress, status.Location, status.ForwardedPort); + } + else + { + Log.Information("VPN client connected and ready. IP: {PublicIP} ({Location})", status.PublicIPAddress, status.Location); + } } else if (IsReady && !isReadyNow) { @@ -211,17 +218,23 @@ public class VPNService : IDisposable } else if (!IsReady && !isReadyNow) { - string port = OptionsMonitor.CurrentValue.Integration.Vpn.PortForwarding ? status.ForwardedPort.ToString() : "N/A"; - port = string.IsNullOrEmpty(port) ? "?" : port; - - string ip = status.PublicIPAddress == default ? "?" : status.PublicIPAddress.ToString(); - Log.Information("Waiting for VPN client; IP: {PublicIP}, Forwarded port: {Port}", ip, port); + if (!options.PortForwarding) + { + Log.Information("Waiting for VPN client; IP: ?"); + } + else + { + // port could possibly come first, if the client allows the user to specify it + string port = status.ForwardedPort.HasValue ? status.ForwardedPort.ToString() : "?"; + string ip = status.PublicIPAddress == default ? "?" : status.PublicIPAddress.ToString(); + Log.Information("Waiting for VPN client; IP: {PublicIP}, Forwarded port: {Port}", ip, port); + } } IsReady = isReadyNow; Status = status ?? new VPNStatus(); - if (OptionsAtStartup.Integration.Vpn.Required && !IsReady) + if (!IsReady) { SoulseekClient.Disconnect("VPN client disconnected", new VPNClientException("VPN client disconnected")); } |
