diff options
| author | JP Dillingham <jp@dillingham.me> | 2022-11-14 21:22:52 -0600 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2022-11-14 21:22:52 -0600 |
| commit | 46ee602c9744fa6636b2e87447cc557b63cfe0b9 (patch) | |
| tree | 609051dada16e1b829023326b72dd7344743c607 /src/slskd/Core | |
| parent | 7bc7e55208118ea622d72950648d09ccc6c816ee (diff) | |
| parent | 3d0af40b9e85ee4dc07665ffdf16449a873a0640 (diff) | |
| download | slskd-46ee602c9744fa6636b2e87447cc557b63cfe0b9.tar.gz | |
Merge remote-tracking branch 'origin/master' into agent-ui
Diffstat (limited to 'src/slskd/Core')
| -rw-r--r-- | src/slskd/Core/Options.cs | 63 | ||||
| -rw-r--r-- | src/slskd/Core/State.cs | 12 |
2 files changed, 42 insertions, 33 deletions
diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs index e273229f..3a61e376 100644 --- a/src/slskd/Core/Options.cs +++ b/src/slskd/Core/Options.cs @@ -32,7 +32,7 @@ namespace slskd using slskd.Authentication; using slskd.Configuration; using slskd.Cryptography; - using slskd.Network; + using slskd.Relay; using slskd.Shares; using slskd.Validation; using Soulseek.Diagnostics; @@ -151,15 +151,6 @@ namespace slskd public bool Debug { get; init; } = Debugger.IsAttached; /// <summary> - /// Gets a value indicating whether the application should run in experimental mode. - /// </summary> - [Argument(default, "experimental")] - [EnvironmentVariable("EXPERIMENTAL")] - [Description("run in experimental mode")] - [RequiresRestart] - public bool Experimental { get; init; } = false; - - /// <summary> /// Gets a value indicating whether remote configuration of options is allowed. /// </summary> [Argument(default, "remote-configuration")] @@ -205,10 +196,10 @@ namespace slskd public string ConfigurationFile { get; init; } = Program.DefaultConfigurationFile; /// <summary> - /// Gets network options. + /// Gets relay options. /// </summary> [Validate] - public NetworkOptions Network { get; init; } = new NetworkOptions(); + public RelayOptions Relay { get; init; } = new RelayOptions(); /// <summary> /// Gets directory options. @@ -297,9 +288,9 @@ namespace slskd { var results = new List<ValidationResult>(); - if (InstanceName == "local" && Network.Mode.ToEnum<OperationMode>() == OperationMode.Agent) + if (InstanceName == "local" && Relay.Mode.ToEnum<OperationMode>() == OperationMode.Agent) { - results.Add(new ValidationResult("Instance name must be something other than 'local' when operating in Network Agent mode")); + results.Add(new ValidationResult("Instance name must be something other than 'local' when operating in Relay Agent mode")); } return results; @@ -372,32 +363,50 @@ namespace slskd [Description("log SQL queries generated by Entity Framework")] [RequiresRestart] public bool LogSQL { get; init; } = false; + + /// <summary> + /// Gets a value indicating whether the application should run in experimental mode. + /// </summary> + [Argument(default, "experimental")] + [EnvironmentVariable("EXPERIMENTAL")] + [Description("run in experimental mode")] + [RequiresRestart] + public bool Experimental { get; init; } = false; + + /// <summary> + /// Gets a value indicating whether the application should run in volatile mode. + /// </summary> + [Argument(default, "volatile")] + [EnvironmentVariable("VOLATILE")] + [Description("use volatile data storage (all data will be lost at shutdown)")] + [RequiresRestart] + public bool Volatile { get; init; } = false; } /// <summary> - /// Network options. + /// Relay options. /// </summary> - public class NetworkOptions : IValidatableObject + public class RelayOptions : IValidatableObject { /// <summary> /// Gets the application operation mode. /// </summary> - [Argument('m', "network-operation-mode")] - [EnvironmentVariable("NETWORK_OPERATION_MODE")] - [Description("network operation mode; controller, agent")] + [Argument('m', "relay-operation-mode")] + [EnvironmentVariable("RELAY_OPERATION_MODE")] + [Description("relay operation mode; controller, agent")] [RequiresRestart] [Enum(typeof(OperationMode))] - public string Mode { get; init; } = slskd.Network.OperationMode.Controller.ToString().ToLowerInvariant(); + public string Mode { get; init; } = slskd.Relay.OperationMode.Controller.ToString().ToLowerInvariant(); /// <summary> /// Gets the controller configuration. /// </summary> - public NetworkControllerConfigurationOptions Controller { get; init; } = new NetworkControllerConfigurationOptions(); + public RelayControllerConfigurationOptions Controller { get; init; } = new RelayControllerConfigurationOptions(); /// <summary> /// Gets the agent configuration. /// </summary> - public Dictionary<string, NetworkAgentConfigurationOptions> Agents { get; init; } = new(); + public Dictionary<string, RelayAgentConfigurationOptions> Agents { get; init; } = new(); public IEnumerable<ValidationResult> Validate(ValidationContext validationContext) { @@ -405,7 +414,7 @@ namespace slskd var results = new List<ValidationResult>(); var modeResults = new List<ValidationResult>(); - if (mode == slskd.Network.OperationMode.Agent && !Validator.TryValidateObject(Controller, new ValidationContext(Controller), modeResults, validateAllProperties: true)) + if (mode == slskd.Relay.OperationMode.Agent && !Validator.TryValidateObject(Controller, new ValidationContext(Controller), modeResults, validateAllProperties: true)) { results.Add(new CompositeValidationResult("Controller", modeResults)); } @@ -430,9 +439,9 @@ namespace slskd } /// <summary> - /// Network controller configuration options. + /// Relay controller configuration options. /// </summary> - public class NetworkControllerConfigurationOptions + public class RelayControllerConfigurationOptions { /// <summary> /// Gets the controller address. @@ -476,9 +485,9 @@ namespace slskd } /// <summary> - /// Network agent configuration options. + /// Relay agent configuration options. /// </summary> - public class NetworkAgentConfigurationOptions + public class RelayAgentConfigurationOptions { /// <summary> /// Gets the agent secret. diff --git a/src/slskd/Core/State.cs b/src/slskd/Core/State.cs index df670893..76253501 100644 --- a/src/slskd/Core/State.cs +++ b/src/slskd/Core/State.cs @@ -22,7 +22,7 @@ namespace slskd using System.Linq; using System.Net; using System.Text.Json.Serialization; - using slskd.Network; + using slskd.Relay; using slskd.Users; using Soulseek; @@ -35,7 +35,7 @@ namespace slskd public bool PendingReconnect { get; init; } public bool PendingRestart { get; init; } public ServerState Server { get; init; } = new ServerState(); - public NetworkState Network { get; init; } = new NetworkState(); + public RelayState Relay { get; init; } = new RelayState(); public UserState User { get; init; } = new UserState(); public DistributedNetworkState DistributedNetwork { get; init; } = new DistributedNetworkState(); public ShareState Shares { get; init; } = new ShareState(); @@ -65,17 +65,17 @@ namespace slskd public bool IsTransitioning => State.HasFlag(SoulseekClientStates.Connecting) || State.HasFlag(SoulseekClientStates.Disconnecting) || State.HasFlag(SoulseekClientStates.LoggingIn); } - public record NetworkState + public record RelayState { public OperationMode Mode { get; init; } - public NetworkControllerState Controller { get; init; } = new NetworkControllerState(); + public RelayControllerState Controller { get; init; } = new RelayControllerState(); public IReadOnlyCollection<Agent> Agents { get; init; } = Enumerable.Empty<Agent>().ToList().AsReadOnly(); } - public record NetworkControllerState + public record RelayControllerState { public string Address { get; init; } - public NetworkClientState State { get; init; } = NetworkClientState.Disconnected; + public RelayClientState State { get; init; } = RelayClientState.Disconnected; } public record UserState |
