1
0
mirror of https://github.com/proxysu/ProxySU.git synced 2024-11-25 22:56:09 +03:00

增加WebSocket+TLS(自签证书)

This commit is contained in:
ProxySU 2020-04-16 14:00:26 +08:00
parent d4e4e95e99
commit e22f15159c
4 changed files with 98 additions and 22 deletions

View File

@ -172,6 +172,7 @@
<Button x:Name="testPortOccupy" Content="测试端口占用" Grid.Column="0" Grid.Row="2" Margin="5" Click="TestPortOccupy_Click"></Button>
<Button x:Name="testInstalledV2ray" Content="测试是否安装V2ray" Grid.Column="1" Grid.Row="0" Margin="5" Click="TestInstalledV2ray_Click"></Button>
<Button x:Name="testsshCmd" Content="测试ssh命令" Grid.Column="1" Grid.Row="1" Margin="5" Click="TestsshCmd_Click"></Button>-->
<Button Content="测试数组赋值" Grid.Column="2" Grid.Row="0" Margin="5" Click="Button_Click"></Button>
</Grid>
</TabItem>
</TabControl>

View File

@ -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)
{
@ -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();

View File

@ -113,13 +113,13 @@
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<RadioButton x:Name="RadioButtonWebSocket" Content="WebSocket" GroupName="TemplateGroup" Grid.Column="0" Grid.Row="1" Checked="RadioButtonWebSocketTLS2Web_Checked"></RadioButton>
<TextBlock Text="数据加密传输传输协议使用WebSocket未启用TLS,将被识别为WebSocket流量。" TextWrapping="Wrap" Grid.Column="1" Grid.Row="1" Grid.ColumnSpan="3"></TextBlock>
<!--<RadioButton x:Name="RadioButtonWebSocket" Content="WebSocket" GroupName="TemplateGroup" Grid.Column="0" Grid.Row="1" Checked="RadioButtonWebSocketTLS2Web_Checked"></RadioButton>
<TextBlock Text="数据加密传输传输协议使用WebSocket未启用TLS,将被识别为WebSocket流量。" TextWrapping="Wrap" Grid.Column="1" Grid.Row="1" Grid.ColumnSpan="3"></TextBlock>-->
<RadioButton x:Name="RadioButtonWebSocketTLS" Content="WebSocket+TLS" GroupName="TemplateGroup" Grid.Column="0" Grid.Row="2" Checked="RadioButtonHTTP2_Checked"/>
<TextBlock Text="数据加密传输传输协议使用WebSocket启用TLS,将被识别为TLS流量。(需要域名)" TextWrapping="Wrap" Grid.Column="1" Grid.Row="2" Grid.ColumnSpan="3"></TextBlock>
<RadioButton x:Name="RadioButtonWebSocketTLS2Web" Content="WebSocket+TLS+Web" GroupName="TemplateGroup" Grid.Column="0" Grid.Row="3" Checked="RadioButtonWebSocketTLS2Web_Checked"></RadioButton>
<TextBlock Text="稳定性强使用Caddy做伪装网站隐藏代理会被识别为访问网站的https流量抗封锁识别最强。(需要域名)" TextWrapping="Wrap" Grid.Column="1" Grid.Row="3" Grid.ColumnSpan="3"></TextBlock>
<RadioButton x:Name="RadioButtonWebSocketTLSnoDomain" Content="WebSocket+TLS(自签证书)" GroupName="TemplateGroup" Grid.Column="0" Grid.Row="4" Checked="RadioButtonWebSocketTLS2Web_Checked"></RadioButton>
<RadioButton x:Name="RadioButtonWebSocketTLSselfSigned" Content="WebSocket+TLS(自签证书)" GroupName="TemplateGroup" Grid.Column="0" Grid.Row="4" Checked="RadioButtonWebSocketTLSselfSigned_Checked"></RadioButton>
<TextBlock Text="数据加密传输传输协议使用WebSocket启用TLS,将被识别为TLS流量。(无需域名)" TextWrapping="Wrap" Grid.Column="1" Grid.Row="4" Grid.ColumnSpan="3"></TextBlock>
</Grid>

View File

@ -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,6 +131,8 @@ namespace ProxySU
//传递伪装网站
MainWindow.ReceiveConfigurationParameters[7] = TextBoxMaskSites.Text.ToString();
//处理伪装网站域名中的前缀
if (TextBoxMaskSites.Text.ToString().Length >= 7)
{
string testDomain = TextBoxMaskSites.Text.Substring(0, 7);
if (String.Equals(testDomain, "https:/") || String.Equals(testDomain, "http://"))
{
@ -130,7 +143,7 @@ namespace ProxySU
{
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)
{