New: Added check to ensure FW is enabled before opening and closing ports.
This commit is contained in:
parent
340f05aef4
commit
ab7d3ebcc5
|
@ -37,18 +37,23 @@ namespace NzbDrone.Common
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsNzbDronePortOpen())
|
int port = 0;
|
||||||
|
|
||||||
|
if (IsFirewallEnabled())
|
||||||
{
|
{
|
||||||
Logger.Trace("NzbDrone port is already open, skipping.");
|
if(IsNzbDronePortOpen())
|
||||||
return;
|
{
|
||||||
|
Logger.Trace("NzbDrone port is already open, skipping.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Close any old ports
|
||||||
|
port = CloseFirewallPort();
|
||||||
|
|
||||||
|
//Open the new port
|
||||||
|
OpenFirewallPort(_configFileProvider.Port);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Close any old ports
|
|
||||||
var port = CloseFirewallPort();
|
|
||||||
|
|
||||||
//Open the new port
|
|
||||||
OpenFirewallPort(_configFileProvider.Port);
|
|
||||||
|
|
||||||
//Skip Url Register if not Vista or 7
|
//Skip Url Register if not Vista or 7
|
||||||
if (_enviromentProvider.GetOsVersion().Major < 6)
|
if (_enviromentProvider.GetOsVersion().Major < 6)
|
||||||
return;
|
return;
|
||||||
|
@ -123,7 +128,7 @@ namespace NzbDrone.Common
|
||||||
}
|
}
|
||||||
catch(Exception ex)
|
catch(Exception ex)
|
||||||
{
|
{
|
||||||
Logger.WarnException("Failed to open port in firewall for NzbDrone" + portNumber, ex);
|
Logger.WarnException("Failed to open port in firewall for NzbDrone " + portNumber, ex);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -161,6 +166,22 @@ namespace NzbDrone.Common
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool IsFirewallEnabled()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var netFwMgrType = Type.GetTypeFromProgID("HNetCfg.FwMgr", false);
|
||||||
|
var mgr = (INetFwMgr)Activator.CreateInstance(netFwMgrType);
|
||||||
|
return mgr.LocalPolicy.CurrentProfile.FirewallEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
Logger.WarnException("Failed to check if the firewall is enabled", ex);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private bool RegisterUrl(int portNumber)
|
private bool RegisterUrl(int portNumber)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
|
@ -45,7 +45,7 @@ namespace NzbDrone.Web.Models
|
||||||
public bool Monitored { get; set; }
|
public bool Monitored { get; set; }
|
||||||
|
|
||||||
[DisplayName("Backlog Setting")]
|
[DisplayName("Backlog Setting")]
|
||||||
[Description("Should NzbDrone download past missing episodes?")]
|
[Description("Should NzbDrone search for missing episodes every 30 days?")]
|
||||||
public int BacklogSetting { get; set; }
|
public int BacklogSetting { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue