diff options
| author | JP Dillingham <jp@dillingham.me> | 2022-11-08 07:46:30 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-08 07:46:30 -0600 |
| commit | 7850ce245d51c80b0b05f59523d866dae2303669 (patch) | |
| tree | 7658ca859d3563c1b4f773d7bd1d707662fcd015 /src/slskd/Core | |
| parent | f03520a84f7ce90339f0339bb4bd7e7d0d34a856 (diff) | |
| parent | 74dbb69973035a93e2eda532bd6afe7e2f89d741 (diff) | |
| download | slskd-7850ce245d51c80b0b05f59523d866dae2303669.tar.gz | |
Merge pull request #739 from slskd/network-state
Add network state to application state
Diffstat (limited to 'src/slskd/Core')
| -rw-r--r-- | src/slskd/Core/Options.cs | 9 | ||||
| -rw-r--r-- | src/slskd/Core/State.cs | 16 |
2 files changed, 16 insertions, 9 deletions
diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs index a1591923..8d529f03 100644 --- a/src/slskd/Core/Options.cs +++ b/src/slskd/Core/Options.cs @@ -372,15 +372,6 @@ namespace slskd [Description("log SQL queries generated by Entity Framework")] [RequiresRestart] public bool LogSQL { get; init; } = false; - - /// <summary> - /// Gets a value indicating whether to run in both controller and agent network modes. - /// </summary> - [Argument(default, "dual-network-mode")] - [EnvironmentVariable("DUAL_NETWORK_MODE")] - [Description("run in both controller and agent network modes")] - [RequiresRestart] - public bool DualNetworkMode { get; init; } = false; } /// <summary> diff --git a/src/slskd/Core/State.cs b/src/slskd/Core/State.cs index f3fbf03e..df670893 100644 --- a/src/slskd/Core/State.cs +++ b/src/slskd/Core/State.cs @@ -19,8 +19,10 @@ namespace slskd { using System; using System.Collections.Generic; + using System.Linq; using System.Net; using System.Text.Json.Serialization; + using slskd.Network; using slskd.Users; using Soulseek; @@ -33,6 +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 UserState User { get; init; } = new UserState(); public DistributedNetworkState DistributedNetwork { get; init; } = new DistributedNetworkState(); public ShareState Shares { get; init; } = new ShareState(); @@ -62,6 +65,19 @@ namespace slskd public bool IsTransitioning => State.HasFlag(SoulseekClientStates.Connecting) || State.HasFlag(SoulseekClientStates.Disconnecting) || State.HasFlag(SoulseekClientStates.LoggingIn); } + public record NetworkState + { + public OperationMode Mode { get; init; } + public NetworkControllerState Controller { get; init; } = new NetworkControllerState(); + public IReadOnlyCollection<Agent> Agents { get; init; } = Enumerable.Empty<Agent>().ToList().AsReadOnly(); + } + + public record NetworkControllerState + { + public string Address { get; init; } + public NetworkClientState State { get; init; } = NetworkClientState.Disconnected; + } + public record UserState { public string Username { get; init; } |
