mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-16 11:37:58 +02:00
minor cleanup
This commit is contained in:
parent
c88b5ee946
commit
b6d3c28fa1
@ -3,12 +3,11 @@
|
|||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Core.Configuration;
|
using NzbDrone.Core.Configuration;
|
||||||
|
|
||||||
namespace NzbDrone.Host.Host
|
namespace NzbDrone.Host.AccessControl
|
||||||
{
|
{
|
||||||
public interface IFirewallAdapter
|
public interface IFirewallAdapter
|
||||||
{
|
{
|
||||||
void MakeAccessible();
|
void MakeAccessible();
|
||||||
bool IsNzbDronePortOpen();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class FirewallAdapter : IFirewallAdapter
|
public class FirewallAdapter : IFirewallAdapter
|
||||||
@ -24,8 +23,6 @@ public FirewallAdapter(IConfigFileProvider configFileProvider, Logger logger)
|
|||||||
|
|
||||||
public void MakeAccessible()
|
public void MakeAccessible()
|
||||||
{
|
{
|
||||||
int port = 0;
|
|
||||||
|
|
||||||
if (IsFirewallEnabled())
|
if (IsFirewallEnabled())
|
||||||
{
|
{
|
||||||
if (IsNzbDronePortOpen())
|
if (IsNzbDronePortOpen())
|
||||||
@ -42,7 +39,7 @@ public void MakeAccessible()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public bool IsNzbDronePortOpen()
|
private bool IsNzbDronePortOpen()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -75,7 +72,7 @@ private void OpenFirewallPort(int portNumber)
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var type = Type.GetTypeFromProgID("HNetCfg.FWOpenPort", false);
|
var type = Type.GetTypeFromProgID("HNetCfg.FWOpenPort", false);
|
||||||
var port = Activator.CreateInstance(type) as INetFwOpenPort;
|
var port = (INetFwOpenPort)Activator.CreateInstance(type);
|
||||||
|
|
||||||
port.Port = portNumber;
|
port.Port = portNumber;
|
||||||
port.Name = "NzbDrone";
|
port.Name = "NzbDrone";
|
||||||
@ -94,7 +91,7 @@ private void OpenFirewallPort(int portNumber)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int CloseFirewallPort()
|
private void CloseFirewallPort()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -116,14 +113,12 @@ private int CloseFirewallPort()
|
|||||||
if (portNumber != _configFileProvider.Port)
|
if (portNumber != _configFileProvider.Port)
|
||||||
{
|
{
|
||||||
ports.Remove(portNumber, NET_FW_IP_PROTOCOL_.NET_FW_IP_PROTOCOL_TCP);
|
ports.Remove(portNumber, NET_FW_IP_PROTOCOL_.NET_FW_IP_PROTOCOL_TCP);
|
||||||
return portNumber;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.WarnException("Failed to close port in firewall for NzbDrone", ex);
|
_logger.WarnException("Failed to close port in firewall for NzbDrone", ex);
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsFirewallEnabled()
|
private bool IsFirewallEnabled()
|
@ -4,7 +4,7 @@
|
|||||||
using NzbDrone.Common.EnvironmentInfo;
|
using NzbDrone.Common.EnvironmentInfo;
|
||||||
using NzbDrone.Core.Configuration;
|
using NzbDrone.Core.Configuration;
|
||||||
|
|
||||||
namespace NzbDrone.Host.Host
|
namespace NzbDrone.Host.AccessControl
|
||||||
{
|
{
|
||||||
public interface IUrlAclAdapter
|
public interface IUrlAclAdapter
|
||||||
{
|
{
|
||||||
@ -43,8 +43,6 @@ private void RunNetsh(string arguments)
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
var process = _processProvider.ShellExecute("netsh.exe", arguments);
|
var process = _processProvider.ShellExecute("netsh.exe", arguments);
|
||||||
process.WaitForExit(5000);
|
process.WaitForExit(5000);
|
||||||
}
|
}
|
@ -4,7 +4,7 @@
|
|||||||
using NzbDrone.Common;
|
using NzbDrone.Common;
|
||||||
using NzbDrone.Common.EnvironmentInfo;
|
using NzbDrone.Common.EnvironmentInfo;
|
||||||
using NzbDrone.Core.Configuration;
|
using NzbDrone.Core.Configuration;
|
||||||
using NzbDrone.Host.Host;
|
using NzbDrone.Host.AccessControl;
|
||||||
using NzbDrone.Host.Owin;
|
using NzbDrone.Host.Owin;
|
||||||
|
|
||||||
namespace NzbDrone.Host
|
namespace NzbDrone.Host
|
||||||
|
@ -107,8 +107,8 @@
|
|||||||
<Compile Include="ApplicationServer.cs">
|
<Compile Include="ApplicationServer.cs">
|
||||||
<SubType>Component</SubType>
|
<SubType>Component</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Host\FirewallAdapter.cs" />
|
<Compile Include="AccessControl\FirewallAdapter.cs" />
|
||||||
<Compile Include="Host\UrlAclAdapter.cs" />
|
<Compile Include="AccessControl\UrlAclAdapter.cs" />
|
||||||
<Compile Include="MainAppContainerBuilder.cs" />
|
<Compile Include="MainAppContainerBuilder.cs" />
|
||||||
<Compile Include="ApplicationModes.cs" />
|
<Compile Include="ApplicationModes.cs" />
|
||||||
<Compile Include="Bootstrap.cs" />
|
<Compile Include="Bootstrap.cs" />
|
||||||
|
@ -121,9 +121,6 @@
|
|||||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<None Include="Resources\NzbDroneIcon.bmp" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<PreBuildEvent>
|
<PreBuildEvent>
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 3.3 KiB |
Loading…
Reference in New Issue
Block a user