diff options
| author | gnattu <gnattu@users.noreply.github.com> | 2024-09-10 03:17:10 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-09 13:17:10 -0600 |
| commit | 987dbe98c8ab55c5c8eb563820e54453c835cdde (patch) | |
| tree | 8d84e69d461b60da74493bbbd7aac4fa12bb2756 | |
| parent | 3da081ba86940f3fcedb188b2243445d1f95c883 (diff) | |
cli: add option to disable network change detection (#11253)
4 files changed, 25 insertions, 3 deletions
diff --git a/Emby.Server.Implementations/ConfigurationOptions.cs b/Emby.Server.Implementations/ConfigurationOptions.cs index e86010513..702707297 100644 --- a/Emby.Server.Implementations/ConfigurationOptions.cs +++ b/Emby.Server.Implementations/ConfigurationOptions.cs @@ -20,7 +20,8 @@ namespace Emby.Server.Implementations { PlaylistsAllowDuplicatesKey, bool.FalseString }, { BindToUnixSocketKey, bool.FalseString }, { SqliteCacheSizeKey, "20000" }, - { FfmpegSkipValidationKey, bool.FalseString } + { FfmpegSkipValidationKey, bool.FalseString }, + { DetectNetworkChangeKey, bool.TrueString } }; } } diff --git a/Jellyfin.Server/StartupOptions.cs b/Jellyfin.Server/StartupOptions.cs index c3989751c..91ac827ca 100644 --- a/Jellyfin.Server/StartupOptions.cs +++ b/Jellyfin.Server/StartupOptions.cs @@ -68,6 +68,12 @@ namespace Jellyfin.Server public string? PublishedServerUrl { get; set; } /// <summary> + /// Gets or sets a value indicating whether the server should not detect network status change. + /// </summary> + [Option("nonetchange", Required = false, HelpText = "Indicates that the server should not detect network status change.")] + public bool NoDetectNetworkChange { get; set; } + + /// <summary> /// Gets the command line options as a dictionary that can be used in the .NET configuration system. /// </summary> /// <returns>The configuration dictionary.</returns> @@ -90,6 +96,11 @@ namespace Jellyfin.Server config.Add(FfmpegPathKey, FFmpegPath); } + if (NoDetectNetworkChange) + { + config.Add(DetectNetworkChangeKey, bool.FalseString); + } + return config; } } diff --git a/MediaBrowser.Controller/Extensions/ConfigurationExtensions.cs b/MediaBrowser.Controller/Extensions/ConfigurationExtensions.cs index 0aaf4fcd9..7ca508426 100644 --- a/MediaBrowser.Controller/Extensions/ConfigurationExtensions.cs +++ b/MediaBrowser.Controller/Extensions/ConfigurationExtensions.cs @@ -70,6 +70,11 @@ namespace MediaBrowser.Controller.Extensions public const string SqliteCacheSizeKey = "sqlite:cacheSize"; /// <summary> + /// The key for a setting that indicates whether the application should detect network status change. + /// </summary> + public const string DetectNetworkChangeKey = "DetectNetworkChange"; + + /// <summary> /// Gets a value indicating whether the application should host static web content from the <see cref="IConfiguration"/>. /// </summary> /// <param name="configuration">The configuration to retrieve the value from.</param> diff --git a/src/Jellyfin.Networking/Manager/NetworkManager.cs b/src/Jellyfin.Networking/Manager/NetworkManager.cs index cf6a2cc55..b285b836b 100644 --- a/src/Jellyfin.Networking/Manager/NetworkManager.cs +++ b/src/Jellyfin.Networking/Manager/NetworkManager.cs @@ -97,10 +97,15 @@ public class NetworkManager : INetworkManager, IDisposable _networkEventLock = new object(); _remoteAddressFilter = new List<IPNetwork>(); + _ = bool.TryParse(startupConfig[DetectNetworkChangeKey], out var detectNetworkChange); + UpdateSettings(_configurationManager.GetNetworkConfiguration()); - NetworkChange.NetworkAddressChanged += OnNetworkAddressChanged; - NetworkChange.NetworkAvailabilityChanged += OnNetworkAvailabilityChanged; + if (detectNetworkChange) + { + NetworkChange.NetworkAddressChanged += OnNetworkAddressChanged; + NetworkChange.NetworkAvailabilityChanged += OnNetworkAvailabilityChanged; + } _configurationManager.NamedConfigurationUpdated += ConfigurationUpdated; } |
