From 56825da6b6ec439c9557e6f17402b6175c827220 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Thu, 31 Aug 2017 22:05:49 -0700 Subject: [PATCH] Don't get registered URLs until they need to be configured --- .../AccessControl/UrlAclAdapter.cs | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/NzbDrone.Host/AccessControl/UrlAclAdapter.cs b/src/NzbDrone.Host/AccessControl/UrlAclAdapter.cs index fd483479b..35c2dee83 100644 --- a/src/NzbDrone.Host/AccessControl/UrlAclAdapter.cs +++ b/src/NzbDrone.Host/AccessControl/UrlAclAdapter.cs @@ -32,7 +32,7 @@ namespace NzbDrone.Host.AccessControl } private List InternalUrls { get; } - private List RegisteredUrls { get; } + private List RegisteredUrls { get; set; } private static readonly Regex UrlAclRegex = new Regex(@"(?https?)\:\/\/(?
.+?)\:(?\d+)/(?.+)?", RegexOptions.Compiled | RegexOptions.IgnoreCase); @@ -49,11 +49,16 @@ namespace NzbDrone.Host.AccessControl _logger = logger; InternalUrls = new List(); - RegisteredUrls = GetRegisteredUrls(); + RegisteredUrls = new List(); } public void ConfigureUrls() { + if (RegisteredUrls.Empty()) + { + GetRegisteredUrls(); + } + var localHostHttpUrls = BuildUrlAcls("http", "localhost", _configFileProvider.Port); var interfaceHttpUrls = BuildUrlAcls("http", _configFileProvider.BindAddress, _configFileProvider.Port); @@ -128,19 +133,24 @@ namespace NzbDrone.Host.AccessControl c.UrlBase == urlAcl.UrlBase); } - private List GetRegisteredUrls() + private void GetRegisteredUrls() { if (OsInfo.IsNotWindows) { - return new List(); + return; + } + + if (RegisteredUrls.Any()) + { + return; } var arguments = string.Format("http show urlacl"); var output = _netshProvider.Run(arguments); - if (output == null || !output.Standard.Any()) return new List(); + if (output == null || !output.Standard.Any()) return; - return output.Standard.Select(line => + RegisteredUrls = output.Standard.Select(line => { var match = UrlAclRegex.Match(line.Content);