diff options
| author | JP Dillingham <jp@dillingham.me> | 2022-11-18 14:22:52 -0600 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2022-11-18 14:22:52 -0600 |
| commit | 8c07bd366bcb0b897f1ae8ad9ae711d083114dc6 (patch) | |
| tree | f720da61d8412a2e8666d4ab04621f5023fde26b /src | |
| parent | cb22565ef6a30f00d3ddac0f92ab69abe84bc6d0 (diff) | |
| download | slskd-8c07bd366bcb0b897f1ae8ad9ae711d083114dc6.tar.gz | |
only configure relay service if enabled
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/Relay/RelayService.cs | 47 |
1 files changed, 25 insertions, 22 deletions
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<OperationMode>(); - - 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<OperationMode>(); - 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; |
