mirror of
https://github.com/netchx/netch.git
synced 2026-03-18 18:13:21 +08:00
修改 添加/编辑服务器 代码,Vmess默认开启MUX多路复用
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
using Netch.Utils;
|
||||
|
||||
@@ -8,7 +7,7 @@ namespace Netch.Forms.Server
|
||||
{
|
||||
public partial class Shadowsocks : Form
|
||||
{
|
||||
public int Index;
|
||||
private readonly Models.Server _server;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化
|
||||
@@ -18,11 +17,15 @@ namespace Netch.Forms.Server
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
Index = index;
|
||||
_server = index != -1
|
||||
? Global.Settings.Server[index]
|
||||
: new Models.Server {EncryptMethod = Global.EncryptMethods.SS[0]};
|
||||
}
|
||||
|
||||
private void Shadowsocks_Load(object sender, EventArgs e)
|
||||
{
|
||||
#region InitText
|
||||
|
||||
ConfigurationGroupBox.Text = i18N.Translate(ConfigurationGroupBox.Text);
|
||||
RemarkLabel.Text = i18N.Translate(RemarkLabel.Text);
|
||||
AddressLabel.Text = i18N.Translate(AddressLabel.Text);
|
||||
@@ -32,25 +35,17 @@ namespace Netch.Forms.Server
|
||||
PluginOptionsLabel.Text = i18N.Translate(PluginOptionsLabel.Text);
|
||||
ControlButton.Text = i18N.Translate(ControlButton.Text);
|
||||
|
||||
foreach (var encrypt in Global.EncryptMethods.SS)
|
||||
{
|
||||
EncryptMethodComboBox.Items.Add(encrypt);
|
||||
}
|
||||
EncryptMethodComboBox.Items.AddRange(Global.EncryptMethods.SS.ToArray());
|
||||
|
||||
if (Index != -1)
|
||||
{
|
||||
RemarkTextBox.Text = Global.Settings.Server[Index].Remark;
|
||||
AddressTextBox.Text = Global.Settings.Server[Index].Hostname;
|
||||
PortTextBox.Text = Global.Settings.Server[Index].Port.ToString();
|
||||
PasswordTextBox.Text = Global.Settings.Server[Index].Password;
|
||||
EncryptMethodComboBox.SelectedIndex = Global.EncryptMethods.SS.IndexOf(Global.Settings.Server[Index].EncryptMethod);
|
||||
PluginTextBox.Text = Global.Settings.Server[Index].Plugin;
|
||||
PluginOptionsTextBox.Text = Global.Settings.Server[Index].PluginOption;
|
||||
}
|
||||
else
|
||||
{
|
||||
EncryptMethodComboBox.SelectedIndex = 0;
|
||||
}
|
||||
#endregion
|
||||
|
||||
RemarkTextBox.Text = _server.Remark;
|
||||
AddressTextBox.Text = _server.Hostname;
|
||||
PortTextBox.Text = _server.Port.ToString();
|
||||
PasswordTextBox.Text = _server.Password;
|
||||
EncryptMethodComboBox.SelectedIndex = Global.EncryptMethods.SS.IndexOf(_server.EncryptMethod);
|
||||
PluginTextBox.Text = _server.Plugin;
|
||||
PluginOptionsTextBox.Text = _server.PluginOption;
|
||||
}
|
||||
|
||||
private void Shadowsocks_FormClosing(object sender, FormClosingEventArgs e)
|
||||
@@ -60,16 +55,17 @@ namespace Netch.Forms.Server
|
||||
|
||||
private void ComboBox_DrawItem(object sender, DrawItemEventArgs e)
|
||||
{
|
||||
var cbx = sender as ComboBox;
|
||||
if (cbx != null)
|
||||
if (sender is ComboBox cbx)
|
||||
{
|
||||
e.DrawBackground();
|
||||
|
||||
if (e.Index >= 0)
|
||||
{
|
||||
var sf = new StringFormat();
|
||||
sf.LineAlignment = StringAlignment.Center;
|
||||
sf.Alignment = StringAlignment.Center;
|
||||
var sf = new StringFormat
|
||||
{
|
||||
LineAlignment = StringAlignment.Center,
|
||||
Alignment = StringAlignment.Center
|
||||
};
|
||||
|
||||
var brush = new SolidBrush(cbx.ForeColor);
|
||||
|
||||
@@ -85,39 +81,24 @@ namespace Netch.Forms.Server
|
||||
|
||||
private void ControlButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!Regex.Match(PortTextBox.Text, "^[0-9]+$").Success)
|
||||
if (!int.TryParse(PortTextBox.Text, out var port))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (Index == -1)
|
||||
|
||||
_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(new Models.Server
|
||||
{
|
||||
Remark = RemarkTextBox.Text,
|
||||
Type = "SS",
|
||||
Hostname = AddressTextBox.Text,
|
||||
Port = int.Parse(PortTextBox.Text),
|
||||
Password = PasswordTextBox.Text,
|
||||
EncryptMethod = EncryptMethodComboBox.Text,
|
||||
Plugin = PluginTextBox.Text,
|
||||
PluginOption = PluginOptionsTextBox.Text
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Global.Settings.Server[Index] = new Models.Server
|
||||
{
|
||||
Remark = RemarkTextBox.Text,
|
||||
Group = Global.Settings.Server[Index].Group,
|
||||
Type = "SS",
|
||||
Hostname = AddressTextBox.Text,
|
||||
Port = int.Parse(PortTextBox.Text),
|
||||
Password = PasswordTextBox.Text,
|
||||
EncryptMethod = EncryptMethodComboBox.Text,
|
||||
Plugin = PluginTextBox.Text,
|
||||
PluginOption = PluginOptionsTextBox.Text,
|
||||
Country = null
|
||||
};
|
||||
Global.Settings.Server.Add(_server);
|
||||
}
|
||||
|
||||
Configuration.Save();
|
||||
@@ -126,4 +107,4 @@ namespace Netch.Forms.Server
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
using Netch.Utils;
|
||||
|
||||
@@ -8,7 +7,7 @@ namespace Netch.Forms.Server
|
||||
{
|
||||
public partial class ShadowsocksR : Form
|
||||
{
|
||||
public int Index;
|
||||
private readonly Models.Server _server;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化
|
||||
@@ -18,11 +17,15 @@ namespace Netch.Forms.Server
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
Index = index;
|
||||
_server = index != -1
|
||||
? Global.Settings.Server[index]
|
||||
: new Models.Server {EncryptMethod = Global.EncryptMethods.SSR[0]};
|
||||
}
|
||||
|
||||
private void ShadowsocksR_Load(object sender, EventArgs e)
|
||||
{
|
||||
#region InitText
|
||||
|
||||
ConfigurationGroupBox.Text = i18N.Translate(ConfigurationGroupBox.Text);
|
||||
RemarkLabel.Text = i18N.Translate(RemarkLabel.Text);
|
||||
AddressLabel.Text = i18N.Translate(AddressLabel.Text);
|
||||
@@ -34,39 +37,23 @@ namespace Netch.Forms.Server
|
||||
OBFSParamLabel.Text = i18N.Translate(OBFSParamLabel.Text);
|
||||
ControlButton.Text = i18N.Translate(ControlButton.Text);
|
||||
|
||||
foreach (var encrypt in Global.EncryptMethods.SSR)
|
||||
{
|
||||
EncryptMethodComboBox.Items.Add(encrypt);
|
||||
}
|
||||
EncryptMethodComboBox.Items.AddRange(Global.EncryptMethods.SSR.ToArray());
|
||||
|
||||
foreach (var protocol in Global.Protocols)
|
||||
{
|
||||
ProtocolComboBox.Items.Add(protocol);
|
||||
}
|
||||
ProtocolComboBox.Items.AddRange(Global.Protocols.ToArray());
|
||||
OBFSComboBox.Items.AddRange(Global.OBFSs.ToArray());
|
||||
|
||||
foreach (var obfs in Global.OBFSs)
|
||||
{
|
||||
OBFSComboBox.Items.Add(obfs);
|
||||
}
|
||||
#endregion
|
||||
|
||||
if (Index != -1)
|
||||
{
|
||||
RemarkTextBox.Text = Global.Settings.Server[Index].Remark;
|
||||
AddressTextBox.Text = Global.Settings.Server[Index].Hostname;
|
||||
PortTextBox.Text = Global.Settings.Server[Index].Port.ToString();
|
||||
PasswordTextBox.Text = Global.Settings.Server[Index].Password;
|
||||
EncryptMethodComboBox.SelectedIndex = Global.EncryptMethods.SSR.IndexOf(Global.Settings.Server[Index].EncryptMethod);
|
||||
ProtocolComboBox.SelectedIndex = Global.Protocols.IndexOf(Global.Settings.Server[Index].Protocol);
|
||||
ProtocolParamTextBox.Text = Global.Settings.Server[Index].ProtocolParam;
|
||||
OBFSComboBox.SelectedIndex = Global.OBFSs.IndexOf(Global.Settings.Server[Index].OBFS);
|
||||
OBFSOptionParamTextBox.Text = Global.Settings.Server[Index].OBFSParam;
|
||||
}
|
||||
else
|
||||
{
|
||||
EncryptMethodComboBox.SelectedIndex = 0;
|
||||
ProtocolComboBox.SelectedIndex = 0;
|
||||
OBFSComboBox.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
RemarkTextBox.Text = _server.Remark;
|
||||
AddressTextBox.Text = _server.Hostname;
|
||||
PortTextBox.Text = _server.Port.ToString();
|
||||
PasswordTextBox.Text = _server.Password;
|
||||
EncryptMethodComboBox.SelectedIndex = Global.EncryptMethods.SSR.IndexOf(_server.EncryptMethod);
|
||||
ProtocolComboBox.SelectedIndex = Global.Protocols.IndexOf(_server.Protocol);
|
||||
ProtocolParamTextBox.Text = _server.ProtocolParam;
|
||||
OBFSComboBox.SelectedIndex = Global.OBFSs.IndexOf(_server.OBFS);
|
||||
OBFSOptionParamTextBox.Text = _server.OBFSParam;
|
||||
}
|
||||
|
||||
private void ShadowsocksR_FormClosing(object sender, FormClosingEventArgs e)
|
||||
@@ -76,16 +63,17 @@ namespace Netch.Forms.Server
|
||||
|
||||
private void ComboBox_DrawItem(object sender, DrawItemEventArgs e)
|
||||
{
|
||||
var cbx = sender as ComboBox;
|
||||
if (cbx != null)
|
||||
if (sender is ComboBox cbx)
|
||||
{
|
||||
e.DrawBackground();
|
||||
|
||||
if (e.Index >= 0)
|
||||
{
|
||||
var sf = new StringFormat();
|
||||
sf.LineAlignment = StringAlignment.Center;
|
||||
sf.Alignment = StringAlignment.Center;
|
||||
var sf = new StringFormat
|
||||
{
|
||||
LineAlignment = StringAlignment.Center,
|
||||
Alignment = StringAlignment.Center
|
||||
};
|
||||
|
||||
var brush = new SolidBrush(cbx.ForeColor);
|
||||
|
||||
@@ -101,43 +89,26 @@ namespace Netch.Forms.Server
|
||||
|
||||
private void ControlButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!Regex.Match(PortTextBox.Text, "^[0-9]+$").Success)
|
||||
if (!int.TryParse(PortTextBox.Text, out var port))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (Index == -1)
|
||||
|
||||
_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(new Models.Server
|
||||
{
|
||||
Remark = RemarkTextBox.Text,
|
||||
Type = "SSR",
|
||||
Hostname = AddressTextBox.Text,
|
||||
Port = int.Parse(PortTextBox.Text),
|
||||
Password = PasswordTextBox.Text,
|
||||
EncryptMethod = EncryptMethodComboBox.Text,
|
||||
Protocol = ProtocolComboBox.Text,
|
||||
ProtocolParam = ProtocolParamTextBox.Text,
|
||||
OBFS = OBFSComboBox.Text,
|
||||
OBFSParam = OBFSOptionParamTextBox.Text
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Global.Settings.Server[Index] = new Models.Server
|
||||
{
|
||||
Remark = RemarkTextBox.Text,
|
||||
Group = Global.Settings.Server[Index].Group,
|
||||
Type = "SSR",
|
||||
Hostname = AddressTextBox.Text,
|
||||
Port = int.Parse(PortTextBox.Text),
|
||||
Password = PasswordTextBox.Text,
|
||||
EncryptMethod = EncryptMethodComboBox.Text,
|
||||
Protocol = ProtocolComboBox.Text,
|
||||
ProtocolParam = ProtocolParamTextBox.Text,
|
||||
OBFS = OBFSComboBox.Text,
|
||||
OBFSParam = OBFSOptionParamTextBox.Text,
|
||||
Country = null
|
||||
};
|
||||
Global.Settings.Server.Add(_server);
|
||||
}
|
||||
|
||||
Configuration.Save();
|
||||
@@ -146,4 +117,4 @@ namespace Netch.Forms.Server
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
using Netch.Utils;
|
||||
|
||||
@@ -8,7 +7,7 @@ namespace Netch.Forms.Server
|
||||
{
|
||||
public partial class Socks5 : Form
|
||||
{
|
||||
public int Index;
|
||||
private readonly Models.Server _server;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化
|
||||
@@ -18,11 +17,15 @@ namespace Netch.Forms.Server
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
Index = index;
|
||||
_server = index != -1
|
||||
? Global.Settings.Server[index]
|
||||
: new Models.Server();
|
||||
}
|
||||
|
||||
private void Shadowsocks_Load(object sender, EventArgs e)
|
||||
{
|
||||
#region InitText
|
||||
|
||||
ConfigurationGroupBox.Text = i18N.Translate(ConfigurationGroupBox.Text);
|
||||
RemarkLabel.Text = i18N.Translate(RemarkLabel.Text);
|
||||
AddressLabel.Text = i18N.Translate(AddressLabel.Text);
|
||||
@@ -30,14 +33,13 @@ namespace Netch.Forms.Server
|
||||
PasswordLabel.Text = i18N.Translate(PasswordLabel.Text);
|
||||
ControlButton.Text = i18N.Translate(ControlButton.Text);
|
||||
|
||||
if (Index != -1)
|
||||
{
|
||||
RemarkTextBox.Text = Global.Settings.Server[Index].Remark;
|
||||
AddressTextBox.Text = Global.Settings.Server[Index].Hostname;
|
||||
PortTextBox.Text = Global.Settings.Server[Index].Port.ToString();
|
||||
UsernameTextBox.Text = Global.Settings.Server[Index].Username;
|
||||
PasswordTextBox.Text = Global.Settings.Server[Index].Password;
|
||||
}
|
||||
#endregion
|
||||
|
||||
RemarkTextBox.Text = _server.Remark;
|
||||
AddressTextBox.Text = _server.Hostname;
|
||||
PortTextBox.Text = _server.Port.ToString();
|
||||
UsernameTextBox.Text = _server.Username;
|
||||
PasswordTextBox.Text = _server.Password;
|
||||
}
|
||||
|
||||
private void Shadowsocks_FormClosing(object sender, FormClosingEventArgs e)
|
||||
@@ -47,16 +49,17 @@ namespace Netch.Forms.Server
|
||||
|
||||
private void ComboBox_DrawItem(object sender, DrawItemEventArgs e)
|
||||
{
|
||||
var cbx = sender as ComboBox;
|
||||
if (cbx != null)
|
||||
if (sender is ComboBox cbx)
|
||||
{
|
||||
e.DrawBackground();
|
||||
|
||||
if (e.Index >= 0)
|
||||
{
|
||||
var sf = new StringFormat();
|
||||
sf.LineAlignment = StringAlignment.Center;
|
||||
sf.Alignment = StringAlignment.Center;
|
||||
var sf = new StringFormat
|
||||
{
|
||||
LineAlignment = StringAlignment.Center,
|
||||
Alignment = StringAlignment.Center
|
||||
};
|
||||
|
||||
var brush = new SolidBrush(cbx.ForeColor);
|
||||
|
||||
@@ -72,35 +75,22 @@ namespace Netch.Forms.Server
|
||||
|
||||
private void ControlButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!Regex.Match(PortTextBox.Text, "^[0-9]+$").Success)
|
||||
if (!int.TryParse(PortTextBox.Text, out var port))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (Index == -1)
|
||||
|
||||
_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(new Models.Server
|
||||
{
|
||||
Remark = RemarkTextBox.Text,
|
||||
Type = "Socks5",
|
||||
Hostname = AddressTextBox.Text,
|
||||
Port = int.Parse(PortTextBox.Text),
|
||||
Username = UsernameTextBox.Text,
|
||||
Password = PasswordTextBox.Text
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Global.Settings.Server[Index] = new Models.Server
|
||||
{
|
||||
Remark = RemarkTextBox.Text,
|
||||
Group = Global.Settings.Server[Index].Group,
|
||||
Type = "Socks5",
|
||||
Hostname = AddressTextBox.Text,
|
||||
Port = int.Parse(PortTextBox.Text),
|
||||
Username = UsernameTextBox.Text,
|
||||
Password = PasswordTextBox.Text,
|
||||
Country = null
|
||||
};
|
||||
Global.Settings.Server.Add(_server);
|
||||
}
|
||||
|
||||
Configuration.Save();
|
||||
@@ -109,4 +99,4 @@ namespace Netch.Forms.Server
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
using Netch.Utils;
|
||||
|
||||
@@ -8,7 +7,7 @@ namespace Netch.Forms.Server
|
||||
{
|
||||
public partial class Trojan : Form
|
||||
{
|
||||
public int Index;
|
||||
private readonly Models.Server _server;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化
|
||||
@@ -18,7 +17,10 @@ namespace Netch.Forms.Server
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
Index = index;
|
||||
|
||||
_server = index != -1
|
||||
? Global.Settings.Server[index]
|
||||
: new Models.Server();
|
||||
}
|
||||
|
||||
private void Trojan_Load(object sender, EventArgs e)
|
||||
@@ -29,13 +31,10 @@ namespace Netch.Forms.Server
|
||||
PasswordLabel.Text = i18N.Translate(PasswordLabel.Text);
|
||||
ControlButton.Text = i18N.Translate(ControlButton.Text);
|
||||
|
||||
if (Index != -1)
|
||||
{
|
||||
RemarkTextBox.Text = Global.Settings.Server[Index].Remark;
|
||||
AddressTextBox.Text = Global.Settings.Server[Index].Hostname;
|
||||
PortTextBox.Text = Global.Settings.Server[Index].Port.ToString();
|
||||
PasswordTextBox.Text = Global.Settings.Server[Index].Password;
|
||||
}
|
||||
RemarkTextBox.Text = _server.Remark;
|
||||
AddressTextBox.Text = _server.Hostname;
|
||||
PortTextBox.Text = _server.Port.ToString();
|
||||
PasswordTextBox.Text = _server.Password;
|
||||
}
|
||||
|
||||
private void Trojan_FormClosing(object sender, FormClosingEventArgs e)
|
||||
@@ -45,16 +44,17 @@ namespace Netch.Forms.Server
|
||||
|
||||
private void ComboBox_DrawItem(object sender, DrawItemEventArgs e)
|
||||
{
|
||||
var cbx = sender as ComboBox;
|
||||
if (cbx != null)
|
||||
if (sender is ComboBox cbx)
|
||||
{
|
||||
e.DrawBackground();
|
||||
|
||||
if (e.Index >= 0)
|
||||
{
|
||||
var sf = new StringFormat();
|
||||
sf.LineAlignment = StringAlignment.Center;
|
||||
sf.Alignment = StringAlignment.Center;
|
||||
var sf = new StringFormat
|
||||
{
|
||||
LineAlignment = StringAlignment.Center,
|
||||
Alignment = StringAlignment.Center
|
||||
};
|
||||
|
||||
var brush = new SolidBrush(cbx.ForeColor);
|
||||
|
||||
@@ -70,33 +70,22 @@ namespace Netch.Forms.Server
|
||||
|
||||
private void ControlButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!Regex.Match(PortTextBox.Text, "^[0-9]+$").Success)
|
||||
if (!int.TryParse(PortTextBox.Text, out var port))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (Index == -1)
|
||||
|
||||
|
||||
_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(new Models.Server
|
||||
{
|
||||
Remark = RemarkTextBox.Text,
|
||||
Type = "Trojan",
|
||||
Hostname = AddressTextBox.Text,
|
||||
Port = int.Parse(PortTextBox.Text),
|
||||
Password = PasswordTextBox.Text
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Global.Settings.Server[Index] = new Models.Server
|
||||
{
|
||||
Remark = RemarkTextBox.Text,
|
||||
Group = Global.Settings.Server[Index].Group,
|
||||
Type = "Trojan",
|
||||
Hostname = AddressTextBox.Text,
|
||||
Port = int.Parse(PortTextBox.Text),
|
||||
Password = PasswordTextBox.Text,
|
||||
Country = null
|
||||
};
|
||||
Global.Settings.Server.Add(_server);
|
||||
}
|
||||
|
||||
Configuration.Save();
|
||||
@@ -105,4 +94,4 @@ namespace Netch.Forms.Server
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
using Netch.Utils;
|
||||
|
||||
@@ -8,27 +7,30 @@ namespace Netch.Forms.Server
|
||||
{
|
||||
public partial class VMess : Form
|
||||
{
|
||||
public int Index;
|
||||
private static Models.Server server;
|
||||
|
||||
public VMess(int index = -1)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
Index = index;
|
||||
server = index != -1
|
||||
? Global.Settings.Server[index]
|
||||
: new Models.Server {EncryptMethod = Global.EncryptMethods.VMess[0]};
|
||||
}
|
||||
|
||||
private void ComboBox_DrawItem(object sender, DrawItemEventArgs e)
|
||||
{
|
||||
var cbx = sender as ComboBox;
|
||||
if (cbx != null)
|
||||
if (sender is ComboBox cbx)
|
||||
{
|
||||
e.DrawBackground();
|
||||
|
||||
if (e.Index >= 0)
|
||||
{
|
||||
var sf = new StringFormat();
|
||||
sf.LineAlignment = StringAlignment.Center;
|
||||
sf.Alignment = StringAlignment.Center;
|
||||
var sf = new StringFormat
|
||||
{
|
||||
LineAlignment = StringAlignment.Center,
|
||||
Alignment = StringAlignment.Center
|
||||
};
|
||||
|
||||
var brush = new SolidBrush(cbx.ForeColor);
|
||||
|
||||
@@ -44,6 +46,8 @@ namespace Netch.Forms.Server
|
||||
|
||||
private void VMess_Load(object sender, EventArgs e)
|
||||
{
|
||||
#region InitText
|
||||
|
||||
ConfigurationGroupBox.Text = i18N.Translate(ConfigurationGroupBox.Text);
|
||||
RemarkLabel.Text = i18N.Translate(RemarkLabel.Text);
|
||||
AddressLabel.Text = i18N.Translate(AddressLabel.Text);
|
||||
@@ -60,50 +64,27 @@ namespace Netch.Forms.Server
|
||||
UseMuxCheckBox.Text = i18N.Translate(UseMuxCheckBox.Text);
|
||||
ControlButton.Text = i18N.Translate(ControlButton.Text);
|
||||
|
||||
foreach (var encrypt in Global.EncryptMethods.VMess)
|
||||
{
|
||||
EncryptMethodComboBox.Items.Add(encrypt);
|
||||
}
|
||||
EncryptMethodComboBox.Items.AddRange(Global.EncryptMethods.VMess.ToArray());
|
||||
TransferProtocolComboBox.Items.AddRange(Global.TransferProtocols.ToArray());
|
||||
FakeTypeComboBox.Items.AddRange(Global.FakeTypes.ToArray());
|
||||
QUICSecurityComboBox.Items.AddRange(Global.EncryptMethods.VMessQUIC.ToArray());
|
||||
|
||||
foreach (var protocol in Global.TransferProtocols)
|
||||
{
|
||||
TransferProtocolComboBox.Items.Add(protocol);
|
||||
}
|
||||
#endregion
|
||||
|
||||
foreach (var fake in Global.FakeTypes)
|
||||
{
|
||||
FakeTypeComboBox.Items.Add(fake);
|
||||
}
|
||||
|
||||
foreach (var security in Global.EncryptMethods.VMessQUIC)
|
||||
{
|
||||
QUICSecurityComboBox.Items.Add(security);
|
||||
}
|
||||
|
||||
if (Index != -1)
|
||||
{
|
||||
RemarkTextBox.Text = Global.Settings.Server[Index].Remark;
|
||||
AddressTextBox.Text = Global.Settings.Server[Index].Hostname;
|
||||
PortTextBox.Text = Global.Settings.Server[Index].Port.ToString();
|
||||
UserIDTextBox.Text = Global.Settings.Server[Index].UserID;
|
||||
AlterIDTextBox.Text = Global.Settings.Server[Index].AlterID.ToString();
|
||||
EncryptMethodComboBox.SelectedIndex = Global.EncryptMethods.VMess.IndexOf(Global.Settings.Server[Index].EncryptMethod);
|
||||
TransferProtocolComboBox.SelectedIndex = Global.TransferProtocols.IndexOf(Global.Settings.Server[Index].TransferProtocol);
|
||||
FakeTypeComboBox.SelectedIndex = Global.FakeTypes.IndexOf(Global.Settings.Server[Index].FakeType);
|
||||
HostTextBox.Text = Global.Settings.Server[Index].Host;
|
||||
PathTextBox.Text = Global.Settings.Server[Index].Path;
|
||||
QUICSecurityComboBox.SelectedIndex = Global.EncryptMethods.VMessQUIC.IndexOf(Global.Settings.Server[Index].QUICSecure);
|
||||
QUICSecretTextBox.Text = Global.Settings.Server[Index].QUICSecret;
|
||||
TLSSecureCheckBox.Checked = Global.Settings.Server[Index].TLSSecure;
|
||||
UseMuxCheckBox.Checked = Global.Settings.Server[Index].UseMux;
|
||||
}
|
||||
else
|
||||
{
|
||||
EncryptMethodComboBox.SelectedIndex = 0;
|
||||
TransferProtocolComboBox.SelectedIndex = 0;
|
||||
FakeTypeComboBox.SelectedIndex = 0;
|
||||
QUICSecurityComboBox.SelectedIndex = 0;
|
||||
}
|
||||
RemarkTextBox.Text = server.Remark;
|
||||
AddressTextBox.Text = server.Hostname;
|
||||
PortTextBox.Text = server.Port.ToString();
|
||||
UserIDTextBox.Text = server.UserID;
|
||||
AlterIDTextBox.Text = server.AlterID.ToString();
|
||||
EncryptMethodComboBox.SelectedIndex = Global.EncryptMethods.VMess.IndexOf(server.EncryptMethod);
|
||||
TransferProtocolComboBox.SelectedIndex = Global.TransferProtocols.IndexOf(server.TransferProtocol);
|
||||
FakeTypeComboBox.SelectedIndex = Global.FakeTypes.IndexOf(server.FakeType);
|
||||
HostTextBox.Text = server.Host;
|
||||
PathTextBox.Text = server.Path;
|
||||
QUICSecurityComboBox.SelectedIndex = Global.EncryptMethods.VMessQUIC.IndexOf(server.QUICSecure);
|
||||
QUICSecretTextBox.Text = server.QUICSecret;
|
||||
TLSSecureCheckBox.Checked = server.TLSSecure;
|
||||
UseMuxCheckBox.Checked = server.UseMux;
|
||||
}
|
||||
|
||||
private void VMess_FormClosing(object sender, FormClosingEventArgs e)
|
||||
@@ -113,57 +94,42 @@ namespace Netch.Forms.Server
|
||||
|
||||
private void ControlButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!Regex.Match(PortTextBox.Text, "^[0-9]+$").Success)
|
||||
if (!int.TryParse(PortTextBox.Text, out var port))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (AlterIDTextBox.Text == "")
|
||||
{
|
||||
MessageBoxX.Show(i18N.Translate("Please fill in alterID"));
|
||||
return;
|
||||
}
|
||||
if (Index == -1)
|
||||
|
||||
if (!int.TryParse(PortTextBox.Text, out var afterId))
|
||||
{
|
||||
Global.Settings.Server.Add(new Models.Server
|
||||
{
|
||||
Remark = RemarkTextBox.Text,
|
||||
Type = "VMess",
|
||||
Hostname = AddressTextBox.Text,
|
||||
Port = int.Parse(PortTextBox.Text),
|
||||
UserID = UserIDTextBox.Text,
|
||||
AlterID = int.Parse(AlterIDTextBox.Text),
|
||||
EncryptMethod = EncryptMethodComboBox.Text,
|
||||
TransferProtocol = TransferProtocolComboBox.Text,
|
||||
FakeType = FakeTypeComboBox.Text,
|
||||
Host = HostTextBox.Text,
|
||||
Path = PathTextBox.Text,
|
||||
QUICSecure = QUICSecurityComboBox.Text,
|
||||
QUICSecret = QUICSecretTextBox.Text,
|
||||
TLSSecure = TLSSecureCheckBox.Checked,
|
||||
UseMux = UseMuxCheckBox.Checked
|
||||
});
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
||||
server.Remark = RemarkTextBox.Text;
|
||||
server.Type = "VMess";
|
||||
server.Hostname = AddressTextBox.Text;
|
||||
server.Port = port;
|
||||
server.UserID = UserIDTextBox.Text;
|
||||
server.AlterID = afterId;
|
||||
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[Index] = new Models.Server
|
||||
{
|
||||
Remark = RemarkTextBox.Text,
|
||||
Type = "VMess",
|
||||
Hostname = AddressTextBox.Text,
|
||||
Port = int.Parse(PortTextBox.Text),
|
||||
UserID = UserIDTextBox.Text,
|
||||
AlterID = int.Parse(AlterIDTextBox.Text),
|
||||
EncryptMethod = EncryptMethodComboBox.Text,
|
||||
TransferProtocol = TransferProtocolComboBox.Text,
|
||||
FakeType = FakeTypeComboBox.Text,
|
||||
Host = HostTextBox.Text,
|
||||
Path = PathTextBox.Text,
|
||||
QUICSecure = QUICSecurityComboBox.Text,
|
||||
QUICSecret = QUICSecretTextBox.Text,
|
||||
TLSSecure = TLSSecureCheckBox.Checked,
|
||||
UseMux = UseMuxCheckBox.Checked,
|
||||
Country = null
|
||||
};
|
||||
Global.Settings.Server.Add(server);
|
||||
}
|
||||
|
||||
Configuration.Save();
|
||||
@@ -172,4 +138,4 @@ namespace Netch.Forms.Server
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -76,7 +76,7 @@ namespace Netch.Models
|
||||
/// <summary>
|
||||
/// 协议(SSR)
|
||||
/// </summary>
|
||||
public string Protocol;
|
||||
public string Protocol = Global.Protocols[0];
|
||||
|
||||
/// <summary>
|
||||
/// 协议参数(SSR)
|
||||
@@ -86,7 +86,7 @@ namespace Netch.Models
|
||||
/// <summary>
|
||||
/// 混淆(SSR)
|
||||
/// </summary>
|
||||
public string OBFS;
|
||||
public string OBFS = Global.OBFSs[0];
|
||||
|
||||
/// <summary>
|
||||
/// 混淆参数(SSR)
|
||||
@@ -96,12 +96,12 @@ namespace Netch.Models
|
||||
/// <summary>
|
||||
/// 传输协议(VMess)
|
||||
/// </summary>
|
||||
public string TransferProtocol = "tcp";
|
||||
public string TransferProtocol = Global.TransferProtocols[0];
|
||||
|
||||
/// <summary>
|
||||
/// 伪装类型(VMess)
|
||||
/// </summary>
|
||||
public string FakeType = string.Empty;
|
||||
public string FakeType = Global.FakeTypes[0];
|
||||
|
||||
/// <summary>
|
||||
/// 伪装域名(VMess:HTTP、WebSocket、HTTP/2)
|
||||
@@ -116,7 +116,7 @@ namespace Netch.Models
|
||||
/// <summary>
|
||||
/// QUIC 加密方式(VMess)
|
||||
/// </summary>
|
||||
public string QUICSecure = "none";
|
||||
public string QUICSecure = Global.EncryptMethods.VMessQUIC[0];
|
||||
|
||||
/// <summary>
|
||||
/// QUIC 加密密钥(VMess)
|
||||
@@ -131,7 +131,7 @@ namespace Netch.Models
|
||||
/// <summary>
|
||||
/// Mux 多路复用(VMess)
|
||||
/// </summary>
|
||||
public bool UseMux = false;
|
||||
public bool UseMux = true;
|
||||
|
||||
/// <summary>
|
||||
/// 延迟
|
||||
@@ -144,10 +144,10 @@ namespace Netch.Models
|
||||
public string Country;
|
||||
|
||||
/// <summary>
|
||||
/// 获取备注
|
||||
/// </summary>
|
||||
/// <returns>备注</returns>
|
||||
public override string ToString()
|
||||
/// 获取备注
|
||||
/// </summary>
|
||||
/// <returns>备注</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(Remark))
|
||||
{
|
||||
@@ -220,4 +220,4 @@ namespace Netch.Models
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user