Skip to content

Commit

Permalink
Fix ssr & save wrong index cause by netchx#239 (netchx#241)
Browse files Browse the repository at this point in the history
Fix ssr & save wrong index cause by netchx#239
  • Loading branch information
HMBSbige authored Jan 22, 2020
2 parents 948e407 + 2196d73 commit a2cecf4
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 33 deletions.
10 changes: 9 additions & 1 deletion Netch/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.ServiceProcess;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -207,7 +208,14 @@ public void AddMode(Models.Mode mode)
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();
}

Expand Down
38 changes: 19 additions & 19 deletions Netch/Forms/Server/ShadowsocksR.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions Netch/Forms/Server/ShadowsocksR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private void ShadowsocksR_Load(object sender, EventArgs e)

foreach (var obfs in Global.OBFSs)
{
PluginComboBox.Items.Add(obfs);
OBFSComboBox.Items.Add(obfs);
}

if (Index != -1)
Expand All @@ -57,14 +57,14 @@ private void ShadowsocksR_Load(object sender, EventArgs e)
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;
}
}

Expand Down Expand Up @@ -116,8 +116,8 @@ private void ControlButton_Click(object sender, EventArgs e)
EncryptMethod = EncryptMethodComboBox.Text,
Protocol = ProtocolComboBox.Text,
ProtocolParam = ProtocolParamTextBox.Text,
Plugin = PluginComboBox.Text,
PluginOption = PluginOptionParamTextBox.Text
OBFS = OBFSComboBox.Text,
OBFSParam = OBFSOptionParamTextBox.Text
});
}
else
Expand All @@ -133,8 +133,8 @@ private void ControlButton_Click(object sender, EventArgs e)
EncryptMethod = EncryptMethodComboBox.Text,
Protocol = ProtocolComboBox.Text,
ProtocolParam = ProtocolParamTextBox.Text,
Plugin = PluginComboBox.Text,
PluginOption = PluginOptionParamTextBox.Text
OBFS = OBFSComboBox.Text,
OBFSParam = OBFSOptionParamTextBox.Text
};
}

Expand Down
14 changes: 9 additions & 5 deletions Netch/Utils/ShareLink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public static string URLSafeBase64Decode(string text)
{
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"));
Expand All @@ -187,7 +187,7 @@ public static string URLSafeBase64Decode(string text)
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="))
Expand Down Expand Up @@ -361,7 +361,7 @@ public static string URLSafeBase64Decode(string text)
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);
Expand All @@ -386,6 +386,10 @@ public static string URLSafeBase64Decode(string text)
}

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));
Expand Down Expand Up @@ -452,10 +456,10 @@ public static string URLSafeBase64Decode(string text)
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];
Expand Down

0 comments on commit a2cecf4

Please sign in to comment.