mirror of
https://github.com/lidarr/Lidarr
synced 2025-02-27 00:02:25 +00:00
Don't get registered URLs until they need to be configured
This commit is contained in:
parent
37fc1f4dcc
commit
9adc168b90
1 changed files with 16 additions and 6 deletions
|
@ -32,7 +32,7 @@ public List<string> Urls
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<UrlAcl> InternalUrls { get; }
|
private List<UrlAcl> InternalUrls { get; }
|
||||||
private List<UrlAcl> RegisteredUrls { get; }
|
private List<UrlAcl> RegisteredUrls { get; set; }
|
||||||
|
|
||||||
private static readonly Regex UrlAclRegex = new Regex(@"(?<scheme>https?)\:\/\/(?<address>.+?)\:(?<port>\d+)/(?<urlbase>.+)?", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
private static readonly Regex UrlAclRegex = new Regex(@"(?<scheme>https?)\:\/\/(?<address>.+?)\:(?<port>\d+)/(?<urlbase>.+)?", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||||
|
|
||||||
|
@ -49,11 +49,16 @@ public UrlAclAdapter(INetshProvider netshProvider,
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
|
|
||||||
InternalUrls = new List<UrlAcl>();
|
InternalUrls = new List<UrlAcl>();
|
||||||
RegisteredUrls = GetRegisteredUrls();
|
RegisteredUrls = new List<UrlAcl>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ConfigureUrls()
|
public void ConfigureUrls()
|
||||||
{
|
{
|
||||||
|
if (RegisteredUrls.Empty())
|
||||||
|
{
|
||||||
|
GetRegisteredUrls();
|
||||||
|
}
|
||||||
|
|
||||||
var localHostHttpUrls = BuildUrlAcls("http", "localhost", _configFileProvider.Port);
|
var localHostHttpUrls = BuildUrlAcls("http", "localhost", _configFileProvider.Port);
|
||||||
var interfaceHttpUrls = BuildUrlAcls("http", _configFileProvider.BindAddress, _configFileProvider.Port);
|
var interfaceHttpUrls = BuildUrlAcls("http", _configFileProvider.BindAddress, _configFileProvider.Port);
|
||||||
|
|
||||||
|
@ -128,19 +133,24 @@ private bool IsRegistered(UrlAcl urlAcl)
|
||||||
c.UrlBase == urlAcl.UrlBase);
|
c.UrlBase == urlAcl.UrlBase);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<UrlAcl> GetRegisteredUrls()
|
private void GetRegisteredUrls()
|
||||||
{
|
{
|
||||||
if (OsInfo.IsNotWindows)
|
if (OsInfo.IsNotWindows)
|
||||||
{
|
{
|
||||||
return new List<UrlAcl>();
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (RegisteredUrls.Any())
|
||||||
|
{
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var arguments = string.Format("http show urlacl");
|
var arguments = string.Format("http show urlacl");
|
||||||
var output = _netshProvider.Run(arguments);
|
var output = _netshProvider.Run(arguments);
|
||||||
|
|
||||||
if (output == null || !output.Standard.Any()) return new List<UrlAcl>();
|
if (output == null || !output.Standard.Any()) return;
|
||||||
|
|
||||||
return output.Standard.Select(line =>
|
RegisteredUrls = output.Standard.Select(line =>
|
||||||
{
|
{
|
||||||
var match = UrlAclRegex.Match(line.Content);
|
var match = UrlAclRegex.Match(line.Content);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue