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 bool AllowExternal { get; set; }
public string APIKey { get; set; } public string APIKey { get; set; }
public string GetListenAddress(bool? external = null) public string[] GetListenAddresses(bool? external = null)
{ {
if (external == null) if (external == null)
{ {
external = AllowExternal; 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() public string GenerateApi()

View File

@@ -103,22 +103,24 @@ namespace Jackett.Services
// Load indexers // Load indexers
indexerService.InitIndexers(); indexerService.InitIndexers();
// Start the server // Start the server
logger.Debug("Starting web server at " + config.GetListenAddress()); logger.Debug("Starting web server at " + config.GetListenAddresses()[0]);
_server = WebApp.Start<Startup>(url: config.GetListenAddress()); var startOptions = new StartOptions();
config.GetListenAddresses().ToList().ForEach(u => startOptions.Urls.Add(u));
_server = WebApp.Start<Startup>(startOptions);
logger.Debug("Web server started"); logger.Debug("Web server started");
} }
public void ReserveUrls(bool doInstall = true) public void ReserveUrls(bool doInstall = true)
{ {
logger.Debug("Unreserving Urls"); logger.Debug("Unreserving Urls");
RunNetSh(string.Format("http delete urlacl {0}", config.GetListenAddress(false))); config.GetListenAddresses(false).ToList().ForEach(u => RunNetSh(string.Format("http delete urlacl {0}", u)));
RunNetSh(string.Format("http delete urlacl {0}", config.GetListenAddress(true))); config.GetListenAddresses(true).ToList().ForEach(u => RunNetSh(string.Format("http delete urlacl {0}", u)));
if (doInstall) if (doInstall)
{ {
logger.Debug("Reserving Urls"); 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"); logger.Debug("Urls reserved");
} }
} }