mirror of
https://github.com/netchx/netch.git
synced 2026-04-05 19:45:05 +08:00
refactor: move IModeController.TestNatRequired to Mode
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
@@ -66,7 +66,7 @@ namespace Netch.Controllers
|
||||
throw new StartFailedException();
|
||||
}
|
||||
|
||||
if (ModeController?.TestNatRequired ?? false)
|
||||
if (mode.TestNatRequired)
|
||||
NatTest();
|
||||
|
||||
return true;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -39,6 +39,14 @@ namespace Netch.Models
|
||||
_ => false
|
||||
};
|
||||
|
||||
public bool TestNatRequired => Type switch
|
||||
{
|
||||
0 => true,
|
||||
1 => true,
|
||||
2 => true,
|
||||
_ => false
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// 绕过中国(0. 不绕过 1. 绕过)
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user