From e22f15159c28f48c5219a206c6df738169497229 Mon Sep 17 00:00:00 2001 From: ProxySU Date: Thu, 16 Apr 2020 14:00:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0WebSocket+TLS(=E8=87=AA?= =?UTF-8?q?=E7=AD=BE=E8=AF=81=E4=B9=A6)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProxySU/MainWindow.xaml | 1 + ProxySU/MainWindow.xaml.cs | 53 ++++++++++++++++++----- ProxySU/TemplateConfiguration.xaml | 6 +-- ProxySU/TemplateConfiguration.xaml.cs | 60 +++++++++++++++++++++++---- 4 files changed, 98 insertions(+), 22 deletions(-) diff --git a/ProxySU/MainWindow.xaml b/ProxySU/MainWindow.xaml index 53a6ae5..5974734 100644 --- a/ProxySU/MainWindow.xaml +++ b/ProxySU/MainWindow.xaml @@ -172,6 +172,7 @@ --> + diff --git a/ProxySU/MainWindow.xaml.cs b/ProxySU/MainWindow.xaml.cs index 6629b41..7affaad 100644 --- a/ProxySU/MainWindow.xaml.cs +++ b/ProxySU/MainWindow.xaml.cs @@ -209,6 +209,11 @@ namespace ProxySU serverConfig = "TemplateConfg\\WebSocket_TLS_server_config.json"; clientConfig = "TemplateConfg\\WebSocket_TLS_client_config.json"; } + else if (String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLSselfSigned")) + { + serverConfig = "TemplateConfg\\WebSocket_TLS_selfSigned_server_config.json"; + clientConfig = "TemplateConfg\\WebSocket_TLS_selfSigned_client_config.json"; + } else if (String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLS2Web")) { serverConfig = "TemplateConfg\\WebSocketTLSWeb_server_config.json"; @@ -557,6 +562,9 @@ namespace ProxySU MessageBox.Show("域名未能正确解析到当前VPS的IP上,请检查!若解析设置正确,请等待生效后再重试安装。如果域名使用了CDN,请先关闭!"); return; } + + } + if (serverConfig.Contains("TLS") == true || serverConfig.Contains("http2") == true) { //检测是否安装lsof if (string.IsNullOrEmpty(client.RunCommand("command -v lsof").Result) == true) { @@ -582,7 +590,7 @@ namespace ProxySU Thread.Sleep(1000); //MessageBox.Show(@"lsof -n -P -i :80 | grep LISTEN"); //MessageBox.Show(client.RunCommand(@"lsof -n -P -i :80 | grep LISTEN").Result); - if (String.IsNullOrEmpty(client.RunCommand(@"lsof -n -P -i :80 | grep LISTEN").Result)==false || String.IsNullOrEmpty(client.RunCommand(@"lsof -n -P -i :443 | grep LISTEN").Result)==false) + if (String.IsNullOrEmpty(client.RunCommand(@"lsof -n -P -i :80 | grep LISTEN").Result) == false || String.IsNullOrEmpty(client.RunCommand(@"lsof -n -P -i :443 | grep LISTEN").Result) == false) { MessageBox.Show("80/443端口之一,或全部被占用,请先用系统工具中的“释放80/443端口”工具,释放出,再重新安装"); currentStatus = "端口被占用,安装失败......"; @@ -591,7 +599,6 @@ namespace ProxySU return; } } - currentStatus = "符合安装要求,布署中......"; textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); Thread.Sleep(1000); @@ -621,7 +628,7 @@ namespace ProxySU //下载官方安装脚本安装 client.RunCommand("curl -o /tmp/go.sh https://install.direct/go.sh"); - client.RunCommand("bash /tmp/go.sh"); + client.RunCommand("bash /tmp/go.sh -f"); string installResult = client.RunCommand("find / -name v2ray").Result.ToString(); if (!installResult.Contains("/usr/bin/v2ray")) @@ -650,8 +657,8 @@ namespace ProxySU { serverJson["inbounds"][0]["port"] = ReceiveConfigurationParameters[1]; } - //tcp+TLS自签证书模式下 - if (serverConfig.Contains("tcpTLSselfSigned") == true) + //TLS自签证书模式下 + if (serverConfig.Contains("selfSigned") == true) { string selfSignedCa = client.RunCommand("/usr/bin/v2ray/v2ctl cert --ca").Result; JObject selfSignedCaJObject = JObject.Parse(selfSignedCa); @@ -1052,6 +1059,12 @@ namespace ProxySU //打开模板设置窗口 private void ButtonTemplateConfiguration_Click(object sender, RoutedEventArgs e) { + //清空初始化模板参数 + for (int i = 0; i != ReceiveConfigurationParameters.Length; i++) + + { + ReceiveConfigurationParameters[i] = i.ToString(); + } WindowTemplateConfiguration windowTemplateConfiguration = new WindowTemplateConfiguration(); windowTemplateConfiguration.ShowDialog(); } @@ -1090,22 +1103,26 @@ namespace ProxySU cmdTestPort = @"lsof -n -P -i :443 | grep LISTEN"; cmdResult = client.RunCommand(cmdTestPort).Result; //MessageBox.Show(cmdTestPort); - if (String.IsNullOrEmpty(cmdTestPort)==false) + if (String.IsNullOrEmpty(cmdResult) ==false) { //MessageBox.Show(cmdResult); string[] cmdResultArry443 = cmdResult.Split(' '); - + //MessageBox.Show(cmdResultArry443[3]); + client.RunCommand($"systemctl stop {cmdResultArry443[0]}"); + client.RunCommand($"systemctl disable {cmdResultArry443[0]}"); client.RunCommand($"kill -9 {cmdResultArry443[3]}"); } cmdTestPort = @"lsof -n -P -i :80 | grep LISTEN"; cmdResult = client.RunCommand(cmdTestPort).Result; - if (String.IsNullOrEmpty(cmdTestPort) == false) + if (String.IsNullOrEmpty(cmdResult) == false) { string[] cmdResultArry80 = cmdResult.Split(' '); + client.RunCommand($"systemctl stop {cmdResultArry80[0]}"); + client.RunCommand($"systemctl disable {cmdResultArry80[0]}"); client.RunCommand($"kill -9 {cmdResultArry80[3]}"); } - + MessageBox.Show("执行完毕!"); client.Disconnect(); } } @@ -1160,6 +1177,22 @@ namespace ProxySU } } + private void Button_Click(object sender, RoutedEventArgs e) + { + string[] testString = new string[6]; + for (int i = 0; i != testString.Length; i++) + + { + + testString[i] = i.ToString(); + + } + foreach (string str in testString) + { + MessageBox.Show(str); + } + } + //private void TestresultClientInform_Click(object sender, RoutedEventArgs e) //{ // ResultClientInformation resultClientInformation = new ResultClientInformation(); @@ -1233,7 +1266,7 @@ namespace ProxySU // //生成安装服务命令中的邮箱 // //string sshCmdEmail = $"email={emailAddress};email=${{email/./@}};echo $email"; // //string email = client.RunCommand(sshCmdEmail).Result.ToString(); - + // //MessageBox.Show(email); // //安装Caddy服务 diff --git a/ProxySU/TemplateConfiguration.xaml b/ProxySU/TemplateConfiguration.xaml index 3493944..b118533 100644 --- a/ProxySU/TemplateConfiguration.xaml +++ b/ProxySU/TemplateConfiguration.xaml @@ -113,13 +113,13 @@ - - + - + diff --git a/ProxySU/TemplateConfiguration.xaml.cs b/ProxySU/TemplateConfiguration.xaml.cs index 0932846..9df91bd 100644 --- a/ProxySU/TemplateConfiguration.xaml.cs +++ b/ProxySU/TemplateConfiguration.xaml.cs @@ -102,6 +102,17 @@ namespace ProxySU //传递域名 MainWindow.ReceiveConfigurationParameters[4] = TextBoxDomain.Text.ToString(); + } + //WebSocket+TLS(自签证书)模式被选中 + else if (RadioButtonWebSocketTLSselfSigned.IsChecked == true) + { + //传递模板类型 + MainWindow.ReceiveConfigurationParameters[0] = "WebSocketTLSselfSigned"; + //传递路径 + MainWindow.ReceiveConfigurationParameters[3] = TextBoxPath.Text.ToString(); + //传递域名 + //MainWindow.ReceiveConfigurationParameters[4] = TextBoxDomain.Text.ToString(); + } //WebSocket+TLS+Web模式被选中 else if (RadioButtonWebSocketTLS2Web.IsChecked == true|| RadioButtonWebSocketTLS2WebHot.IsChecked==true) @@ -120,17 +131,19 @@ namespace ProxySU //传递伪装网站 MainWindow.ReceiveConfigurationParameters[7] = TextBoxMaskSites.Text.ToString(); //处理伪装网站域名中的前缀 - string testDomain = TextBoxMaskSites.Text.Substring(0, 7); - if (String.Equals(testDomain, "https:/") || String.Equals(testDomain, "http://")) + if (TextBoxMaskSites.Text.ToString().Length >= 7) { - //MessageBox.Show(testDomain); - MainWindow.ReceiveConfigurationParameters[7] = TextBoxMaskSites.Text.Replace("/", "\\/"); + string testDomain = TextBoxMaskSites.Text.Substring(0, 7); + if (String.Equals(testDomain, "https:/") || String.Equals(testDomain, "http://")) + { + //MessageBox.Show(testDomain); + MainWindow.ReceiveConfigurationParameters[7] = TextBoxMaskSites.Text.Replace("/", "\\/"); + } + else + { + MainWindow.ReceiveConfigurationParameters[7] = "http:\\/\\/" + TextBoxMaskSites.Text; + } } - else - { - MainWindow.ReceiveConfigurationParameters[7] = "http:\\/\\/" + TextBoxMaskSites.Text; - } - } //http2模式被选中 else if (RadioButtonHTTP2.IsChecked == true) @@ -313,6 +326,35 @@ namespace ProxySU //清除其他选项卡中的选项 UncheckLayouts((TabItem)TabControlTemplate.SelectedItem); } + private void RadioButtonWebSocketTLSselfSigned_Checked(object sender, RoutedEventArgs e) + { + //TextBlockServerListenPort.Visibility = Visibility.Visible; + //TextBoxServerListenPort.Visibility = Visibility.Visible; + //ButtonServerListenPort.Visibility = Visibility.Visible; + TextBoxServerListenPort.Text = "443"; + //显示Path + TextBlockPath.Visibility = Visibility.Visible; + TextBoxPath.Visibility = Visibility.Visible; + TextBoxPath.Text = "/ray"; + ButtonPath.Visibility = Visibility.Visible; + //显示域名 + TextBlockDomain.Visibility = Visibility.Collapsed; + TextBoxDomain.Visibility = Visibility.Collapsed; + //TextBoxDomain.Tag = "可为空"; + //ButtonDomain.Visibility = Visibility.Visible; + //隐藏QUIC密钥 + TextBlockQuicUUID.Visibility = Visibility.Collapsed; + TextBoxQuicUUID.Visibility = Visibility.Collapsed; + ButtonQuicUUID.Visibility = Visibility.Collapsed; + //隐藏伪装网站 + TextBlockMaskSites.Visibility = Visibility.Collapsed; + TextBoxMaskSites.Visibility = Visibility.Collapsed; + + Guid uuid = Guid.NewGuid(); + TextBoxNewUUID.Text = uuid.ToString(); + //清除其他选项卡中的选项 + UncheckLayouts((TabItem)TabControlTemplate.SelectedItem); + } private void RadioButtonHTTP2_Checked(object sender, RoutedEventArgs e) {