Fix loopback & localhost entry points for mono

This commit is contained in:
unknown
2015-07-19 18:26:07 -06:00
parent a37f1df313
commit d02a19b94b
2 changed files with 20 additions and 9 deletions

View File

@@ -18,14 +18,23 @@ namespace Jackett.Models.Config
public bool AllowExternal { get; set; }
public string APIKey { get; set; }
public string GetListenAddress(bool? external = null)
public string[] GetListenAddresses(bool? external = null)
{
if (external == null)
{
external = AllowExternal;
}
return "http://" + (external.Value ? "*" : "127.0.0.1") + ":" + Port + "/";
if (external.Value)
{
return new string[] { "http://*:" + Port + "/" };
}
else
{
return new string[] {
"http://127.0.0.1:" + Port + "/",
"http://localhost:" + Port + "/",
};
}
}
public string GenerateApi()

View File

@@ -105,20 +105,22 @@ namespace Jackett.Services
indexerService.InitIndexers();
// Start the server
logger.Debug("Starting web server at " + config.GetListenAddress());
_server = WebApp.Start<Startup>(url: config.GetListenAddress());
logger.Debug("Starting web server at " + config.GetListenAddresses()[0]);
var startOptions = new StartOptions();
config.GetListenAddresses().ToList().ForEach(u => startOptions.Urls.Add(u));
_server = WebApp.Start<Startup>(startOptions);
logger.Debug("Web server started");
}
public void ReserveUrls(bool doInstall = true)
{
logger.Debug("Unreserving Urls");
RunNetSh(string.Format("http delete urlacl {0}", config.GetListenAddress(false)));
RunNetSh(string.Format("http delete urlacl {0}", config.GetListenAddress(true)));
config.GetListenAddresses(false).ToList().ForEach(u => RunNetSh(string.Format("http delete urlacl {0}", u)));
config.GetListenAddresses(true).ToList().ForEach(u => RunNetSh(string.Format("http delete urlacl {0}", u)));
if (doInstall)
{
logger.Debug("Reserving Urls");
RunNetSh(string.Format("http add urlacl {0} sddl=D:(A;;GX;;;S-1-1-0)", config.GetListenAddress()));
config.GetListenAddresses(true).ToList().ForEach(u => RunNetSh(string.Format("http add urlacl {0} sddl=D:(A;;GX;;;S-1-1-0)", u)));
logger.Debug("Urls reserved");
}
}