refactor: move IModeController.TestNatRequired to Mode

This commit is contained in:
ChsBuffer
2020-10-13 09:48:21 +08:00
parent 79b6e5da43
commit ceb57dcc1a
6 changed files with 9 additions and 9 deletions

View File

@@ -11,8 +11,6 @@ namespace Netch.Controllers
{
public class HTTPController : IModeController
{
public bool TestNatRequired { get; } = false;
public const string IEProxyExceptions = "localhost;127.*;10.*;172.16.*;172.17.*;172.18.*;172.19.*;172.20.*;172.21.*;172.22.*;172.23.*;172.24.*;172.25.*;172.26.*;172.27.*;172.28.*;172.29.*;172.30.*;172.31.*;192.168.*";
public PrivoxyController pPrivoxyController = new PrivoxyController();

View File

@@ -11,7 +11,5 @@ namespace Netch.Controllers
/// <param name="mode">模式</param>
/// <returns>是否成功</returns>
public abstract bool Start(Server s, Mode mode);
public abstract bool TestNatRequired { get; }
}
}

View File

@@ -66,7 +66,7 @@ namespace Netch.Controllers
throw new StartFailedException();
}
if (ModeController?.TestNatRequired ?? false)
if (mode.TestNatRequired)
NatTest();
return true;

View File

@@ -13,8 +13,6 @@ namespace Netch.Controllers
{
public class NFController : IModeController
{
public bool TestNatRequired { get; } = true;
private static readonly ServiceController NFService = new ServiceController("netfilter2");
private static readonly string BinDriver = string.Empty;

View File

@@ -17,8 +17,6 @@ namespace Netch.Controllers
{
public class TUNTAPController : Guard, IModeController
{
public bool TestNatRequired { get; } = true;
private Mode _savedMode = new Mode();
private Server _savedServer = new Server();

View File

@@ -39,6 +39,14 @@ namespace Netch.Models
_ => false
};
public bool TestNatRequired => Type switch
{
0 => true,
1 => true,
2 => true,
_ => false
};
/// <summary>
/// 绕过中国0. 不绕过 1. 绕过)
/// </summary>