From 8c07bd366bcb0b897f1ae8ad9ae711d083114dc6 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Fri, 18 Nov 2022 14:22:52 -0600 Subject: only configure relay service if enabled --- src/slskd/Relay/RelayService.cs | 47 ++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/slskd/Relay/RelayService.cs b/src/slskd/Relay/RelayService.cs index 2e986c84..79f9f143 100644 --- a/src/slskd/Relay/RelayService.cs +++ b/src/slskd/Relay/RelayService.cs @@ -716,32 +716,35 @@ namespace slskd.Relay return; } - var mode = options.Relay.Mode.ToEnum(); - - if (mode == OperationMode.Controller) - { - State.SetValue(state => state with - { - Mode = mode, - Agents = RegisteredAgents, - }); - } - else + if (options.Relay.Enabled) { - // the controller changed. disconnect and throw away the client and create a new one - Client = new RelayClient(Shares, OptionsMonitor, HttpClientFactory); - Client.StateMonitor.OnChange(clientState - => State.SetValue(state => state with { Controller = state.Controller with { State = clientState.Current } })); + var mode = options.Relay.Mode.ToEnum(); - State.SetValue(state => state with + if (mode == OperationMode.Controller) { - Mode = mode, - Controller = new RelayControllerState() + State.SetValue(state => state with + { + Mode = mode, + Agents = RegisteredAgents, + }); + } + else + { + // the controller changed. disconnect and throw away the client and create a new one + Client = new RelayClient(Shares, OptionsMonitor, HttpClientFactory); + Client.StateMonitor.OnChange(clientState + => State.SetValue(state => state with { Controller = state.Controller with { State = clientState.Current } })); + + State.SetValue(state => state with { - Address = options.Relay.Controller.Address, - State = Client.StateMonitor.CurrentValue, - }, - }); + Mode = mode, + Controller = new RelayControllerState() + { + Address = options.Relay.Controller.Address, + State = Client.StateMonitor.CurrentValue, + }, + }); + } } LastOptionsHash = optionsHash; -- cgit v1.2.3