mirror of
https://github.com/netchx/netch.git
synced 2026-05-11 23:45:06 +08:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
af5100fe73 | ||
|
|
f8bcef7ac9 | ||
|
|
591f8e5a5c | ||
|
|
00047a5030 | ||
|
|
6d4dab573e | ||
|
|
141fc58df4 | ||
|
|
4210f36814 |
@@ -15,7 +15,7 @@ namespace Netch.Controllers
|
||||
public const string Name = @"Netch";
|
||||
public const string Copyright = @"Copyright © 2019 - 2020";
|
||||
|
||||
public const string AssemblyVersion = @"1.6.3";
|
||||
public const string AssemblyVersion = @"1.6.4";
|
||||
private const string Suffix = @"";
|
||||
|
||||
public static readonly string Version = $"{AssemblyVersion}{(string.IsNullOrEmpty(Suffix) ? "" : $"-{Suffix}")}";
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace Netch.Forms
|
||||
{
|
||||
FileName = Path.Combine(Global.NetchDir, "NetchUpdater.exe"),
|
||||
Arguments =
|
||||
$"{Global.Settings.UDPSocketPort}|{fileFullPath}|{Global.NetchDir}"
|
||||
$"{Global.Settings.UDPSocketPort} \"{fileFullPath}\" \"{Global.NetchDir}\""
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
867
Netch/Forms/SettingForm.Designer.cs
generated
867
Netch/Forms/SettingForm.Designer.cs
generated
File diff suppressed because it is too large
Load Diff
@@ -1,11 +1,11 @@
|
||||
using System;
|
||||
using Netch.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Netch.Controllers;
|
||||
using Netch.Utils;
|
||||
using TaskScheduler;
|
||||
|
||||
namespace Netch.Forms
|
||||
@@ -15,30 +15,108 @@ namespace Netch.Forms
|
||||
public SettingForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
InitText();
|
||||
i18N.TranslateForm(this);
|
||||
InitValue();
|
||||
}
|
||||
|
||||
|
||||
private void SettingForm2_Load(object sender, EventArgs e)
|
||||
{
|
||||
Task.Run(() => BeginInvoke(new Action(() => UseFakeDNSCheckBox.Visible = Global.Flags.SupportFakeDns)));
|
||||
}
|
||||
|
||||
private void InitValue()
|
||||
{
|
||||
// Local Port
|
||||
Socks5PortTextBox.Text = Global.Settings.Socks5LocalPort.ToString();
|
||||
HTTPPortTextBox.Text = Global.Settings.HTTPLocalPort.ToString();
|
||||
RedirectorTextBox.Text = Global.Settings.RedirectorTCPPort.ToString();
|
||||
AllowDevicesCheckBox.Checked = Global.Settings.LocalAddress switch
|
||||
{
|
||||
"127.0.0.1" => false,
|
||||
"0.0.0.0" => true,
|
||||
_ => false
|
||||
};
|
||||
#region General
|
||||
|
||||
// TUN/TAP
|
||||
TUNTAPAddressTextBox.Text = Global.Settings.TUNTAP.Address;
|
||||
TUNTAPNetmaskTextBox.Text = Global.Settings.TUNTAP.Netmask;
|
||||
TUNTAPGatewayTextBox.Text = Global.Settings.TUNTAP.Gateway;
|
||||
UseCustomDNSCheckBox.Checked = Global.Settings.TUNTAP.UseCustomDNS;
|
||||
BindTextBox<ushort>(Socks5PortTextBox,
|
||||
p => CheckPort("Socks5", p, Global.Settings.Socks5LocalPort),
|
||||
p => Global.Settings.Socks5LocalPort = p,
|
||||
Global.Settings.Socks5LocalPort);
|
||||
BindTextBox<ushort>(HTTPPortTextBox,
|
||||
p => CheckPort("HTTP", p, Global.Settings.HTTPLocalPort),
|
||||
p => Global.Settings.HTTPLocalPort = p,
|
||||
Global.Settings.HTTPLocalPort);
|
||||
BindTextBox<ushort>(RedirectorTextBox,
|
||||
s => CheckPort("RedirectorTCP", s, Global.Settings.RedirectorTCPPort),
|
||||
s => Global.Settings.RedirectorTCPPort = s,
|
||||
Global.Settings.HTTPLocalPort);
|
||||
BindCheckBox(AllowDevicesCheckBox,
|
||||
c => Global.Settings.LocalAddress = AllowDevicesCheckBox.Checked ? "0.0.0.0" : "127.0.0.1",
|
||||
Global.Settings.LocalAddress switch
|
||||
{
|
||||
"127.0.0.1" => false,
|
||||
"0.0.0.0" => true,
|
||||
_ => false
|
||||
});
|
||||
|
||||
|
||||
BindCheckBox(BootShadowsocksFromDLLCheckBox,
|
||||
c => Global.Settings.BootShadowsocksFromDLL = c,
|
||||
Global.Settings.BootShadowsocksFromDLL);
|
||||
BindCheckBox(ResolveServerHostnameCheckBox,
|
||||
c => Global.Settings.ResolveServerHostname = c,
|
||||
Global.Settings.ResolveServerHostname);
|
||||
|
||||
BindTextBox<int>(ProfileCountTextBox,
|
||||
i => i > -1,
|
||||
i => Global.Settings.ProfileCount = i,
|
||||
Global.Settings.ProfileCount);
|
||||
BindCheckBox(TcpingAtStartedCheckBox,
|
||||
b => Global.Settings.StartedTcping = b,
|
||||
Global.Settings.StartedTcping);
|
||||
BindTextBox<int>(DetectionIntervalTextBox,
|
||||
i => i >= 0,
|
||||
i => Global.Settings.StartedTcping_Interval = i,
|
||||
Global.Settings.StartedTcping_Interval);
|
||||
|
||||
InitSTUN();
|
||||
|
||||
BindTextBox<string>(AclAddrTextBox,
|
||||
s => true,
|
||||
s => Global.Settings.ACL = s,
|
||||
Global.Settings.ACL);
|
||||
AclAddrTextBox.Text = Global.Settings.ACL;
|
||||
|
||||
LanguageComboBox.Items.AddRange(i18N.GetTranslateList().ToArray());
|
||||
LanguageComboBox.SelectedItem = Global.Settings.Language;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Process Mode
|
||||
|
||||
BindCheckBox(ModifySystemDNSCheckBox,
|
||||
b => Global.Settings.ModifySystemDNS = b,
|
||||
Global.Settings.ModifySystemDNS);
|
||||
|
||||
#endregion
|
||||
|
||||
#region TUN/TAP
|
||||
|
||||
BindTextBox(TUNTAPAddressTextBox,
|
||||
s => IPAddress.TryParse(s, out _),
|
||||
s => Global.Settings.TUNTAP.Address = s,
|
||||
Global.Settings.TUNTAP.Address);
|
||||
BindTextBox(TUNTAPNetmaskTextBox,
|
||||
s => IPAddress.TryParse(s, out _),
|
||||
s => Global.Settings.TUNTAP.Netmask = s,
|
||||
Global.Settings.TUNTAP.Netmask);
|
||||
BindTextBox(TUNTAPGatewayTextBox,
|
||||
s => IPAddress.TryParse(s, out _),
|
||||
s => Global.Settings.TUNTAP.Gateway = s,
|
||||
Global.Settings.TUNTAP.Gateway);
|
||||
BindCheckBox(UseCustomDNSCheckBox,
|
||||
b => { Global.Settings.TUNTAP.UseCustomDNS = b; },
|
||||
Global.Settings.TUNTAP.UseCustomDNS);
|
||||
TUNTAPUseCustomDNSCheckBox_CheckedChanged(null, null);
|
||||
ProxyDNSCheckBox.Checked = Global.Settings.TUNTAP.ProxyDNS;
|
||||
UseFakeDNSCheckBox.Checked = Global.Settings.TUNTAP.UseFakeDNS;
|
||||
|
||||
BindCheckBox(ProxyDNSCheckBox,
|
||||
b => Global.Settings.TUNTAP.ProxyDNS = b,
|
||||
Global.Settings.TUNTAP.ProxyDNS);
|
||||
BindCheckBox(UseFakeDNSCheckBox,
|
||||
b => Global.Settings.TUNTAP.UseFakeDNS = b,
|
||||
Global.Settings.TUNTAP.UseFakeDNS);
|
||||
|
||||
try
|
||||
{
|
||||
@@ -54,26 +132,79 @@ namespace Netch.Forms
|
||||
// ignored
|
||||
}
|
||||
|
||||
// Behavior
|
||||
ExitWhenClosedCheckBox.Checked = Global.Settings.ExitWhenClosed;
|
||||
StopWhenExitedCheckBox.Checked = Global.Settings.StopWhenExited;
|
||||
StartWhenOpenedCheckBox.Checked = Global.Settings.StartWhenOpened;
|
||||
MinimizeWhenStartedCheckBox.Checked = Global.Settings.MinimizeWhenStarted;
|
||||
RunAtStartupCheckBox.Checked = Global.Settings.RunAtStartup;
|
||||
CheckUpdateWhenOpenedCheckBox.Checked = Global.Settings.CheckUpdateWhenOpened;
|
||||
BootShadowsocksFromDLLCheckBox.Checked = Global.Settings.BootShadowsocksFromDLL;
|
||||
CheckBetaUpdateCheckBox.Checked = Global.Settings.CheckBetaUpdate;
|
||||
ModifySystemDNSCheckBox.Checked = Global.Settings.ModifySystemDNS;
|
||||
UpdateSubscribeatWhenOpenedCheckBox.Checked = Global.Settings.UpdateSubscribeatWhenOpened;
|
||||
ResolveServerHostnameCheckBox.Checked = Global.Settings.ResolveServerHostname;
|
||||
#endregion
|
||||
|
||||
ProfileCountTextBox.Text = Global.Settings.ProfileCount.ToString();
|
||||
TcpingAtStartedCheckBox.Checked = Global.Settings.StartedTcping;
|
||||
DetectionIntervalTextBox.Text = Global.Settings.StartedTcping_Interval.ToString();
|
||||
InitSTUN();
|
||||
AclAddrTextBox.Text = Global.Settings.ACL;
|
||||
LanguageComboBox.Items.AddRange(i18N.GetTranslateList().ToArray());
|
||||
LanguageComboBox.SelectedItem = Global.Settings.Language;
|
||||
#region V2Ray
|
||||
|
||||
BindCheckBox(TLSAllowInsecureCheckBox,
|
||||
b => Global.Settings.V2RayConfig.AllowInsecure = b,
|
||||
Global.Settings.V2RayConfig.AllowInsecure);
|
||||
|
||||
BindTextBox<int>(mtuTextBox,
|
||||
i => true,
|
||||
i => Global.Settings.V2RayConfig.KcpConfig.mtu = i,
|
||||
Global.Settings.V2RayConfig.KcpConfig.mtu);
|
||||
BindTextBox<int>(ttiTextBox,
|
||||
i => true,
|
||||
i => Global.Settings.V2RayConfig.KcpConfig.tti = i,
|
||||
Global.Settings.V2RayConfig.KcpConfig.tti);
|
||||
BindTextBox<int>(uplinkCapacityTextBox,
|
||||
i => true,
|
||||
i => Global.Settings.V2RayConfig.KcpConfig.uplinkCapacity = i,
|
||||
Global.Settings.V2RayConfig.KcpConfig.uplinkCapacity);
|
||||
BindTextBox<int>(downlinkCapacityTextBox,
|
||||
i => true,
|
||||
i => Global.Settings.V2RayConfig.KcpConfig.downlinkCapacity = i,
|
||||
Global.Settings.V2RayConfig.KcpConfig.downlinkCapacity);
|
||||
BindTextBox<int>(readBufferSizeTextBox,
|
||||
i => true,
|
||||
i => Global.Settings.V2RayConfig.KcpConfig.readBufferSize = i,
|
||||
Global.Settings.V2RayConfig.KcpConfig.readBufferSize);
|
||||
BindTextBox<int>(writeBufferSizeTextBox,
|
||||
i => true,
|
||||
i => Global.Settings.V2RayConfig.KcpConfig.writeBufferSize = i,
|
||||
Global.Settings.V2RayConfig.KcpConfig.writeBufferSize);
|
||||
BindCheckBox(congestionCheckBox,
|
||||
b => Global.Settings.V2RayConfig.KcpConfig.congestion = b,
|
||||
Global.Settings.V2RayConfig.KcpConfig.congestion);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Others
|
||||
|
||||
BindCheckBox(ExitWhenClosedCheckBox,
|
||||
b => Global.Settings.ExitWhenClosed = b,
|
||||
Global.Settings.ExitWhenClosed);
|
||||
|
||||
BindCheckBox(StopWhenExitedCheckBox,
|
||||
b => Global.Settings.StopWhenExited = b,
|
||||
Global.Settings.StopWhenExited);
|
||||
|
||||
BindCheckBox(StartWhenOpenedCheckBox,
|
||||
b => Global.Settings.StartWhenOpened = b,
|
||||
Global.Settings.StartWhenOpened);
|
||||
|
||||
BindCheckBox(MinimizeWhenStartedCheckBox,
|
||||
b => Global.Settings.MinimizeWhenStarted = b,
|
||||
Global.Settings.MinimizeWhenStarted);
|
||||
|
||||
BindCheckBox(RunAtStartupCheckBox,
|
||||
b => Global.Settings.RunAtStartup = b,
|
||||
Global.Settings.RunAtStartup);
|
||||
|
||||
BindCheckBox(CheckUpdateWhenOpenedCheckBox,
|
||||
b => Global.Settings.CheckUpdateWhenOpened = b,
|
||||
Global.Settings.CheckUpdateWhenOpened);
|
||||
|
||||
BindCheckBox(CheckBetaUpdateCheckBox,
|
||||
b => Global.Settings.CheckBetaUpdate = b,
|
||||
Global.Settings.CheckBetaUpdate);
|
||||
|
||||
BindCheckBox(UpdateSubscribeatWhenOpenedCheckBox,
|
||||
b => Global.Settings.UpdateSubscribeatWhenOpened = b,
|
||||
Global.Settings.UpdateSubscribeatWhenOpened);
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
private void TUNTAPUseCustomDNSCheckBox_CheckedChanged(object sender, EventArgs e)
|
||||
@@ -92,10 +223,6 @@ namespace Netch.Forms
|
||||
}
|
||||
}
|
||||
|
||||
private void InitText()
|
||||
{
|
||||
i18N.TranslateForm(this);
|
||||
}
|
||||
|
||||
private void InitSTUN()
|
||||
{
|
||||
@@ -104,7 +231,7 @@ namespace Netch.Forms
|
||||
var stuns = File.ReadLines("bin\\stun.txt");
|
||||
STUN_ServerComboBox.Items.AddRange(stuns.ToArray());
|
||||
}
|
||||
catch (Exception)
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
@@ -112,13 +239,6 @@ namespace Netch.Forms
|
||||
STUN_ServerComboBox.Text = $"{Global.Settings.STUN_Server}:{Global.Settings.STUN_Server_Port}";
|
||||
}
|
||||
|
||||
private void SettingForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
InitValue();
|
||||
|
||||
Task.Run(() => BeginInvoke(new Action(() => UseFakeDNSCheckBox.Visible = Global.Flags.SupportFakeDns)));
|
||||
}
|
||||
|
||||
private void GlobalBypassIPsButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
Hide();
|
||||
@@ -128,60 +248,16 @@ namespace Netch.Forms
|
||||
|
||||
private void ControlButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
#region Check
|
||||
|
||||
#region Port
|
||||
|
||||
ushort socks5LocalPort;
|
||||
ushort httpLocalPort;
|
||||
ushort redirectorTCPPort;
|
||||
try
|
||||
{
|
||||
socks5LocalPort = ushort.Parse(Socks5PortTextBox.Text);
|
||||
httpLocalPort = ushort.Parse(HTTPPortTextBox.Text);
|
||||
redirectorTCPPort = ushort.Parse(RedirectorTextBox.Text);
|
||||
|
||||
static void CheckPort(string portName, ushort port, ushort originPort, PortType portType = PortType.Both)
|
||||
{
|
||||
if (port == originPort)
|
||||
return;
|
||||
|
||||
if (PortHelper.PortInUse(port, portType))
|
||||
{
|
||||
MessageBoxX.Show(i18N.TranslateFormat("The {0} port is in use.", portName));
|
||||
throw new PortInUseException();
|
||||
}
|
||||
}
|
||||
|
||||
CheckPort("Socks5", socks5LocalPort, Global.Settings.Socks5LocalPort);
|
||||
CheckPort("HTTP", httpLocalPort, Global.Settings.HTTPLocalPort);
|
||||
CheckPort("RedirectorTCP", redirectorTCPPort, Global.Settings.RedirectorTCPPort);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
switch (exception)
|
||||
{
|
||||
case FormatException _:
|
||||
MessageBoxX.Show(i18N.Translate("Port value illegal. Try again."));
|
||||
break;
|
||||
case PortInUseException _:
|
||||
break;
|
||||
}
|
||||
|
||||
if (!_checkActions.All(pair => pair.Value.Invoke(pair.Key.Text)))
|
||||
return;
|
||||
}
|
||||
|
||||
#endregion
|
||||
#region Check
|
||||
|
||||
#region TUNTAP
|
||||
|
||||
var dns = new string[0];
|
||||
try
|
||||
{
|
||||
IPAddress.Parse(TUNTAPAddressTextBox.Text);
|
||||
IPAddress.Parse(TUNTAPNetmaskTextBox.Text);
|
||||
IPAddress.Parse(TUNTAPGatewayTextBox.Text);
|
||||
|
||||
if (UseCustomDNSCheckBox.Checked)
|
||||
{
|
||||
dns = TUNTAPDNSTextBox.Text.Split(',').Where(s => !string.IsNullOrEmpty(s)).Select(s => s.Trim())
|
||||
@@ -203,11 +279,6 @@ namespace Netch.Forms
|
||||
if (exception is FormatException)
|
||||
MessageBoxX.Show(i18N.Translate("IP address format illegal. Try again."));
|
||||
|
||||
TUNTAPAddressTextBox.Text = Global.Settings.TUNTAP.Address;
|
||||
TUNTAPNetmaskTextBox.Text = Global.Settings.TUNTAP.Netmask;
|
||||
TUNTAPGatewayTextBox.Text = Global.Settings.TUNTAP.Gateway;
|
||||
UseCustomDNSCheckBox.Checked = Global.Settings.TUNTAP.UseCustomDNS;
|
||||
|
||||
if (UseCustomDNSCheckBox.Checked)
|
||||
{
|
||||
TUNTAPDNSTextBox.Text = Global.Settings.TUNTAP.DNS.Aggregate((current, ip) => $"{current},{ip}");
|
||||
@@ -220,44 +291,6 @@ namespace Netch.Forms
|
||||
|
||||
#region Behavior
|
||||
|
||||
// Profile
|
||||
int profileCount;
|
||||
try
|
||||
{
|
||||
profileCount = int.Parse(ProfileCountTextBox.Text);
|
||||
|
||||
if (profileCount <= -1)
|
||||
{
|
||||
throw new FormatException();
|
||||
}
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
ProfileCountTextBox.Text = Global.Settings.ProfileCount.ToString();
|
||||
MessageBoxX.Show(i18N.Translate("ProfileCount value illegal. Try again."));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Started TCPing Interval
|
||||
int detectionInterval;
|
||||
try
|
||||
{
|
||||
detectionInterval = int.Parse(DetectionIntervalTextBox.Text);
|
||||
|
||||
if (detectionInterval <= 0)
|
||||
{
|
||||
throw new FormatException();
|
||||
}
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
ProfileCountTextBox.Text = Global.Settings.ProfileCount.ToString();
|
||||
MessageBoxX.Show(i18N.Translate("Detection interval value illegal. Try again."));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// STUN
|
||||
string stunServer;
|
||||
int stunServerPort;
|
||||
@@ -277,7 +310,6 @@ namespace Netch.Forms
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
ProfileCountTextBox.Text = Global.Settings.ProfileCount.ToString();
|
||||
MessageBoxX.Show(i18N.Translate("STUN_ServerPort value illegal. Try again."));
|
||||
|
||||
return;
|
||||
@@ -289,55 +321,14 @@ namespace Netch.Forms
|
||||
|
||||
#region Save
|
||||
|
||||
#region Port
|
||||
|
||||
Global.Settings.Socks5LocalPort = socks5LocalPort;
|
||||
Global.Settings.HTTPLocalPort = httpLocalPort;
|
||||
Global.Settings.RedirectorTCPPort = redirectorTCPPort;
|
||||
Global.Settings.LocalAddress = AllowDevicesCheckBox.Checked ? "0.0.0.0" : "127.0.0.1";
|
||||
|
||||
#endregion
|
||||
|
||||
#region TUNTAP
|
||||
|
||||
Global.Settings.TUNTAP.Address = TUNTAPAddressTextBox.Text;
|
||||
Global.Settings.TUNTAP.Netmask = TUNTAPNetmaskTextBox.Text;
|
||||
Global.Settings.TUNTAP.Gateway = TUNTAPGatewayTextBox.Text;
|
||||
Global.Settings.TUNTAP.UseCustomDNS = UseCustomDNSCheckBox.Checked;
|
||||
if (Global.Settings.TUNTAP.UseCustomDNS)
|
||||
foreach (var pair in _saveActions)
|
||||
{
|
||||
Global.Settings.TUNTAP.DNS.Clear();
|
||||
Global.Settings.TUNTAP.DNS.AddRange(dns);
|
||||
pair.Value.Invoke(pair.Key);
|
||||
}
|
||||
|
||||
Global.Settings.TUNTAP.ProxyDNS = ProxyDNSCheckBox.Checked;
|
||||
Global.Settings.TUNTAP.UseFakeDNS = UseFakeDNSCheckBox.Checked;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Behavior
|
||||
|
||||
Global.Settings.ExitWhenClosed = ExitWhenClosedCheckBox.Checked;
|
||||
Global.Settings.StopWhenExited = StopWhenExitedCheckBox.Checked;
|
||||
Global.Settings.StartWhenOpened = StartWhenOpenedCheckBox.Checked;
|
||||
Global.Settings.MinimizeWhenStarted = MinimizeWhenStartedCheckBox.Checked;
|
||||
Global.Settings.RunAtStartup = RunAtStartupCheckBox.Checked;
|
||||
Global.Settings.CheckUpdateWhenOpened = CheckUpdateWhenOpenedCheckBox.Checked;
|
||||
Global.Settings.BootShadowsocksFromDLL = BootShadowsocksFromDLLCheckBox.Checked;
|
||||
Global.Settings.CheckBetaUpdate = CheckBetaUpdateCheckBox.Checked;
|
||||
Global.Settings.ModifySystemDNS = ModifySystemDNSCheckBox.Checked;
|
||||
Global.Settings.UpdateSubscribeatWhenOpened = UpdateSubscribeatWhenOpenedCheckBox.Checked;
|
||||
Global.Settings.ResolveServerHostname = ResolveServerHostnameCheckBox.Checked;
|
||||
|
||||
Global.Settings.ProfileCount = profileCount;
|
||||
Global.Settings.StartedTcping = TcpingAtStartedCheckBox.Checked;
|
||||
Global.Settings.StartedTcping_Interval = detectionInterval;
|
||||
Global.Settings.TUNTAP.DNS = dns.ToList();
|
||||
Global.Settings.STUN_Server = stunServer;
|
||||
Global.Settings.STUN_Server_Port = stunServerPort;
|
||||
Global.Settings.ACL = AclAddrTextBox.Text;
|
||||
Global.Settings.Language = LanguageComboBox.SelectedItem.ToString();
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -393,6 +384,15 @@ namespace Netch.Forms
|
||||
Close();
|
||||
}
|
||||
|
||||
private bool CheckPort(string portName, ushort port, ushort originPort, PortType portType = PortType.Both)
|
||||
{
|
||||
if (port == originPort) return true;
|
||||
if (!PortHelper.PortInUse(port, portType)) return true;
|
||||
|
||||
MessageBoxX.Show(i18N.TranslateFormat("The {0} port is in use.", portName));
|
||||
return false;
|
||||
}
|
||||
|
||||
private async void ICSCheckBox_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
@@ -421,5 +421,38 @@ namespace Netch.Forms
|
||||
ICSCheckBox.Enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void BindTextBox(TextBox control, Func<string, bool> check, Action<string> save, object value)
|
||||
{
|
||||
BindTextBox<string>(control, check, save, value);
|
||||
}
|
||||
|
||||
private void BindTextBox<T>(TextBox control, Func<T, bool> check, Action<T> save, object value)
|
||||
{
|
||||
control.Text = value.ToString();
|
||||
_checkActions.Add(control, s =>
|
||||
{
|
||||
try
|
||||
{
|
||||
return check.Invoke((T) Convert.ChangeType(s, typeof(T)));
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
});
|
||||
_saveActions.Add(control, c => save.Invoke((T) Convert.ChangeType(((TextBox) c).Text, typeof(T))));
|
||||
}
|
||||
|
||||
private void BindCheckBox(CheckBox control, Action<bool> save, bool value)
|
||||
{
|
||||
control.Checked = value;
|
||||
_checkActions.Add(control, s => true);
|
||||
_saveActions.Add(control, c => save.Invoke(((CheckBox) c).Checked));
|
||||
}
|
||||
|
||||
private readonly Dictionary<Control, Func<string, bool>> _checkActions = new Dictionary<Control, Func<string, bool>>();
|
||||
|
||||
private readonly Dictionary<Control, Action<Control>> _saveActions = new Dictionary<Control, Action<Control>>();
|
||||
}
|
||||
}
|
||||
@@ -43,6 +43,30 @@ namespace Netch.Models
|
||||
public bool UseFakeDNS = false;
|
||||
}
|
||||
|
||||
public class KcpConfig
|
||||
{
|
||||
public int mtu = 1350;
|
||||
|
||||
public int tti = 50;
|
||||
|
||||
public int uplinkCapacity = 12;
|
||||
|
||||
public int downlinkCapacity = 100;
|
||||
|
||||
public bool congestion = false;
|
||||
|
||||
public int readBufferSize = 2;
|
||||
|
||||
public int writeBufferSize = 2;
|
||||
}
|
||||
|
||||
public class V2rayConfig
|
||||
{
|
||||
public bool AllowInsecure = true;
|
||||
|
||||
public KcpConfig KcpConfig = new KcpConfig();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 用于读取和写入的配置的类
|
||||
/// </summary>
|
||||
@@ -207,5 +231,7 @@ namespace Netch.Models
|
||||
/// 语言设置
|
||||
/// </summary>
|
||||
public string Language = "System";
|
||||
|
||||
public V2rayConfig V2RayConfig = new V2rayConfig();
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using Netch.Forms;
|
||||
|
||||
namespace Netch.Servers.VLESS.VLESSForm
|
||||
@@ -38,9 +39,22 @@ namespace Netch.Servers.VLESS.VLESSForm
|
||||
s => true,
|
||||
s => server.Path = s,
|
||||
server.Path);
|
||||
CreateCheckBox("TLSSecure", "TLS Secure",
|
||||
b => server.TLSSecure = b,
|
||||
server.TLSSecure);
|
||||
CreateComboBox("TLSSecure", "TLS Secure",
|
||||
new List<string> {"", "true", "false"},
|
||||
s =>
|
||||
{
|
||||
server.TLSSecure = s switch
|
||||
{
|
||||
"" => null,
|
||||
"true" => true,
|
||||
"false" => false,
|
||||
_ => null
|
||||
};
|
||||
},
|
||||
server.TLSSecure?.ToString() ?? string.Empty);
|
||||
CreateCheckBox("UseMux", "Use Mux",
|
||||
b => server.UseMux = b,
|
||||
server.UseMux);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Netch.Forms;
|
||||
using System.Collections.Generic;
|
||||
using Netch.Forms;
|
||||
|
||||
namespace Netch.Servers.VMess.Form
|
||||
{
|
||||
@@ -47,12 +48,22 @@ namespace Netch.Servers.VMess.Form
|
||||
s => true,
|
||||
s => server.QUICSecret = s,
|
||||
server.QUICSecret);
|
||||
CreateComboBox("TLSSecure", "TLS Secure",
|
||||
new List<string> {"", "true", "false"},
|
||||
s =>
|
||||
{
|
||||
server.TLSSecure = s switch
|
||||
{
|
||||
"" => null,
|
||||
"true" => true,
|
||||
"false" => false,
|
||||
_ => null
|
||||
};
|
||||
},
|
||||
server.TLSSecure?.ToString() ?? string.Empty);
|
||||
CreateCheckBox("UseMux", "Use Mux",
|
||||
s => server.UseMux = s,
|
||||
server.UseMux);
|
||||
CreateCheckBox("TLSSecure", "TLS Secure",
|
||||
s => server.TLSSecure = s,
|
||||
server.TLSSecure);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
using Netch.Controllers;
|
||||
using Netch.Models;
|
||||
using Netch.Servers.VMess.Models;
|
||||
using Newtonsoft.Json;
|
||||
using V2rayConfig = Netch.Servers.VMess.Models.V2rayConfig;
|
||||
|
||||
namespace Netch.Servers.VMess.Utils
|
||||
{
|
||||
@@ -238,7 +238,7 @@ namespace Netch.Servers.VMess.Utils
|
||||
{
|
||||
streamSettings.network = server.TransferProtocol;
|
||||
var host = server.Host;
|
||||
if (server.TLSSecure)
|
||||
if (server.TLSSecure ?? Global.Settings.V2RayConfig.AllowInsecure)
|
||||
{
|
||||
streamSettings.security = "tls";
|
||||
|
||||
@@ -263,14 +263,13 @@ namespace Netch.Servers.VMess.Utils
|
||||
case "kcp":
|
||||
var kcpSettings = new KcpSettings
|
||||
{
|
||||
/*TODO KCP Settings
|
||||
mtu = Global.Settings.KcpSettings.mtu,
|
||||
tti = Global.Settings.KcpSettings.tti,
|
||||
uplinkCapacity = Global.Settings.KcpSettings.uplinkCapacity,
|
||||
downlinkCapacity = Global.Settings.KcpSettings.downlinkCapacity,
|
||||
congestion = Global.Settings.KcpSettings.congestion,
|
||||
readBufferSize = Global.Settings.KcpSettings.readBufferSize,
|
||||
writeBufferSize = Global.Settings.KcpSettings.writeBufferSize,*/
|
||||
mtu = Global.Settings.V2RayConfig.KcpConfig.mtu,
|
||||
tti = Global.Settings.V2RayConfig.KcpConfig.tti,
|
||||
uplinkCapacity = Global.Settings.V2RayConfig.KcpConfig.uplinkCapacity,
|
||||
downlinkCapacity = Global.Settings.V2RayConfig.KcpConfig.downlinkCapacity,
|
||||
congestion = Global.Settings.V2RayConfig.KcpConfig.congestion,
|
||||
readBufferSize = Global.Settings.V2RayConfig.KcpConfig.readBufferSize,
|
||||
writeBufferSize = Global.Settings.V2RayConfig.KcpConfig.writeBufferSize,
|
||||
header = new Header
|
||||
{
|
||||
type = server.FakeType
|
||||
@@ -319,7 +318,7 @@ namespace Netch.Servers.VMess.Utils
|
||||
type = server.FakeType
|
||||
}
|
||||
};
|
||||
if (server.TLSSecure)
|
||||
if (server.TLSSecure ?? Global.Settings.V2RayConfig.AllowInsecure)
|
||||
{
|
||||
streamSettings.tlsSettings.serverName = server.Hostname;
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace Netch.Servers.VMess
|
||||
/// <summary>
|
||||
/// TLS 底层传输安全
|
||||
/// </summary>
|
||||
public bool TLSSecure { get; set; } = false;
|
||||
public bool? TLSSecure { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Mux 多路复用
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace Netch.Servers.VMess
|
||||
type = server.FakeType,
|
||||
host = server.Host,
|
||||
path = server.Path,
|
||||
tls = server.TLSSecure ? "tls" : ""
|
||||
tls = server.TLSSecure ?? Global.Settings.V2RayConfig.AllowInsecure ? "tls" : ""
|
||||
});
|
||||
return "vmess://" + ShareLink.URLSafeBase64Encode(vmessJson);
|
||||
}
|
||||
|
||||
@@ -159,6 +159,9 @@ namespace Netch.Utils
|
||||
portName = "HTTP";
|
||||
MainForm.StatusPortInfoText.HttpPort = (ushort) port;
|
||||
break;
|
||||
case 4:
|
||||
modeController = null;
|
||||
break;
|
||||
default:
|
||||
Logging.Error("未知模式类型");
|
||||
throw new StartFailedException();
|
||||
|
||||
@@ -25,11 +25,10 @@ namespace NetchUpdater
|
||||
UpdaterFriendlyName = Path.GetFileName(UpdaterFullName);
|
||||
}
|
||||
|
||||
public static void Main(string[] args1)
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
var result = false;
|
||||
|
||||
var args = args1.Aggregate((s, s1) => $"{s} {s1}").Split('|').Select(s => s.Trim()).ToArray();
|
||||
try
|
||||
{
|
||||
#region Check Arguments
|
||||
@@ -87,7 +86,7 @@ namespace NetchUpdater
|
||||
Process.Start(new ProcessStartInfo
|
||||
{
|
||||
FileName = newUpdaterPath,
|
||||
Arguments = $"{port}|{updatePath}|{targetPath}",
|
||||
Arguments = $"{port} \"{updatePath}\" \"{targetPath}\"",
|
||||
WorkingDirectory = tempPath,
|
||||
UseShellExecute = false
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user