From 8a2dbd5c2c83b8d5c68a5e5092fdf93173d24740 Mon Sep 17 00:00:00 2001 From: ProxySU <proxysetuptools@gmail.com> Date: Wed, 15 Apr 2020 10:47:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0tcp+TLS(=E8=87=AA=E7=AD=BE?= =?UTF-8?q?=E8=AF=81=E4=B9=A6)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProxySU/MainWindow.xaml.cs | 54 +++++++++++++++---------- ProxySU/ResultClientInformation.xaml.cs | 8 ++++ ProxySU/TemplateConfiguration.xaml | 3 +- ProxySU/TemplateConfiguration.xaml.cs | 10 +++++ 4 files changed, 53 insertions(+), 22 deletions(-) diff --git a/ProxySU/MainWindow.xaml.cs b/ProxySU/MainWindow.xaml.cs index 01a0808..6629b41 100644 --- a/ProxySU/MainWindow.xaml.cs +++ b/ProxySU/MainWindow.xaml.cs @@ -189,25 +189,35 @@ namespace ProxySU serverConfig = "TemplateConfg\\tcp_server_config.json"; clientConfig = "TemplateConfg\\tcp_client_config.json"; } + else if (String.Equals(ReceiveConfigurationParameters[0], "TCPhttp")) + { + serverConfig = "TemplateConfg\\tcp_http_server_config.json"; + clientConfig = "TemplateConfg\\tcp_http_client_config.json"; + } + else if (String.Equals(ReceiveConfigurationParameters[0], "tcpTLS")) + { + serverConfig = "TemplateConfg\\tcp_TLS_server_config.json"; + clientConfig = "TemplateConfg\\tcp_TLS_client_config.json"; + } + else if (String.Equals(ReceiveConfigurationParameters[0], "tcpTLSselfSigned")) + { + serverConfig = "TemplateConfg\\tcpTLSselfSigned_server_config.json"; + clientConfig = "TemplateConfg\\tcpTLSselfSigned_client_config.json"; + } + else if (String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLS")) + { + serverConfig = "TemplateConfg\\WebSocket_TLS_server_config.json"; + clientConfig = "TemplateConfg\\WebSocket_TLS_client_config.json"; + } else if (String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLS2Web")) { serverConfig = "TemplateConfg\\WebSocketTLSWeb_server_config.json"; clientConfig = "TemplateConfg\\WebSocketTLSWeb_client_config.json"; } - else if (String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLS")) + else if (String.Equals(ReceiveConfigurationParameters[0], "Http2")) { - serverConfig = "TemplateConfg\\WebSocketTLS_server_config.json"; - clientConfig = "TemplateConfg\\WebSocketTLS_client_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "tcpTLS")) - { - serverConfig = "TemplateConfg\\tcpTLS_server_config.json"; - clientConfig = "TemplateConfg\\tcpTLS_client_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "TCPhttp")) - { - serverConfig = "TemplateConfg\\tcp_http_server_config.json"; - clientConfig = "TemplateConfg\\tcp_http_client_config.json"; + serverConfig = "TemplateConfg\\http2_server_config.json"; + clientConfig = "TemplateConfg\\http2_client_config.json"; } //else if (String.Equals(ReceiveConfigurationParameters[0], "MkcpNone")|| String.Equals(ReceiveConfigurationParameters[0], "mKCP2SRTP")||String.Equals(ReceiveConfigurationParameters[0], "mKCPuTP")|| String.Equals(ReceiveConfigurationParameters[0], "mKCP2WechatVideo")|| String.Equals(ReceiveConfigurationParameters[0], "mKCP2DTLS")|| String.Equals(ReceiveConfigurationParameters[0], "mKCP2WireGuard")) else if (ReceiveConfigurationParameters[0].Contains("mKCP")) @@ -215,12 +225,7 @@ namespace ProxySU serverConfig = "TemplateConfg\\mkcp_server_config.json"; clientConfig = "TemplateConfg\\mkcp_client_config.json"; } - - else if (String.Equals(ReceiveConfigurationParameters[0], "Http2")) - { - serverConfig = "TemplateConfg\\http2_server_config.json"; - clientConfig = "TemplateConfg\\http2_client_config.json"; - } + // else if (String.Equals(ReceiveConfigurationParameters[0], "QuicNone") || String.Equals(ReceiveConfigurationParameters[0], "QuicSRTP") || String.Equals(ReceiveConfigurationParameters[0], "Quic2uTP") || String.Equals(ReceiveConfigurationParameters[0], "QuicWechatVideo") || String.Equals(ReceiveConfigurationParameters[0], "QuicDTLS") || String.Equals(ReceiveConfigurationParameters[0], "QuicWireGuard")) else if (ReceiveConfigurationParameters[0].Contains("Quic")) { @@ -645,6 +650,13 @@ namespace ProxySU { serverJson["inbounds"][0]["port"] = ReceiveConfigurationParameters[1]; } + //tcp+TLS自签证书模式下 + if (serverConfig.Contains("tcpTLSselfSigned") == true) + { + string selfSignedCa = client.RunCommand("/usr/bin/v2ray/v2ctl cert --ca").Result; + JObject selfSignedCaJObject = JObject.Parse(selfSignedCa); + serverJson["inbounds"][0]["streamSettings"]["tlsSettings"]["certificates"][0] = selfSignedCaJObject; + } //如果是WebSocketTLSWeb模式,则设置路径 if (serverConfig.Contains("WebSocket") == true) { @@ -758,10 +770,10 @@ namespace ProxySU //启动Caddy服务 - client.RunCommand("caddy -service start"); + client.RunCommand("caddy -service restart"); } - if (serverConfig.Contains("http2") == true|| serverConfig.Contains("WebSocketTLS")==true|| serverConfig.Contains("tcpTLS") == true) + if (serverConfig.Contains("http2") == true|| serverConfig.Contains("WebSocket_TLS") ==true|| serverConfig.Contains("tcp_TLS") == true) { currentStatus = "使用Http2/WebSocket +TLS/tcp+TLS模式,正在安装acme.sh......"; textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); diff --git a/ProxySU/ResultClientInformation.xaml.cs b/ProxySU/ResultClientInformation.xaml.cs index 865cc43..6737d31 100644 --- a/ProxySU/ResultClientInformation.xaml.cs +++ b/ProxySU/ResultClientInformation.xaml.cs @@ -64,6 +64,14 @@ namespace ProxySU HidePathAndTLS(); HideQuicKey(); } + else if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "tcpTLSselfSigned")) + { + TextBoxTransmission.Text = "tcp"; + TextBoxCamouflageType.Text = "none"; + TextBoxTLS.Text = "tls"; + HidePathAndTLS(); + HideQuicKey(); + } else if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "MkcpNone")) { TextBoxTransmission.Text = "kcp"; diff --git a/ProxySU/TemplateConfiguration.xaml b/ProxySU/TemplateConfiguration.xaml index 910f3db..3493944 100644 --- a/ProxySU/TemplateConfiguration.xaml +++ b/ProxySU/TemplateConfiguration.xaml @@ -89,8 +89,9 @@ <TextBlock Text="数据加密传输,并做http伪装,会被识别为http流量,但并不是真正的http访问" Grid.Column="1" Grid.Row="2" Grid.ColumnSpan="3"></TextBlock> <RadioButton x:Name="RadioButtonTCP2TLS" Content="TCP+TLS" GroupName="TemplateGroup" Grid.Column="0" Grid.Row="3" Checked="RadioButtonTCP2TLS_Checked" /> <TextBlock Text="数据加密传输,传输协议使用TLS,会被识别为TLS流量,不等同于https流量特征 (需要域名)" Grid.Column="1" Grid.Row="3" Grid.ColumnSpan="3"></TextBlock> - <RadioButton x:Name="RadioButtonTCP2TLSnoDomain" Content="TCP+TLS((自签证书)" GroupName="TemplateGroup" Grid.Column="0" Grid.Row="4" Checked="RadioButtonTCP2TLSnoDomain_Checked" /> + <RadioButton x:Name="RadioButtonTcpTLS2SelfSigned" Content="TCP+TLS((自签证书)" GroupName="TemplateGroup" Grid.Column="0" Grid.Row="4" Checked="RadioButtonTCP2TLSnoDomain_Checked" /> <TextBlock Text="数据加密传输,传输协议使用TLS,会被识别为TLS流量,不等同于https流量特征 (无需域名)" Grid.Column="1" Grid.Row="4" Grid.ColumnSpan="3"></TextBlock> + <TextBlock Text="Shadowrocket (ios)需要手动打开“允许不安全”选项" TextWrapping="Wrap" Grid.Column="4" Grid.Row="4" ></TextBlock> </Grid> </TabItem> diff --git a/ProxySU/TemplateConfiguration.xaml.cs b/ProxySU/TemplateConfiguration.xaml.cs index 227fee8..0932846 100644 --- a/ProxySU/TemplateConfiguration.xaml.cs +++ b/ProxySU/TemplateConfiguration.xaml.cs @@ -76,6 +76,16 @@ namespace ProxySU //传递域名 MainWindow.ReceiveConfigurationParameters[4] = TextBoxDomain.Text.ToString(); + } + //tcp+TLS(自签证书)模式被选中 + else if (RadioButtonTcpTLS2SelfSigned.IsChecked == true) + { + //传递模板类型 + MainWindow.ReceiveConfigurationParameters[0] = "tcpTLSselfSigned"; + + //传递域名 + // MainWindow.ReceiveConfigurationParameters[4] = TextBoxDomain.Text.ToString(); + } //WebSocket+TLS模式被选中 else if (RadioButtonWebSocketTLS.IsChecked == true)