Compare commits

...

10 Commits

Author SHA1 Message Date
Connection Refused
b2288817a0 Merge pull request #232 from 54Pany/master
Enhance tun/tap interface metric and fix dns server bug
2020-01-07 23:59:34 +08:00
anonymous
591a4be34d Enhance tun/tap interface metric and fix dns server bug 2020-01-07 23:29:46 +08:00
Connection Refused
74a748e0cf Merge pull request #231 from henning724/master
A simple profile UI which enables you to swtich to different profiles quickly
2020-01-04 18:50:09 +08:00
henning
6eca1085b2 A simple profile UI which enables you to swtich to different profiles quickly.
1. It will enable the UI sooner after you click the "Stop" button, allowing you to switch mode/server much sooner.

2. Adds a Profile UI which allows you to Ctrl+Click to save a profile and Click to switch to a profile.
2020-01-01 20:08:57 +08:00
Connection Refused
b57fb5c77a Merge pull request #230 from zyc199847/v2ray-mux-support
Try to fix v2ray mux issue
2019-12-21 00:01:32 +08:00
Jason
42c3bfa45e Try to fix v2ray mux issue 2019-12-20 23:14:07 +08:00
Connection Refused
365fd609be Update submodule 2019-12-16 20:34:12 +08:00
Tindy X
838a3b34d8 Fix VMess TLS settings 2019-12-09 13:31:55 +08:00
Connection Refused
185c60f509 Merge pull request #225 from ChickenSeller/bugfix_sublink
Suport negative port number in SSR sublink
2019-12-05 23:28:10 +08:00
Kaguya
5eb19586de Bugfix: minus port support 2019-12-05 23:51:19 +09:00
15 changed files with 454 additions and 97 deletions

View File

@@ -100,6 +100,19 @@ namespace Netch.Controllers
if (SavedMode.Type == 2) // 处理仅规则内走直连
{
// 将TAP网卡权重放到最高
Instance = new Process()
{
StartInfo =
{
FileName = String.Format("netsh"),
Arguments = String.Format("interface ip set interface {0} metric=0",Global.TUNTAP.Index),
WindowStyle = ProcessWindowStyle.Hidden,
UseShellExecute = true,
CreateNoWindow = true
}
};
Instance.Start();
// 创建默认路由
if (!NativeMethods.CreateRoute("0.0.0.0", 0, Global.Settings.TUNTAP.Gateway, Global.TUNTAP.Index, 10))
{
@@ -336,7 +349,8 @@ namespace Netch.Controllers
Instance.Kill();
}
pDNSController.Stop();
//pDNSController.Stop();
//修复点击停止按钮后再启动DNS服务没监听的BUG
ClearBypass();
}
catch (Exception e)

View File

@@ -115,8 +115,15 @@ namespace Netch.Controllers
path = server.Path == "" ? "/" : server.Path
} : null,
tlsSettings = new Models.Information.VMess.TLSSettings()
{
allowInsecure = true,
serverName = server.Host == "" ? server.Hostname : server.Host
}
},
mux = new Models.Information.VMess.OutboundMux()
{
enabled = server.UseMux
}
},
new Models.Information.VMess.Outbounds()
{

View File

@@ -50,6 +50,8 @@
this.AboutToolStripButton = new System.Windows.Forms.ToolStripButton();
this.VersionLabel = new System.Windows.Forms.ToolStripLabel();
this.ConfigurationGroupBox = new System.Windows.Forms.GroupBox();
this.ProfileNameText = new System.Windows.Forms.TextBox();
this.ProfileLabel = new System.Windows.Forms.Label();
this.SpeedPictureBox = new System.Windows.Forms.PictureBox();
this.DeletePictureBox = new System.Windows.Forms.PictureBox();
this.EditPictureBox = new System.Windows.Forms.PictureBox();
@@ -68,6 +70,8 @@
this.ShowMainFormToolStripButton = new System.Windows.Forms.ToolStripMenuItem();
this.ExitToolStripButton = new System.Windows.Forms.ToolStripMenuItem();
this.SettingsButton = new System.Windows.Forms.Button();
this.ProfileGroupBox = new System.Windows.Forms.GroupBox();
this.ProfileTable = new System.Windows.Forms.TableLayoutPanel();
this.MenuStrip.SuspendLayout();
this.ConfigurationGroupBox.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.SpeedPictureBox)).BeginInit();
@@ -75,6 +79,7 @@
((System.ComponentModel.ISupportInitialize)(this.EditPictureBox)).BeginInit();
this.StatusStrip.SuspendLayout();
this.NotifyMenu.SuspendLayout();
this.ProfileGroupBox.SuspendLayout();
this.SuspendLayout();
//
// MenuStrip
@@ -91,7 +96,7 @@
this.MenuStrip.Location = new System.Drawing.Point(0, 0);
this.MenuStrip.Name = "MenuStrip";
this.MenuStrip.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional;
this.MenuStrip.Size = new System.Drawing.Size(608, 26);
this.MenuStrip.Size = new System.Drawing.Size(608, 24);
this.MenuStrip.TabIndex = 0;
//
// ServerToolStripMenuItem
@@ -104,41 +109,41 @@
this.AddVMessServerToolStripMenuItem});
this.ServerToolStripMenuItem.Margin = new System.Windows.Forms.Padding(3, 0, 0, 1);
this.ServerToolStripMenuItem.Name = "ServerToolStripMenuItem";
this.ServerToolStripMenuItem.Size = new System.Drawing.Size(57, 21);
this.ServerToolStripMenuItem.Size = new System.Drawing.Size(51, 19);
this.ServerToolStripMenuItem.Text = "Server";
//
// ImportServersFromClipboardToolStripMenuItem
//
this.ImportServersFromClipboardToolStripMenuItem.Name = "ImportServersFromClipboardToolStripMenuItem";
this.ImportServersFromClipboardToolStripMenuItem.Size = new System.Drawing.Size(259, 22);
this.ImportServersFromClipboardToolStripMenuItem.Size = new System.Drawing.Size(236, 22);
this.ImportServersFromClipboardToolStripMenuItem.Text = "Import Servers From Clipboard";
this.ImportServersFromClipboardToolStripMenuItem.Click += new System.EventHandler(this.ImportServersFromClipboardToolStripMenuItem_Click);
//
// AddSocks5ServerToolStripMenuItem
//
this.AddSocks5ServerToolStripMenuItem.Name = "AddSocks5ServerToolStripMenuItem";
this.AddSocks5ServerToolStripMenuItem.Size = new System.Drawing.Size(259, 22);
this.AddSocks5ServerToolStripMenuItem.Size = new System.Drawing.Size(236, 22);
this.AddSocks5ServerToolStripMenuItem.Text = "Add [Socks5] Server";
this.AddSocks5ServerToolStripMenuItem.Click += new System.EventHandler(this.AddSocks5ServerToolStripMenuItem_Click);
//
// AddShadowsocksServerToolStripMenuItem
//
this.AddShadowsocksServerToolStripMenuItem.Name = "AddShadowsocksServerToolStripMenuItem";
this.AddShadowsocksServerToolStripMenuItem.Size = new System.Drawing.Size(259, 22);
this.AddShadowsocksServerToolStripMenuItem.Size = new System.Drawing.Size(236, 22);
this.AddShadowsocksServerToolStripMenuItem.Text = "Add [Shadowsocks] Server";
this.AddShadowsocksServerToolStripMenuItem.Click += new System.EventHandler(this.AddShadowsocksServerToolStripMenuItem_Click);
//
// AddShadowsocksRServerToolStripMenuItem
//
this.AddShadowsocksRServerToolStripMenuItem.Name = "AddShadowsocksRServerToolStripMenuItem";
this.AddShadowsocksRServerToolStripMenuItem.Size = new System.Drawing.Size(259, 22);
this.AddShadowsocksRServerToolStripMenuItem.Size = new System.Drawing.Size(236, 22);
this.AddShadowsocksRServerToolStripMenuItem.Text = "Add [ShadowsocksR] Server";
this.AddShadowsocksRServerToolStripMenuItem.Click += new System.EventHandler(this.AddShadowsocksRServerToolStripMenuItem_Click);
//
// AddVMessServerToolStripMenuItem
//
this.AddVMessServerToolStripMenuItem.Name = "AddVMessServerToolStripMenuItem";
this.AddVMessServerToolStripMenuItem.Size = new System.Drawing.Size(259, 22);
this.AddVMessServerToolStripMenuItem.Size = new System.Drawing.Size(236, 22);
this.AddVMessServerToolStripMenuItem.Text = "Add [VMess] Server";
this.AddVMessServerToolStripMenuItem.Click += new System.EventHandler(this.AddVMessServerToolStripMenuItem_Click);
//
@@ -148,13 +153,13 @@
this.CreateProcessModeToolStripMenuItem});
this.ModeToolStripMenuItem.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
this.ModeToolStripMenuItem.Name = "ModeToolStripMenuItem";
this.ModeToolStripMenuItem.Size = new System.Drawing.Size(55, 21);
this.ModeToolStripMenuItem.Size = new System.Drawing.Size(50, 19);
this.ModeToolStripMenuItem.Text = "Mode";
//
// CreateProcessModeToolStripMenuItem
//
this.CreateProcessModeToolStripMenuItem.Name = "CreateProcessModeToolStripMenuItem";
this.CreateProcessModeToolStripMenuItem.Size = new System.Drawing.Size(202, 22);
this.CreateProcessModeToolStripMenuItem.Size = new System.Drawing.Size(185, 22);
this.CreateProcessModeToolStripMenuItem.Text = "Create Process Mode";
this.CreateProcessModeToolStripMenuItem.Click += new System.EventHandler(this.CreateProcessModeToolStripButton_Click);
//
@@ -165,20 +170,20 @@
this.UpdateServersFromSubscribeLinksToolStripMenuItem});
this.SubscribeToolStripMenuItem.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
this.SubscribeToolStripMenuItem.Name = "SubscribeToolStripMenuItem";
this.SubscribeToolStripMenuItem.Size = new System.Drawing.Size(77, 21);
this.SubscribeToolStripMenuItem.Size = new System.Drawing.Size(70, 19);
this.SubscribeToolStripMenuItem.Text = "Subscribe";
//
// ManageSubscribeLinksToolStripMenuItem
//
this.ManageSubscribeLinksToolStripMenuItem.Name = "ManageSubscribeLinksToolStripMenuItem";
this.ManageSubscribeLinksToolStripMenuItem.Size = new System.Drawing.Size(294, 22);
this.ManageSubscribeLinksToolStripMenuItem.Size = new System.Drawing.Size(267, 22);
this.ManageSubscribeLinksToolStripMenuItem.Text = "Manage Subscribe Links";
this.ManageSubscribeLinksToolStripMenuItem.Click += new System.EventHandler(this.ManageSubscribeLinksToolStripMenuItem_Click);
//
// UpdateServersFromSubscribeLinksToolStripMenuItem
//
this.UpdateServersFromSubscribeLinksToolStripMenuItem.Name = "UpdateServersFromSubscribeLinksToolStripMenuItem";
this.UpdateServersFromSubscribeLinksToolStripMenuItem.Size = new System.Drawing.Size(294, 22);
this.UpdateServersFromSubscribeLinksToolStripMenuItem.Size = new System.Drawing.Size(267, 22);
this.UpdateServersFromSubscribeLinksToolStripMenuItem.Text = "Update Servers From Subscribe Links";
this.UpdateServersFromSubscribeLinksToolStripMenuItem.Click += new System.EventHandler(this.UpdateServersFromSubscribeLinksToolStripMenuItem_Click);
//
@@ -191,34 +196,34 @@
this.CleanDNSCacheToolStripMenuItem});
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);
this.OptionsToolStripMenuItem.Size = new System.Drawing.Size(61, 19);
this.OptionsToolStripMenuItem.Text = "Options";
//
// ReloadModesToolStripMenuItem
//
this.ReloadModesToolStripMenuItem.Name = "ReloadModesToolStripMenuItem";
this.ReloadModesToolStripMenuItem.Size = new System.Drawing.Size(177, 22);
this.ReloadModesToolStripMenuItem.Size = new System.Drawing.Size(166, 22);
this.ReloadModesToolStripMenuItem.Text = "Reload Modes";
this.ReloadModesToolStripMenuItem.Click += new System.EventHandler(this.ReloadModesToolStripMenuItem_Click);
//
// RestartServiceToolStripMenuItem
//
this.RestartServiceToolStripMenuItem.Name = "RestartServiceToolStripMenuItem";
this.RestartServiceToolStripMenuItem.Size = new System.Drawing.Size(177, 22);
this.RestartServiceToolStripMenuItem.Size = new System.Drawing.Size(166, 22);
this.RestartServiceToolStripMenuItem.Text = "Restart Service";
this.RestartServiceToolStripMenuItem.Click += new System.EventHandler(this.RestartServiceToolStripMenuItem_Click);
//
// UninstallServiceToolStripMenuItem
//
this.UninstallServiceToolStripMenuItem.Name = "UninstallServiceToolStripMenuItem";
this.UninstallServiceToolStripMenuItem.Size = new System.Drawing.Size(177, 22);
this.UninstallServiceToolStripMenuItem.Size = new System.Drawing.Size(166, 22);
this.UninstallServiceToolStripMenuItem.Text = "Uninstall Service";
this.UninstallServiceToolStripMenuItem.Click += new System.EventHandler(this.UninstallServiceToolStripMenuItem_Click);
//
// CleanDNSCacheToolStripMenuItem
//
this.CleanDNSCacheToolStripMenuItem.Name = "CleanDNSCacheToolStripMenuItem";
this.CleanDNSCacheToolStripMenuItem.Size = new System.Drawing.Size(177, 22);
this.CleanDNSCacheToolStripMenuItem.Size = new System.Drawing.Size(166, 22);
this.CleanDNSCacheToolStripMenuItem.Text = "Clean DNS Cache";
this.CleanDNSCacheToolStripMenuItem.Click += new System.EventHandler(this.CleanDNSCacheToolStripMenuItem_Click);
//
@@ -228,7 +233,7 @@
this.AboutToolStripButton.AutoToolTip = false;
this.AboutToolStripButton.Margin = new System.Windows.Forms.Padding(0, 0, 3, 1);
this.AboutToolStripButton.Name = "AboutToolStripButton";
this.AboutToolStripButton.Size = new System.Drawing.Size(47, 21);
this.AboutToolStripButton.Size = new System.Drawing.Size(44, 19);
this.AboutToolStripButton.Text = "About";
this.AboutToolStripButton.Click += new System.EventHandler(this.AboutToolStripButton_Click);
//
@@ -240,12 +245,14 @@
this.VersionLabel.IsLink = true;
this.VersionLabel.LinkBehavior = System.Windows.Forms.LinkBehavior.NeverUnderline;
this.VersionLabel.Name = "VersionLabel";
this.VersionLabel.Size = new System.Drawing.Size(35, 19);
this.VersionLabel.Size = new System.Drawing.Size(31, 17);
this.VersionLabel.Text = "x.x.x";
this.VersionLabel.Click += new System.EventHandler(this.VersionLabel_Click);
//
// ConfigurationGroupBox
//
this.ConfigurationGroupBox.Controls.Add(this.ProfileNameText);
this.ConfigurationGroupBox.Controls.Add(this.ProfileLabel);
this.ConfigurationGroupBox.Controls.Add(this.SpeedPictureBox);
this.ConfigurationGroupBox.Controls.Add(this.DeletePictureBox);
this.ConfigurationGroupBox.Controls.Add(this.EditPictureBox);
@@ -255,11 +262,27 @@
this.ConfigurationGroupBox.Controls.Add(this.ServerLabel);
this.ConfigurationGroupBox.Location = new System.Drawing.Point(12, 28);
this.ConfigurationGroupBox.Name = "ConfigurationGroupBox";
this.ConfigurationGroupBox.Size = new System.Drawing.Size(584, 86);
this.ConfigurationGroupBox.Size = new System.Drawing.Size(584, 116);
this.ConfigurationGroupBox.TabIndex = 1;
this.ConfigurationGroupBox.TabStop = false;
this.ConfigurationGroupBox.Text = "Configuration";
//
// ProfileNameText
//
this.ProfileNameText.Location = new System.Drawing.Point(96, 88);
this.ProfileNameText.Name = "ProfileNameText";
this.ProfileNameText.Size = new System.Drawing.Size(415, 23);
this.ProfileNameText.TabIndex = 11;
//
// label1
//
this.ProfileLabel.AutoSize = true;
this.ProfileLabel.Location = new System.Drawing.Point(6, 89);
this.ProfileLabel.Name = "label1";
this.ProfileLabel.Size = new System.Drawing.Size(84, 17);
this.ProfileLabel.TabIndex = 10;
this.ProfileLabel.Text = "Profile Name";
//
// SpeedPictureBox
//
this.SpeedPictureBox.Cursor = System.Windows.Forms.Cursors.Hand;
@@ -344,7 +367,7 @@
this.UsedBandwidthLabel,
this.DownloadSpeedLabel,
this.UploadSpeedLabel});
this.StatusStrip.Location = new System.Drawing.Point(0, 154);
this.StatusStrip.Location = new System.Drawing.Point(0, 235);
this.StatusStrip.Name = "StatusStrip";
this.StatusStrip.Size = new System.Drawing.Size(608, 22);
this.StatusStrip.SizingGrip = false;
@@ -354,33 +377,33 @@
//
this.StatusLabel.BackColor = System.Drawing.Color.Transparent;
this.StatusLabel.Name = "StatusLabel";
this.StatusLabel.Size = new System.Drawing.Size(177, 17);
this.StatusLabel.Size = new System.Drawing.Size(162, 17);
this.StatusLabel.Text = "Status: Waiting for command";
//
// UsedBandwidthLabel
//
this.UsedBandwidthLabel.Name = "UsedBandwidthLabel";
this.UsedBandwidthLabel.Size = new System.Drawing.Size(72, 17);
this.UsedBandwidthLabel.Size = new System.Drawing.Size(62, 17);
this.UsedBandwidthLabel.Text = "Used: 0 KB";
this.UsedBandwidthLabel.Visible = false;
//
// DownloadSpeedLabel
//
this.DownloadSpeedLabel.Name = "DownloadSpeedLabel";
this.DownloadSpeedLabel.Size = new System.Drawing.Size(59, 17);
this.DownloadSpeedLabel.Size = new System.Drawing.Size(52, 17);
this.DownloadSpeedLabel.Text = "↓: 0 KB/s";
this.DownloadSpeedLabel.Visible = false;
//
// UploadSpeedLabel
//
this.UploadSpeedLabel.Name = "UploadSpeedLabel";
this.UploadSpeedLabel.Size = new System.Drawing.Size(59, 17);
this.UploadSpeedLabel.Size = new System.Drawing.Size(52, 17);
this.UploadSpeedLabel.Text = "↑: 0 KB/s";
this.UploadSpeedLabel.Visible = false;
//
// ControlButton
//
this.ControlButton.Location = new System.Drawing.Point(521, 120);
this.ControlButton.Location = new System.Drawing.Point(521, 205);
this.ControlButton.Name = "ControlButton";
this.ControlButton.Size = new System.Drawing.Size(75, 27);
this.ControlButton.TabIndex = 3;
@@ -404,25 +427,25 @@
this.ExitToolStripButton});
this.NotifyMenu.Name = "NotifyMenu";
this.NotifyMenu.ShowItemToolTips = false;
this.NotifyMenu.Size = new System.Drawing.Size(108, 48);
this.NotifyMenu.Size = new System.Drawing.Size(104, 48);
//
// ShowMainFormToolStripButton
//
this.ShowMainFormToolStripButton.Name = "ShowMainFormToolStripButton";
this.ShowMainFormToolStripButton.Size = new System.Drawing.Size(107, 22);
this.ShowMainFormToolStripButton.Size = new System.Drawing.Size(103, 22);
this.ShowMainFormToolStripButton.Text = "Show";
this.ShowMainFormToolStripButton.Click += new System.EventHandler(this.ShowMainFormToolStripButton_Click);
//
// ExitToolStripButton
//
this.ExitToolStripButton.Name = "ExitToolStripButton";
this.ExitToolStripButton.Size = new System.Drawing.Size(107, 22);
this.ExitToolStripButton.Size = new System.Drawing.Size(103, 22);
this.ExitToolStripButton.Text = "Exit";
this.ExitToolStripButton.Click += new System.EventHandler(this.ExitToolStripButton_Click);
//
// SettingsButton
//
this.SettingsButton.Location = new System.Drawing.Point(12, 120);
this.SettingsButton.Location = new System.Drawing.Point(12, 205);
this.SettingsButton.Name = "SettingsButton";
this.SettingsButton.Size = new System.Drawing.Size(72, 24);
this.SettingsButton.TabIndex = 4;
@@ -430,17 +453,44 @@
this.SettingsButton.UseVisualStyleBackColor = true;
this.SettingsButton.Click += new System.EventHandler(this.SettingsButton_Click);
//
// profileGroupBox
//
this.ProfileGroupBox.Controls.Add(this.ProfileTable);
this.ProfileGroupBox.Location = new System.Drawing.Point(12, 145);
this.ProfileGroupBox.Name = "profileGroupBox";
this.ProfileGroupBox.Size = new System.Drawing.Size(584, 61);
this.ProfileGroupBox.TabIndex = 13;
this.ProfileGroupBox.TabStop = false;
this.ProfileGroupBox.Text = "Profiles";
//
// profileTable
//
this.ProfileTable.AutoSize = true;
this.ProfileTable.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.ProfileTable.ColumnCount = 2;
this.ProfileTable.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.ProfileTable.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.ProfileTable.Dock = System.Windows.Forms.DockStyle.Fill;
this.ProfileTable.Location = new System.Drawing.Point(3, 19);
this.ProfileTable.Name = "profileTable";
this.ProfileTable.RowCount = 1;
this.ProfileTable.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.ProfileTable.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.ProfileTable.Size = new System.Drawing.Size(578, 39);
this.ProfileTable.TabIndex = 0;
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.ClientSize = new System.Drawing.Size(608, 176);
this.ClientSize = new System.Drawing.Size(608, 257);
this.Controls.Add(this.ProfileGroupBox);
this.Controls.Add(this.SettingsButton);
this.Controls.Add(this.ControlButton);
this.Controls.Add(this.StatusStrip);
this.Controls.Add(this.ConfigurationGroupBox);
this.Controls.Add(this.MenuStrip);
this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.Font = new System.Drawing.Font("Microsoft YaHei", 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);
@@ -460,6 +510,8 @@
this.StatusStrip.ResumeLayout(false);
this.StatusStrip.PerformLayout();
this.NotifyMenu.ResumeLayout(false);
this.ProfileGroupBox.ResumeLayout(false);
this.ProfileGroupBox.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
@@ -505,5 +557,9 @@
private System.Windows.Forms.ToolStripStatusLabel UploadSpeedLabel;
private System.Windows.Forms.ToolStripStatusLabel DownloadSpeedLabel;
private System.Windows.Forms.ToolStripMenuItem CleanDNSCacheToolStripMenuItem;
private System.Windows.Forms.Label ProfileLabel;
private System.Windows.Forms.TextBox ProfileNameText;
private System.Windows.Forms.GroupBox ProfileGroupBox;
private System.Windows.Forms.TableLayoutPanel ProfileTable;
}
}

View File

@@ -38,6 +38,8 @@ namespace Netch.Forms
/// </summary>
public bool IsFirstOpened = true;
public List<Button> ProfileButtons = new List<Button>();
public MainForm()
{
InitializeComponent();
@@ -299,6 +301,8 @@ namespace Netch.Forms
ShowMainFormToolStripButton.Text = Utils.i18N.Translate("Show");
ExitToolStripButton.Text = Utils.i18N.Translate("Exit");
InitProfile();
// 自动检测延迟
Task.Run(() =>
{
@@ -821,6 +825,10 @@ namespace Netch.Forms
StatusLabel.Text = $"{Utils.i18N.Translate("Status")}{Utils.i18N.Translate(": ")}{Utils.i18N.Translate("Stopping")}";
State = Models.State.Stopping;
MenuStrip.Enabled = ConfigurationGroupBox.Enabled = SettingsButton.Enabled = true;
ProfileGroupBox.Enabled = false;
Task.Run(() =>
{
var server = ServerComboBox.SelectedItem as Models.Server;
@@ -838,7 +846,9 @@ namespace Netch.Forms
UsedBandwidthLabel.Visible = UploadSpeedLabel.Visible = DownloadSpeedLabel.Visible = false;
}
MenuStrip.Enabled = ConfigurationGroupBox.Enabled = ControlButton.Enabled = SettingsButton.Enabled = true;
ControlButton.Enabled = true;
ProfileGroupBox.Enabled = true;
ControlButton.Text = Utils.i18N.Translate("Start");
StatusLabel.Text = $"{Utils.i18N.Translate("Status")}{Utils.i18N.Translate(": ")}{Utils.i18N.Translate("Stopped")}";
State = Models.State.Stopped;
@@ -930,5 +940,147 @@ namespace Netch.Forms
LastDownloadBandwidth = download;
Refresh();
}
private void ProfileButton_Click(object sender, EventArgs e)
{
int index = ProfileButtons.IndexOf((Button)sender);
//Utils.Logging.Info(String.Format("Button no.{0} clicked", index));
if (Control.ModifierKeys == Keys.Control)
{
SaveProfile(index);
ProfileButtons[index].Text = ProfileNameText.Text;
}
else
{
try
{
ProfileNameText.Text = LoadProfile(index);
// start the profile
bool need2ndStart = true;
if (State == Models.State.Waiting || State == Models.State.Stopped)
{
need2ndStart = false;
}
ControlButton.PerformClick();
if (need2ndStart)
{
Task.Run(() =>
{
while (State != Models.State.Stopped)
{
Thread.Sleep(200);
}
ControlButton.PerformClick();
});
}
}
catch (Exception ee)
{
Utils.Logging.Info(ee.Message);
ProfileButtons[index].Text = "Error";
}
}
}
public void InitProfile()
{
int num_profile = 4;
ProfileTable.ColumnCount = num_profile;
while (Global.Settings.profiles.Count < num_profile)
{
Global.Settings.profiles.Add(new Models.Profile());
}
// buttons
for (int i = 0; i < num_profile; ++i)
{
var b = new Button();
ProfileTable.Controls.Add(b,i,0);
b.Location = new Point(i * 100, 0);
b.Click += new EventHandler(ProfileButton_Click);
b.Dock = DockStyle.Fill;
ProfileButtons.Add(b);
if (!Global.Settings.profiles[i].IsDummy)
{
b.Text = Global.Settings.profiles[i].ProfileName;
}
else
{
b.Text = "None";
}
}
// equal column
this.ProfileTable.ColumnStyles.Clear();
for (int i = 1; i <= this.ProfileTable.RowCount; i++)
{
ProfileTable.RowStyles.Add(new RowStyle(SizeType.Percent, 1));
}
for (int i = 1; i <= this.ProfileTable.ColumnCount; i++)
{
ProfileTable.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 1));
}
}
private String LoadProfile(int index)
{
Models.Profile p = Global.Settings.profiles[index];
if (p.IsDummy)
throw new Exception("Profile not found.");
bool result = false;
foreach(Models.Server server in ServerComboBox.Items)
{
if (server.Remark.Equals(p.ServerRemark))
{
ServerComboBox.SelectedItem = server;
result = true;
break;
}
}
if (!result)
throw new Exception("Server not found.");
result = false;
foreach (Models.Mode mode in ModeComboBox.Items)
{
if (mode.Remark.Equals(p.ModeRemark))
{
ModeComboBox.SelectedItem = mode;
result = true;
break;
}
}
if (!result)
throw new Exception("Mode not found.");
return p.ProfileName;
}
private void SaveProfile(int index)
{
var selectedServer = (Models.Server)ServerComboBox.SelectedItem;
var selectedMode = (Models.Mode)ModeComboBox.SelectedItem;
String name = ProfileNameText.Text;
Global.Settings.profiles[index] = new Models.Profile(selectedServer, selectedMode, name);
}
}
}

View File

@@ -30,6 +30,7 @@
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(VMess));
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();
@@ -61,6 +62,7 @@
//
// 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);
@@ -86,19 +88,33 @@
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.Location = new System.Drawing.Point(18, 18);
this.ConfigurationGroupBox.Margin = new System.Windows.Forms.Padding(4);
this.ConfigurationGroupBox.Name = "ConfigurationGroupBox";
this.ConfigurationGroupBox.Size = new System.Drawing.Size(420, 373);
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(302, 346);
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(90, 21);
this.TLSSecureCheckBox.Size = new System.Drawing.Size(127, 28);
this.TLSSecureCheckBox.TabIndex = 24;
this.TLSSecureCheckBox.Text = "TLS Secure";
this.TLSSecureCheckBox.UseVisualStyleBackColor = true;
@@ -106,26 +122,29 @@
// QUICSecretLabel
//
this.QUICSecretLabel.AutoSize = true;
this.QUICSecretLabel.Location = new System.Drawing.Point(10, 320);
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(79, 17);
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(10, 290);
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(88, 17);
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(120, 317);
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(294, 23);
this.QUICSecretTextBox.Size = new System.Drawing.Size(439, 31);
this.QUICSecretTextBox.TabIndex = 23;
this.QUICSecretTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
@@ -134,52 +153,58 @@
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(120, 286);
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(294, 24);
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(10, 260);
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(33, 17);
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(120, 257);
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(294, 23);
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(10, 231);
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(35, 17);
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(120, 228);
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(294, 23);
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(10, 201);
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(67, 17);
this.FakeTypeLabel.Size = new System.Drawing.Size(97, 24);
this.FakeTypeLabel.TabIndex = 14;
this.FakeTypeLabel.Text = "Fake Type";
//
@@ -188,18 +213,20 @@
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(120, 197);
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(294, 24);
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(10, 170);
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(109, 17);
this.TransferProtocolLabel.Size = new System.Drawing.Size(156, 24);
this.TransferProtocolLabel.TabIndex = 12;
this.TransferProtocolLabel.Text = "Transfer Protocol";
//
@@ -208,18 +235,20 @@
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(120, 166);
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(294, 24);
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(10, 139);
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(101, 17);
this.EncryptMethodLabel.Size = new System.Drawing.Size(150, 24);
this.EncryptMethodLabel.TabIndex = 10;
this.EncryptMethodLabel.Text = "Encrypt Method";
//
@@ -228,102 +257,114 @@
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, 135);
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(294, 24);
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(10, 109);
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(52, 17);
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(120, 106);
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(54, 23);
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(10, 80);
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(52, 17);
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(120, 77);
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(294, 23);
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(360, 48);
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(54, 23);
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(120, 48);
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(234, 23);
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(10, 51);
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(56, 17);
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(120, 19);
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(294, 23);
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(10, 22);
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(53, 17);
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(353, 51);
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(11, 17);
this.PortLabel.Size = new System.Drawing.Size(14, 24);
this.PortLabel.TabIndex = 4;
this.PortLabel.Text = ":";
//
// ControlButton
//
this.ControlButton.Location = new System.Drawing.Point(357, 391);
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(75, 23);
this.ControlButton.Size = new System.Drawing.Size(112, 34);
this.ControlButton.TabIndex = 2;
this.ControlButton.Text = "Save";
this.ControlButton.UseVisualStyleBackColor = true;
@@ -331,15 +372,15 @@
//
// VMess
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleDimensions = new System.Drawing.SizeF(144F, 144F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.ClientSize = new System.Drawing.Size(444, 426);
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(3, 4, 3, 4);
this.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6);
this.MaximizeBox = false;
this.Name = "VMess";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
@@ -381,5 +422,6 @@
private System.Windows.Forms.Label QUICSecretLabel;
private System.Windows.Forms.CheckBox TLSSecureCheckBox;
private System.Windows.Forms.Button ControlButton;
private System.Windows.Forms.CheckBox UseMuxCheckBox;
}
}

View File

@@ -55,6 +55,7 @@ namespace Netch.Forms.Server
QUICSecurityLabel.Text = Utils.i18N.Translate("QUIC Security");
QUICSecretLabel.Text = Utils.i18N.Translate("QUIC Secret");
TLSSecureCheckBox.Text = Utils.i18N.Translate("TLS Secure");
UseMuxCheckBox.Text = Utils.i18N.Translate("Use Mux");
ControlButton.Text = Utils.i18N.Translate("Save");
foreach (var encrypt in Global.EncryptMethods.VMess)
@@ -92,6 +93,7 @@ namespace Netch.Forms.Server
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
{
@@ -126,7 +128,8 @@ namespace Netch.Forms.Server
Path = PathTextBox.Text,
QUICSecure = QUICSecurityComboBox.Text,
QUICSecret = QUICSecretTextBox.Text,
TLSSecure = TLSSecureCheckBox.Checked
TLSSecure = TLSSecureCheckBox.Checked,
UseMux = UseMuxCheckBox.Checked
});
}
else
@@ -146,7 +149,8 @@ namespace Netch.Forms.Server
Path = PathTextBox.Text,
QUICSecure = QUICSecurityComboBox.Text,
QUICSecret = QUICSecretTextBox.Text,
TLSSecure = TLSSecureCheckBox.Checked
TLSSecure = TLSSecureCheckBox.Checked,
UseMux = UseMuxCheckBox.Checked
};
}

View File

@@ -128,6 +128,8 @@ namespace Netch.Models.Information
public class TLSSettings
{
public bool allowInsecure = true;
public string serverName;
}
public class OutboundSettings
@@ -137,7 +139,7 @@ namespace Netch.Models.Information
public class OutboundMux
{
public bool enabled = true;
public bool enabled = false;
}
public class StreamSettings

30
Netch/Models/Profile.cs Normal file
View File

@@ -0,0 +1,30 @@
using System;
namespace Netch.Models
{
public class Profile
{
public String ServerRemark;
public String ModeRemark;
public String ProfileName;
public bool IsDummy = true;
public Profile(Server server, Mode mode, String name)
{
ServerRemark = server.Remark;
ModeRemark = mode.Remark;
ProfileName = name;
IsDummy = false;
}
/// <summary>
/// Return a dummy one.
/// </summary>
public Profile()
{
}
}
}

View File

@@ -128,6 +128,11 @@ namespace Netch.Models
/// </summary>
public bool TLSSecure = false;
/// <summary>
/// Mux 多路复用VMess
/// </summary>
public bool UseMux = false;
/// <summary>
/// 延迟
/// </summary>

View File

@@ -118,5 +118,11 @@ namespace Netch.Models
/// 全局绕过 IP 列表
/// </summary>
public List<string> BypassIPs = new List<string>();
/// <summary>
/// Saved profiles
/// </summary>
public List<Profile> profiles = new List<Profile>();
}
}

View File

@@ -5,6 +5,14 @@
/// </summary>
public class VMess
{
/// <summary>
/// Mux Class
/// </summary>
public class Mux
{
public object enabled;
}
/// <summary>
/// 链接版本
/// </summary>
@@ -59,5 +67,10 @@
/// 是否使用 TLS
/// </summary>
public string tls;
/// <summary>
/// Mux 多路复用
/// </summary>
public Mux mux;
}
}

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
@@ -294,6 +294,7 @@
<Compile Include="Models\GitHubRelease\VersionUtil.cs" />
<Compile Include="Models\LegacyServer.cs" />
<Compile Include="Models\LegacySetting.cs" />
<Compile Include="Models\Profile.cs" />
<Compile Include="NativeMethods.cs" />
<Compile Include="Netch.cs" />
<Compile Include="Models\Information\VMess.cs" />

View File

@@ -41,6 +41,7 @@
"QUIC Security": "QUIC 加密方式",
"QUIC Secret": "QUIC 加密密钥",
"TLS Secure": "TLS 底层传输安全",
"Use Mux": "Mux 多路复用",
"Encrypt Method": "加密方式",
"Protocol": "协议",
"Protocol Param": "协议参数",

View File

@@ -358,13 +358,17 @@ namespace Netch.Utils
data.Type = "SS";
}
*/
var parser = new Regex(@"^(?<server>.+):(?<port>\d+?):(?<protocol>.+?):(?<method>.+?):(?<obfs>.+?):(?<password>.+?)/\?(?<info>.*)$");
var parser = new Regex(@"^(?<server>.+):(?<port>(-?\d+?)):(?<protocol>.+?):(?<method>.+?):(?<obfs>.+?):(?<password>.+?)/\?(?<info>.*)$");
var match = parser.Match(URLSafeBase64Decode(text));
if(match.Success)
{
data.Hostname = match.Groups["server"].Value;
data.Port = int.Parse(match.Groups["port"].Value);
if (data.Port < 0)
{
data.Port += 65536;
}
data.Password = URLSafeBase64Decode(match.Groups["password"].Value);
data.EncryptMethod = match.Groups["method"].Value;
@@ -478,6 +482,26 @@ namespace Netch.Utils
}
data.TLSSecure = vmess.tls == "tls";
if (vmess.mux == null)
{
data.UseMux = false;
}
else
{
if (vmess.mux.enabled is Boolean)
{
data.UseMux = (bool)vmess.mux.enabled;
}
else if (vmess.mux.enabled is String)
{
data.UseMux = (string)vmess.mux.enabled == "true"; // 针对使用字符串当作布尔值的情况
}
else
{
data.UseMux = false;
}
}
data.EncryptMethod = "auto"; // V2Ray 加密方式不包括在链接中,主动添加一个
list.Add(data);

2
modes

Submodule modes updated: c994796add...cff55c0541