diff options
| author | JP Dillingham <jp@dillingham.me> | 2022-11-18 16:13:26 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-18 16:13:26 -0600 |
| commit | 1ea40a325479d543714910a2848fcba0249f3724 (patch) | |
| tree | 998092ec045804bce76d1753df460f817db134c3 /src/slskd/Relay/RelayService.cs | |
| parent | 43c3a052796fbd490677de931c2b6925efa0fa5e (diff) | |
| parent | 8c67a655322fc787ef8677ebbded1596dab36b4d (diff) | |
| download | slskd-1ea40a325479d543714910a2848fcba0249f3724.tar.gz | |
Merge pull request #758 from slskd/disable-relay
Add an option to disable Relay functionality
Diffstat (limited to 'src/slskd/Relay/RelayService.cs')
| -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; |
