mirror of
https://github.com/netchx/netch.git
synced 2026-05-11 23:45:06 +08:00
Compare commits
27 Commits
1.6.0-Beta
...
1.6.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3efbad5e5e | ||
|
|
020c2d7e67 | ||
|
|
adcc6a75c9 | ||
|
|
7e907eef6f | ||
|
|
d213872bde | ||
|
|
71687c1da6 | ||
|
|
2eb6b23ca7 | ||
|
|
5490364217 | ||
|
|
e1d66970e2 | ||
|
|
af05878cc5 | ||
|
|
a59cfdf066 | ||
|
|
513667d983 | ||
|
|
2e89011f56 | ||
|
|
d369858273 | ||
|
|
78def0ae1d | ||
|
|
2dc4bb771e | ||
|
|
4b4280c06b | ||
|
|
23ac571ade | ||
|
|
6f9e364444 | ||
|
|
9fbac446e3 | ||
|
|
73c7a9fe32 | ||
|
|
4617de3fda | ||
|
|
40db9adc0d | ||
|
|
ec4e98db62 | ||
|
|
4f3b0e5afb | ||
|
|
36dc4a07f1 | ||
|
|
cc99d32232 |
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@@ -9,7 +9,7 @@ jobs:
|
||||
uses: nuget/setup-nuget@v1
|
||||
|
||||
- name: Setup MSBuild
|
||||
uses: microsoft/setup-msbuild@v1.0.0
|
||||
uses: microsoft/setup-msbuild@v1.0.1
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
@@ -9,6 +9,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetchLib", "NetchLib\NetchL
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetchUpdater", "NetchUpdater\NetchUpdater.csproj", "{828318A8-9B90-4A5F-BD6B-E632CC9D8933}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{53397641-35CA-4336-8E22-2CE12EF476AC}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
@@ -27,6 +29,10 @@ Global
|
||||
{828318A8-9B90-4A5F-BD6B-E632CC9D8933}.Debug|x64.Build.0 = Debug|x64
|
||||
{828318A8-9B90-4A5F-BD6B-E632CC9D8933}.Release|x64.ActiveCfg = Release|x64
|
||||
{828318A8-9B90-4A5F-BD6B-E632CC9D8933}.Release|x64.Build.0 = Release|x64
|
||||
{53397641-35CA-4336-8E22-2CE12EF476AC}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{53397641-35CA-4336-8E22-2CE12EF476AC}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{53397641-35CA-4336-8E22-2CE12EF476AC}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{53397641-35CA-4336-8E22-2CE12EF476AC}.Release|x64.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -4,13 +4,10 @@ using System.Text;
|
||||
|
||||
namespace Netch.Controllers
|
||||
{
|
||||
public class DNSController : Controller
|
||||
public class DNSController : IController
|
||||
{
|
||||
public DNSController()
|
||||
{
|
||||
Name = "DNS Service";
|
||||
RedirectStd = false;
|
||||
}
|
||||
|
||||
public string Name { get; } = "DNS Service";
|
||||
|
||||
/// <summary>
|
||||
/// 启动DNS服务
|
||||
@@ -27,7 +24,7 @@ namespace Netch.Controllers
|
||||
aiodns_init();
|
||||
}
|
||||
|
||||
public override void Stop()
|
||||
public void Stop()
|
||||
{
|
||||
aiodns_free();
|
||||
}
|
||||
|
||||
@@ -12,12 +12,18 @@ using Timer = System.Timers.Timer;
|
||||
|
||||
namespace Netch.Controllers
|
||||
{
|
||||
abstract partial class Controller
|
||||
public abstract class Guard
|
||||
{
|
||||
public abstract string Name { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// 主程序名
|
||||
/// </summary>
|
||||
public string MainFile { get; protected set; }
|
||||
public abstract string MainFile { get; protected set; }
|
||||
|
||||
protected State State { get; set; } = State.Waiting;
|
||||
|
||||
public abstract void Stop();
|
||||
|
||||
/// <summary>
|
||||
/// 成功启动关键词
|
||||
@@ -4,29 +4,23 @@ using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Microsoft.Win32;
|
||||
using Netch.Models;
|
||||
using Netch.ServerEx.Socks5;
|
||||
using Netch.Servers.Socks5;
|
||||
using Netch.Utils;
|
||||
|
||||
namespace Netch.Controllers
|
||||
{
|
||||
public class HTTPController : ModeController
|
||||
public class HTTPController : IModeController
|
||||
{
|
||||
public override bool TestNatRequired { get; } = false;
|
||||
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.*";
|
||||
|
||||
/// <summary>
|
||||
/// 实例
|
||||
/// </summary>
|
||||
public PrivoxyController pPrivoxyController = new PrivoxyController();
|
||||
|
||||
private string prevBypass, prevHTTP, prevPAC;
|
||||
private bool prevEnabled;
|
||||
|
||||
public HTTPController()
|
||||
{
|
||||
Name = "HTTP";
|
||||
}
|
||||
public string Name { get; } = "HTTP";
|
||||
|
||||
/// <summary>
|
||||
/// 启动
|
||||
@@ -34,7 +28,7 @@ namespace Netch.Controllers
|
||||
/// <param name="s">服务器</param>
|
||||
/// <param name="mode">模式</param>
|
||||
/// <returns>是否启动成功</returns>
|
||||
public override bool Start(Server s, Mode mode)
|
||||
public bool Start(Server s, Mode mode)
|
||||
{
|
||||
RecordPrevious();
|
||||
|
||||
@@ -97,7 +91,7 @@ namespace Netch.Controllers
|
||||
/// <summary>
|
||||
/// 停止
|
||||
/// </summary>
|
||||
public override void Stop()
|
||||
public void Stop()
|
||||
{
|
||||
var tasks = new[]
|
||||
{
|
||||
15
Netch/Controllers/IController.cs
Normal file
15
Netch/Controllers/IController.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
namespace Netch.Controllers
|
||||
{
|
||||
public interface IController
|
||||
{
|
||||
/// <summary>
|
||||
/// 控制器名
|
||||
/// </summary>
|
||||
public string Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 停止
|
||||
/// </summary>
|
||||
public abstract void Stop();
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ using Netch.Models;
|
||||
|
||||
namespace Netch.Controllers
|
||||
{
|
||||
public abstract class ModeController : Controller
|
||||
public interface IModeController : IController
|
||||
{
|
||||
/// <summary>
|
||||
/// 启动
|
||||
19
Netch/Controllers/IServerController.cs
Normal file
19
Netch/Controllers/IServerController.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using Netch.Models;
|
||||
|
||||
namespace Netch.Controllers
|
||||
{
|
||||
public interface IServerController : IController
|
||||
{
|
||||
public int? Socks5LocalPort { get; set; }
|
||||
|
||||
public string LocalAddress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 启动
|
||||
/// </summary>
|
||||
/// <param name="server">服务器</param>
|
||||
/// <param name="mode">模式</param>
|
||||
/// <returns>是否启动成功</returns>
|
||||
public abstract bool Start(Server server, Mode mode);
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
using Netch.Models;
|
||||
|
||||
namespace Netch.Controllers
|
||||
{
|
||||
public abstract partial class Controller
|
||||
{
|
||||
/// <summary>
|
||||
/// 控制器名
|
||||
/// </summary>
|
||||
public string Name { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// 当前状态
|
||||
/// </summary>
|
||||
public State State { get; protected set; } = State.Waiting;
|
||||
|
||||
/// <summary>
|
||||
/// 停止
|
||||
/// </summary>
|
||||
public abstract void Stop();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using Netch.Models;
|
||||
using Netch.Utils;
|
||||
@@ -10,8 +11,8 @@ namespace Netch.Controllers
|
||||
{
|
||||
public static class MainController
|
||||
{
|
||||
public static ServerController ServerController { get; private set; }
|
||||
public static ModeController ModeController { get; private set; }
|
||||
public static IServerController ServerController { get; private set; }
|
||||
public static IModeController ModeController { get; private set; }
|
||||
|
||||
public static bool NttTested;
|
||||
|
||||
@@ -34,12 +35,22 @@ namespace Netch.Controllers
|
||||
|
||||
NativeMethods.FlushDNSResolverCache();
|
||||
|
||||
if (!Utils.Utils.SearchOutboundAdapter(false))
|
||||
try
|
||||
{
|
||||
WebUtil.BestLocalEndPoint(new IPEndPoint(0x72727272, 53));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
MessageBoxX.Show("No internet connection");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (DNS.Lookup(server.Hostname) == null)
|
||||
{
|
||||
MessageBoxX.Show("Lookup Server hostname failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
_ = Task.Run(Firewall.AddNetchFwRules);
|
||||
|
||||
try
|
||||
@@ -54,7 +65,7 @@ namespace Netch.Controllers
|
||||
throw new StartFailedException();
|
||||
}
|
||||
|
||||
if (ModeController.TestNatRequired)
|
||||
if (ModeController?.TestNatRequired ?? false)
|
||||
NatTest();
|
||||
|
||||
return true;
|
||||
@@ -95,12 +106,16 @@ namespace Netch.Controllers
|
||||
return true;
|
||||
}
|
||||
|
||||
ServerController = Servers.GetUtilByTypeName(server.Type).GetController();
|
||||
ServerController = ServerHelper.GetUtilByTypeName(server.Type).GetController();
|
||||
|
||||
if (ServerController is Guard instanceController)
|
||||
{
|
||||
Utils.Utils.KillProcessByName(instanceController.MainFile);
|
||||
}
|
||||
|
||||
Utils.Utils.KillProcessByName(ServerController.MainFile);
|
||||
PortCheckAndShowMessageBox(Global.Settings.Socks5LocalPort, "Socks5");
|
||||
|
||||
Global.MainForm.StatusText(i18N.Translate("Starting ", ServerController.Name));
|
||||
Global.MainForm.StatusText(i18N.TranslateFormat("Starting {0}", ServerController.Name));
|
||||
if (await Task.Run(() => ServerController.Start(server, mode)))
|
||||
{
|
||||
UsingPorts.Add(StatusPortInfoText.Socks5Port = Global.Settings.Socks5LocalPort);
|
||||
@@ -136,7 +151,7 @@ namespace Netch.Controllers
|
||||
return false;
|
||||
}
|
||||
|
||||
Global.MainForm.StatusText(i18N.Translate("Starting ", ModeController.Name));
|
||||
Global.MainForm.StatusText(i18N.TranslateFormat("Starting {0}", ModeController.Name));
|
||||
if (await Task.Run(() => ModeController.Start(server, mode)))
|
||||
{
|
||||
switch (mode.Type)
|
||||
|
||||
@@ -9,9 +9,9 @@ using nfapinet;
|
||||
|
||||
namespace Netch.Controllers
|
||||
{
|
||||
public class NFController : ModeController
|
||||
public class NFController : IModeController
|
||||
{
|
||||
public override bool TestNatRequired { get; } = true;
|
||||
public bool TestNatRequired { get; } = true;
|
||||
|
||||
private static readonly ServiceController NFService = new ServiceController("netfilter2");
|
||||
|
||||
@@ -19,42 +19,40 @@ namespace Netch.Controllers
|
||||
private static readonly string SystemDriver = $"{Environment.SystemDirectory}\\drivers\\netfilter2.sys";
|
||||
private static string _sysDns;
|
||||
|
||||
public string Name { get; } = "Redirector";
|
||||
|
||||
static NFController()
|
||||
{
|
||||
string fileName;
|
||||
switch ($"{Environment.OSVersion.Version.Major}.{Environment.OSVersion.Version.Minor}")
|
||||
{
|
||||
case "10.0":
|
||||
BinDriver = "Win-10.sys";
|
||||
fileName = "Win-10.sys";
|
||||
break;
|
||||
case "6.3":
|
||||
case "6.2":
|
||||
BinDriver = "Win-8.sys";
|
||||
fileName = "Win-8.sys";
|
||||
break;
|
||||
case "6.1":
|
||||
case "6.0":
|
||||
BinDriver = "Win-7.sys";
|
||||
fileName = "Win-7.sys";
|
||||
break;
|
||||
default:
|
||||
Logging.Error($"不支持的系统版本:{Environment.OSVersion.Version}");
|
||||
return;
|
||||
}
|
||||
|
||||
BinDriver = "bin\\" + BinDriver;
|
||||
BinDriver = "bin\\" + fileName;
|
||||
}
|
||||
|
||||
public NFController()
|
||||
public bool Start(Server s, Mode mode)
|
||||
{
|
||||
Name = "Redirector";
|
||||
}
|
||||
|
||||
public override bool Start(Server s, Mode mode)
|
||||
{
|
||||
Logging.Info("内置驱动版本: " + Utils.Utils.FileVersion(BinDriver));
|
||||
if (Utils.Utils.FileVersion(SystemDriver) != Utils.Utils.FileVersion(BinDriver))
|
||||
Logging.Info("内置驱动版本: " + Utils.Utils.GetFileVersion(BinDriver));
|
||||
if (Utils.Utils.GetFileVersion(SystemDriver) != Utils.Utils.GetFileVersion(BinDriver))
|
||||
{
|
||||
if (File.Exists(SystemDriver))
|
||||
{
|
||||
Logging.Info("系统驱动版本: " + Utils.Utils.FileVersion(SystemDriver));
|
||||
Logging.Info("系统驱动版本: " + Utils.Utils.GetFileVersion(SystemDriver));
|
||||
Logging.Info("更新驱动");
|
||||
UninstallDriver();
|
||||
}
|
||||
@@ -99,7 +97,7 @@ namespace Netch.Controllers
|
||||
return aio_init();
|
||||
}
|
||||
|
||||
public override void Stop()
|
||||
public void Stop()
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
@@ -171,7 +169,7 @@ namespace Netch.Controllers
|
||||
/// <returns>是否成功卸载</returns>
|
||||
public static bool UninstallDriver()
|
||||
{
|
||||
Global.MainForm.StatusText(i18N.Translate("Uninstalling NF Service"));
|
||||
Global.MainForm.StatusText(i18N.TranslateFormat("Uninstalling {0}", "NF Service"));
|
||||
Logging.Info("卸载 NF 驱动");
|
||||
try
|
||||
{
|
||||
@@ -5,18 +5,14 @@ using Netch.Utils;
|
||||
|
||||
namespace Netch.Controllers
|
||||
{
|
||||
public class NTTController : Controller
|
||||
public class NTTController : Guard, IController
|
||||
{
|
||||
private string _localEnd;
|
||||
private string _publicEnd;
|
||||
private string _result;
|
||||
private string _bindingTest;
|
||||
|
||||
public NTTController()
|
||||
{
|
||||
Name = "NTT";
|
||||
MainFile = "NTT.exe";
|
||||
}
|
||||
public override string Name { get; protected set; } = "NTT";
|
||||
public override string MainFile { get; protected set; } = "NTT.exe";
|
||||
|
||||
/// <summary>
|
||||
/// 启动 NatTypeTester
|
||||
@@ -55,6 +51,7 @@ namespace Netch.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private new void OnOutputDataReceived(object sender, DataReceivedEventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(e.Data)) return;
|
||||
|
||||
@@ -3,15 +3,17 @@ using Netch.Models;
|
||||
|
||||
namespace Netch.Controllers
|
||||
{
|
||||
public class PrivoxyController : Controller
|
||||
public class PrivoxyController : Guard, IController
|
||||
{
|
||||
public PrivoxyController()
|
||||
{
|
||||
Name = "Privoxy";
|
||||
MainFile = "Privoxy.exe";
|
||||
RedirectStd = false;
|
||||
}
|
||||
|
||||
public override string Name { get; protected set; } = "Privoxy";
|
||||
|
||||
public override string MainFile { get; protected set; } = "Privoxy.exe";
|
||||
|
||||
public bool Start(Server server, Mode mode)
|
||||
{
|
||||
var text = File.ReadAllText("bin\\default.conf")
|
||||
|
||||
@@ -14,9 +14,9 @@ using Netch.Utils;
|
||||
|
||||
namespace Netch.Controllers
|
||||
{
|
||||
public class TUNTAPController : ModeController
|
||||
public class TUNTAPController : Guard, IModeController
|
||||
{
|
||||
public override bool TestNatRequired { get; } = true;
|
||||
public bool TestNatRequired { get; } = true;
|
||||
|
||||
// ByPassLan IP
|
||||
private readonly List<string> _bypassLanIPs = new List<string>
|
||||
@@ -28,57 +28,111 @@ namespace Netch.Controllers
|
||||
/// <summary>
|
||||
/// 服务器 IP 地址
|
||||
/// </summary>
|
||||
private IPAddress[] _serverAddresses = new IPAddress[0];
|
||||
private IPAddress _serverAddresses;
|
||||
|
||||
/// <summary>
|
||||
/// 本地 DNS 服务控制器
|
||||
/// </summary>
|
||||
public DNSController pDNSController = new DNSController();
|
||||
public DNSController DNSController = new DNSController();
|
||||
|
||||
public TUNTAPController()
|
||||
{
|
||||
Name = "tun2socks";
|
||||
MainFile = "tun2socks.exe";
|
||||
StartedKeywords.Add("Running");
|
||||
StoppedKeywords.AddRange(new[] {"failed", "invalid vconfig file"});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 配置 TUNTAP 适配器
|
||||
/// </summary>
|
||||
private bool Configure()
|
||||
{
|
||||
// 查询服务器 IP 地址
|
||||
var destination = Dns.GetHostAddressesAsync(_savedServer.Hostname);
|
||||
if (destination.Wait(1000))
|
||||
{
|
||||
if (destination.Result.Length == 0) return false;
|
||||
public override string Name { get; protected set; } = "tun2socks";
|
||||
public override string MainFile { get; protected set; } = "tun2socks.exe";
|
||||
|
||||
_serverAddresses = destination.Result;
|
||||
public bool Start(Server s, Mode mode)
|
||||
{
|
||||
_savedMode = mode;
|
||||
_savedServer = s;
|
||||
|
||||
// 查询服务器 IP 地址
|
||||
_serverAddresses = DNS.Lookup(_savedServer.Hostname);
|
||||
|
||||
// 查找出口适配器
|
||||
if (!Utils.Utils.SearchOutboundAdapter())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// 搜索出口
|
||||
return SearchTapAdapter();
|
||||
// 查找并安装 TAP 适配器
|
||||
if (!SearchTapAdapter() && !AddTap())
|
||||
{
|
||||
Logging.Error("Tap 适配器安装失败");
|
||||
return false;
|
||||
}
|
||||
|
||||
SetupRouteTable();
|
||||
|
||||
string dns;
|
||||
if (Global.Settings.TUNTAP.UseCustomDNS)
|
||||
{
|
||||
if (Global.Settings.TUNTAP.DNS.Any())
|
||||
{
|
||||
dns = Global.Settings.TUNTAP.DNS.Aggregate((current, ip) => $"{current},{ip}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Global.Settings.TUNTAP.DNS.Add("1.1.1.1");
|
||||
dns = "1.1.1.1";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var _ = DNSController.Start();
|
||||
dns = "127.0.0.1";
|
||||
}
|
||||
|
||||
var argument = new StringBuilder();
|
||||
if (s.IsSocks5())
|
||||
argument.Append($"-proxyServer {_serverAddresses}:{s.Port} ");
|
||||
else
|
||||
argument.Append($"-proxyServer 127.0.0.1:{Global.Settings.Socks5LocalPort} ");
|
||||
|
||||
argument.Append(
|
||||
$"-tunAddr {Global.Settings.TUNTAP.Address} -tunMask {Global.Settings.TUNTAP.Netmask} -tunGw {Global.Settings.TUNTAP.Gateway} -tunDns {dns} -tunName \"{TUNTAP.GetName(Global.TUNTAP.ComponentID)}\" ");
|
||||
|
||||
if (Global.Settings.TUNTAP.UseFakeDNS && Global.Flags.SupportFakeDns)
|
||||
argument.Append("-fakeDns ");
|
||||
|
||||
return StartInstanceAuto(argument.ToString(), ProcessPriorityClass.RealTime);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// TUN/TAP停止
|
||||
/// </summary>
|
||||
public override void Stop()
|
||||
{
|
||||
var tasks = new[]
|
||||
{
|
||||
Task.Factory.StartNew(StopInstance),
|
||||
Task.Factory.StartNew(ClearRouteTable),
|
||||
Task.Factory.StartNew(DNSController.Stop)
|
||||
};
|
||||
Task.WaitAll(tasks);
|
||||
}
|
||||
|
||||
private readonly List<IPNetwork> _directIPs = new List<IPNetwork>();
|
||||
|
||||
private readonly List<IPNetwork> _proxyIPs = new List<IPNetwork>();
|
||||
|
||||
/// <summary>
|
||||
/// 设置绕行规则
|
||||
/// </summary>
|
||||
/// <returns>是否设置成功</returns>
|
||||
private bool SetupRouteTable()
|
||||
private void SetupRouteTable()
|
||||
{
|
||||
Logging.Info("收集路由表规则");
|
||||
Global.MainForm.StatusText(i18N.Translate("SetupBypass"));
|
||||
|
||||
Logging.Info("绕行 → 全局绕过 IP");
|
||||
_directIPs.AddRange(Global.Settings.BypassIPs.Select(IPNetwork.Parse));
|
||||
|
||||
Logging.Info("绕行 → 服务器 IP");
|
||||
_directIPs.AddRange(_serverAddresses.Where(address => !IPAddress.IsLoopback(address))
|
||||
.Select(address => IPNetwork.Parse(address.ToString(), 32)));
|
||||
if (!IPAddress.IsLoopback(_serverAddresses))
|
||||
_directIPs.Add(IPNetwork.Parse(_serverAddresses.ToString(), 32));
|
||||
|
||||
Logging.Info("绕行 → 局域网 IP");
|
||||
_directIPs.AddRange(_bypassLanIPs.Select(IPNetwork.Parse));
|
||||
@@ -111,22 +165,11 @@ namespace Netch.Controllers
|
||||
Logging.Info("代理 → 自定义 DNS");
|
||||
if (Global.Settings.TUNTAP.UseCustomDNS)
|
||||
{
|
||||
var dns = string.Empty;
|
||||
foreach (var value in Global.Settings.TUNTAP.DNS)
|
||||
{
|
||||
dns += value;
|
||||
dns += ',';
|
||||
}
|
||||
|
||||
dns = dns.Trim();
|
||||
dns = dns.Substring(0, dns.Length - 1);
|
||||
RouteAction(Action.Create, dns, 32, RouteType.TUNTAP);
|
||||
_proxyIPs.AddRange(Global.Settings.TUNTAP.DNS.Select(ip => IPNetwork.Parse(ip, 32)));
|
||||
}
|
||||
else
|
||||
{
|
||||
_proxyIPs.AddRange(
|
||||
new[] {"1.1.1.1", "8.8.8.8", "9.9.9.9", "185.222.222.222"}.Select(ip =>
|
||||
IPNetwork.Parse(ip, 32)));
|
||||
_proxyIPs.AddRange(new[] {"1.1.1.1", "8.8.8.8", "9.9.9.9", "185.222.222.222"}.Select(ip => IPNetwork.Parse(ip, 32)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,37 +188,21 @@ namespace Netch.Controllers
|
||||
}
|
||||
);
|
||||
|
||||
if (_savedMode.BypassChina)
|
||||
{
|
||||
Logging.Info("绕行 → 中国 IP");
|
||||
|
||||
foreach (var str in File.ReadAllLines("bin\\china_ip_list", Encoding.UTF8))
|
||||
{
|
||||
if (IPNetwork.TryParse(str, out var entry))
|
||||
{
|
||||
_directIPs.Add(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Logging.Info("绕行 → 规则 IP");
|
||||
_directIPs.AddRange(_savedMode.Rule.Select(IPNetwork.Parse));
|
||||
|
||||
Logging.Info("代理 → 全局");
|
||||
if (!RouteAction(Action.Create, IPNetwork.Parse("0.0.0.0", 0), RouteType.TUNTAP))
|
||||
{
|
||||
State = State.Stopped;
|
||||
return false;
|
||||
}
|
||||
RouteAction(Action.Create, IPNetwork.Parse("0.0.0.0", 0), RouteType.TUNTAP);
|
||||
|
||||
Logging.Info("移除 → 出口网卡路由");
|
||||
RouteAction(Action.Delete, IPNetwork.Parse("0.0.0.0", 0), RouteType.Outbound);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
Logging.Info("设置路由规则");
|
||||
RouteAction(Action.Create, _directIPs, RouteType.Gateway);
|
||||
RouteAction(Action.Create, _directIPs, RouteType.Outbound);
|
||||
RouteAction(Action.Create, _proxyIPs, RouteType.TUNTAP);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -189,75 +216,18 @@ namespace Netch.Controllers
|
||||
case 1:
|
||||
break;
|
||||
case 2:
|
||||
RouteAction(Action.Delete, "0.0.0.0", 0, RouteType.TUNTAP, 10);
|
||||
RouteAction(Action.Delete, IPNetwork.Parse("0.0.0.0", 0), RouteType.TUNTAP);
|
||||
RouteAction(Action.Create, IPNetwork.Parse("0.0.0.0", 0), RouteType.Outbound);
|
||||
break;
|
||||
}
|
||||
|
||||
RouteAction(Action.Delete, _directIPs, RouteType.Gateway);
|
||||
RouteAction(Action.Delete, _directIPs, RouteType.Outbound);
|
||||
RouteAction(Action.Delete, _proxyIPs, RouteType.TUNTAP);
|
||||
_directIPs.Clear();
|
||||
_proxyIPs.Clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Start(Server s, Mode mode)
|
||||
{
|
||||
_savedMode = mode;
|
||||
_savedServer = s;
|
||||
|
||||
if (!Configure()) return false;
|
||||
|
||||
SetupRouteTable();
|
||||
|
||||
var adapterName = TUNTAP.GetName(Global.TUNTAP.ComponentID);
|
||||
|
||||
string dns;
|
||||
if (Global.Settings.TUNTAP.UseCustomDNS)
|
||||
{
|
||||
if (Global.Settings.TUNTAP.DNS.Any())
|
||||
{
|
||||
dns = Global.Settings.TUNTAP.DNS.Aggregate((current, ip) => $"{current},{ip}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Global.Settings.TUNTAP.DNS.Add("1.1.1.1");
|
||||
dns = "1.1.1.1";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var _ = pDNSController.Start();
|
||||
dns = "127.0.0.1";
|
||||
}
|
||||
|
||||
var argument = new StringBuilder();
|
||||
if (s.IsSocks5())
|
||||
argument.Append($"-proxyServer {s.Hostname}:{s.Port} ");
|
||||
else
|
||||
argument.Append($"-proxyServer 127.0.0.1:{Global.Settings.Socks5LocalPort} ");
|
||||
|
||||
argument.Append(
|
||||
$"-tunAddr {Global.Settings.TUNTAP.Address} -tunMask {Global.Settings.TUNTAP.Netmask} -tunGw {Global.Settings.TUNTAP.Gateway} -tunDns {dns} -tunName \"{adapterName}\" ");
|
||||
|
||||
if (Global.Settings.TUNTAP.UseFakeDNS && Global.Flags.SupportFakeDns)
|
||||
argument.Append("-fakeDns ");
|
||||
|
||||
return StartInstanceAuto(argument.ToString(), ProcessPriorityClass.RealTime);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// TUN/TAP停止
|
||||
/// </summary>
|
||||
public override void Stop()
|
||||
{
|
||||
var tasks = new[]
|
||||
{
|
||||
Task.Factory.StartNew(StopInstance),
|
||||
Task.Factory.StartNew(ClearRouteTable),
|
||||
Task.Factory.StartNew(pDNSController.Stop)
|
||||
};
|
||||
Task.WaitAll(tasks);
|
||||
}
|
||||
|
||||
public bool TestFakeDNS()
|
||||
{
|
||||
@@ -265,15 +235,17 @@ namespace Netch.Controllers
|
||||
var helpStr = new StringBuilder();
|
||||
try
|
||||
{
|
||||
void OnOutputDataReceived(object sender,DataReceivedEventArgs e)
|
||||
void OnOutputDataReceived(object sender, DataReceivedEventArgs e)
|
||||
{
|
||||
if (e.Data == null)
|
||||
{
|
||||
exited = true;
|
||||
return;
|
||||
}
|
||||
|
||||
helpStr.Append(e.Data);
|
||||
}
|
||||
|
||||
InitInstance("-h");
|
||||
// Instance.OutputDataReceived += OnOutputDataReceived;
|
||||
Instance.ErrorDataReceived += OnOutputDataReceived;
|
||||
@@ -298,27 +270,15 @@ namespace Netch.Controllers
|
||||
/// </summary>
|
||||
public static bool SearchTapAdapter()
|
||||
{
|
||||
Global.TUNTAP.Adapter = null;
|
||||
Global.TUNTAP.Index = -1;
|
||||
Global.TUNTAP.ComponentID = TUNTAP.GetComponentID();
|
||||
|
||||
// 搜索 TUN/TAP 适配器的索引
|
||||
if (string.IsNullOrEmpty(Global.TUNTAP.ComponentID = TUNTAP.GetComponentID()))
|
||||
if (string.IsNullOrEmpty(Global.TUNTAP.ComponentID))
|
||||
{
|
||||
Logging.Info("找不到 TAP 适配器");
|
||||
if (MessageBoxX.Show(i18N.Translate("TUN/TAP driver is not detected. Is it installed now?"),
|
||||
confirm: true) == DialogResult.OK)
|
||||
{
|
||||
TUNTAP.addtap();
|
||||
// 给点时间,不然立马安装完毕就查找适配器可能会导致找不到适配器ID
|
||||
Thread.Sleep(1000);
|
||||
if (string.IsNullOrEmpty(Global.TUNTAP.ComponentID = TUNTAP.GetComponentID()))
|
||||
{
|
||||
Logging.Error("找不到 TAP 适配器,驱动可能安装失败");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Logging.Info("取消安装 TAP 驱动 ");
|
||||
return false;
|
||||
}
|
||||
Logging.Info("TAP 适配器未安装");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 根据 ComponentID 寻找 Tap适配器
|
||||
@@ -329,6 +289,7 @@ namespace Netch.Controllers
|
||||
Global.TUNTAP.Index = adapter.GetIPProperties().GetIPv4Properties().Index;
|
||||
Logging.Info(
|
||||
$"TAP 适配器:{adapter.Name} {adapter.Id} {adapter.Description}, index: {Global.TUNTAP.Index}");
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -341,6 +302,18 @@ namespace Netch.Controllers
|
||||
Logging.Error(msg);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool AddTap()
|
||||
{
|
||||
TUNTAP.addtap();
|
||||
// 给点时间,不然立马安装完毕就查找适配器可能会导致找不到适配器ID
|
||||
Thread.Sleep(1000);
|
||||
if (string.IsNullOrEmpty(Global.TUNTAP.ComponentID = TUNTAP.GetComponentID()))
|
||||
{
|
||||
Logging.Error("找不到 TAP 适配器,驱动可能安装失败");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -348,7 +321,7 @@ namespace Netch.Controllers
|
||||
|
||||
private enum RouteType
|
||||
{
|
||||
Gateway,
|
||||
Outbound,
|
||||
TUNTAP
|
||||
}
|
||||
|
||||
@@ -367,18 +340,13 @@ namespace Netch.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
private static bool RouteAction(Action action, string address, byte cidr, RouteType routeType, int metric = 0)
|
||||
{
|
||||
return RouteAction(action, IPNetwork.Parse(address, cidr), routeType, metric);
|
||||
}
|
||||
|
||||
private static bool RouteAction(Action action, IPNetwork ipNetwork, RouteType routeType, int metric = 0)
|
||||
{
|
||||
string gateway;
|
||||
int index;
|
||||
switch (routeType)
|
||||
{
|
||||
case RouteType.Gateway:
|
||||
case RouteType.Outbound:
|
||||
gateway = Global.Outbound.Gateway.ToString();
|
||||
index = Global.Outbound.Index;
|
||||
break;
|
||||
@@ -401,7 +369,7 @@ namespace Netch.Controllers
|
||||
|
||||
if (!result)
|
||||
{
|
||||
Logging.Warning($"{action} Route on {routeType} Adapter failed: {ipNetwork} metric {metric}");
|
||||
Logging.Warning($"Failed to {action} Route on {routeType} Adapter: {ipNetwork} metric {metric}");
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -15,8 +15,8 @@ namespace Netch.Controllers
|
||||
public const string Name = @"Netch";
|
||||
public const string Copyright = @"Copyright © 2019 - 2020";
|
||||
|
||||
public const string AssemblyVersion = @"1.6.0";
|
||||
private const string Suffix = @"Beta1";
|
||||
public const string AssemblyVersion = @"1.6.1";
|
||||
private const string Suffix = @"";
|
||||
|
||||
public static readonly string Version = $"{AssemblyVersion}{(string.IsNullOrEmpty(Suffix) ? "" : $"-{Suffix}")}";
|
||||
|
||||
|
||||
16
Netch/Forms/MainForm.Designer.cs
generated
16
Netch/Forms/MainForm.Designer.cs
generated
@@ -45,7 +45,7 @@
|
||||
this.UpdateACLToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.updateACLWithProxyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.UninstallServiceToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.reinstallTapDriverToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.UninstallTapDriverToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.HelpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.CheckForUpdatesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.fAQToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
@@ -193,7 +193,7 @@
|
||||
this.UpdateACLToolStripMenuItem,
|
||||
this.updateACLWithProxyToolStripMenuItem,
|
||||
this.UninstallServiceToolStripMenuItem,
|
||||
this.reinstallTapDriverToolStripMenuItem});
|
||||
this.UninstallTapDriverToolStripMenuItem});
|
||||
this.OptionsToolStripMenuItem.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
|
||||
this.OptionsToolStripMenuItem.Name = "OptionsToolStripMenuItem";
|
||||
this.OptionsToolStripMenuItem.Size = new System.Drawing.Size(66, 21);
|
||||
@@ -234,12 +234,12 @@
|
||||
this.UninstallServiceToolStripMenuItem.Text = "Uninstall NF Service";
|
||||
this.UninstallServiceToolStripMenuItem.Click += new System.EventHandler(this.UninstallServiceToolStripMenuItem_Click);
|
||||
//
|
||||
// reinstallTapDriverToolStripMenuItem
|
||||
// UninstallTapDriverToolStripMenuItem
|
||||
//
|
||||
this.reinstallTapDriverToolStripMenuItem.Name = "reinstallTapDriverToolStripMenuItem";
|
||||
this.reinstallTapDriverToolStripMenuItem.Size = new System.Drawing.Size(219, 22);
|
||||
this.reinstallTapDriverToolStripMenuItem.Text = "Reinstall TUN/TAP driver";
|
||||
this.reinstallTapDriverToolStripMenuItem.Click += new System.EventHandler(this.reinstallTapDriverToolStripMenuItem_Click);
|
||||
this.UninstallTapDriverToolStripMenuItem.Name = "UninstallTapDriverToolStripMenuItem";
|
||||
this.UninstallTapDriverToolStripMenuItem.Size = new System.Drawing.Size(219, 22);
|
||||
this.UninstallTapDriverToolStripMenuItem.Text = "Uninstall TUN/TAP driver";
|
||||
this.UninstallTapDriverToolStripMenuItem.Click += new System.EventHandler(this.reinstallTapDriverToolStripMenuItem_Click);
|
||||
//
|
||||
// HelpToolStripMenuItem
|
||||
//
|
||||
@@ -735,7 +735,7 @@
|
||||
private System.Windows.Forms.Label ProfileLabel;
|
||||
private System.Windows.Forms.TextBox ProfileNameText;
|
||||
private System.Windows.Forms.TableLayoutPanel ProfileTable;
|
||||
private System.Windows.Forms.ToolStripMenuItem reinstallTapDriverToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem UninstallTapDriverToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem CheckForUpdatesToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem ReloadModesToolStripMenuItem;
|
||||
private System.Windows.Forms.ComboBox ServerComboBox;
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace Netch.Forms
|
||||
var result = s.Substring(start, end - start);
|
||||
|
||||
Hide();
|
||||
Servers.GetUtilByFullName(result).Create();
|
||||
ServerHelper.GetUtilByFullName(result).Create();
|
||||
|
||||
InitServer();
|
||||
Configuration.Save();
|
||||
@@ -77,7 +77,7 @@ namespace Netch.Forms
|
||||
Enabled = false;
|
||||
try
|
||||
{
|
||||
Modes.Load();
|
||||
ModeHelper.Load();
|
||||
InitMode();
|
||||
NotifyTip(i18N.Translate("Modes have been reload"));
|
||||
}
|
||||
@@ -315,14 +315,14 @@ namespace Netch.Forms
|
||||
private async void UninstallServiceToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Enabled = false;
|
||||
StatusText(i18N.Translate("Uninstalling NF Service"));
|
||||
StatusText(i18N.TranslateFormat("Uninstalling {0}", "NF Service"));
|
||||
try
|
||||
{
|
||||
await Task.Run(() =>
|
||||
{
|
||||
if (NFController.UninstallDriver())
|
||||
{
|
||||
StatusText(i18N.Translate("Service has been uninstalled"));
|
||||
StatusText(i18N.TranslateFormat("{0} has been uninstalled", "NF Service"));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -334,20 +334,16 @@ namespace Netch.Forms
|
||||
|
||||
private async void reinstallTapDriverToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
StatusText(i18N.Translate("Reinstalling TUN/TAP driver"));
|
||||
StatusText(i18N.TranslateFormat("Uninstalling {0}", "TUN/TAP driver"));
|
||||
Enabled = false;
|
||||
try
|
||||
{
|
||||
await Task.Run(() =>
|
||||
{
|
||||
TUNTAP.deltapall();
|
||||
TUNTAP.addtap();
|
||||
});
|
||||
StatusText(i18N.Translate("Reinstall TUN/TAP driver successfully"));
|
||||
await Task.Run(TUNTAP.deltapall);
|
||||
StatusText(i18N.TranslateFormat("{0} has been uninstalled", "TUN/TAP driver"));
|
||||
}
|
||||
catch
|
||||
catch (Exception exception)
|
||||
{
|
||||
NotifyTip(i18N.Translate("Reinstall TUN/TAP driver failed"), info: false);
|
||||
Logging.Error($"卸载 TUN/TAP 适配器失败: {exception}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
@@ -167,6 +167,9 @@ namespace Netch.Forms
|
||||
return;
|
||||
}
|
||||
|
||||
// Reset Mode ComboBox Items
|
||||
ModeComboBox.Text = string.Empty;
|
||||
|
||||
try
|
||||
{
|
||||
LoadProfile(index);
|
||||
|
||||
@@ -157,7 +157,7 @@ namespace Netch.Forms
|
||||
|
||||
private void AddAddServerToolStripMenuItems()
|
||||
{
|
||||
foreach (var serversUtil in Servers.ServerUtils.Where(i => !string.IsNullOrEmpty(i.FullName)))
|
||||
foreach (var serversUtil in ServerHelper.ServerUtils.Where(i => !string.IsNullOrEmpty(i.FullName)))
|
||||
{
|
||||
var fullName = serversUtil.FullName;
|
||||
var control = new ToolStripMenuItem
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Netch.Forms
|
||||
UninstallServiceToolStripMenuItem.Enabled =
|
||||
updateACLWithProxyToolStripMenuItem.Enabled =
|
||||
UpdateServersFromSubscribeLinksToolStripMenuItem.Enabled =
|
||||
reinstallTapDriverToolStripMenuItem.Enabled =
|
||||
UninstallTapDriverToolStripMenuItem.Enabled =
|
||||
ReloadModesToolStripMenuItem.Enabled = enabled;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,11 +41,18 @@ namespace Netch.Forms
|
||||
{
|
||||
AddAddServerToolStripMenuItems();
|
||||
|
||||
#region i18N Translations
|
||||
|
||||
_mainFormText.Add(UninstallServiceToolStripMenuItem.Name, new[] {"Uninstall {0}", "NF Service"});
|
||||
_mainFormText.Add(UninstallTapDriverToolStripMenuItem.Name, new[] {"Uninstall {0}", "TUN/TAP driver"});
|
||||
|
||||
#endregion
|
||||
|
||||
OnlyInstance.Called += OnCalled;
|
||||
// 计算 ComboBox绘制 目标宽度
|
||||
_eWidth = ServerComboBox.Width / 10;
|
||||
|
||||
Modes.Load();
|
||||
ModeHelper.Load();
|
||||
InitMode();
|
||||
InitServer();
|
||||
_comboBoxInitialized = true;
|
||||
@@ -168,6 +175,7 @@ namespace Netch.Forms
|
||||
{
|
||||
i18N.Load(Global.Settings.Language);
|
||||
InitText();
|
||||
InitMode();
|
||||
InitProfile();
|
||||
}
|
||||
|
||||
@@ -226,11 +234,12 @@ namespace Netch.Forms
|
||||
case ListControl _:
|
||||
break;
|
||||
case Control c:
|
||||
|
||||
c.Text = ControlText(c.Name);
|
||||
if (_mainFormText.ContainsKey(c.Name))
|
||||
c.Text = ControlText(c.Name);
|
||||
break;
|
||||
case ToolStripItem c:
|
||||
c.Text = ControlText(c.Name);
|
||||
if (_mainFormText.ContainsKey(c.Name))
|
||||
c.Text = ControlText(c.Name);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -314,7 +323,7 @@ namespace Netch.Forms
|
||||
|
||||
Hide();
|
||||
var server = Global.Settings.Server[ServerComboBox.SelectedIndex];
|
||||
Servers.GetUtilByTypeName(server.Type).Edit(server);
|
||||
ServerHelper.GetUtilByTypeName(server.Type).Edit(server);
|
||||
InitServer();
|
||||
Configuration.Save();
|
||||
Show();
|
||||
@@ -372,7 +381,7 @@ namespace Netch.Forms
|
||||
return;
|
||||
}
|
||||
|
||||
Modes.Delete((Models.Mode) ModeComboBox.SelectedItem);
|
||||
ModeHelper.Delete((Models.Mode) ModeComboBox.SelectedItem);
|
||||
SelectLastMode();
|
||||
}
|
||||
|
||||
|
||||
@@ -207,14 +207,14 @@ namespace Netch.Forms.Mode
|
||||
_mode.Rule.Clear();
|
||||
_mode.Rule.AddRange(RuleListBox.Items.Cast<string>());
|
||||
|
||||
Modes.WriteFile(_mode);
|
||||
ModeHelper.WriteFile(_mode);
|
||||
Global.MainForm.InitMode();
|
||||
Edited = false;
|
||||
MessageBoxX.Show(i18N.Translate("Mode updated successfully"));
|
||||
}
|
||||
else
|
||||
{
|
||||
var fullName = Modes.GetFullPath(FilenameTextBox.Text + ".txt");
|
||||
var fullName = ModeHelper.GetFullPath(FilenameTextBox.Text + ".txt");
|
||||
if (File.Exists(fullName))
|
||||
{
|
||||
MessageBoxX.Show(i18N.Translate("File already exists.\n Please Change the filename"));
|
||||
@@ -230,8 +230,8 @@ namespace Netch.Forms.Mode
|
||||
};
|
||||
mode.Rule.AddRange(RuleListBox.Items.Cast<string>());
|
||||
|
||||
Modes.WriteFile(mode);
|
||||
Modes.Add(mode);
|
||||
ModeHelper.WriteFile(mode);
|
||||
ModeHelper.Add(mode);
|
||||
MessageBoxX.Show(i18N.Translate("Mode added successfully"));
|
||||
}
|
||||
|
||||
|
||||
316
Netch/Forms/ServerForm.cs
Normal file
316
Netch/Forms/ServerForm.cs
Normal file
@@ -0,0 +1,316 @@
|
||||
using System.ComponentModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using Netch.Models;
|
||||
using Netch.Properties;
|
||||
using Netch.Utils;
|
||||
|
||||
namespace Netch.Forms
|
||||
{
|
||||
public abstract class ServerForm : Form
|
||||
{
|
||||
protected abstract string TypeName { get; }
|
||||
protected Server Server { get; set; }
|
||||
|
||||
private int _controlLines = 2;
|
||||
|
||||
private const int ControlLineHeight = 28;
|
||||
private const int InputBoxWidth = 294;
|
||||
|
||||
protected ServerForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_checkActions.Add(RemarkTextBox, s => true);
|
||||
_saveActions.Add(RemarkTextBox, s => Server.Remark = (string) s);
|
||||
|
||||
_checkActions.Add(AddressTextBox, s => s != string.Empty);
|
||||
_saveActions.Add(AddressTextBox, s => Server.Hostname = (string) s);
|
||||
|
||||
_checkActions.Add(PortTextBox, s => ushort.TryParse(s, out var port) && port != 0);
|
||||
_saveActions.Add(PortTextBox, s => Server.Port = ushort.Parse((string) s));
|
||||
}
|
||||
|
||||
public new void ShowDialog()
|
||||
{
|
||||
AfterFactor();
|
||||
base.ShowDialog();
|
||||
}
|
||||
|
||||
public new void Show()
|
||||
{
|
||||
AfterFactor();
|
||||
base.Show();
|
||||
}
|
||||
|
||||
private void AfterFactor()
|
||||
{
|
||||
Text = TypeName ?? string.Empty;
|
||||
|
||||
RemarkTextBox.Text = Server.Remark;
|
||||
AddressTextBox.Text = Server.Hostname;
|
||||
PortTextBox.Text = Server.Port.ToString();
|
||||
|
||||
AddSaveButton();
|
||||
i18N.TranslateForm(this);
|
||||
|
||||
ConfigurationGroupBox.ResumeLayout(false);
|
||||
ConfigurationGroupBox.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
protected void CreateTextBox(string name, string remark, Func<string, bool> check, Action<string> save, string value, int width = InputBoxWidth)
|
||||
{
|
||||
_controlLines++;
|
||||
|
||||
var textBox = new TextBox
|
||||
{
|
||||
Location = new Point(120, ControlLineHeight * _controlLines),
|
||||
Name = $"{name}TextBox",
|
||||
Size = new Size(width, 23),
|
||||
TextAlign = HorizontalAlignment.Center,
|
||||
Text = value
|
||||
};
|
||||
_checkActions.Add(textBox, check);
|
||||
_saveActions.Add(textBox, o => save.Invoke((string) o));
|
||||
ConfigurationGroupBox.Controls.AddRange(
|
||||
new Control[]
|
||||
{
|
||||
textBox,
|
||||
new Label
|
||||
{
|
||||
AutoSize = true,
|
||||
Location = new Point(10, ControlLineHeight * _controlLines),
|
||||
Name = $"{name}Label",
|
||||
Size = new Size(56, 17),
|
||||
Text = remark
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
protected void CreateComboBox(string name, string remark, List<string> values, Action<string> save, string value, int width = InputBoxWidth)
|
||||
{
|
||||
_controlLines++;
|
||||
|
||||
var comboBox = new ComboBox
|
||||
{
|
||||
Location = new Point(120, ControlLineHeight * _controlLines),
|
||||
Name = $"{name}ComboBox",
|
||||
Size = new Size(width, 23),
|
||||
DrawMode = DrawMode.OwnerDrawFixed,
|
||||
DropDownStyle = ComboBoxStyle.DropDownList,
|
||||
FormattingEnabled = true
|
||||
};
|
||||
comboBox.Items.AddRange(values.ToArray());
|
||||
comboBox.SelectedIndex = values.IndexOf(value);
|
||||
comboBox.DrawItem += Utils.Utils.DrawCenterComboBox;
|
||||
_saveActions.Add(comboBox, o => save.Invoke((string) o));
|
||||
ConfigurationGroupBox.Controls.AddRange(
|
||||
new Control[]
|
||||
{
|
||||
comboBox,
|
||||
new Label
|
||||
{
|
||||
AutoSize = true,
|
||||
Location = new Point(10, ControlLineHeight * _controlLines),
|
||||
Name = $"{name}Label",
|
||||
Size = new Size(56, 17),
|
||||
Text = remark
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
protected void CreateCheckBox(string name, string remark, Action<bool> save, bool value)
|
||||
{
|
||||
_controlLines++;
|
||||
|
||||
var checkBox = new CheckBox
|
||||
{
|
||||
AutoSize = true,
|
||||
Location = new Point(120, ControlLineHeight * _controlLines),
|
||||
Name = $"{name}CheckBox",
|
||||
Checked = value,
|
||||
Text = remark
|
||||
};
|
||||
_saveActions.Add(checkBox, o => save.Invoke((bool) o));
|
||||
ConfigurationGroupBox.Controls.AddRange(
|
||||
new Control[]
|
||||
{
|
||||
checkBox
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private readonly Dictionary<Control, Func<string, bool>> _checkActions = new Dictionary<Control, Func<string, bool>>();
|
||||
|
||||
private readonly Dictionary<Control, Action<object>> _saveActions = new Dictionary<Control, Action<object>>();
|
||||
|
||||
private void AddSaveButton()
|
||||
{
|
||||
_controlLines++;
|
||||
var control = new Button
|
||||
{
|
||||
Location = new Point(340, _controlLines * ControlLineHeight + 10),
|
||||
Name = "ControlButton",
|
||||
Size = new Size(75, 23),
|
||||
Text = "Save",
|
||||
UseVisualStyleBackColor = true
|
||||
};
|
||||
control.Click += ControlButton_Click;
|
||||
ConfigurationGroupBox.Controls.Add(control);
|
||||
}
|
||||
|
||||
private void ControlButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_checkActions.All(pair => pair.Value.Invoke(pair.Key.Text)))
|
||||
{
|
||||
foreach (var pair in _saveActions)
|
||||
{
|
||||
switch (pair.Key)
|
||||
{
|
||||
case CheckBox c:
|
||||
pair.Value.Invoke(c.Checked);
|
||||
break;
|
||||
default:
|
||||
pair.Value.Invoke(pair.Key.Text);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (Global.Settings.Server.IndexOf(Server) == -1)
|
||||
Global.Settings.Server.Add(Server);
|
||||
|
||||
MessageBoxX.Show(i18N.Translate("Saved"));
|
||||
}
|
||||
else
|
||||
return;
|
||||
|
||||
Close();
|
||||
}
|
||||
|
||||
private IContainer components = null;
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
components?.Dispose();
|
||||
}
|
||||
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
ConfigurationGroupBox = new GroupBox();
|
||||
AddressLabel = new Label();
|
||||
PortTextBox = new TextBox();
|
||||
AddressTextBox = new TextBox();
|
||||
RemarkTextBox = new TextBox();
|
||||
RemarkLabel = new Label();
|
||||
PortLabel = new Label();
|
||||
ConfigurationGroupBox.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// ConfigurationGroupBox
|
||||
//
|
||||
ConfigurationGroupBox.AutoSize = true;
|
||||
ConfigurationGroupBox.AutoSizeMode = AutoSizeMode.GrowAndShrink;
|
||||
ConfigurationGroupBox.Controls.Add(AddressLabel);
|
||||
ConfigurationGroupBox.Controls.Add(PortTextBox);
|
||||
ConfigurationGroupBox.Controls.Add(AddressTextBox);
|
||||
ConfigurationGroupBox.Controls.Add(RemarkTextBox);
|
||||
ConfigurationGroupBox.Controls.Add(RemarkLabel);
|
||||
ConfigurationGroupBox.Controls.Add(PortLabel);
|
||||
ConfigurationGroupBox.Dock = DockStyle.Fill;
|
||||
ConfigurationGroupBox.Location = new Point(5, 5);
|
||||
ConfigurationGroupBox.Name = "ConfigurationGroupBox";
|
||||
ConfigurationGroupBox.Size = new Size(434, 127);
|
||||
ConfigurationGroupBox.TabIndex = 0;
|
||||
ConfigurationGroupBox.TabStop = false;
|
||||
ConfigurationGroupBox.Text = "Configuration";
|
||||
//
|
||||
// AddressLabel
|
||||
//
|
||||
AddressLabel.AutoSize = true;
|
||||
AddressLabel.Location = new Point(10, ControlLineHeight * 2);
|
||||
AddressLabel.Name = "AddressLabel";
|
||||
AddressLabel.Size = new Size(56, 17);
|
||||
AddressLabel.TabIndex = 2;
|
||||
AddressLabel.Text = "Address";
|
||||
//
|
||||
// PortTextBox
|
||||
//
|
||||
PortTextBox.Location = new Point(358, ControlLineHeight * 2);
|
||||
PortTextBox.Name = "PortTextBox";
|
||||
PortTextBox.Size = new Size(56, 23);
|
||||
PortTextBox.TabIndex = 5;
|
||||
PortTextBox.TextAlign = HorizontalAlignment.Center;
|
||||
//
|
||||
// AddressTextBox
|
||||
//
|
||||
AddressTextBox.Location = new Point(120, ControlLineHeight * 2);
|
||||
AddressTextBox.Name = "AddressTextBox";
|
||||
AddressTextBox.Size = new Size(232, 23);
|
||||
AddressTextBox.TabIndex = 3;
|
||||
AddressTextBox.TextAlign = HorizontalAlignment.Center;
|
||||
//
|
||||
// RemarkTextBox
|
||||
//
|
||||
RemarkTextBox.Location = new Point(120, ControlLineHeight);
|
||||
RemarkTextBox.Name = "RemarkTextBox";
|
||||
RemarkTextBox.Size = new Size(294, 23);
|
||||
RemarkTextBox.TabIndex = 1;
|
||||
RemarkTextBox.TextAlign = HorizontalAlignment.Center;
|
||||
//
|
||||
// RemarkLabel
|
||||
//
|
||||
RemarkLabel.AutoSize = true;
|
||||
RemarkLabel.Location = new Point(10, ControlLineHeight);
|
||||
RemarkLabel.Name = "RemarkLabel";
|
||||
RemarkLabel.Size = new Size(53, 17);
|
||||
RemarkLabel.TabIndex = 0;
|
||||
RemarkLabel.Text = "Remark";
|
||||
//
|
||||
// PortLabel
|
||||
//
|
||||
PortLabel.AutoSize = true;
|
||||
PortLabel.Location = new Point(351, ControlLineHeight * 2);
|
||||
PortLabel.Name = "PortLabel";
|
||||
PortLabel.Size = new Size(11, 17);
|
||||
PortLabel.TabIndex = 4;
|
||||
PortLabel.Text = ":";
|
||||
//
|
||||
// ServerForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(96F, 96F);
|
||||
AutoScaleMode = AutoScaleMode.Dpi;
|
||||
AutoSize = true;
|
||||
AutoSizeMode = AutoSizeMode.GrowAndShrink;
|
||||
ClientSize = new Size(444, 137);
|
||||
Controls.Add(ConfigurationGroupBox);
|
||||
Font = new Font("微软雅黑", 9F, FontStyle.Regular, GraphicsUnit.Point, (byte) 134);
|
||||
FormBorderStyle = FormBorderStyle.FixedSingle;
|
||||
Icon = Icon.FromHandle(Resources.Netch.GetHicon());
|
||||
Margin = new Padding(3, 4, 3, 4);
|
||||
MaximizeBox = false;
|
||||
Name = "ServerForm";
|
||||
Padding = new Padding(11, 5, 11, 4);
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
}
|
||||
|
||||
private GroupBox ConfigurationGroupBox;
|
||||
private Label RemarkLabel;
|
||||
protected TextBox RemarkTextBox;
|
||||
private Label PortLabel;
|
||||
protected TextBox AddressTextBox;
|
||||
private TextBox PortTextBox;
|
||||
private Label AddressLabel;
|
||||
}
|
||||
}
|
||||
3
Netch/Forms/SettingForm.Designer.cs
generated
3
Netch/Forms/SettingForm.Designer.cs
generated
@@ -206,7 +206,8 @@
|
||||
this.ICSCheckBox.Name = "ICSCheckBox";
|
||||
this.ICSCheckBox.Size = new System.Drawing.Size(46, 21);
|
||||
this.ICSCheckBox.TabIndex = 5;
|
||||
this.ICSCheckBox.Text = "ICS";
|
||||
this.ICSCheckBox.Text = "Tap Network Sharing";
|
||||
this.ICSCheckBox.Enabled = false;
|
||||
this.ICSCheckBox.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
this.ICSCheckBox.UseVisualStyleBackColor = true;
|
||||
this.ICSCheckBox.CheckedChanged += new System.EventHandler(this.ICSCheckBox_CheckedChanged);
|
||||
|
||||
@@ -38,7 +38,12 @@ namespace Netch.Forms
|
||||
TUNTAPUseCustomDNSCheckBox_CheckedChanged(null, null);
|
||||
ProxyDNSCheckBox.Checked = Global.Settings.TUNTAP.ProxyDNS;
|
||||
UseFakeDNSCheckBox.Checked = Global.Settings.TUNTAP.UseFakeDNS;
|
||||
ICSCheckBox.Checked = ICSController.Enabled;
|
||||
|
||||
if (TUNTAPController.SearchTapAdapter())
|
||||
{
|
||||
ICSCheckBox.Enabled = true;
|
||||
ICSCheckBox.Checked = ICSHelper.Enabled;
|
||||
}
|
||||
|
||||
// Behavior
|
||||
ExitWhenClosedCheckBox.Checked = Global.Settings.ExitWhenClosed;
|
||||
@@ -387,12 +392,12 @@ namespace Netch.Forms
|
||||
{
|
||||
if (ICSCheckBox.Checked)
|
||||
{
|
||||
if (!ICSController.Enabled)
|
||||
ICSCheckBox.Checked = ICSController.Enable();
|
||||
if (!ICSHelper.Enabled)
|
||||
ICSCheckBox.Checked = ICSHelper.Enable();
|
||||
}
|
||||
else
|
||||
{
|
||||
ICSController.Disable();
|
||||
ICSHelper.Disable();
|
||||
}
|
||||
});
|
||||
ICSCheckBox.Enabled = true;
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace Netch.Forms
|
||||
|
||||
if (!LinkTextBox.Text.StartsWith("HTTP://", StringComparison.OrdinalIgnoreCase) && !LinkTextBox.Text.StartsWith("HTTPS://", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
MessageBoxX.Show(i18N.Translate("Links must start with http:// or https://"));
|
||||
MessageBoxX.Show(i18N.Translate("Link must start with http:// or https://"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,17 +28,10 @@ namespace Netch
|
||||
|
||||
public static class Flags
|
||||
{
|
||||
static Flags()
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
SupportFakeDns = new TUNTAPController().TestFakeDNS();
|
||||
IsWindows10Upper = Environment.OSVersion.Version.Major >= 10;
|
||||
});
|
||||
}
|
||||
public static bool SupportFakeDns => _supportFakeDns ??= new TUNTAPController().TestFakeDNS();
|
||||
public static readonly bool IsWindows10Upper = Environment.OSVersion.Version.Major >= 10;
|
||||
|
||||
public static bool SupportFakeDns;
|
||||
public static bool IsWindows10Upper;
|
||||
private static bool? _supportFakeDns;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using Netch.Controllers;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Netch.Models
|
||||
@@ -20,6 +21,8 @@ namespace Netch.Models
|
||||
/// </summary>
|
||||
string FullName { get; }
|
||||
|
||||
string ShortName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Support URI
|
||||
/// </summary>
|
||||
@@ -33,7 +36,7 @@ namespace Netch.Models
|
||||
|
||||
string GetShareLink(Server server);
|
||||
|
||||
public abstract ServerController GetController();
|
||||
public abstract IServerController GetController();
|
||||
|
||||
public abstract IEnumerable<Server> ParseUri(string text);
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Netch.Utils;
|
||||
|
||||
namespace Netch.Models
|
||||
{
|
||||
@@ -47,7 +48,7 @@ namespace Netch.Models
|
||||
/// <returns>备注</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return $"[{Type + 1}] {Remark}";
|
||||
return $"[{Type + 1}] {i18N.Translate(Remark)}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -41,11 +41,6 @@ namespace Netch.Models
|
||||
/// </summary>
|
||||
public int Delay = -1;
|
||||
|
||||
/// <summary>
|
||||
/// 地区
|
||||
/// </summary>
|
||||
public string Country;
|
||||
|
||||
public bool IsSocks5() => Type == "Socks5";
|
||||
|
||||
/// <summary>
|
||||
@@ -59,28 +54,9 @@ namespace Netch.Models
|
||||
Remark = $"{Hostname}:{Port}";
|
||||
}
|
||||
|
||||
if (Country == null)
|
||||
{
|
||||
Country = Utils.Utils.GetCityCode(Hostname);
|
||||
}
|
||||
|
||||
Group = Group.Equals("None") || Group.Equals("") ? "NONE" : Group;
|
||||
|
||||
switch (Type)
|
||||
{
|
||||
case "Socks5":
|
||||
return $"[S5][{Country}][{Group}] {Remark}";
|
||||
case "SS":
|
||||
return $"[SS][{Country}][{Group}] {Remark}";
|
||||
case "SSR":
|
||||
return $"[SR][{Country}][{Group}] {Remark}";
|
||||
case "VMess":
|
||||
return $"[V2][{Country}][{Group}] {Remark}";
|
||||
case "Trojan":
|
||||
return $"[TR][{Country}][{Group}] {Remark}";
|
||||
default:
|
||||
return "WTF";
|
||||
}
|
||||
return $"[{ServerHelper.GetUtilByTypeName(Type)?.ShortName ?? "WTF"}][{Group}] {Remark}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
using Netch.Controllers;
|
||||
|
||||
namespace Netch.Models
|
||||
{
|
||||
public abstract class ServerController : Controller
|
||||
{
|
||||
private int? _socks5Port;
|
||||
|
||||
public int Socks5LocalPort
|
||||
{
|
||||
get => _socks5Port ?? Global.Settings.Socks5LocalPort;
|
||||
set => _socks5Port = value;
|
||||
}
|
||||
|
||||
private string _localAddress;
|
||||
|
||||
public string LocalAddress
|
||||
{
|
||||
get => _localAddress ?? Global.Settings.LocalAddress;
|
||||
set => _localAddress = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 启动
|
||||
/// </summary>
|
||||
/// <param name="server">服务器</param>
|
||||
/// <param name="mode">模式</param>
|
||||
/// <returns>是否启动成功</returns>
|
||||
public abstract bool Start(Server server, Mode mode);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using NETCONLib;
|
||||
|
||||
namespace WinFW
|
||||
namespace Netch.Models.WinFW
|
||||
{
|
||||
public class NetworkConnection : INetConnection, INetConnectionProps, INetSharingConfiguration
|
||||
{
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using System.Collections;
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using NETCONLib;
|
||||
using NETCONLib;
|
||||
|
||||
namespace WinFW
|
||||
namespace Netch.Models.WinFW
|
||||
{
|
||||
/// <summary>
|
||||
/// A collection that stores 'NetworkConnection' objects.
|
||||
|
||||
@@ -11,18 +11,12 @@
|
||||
"Stop": "停止",
|
||||
"Waiting for command": "等待命令中",
|
||||
"Starting": "正在启动中",
|
||||
"Start failed": "启动失败,请打开软件目录logging文件夹查看日志",
|
||||
"Start failed": "启动失败",
|
||||
"Started": "已启动",
|
||||
"Stopping": "正在停止中",
|
||||
"Stopped": "已停止",
|
||||
"Starting ": "正在启动 ",
|
||||
"Starting Tap": "正在启动 TUN/TAP",
|
||||
"Starting {0}": "正在启动 {0}",
|
||||
"Starting NatTester": "正在启动 NAT 测试",
|
||||
"Starting LocalDns service": "正在启动本地 DNS 服务",
|
||||
"Starting Redirector": "正在启动 Redirector",
|
||||
"Restarting Redirector": "正常启动失败,正在尝试重新启动 Redirector",
|
||||
"Starting netfilter2 Service": "正在启动 netfilter2 服务",
|
||||
"Starting dns Service": "正在启动 DNS 服务",
|
||||
"SetupBypass": "设置绕行规则",
|
||||
"Test failed": "测试失败",
|
||||
"Starting update subscription": "正在更新订阅",
|
||||
@@ -78,9 +72,11 @@
|
||||
"Update servers error from {0}": "从 {0} 更新服务器失败",
|
||||
|
||||
"Options": "选项",
|
||||
"Uninstall NF Service": "卸载 NF 服务",
|
||||
"Uninstalling NF Service": "正在卸载 NF 服务中",
|
||||
"Service has been uninstalled": "服务已卸载",
|
||||
"NF Service": "NF 服务",
|
||||
"TUN/TAP driver": "TUN/TAP 驱动",
|
||||
"Uninstall {0}": "卸载 {0}",
|
||||
"Uninstalling {0}": "正在卸载 {0} 中",
|
||||
"{0} has been uninstalled": "{0} 已卸载",
|
||||
"Reload Modes": "重载模式",
|
||||
"Modes have been reload": "模式已重载",
|
||||
"Clean DNS Cache": "清理 DNS 缓存",
|
||||
@@ -89,10 +85,6 @@
|
||||
"Update ACL with proxy": "使用代理更新 ACL 规则",
|
||||
"ACL updated successfully": "ACL 更新成功",
|
||||
"ACL update failed": "ACL 更新失败",
|
||||
"Reinstall TUN/TAP driver": "重新安装 TUN/TAP 驱动",
|
||||
"Reinstall TUN/TAP driver successfully": "重装 TUN/TAP 驱动成功",
|
||||
"Reinstall TUN/TAP driver failed": "重装 TUN/TAP 驱动失败",
|
||||
"Reinstalling TUN/TAP driver": "正在重装 TUN/TAP 驱动",
|
||||
"Open Directory": "打开目录",
|
||||
|
||||
"About": "关于",
|
||||
@@ -118,8 +110,6 @@
|
||||
"Remark": "备注",
|
||||
"Filename": "文件名",
|
||||
"Use Custom Filename": "使用自定义文件名",
|
||||
"Stay the same": "保持一致",
|
||||
"Time data": "时间数据",
|
||||
"Add": "添加",
|
||||
"Scan": "扫描",
|
||||
"Save": "保存",
|
||||
@@ -178,6 +168,7 @@
|
||||
"STUN Server Port": "STUN 服务器端口",
|
||||
"Custom ACL": "自定义 ACL 规则",
|
||||
"Language": "语言",
|
||||
"Tap Network Sharing": "Tap 网络共享",
|
||||
|
||||
"Profile": "配置名",
|
||||
"Profiles": "配置",
|
||||
@@ -189,10 +180,10 @@
|
||||
|
||||
"The {0} port is in use.": "{0} 端口已被占用",
|
||||
|
||||
"Bypass LAN": "[网页代理] 绕过局域网",
|
||||
"Bypass LAN (Non System Proxy)": "[网页代理] 绕过局域网(不设置系统代理)",
|
||||
"Bypass LAN (TUN/TAP)": "[TUN/TAP] 绕过局域网",
|
||||
"Bypass LAN and China": "[网页代理] 绕过局域网和中国大陆",
|
||||
"Bypass LAN and China (Non System Proxy)": "[网页代理] 绕过局域网和中国大陆 (不设置系统代理)",
|
||||
"Bypass LAN and China (TUN/TAP)": "[TUN/TAP] 绕过局域网和中国大陆"
|
||||
"[Web Proxy] Bypass LAN": "[网页代理] 绕过局域网",
|
||||
"[Non Web Proxy] Bypass LAN": "[不设置代理] 绕过局域网",
|
||||
"[TUN/TAP] Bypass LAN": "[TUN/TAP] 绕过局域网",
|
||||
"[Web Proxy] Bypass LAN and China": "[网页代理] 绕过局域网和中国大陆",
|
||||
"[Non Web Proxy] Bypass LAN and China": "[不设置代理] 绕过局域网和中国大陆",
|
||||
"[TUN/TAP] Bypass LAN and China": "[TUN/TAP] 绕过局域网和中国大陆"
|
||||
}
|
||||
@@ -1,247 +0,0 @@
|
||||
namespace Netch.ServerEx.Shadowsocks.Form
|
||||
{
|
||||
partial class ShadowsocksForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ShadowsocksForm));
|
||||
this.ConfigurationGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.PluginOptionsTextBox = new System.Windows.Forms.TextBox();
|
||||
this.PluginOptionsLabel = new System.Windows.Forms.Label();
|
||||
this.PluginTextBox = new System.Windows.Forms.TextBox();
|
||||
this.PluginLabel = new System.Windows.Forms.Label();
|
||||
this.EncryptMethodLabel = new System.Windows.Forms.Label();
|
||||
this.EncryptMethodComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.PasswordTextBox = new System.Windows.Forms.TextBox();
|
||||
this.PasswordLabel = new System.Windows.Forms.Label();
|
||||
this.AddressLabel = new System.Windows.Forms.Label();
|
||||
this.PortTextBox = new System.Windows.Forms.TextBox();
|
||||
this.AddressTextBox = new System.Windows.Forms.TextBox();
|
||||
this.RemarkTextBox = new System.Windows.Forms.TextBox();
|
||||
this.RemarkLabel = new System.Windows.Forms.Label();
|
||||
this.PortLabel = new System.Windows.Forms.Label();
|
||||
this.ControlButton = new System.Windows.Forms.Button();
|
||||
this.ConfigurationGroupBox.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// ConfigurationGroupBox
|
||||
//
|
||||
this.ConfigurationGroupBox.Controls.Add(this.PluginOptionsTextBox);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.PluginOptionsLabel);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.PluginTextBox);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.PluginLabel);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.EncryptMethodLabel);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.EncryptMethodComboBox);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.PasswordTextBox);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.PasswordLabel);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.AddressLabel);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.PortTextBox);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.AddressTextBox);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.RemarkTextBox);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.RemarkLabel);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.PortLabel);
|
||||
this.ConfigurationGroupBox.Location = new System.Drawing.Point(12, 12);
|
||||
this.ConfigurationGroupBox.Name = "ConfigurationGroupBox";
|
||||
this.ConfigurationGroupBox.Size = new System.Drawing.Size(420, 197);
|
||||
this.ConfigurationGroupBox.TabIndex = 0;
|
||||
this.ConfigurationGroupBox.TabStop = false;
|
||||
this.ConfigurationGroupBox.Text = "Configuration";
|
||||
//
|
||||
// PluginOptionsTextBox
|
||||
//
|
||||
this.PluginOptionsTextBox.Location = new System.Drawing.Point(120, 166);
|
||||
this.PluginOptionsTextBox.Name = "PluginOptionsTextBox";
|
||||
this.PluginOptionsTextBox.Size = new System.Drawing.Size(294, 23);
|
||||
this.PluginOptionsTextBox.TabIndex = 13;
|
||||
this.PluginOptionsTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// PluginOptionsLabel
|
||||
//
|
||||
this.PluginOptionsLabel.AutoSize = true;
|
||||
this.PluginOptionsLabel.Location = new System.Drawing.Point(10, 169);
|
||||
this.PluginOptionsLabel.Name = "PluginOptionsLabel";
|
||||
this.PluginOptionsLabel.Size = new System.Drawing.Size(93, 17);
|
||||
this.PluginOptionsLabel.TabIndex = 12;
|
||||
this.PluginOptionsLabel.Text = "Plugin Options";
|
||||
//
|
||||
// PluginTextBox
|
||||
//
|
||||
this.PluginTextBox.Location = new System.Drawing.Point(120, 137);
|
||||
this.PluginTextBox.Name = "PluginTextBox";
|
||||
this.PluginTextBox.Size = new System.Drawing.Size(294, 23);
|
||||
this.PluginTextBox.TabIndex = 11;
|
||||
this.PluginTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// PluginLabel
|
||||
//
|
||||
this.PluginLabel.AutoSize = true;
|
||||
this.PluginLabel.Location = new System.Drawing.Point(10, 140);
|
||||
this.PluginLabel.Name = "PluginLabel";
|
||||
this.PluginLabel.Size = new System.Drawing.Size(43, 17);
|
||||
this.PluginLabel.TabIndex = 10;
|
||||
this.PluginLabel.Text = "Plugin";
|
||||
//
|
||||
// EncryptMethodLabel
|
||||
//
|
||||
this.EncryptMethodLabel.AutoSize = true;
|
||||
this.EncryptMethodLabel.Location = new System.Drawing.Point(10, 110);
|
||||
this.EncryptMethodLabel.Name = "EncryptMethodLabel";
|
||||
this.EncryptMethodLabel.Size = new System.Drawing.Size(101, 17);
|
||||
this.EncryptMethodLabel.TabIndex = 8;
|
||||
this.EncryptMethodLabel.Text = "Encrypt Method";
|
||||
//
|
||||
// EncryptMethodComboBox
|
||||
//
|
||||
this.EncryptMethodComboBox.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
|
||||
this.EncryptMethodComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.EncryptMethodComboBox.FormattingEnabled = true;
|
||||
this.EncryptMethodComboBox.Location = new System.Drawing.Point(120, 106);
|
||||
this.EncryptMethodComboBox.Name = "EncryptMethodComboBox";
|
||||
this.EncryptMethodComboBox.Size = new System.Drawing.Size(294, 24);
|
||||
this.EncryptMethodComboBox.TabIndex = 9;
|
||||
this.EncryptMethodComboBox.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.ComboBox_DrawItem);
|
||||
//
|
||||
// PasswordTextBox
|
||||
//
|
||||
this.PasswordTextBox.Location = new System.Drawing.Point(120, 77);
|
||||
this.PasswordTextBox.Name = "PasswordTextBox";
|
||||
this.PasswordTextBox.Size = new System.Drawing.Size(294, 23);
|
||||
this.PasswordTextBox.TabIndex = 7;
|
||||
this.PasswordTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// PasswordLabel
|
||||
//
|
||||
this.PasswordLabel.AutoSize = true;
|
||||
this.PasswordLabel.Location = new System.Drawing.Point(10, 80);
|
||||
this.PasswordLabel.Name = "PasswordLabel";
|
||||
this.PasswordLabel.Size = new System.Drawing.Size(64, 17);
|
||||
this.PasswordLabel.TabIndex = 6;
|
||||
this.PasswordLabel.Text = "Password";
|
||||
//
|
||||
// AddressLabel
|
||||
//
|
||||
this.AddressLabel.AutoSize = true;
|
||||
this.AddressLabel.Location = new System.Drawing.Point(10, 51);
|
||||
this.AddressLabel.Name = "AddressLabel";
|
||||
this.AddressLabel.Size = new System.Drawing.Size(56, 17);
|
||||
this.AddressLabel.TabIndex = 2;
|
||||
this.AddressLabel.Text = "Address";
|
||||
//
|
||||
// PortTextBox
|
||||
//
|
||||
this.PortTextBox.Location = new System.Drawing.Point(358, 48);
|
||||
this.PortTextBox.Name = "PortTextBox";
|
||||
this.PortTextBox.Size = new System.Drawing.Size(56, 23);
|
||||
this.PortTextBox.TabIndex = 5;
|
||||
this.PortTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// AddressTextBox
|
||||
//
|
||||
this.AddressTextBox.Location = new System.Drawing.Point(120, 48);
|
||||
this.AddressTextBox.Name = "AddressTextBox";
|
||||
this.AddressTextBox.Size = new System.Drawing.Size(232, 23);
|
||||
this.AddressTextBox.TabIndex = 3;
|
||||
this.AddressTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// RemarkTextBox
|
||||
//
|
||||
this.RemarkTextBox.Location = new System.Drawing.Point(120, 19);
|
||||
this.RemarkTextBox.Name = "RemarkTextBox";
|
||||
this.RemarkTextBox.Size = new System.Drawing.Size(294, 23);
|
||||
this.RemarkTextBox.TabIndex = 1;
|
||||
this.RemarkTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// RemarkLabel
|
||||
//
|
||||
this.RemarkLabel.AutoSize = true;
|
||||
this.RemarkLabel.Location = new System.Drawing.Point(10, 22);
|
||||
this.RemarkLabel.Name = "RemarkLabel";
|
||||
this.RemarkLabel.Size = new System.Drawing.Size(53, 17);
|
||||
this.RemarkLabel.TabIndex = 0;
|
||||
this.RemarkLabel.Text = "Remark";
|
||||
//
|
||||
// PortLabel
|
||||
//
|
||||
this.PortLabel.AutoSize = true;
|
||||
this.PortLabel.Location = new System.Drawing.Point(351, 51);
|
||||
this.PortLabel.Name = "PortLabel";
|
||||
this.PortLabel.Size = new System.Drawing.Size(11, 17);
|
||||
this.PortLabel.TabIndex = 4;
|
||||
this.PortLabel.Text = ":";
|
||||
//
|
||||
// ControlButton
|
||||
//
|
||||
this.ControlButton.Location = new System.Drawing.Point(357, 215);
|
||||
this.ControlButton.Name = "ControlButton";
|
||||
this.ControlButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.ControlButton.TabIndex = 1;
|
||||
this.ControlButton.Text = "Save";
|
||||
this.ControlButton.UseVisualStyleBackColor = true;
|
||||
this.ControlButton.Click += new System.EventHandler(this.ControlButton_Click);
|
||||
//
|
||||
// Shadowsocks
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
||||
this.ClientSize = new System.Drawing.Size(444, 248);
|
||||
this.Controls.Add(this.ControlButton);
|
||||
this.Controls.Add(this.ConfigurationGroupBox);
|
||||
this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.MaximizeBox = false;
|
||||
this.Name = "ShadowsocksForm";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "Shadowsocks";
|
||||
this.Load += new System.EventHandler(this.Shadowsocks_Load);
|
||||
this.ConfigurationGroupBox.ResumeLayout(false);
|
||||
this.ConfigurationGroupBox.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.GroupBox ConfigurationGroupBox;
|
||||
private System.Windows.Forms.Button ControlButton;
|
||||
private System.Windows.Forms.Label RemarkLabel;
|
||||
private System.Windows.Forms.TextBox RemarkTextBox;
|
||||
private System.Windows.Forms.Label PortLabel;
|
||||
private System.Windows.Forms.TextBox AddressTextBox;
|
||||
private System.Windows.Forms.TextBox PortTextBox;
|
||||
private System.Windows.Forms.Label AddressLabel;
|
||||
private System.Windows.Forms.Label EncryptMethodLabel;
|
||||
private System.Windows.Forms.ComboBox EncryptMethodComboBox;
|
||||
private System.Windows.Forms.TextBox PasswordTextBox;
|
||||
private System.Windows.Forms.Label PasswordLabel;
|
||||
private System.Windows.Forms.TextBox PluginOptionsTextBox;
|
||||
private System.Windows.Forms.Label PluginOptionsLabel;
|
||||
private System.Windows.Forms.TextBox PluginTextBox;
|
||||
private System.Windows.Forms.Label PluginLabel;
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using Netch.Utils;
|
||||
|
||||
namespace Netch.ServerEx.Shadowsocks.Form
|
||||
{
|
||||
public partial class ShadowsocksForm : System.Windows.Forms.Form
|
||||
{
|
||||
private readonly Shadowsocks _server;
|
||||
|
||||
public ShadowsocksForm(Shadowsocks server = default)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_server = server ?? new Shadowsocks();
|
||||
}
|
||||
|
||||
private void Shadowsocks_Load(object sender, EventArgs e)
|
||||
{
|
||||
i18N.TranslateForm(this);
|
||||
|
||||
EncryptMethodComboBox.Items.AddRange(SSGlobal.EncryptMethods.ToArray());
|
||||
|
||||
RemarkTextBox.Text = _server.Remark;
|
||||
AddressTextBox.Text = _server.Hostname;
|
||||
PortTextBox.Text = _server.Port.ToString();
|
||||
PasswordTextBox.Text = _server.Password;
|
||||
EncryptMethodComboBox.SelectedIndex = SSGlobal.EncryptMethods.IndexOf(_server.EncryptMethod);
|
||||
PluginTextBox.Text = _server.Plugin;
|
||||
PluginOptionsTextBox.Text = _server.PluginOption;
|
||||
}
|
||||
|
||||
private void ComboBox_DrawItem(object sender, DrawItemEventArgs e)
|
||||
{
|
||||
Utils.Utils.DrawCenterComboBox(sender, e);
|
||||
}
|
||||
|
||||
private void ControlButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!ushort.TryParse(PortTextBox.Text, out var port)) return;
|
||||
|
||||
_server.Remark = RemarkTextBox.Text;
|
||||
_server.Type = "SS";
|
||||
_server.Hostname = AddressTextBox.Text;
|
||||
_server.Port = port;
|
||||
_server.Password = PasswordTextBox.Text;
|
||||
_server.EncryptMethod = EncryptMethodComboBox.Text;
|
||||
_server.Plugin = PluginTextBox.Text;
|
||||
_server.PluginOption = PluginOptionsTextBox.Text;
|
||||
_server.Country = null;
|
||||
|
||||
if (Global.Settings.Server.IndexOf(_server) == -1)
|
||||
Global.Settings.Server.Add(_server);
|
||||
|
||||
MessageBoxX.Show(i18N.Translate("Saved"));
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,299 +0,0 @@
|
||||
namespace Netch.ServerEx.ShadowsocksR.Form
|
||||
{
|
||||
partial class ShadowsocksRForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ShadowsocksRForm));
|
||||
this.ConfigurationGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.OBFSParamLabel = new System.Windows.Forms.Label();
|
||||
this.OBFSOptionParamTextBox = new System.Windows.Forms.TextBox();
|
||||
this.OBFSLabel = new System.Windows.Forms.Label();
|
||||
this.OBFSComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.ProtocolParamLabel = new System.Windows.Forms.Label();
|
||||
this.ProtocolParamTextBox = new System.Windows.Forms.TextBox();
|
||||
this.ProtocolLabel = new System.Windows.Forms.Label();
|
||||
this.ProtocolComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.EncryptMethodLabel = new System.Windows.Forms.Label();
|
||||
this.EncryptMethodComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.PasswordTextBox = new System.Windows.Forms.TextBox();
|
||||
this.PasswordLabel = new System.Windows.Forms.Label();
|
||||
this.AddressLabel = new System.Windows.Forms.Label();
|
||||
this.PortTextBox = new System.Windows.Forms.TextBox();
|
||||
this.AddressTextBox = new System.Windows.Forms.TextBox();
|
||||
this.RemarkTextBox = new System.Windows.Forms.TextBox();
|
||||
this.RemarkLabel = new System.Windows.Forms.Label();
|
||||
this.PortLabel = new System.Windows.Forms.Label();
|
||||
this.ControlButton = new System.Windows.Forms.Button();
|
||||
this.ConfigurationGroupBox.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// ConfigurationGroupBox
|
||||
//
|
||||
this.ConfigurationGroupBox.Controls.Add(this.OBFSParamLabel);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.OBFSOptionParamTextBox);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.OBFSLabel);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.OBFSComboBox);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.ProtocolParamLabel);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.ProtocolParamTextBox);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.ProtocolLabel);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.ProtocolComboBox);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.EncryptMethodLabel);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.EncryptMethodComboBox);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.PasswordTextBox);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.PasswordLabel);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.AddressLabel);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.PortTextBox);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.AddressTextBox);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.RemarkTextBox);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.RemarkLabel);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.PortLabel);
|
||||
this.ConfigurationGroupBox.Location = new System.Drawing.Point(12, 12);
|
||||
this.ConfigurationGroupBox.Name = "ConfigurationGroupBox";
|
||||
this.ConfigurationGroupBox.Size = new System.Drawing.Size(420, 258);
|
||||
this.ConfigurationGroupBox.TabIndex = 0;
|
||||
this.ConfigurationGroupBox.TabStop = false;
|
||||
this.ConfigurationGroupBox.Text = "Configuration";
|
||||
//
|
||||
// OBFSParamLabel
|
||||
//
|
||||
this.OBFSParamLabel.AutoSize = true;
|
||||
this.OBFSParamLabel.Location = new System.Drawing.Point(10, 230);
|
||||
this.OBFSParamLabel.Name = "OBFSParamLabel";
|
||||
this.OBFSParamLabel.Size = new System.Drawing.Size(80, 17);
|
||||
this.OBFSParamLabel.TabIndex = 16;
|
||||
this.OBFSParamLabel.Text = "OBFS Param";
|
||||
//
|
||||
// OBFSParamTextBox
|
||||
//
|
||||
this.OBFSOptionParamTextBox.Location = new System.Drawing.Point(120, 227);
|
||||
this.OBFSOptionParamTextBox.Name = "OBFSParamTextBox";
|
||||
this.OBFSOptionParamTextBox.Size = new System.Drawing.Size(294, 23);
|
||||
this.OBFSOptionParamTextBox.TabIndex = 17;
|
||||
this.OBFSOptionParamTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// OBFSLabel
|
||||
//
|
||||
this.OBFSLabel.AutoSize = true;
|
||||
this.OBFSLabel.Location = new System.Drawing.Point(10, 200);
|
||||
this.OBFSLabel.Name = "OBFSLabel";
|
||||
this.OBFSLabel.Size = new System.Drawing.Size(39, 17);
|
||||
this.OBFSLabel.TabIndex = 14;
|
||||
this.OBFSLabel.Text = "OBFS";
|
||||
//
|
||||
// OBFSComboBox
|
||||
//
|
||||
this.OBFSComboBox.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
|
||||
this.OBFSComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.OBFSComboBox.FormattingEnabled = true;
|
||||
this.OBFSComboBox.Location = new System.Drawing.Point(120, 196);
|
||||
this.OBFSComboBox.Name = "OBFSComboBox";
|
||||
this.OBFSComboBox.Size = new System.Drawing.Size(294, 24);
|
||||
this.OBFSComboBox.TabIndex = 15;
|
||||
this.OBFSComboBox.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.ComboBox_DrawItem);
|
||||
//
|
||||
// ProtocolParamLabel
|
||||
//
|
||||
this.ProtocolParamLabel.AutoSize = true;
|
||||
this.ProtocolParamLabel.Location = new System.Drawing.Point(10, 170);
|
||||
this.ProtocolParamLabel.Name = "ProtocolParamLabel";
|
||||
this.ProtocolParamLabel.Size = new System.Drawing.Size(98, 17);
|
||||
this.ProtocolParamLabel.TabIndex = 12;
|
||||
this.ProtocolParamLabel.Text = "Protocol Param";
|
||||
//
|
||||
// ProtocolParamTextBox
|
||||
//
|
||||
this.ProtocolParamTextBox.Location = new System.Drawing.Point(120, 167);
|
||||
this.ProtocolParamTextBox.Name = "ProtocolParamTextBox";
|
||||
this.ProtocolParamTextBox.Size = new System.Drawing.Size(294, 23);
|
||||
this.ProtocolParamTextBox.TabIndex = 13;
|
||||
this.ProtocolParamTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// ProtocolLabel
|
||||
//
|
||||
this.ProtocolLabel.AutoSize = true;
|
||||
this.ProtocolLabel.Location = new System.Drawing.Point(10, 140);
|
||||
this.ProtocolLabel.Name = "ProtocolLabel";
|
||||
this.ProtocolLabel.Size = new System.Drawing.Size(57, 17);
|
||||
this.ProtocolLabel.TabIndex = 10;
|
||||
this.ProtocolLabel.Text = "Protocol";
|
||||
//
|
||||
// ProtocolComboBox
|
||||
//
|
||||
this.ProtocolComboBox.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
|
||||
this.ProtocolComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.ProtocolComboBox.FormattingEnabled = true;
|
||||
this.ProtocolComboBox.Location = new System.Drawing.Point(120, 136);
|
||||
this.ProtocolComboBox.Name = "ProtocolComboBox";
|
||||
this.ProtocolComboBox.Size = new System.Drawing.Size(294, 24);
|
||||
this.ProtocolComboBox.TabIndex = 11;
|
||||
this.ProtocolComboBox.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.ComboBox_DrawItem);
|
||||
//
|
||||
// EncryptMethodLabel
|
||||
//
|
||||
this.EncryptMethodLabel.AutoSize = true;
|
||||
this.EncryptMethodLabel.Location = new System.Drawing.Point(10, 110);
|
||||
this.EncryptMethodLabel.Name = "EncryptMethodLabel";
|
||||
this.EncryptMethodLabel.Size = new System.Drawing.Size(101, 17);
|
||||
this.EncryptMethodLabel.TabIndex = 8;
|
||||
this.EncryptMethodLabel.Text = "Encrypt Method";
|
||||
//
|
||||
// EncryptMethodComboBox
|
||||
//
|
||||
this.EncryptMethodComboBox.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
|
||||
this.EncryptMethodComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.EncryptMethodComboBox.FormattingEnabled = true;
|
||||
this.EncryptMethodComboBox.Location = new System.Drawing.Point(120, 106);
|
||||
this.EncryptMethodComboBox.Name = "EncryptMethodComboBox";
|
||||
this.EncryptMethodComboBox.Size = new System.Drawing.Size(294, 24);
|
||||
this.EncryptMethodComboBox.TabIndex = 9;
|
||||
this.EncryptMethodComboBox.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.ComboBox_DrawItem);
|
||||
//
|
||||
// PasswordTextBox
|
||||
//
|
||||
this.PasswordTextBox.Location = new System.Drawing.Point(120, 77);
|
||||
this.PasswordTextBox.Name = "PasswordTextBox";
|
||||
this.PasswordTextBox.Size = new System.Drawing.Size(294, 23);
|
||||
this.PasswordTextBox.TabIndex = 7;
|
||||
this.PasswordTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// PasswordLabel
|
||||
//
|
||||
this.PasswordLabel.AutoSize = true;
|
||||
this.PasswordLabel.Location = new System.Drawing.Point(10, 80);
|
||||
this.PasswordLabel.Name = "PasswordLabel";
|
||||
this.PasswordLabel.Size = new System.Drawing.Size(64, 17);
|
||||
this.PasswordLabel.TabIndex = 6;
|
||||
this.PasswordLabel.Text = "Password";
|
||||
//
|
||||
// AddressLabel
|
||||
//
|
||||
this.AddressLabel.AutoSize = true;
|
||||
this.AddressLabel.Location = new System.Drawing.Point(10, 51);
|
||||
this.AddressLabel.Name = "AddressLabel";
|
||||
this.AddressLabel.Size = new System.Drawing.Size(56, 17);
|
||||
this.AddressLabel.TabIndex = 2;
|
||||
this.AddressLabel.Text = "Address";
|
||||
//
|
||||
// PortTextBox
|
||||
//
|
||||
this.PortTextBox.Location = new System.Drawing.Point(358, 48);
|
||||
this.PortTextBox.Name = "PortTextBox";
|
||||
this.PortTextBox.Size = new System.Drawing.Size(56, 23);
|
||||
this.PortTextBox.TabIndex = 5;
|
||||
this.PortTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// AddressTextBox
|
||||
//
|
||||
this.AddressTextBox.Location = new System.Drawing.Point(120, 48);
|
||||
this.AddressTextBox.Name = "AddressTextBox";
|
||||
this.AddressTextBox.Size = new System.Drawing.Size(232, 23);
|
||||
this.AddressTextBox.TabIndex = 3;
|
||||
this.AddressTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// RemarkTextBox
|
||||
//
|
||||
this.RemarkTextBox.Location = new System.Drawing.Point(120, 19);
|
||||
this.RemarkTextBox.Name = "RemarkTextBox";
|
||||
this.RemarkTextBox.Size = new System.Drawing.Size(294, 23);
|
||||
this.RemarkTextBox.TabIndex = 1;
|
||||
this.RemarkTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// RemarkLabel
|
||||
//
|
||||
this.RemarkLabel.AutoSize = true;
|
||||
this.RemarkLabel.Location = new System.Drawing.Point(10, 22);
|
||||
this.RemarkLabel.Name = "RemarkLabel";
|
||||
this.RemarkLabel.Size = new System.Drawing.Size(53, 17);
|
||||
this.RemarkLabel.TabIndex = 0;
|
||||
this.RemarkLabel.Text = "Remark";
|
||||
//
|
||||
// PortLabel
|
||||
//
|
||||
this.PortLabel.AutoSize = true;
|
||||
this.PortLabel.Location = new System.Drawing.Point(351, 51);
|
||||
this.PortLabel.Name = "PortLabel";
|
||||
this.PortLabel.Size = new System.Drawing.Size(11, 17);
|
||||
this.PortLabel.TabIndex = 4;
|
||||
this.PortLabel.Text = ":";
|
||||
//
|
||||
// ControlButton
|
||||
//
|
||||
this.ControlButton.Location = new System.Drawing.Point(357, 276);
|
||||
this.ControlButton.Name = "ControlButton";
|
||||
this.ControlButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.ControlButton.TabIndex = 1;
|
||||
this.ControlButton.Text = "Save";
|
||||
this.ControlButton.UseVisualStyleBackColor = true;
|
||||
this.ControlButton.Click += new System.EventHandler(this.ControlButton_Click);
|
||||
//
|
||||
// ShadowsocksR
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
||||
this.ClientSize = new System.Drawing.Size(444, 310);
|
||||
this.Controls.Add(this.ControlButton);
|
||||
this.Controls.Add(this.ConfigurationGroupBox);
|
||||
this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.MaximizeBox = false;
|
||||
this.Name = "ShadowsocksRForm";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "ShadowsocksR";
|
||||
this.Load += new System.EventHandler(this.ShadowsocksR_Load);
|
||||
this.ConfigurationGroupBox.ResumeLayout(false);
|
||||
this.ConfigurationGroupBox.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.GroupBox ConfigurationGroupBox;
|
||||
private System.Windows.Forms.Button ControlButton;
|
||||
private System.Windows.Forms.Label RemarkLabel;
|
||||
private System.Windows.Forms.TextBox RemarkTextBox;
|
||||
private System.Windows.Forms.Label PortLabel;
|
||||
private System.Windows.Forms.TextBox AddressTextBox;
|
||||
private System.Windows.Forms.TextBox PortTextBox;
|
||||
private System.Windows.Forms.Label AddressLabel;
|
||||
private System.Windows.Forms.Label EncryptMethodLabel;
|
||||
private System.Windows.Forms.ComboBox EncryptMethodComboBox;
|
||||
private System.Windows.Forms.TextBox PasswordTextBox;
|
||||
private System.Windows.Forms.Label PasswordLabel;
|
||||
private System.Windows.Forms.Label ProtocolLabel;
|
||||
private System.Windows.Forms.ComboBox ProtocolComboBox;
|
||||
private System.Windows.Forms.TextBox ProtocolParamTextBox;
|
||||
private System.Windows.Forms.Label ProtocolParamLabel;
|
||||
private System.Windows.Forms.Label OBFSLabel;
|
||||
private System.Windows.Forms.ComboBox OBFSComboBox;
|
||||
private System.Windows.Forms.TextBox OBFSOptionParamTextBox;
|
||||
private System.Windows.Forms.Label OBFSParamLabel;
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using Netch.Utils;
|
||||
|
||||
namespace Netch.ServerEx.ShadowsocksR.Form
|
||||
{
|
||||
public partial class ShadowsocksRForm : System.Windows.Forms.Form
|
||||
{
|
||||
private readonly ShadowsocksR _server;
|
||||
|
||||
public ShadowsocksRForm(Models.Server server = default)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_server = (ShadowsocksR) (server ?? new ShadowsocksR());
|
||||
}
|
||||
|
||||
private void ShadowsocksR_Load(object sender, EventArgs e)
|
||||
{
|
||||
i18N.TranslateForm(this);
|
||||
|
||||
EncryptMethodComboBox.Items.AddRange(SSRGlobal.EncryptMethods.ToArray());
|
||||
ProtocolComboBox.Items.AddRange(SSRGlobal.Protocols.ToArray());
|
||||
OBFSComboBox.Items.AddRange(SSRGlobal.OBFSs.ToArray());
|
||||
|
||||
RemarkTextBox.Text = _server.Remark;
|
||||
AddressTextBox.Text = _server.Hostname;
|
||||
PortTextBox.Text = _server.Port.ToString();
|
||||
PasswordTextBox.Text = _server.Password;
|
||||
EncryptMethodComboBox.SelectedIndex = SSRGlobal.EncryptMethods.IndexOf(_server.EncryptMethod);
|
||||
ProtocolComboBox.SelectedIndex = SSRGlobal.Protocols.IndexOf(_server.Protocol);
|
||||
ProtocolParamTextBox.Text = _server.ProtocolParam;
|
||||
OBFSComboBox.SelectedIndex = SSRGlobal.OBFSs.IndexOf(_server.OBFS);
|
||||
OBFSOptionParamTextBox.Text = _server.OBFSParam;
|
||||
}
|
||||
|
||||
private void ComboBox_DrawItem(object sender, DrawItemEventArgs e)
|
||||
{
|
||||
Utils.Utils.DrawCenterComboBox(sender, e);
|
||||
}
|
||||
|
||||
private void ControlButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!ushort.TryParse(PortTextBox.Text, out var port)) return;
|
||||
|
||||
_server.Remark = RemarkTextBox.Text;
|
||||
_server.Type = "SSR";
|
||||
_server.Hostname = AddressTextBox.Text;
|
||||
_server.Port = port;
|
||||
_server.Password = PasswordTextBox.Text;
|
||||
_server.EncryptMethod = EncryptMethodComboBox.Text;
|
||||
_server.Protocol = ProtocolComboBox.Text;
|
||||
_server.ProtocolParam = ProtocolParamTextBox.Text;
|
||||
_server.OBFS = OBFSComboBox.Text;
|
||||
_server.OBFSParam = OBFSOptionParamTextBox.Text;
|
||||
_server.Country = null;
|
||||
|
||||
if (Global.Settings.Server.IndexOf(_server) == -1)
|
||||
Global.Settings.Server.Add(_server);
|
||||
|
||||
MessageBoxX.Show(i18N.Translate("Saved"));
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
198
Netch/ServerEx/Socks5/Form/Socks5Form.Designer.cs
generated
198
Netch/ServerEx/Socks5/Form/Socks5Form.Designer.cs
generated
@@ -1,198 +0,0 @@
|
||||
namespace Netch.ServerEx.Socks5.Form
|
||||
{
|
||||
partial class Socks5Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Socks5Form));
|
||||
this.ConfigurationGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.PasswordLabel = new System.Windows.Forms.Label();
|
||||
this.UsernameTextBox = new System.Windows.Forms.TextBox();
|
||||
this.PasswordTextBox = new System.Windows.Forms.TextBox();
|
||||
this.UsernameLabel = new System.Windows.Forms.Label();
|
||||
this.AddressLabel = new System.Windows.Forms.Label();
|
||||
this.PortTextBox = new System.Windows.Forms.TextBox();
|
||||
this.AddressTextBox = new System.Windows.Forms.TextBox();
|
||||
this.RemarkTextBox = new System.Windows.Forms.TextBox();
|
||||
this.RemarkLabel = new System.Windows.Forms.Label();
|
||||
this.PortLabel = new System.Windows.Forms.Label();
|
||||
this.ControlButton = new System.Windows.Forms.Button();
|
||||
this.ConfigurationGroupBox.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// ConfigurationGroupBox
|
||||
//
|
||||
this.ConfigurationGroupBox.Controls.Add(this.PasswordLabel);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.UsernameTextBox);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.PasswordTextBox);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.UsernameLabel);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.AddressLabel);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.PortTextBox);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.AddressTextBox);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.RemarkTextBox);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.RemarkLabel);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.PortLabel);
|
||||
this.ConfigurationGroupBox.Location = new System.Drawing.Point(12, 12);
|
||||
this.ConfigurationGroupBox.Name = "ConfigurationGroupBox";
|
||||
this.ConfigurationGroupBox.Size = new System.Drawing.Size(420, 139);
|
||||
this.ConfigurationGroupBox.TabIndex = 0;
|
||||
this.ConfigurationGroupBox.TabStop = false;
|
||||
this.ConfigurationGroupBox.Text = "Configuration";
|
||||
//
|
||||
// PasswordLabel
|
||||
//
|
||||
this.PasswordLabel.AutoSize = true;
|
||||
this.PasswordLabel.Location = new System.Drawing.Point(10, 109);
|
||||
this.PasswordLabel.Name = "PasswordLabel";
|
||||
this.PasswordLabel.Size = new System.Drawing.Size(64, 17);
|
||||
this.PasswordLabel.TabIndex = 8;
|
||||
this.PasswordLabel.Text = "Password";
|
||||
//
|
||||
// UsernameTextBox
|
||||
//
|
||||
this.UsernameTextBox.Location = new System.Drawing.Point(120, 77);
|
||||
this.UsernameTextBox.Name = "UsernameTextBox";
|
||||
this.UsernameTextBox.Size = new System.Drawing.Size(294, 23);
|
||||
this.UsernameTextBox.TabIndex = 7;
|
||||
this.UsernameTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// PasswordTextBox
|
||||
//
|
||||
this.PasswordTextBox.Location = new System.Drawing.Point(120, 106);
|
||||
this.PasswordTextBox.Name = "PasswordTextBox";
|
||||
this.PasswordTextBox.Size = new System.Drawing.Size(294, 23);
|
||||
this.PasswordTextBox.TabIndex = 9;
|
||||
this.PasswordTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// UsernameLabel
|
||||
//
|
||||
this.UsernameLabel.AutoSize = true;
|
||||
this.UsernameLabel.Location = new System.Drawing.Point(10, 80);
|
||||
this.UsernameLabel.Name = "UsernameLabel";
|
||||
this.UsernameLabel.Size = new System.Drawing.Size(67, 17);
|
||||
this.UsernameLabel.TabIndex = 6;
|
||||
this.UsernameLabel.Text = "Username";
|
||||
//
|
||||
// AddressLabel
|
||||
//
|
||||
this.AddressLabel.AutoSize = true;
|
||||
this.AddressLabel.Location = new System.Drawing.Point(10, 51);
|
||||
this.AddressLabel.Name = "AddressLabel";
|
||||
this.AddressLabel.Size = new System.Drawing.Size(56, 17);
|
||||
this.AddressLabel.TabIndex = 2;
|
||||
this.AddressLabel.Text = "Address";
|
||||
//
|
||||
// PortTextBox
|
||||
//
|
||||
this.PortTextBox.Location = new System.Drawing.Point(358, 48);
|
||||
this.PortTextBox.Name = "PortTextBox";
|
||||
this.PortTextBox.Size = new System.Drawing.Size(56, 23);
|
||||
this.PortTextBox.TabIndex = 5;
|
||||
this.PortTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// AddressTextBox
|
||||
//
|
||||
this.AddressTextBox.Location = new System.Drawing.Point(120, 48);
|
||||
this.AddressTextBox.Name = "AddressTextBox";
|
||||
this.AddressTextBox.Size = new System.Drawing.Size(232, 23);
|
||||
this.AddressTextBox.TabIndex = 3;
|
||||
this.AddressTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// RemarkTextBox
|
||||
//
|
||||
this.RemarkTextBox.Location = new System.Drawing.Point(120, 19);
|
||||
this.RemarkTextBox.Name = "RemarkTextBox";
|
||||
this.RemarkTextBox.Size = new System.Drawing.Size(294, 23);
|
||||
this.RemarkTextBox.TabIndex = 1;
|
||||
this.RemarkTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// RemarkLabel
|
||||
//
|
||||
this.RemarkLabel.AutoSize = true;
|
||||
this.RemarkLabel.Location = new System.Drawing.Point(10, 22);
|
||||
this.RemarkLabel.Name = "RemarkLabel";
|
||||
this.RemarkLabel.Size = new System.Drawing.Size(53, 17);
|
||||
this.RemarkLabel.TabIndex = 0;
|
||||
this.RemarkLabel.Text = "Remark";
|
||||
//
|
||||
// PortLabel
|
||||
//
|
||||
this.PortLabel.AutoSize = true;
|
||||
this.PortLabel.Location = new System.Drawing.Point(351, 51);
|
||||
this.PortLabel.Name = "PortLabel";
|
||||
this.PortLabel.Size = new System.Drawing.Size(11, 17);
|
||||
this.PortLabel.TabIndex = 4;
|
||||
this.PortLabel.Text = ":";
|
||||
//
|
||||
// ControlButton
|
||||
//
|
||||
this.ControlButton.Location = new System.Drawing.Point(357, 157);
|
||||
this.ControlButton.Name = "ControlButton";
|
||||
this.ControlButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.ControlButton.TabIndex = 1;
|
||||
this.ControlButton.Text = "Save";
|
||||
this.ControlButton.UseVisualStyleBackColor = true;
|
||||
this.ControlButton.Click += new System.EventHandler(this.ControlButton_Click);
|
||||
//
|
||||
// Socks5
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
||||
this.ClientSize = new System.Drawing.Size(444, 192);
|
||||
this.Controls.Add(this.ControlButton);
|
||||
this.Controls.Add(this.ConfigurationGroupBox);
|
||||
this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.MaximizeBox = false;
|
||||
this.Name = "Socks5Form";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "Socks5";
|
||||
this.Load += new System.EventHandler(this.Socks5_Load);
|
||||
this.ConfigurationGroupBox.ResumeLayout(false);
|
||||
this.ConfigurationGroupBox.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.GroupBox ConfigurationGroupBox;
|
||||
private System.Windows.Forms.Button ControlButton;
|
||||
private System.Windows.Forms.Label RemarkLabel;
|
||||
private System.Windows.Forms.TextBox RemarkTextBox;
|
||||
private System.Windows.Forms.Label PortLabel;
|
||||
private System.Windows.Forms.TextBox AddressTextBox;
|
||||
private System.Windows.Forms.TextBox PortTextBox;
|
||||
private System.Windows.Forms.Label AddressLabel;
|
||||
private System.Windows.Forms.TextBox PasswordTextBox;
|
||||
private System.Windows.Forms.Label UsernameLabel;
|
||||
private System.Windows.Forms.Label PasswordLabel;
|
||||
private System.Windows.Forms.TextBox UsernameTextBox;
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
using System;
|
||||
using Netch.Utils;
|
||||
|
||||
namespace Netch.ServerEx.Socks5.Form
|
||||
{
|
||||
public partial class Socks5Form : System.Windows.Forms.Form
|
||||
{
|
||||
private readonly Socks5 _server;
|
||||
|
||||
public Socks5Form(Models.Server server = default)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_server = (Socks5) (server ?? new Socks5());
|
||||
}
|
||||
|
||||
private void Socks5_Load(object sender, EventArgs e)
|
||||
{
|
||||
i18N.TranslateForm(this);
|
||||
|
||||
RemarkTextBox.Text = _server.Remark;
|
||||
AddressTextBox.Text = _server.Hostname;
|
||||
PortTextBox.Text = _server.Port.ToString();
|
||||
UsernameTextBox.Text = _server.Username;
|
||||
PasswordTextBox.Text = _server.Password;
|
||||
}
|
||||
|
||||
private void ControlButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!ushort.TryParse(PortTextBox.Text, out var port)) return;
|
||||
|
||||
_server.Remark = RemarkTextBox.Text;
|
||||
_server.Type = "Socks5";
|
||||
_server.Hostname = AddressTextBox.Text;
|
||||
_server.Port = port;
|
||||
_server.Username = UsernameTextBox.Text;
|
||||
_server.Password = PasswordTextBox.Text;
|
||||
_server.Country = null;
|
||||
|
||||
if (Global.Settings.Server.IndexOf(_server) == -1)
|
||||
Global.Settings.Server.Add(_server);
|
||||
|
||||
MessageBoxX.Show(i18N.Translate("Saved"));
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
175
Netch/ServerEx/Trojan/Form/TrojanForm.Designer.cs
generated
175
Netch/ServerEx/Trojan/Form/TrojanForm.Designer.cs
generated
@@ -1,175 +0,0 @@
|
||||
namespace Netch.ServerEx.Trojan.Form
|
||||
{
|
||||
partial class TrojanForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(TrojanForm));
|
||||
this.ConfigurationGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.PasswordTextBox = new System.Windows.Forms.TextBox();
|
||||
this.PasswordLabel = new System.Windows.Forms.Label();
|
||||
this.AddressLabel = new System.Windows.Forms.Label();
|
||||
this.PortTextBox = new System.Windows.Forms.TextBox();
|
||||
this.AddressTextBox = new System.Windows.Forms.TextBox();
|
||||
this.RemarkTextBox = new System.Windows.Forms.TextBox();
|
||||
this.RemarkLabel = new System.Windows.Forms.Label();
|
||||
this.PortLabel = new System.Windows.Forms.Label();
|
||||
this.ControlButton = new System.Windows.Forms.Button();
|
||||
this.ConfigurationGroupBox.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// ConfigurationGroupBox
|
||||
//
|
||||
this.ConfigurationGroupBox.Controls.Add(this.PasswordTextBox);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.PasswordLabel);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.AddressLabel);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.PortTextBox);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.AddressTextBox);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.RemarkTextBox);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.RemarkLabel);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.PortLabel);
|
||||
this.ConfigurationGroupBox.Location = new System.Drawing.Point(12, 12);
|
||||
this.ConfigurationGroupBox.Name = "ConfigurationGroupBox";
|
||||
this.ConfigurationGroupBox.Size = new System.Drawing.Size(420, 109);
|
||||
this.ConfigurationGroupBox.TabIndex = 0;
|
||||
this.ConfigurationGroupBox.TabStop = false;
|
||||
this.ConfigurationGroupBox.Text = "Configuration";
|
||||
//
|
||||
// PasswordTextBox
|
||||
//
|
||||
this.PasswordTextBox.Location = new System.Drawing.Point(120, 77);
|
||||
this.PasswordTextBox.Name = "PasswordTextBox";
|
||||
this.PasswordTextBox.Size = new System.Drawing.Size(294, 23);
|
||||
this.PasswordTextBox.TabIndex = 7;
|
||||
this.PasswordTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// PasswordLabel
|
||||
//
|
||||
this.PasswordLabel.AutoSize = true;
|
||||
this.PasswordLabel.Location = new System.Drawing.Point(10, 80);
|
||||
this.PasswordLabel.Name = "PasswordLabel";
|
||||
this.PasswordLabel.Size = new System.Drawing.Size(64, 17);
|
||||
this.PasswordLabel.TabIndex = 6;
|
||||
this.PasswordLabel.Text = "Password";
|
||||
//
|
||||
// AddressLabel
|
||||
//
|
||||
this.AddressLabel.AutoSize = true;
|
||||
this.AddressLabel.Location = new System.Drawing.Point(10, 51);
|
||||
this.AddressLabel.Name = "AddressLabel";
|
||||
this.AddressLabel.Size = new System.Drawing.Size(56, 17);
|
||||
this.AddressLabel.TabIndex = 2;
|
||||
this.AddressLabel.Text = "Address";
|
||||
//
|
||||
// PortTextBox
|
||||
//
|
||||
this.PortTextBox.Location = new System.Drawing.Point(358, 48);
|
||||
this.PortTextBox.Name = "PortTextBox";
|
||||
this.PortTextBox.Size = new System.Drawing.Size(56, 23);
|
||||
this.PortTextBox.TabIndex = 5;
|
||||
this.PortTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// AddressTextBox
|
||||
//
|
||||
this.AddressTextBox.Location = new System.Drawing.Point(120, 48);
|
||||
this.AddressTextBox.Name = "AddressTextBox";
|
||||
this.AddressTextBox.Size = new System.Drawing.Size(232, 23);
|
||||
this.AddressTextBox.TabIndex = 3;
|
||||
this.AddressTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// RemarkTextBox
|
||||
//
|
||||
this.RemarkTextBox.Location = new System.Drawing.Point(120, 19);
|
||||
this.RemarkTextBox.Name = "RemarkTextBox";
|
||||
this.RemarkTextBox.Size = new System.Drawing.Size(294, 23);
|
||||
this.RemarkTextBox.TabIndex = 1;
|
||||
this.RemarkTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// RemarkLabel
|
||||
//
|
||||
this.RemarkLabel.AutoSize = true;
|
||||
this.RemarkLabel.Location = new System.Drawing.Point(10, 22);
|
||||
this.RemarkLabel.Name = "RemarkLabel";
|
||||
this.RemarkLabel.Size = new System.Drawing.Size(53, 17);
|
||||
this.RemarkLabel.TabIndex = 0;
|
||||
this.RemarkLabel.Text = "Remark";
|
||||
//
|
||||
// PortLabel
|
||||
//
|
||||
this.PortLabel.AutoSize = true;
|
||||
this.PortLabel.Location = new System.Drawing.Point(351, 51);
|
||||
this.PortLabel.Name = "PortLabel";
|
||||
this.PortLabel.Size = new System.Drawing.Size(11, 17);
|
||||
this.PortLabel.TabIndex = 4;
|
||||
this.PortLabel.Text = ":";
|
||||
//
|
||||
// ControlButton
|
||||
//
|
||||
this.ControlButton.Location = new System.Drawing.Point(357, 127);
|
||||
this.ControlButton.Name = "ControlButton";
|
||||
this.ControlButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.ControlButton.TabIndex = 1;
|
||||
this.ControlButton.Text = "Save";
|
||||
this.ControlButton.UseVisualStyleBackColor = true;
|
||||
this.ControlButton.Click += new System.EventHandler(this.ControlButton_Click);
|
||||
//
|
||||
// Trojan
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
||||
this.ClientSize = new System.Drawing.Size(444, 161);
|
||||
this.Controls.Add(this.ControlButton);
|
||||
this.Controls.Add(this.ConfigurationGroupBox);
|
||||
this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.MaximizeBox = false;
|
||||
this.Name = "TrojanForm";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "Trojan";
|
||||
this.Load += new System.EventHandler(this.TrojanForm_Load);
|
||||
this.ConfigurationGroupBox.ResumeLayout(false);
|
||||
this.ConfigurationGroupBox.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.GroupBox ConfigurationGroupBox;
|
||||
private System.Windows.Forms.Button ControlButton;
|
||||
private System.Windows.Forms.Label RemarkLabel;
|
||||
private System.Windows.Forms.TextBox RemarkTextBox;
|
||||
private System.Windows.Forms.Label PortLabel;
|
||||
private System.Windows.Forms.TextBox AddressTextBox;
|
||||
private System.Windows.Forms.TextBox PortTextBox;
|
||||
private System.Windows.Forms.Label AddressLabel;
|
||||
private System.Windows.Forms.TextBox PasswordTextBox;
|
||||
private System.Windows.Forms.Label PasswordLabel;
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using Netch.Models;
|
||||
using Netch.Utils;
|
||||
|
||||
namespace Netch.ServerEx.Trojan.Form
|
||||
{
|
||||
public partial class TrojanForm : System.Windows.Forms.Form
|
||||
{
|
||||
private readonly Trojan _server;
|
||||
|
||||
public TrojanForm(Server server = default)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_server = (Trojan) (server ?? new Trojan());
|
||||
}
|
||||
|
||||
private void TrojanForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
i18N.TranslateForm(this);
|
||||
|
||||
RemarkTextBox.Text = _server.Remark;
|
||||
AddressTextBox.Text = _server.Hostname;
|
||||
PortTextBox.Text = _server.Port.ToString();
|
||||
PasswordTextBox.Text = _server.Password;
|
||||
}
|
||||
|
||||
private void ComboBox_DrawItem(object sender, DrawItemEventArgs e)
|
||||
{
|
||||
Utils.Utils.DrawCenterComboBox(sender, e);
|
||||
}
|
||||
|
||||
private void ControlButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!ushort.TryParse(PortTextBox.Text, out var port)) return;
|
||||
|
||||
_server.Remark = RemarkTextBox.Text;
|
||||
_server.Type = "Trojan";
|
||||
_server.Hostname = AddressTextBox.Text;
|
||||
_server.Port = port;
|
||||
_server.Password = PasswordTextBox.Text;
|
||||
_server.Country = null;
|
||||
|
||||
if (Global.Settings.Server.IndexOf(_server) == -1)
|
||||
Global.Settings.Server.Add(_server);
|
||||
|
||||
MessageBoxX.Show(i18N.Translate("Saved"));
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
426
Netch/ServerEx/VMess/Form/VMessForm.Designer.cs
generated
426
Netch/ServerEx/VMess/Form/VMessForm.Designer.cs
generated
@@ -1,426 +0,0 @@
|
||||
namespace Netch.ServerEx.VMess.Form
|
||||
{
|
||||
partial class VMessForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(VMessForm));
|
||||
this.ConfigurationGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.UseMuxCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.TLSSecureCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.QUICSecretLabel = new System.Windows.Forms.Label();
|
||||
this.QUICSecurityLabel = new System.Windows.Forms.Label();
|
||||
this.QUICSecretTextBox = new System.Windows.Forms.TextBox();
|
||||
this.QUICSecurityComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.PathLabel = new System.Windows.Forms.Label();
|
||||
this.PathTextBox = new System.Windows.Forms.TextBox();
|
||||
this.HostLabel = new System.Windows.Forms.Label();
|
||||
this.HostTextBox = new System.Windows.Forms.TextBox();
|
||||
this.FakeTypeLabel = new System.Windows.Forms.Label();
|
||||
this.FakeTypeComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.TransferProtocolLabel = new System.Windows.Forms.Label();
|
||||
this.TransferProtocolComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.EncryptMethodLabel = new System.Windows.Forms.Label();
|
||||
this.EncryptMethodComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.AlterIDLabel = new System.Windows.Forms.Label();
|
||||
this.AlterIDTextBox = new System.Windows.Forms.TextBox();
|
||||
this.UserIDLabel = new System.Windows.Forms.Label();
|
||||
this.UserIDTextBox = new System.Windows.Forms.TextBox();
|
||||
this.PortTextBox = new System.Windows.Forms.TextBox();
|
||||
this.AddressTextBox = new System.Windows.Forms.TextBox();
|
||||
this.AddressLabel = new System.Windows.Forms.Label();
|
||||
this.RemarkTextBox = new System.Windows.Forms.TextBox();
|
||||
this.RemarkLabel = new System.Windows.Forms.Label();
|
||||
this.PortLabel = new System.Windows.Forms.Label();
|
||||
this.ControlButton = new System.Windows.Forms.Button();
|
||||
this.ConfigurationGroupBox.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// ConfigurationGroupBox
|
||||
//
|
||||
this.ConfigurationGroupBox.Controls.Add(this.UseMuxCheckBox);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.TLSSecureCheckBox);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.QUICSecretLabel);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.QUICSecurityLabel);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.QUICSecretTextBox);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.QUICSecurityComboBox);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.PathLabel);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.PathTextBox);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.HostLabel);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.HostTextBox);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.FakeTypeLabel);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.FakeTypeComboBox);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.TransferProtocolLabel);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.TransferProtocolComboBox);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.EncryptMethodLabel);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.EncryptMethodComboBox);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.AlterIDLabel);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.AlterIDTextBox);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.UserIDLabel);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.UserIDTextBox);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.PortTextBox);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.AddressTextBox);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.AddressLabel);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.RemarkTextBox);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.RemarkLabel);
|
||||
this.ConfigurationGroupBox.Controls.Add(this.PortLabel);
|
||||
this.ConfigurationGroupBox.Location = new System.Drawing.Point(18, 18);
|
||||
this.ConfigurationGroupBox.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.ConfigurationGroupBox.Name = "ConfigurationGroupBox";
|
||||
this.ConfigurationGroupBox.Padding = new System.Windows.Forms.Padding(4);
|
||||
this.ConfigurationGroupBox.Size = new System.Drawing.Size(630, 560);
|
||||
this.ConfigurationGroupBox.TabIndex = 1;
|
||||
this.ConfigurationGroupBox.TabStop = false;
|
||||
this.ConfigurationGroupBox.Text = "Configuration";
|
||||
//
|
||||
// UseMuxCheckBox
|
||||
//
|
||||
this.UseMuxCheckBox.AutoSize = true;
|
||||
this.UseMuxCheckBox.Location = new System.Drawing.Point(292, 519);
|
||||
this.UseMuxCheckBox.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.UseMuxCheckBox.Name = "UseMuxCheckBox";
|
||||
this.UseMuxCheckBox.Size = new System.Drawing.Size(110, 28);
|
||||
this.UseMuxCheckBox.TabIndex = 25;
|
||||
this.UseMuxCheckBox.Text = "Use Mux";
|
||||
this.UseMuxCheckBox.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// TLSSecureCheckBox
|
||||
//
|
||||
this.TLSSecureCheckBox.AutoSize = true;
|
||||
this.TLSSecureCheckBox.Location = new System.Drawing.Point(453, 519);
|
||||
this.TLSSecureCheckBox.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.TLSSecureCheckBox.Name = "TLSSecureCheckBox";
|
||||
this.TLSSecureCheckBox.Size = new System.Drawing.Size(127, 28);
|
||||
this.TLSSecureCheckBox.TabIndex = 24;
|
||||
this.TLSSecureCheckBox.Text = "TLS Secure";
|
||||
this.TLSSecureCheckBox.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// QUICSecretLabel
|
||||
//
|
||||
this.QUICSecretLabel.AutoSize = true;
|
||||
this.QUICSecretLabel.Location = new System.Drawing.Point(15, 480);
|
||||
this.QUICSecretLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.QUICSecretLabel.Name = "QUICSecretLabel";
|
||||
this.QUICSecretLabel.Size = new System.Drawing.Size(113, 24);
|
||||
this.QUICSecretLabel.TabIndex = 22;
|
||||
this.QUICSecretLabel.Text = "QUIC Secret";
|
||||
//
|
||||
// QUICSecurityLabel
|
||||
//
|
||||
this.QUICSecurityLabel.AutoSize = true;
|
||||
this.QUICSecurityLabel.Location = new System.Drawing.Point(15, 435);
|
||||
this.QUICSecurityLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.QUICSecurityLabel.Name = "QUICSecurityLabel";
|
||||
this.QUICSecurityLabel.Size = new System.Drawing.Size(129, 24);
|
||||
this.QUICSecurityLabel.TabIndex = 20;
|
||||
this.QUICSecurityLabel.Text = "QUIC Security";
|
||||
//
|
||||
// QUICSecretTextBox
|
||||
//
|
||||
this.QUICSecretTextBox.Location = new System.Drawing.Point(180, 476);
|
||||
this.QUICSecretTextBox.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.QUICSecretTextBox.Name = "QUICSecretTextBox";
|
||||
this.QUICSecretTextBox.Size = new System.Drawing.Size(439, 31);
|
||||
this.QUICSecretTextBox.TabIndex = 23;
|
||||
this.QUICSecretTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// QUICSecurityComboBox
|
||||
//
|
||||
this.QUICSecurityComboBox.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
|
||||
this.QUICSecurityComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.QUICSecurityComboBox.FormattingEnabled = true;
|
||||
this.QUICSecurityComboBox.Location = new System.Drawing.Point(180, 429);
|
||||
this.QUICSecurityComboBox.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.QUICSecurityComboBox.Name = "QUICSecurityComboBox";
|
||||
this.QUICSecurityComboBox.Size = new System.Drawing.Size(439, 32);
|
||||
this.QUICSecurityComboBox.TabIndex = 21;
|
||||
this.QUICSecurityComboBox.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.ComboBox_DrawItem);
|
||||
//
|
||||
// PathLabel
|
||||
//
|
||||
this.PathLabel.AutoSize = true;
|
||||
this.PathLabel.Location = new System.Drawing.Point(15, 390);
|
||||
this.PathLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.PathLabel.Name = "PathLabel";
|
||||
this.PathLabel.Size = new System.Drawing.Size(49, 24);
|
||||
this.PathLabel.TabIndex = 18;
|
||||
this.PathLabel.Text = "Path";
|
||||
//
|
||||
// PathTextBox
|
||||
//
|
||||
this.PathTextBox.Location = new System.Drawing.Point(180, 386);
|
||||
this.PathTextBox.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.PathTextBox.Name = "PathTextBox";
|
||||
this.PathTextBox.Size = new System.Drawing.Size(439, 31);
|
||||
this.PathTextBox.TabIndex = 19;
|
||||
this.PathTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// HostLabel
|
||||
//
|
||||
this.HostLabel.AutoSize = true;
|
||||
this.HostLabel.Location = new System.Drawing.Point(15, 346);
|
||||
this.HostLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.HostLabel.Name = "HostLabel";
|
||||
this.HostLabel.Size = new System.Drawing.Size(50, 24);
|
||||
this.HostLabel.TabIndex = 16;
|
||||
this.HostLabel.Text = "Host";
|
||||
//
|
||||
// HostTextBox
|
||||
//
|
||||
this.HostTextBox.Location = new System.Drawing.Point(180, 342);
|
||||
this.HostTextBox.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.HostTextBox.Name = "HostTextBox";
|
||||
this.HostTextBox.Size = new System.Drawing.Size(439, 31);
|
||||
this.HostTextBox.TabIndex = 17;
|
||||
this.HostTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// FakeTypeLabel
|
||||
//
|
||||
this.FakeTypeLabel.AutoSize = true;
|
||||
this.FakeTypeLabel.Location = new System.Drawing.Point(15, 302);
|
||||
this.FakeTypeLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.FakeTypeLabel.Name = "FakeTypeLabel";
|
||||
this.FakeTypeLabel.Size = new System.Drawing.Size(97, 24);
|
||||
this.FakeTypeLabel.TabIndex = 14;
|
||||
this.FakeTypeLabel.Text = "Fake Type";
|
||||
//
|
||||
// FakeTypeComboBox
|
||||
//
|
||||
this.FakeTypeComboBox.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
|
||||
this.FakeTypeComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.FakeTypeComboBox.FormattingEnabled = true;
|
||||
this.FakeTypeComboBox.Location = new System.Drawing.Point(180, 296);
|
||||
this.FakeTypeComboBox.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.FakeTypeComboBox.Name = "FakeTypeComboBox";
|
||||
this.FakeTypeComboBox.Size = new System.Drawing.Size(439, 32);
|
||||
this.FakeTypeComboBox.TabIndex = 15;
|
||||
this.FakeTypeComboBox.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.ComboBox_DrawItem);
|
||||
//
|
||||
// TransferProtocolLabel
|
||||
//
|
||||
this.TransferProtocolLabel.AutoSize = true;
|
||||
this.TransferProtocolLabel.Location = new System.Drawing.Point(15, 255);
|
||||
this.TransferProtocolLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.TransferProtocolLabel.Name = "TransferProtocolLabel";
|
||||
this.TransferProtocolLabel.Size = new System.Drawing.Size(156, 24);
|
||||
this.TransferProtocolLabel.TabIndex = 12;
|
||||
this.TransferProtocolLabel.Text = "Transfer Protocol";
|
||||
//
|
||||
// TransferProtocolComboBox
|
||||
//
|
||||
this.TransferProtocolComboBox.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
|
||||
this.TransferProtocolComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.TransferProtocolComboBox.FormattingEnabled = true;
|
||||
this.TransferProtocolComboBox.Location = new System.Drawing.Point(180, 249);
|
||||
this.TransferProtocolComboBox.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.TransferProtocolComboBox.Name = "TransferProtocolComboBox";
|
||||
this.TransferProtocolComboBox.Size = new System.Drawing.Size(439, 32);
|
||||
this.TransferProtocolComboBox.TabIndex = 13;
|
||||
this.TransferProtocolComboBox.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.ComboBox_DrawItem);
|
||||
//
|
||||
// EncryptMethodLabel
|
||||
//
|
||||
this.EncryptMethodLabel.AutoSize = true;
|
||||
this.EncryptMethodLabel.Location = new System.Drawing.Point(15, 208);
|
||||
this.EncryptMethodLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.EncryptMethodLabel.Name = "EncryptMethodLabel";
|
||||
this.EncryptMethodLabel.Size = new System.Drawing.Size(150, 24);
|
||||
this.EncryptMethodLabel.TabIndex = 10;
|
||||
this.EncryptMethodLabel.Text = "Encrypt Method";
|
||||
//
|
||||
// EncryptMethodComboBox
|
||||
//
|
||||
this.EncryptMethodComboBox.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
|
||||
this.EncryptMethodComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.EncryptMethodComboBox.FormattingEnabled = true;
|
||||
this.EncryptMethodComboBox.Location = new System.Drawing.Point(180, 202);
|
||||
this.EncryptMethodComboBox.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.EncryptMethodComboBox.Name = "EncryptMethodComboBox";
|
||||
this.EncryptMethodComboBox.Size = new System.Drawing.Size(439, 32);
|
||||
this.EncryptMethodComboBox.TabIndex = 11;
|
||||
this.EncryptMethodComboBox.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.ComboBox_DrawItem);
|
||||
//
|
||||
// AlterIDLabel
|
||||
//
|
||||
this.AlterIDLabel.AutoSize = true;
|
||||
this.AlterIDLabel.Location = new System.Drawing.Point(15, 164);
|
||||
this.AlterIDLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.AlterIDLabel.Name = "AlterIDLabel";
|
||||
this.AlterIDLabel.Size = new System.Drawing.Size(76, 24);
|
||||
this.AlterIDLabel.TabIndex = 8;
|
||||
this.AlterIDLabel.Text = "Alter ID";
|
||||
//
|
||||
// AlterIDTextBox
|
||||
//
|
||||
this.AlterIDTextBox.Location = new System.Drawing.Point(180, 159);
|
||||
this.AlterIDTextBox.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.AlterIDTextBox.Name = "AlterIDTextBox";
|
||||
this.AlterIDTextBox.Size = new System.Drawing.Size(79, 31);
|
||||
this.AlterIDTextBox.TabIndex = 9;
|
||||
this.AlterIDTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// UserIDLabel
|
||||
//
|
||||
this.UserIDLabel.AutoSize = true;
|
||||
this.UserIDLabel.Location = new System.Drawing.Point(15, 120);
|
||||
this.UserIDLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.UserIDLabel.Name = "UserIDLabel";
|
||||
this.UserIDLabel.Size = new System.Drawing.Size(72, 24);
|
||||
this.UserIDLabel.TabIndex = 6;
|
||||
this.UserIDLabel.Text = "User ID";
|
||||
//
|
||||
// UserIDTextBox
|
||||
//
|
||||
this.UserIDTextBox.Location = new System.Drawing.Point(180, 116);
|
||||
this.UserIDTextBox.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.UserIDTextBox.Name = "UserIDTextBox";
|
||||
this.UserIDTextBox.Size = new System.Drawing.Size(439, 31);
|
||||
this.UserIDTextBox.TabIndex = 7;
|
||||
this.UserIDTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// PortTextBox
|
||||
//
|
||||
this.PortTextBox.Location = new System.Drawing.Point(540, 72);
|
||||
this.PortTextBox.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.PortTextBox.Name = "PortTextBox";
|
||||
this.PortTextBox.Size = new System.Drawing.Size(79, 31);
|
||||
this.PortTextBox.TabIndex = 5;
|
||||
this.PortTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// AddressTextBox
|
||||
//
|
||||
this.AddressTextBox.Location = new System.Drawing.Point(180, 72);
|
||||
this.AddressTextBox.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.AddressTextBox.Name = "AddressTextBox";
|
||||
this.AddressTextBox.Size = new System.Drawing.Size(349, 31);
|
||||
this.AddressTextBox.TabIndex = 3;
|
||||
this.AddressTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// AddressLabel
|
||||
//
|
||||
this.AddressLabel.AutoSize = true;
|
||||
this.AddressLabel.Location = new System.Drawing.Point(15, 76);
|
||||
this.AddressLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.AddressLabel.Name = "AddressLabel";
|
||||
this.AddressLabel.Size = new System.Drawing.Size(80, 24);
|
||||
this.AddressLabel.TabIndex = 2;
|
||||
this.AddressLabel.Text = "Address";
|
||||
//
|
||||
// RemarkTextBox
|
||||
//
|
||||
this.RemarkTextBox.Location = new System.Drawing.Point(180, 28);
|
||||
this.RemarkTextBox.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.RemarkTextBox.Name = "RemarkTextBox";
|
||||
this.RemarkTextBox.Size = new System.Drawing.Size(439, 31);
|
||||
this.RemarkTextBox.TabIndex = 1;
|
||||
this.RemarkTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// RemarkLabel
|
||||
//
|
||||
this.RemarkLabel.AutoSize = true;
|
||||
this.RemarkLabel.Location = new System.Drawing.Point(15, 33);
|
||||
this.RemarkLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.RemarkLabel.Name = "RemarkLabel";
|
||||
this.RemarkLabel.Size = new System.Drawing.Size(76, 24);
|
||||
this.RemarkLabel.TabIndex = 0;
|
||||
this.RemarkLabel.Text = "Remark";
|
||||
//
|
||||
// PortLabel
|
||||
//
|
||||
this.PortLabel.AutoSize = true;
|
||||
this.PortLabel.Location = new System.Drawing.Point(530, 76);
|
||||
this.PortLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.PortLabel.Name = "PortLabel";
|
||||
this.PortLabel.Size = new System.Drawing.Size(14, 24);
|
||||
this.PortLabel.TabIndex = 4;
|
||||
this.PortLabel.Text = ":";
|
||||
//
|
||||
// ControlButton
|
||||
//
|
||||
this.ControlButton.Location = new System.Drawing.Point(536, 586);
|
||||
this.ControlButton.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.ControlButton.Name = "ControlButton";
|
||||
this.ControlButton.Size = new System.Drawing.Size(112, 34);
|
||||
this.ControlButton.TabIndex = 2;
|
||||
this.ControlButton.Text = "Save";
|
||||
this.ControlButton.UseVisualStyleBackColor = true;
|
||||
this.ControlButton.Click += new System.EventHandler(this.ControlButton_Click);
|
||||
//
|
||||
// VMess
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(144F, 144F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
||||
this.ClientSize = new System.Drawing.Size(666, 639);
|
||||
this.Controls.Add(this.ControlButton);
|
||||
this.Controls.Add(this.ConfigurationGroupBox);
|
||||
this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6);
|
||||
this.MaximizeBox = false;
|
||||
this.Name = "VMessForm";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "VMess";
|
||||
this.Load += new System.EventHandler(this.VMess_Load);
|
||||
this.ConfigurationGroupBox.ResumeLayout(false);
|
||||
this.ConfigurationGroupBox.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.GroupBox ConfigurationGroupBox;
|
||||
private System.Windows.Forms.TextBox PortTextBox;
|
||||
private System.Windows.Forms.TextBox AddressTextBox;
|
||||
private System.Windows.Forms.Label AddressLabel;
|
||||
private System.Windows.Forms.TextBox RemarkTextBox;
|
||||
private System.Windows.Forms.Label RemarkLabel;
|
||||
private System.Windows.Forms.Label PortLabel;
|
||||
private System.Windows.Forms.Label UserIDLabel;
|
||||
private System.Windows.Forms.TextBox UserIDTextBox;
|
||||
private System.Windows.Forms.Label AlterIDLabel;
|
||||
private System.Windows.Forms.TextBox AlterIDTextBox;
|
||||
private System.Windows.Forms.Label EncryptMethodLabel;
|
||||
private System.Windows.Forms.ComboBox EncryptMethodComboBox;
|
||||
private System.Windows.Forms.Label TransferProtocolLabel;
|
||||
private System.Windows.Forms.ComboBox TransferProtocolComboBox;
|
||||
private System.Windows.Forms.Label FakeTypeLabel;
|
||||
private System.Windows.Forms.ComboBox FakeTypeComboBox;
|
||||
private System.Windows.Forms.Label HostLabel;
|
||||
private System.Windows.Forms.TextBox HostTextBox;
|
||||
private System.Windows.Forms.Label PathLabel;
|
||||
private System.Windows.Forms.TextBox PathTextBox;
|
||||
private System.Windows.Forms.Label QUICSecurityLabel;
|
||||
private System.Windows.Forms.TextBox QUICSecretTextBox;
|
||||
private System.Windows.Forms.ComboBox QUICSecurityComboBox;
|
||||
private System.Windows.Forms.Label QUICSecretLabel;
|
||||
private System.Windows.Forms.CheckBox TLSSecureCheckBox;
|
||||
private System.Windows.Forms.Button ControlButton;
|
||||
private System.Windows.Forms.CheckBox UseMuxCheckBox;
|
||||
}
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using Netch.Models;
|
||||
using Netch.Utils;
|
||||
|
||||
namespace Netch.ServerEx.VMess.Form
|
||||
{
|
||||
public partial class VMessForm : System.Windows.Forms.Form
|
||||
{
|
||||
private static VMess _server;
|
||||
|
||||
public VMessForm(Server server = default)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_server = (VMess) server ?? new VMess();
|
||||
}
|
||||
|
||||
private void ComboBox_DrawItem(object sender, DrawItemEventArgs e)
|
||||
{
|
||||
Utils.Utils.DrawCenterComboBox(sender, e);
|
||||
}
|
||||
|
||||
private void VMess_Load(object sender, EventArgs e)
|
||||
{
|
||||
i18N.TranslateForm(this);
|
||||
|
||||
EncryptMethodComboBox.Items.AddRange(VMessGlobal.EncryptMethods.ToArray());
|
||||
TransferProtocolComboBox.Items.AddRange(VMessGlobal.TransferProtocols.ToArray());
|
||||
FakeTypeComboBox.Items.AddRange(VMessGlobal.FakeTypes.ToArray());
|
||||
QUICSecurityComboBox.Items.AddRange(VMessGlobal.QUIC.ToArray());
|
||||
|
||||
|
||||
RemarkTextBox.Text = _server.Remark;
|
||||
AddressTextBox.Text = _server.Hostname;
|
||||
PortTextBox.Text = _server.Port.ToString();
|
||||
UserIDTextBox.Text = _server.UserID;
|
||||
AlterIDTextBox.Text = _server.AlterID.ToString();
|
||||
EncryptMethodComboBox.SelectedIndex = VMessGlobal.EncryptMethods.IndexOf(_server.EncryptMethod);
|
||||
TransferProtocolComboBox.SelectedIndex = VMessGlobal.TransferProtocols.IndexOf(_server.TransferProtocol);
|
||||
FakeTypeComboBox.SelectedIndex = VMessGlobal.FakeTypes.IndexOf(_server.FakeType);
|
||||
HostTextBox.Text = _server.Host;
|
||||
PathTextBox.Text = _server.Path;
|
||||
QUICSecurityComboBox.SelectedIndex = VMessGlobal.QUIC.IndexOf(_server.QUICSecure);
|
||||
QUICSecretTextBox.Text = _server.QUICSecret;
|
||||
TLSSecureCheckBox.Checked = _server.TLSSecure;
|
||||
UseMuxCheckBox.Checked = _server.UseMux;
|
||||
}
|
||||
|
||||
private void ControlButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!ushort.TryParse(PortTextBox.Text, out var port)) return;
|
||||
|
||||
if (!int.TryParse(AlterIDTextBox.Text, out var alterId)) return;
|
||||
|
||||
_server.Remark = RemarkTextBox.Text;
|
||||
_server.Type = "VMess";
|
||||
_server.Hostname = AddressTextBox.Text;
|
||||
_server.Port = port;
|
||||
_server.UserID = UserIDTextBox.Text;
|
||||
_server.AlterID = alterId;
|
||||
_server.EncryptMethod = EncryptMethodComboBox.Text;
|
||||
_server.TransferProtocol = TransferProtocolComboBox.Text;
|
||||
_server.FakeType = FakeTypeComboBox.Text;
|
||||
_server.Host = HostTextBox.Text;
|
||||
_server.Path = PathTextBox.Text;
|
||||
_server.QUICSecure = QUICSecurityComboBox.Text;
|
||||
_server.QUICSecret = QUICSecretTextBox.Text;
|
||||
_server.TLSSecure = TLSSecureCheckBox.Checked;
|
||||
_server.UseMux = UseMuxCheckBox.Checked;
|
||||
_server.Country = null;
|
||||
|
||||
if (Global.Settings.Server.IndexOf(_server) == -1)
|
||||
Global.Settings.Server.Add(_server);
|
||||
|
||||
MessageBoxX.Show(i18N.Translate("Saved"));
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
31
Netch/Servers/Shadowsocks/Form/ShadowsocksForm.cs
Normal file
31
Netch/Servers/Shadowsocks/Form/ShadowsocksForm.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using Netch.Forms;
|
||||
|
||||
namespace Netch.Servers.Shadowsocks.Form
|
||||
{
|
||||
public class ShadowsocksForm : ServerForm
|
||||
{
|
||||
protected override string TypeName { get; } = "Shadowsocks";
|
||||
|
||||
public ShadowsocksForm(Shadowsocks server = default)
|
||||
{
|
||||
server ??= new Shadowsocks();
|
||||
Server = server;
|
||||
CreateTextBox("Password", "Password",
|
||||
s => true,
|
||||
s => server.Password = s,
|
||||
server.Password);
|
||||
CreateComboBox("EncryptMethod", "Encrypt Method",
|
||||
SSGlobal.EncryptMethods,
|
||||
s => server.EncryptMethod = s,
|
||||
server.EncryptMethod);
|
||||
CreateTextBox("Plugin", "Plugin",
|
||||
s => true,
|
||||
s => server.Plugin = s,
|
||||
server.Plugin);
|
||||
CreateTextBox("PluginsOption", "Plugin Options",
|
||||
s => true,
|
||||
s => server.PluginOption = s,
|
||||
server.PluginOption);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Netch.ServerEx.Shadowsocks.Models.SSD
|
||||
namespace Netch.Servers.Shadowsocks.Models.SSD
|
||||
{
|
||||
public class Main
|
||||
{
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Netch.ServerEx.Shadowsocks.Models.SSD
|
||||
namespace Netch.Servers.Shadowsocks.Models.SSD
|
||||
{
|
||||
public class SSDServer
|
||||
{
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Netch.ServerEx.Shadowsocks.Models
|
||||
namespace Netch.Servers.Shadowsocks.Models
|
||||
{
|
||||
public class ShadowsocksConfig
|
||||
{
|
||||
@@ -1,19 +1,20 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using Netch.Controllers;
|
||||
using Netch.Models;
|
||||
using Netch.Utils;
|
||||
|
||||
namespace Netch.ServerEx.Shadowsocks
|
||||
namespace Netch.Servers.Shadowsocks
|
||||
{
|
||||
public class SSController : ServerController
|
||||
public class SSController : Guard, IServerController
|
||||
{
|
||||
public SSController()
|
||||
{
|
||||
Name = "Shadowsocks";
|
||||
MainFile = "Shadowsocks.exe";
|
||||
}
|
||||
public override string Name { get; protected set; } = "Shadowsocks";
|
||||
public override string MainFile { get; protected set; } = "Shadowsocks.exe";
|
||||
|
||||
public override bool Start(Server s, Mode mode)
|
||||
public int? Socks5LocalPort { get; set; }
|
||||
public string LocalAddress { get; set; }
|
||||
|
||||
public bool Start(Server s, Mode mode)
|
||||
{
|
||||
bool DllFlag()
|
||||
{
|
||||
@@ -26,7 +27,7 @@ namespace Netch.ServerEx.Shadowsocks
|
||||
{
|
||||
State = State.Starting;
|
||||
var client = Encoding.UTF8.GetBytes($"{LocalAddress}:{Socks5LocalPort}");
|
||||
var remote = Encoding.UTF8.GetBytes($"{server.Hostname}:{server.Port}");
|
||||
var remote = Encoding.UTF8.GetBytes($"{DNS.Lookup(server.Hostname)}:{server.Port}");
|
||||
var passwd = Encoding.UTF8.GetBytes($"{server.Password}");
|
||||
var method = Encoding.UTF8.GetBytes($"{server.EncryptMethod}");
|
||||
if (!ShadowsocksDLL.Info(client, remote, passwd, method))
|
||||
@@ -54,10 +55,10 @@ namespace Netch.ServerEx.Shadowsocks
|
||||
|
||||
var argument = new StringBuilder();
|
||||
argument.Append(
|
||||
$"-s {server.Hostname} " +
|
||||
$"-s {DNS.Lookup(server.Hostname)} " +
|
||||
$"-p {server.Port} " +
|
||||
$"-b {LocalAddress} " +
|
||||
$"-l {Socks5LocalPort} " +
|
||||
$"-b {LocalAddress ?? Global.Settings.LocalAddress} " +
|
||||
$"-l {Socks5LocalPort ?? Global.Settings.Socks5LocalPort} " +
|
||||
$"-m {server.EncryptMethod} " +
|
||||
$"-k \"{server.Password}\" " +
|
||||
"-u ");
|
||||
@@ -3,22 +3,23 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Web;
|
||||
using Netch.Controllers;
|
||||
using Netch.Models;
|
||||
using Netch.ServerEx.Shadowsocks.Form;
|
||||
using Netch.ServerEx.Shadowsocks.Models.SSD;
|
||||
using Netch.Servers.Shadowsocks.Form;
|
||||
using Netch.Servers.Shadowsocks.Models.SSD;
|
||||
using Netch.Utils;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Netch.ServerEx.Shadowsocks
|
||||
namespace Netch.Servers.Shadowsocks
|
||||
{
|
||||
public class SSUtil : IServerUtil
|
||||
{
|
||||
public ushort Priority { get; } = 1;
|
||||
public string TypeName { get; } = "SS";
|
||||
public string FullName { get; } = "Shadowsocks";
|
||||
|
||||
public string[] UriScheme { get; } = {"ss","ssd"};
|
||||
public string ShortName { get; } = "SS";
|
||||
public string[] UriScheme { get; } = {"ss", "ssd"};
|
||||
|
||||
public Server ParseJObject(JObject j)
|
||||
{
|
||||
@@ -42,7 +43,7 @@ namespace Netch.ServerEx.Shadowsocks
|
||||
return "ss://" + ShareLink.URLSafeBase64Encode($"{server.EncryptMethod}:{server.Password}@{server.Hostname}:{server.Port}") + "#" + HttpUtility.UrlEncode(server.Remark);
|
||||
}
|
||||
|
||||
public ServerController GetController()
|
||||
public IServerController GetController()
|
||||
{
|
||||
return new SSController();
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using Netch.Models;
|
||||
|
||||
namespace Netch.ServerEx.Shadowsocks
|
||||
namespace Netch.Servers.Shadowsocks
|
||||
{
|
||||
public class Shadowsocks : Server
|
||||
{
|
||||
39
Netch/Servers/ShadowsocksR/Form/ShadowsocksRForm.cs
Normal file
39
Netch/Servers/ShadowsocksR/Form/ShadowsocksRForm.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using Netch.Forms;
|
||||
|
||||
namespace Netch.Servers.ShadowsocksR.Form
|
||||
{
|
||||
public class ShadowsocksRForm : ServerForm
|
||||
{
|
||||
protected override string TypeName { get; } = "ShadowsocksR";
|
||||
|
||||
public ShadowsocksRForm(ShadowsocksR server = default)
|
||||
{
|
||||
server ??= new ShadowsocksR();
|
||||
Server = server;
|
||||
CreateTextBox("Password", "Password",
|
||||
s => true,
|
||||
s => server.Password = s,
|
||||
server.Password);
|
||||
CreateComboBox("EncryptMethod", "Encrypt Method",
|
||||
SSRGlobal.EncryptMethods,
|
||||
s => server.EncryptMethod = s,
|
||||
server.EncryptMethod);
|
||||
CreateComboBox("Protocol", "Protocol",
|
||||
SSRGlobal.Protocols,
|
||||
s => server.Protocol = s,
|
||||
server.Protocol);
|
||||
CreateTextBox("ProtocolParam", "Protocol Param",
|
||||
s => true,
|
||||
s => server.ProtocolParam = s,
|
||||
server.ProtocolParam);
|
||||
CreateComboBox("OBFS", "OBFS",
|
||||
SSRGlobal.OBFSs,
|
||||
s => server.OBFS = s,
|
||||
server.OBFS);
|
||||
CreateTextBox("OBFSParam", "OBFS Param",
|
||||
s => true,
|
||||
s => server.OBFSParam = s,
|
||||
server.OBFSParam);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,25 +1,27 @@
|
||||
using System.Text;
|
||||
using Netch.Controllers;
|
||||
using Netch.Models;
|
||||
using Netch.Utils;
|
||||
|
||||
namespace Netch.ServerEx.ShadowsocksR
|
||||
namespace Netch.Servers.ShadowsocksR
|
||||
{
|
||||
public class SSRController : ServerController
|
||||
public class SSRController : Guard, IServerController
|
||||
{
|
||||
public SSRController()
|
||||
{
|
||||
Name = "ShadowsocksR";
|
||||
MainFile = "ShadowsocksR.exe";
|
||||
}
|
||||
public override string MainFile { get; protected set; } = "ShadowsocksR.exe";
|
||||
|
||||
public override string Name { get; protected set; } = "ShadowsocksR";
|
||||
|
||||
public override bool Start(Server s, Mode mode)
|
||||
public int? Socks5LocalPort { get; set; }
|
||||
public string LocalAddress { get; set; }
|
||||
|
||||
public bool Start(Server s, Mode mode)
|
||||
{
|
||||
var server = (ShadowsocksR) s;
|
||||
|
||||
#region Argument
|
||||
|
||||
var argument = new StringBuilder();
|
||||
argument.Append($"-s {server.Hostname} -p {server.Port} -k \"{server.Password}\" -m {server.EncryptMethod} -t 120");
|
||||
argument.Append($"-s {DNS.Lookup(server.Hostname)} -p {server.Port} -k \"{server.Password}\" -m {server.EncryptMethod} -t 120");
|
||||
if (!string.IsNullOrEmpty(server.Protocol))
|
||||
{
|
||||
argument.Append($" -O {server.Protocol}");
|
||||
@@ -32,7 +34,7 @@ namespace Netch.ServerEx.ShadowsocksR
|
||||
if (!string.IsNullOrEmpty(server.OBFSParam)) argument.Append($" -g \"{server.OBFSParam}\"");
|
||||
}
|
||||
|
||||
argument.Append($" -b {LocalAddress} -l {Socks5LocalPort} -u");
|
||||
argument.Append($" -b {LocalAddress ?? Global.Settings.LocalAddress} -l {Socks5LocalPort ?? Global.Settings.Socks5LocalPort} -u");
|
||||
if (mode.BypassChina) argument.Append(" --acl default.acl");
|
||||
|
||||
#endregion
|
||||
@@ -1,19 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
using Netch.Controllers;
|
||||
using Netch.Models;
|
||||
using Netch.ServerEx.ShadowsocksR.Form;
|
||||
using Netch.Servers.ShadowsocksR.Form;
|
||||
using Netch.Utils;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Netch.ServerEx.ShadowsocksR
|
||||
namespace Netch.Servers.ShadowsocksR
|
||||
{
|
||||
public class SSRUtil : IServerUtil
|
||||
{
|
||||
public ushort Priority { get; } = 1;
|
||||
public string TypeName { get; } = "SSR";
|
||||
public string FullName { get; } = "ShadowsocksR";
|
||||
|
||||
public string ShortName { get; } = "SR";
|
||||
public string[] UriScheme { get; } = {"ssr"};
|
||||
|
||||
public Server ParseJObject(JObject j)
|
||||
@@ -24,7 +25,7 @@ namespace Netch.ServerEx.ShadowsocksR
|
||||
|
||||
public void Edit(Server s)
|
||||
{
|
||||
new ShadowsocksRForm(s).ShowDialog();
|
||||
new ShadowsocksRForm((ShadowsocksR) s).ShowDialog();
|
||||
}
|
||||
|
||||
public void Create()
|
||||
@@ -42,7 +43,7 @@ namespace Netch.ServerEx.ShadowsocksR
|
||||
return "ssr://" + ShareLink.URLSafeBase64Encode($"{server.Hostname}:{server.Port}:{server.Protocol}:{server.EncryptMethod}:{server.OBFS}:{ShareLink.URLSafeBase64Encode(server.Password)}{paraStr}");
|
||||
}
|
||||
|
||||
public ServerController GetController()
|
||||
public IServerController GetController()
|
||||
{
|
||||
return new SSRController();
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using Netch.Models;
|
||||
|
||||
namespace Netch.ServerEx.ShadowsocksR
|
||||
namespace Netch.Servers.ShadowsocksR
|
||||
{
|
||||
public class ShadowsocksR : Server
|
||||
{
|
||||
15
Netch/Servers/Socks5/Form/Socks5Form.cs
Normal file
15
Netch/Servers/Socks5/Form/Socks5Form.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using Netch.Forms;
|
||||
|
||||
namespace Netch.Servers.Socks5.Form
|
||||
{
|
||||
public class Socks5Form : ServerForm
|
||||
{
|
||||
protected override string TypeName { get; } = "Socks5";
|
||||
|
||||
public Socks5Form(Socks5 server = default)
|
||||
{
|
||||
server ??= new Socks5();
|
||||
Server = server;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,18 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Netch.Controllers;
|
||||
using Netch.Models;
|
||||
using Netch.ServerEx.Socks5.Form;
|
||||
using Netch.Servers.Socks5.Form;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Netch.ServerEx.Socks5
|
||||
namespace Netch.Servers.Socks5
|
||||
{
|
||||
public class S5Util : IServerUtil
|
||||
{
|
||||
public ushort Priority { get; } = 0;
|
||||
public string TypeName { get; } = "Socks5";
|
||||
public string FullName { get; } = "Socks5";
|
||||
|
||||
public string ShortName { get; } = "S5";
|
||||
public string[] UriScheme { get; } = { };
|
||||
|
||||
public Server ParseJObject(JObject j)
|
||||
@@ -21,7 +22,7 @@ namespace Netch.ServerEx.Socks5
|
||||
|
||||
public void Edit(Server s)
|
||||
{
|
||||
new Socks5Form(s).ShowDialog();
|
||||
new Socks5Form((Socks5) s).ShowDialog();
|
||||
}
|
||||
|
||||
public void Create()
|
||||
@@ -35,7 +36,7 @@ namespace Netch.ServerEx.Socks5
|
||||
return $"https://t.me/socks?server={server.Hostname}&port={server.Port}";
|
||||
}
|
||||
|
||||
public ServerController GetController()
|
||||
public IServerController GetController()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
using Netch.Models;
|
||||
|
||||
namespace Netch.ServerEx.Socks5
|
||||
namespace Netch.Servers.Socks5
|
||||
{
|
||||
public class Socks5 : Server
|
||||
{
|
||||
23
Netch/Servers/Trojan/Form/TrojanForm.cs
Normal file
23
Netch/Servers/Trojan/Form/TrojanForm.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using Netch.Forms;
|
||||
|
||||
namespace Netch.Servers.Trojan.Form
|
||||
{
|
||||
public class TrojanForm : ServerForm
|
||||
{
|
||||
protected override string TypeName { get; } = "Trojan";
|
||||
|
||||
public TrojanForm(Trojan server = default)
|
||||
{
|
||||
server ??= new Trojan();
|
||||
Server = server;
|
||||
CreateTextBox("Password", "Password",
|
||||
s => true,
|
||||
s => server.Password = s,
|
||||
server.Password);
|
||||
CreateTextBox("Host", "Host",
|
||||
s => true,
|
||||
s => server.Host = s,
|
||||
server.Host);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Netch.ServerEx.Trojan.Models
|
||||
namespace Netch.Servers.Trojan.Models
|
||||
{
|
||||
public class TrojanConfig
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using Netch.Models;
|
||||
|
||||
namespace Netch.ServerEx.Trojan
|
||||
namespace Netch.Servers.Trojan
|
||||
{
|
||||
public class Trojan : Server
|
||||
{
|
||||
@@ -1,29 +1,35 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Netch.Controllers;
|
||||
using Netch.Models;
|
||||
using Netch.ServerEx.Trojan.Models;
|
||||
using Netch.Servers.Trojan.Models;
|
||||
using Netch.Utils;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Netch.ServerEx.Trojan
|
||||
namespace Netch.Servers.Trojan
|
||||
{
|
||||
public class TrojanController : ServerController
|
||||
public class TrojanController : Guard, IServerController
|
||||
{
|
||||
public TrojanController()
|
||||
{
|
||||
Name = "Trojan";
|
||||
MainFile = "Trojan.exe";
|
||||
StartedKeywords.Add("started");
|
||||
StoppedKeywords.Add("exiting");
|
||||
}
|
||||
|
||||
public override bool Start(Server s, Mode mode)
|
||||
public override string MainFile { get; protected set; } = "Trojan.exe";
|
||||
public override string Name { get; protected set; } = "Trojan";
|
||||
public int? Socks5LocalPort { get; set; }
|
||||
public string LocalAddress { get; set; }
|
||||
|
||||
|
||||
public bool Start(Server s, Mode mode)
|
||||
{
|
||||
var server = (Trojan) s;
|
||||
File.WriteAllText("data\\last.json", JsonConvert.SerializeObject(new TrojanConfig
|
||||
{
|
||||
local_addr = LocalAddress,
|
||||
local_port = Socks5LocalPort,
|
||||
remote_addr = server.Hostname,
|
||||
local_addr = LocalAddress ?? Global.Settings.LocalAddress,
|
||||
local_port = Socks5LocalPort ?? Global.Settings.Socks5LocalPort,
|
||||
remote_addr = DNS.Lookup(server.Hostname).ToString(),
|
||||
remote_port = server.Port,
|
||||
password = new List<string>
|
||||
{
|
||||
@@ -2,18 +2,19 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Web;
|
||||
using Netch.Controllers;
|
||||
using Netch.Models;
|
||||
using Netch.ServerEx.Trojan.Form;
|
||||
using Netch.Servers.Trojan.Form;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Netch.ServerEx.Trojan
|
||||
namespace Netch.Servers.Trojan
|
||||
{
|
||||
public class TrojanUtil : IServerUtil
|
||||
{
|
||||
public ushort Priority { get; } = 2;
|
||||
public ushort Priority { get; } = 3;
|
||||
public string TypeName { get; } = "Trojan";
|
||||
public string FullName { get; } = "Trojan";
|
||||
|
||||
public string ShortName { get; } = "TR";
|
||||
public string[] UriScheme { get; } = {"trojan"};
|
||||
|
||||
public Server ParseJObject(JObject j)
|
||||
@@ -23,7 +24,7 @@ namespace Netch.ServerEx.Trojan
|
||||
|
||||
public void Edit(Server s)
|
||||
{
|
||||
new TrojanForm(s).ShowDialog();
|
||||
new TrojanForm((Trojan) s).ShowDialog();
|
||||
}
|
||||
|
||||
public void Create()
|
||||
@@ -37,7 +38,7 @@ namespace Netch.ServerEx.Trojan
|
||||
return "";
|
||||
}
|
||||
|
||||
public ServerController GetController()
|
||||
public IServerController GetController()
|
||||
{
|
||||
return new TrojanController();
|
||||
}
|
||||
58
Netch/Servers/VMess/Form/VMessForm.cs
Normal file
58
Netch/Servers/VMess/Form/VMessForm.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using Netch.Forms;
|
||||
|
||||
namespace Netch.Servers.VMess.Form
|
||||
{
|
||||
public class VMessForm : ServerForm
|
||||
{
|
||||
protected override string TypeName { get; } = "VMess";
|
||||
|
||||
public VMessForm(VMess server = default)
|
||||
{
|
||||
server ??= new VMess();
|
||||
Server = server;
|
||||
CreateTextBox("UserId", "User ID",
|
||||
s => true,
|
||||
s => server.UserID = s,
|
||||
server.UserID);
|
||||
CreateTextBox("AlterId", "Alter ID",
|
||||
s => int.TryParse(s, out _),
|
||||
s => server.AlterID = int.Parse(s),
|
||||
server.AlterID.ToString(),
|
||||
76);
|
||||
CreateComboBox("EncryptMethod", "Encrypt Method",
|
||||
VMessGlobal.EncryptMethods,
|
||||
s => server.EncryptMethod = s,
|
||||
server.EncryptMethod);
|
||||
CreateComboBox("TransferProtocol", "Transfer Protocol",
|
||||
VMessGlobal.TransferProtocols,
|
||||
s => server.TransferProtocol = s,
|
||||
server.TransferProtocol);
|
||||
CreateComboBox("FakeType", "Fake Type",
|
||||
VMessGlobal.FakeTypes,
|
||||
s => server.FakeType = s,
|
||||
server.FakeType);
|
||||
CreateTextBox("Host", "Host",
|
||||
s => true,
|
||||
s => server.Host = s,
|
||||
server.Host);
|
||||
CreateTextBox("Path", "Path",
|
||||
s => true,
|
||||
s => server.Path = s,
|
||||
server.Path);
|
||||
CreateComboBox("QUICSecurity", "QUIC Security",
|
||||
VMessGlobal.QUIC,
|
||||
s => server.QUIC = s,
|
||||
server.QUIC);
|
||||
CreateTextBox("QUICSecret", "QUIC Secret",
|
||||
s => true,
|
||||
s => server.QUICSecret = s,
|
||||
server.QUICSecret);
|
||||
CreateCheckBox("UseMux", "Use Mux",
|
||||
s => server.UseMux = s,
|
||||
server.UseMux);
|
||||
CreateCheckBox("TLSSecure", "TLS Secure",
|
||||
s => server.TLSSecure = s,
|
||||
server.TLSSecure);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Netch.ServerEx.VMess.Models
|
||||
namespace Netch.Servers.VMess.Models
|
||||
{
|
||||
public class VMessConfig
|
||||
{
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Netch.ServerEx.VMess.Models
|
||||
namespace Netch.Servers.VMess.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 使用 v2rayN 定义的 VMess 链接格式
|
||||
@@ -1,7 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using Netch.Models;
|
||||
|
||||
namespace Netch.ServerEx.VMess
|
||||
namespace Netch.Servers.VMess
|
||||
{
|
||||
public class VMess : Server
|
||||
{
|
||||
@@ -1,22 +1,29 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Netch.Controllers;
|
||||
using Netch.Models;
|
||||
using Netch.ServerEx.VMess.Models;
|
||||
using Netch.Servers.VMess.Models;
|
||||
using Netch.Utils;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Netch.ServerEx.VMess
|
||||
namespace Netch.Servers.VMess
|
||||
{
|
||||
public class VMessController : ServerController
|
||||
public class VMessController : Guard, IServerController
|
||||
{
|
||||
public VMessController()
|
||||
{
|
||||
Name = "V2Ray";
|
||||
MainFile = "v2ray.exe";
|
||||
StartedKeywords.Add("started");
|
||||
StoppedKeywords.AddRange(new[] {"config file not readable", "failed to"});
|
||||
}
|
||||
|
||||
public override bool Start(Server s, Mode mode)
|
||||
|
||||
public override string Name { get; protected set; } = "V2Ray";
|
||||
public override string MainFile { get; protected set; } = "v2ray.exe";
|
||||
public int? Socks5LocalPort { get; set; }
|
||||
public string LocalAddress { get; set; }
|
||||
|
||||
|
||||
public bool Start(Server s, Mode mode)
|
||||
{
|
||||
var server = (VMess) s;
|
||||
File.WriteAllText("data\\last.json", JsonConvert.SerializeObject(new VMessConfig.Config()
|
||||
@@ -26,8 +33,8 @@ namespace Netch.ServerEx.VMess
|
||||
new VMessConfig.Inbounds
|
||||
{
|
||||
settings = new VMessConfig.InboundSettings(),
|
||||
port = Socks5LocalPort,
|
||||
listen = LocalAddress
|
||||
port = Socks5LocalPort ?? Global.Settings.Socks5LocalPort,
|
||||
listen = LocalAddress ?? Global.Settings.LocalAddress
|
||||
}
|
||||
},
|
||||
outbounds = new List<VMessConfig.Outbounds>
|
||||
@@ -40,7 +47,7 @@ namespace Netch.ServerEx.VMess
|
||||
{
|
||||
new VMessConfig.VNext
|
||||
{
|
||||
address = server.Hostname,
|
||||
address = DNS.Lookup(server.Hostname).ToString(),
|
||||
port = server.Port,
|
||||
users = new List<VMessConfig.User>
|
||||
{
|
||||
@@ -1,18 +1,20 @@
|
||||
using System.Collections.Generic;
|
||||
using Netch.Controllers;
|
||||
using Netch.Models;
|
||||
using Netch.ServerEx.VMess.Form;
|
||||
using Netch.ServerEx.VMess.Models;
|
||||
using Netch.Servers.VMess.Form;
|
||||
using Netch.Servers.VMess.Models;
|
||||
using Netch.Utils;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Netch.ServerEx.VMess
|
||||
namespace Netch.Servers.VMess
|
||||
{
|
||||
public class VMessUtil : IServerUtil
|
||||
{
|
||||
public ushort Priority { get; } = 2;
|
||||
public ushort Priority { get; } = 3;
|
||||
public string TypeName { get; } = "VMess";
|
||||
public string FullName { get; } = "VMess";
|
||||
public string ShortName { get; } = "V2";
|
||||
public string[] UriScheme { get; } = {"vmess"};
|
||||
|
||||
public Server ParseJObject(JObject j)
|
||||
@@ -22,7 +24,7 @@ namespace Netch.ServerEx.VMess
|
||||
|
||||
public void Edit(Server s)
|
||||
{
|
||||
new VMessForm(s).ShowDialog();
|
||||
new VMessForm((VMess) s).ShowDialog();
|
||||
}
|
||||
|
||||
public void Create()
|
||||
@@ -51,7 +53,7 @@ namespace Netch.ServerEx.VMess
|
||||
return "vmess://" + ShareLink.URLSafeBase64Encode(vmessJson);
|
||||
}
|
||||
|
||||
public ServerController GetController()
|
||||
public IServerController GetController()
|
||||
{
|
||||
return new VMessController();
|
||||
}
|
||||
@@ -73,11 +73,13 @@ namespace Netch.Utils
|
||||
}
|
||||
else if (MainController.ServerController != null)
|
||||
{
|
||||
instances.Add(MainController.ServerController.Instance);
|
||||
if (MainController.ServerController is Guard instanceController)
|
||||
instances.Add(instanceController.Instance);
|
||||
}
|
||||
else if (MainController.ModeController != null)
|
||||
{
|
||||
instances.Add(MainController.ModeController.Instance);
|
||||
if (MainController.ModeController is Guard instanceController)
|
||||
instances.Add(instanceController.Instance);
|
||||
}
|
||||
|
||||
var processList = instances.Select(instance => instance.Id).ToList();
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Netch.Utils
|
||||
|
||||
foreach (JObject server in settingJObject["Server"])
|
||||
{
|
||||
var serverResult = Servers.ParseJObject(server);
|
||||
var serverResult = ServerHelper.ParseJObject(server);
|
||||
if (serverResult != null)
|
||||
Global.Settings.Server.Add(serverResult);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ using NetFwTypeLib;
|
||||
|
||||
namespace Netch.Utils
|
||||
{
|
||||
public class Firewall
|
||||
public static class Firewall
|
||||
{
|
||||
private static readonly string[] ProgramPath =
|
||||
{
|
||||
|
||||
@@ -1,33 +1,30 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Management;
|
||||
using Netch.Utils;
|
||||
using Netch.Controllers;
|
||||
using Netch.Models.WinFW;
|
||||
using NETCONLib;
|
||||
using WinFW;
|
||||
|
||||
namespace Netch.Controllers
|
||||
namespace Netch.Utils
|
||||
{
|
||||
public class ICSController
|
||||
public static class ICSHelper
|
||||
{
|
||||
public static bool Enabled
|
||||
{
|
||||
get
|
||||
{
|
||||
TUNTAPController.SearchTapAdapter();
|
||||
foreach (NetworkConnection connection in new NetworkConnectionCollection())
|
||||
{
|
||||
if (connection.DeviceName == Global.TUNTAP.Adapter.Description)
|
||||
{
|
||||
return connection.SharingEnabled;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return (
|
||||
from NetworkConnection connection in new NetworkConnectionCollection()
|
||||
where connection.DeviceName == Global.TUNTAP.Adapter.Description
|
||||
select connection.SharingEnabled
|
||||
).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
|
||||
public static bool Enable()
|
||||
{
|
||||
Utils.Utils.SearchOutboundAdapter();
|
||||
Utils.SearchOutboundAdapter(false);
|
||||
TUNTAPController.SearchTapAdapter();
|
||||
|
||||
if (Global.TUNTAP.Adapter == null || Global.Outbound.Adapter == null)
|
||||
@@ -41,10 +38,7 @@ namespace Netch.Controllers
|
||||
|
||||
#region Save Outbound IP Config
|
||||
|
||||
var wmi = new ManagementClass("Win32_NetworkAdapterConfiguration");
|
||||
var moc = wmi.GetInstances();
|
||||
|
||||
var dhcpEnabled = true;
|
||||
bool dhcpEnabled;
|
||||
string[] ipAddress = null;
|
||||
string[] subnetMask = null;
|
||||
string[] gateway = null;
|
||||
@@ -101,19 +95,19 @@ namespace Netch.Controllers
|
||||
else
|
||||
{
|
||||
//Set static IP and subnet mask
|
||||
var newIP = outboundWmi.GetMethodParameters("EnableStatic");
|
||||
newIP["IPAddress"] = ipAddress;
|
||||
newIP["SubnetMask"] = subnetMask;
|
||||
outboundWmi.InvokeMethod("EnableStatic", newIP, null);
|
||||
var ip = outboundWmi.GetMethodParameters("EnableStatic");
|
||||
ip["IPAddress"] = ipAddress;
|
||||
ip["SubnetMask"] = subnetMask;
|
||||
outboundWmi.InvokeMethod("EnableStatic", ip, null);
|
||||
//Set default gateway
|
||||
var newGateway = outboundWmi.GetMethodParameters("SetGateways");
|
||||
newGateway["DefaultIPGateway"] = gateway;
|
||||
newGateway["GatewayCostMetric"] = gatewayMetric;
|
||||
outboundWmi.InvokeMethod("SetGateways", newGateway, null);
|
||||
//Set dns servers
|
||||
var newDNS = outboundWmi.GetMethodParameters("SetDNSServerSearchOrder");
|
||||
newDNS["DNSServerSearchOrder"] = dns;
|
||||
outboundWmi.InvokeMethod("SetDNSServerSearchOrder", newDNS, null);
|
||||
var newDns = outboundWmi.GetMethodParameters("SetDNSServerSearchOrder");
|
||||
newDns["DNSServerSearchOrder"] = dns;
|
||||
outboundWmi.InvokeMethod("SetDNSServerSearchOrder", newDns, null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -139,10 +133,9 @@ namespace Netch.Controllers
|
||||
|
||||
public static void Disable()
|
||||
{
|
||||
foreach (NetworkConnection connection in new NetworkConnectionCollection())
|
||||
foreach (var connection in new NetworkConnectionCollection().Cast<NetworkConnection>().Where(connection => connection.SharingEnabled))
|
||||
{
|
||||
if (connection.SharingEnabled)
|
||||
connection.DisableSharing();
|
||||
connection.DisableSharing();
|
||||
}
|
||||
|
||||
CleanupWMISharingEntries();
|
||||
@@ -153,25 +146,27 @@ namespace Netch.Controllers
|
||||
var scope = new ManagementScope("root\\Microsoft\\HomeNet");
|
||||
scope.Connect();
|
||||
|
||||
var options = new PutOptions();
|
||||
options.Type = PutType.UpdateOnly;
|
||||
|
||||
var query = new ObjectQuery("SELECT * FROM HNet_ConnectionProperties");
|
||||
var srchr = new ManagementObjectSearcher(scope, query);
|
||||
foreach (ManagementObject entry in srchr.Get())
|
||||
var searchResults = new ManagementObjectSearcher(scope, new ObjectQuery("SELECT * FROM HNet_ConnectionProperties"));
|
||||
foreach (var o in searchResults.Get())
|
||||
{
|
||||
var entry = (ManagementObject) o;
|
||||
if ((bool) entry["IsIcsPrivate"])
|
||||
entry["IsIcsPrivate"] = false;
|
||||
if ((bool) entry["IsIcsPublic"])
|
||||
entry["IsIcsPublic"] = false;
|
||||
entry.Put(options);
|
||||
|
||||
entry.Put(new PutOptions
|
||||
{
|
||||
Type = PutType.UpdateOnly
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static ManagementObject GetManagementObjectByDeviceNameOrDefault(string deviceName)
|
||||
private static ManagementObject GetManagementObjectByDeviceNameOrDefault(string deviceName)
|
||||
{
|
||||
foreach (ManagementObject mo in new ManagementClass("Win32_NetworkAdapterConfiguration").GetInstances())
|
||||
foreach (var o in new ManagementClass("Win32_NetworkAdapterConfiguration").GetInstances())
|
||||
{
|
||||
var mo = (ManagementObject) o;
|
||||
if (((string) mo["Caption"]).EndsWith(deviceName))
|
||||
{
|
||||
return mo;
|
||||
@@ -6,7 +6,7 @@ using Netch.Models;
|
||||
|
||||
namespace Netch.Utils
|
||||
{
|
||||
public static class Modes
|
||||
public static class ModeHelper
|
||||
{
|
||||
private const string MODE_DIR = "mode";
|
||||
|
||||
@@ -64,18 +64,17 @@ namespace Netch.Utils
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
var splited = text.Substring(text.IndexOf('#') + 1).Split(',').Select(s => s.Trim()).ToArray();
|
||||
try
|
||||
{
|
||||
string tmp;
|
||||
if ((tmp = splited.ElementAtOrDefault(0)) != null)
|
||||
mode.Remark = i18N.Translate(tmp);
|
||||
var splited = text.Substring(text.IndexOf('#') + 1).Split(',').Select(s => s.Trim()).ToArray();
|
||||
|
||||
tmp = splited.ElementAtOrDefault(1);
|
||||
mode.Type = tmp != null ? int.Parse(tmp) : 0;
|
||||
mode.Remark = splited[0];
|
||||
|
||||
if ((tmp = splited.ElementAtOrDefault(2)) != null)
|
||||
mode.BypassChina = int.Parse(tmp) == 1;
|
||||
var result = int.TryParse(splited.ElementAtOrDefault(1), out var type);
|
||||
mode.Type = result ? type : 0;
|
||||
|
||||
var result1 = int.TryParse(splited.ElementAtOrDefault(2), out var bypassChina);
|
||||
mode.BypassChina = result1 && bypassChina == 1;
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -5,7 +5,7 @@ using System.Text;
|
||||
|
||||
namespace Netch.Utils
|
||||
{
|
||||
public class OnlyInstance
|
||||
public static class OnlyInstance
|
||||
{
|
||||
public enum Commands
|
||||
{
|
||||
|
||||
@@ -7,11 +7,11 @@ using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Netch.Utils
|
||||
{
|
||||
public static class Servers
|
||||
public static class ServerHelper
|
||||
{
|
||||
public static readonly IEnumerable<IServerUtil> ServerUtils;
|
||||
|
||||
static Servers()
|
||||
static ServerHelper()
|
||||
{
|
||||
var serversUtilsTypes = Assembly.GetExecutingAssembly().GetExportedTypes().Where(type => type.GetInterfaces().Any(t => t == typeof(IServerUtil)));
|
||||
ServerUtils = serversUtilsTypes.Select(t => (IServerUtil) Activator.CreateInstance(t)).OrderBy(util => util.Priority);
|
||||
@@ -3,8 +3,8 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Netch.ServerEx.Shadowsocks;
|
||||
using Netch.ServerEx.Shadowsocks.Models;
|
||||
using Netch.Servers.Shadowsocks;
|
||||
using Netch.Servers.Shadowsocks.Models;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Server = Netch.Models.Server;
|
||||
@@ -105,7 +105,7 @@ namespace Netch.Utils
|
||||
|
||||
public static string GetShareLink(Server server)
|
||||
{
|
||||
return Servers.GetUtilByTypeName(server.Type).GetShareLink(server);
|
||||
return ServerHelper.GetUtilByTypeName(server.Type).GetShareLink(server);
|
||||
}
|
||||
|
||||
public static List<Server> ParseText(string text)
|
||||
@@ -169,7 +169,7 @@ namespace Netch.Utils
|
||||
{
|
||||
if (text.StartsWith("tg://socks?") || text.StartsWith("https://t.me/socks?"))
|
||||
{
|
||||
list.AddRange(Servers.GetUtilByTypeName("Socks5").ParseUri(text));
|
||||
list.AddRange(ServerHelper.GetUtilByTypeName("Socks5").ParseUri(text));
|
||||
}
|
||||
else if (text.StartsWith("Netch://"))
|
||||
{
|
||||
@@ -178,7 +178,7 @@ namespace Netch.Utils
|
||||
else
|
||||
{
|
||||
var scheme = GetUriScheme(text);
|
||||
var util = Servers.GetUtilByUriScheme(scheme);
|
||||
var util = ServerHelper.GetUtilByUriScheme(scheme);
|
||||
if (util == null)
|
||||
{
|
||||
Logging.Warning($"无法处理 {scheme} 协议订阅链接");
|
||||
@@ -230,8 +230,8 @@ namespace Netch.Utils
|
||||
}
|
||||
|
||||
var type = (string) NetchLink["Type"];
|
||||
var s = Servers.GetUtilByTypeName(type).ParseJObject(NetchLink);
|
||||
return Servers.GetUtilByTypeName(s.Type).CheckServer(s) ? s : null;
|
||||
var s = ServerHelper.GetUtilByTypeName(type).ParseJObject(NetchLink);
|
||||
return ServerHelper.GetUtilByTypeName(s.Type).CheckServer(s) ? s : null;
|
||||
}
|
||||
|
||||
public static string GetNetchLink(Server s)
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace Netch.Utils
|
||||
/// <returns>适配器名称</returns>
|
||||
public static string GetName(string componentId)
|
||||
{
|
||||
var registry = Registry.LocalMachine.OpenSubKey(string.Format("{0}\\{1}\\Connection", NETWORK_KEY, componentId));
|
||||
var registry = Registry.LocalMachine.OpenSubKey($"{NETWORK_KEY}\\{componentId}\\Connection");
|
||||
|
||||
return registry.GetValue("Name", "").ToString();
|
||||
}
|
||||
@@ -70,7 +70,7 @@ namespace Netch.Utils
|
||||
/// </summary>
|
||||
public static void deltapall()
|
||||
{
|
||||
Logging.Info("正在卸载 TUN/TAP 适配器");
|
||||
Logging.Info("卸载 TUN/TAP 适配器");
|
||||
var installProcess = new Process {StartInfo = {WindowStyle = ProcessWindowStyle.Hidden, FileName = Path.Combine("bin/tap-driver", "deltapall.bat")}};
|
||||
installProcess.Start();
|
||||
installProcess.WaitForExit();
|
||||
@@ -82,7 +82,7 @@ namespace Netch.Utils
|
||||
/// </summary>
|
||||
public static void addtap()
|
||||
{
|
||||
Logging.Info("正在安装 TUN/TAP 适配器");
|
||||
Logging.Info("安装 TUN/TAP 适配器");
|
||||
//安装Tap Driver
|
||||
var installProcess = new Process {StartInfo = {WindowStyle = ProcessWindowStyle.Hidden, FileName = Path.Combine("bin/tap-driver", "addtap.bat")}};
|
||||
installProcess.Start();
|
||||
|
||||
@@ -96,9 +96,9 @@ namespace Netch.Utils
|
||||
{
|
||||
try
|
||||
{
|
||||
var SHA256 = System.Security.Cryptography.SHA256.Create();
|
||||
var sha256 = System.Security.Cryptography.SHA256.Create();
|
||||
var fileStream = File.OpenRead(filePath);
|
||||
return SHA256.ComputeHash(fileStream).Aggregate(string.Empty, (current, b) => current + b.ToString("x2"));
|
||||
return sha256.ComputeHash(fileStream).Aggregate(string.Empty, (current, b) => current + b.ToString("x2"));
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -124,49 +124,40 @@ namespace Netch.Utils
|
||||
}
|
||||
}
|
||||
|
||||
public static string FileVersion(string file) => File.Exists(file) ? FileVersionInfo.GetVersionInfo(file).FileVersion : string.Empty;
|
||||
public static string GetFileVersion(string file) => File.Exists(file) ? FileVersionInfo.GetVersionInfo(file).FileVersion : string.Empty;
|
||||
|
||||
public static bool SearchOutboundAdapter(bool log = true)
|
||||
public static bool SearchOutboundAdapter(bool logging = true)
|
||||
{
|
||||
IPAddress localEnd;
|
||||
try
|
||||
{
|
||||
localEnd = WebUtil.BestLocalEndPoint(new IPEndPoint(0x72727272, 53)).Address;
|
||||
}
|
||||
catch
|
||||
// 寻找出口适配器
|
||||
if (Win32Native.GetBestRoute(BitConverter.ToUInt32(IPAddress.Parse("114.114.114.114").GetAddressBytes(), 0),
|
||||
0, out var pRoute) != 0)
|
||||
{
|
||||
Logging.Error("GetBestRoute 搜索失败");
|
||||
return false;
|
||||
}
|
||||
|
||||
Global.Outbound.Index = pRoute.dwForwardIfIndex;
|
||||
// 根据 IP Index 寻找 出口适配器
|
||||
try
|
||||
{
|
||||
// 根据 IP 寻找 出口适配器
|
||||
Global.Outbound.Adapter = NetworkInterface.GetAllNetworkInterfaces().First(_ =>
|
||||
var adapter = NetworkInterface.GetAllNetworkInterfaces().First(_ =>
|
||||
{
|
||||
try
|
||||
{
|
||||
return _.GetIPProperties().UnicastAddresses.Any(ip =>
|
||||
{
|
||||
if (ip.Address.AddressFamily == AddressFamily.InterNetwork && ip.Address.ToString().Equals(localEnd.ToString()))
|
||||
{
|
||||
Global.Outbound.Index = _.GetIPProperties().GetIPv4Properties().Index;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
return _.GetIPProperties().GetIPv4Properties().Index == Global.Outbound.Index;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
});
|
||||
Global.Outbound.Gateway = Global.Outbound.Adapter.GetIPProperties().GatewayAddresses[0].Address;
|
||||
if (log)
|
||||
Global.Outbound.Adapter = adapter;
|
||||
Global.Outbound.Gateway = new IPAddress(pRoute.dwForwardNextHop);
|
||||
if (logging)
|
||||
{
|
||||
Logging.Info($"出口 IPv4 地址:{Global.Outbound.Address}");
|
||||
Logging.Info($"出口 网关 地址:{Global.Outbound.Gateway}");
|
||||
Logging.Info($"出口适配器:{Global.Outbound.Adapter.Name} {Global.Outbound.Adapter.Id} {Global.Outbound.Adapter.Description}, index: {Global.Outbound.Index}");
|
||||
Logging.Info($"出口适配器:{adapter.Name} {adapter.Id} {adapter.Description}, index: {Global.Outbound.Index}");
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Netch.Utils
|
||||
{
|
||||
public class WebUtil
|
||||
public static class WebUtil
|
||||
{
|
||||
public const string DefaultUserAgent =
|
||||
@"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.70 Safari/537.36";
|
||||
|
||||
@@ -1,11 +1,347 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace Netch
|
||||
{
|
||||
public static class Win32Native
|
||||
{
|
||||
public enum ForwardType
|
||||
{
|
||||
Other = 1,
|
||||
Invalid = 2,
|
||||
Direct = 3,
|
||||
Indirect = 4
|
||||
}
|
||||
|
||||
public enum ForwardProtocol
|
||||
{
|
||||
Other = 1,
|
||||
Local = 2,
|
||||
NetMGMT = 3,
|
||||
ICMP = 4,
|
||||
EGP = 5,
|
||||
GGP = 6,
|
||||
Hello = 7,
|
||||
RIP = 8,
|
||||
IS_IS = 9,
|
||||
ES_IS = 10, // 0x0000000A
|
||||
CISCO = 11, // 0x0000000B
|
||||
BBN = 12, // 0x0000000C
|
||||
OSPF = 13, // 0x0000000D
|
||||
BGP = 14, // 0x0000000E
|
||||
NT_AUTOSTATIC = 10002, // 0x00002712
|
||||
NT_STATIC = 10006, // 0x00002716
|
||||
NT_STATIC_NON_DOD = 10007 // 0x00002717
|
||||
}
|
||||
|
||||
public class RouteEntry
|
||||
{
|
||||
internal MIB_IPFORWARDROW _ipFwdNative;
|
||||
private int _metric1;
|
||||
private int _metric2;
|
||||
private int _metric3;
|
||||
private int _metric4;
|
||||
private int _metric5;
|
||||
private IPAddress _destination;
|
||||
private IPAddress _mask;
|
||||
private int _policy;
|
||||
private IPAddress _nextHop;
|
||||
private NetworkInterface _interface;
|
||||
private ForwardProtocol _protocol;
|
||||
private ForwardType _type;
|
||||
private int _nextHopAS;
|
||||
private int _age;
|
||||
private int _index;
|
||||
|
||||
public int Index
|
||||
{
|
||||
get => _index;
|
||||
set => _index = value;
|
||||
}
|
||||
|
||||
public IPAddress Destination
|
||||
{
|
||||
get => _destination;
|
||||
set => _destination = value;
|
||||
}
|
||||
|
||||
public IPAddress Mask
|
||||
{
|
||||
get => _mask;
|
||||
set => _mask = value;
|
||||
}
|
||||
|
||||
public int Policy
|
||||
{
|
||||
get => _policy;
|
||||
set => _policy = value;
|
||||
}
|
||||
|
||||
public IPAddress NextHop
|
||||
{
|
||||
get => _nextHop;
|
||||
set => _nextHop = value;
|
||||
}
|
||||
|
||||
public NetworkInterface RelatedInterface => _interface;
|
||||
|
||||
public string InterfaceName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (RelatedInterface == null)
|
||||
return string.Empty;
|
||||
return RelatedInterface.Name;
|
||||
}
|
||||
}
|
||||
|
||||
public ForwardType ForwardType
|
||||
{
|
||||
get => _type;
|
||||
set => _type = value;
|
||||
}
|
||||
|
||||
public ForwardProtocol Protocol
|
||||
{
|
||||
get => _protocol;
|
||||
set => _protocol = value;
|
||||
}
|
||||
|
||||
public int Age
|
||||
{
|
||||
get => _age;
|
||||
set => _age = value;
|
||||
}
|
||||
|
||||
public int NextHopAS
|
||||
{
|
||||
get => _nextHopAS;
|
||||
set => _nextHopAS = value;
|
||||
}
|
||||
|
||||
public int Metric1
|
||||
{
|
||||
get => _metric1;
|
||||
set => _metric1 = value;
|
||||
}
|
||||
|
||||
public int Metric2
|
||||
{
|
||||
get => _metric2;
|
||||
set => _metric2 = value;
|
||||
}
|
||||
|
||||
public int Metric3
|
||||
{
|
||||
get => _metric3;
|
||||
set => _metric3 = value;
|
||||
}
|
||||
|
||||
public int Metric4
|
||||
{
|
||||
get => _metric4;
|
||||
set => _metric4 = value;
|
||||
}
|
||||
|
||||
public int Metric5
|
||||
{
|
||||
get => _metric5;
|
||||
set => _metric5 = value;
|
||||
}
|
||||
|
||||
public RouteEntry(
|
||||
uint destination,
|
||||
uint mask,
|
||||
int policy,
|
||||
uint nextHop,
|
||||
NetworkInterface intf,
|
||||
ForwardType type,
|
||||
ForwardProtocol proto,
|
||||
int age,
|
||||
int nextHopAS,
|
||||
int metric1,
|
||||
int metric2,
|
||||
int metric3,
|
||||
int metric4,
|
||||
int metric5,
|
||||
int idx)
|
||||
{
|
||||
_age = age;
|
||||
_policy = policy;
|
||||
_protocol = proto;
|
||||
_type = type;
|
||||
_destination = new IPAddress(destination);
|
||||
_mask = new IPAddress(mask);
|
||||
_nextHop = new IPAddress(nextHop);
|
||||
_nextHopAS = nextHopAS;
|
||||
_interface = intf;
|
||||
_metric1 = metric1;
|
||||
_metric2 = metric2;
|
||||
_metric3 = metric3;
|
||||
_metric4 = metric4;
|
||||
_metric5 = metric5;
|
||||
_index = idx;
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
||||
public struct MIB_IFROW
|
||||
{
|
||||
private const int MAX_INTERFACE_NAME_LEN = 256;
|
||||
private const int MAXLEN_IFDESCR = 256;
|
||||
private const int MAXLEN_PHYSADDR = 8;
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
|
||||
public string wszName;
|
||||
public int dwIndex;
|
||||
public int dwType;
|
||||
public int dwMtu;
|
||||
public int dwSpeed;
|
||||
public int dwPhysAddrLen;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
|
||||
public byte[] bPhysAddr;
|
||||
public int dwAdminStatus;
|
||||
public int dwOperStatus;
|
||||
public int dwLastChange;
|
||||
public int dwInOctets;
|
||||
public int dwInUcastPkts;
|
||||
public int dwInNUcastPkts;
|
||||
public int dwInDiscards;
|
||||
public int dwInErrors;
|
||||
public int dwInUnknownProtos;
|
||||
public int dwOutOctets;
|
||||
public int dwOutUcastPkts;
|
||||
public int dwOutNUcastPkts;
|
||||
public int dwOutDiscards;
|
||||
public int dwOutErrors;
|
||||
public int dwOutQLen;
|
||||
public int dwDescrLen;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
|
||||
public byte[] bDescr;
|
||||
}
|
||||
|
||||
public class AdaptersTable
|
||||
{
|
||||
private Dictionary<int, NetworkInterface> _adapters = new Dictionary<int, NetworkInterface>();
|
||||
|
||||
public IDictionary<int, NetworkInterface> GetAdapters()
|
||||
{
|
||||
return _adapters;
|
||||
}
|
||||
|
||||
public NetworkInterface GetAdapter(int interfaceIndex)
|
||||
{
|
||||
NetworkInterface networkInterface = null;
|
||||
_adapters.TryGetValue(interfaceIndex, out networkInterface);
|
||||
return networkInterface;
|
||||
}
|
||||
|
||||
public int GetAdapterIndex(NetworkInterface networkInterface)
|
||||
{
|
||||
return _adapters.First(a => a.Value == networkInterface).Key;
|
||||
}
|
||||
|
||||
public AdaptersTable()
|
||||
{
|
||||
var num1 = IntPtr.Zero;
|
||||
var pdwSize = 0;
|
||||
var num2 = 0;
|
||||
num2 = GetIfTable(IntPtr.Zero, ref pdwSize, true);
|
||||
var networkInterfaces = NetworkInterface.GetAllNetworkInterfaces();
|
||||
try
|
||||
{
|
||||
num1 = Marshal.AllocHGlobal(pdwSize);
|
||||
if (GetIfTable(num1, ref pdwSize, true) != 0)
|
||||
return;
|
||||
var num3 = Marshal.ReadInt32(num1);
|
||||
var ptr = new IntPtr(num1.ToInt32() + 4);
|
||||
for (var index = 0; index < num3; ++index)
|
||||
{
|
||||
var structure = (MIB_IFROW)Marshal.PtrToStructure(ptr, typeof(MIB_IFROW));
|
||||
var pIfRow = new MIB_IFROW();
|
||||
pIfRow.dwIndex = structure.dwIndex;
|
||||
if (GetIfEntry(ref pIfRow) == 0)
|
||||
{
|
||||
var str = Encoding.ASCII.GetString(structure.bDescr, 0, pIfRow.dwDescrLen - 1);
|
||||
foreach (var networkInterface in networkInterfaces)
|
||||
{
|
||||
if (networkInterface.Description == str)
|
||||
{
|
||||
_adapters.Add(structure.dwIndex, networkInterface);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
ptr = new IntPtr(ptr.ToInt32() + Marshal.SizeOf(typeof(MIB_IFROW)));
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
finally
|
||||
{
|
||||
Marshal.FreeHGlobal(num1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public struct MIB_IPFORWARDROW
|
||||
{
|
||||
public uint dwForwardDest;
|
||||
public uint dwForwardMask;
|
||||
public int dwForwardPolicy;
|
||||
public uint dwForwardNextHop;
|
||||
public int dwForwardIfIndex;
|
||||
public ForwardType dwForwardType;
|
||||
public ForwardProtocol dwForwardProto;
|
||||
public int dwForwardAge;
|
||||
public int dwForwardNextHopAS;
|
||||
public int dwForwardMetric1;
|
||||
public int dwForwardMetric2;
|
||||
public int dwForwardMetric3;
|
||||
public int dwForwardMetric4;
|
||||
public int dwForwardMetric5;
|
||||
|
||||
public static implicit operator MIB_IPFORWARDROW(RouteEntry value)
|
||||
{
|
||||
var mibIpforwardrow = new MIB_IPFORWARDROW();
|
||||
mibIpforwardrow.dwForwardAge = value.Age;
|
||||
mibIpforwardrow.dwForwardDest = BitConverter.ToUInt32(value.Destination.GetAddressBytes(), 0);
|
||||
mibIpforwardrow.dwForwardMask = BitConverter.ToUInt32(value.Mask.GetAddressBytes(), 0);
|
||||
mibIpforwardrow.dwForwardMetric1 = value.Metric1;
|
||||
mibIpforwardrow.dwForwardMetric2 = value.Metric2;
|
||||
mibIpforwardrow.dwForwardMetric3 = value.Metric3;
|
||||
mibIpforwardrow.dwForwardMetric4 = value.Metric4;
|
||||
mibIpforwardrow.dwForwardMetric5 = value.Metric5;
|
||||
mibIpforwardrow.dwForwardNextHop = BitConverter.ToUInt32(value.NextHop.GetAddressBytes(), 0);
|
||||
mibIpforwardrow.dwForwardNextHopAS = value.NextHopAS;
|
||||
mibIpforwardrow.dwForwardPolicy = value.Policy;
|
||||
mibIpforwardrow.dwForwardProto = value.Protocol;
|
||||
mibIpforwardrow.dwForwardType = value.ForwardType;
|
||||
var adaptersTable = new AdaptersTable();
|
||||
mibIpforwardrow.dwForwardIfIndex = adaptersTable.GetAdapterIndex(value.RelatedInterface);
|
||||
return mibIpforwardrow;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("iphlpapi", SetLastError = true)]
|
||||
public static extern int GetIfTable(IntPtr pIfTable, ref int pdwSize, bool bOrder);
|
||||
|
||||
[DllImport("iphlpapi", SetLastError = true)]
|
||||
public static extern int GetIfEntry(ref MIB_IFROW pIfRow);
|
||||
|
||||
[DllImport("iphlpapi", SetLastError = true)]
|
||||
public static extern int GetBestRoute(uint dwDestAddr, int dwSourceAddr, out MIB_IPFORWARDROW pRoute);
|
||||
|
||||
[DllImport("User32", CharSet = CharSet.Auto, ExactSpelling = true)]
|
||||
public static extern IntPtr GetForegroundWindow();
|
||||
|
||||
[DllImport("WinINet")]
|
||||
public static extern bool InternetSetOption(IntPtr hInternet, int dwOption, IntPtr lpBuffer, int dwBufferLength);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
3
Test/.gitignore
vendored
Normal file
3
Test/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
/bin
|
||||
/obj
|
||||
/Netch.csproj.user
|
||||
35
Test/Properties/AssemblyInfo.cs
Normal file
35
Test/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Test")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Test")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2020")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("53397641-35CA-4336-8E22-2CE12EF476AC")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
64
Test/Test.csproj
Normal file
64
Test/Test.csproj
Normal file
@@ -0,0 +1,64 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{53397641-35CA-4336-8E22-2CE12EF476AC}</ProjectGuid>
|
||||
<ProjectTypeGuids>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Test</RootNamespace>
|
||||
<AssemblyName>Test</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="nunit.framework, Version=3.5.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb">
|
||||
<HintPath>..\packages\NUnit.3.5.0\lib\net45\nunit.framework.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Tests.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Netch\Netch.csproj">
|
||||
<Project>{4b041b91-5790-4571-8c58-c63ffe4bc9f8}</Project>
|
||||
<Name>Netch</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
|
||||
</Project>
|
||||
52
Test/Tests.cs
Normal file
52
Test/Tests.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using Netch.Servers.ShadowsocksR.Form;
|
||||
using Netch.Servers.ShadowsocksR;
|
||||
using Netch.Servers.VMess;
|
||||
using Netch.Servers.VMess.Form;
|
||||
using Netch.Utils;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Test
|
||||
{
|
||||
[TestFixture]
|
||||
public class Tests
|
||||
{
|
||||
[Test]
|
||||
public void TestServerForm()
|
||||
{
|
||||
i18N.Load("zh-CN");
|
||||
|
||||
var server = ParseVMessUri();
|
||||
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new VMessForm(server));
|
||||
}
|
||||
|
||||
private static ShadowsocksR ParseSSRUri()
|
||||
{
|
||||
return (ShadowsocksR) new SSRUtil().ParseUri(@"ssr://MTI3LjAuMC4xOjEyMzQ6YXV0aF9hZXMxMjhfbWQ1OmFlcy0xMjgtY2ZiOnRsczEuMl90aWNrZXRfYXV0aDpZV0ZoWW1KaS8_b2Jmc3BhcmFtPVluSmxZV3QzWVRFeExtMXZaUSZyZW1hcmtzPTVyV0w2Sy1WNUxpdDVwYUg").First();
|
||||
}
|
||||
|
||||
private static VMess ParseVMessUri()
|
||||
{
|
||||
/*
|
||||
{
|
||||
"v": "2",
|
||||
"ps": "备注别名",
|
||||
"add": "111.111.111.111",
|
||||
"port": "32000",
|
||||
"id": "1386f85e-657b-4d6e-9d56-78badb75e1fd",
|
||||
"aid": "100",
|
||||
"net": "tcp",
|
||||
"type": "none",
|
||||
"host": "www.bbb.com",
|
||||
"path": "/",
|
||||
"tls": "tls"
|
||||
}
|
||||
*/
|
||||
return (VMess) new VMessUtil().ParseUri(@"vmess://eyAidiI6ICIyIiwgInBzIjogIuWkh+azqOWIq+WQjSIsICJhZGQiOiAiMTExLjExMS4xMTEuMTExIiwgInBvcnQiOiAiMzIwMDAiLCAiaWQiOiAiMTM4NmY4NWUtNjU3Yi00ZDZlLTlkNTYtNzhiYWRiNzVlMWZkIiwgImFpZCI6ICIxMDAiLCAibmV0IjogInRjcCIsICJ0eXBlIjogIm5vbmUiLCAiaG9zdCI6ICJ3d3cuYmJiLmNvbSIsICJwYXRoIjogIi8iLCAidGxzIjogInRscyIgfQ==").First();
|
||||
}
|
||||
}
|
||||
}
|
||||
4
Test/packages.config
Normal file
4
Test/packages.config
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="NUnit" version="3.5.0" targetFramework="net45" />
|
||||
</packages>
|
||||
2
binaries
2
binaries
Submodule binaries updated: 01ec02ddd9...fb15d4bffd
2
modes
2
modes
Submodule modes updated: 309536b9b1...034c8583ad
Submodule translations updated: 06e77dc2b1...9ee3747784
Reference in New Issue
Block a user