Fix ssr & save wrong index cause by #239 (#241)

Fix ssr & save wrong index cause by #239
This commit is contained in:
Bruce Wayne
2020-01-22 23:12:59 +08:00
committed by GitHub
4 changed files with 45 additions and 33 deletions

View File

@@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.ServiceProcess;
using System.Threading;
using System.Threading.Tasks;
@@ -207,7 +208,14 @@ namespace Netch.Forms
private void SaveConfigs()
{
Global.Settings.ServerComboBoxSelectedIndex = ServerComboBox.SelectedIndex;
Global.Settings.ModeComboBoxSelectedIndex = ModeComboBox.SelectedIndex;
if (ModeComboBox.Tag is object[] list)
{
Global.Settings.ModeComboBoxSelectedIndex = list.ToList().IndexOf(ModeComboBox.SelectedItem);
}
else
{
Global.Settings.ModeComboBoxSelectedIndex = ModeComboBox.Items.IndexOf(ModeComboBox.SelectedItem);
}
Utils.Configuration.Save();
}

View File

@@ -31,9 +31,9 @@
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ShadowsocksR));
this.ConfigurationGroupBox = new System.Windows.Forms.GroupBox();
this.OBFSParamLabel = new System.Windows.Forms.Label();
this.PluginOptionParamTextBox = new System.Windows.Forms.TextBox();
this.OBFSOptionParamTextBox = new System.Windows.Forms.TextBox();
this.OBFSLabel = new System.Windows.Forms.Label();
this.PluginComboBox = new System.Windows.Forms.ComboBox();
this.OBFSComboBox = new System.Windows.Forms.ComboBox();
this.ProtocolParamLabel = new System.Windows.Forms.Label();
this.ProtocolParamTextBox = new System.Windows.Forms.TextBox();
this.ProtocolLabel = new System.Windows.Forms.Label();
@@ -55,9 +55,9 @@
// ConfigurationGroupBox
//
this.ConfigurationGroupBox.Controls.Add(this.OBFSParamLabel);
this.ConfigurationGroupBox.Controls.Add(this.PluginOptionParamTextBox);
this.ConfigurationGroupBox.Controls.Add(this.OBFSOptionParamTextBox);
this.ConfigurationGroupBox.Controls.Add(this.OBFSLabel);
this.ConfigurationGroupBox.Controls.Add(this.PluginComboBox);
this.ConfigurationGroupBox.Controls.Add(this.OBFSComboBox);
this.ConfigurationGroupBox.Controls.Add(this.ProtocolParamLabel);
this.ConfigurationGroupBox.Controls.Add(this.ProtocolParamTextBox);
this.ConfigurationGroupBox.Controls.Add(this.ProtocolLabel);
@@ -90,11 +90,11 @@
//
// OBFSParamTextBox
//
this.PluginOptionParamTextBox.Location = new System.Drawing.Point(120, 227);
this.PluginOptionParamTextBox.Name = "OBFSParamTextBox";
this.PluginOptionParamTextBox.Size = new System.Drawing.Size(294, 23);
this.PluginOptionParamTextBox.TabIndex = 17;
this.PluginOptionParamTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.OBFSOptionParamTextBox.Location = new System.Drawing.Point(120, 227);
this.OBFSOptionParamTextBox.Name = "OBFSParamTextBox";
this.OBFSOptionParamTextBox.Size = new System.Drawing.Size(294, 23);
this.OBFSOptionParamTextBox.TabIndex = 17;
this.OBFSOptionParamTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// OBFSLabel
//
@@ -107,14 +107,14 @@
//
// OBFSComboBox
//
this.PluginComboBox.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
this.PluginComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.PluginComboBox.FormattingEnabled = true;
this.PluginComboBox.Location = new System.Drawing.Point(120, 196);
this.PluginComboBox.Name = "OBFSComboBox";
this.PluginComboBox.Size = new System.Drawing.Size(294, 24);
this.PluginComboBox.TabIndex = 15;
this.PluginComboBox.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.ComboBox_DrawItem);
this.OBFSComboBox.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
this.OBFSComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.OBFSComboBox.FormattingEnabled = true;
this.OBFSComboBox.Location = new System.Drawing.Point(120, 196);
this.OBFSComboBox.Name = "OBFSComboBox";
this.OBFSComboBox.Size = new System.Drawing.Size(294, 24);
this.OBFSComboBox.TabIndex = 15;
this.OBFSComboBox.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.ComboBox_DrawItem);
//
// ProtocolParamLabel
//
@@ -293,8 +293,8 @@
private System.Windows.Forms.TextBox ProtocolParamTextBox;
private System.Windows.Forms.Label ProtocolParamLabel;
private System.Windows.Forms.Label OBFSLabel;
private System.Windows.Forms.ComboBox PluginComboBox;
private System.Windows.Forms.TextBox PluginOptionParamTextBox;
private System.Windows.Forms.ComboBox OBFSComboBox;
private System.Windows.Forms.TextBox OBFSOptionParamTextBox;
private System.Windows.Forms.Label OBFSParamLabel;
}
}

View File

@@ -45,7 +45,7 @@ namespace Netch.Forms.Server
foreach (var obfs in Global.OBFSs)
{
PluginComboBox.Items.Add(obfs);
OBFSComboBox.Items.Add(obfs);
}
if (Index != -1)
@@ -57,14 +57,14 @@ namespace Netch.Forms.Server
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;
PluginComboBox.SelectedIndex = Global.OBFSs.IndexOf(Global.Settings.Server[Index].Plugin);
PluginOptionParamTextBox.Text = Global.Settings.Server[Index].PluginOption;
OBFSComboBox.SelectedIndex = Global.OBFSs.IndexOf(Global.Settings.Server[Index].OBFS);
OBFSOptionParamTextBox.Text = Global.Settings.Server[Index].OBFSParam;
}
else
{
EncryptMethodComboBox.SelectedIndex = 0;
ProtocolComboBox.SelectedIndex = 0;
PluginComboBox.SelectedIndex = 0;
OBFSComboBox.SelectedIndex = 0;
}
}
@@ -116,8 +116,8 @@ namespace Netch.Forms.Server
EncryptMethod = EncryptMethodComboBox.Text,
Protocol = ProtocolComboBox.Text,
ProtocolParam = ProtocolParamTextBox.Text,
Plugin = PluginComboBox.Text,
PluginOption = PluginOptionParamTextBox.Text
OBFS = OBFSComboBox.Text,
OBFSParam = OBFSOptionParamTextBox.Text
});
}
else
@@ -133,8 +133,8 @@ namespace Netch.Forms.Server
EncryptMethod = EncryptMethodComboBox.Text,
Protocol = ProtocolComboBox.Text,
ProtocolParam = ProtocolParamTextBox.Text,
Plugin = PluginComboBox.Text,
PluginOption = PluginOptionParamTextBox.Text
OBFS = OBFSComboBox.Text,
OBFSParam = OBFSOptionParamTextBox.Text
};
}

View File

@@ -175,7 +175,7 @@ namespace Netch.Utils
{
var finder = new Regex(@"^(?<data>.+?)\?(.+)$");
var match = finder.Match(text);
if (match.Success)
{
var plugins = HttpUtility.UrlDecode(HttpUtility.ParseQueryString(new Uri(text).Query).Get("plugin"));
@@ -187,7 +187,7 @@ namespace Netch.Utils
if (!pluginopts.Contains("obfs="))
pluginopts = "obfs=http;obfs-host=" + pluginopts;
}
else if(plugin == "simple-obfs-tls")
else if (plugin == "simple-obfs-tls")
{
plugin = "simple-obfs";
if (!pluginopts.Contains("obfs="))
@@ -361,7 +361,7 @@ namespace Netch.Utils
var parser = new Regex(@"^(?<server>.+):(?<port>(-?\d+?)):(?<protocol>.+?):(?<method>.+?):(?<obfs>.+?):(?<password>.+?)/\?(?<info>.*)$");
var match = parser.Match(URLSafeBase64Decode(text));
if(match.Success)
if (match.Success)
{
data.Hostname = match.Groups["server"].Value;
data.Port = int.Parse(match.Groups["port"].Value);
@@ -386,6 +386,10 @@ namespace Netch.Utils
}
data.OBFS = match.Groups["obfs"].Value;
if (data.OBFS == @"tls1.2_ticket_fastauth")
{
data.OBFS = @"tls1.2_ticket_auth";
}
if (!Global.OBFSs.Contains(data.OBFS))
{
Logging.Info(String.Format("不支持的 SSR 混淆:{0}", data.OBFS));
@@ -452,10 +456,10 @@ namespace Netch.Utils
return null;
}
if(vmess.v == null || vmess.v == "1")
if (vmess.v == null || vmess.v == "1")
{
var info = vmess.host.Split(';');
if(info.Length == 2)
if (info.Length == 2)
{
vmess.host = info[0];
vmess.path = info[1];