Skip to content

Commit

Permalink
排查bug2
Browse files Browse the repository at this point in the history
  • Loading branch information
proxysu committed Apr 18, 2020
1 parent 2390a2b commit 67f31e3
Show file tree
Hide file tree
Showing 17 changed files with 259 additions and 228 deletions.
16 changes: 8 additions & 8 deletions ProxySU/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@
<RowDefinition></RowDefinition>

</Grid.RowDefinitions>
<Button x:Name="ButtonGuideConfiguration" Visibility="Visible" Content="启用向导" Grid.Column="0" Grid.Row="0" Click="ButtonGuideConfiguration_Click"></Button>
<TextBlock Text="通过向导生成配置文件" Visibility="Visible" Grid.Column="0" Grid.Row="1" Grid.RowSpan="2" HorizontalAlignment="Center"></TextBlock>
<!--<Button x:Name="ButtonGuideConfiguration" Visibility="Visible" Content="启用向导" Grid.Column="0" Grid.Row="0" Click="ButtonGuideConfiguration_Click"></Button>
<TextBlock Text="通过向导生成配置文件" Visibility="Visible" Grid.Column="0" Grid.Row="1" Grid.RowSpan="2" HorizontalAlignment="Center"></TextBlock>-->
<Button x:Name="ButtonTemplateConfiguration" Content="模板库" Grid.Column="1" Grid.Row="0" Click="ButtonTemplateConfiguration_Click"></Button>
<TextBlock Text="模板库" Grid.Column="1" Grid.Row="1" Grid.RowSpan="2" HorizontalAlignment="Center"></TextBlock>
<Button x:Name="ButtonAdvancedConfiguration" Visibility="Visible" Content="配置编辑器" Grid.Column="2" Grid.Row="0" Click="ButtonAdvancedConfiguration_Click"></Button>
<TextBlock Text="配置文件高级生成器&#x0a;(有经验用户可以使用)" Visibility="Visible" Grid.Column="2" Grid.Row="1" Grid.RowSpan="2" HorizontalAlignment="Center"></TextBlock>
<!--<Button x:Name="ButtonAdvancedConfiguration" Visibility="Visible" Content="配置编辑器" Grid.Column="2" Grid.Row="0" Click="ButtonAdvancedConfiguration_Click"></Button>
<TextBlock Text="配置文件高级生成器&#x0a;(有经验用户可以使用)" Visibility="Visible" Grid.Column="2" Grid.Row="1" Grid.RowSpan="2" HorizontalAlignment="Center"></TextBlock>-->
<!--<RadioButton x:Name="RadioButtonGuideConfiguration" Content="向导生成配置" Grid.Column="0" Grid.Row="0"></RadioButton>
<RadioButton x:Name="RadioButtonTemplateConfiguration" Content="模板配置" Grid.Column="0" Grid.Row="1"></RadioButton>
<RadioButton x:Name="RadioButtonAdvancedConfiguration" Content="高级配置" Grid.Column="0" Grid.Row="2"></RadioButton>
Expand All @@ -151,7 +151,7 @@
<Button x:Name="ButtonClearOccupiedPorts" Content="释放80/443端口" Grid.Column="1" Grid.Row="0" Margin="5" Click="ButtonClearOccupiedPorts_Click"></Button>
</Grid>
</TabItem>
<TabItem Header="测试面板" Visibility="Visible" Width="150" Height="30">
<!--<TabItem Header="测试面板" Visibility="Visible" Width="150" Height="30">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
Expand All @@ -167,15 +167,15 @@
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<!--<Button Content="更改SELinux模式" Grid.Column="0" Grid.Row="0" Margin="10" Click="Button_Click"></Button>-->
--><!--<Button Content="更改SELinux模式" Grid.Column="0" Grid.Row="0" Margin="10" Click="Button_Click"></Button>-->
<!--<Button x:Name="testresultClientInform" Content="测试结果窗口" Grid.Column="0" Grid.Row="1" Margin="5" Click="TestresultClientInform_Click"></Button>
<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>-->
<!--<Button Content="测试数组赋值" Grid.Column="2" Grid.Row="0" Margin="5" Click="Button_Click"></Button>--><!--
<Button Content="test" Click="Button_Click_1"></Button>
</Grid>
</TabItem>
</TabItem>-->
</TabControl>


Expand Down
48 changes: 29 additions & 19 deletions ProxySU/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ private void Button_Login_Click(object sender, RoutedEventArgs e)
}
else if (String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLSselfSigned"))
{
serverConfig = "TemplateConfg\\WebSocket_TLS_selfSigned_server_config.json";
clientConfig = "TemplateConfg\\WebSocket_TLS_selfSigned_client_config.json";
serverConfig = "TemplateConfg\\WebSocketTLS_selfSigned_server_config.json";
clientConfig = "TemplateConfg\\WebSocketTLS_selfSigned_client_config.json";
}
else if (String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLS2Web"))
{
Expand All @@ -231,13 +231,13 @@ private void Button_Login_Click(object sender, RoutedEventArgs e)
}
else if (String.Equals(ReceiveConfigurationParameters[0], "http2Web"))
{
serverConfig = "TemplateConfg\\http2Web_server_config.json";
clientConfig = "TemplateConfg\\http2Web_client_config.json";
serverConfig = "TemplateConfg\\Http2Web_server_config.json";
clientConfig = "TemplateConfg\\Http2Web_client_config.json";
}
else if (String.Equals(ReceiveConfigurationParameters[0], "http2selfSigned"))
{
serverConfig = "TemplateConfg\\http2selfSigned_server_config.json";
clientConfig = "TemplateConfg\\http2selfSigned_client_config.json";
serverConfig = "TemplateConfg\\Http2selfSigned_server_config.json";
clientConfig = "TemplateConfg\\Http2selfSigned_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"))
Expand Down Expand Up @@ -571,15 +571,15 @@ private void StartSetUpRemoteHost(ConnectionInfo connectionInfo,TextBlock textBl
}
else
{
currentStatus = "域名未能正确解析到当前VPS的IP上!";
currentStatus = "域名未能正确解析到当前VPS的IP上!安装失败!";
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
Thread.Sleep(1000);
MessageBox.Show("域名未能正确解析到当前VPS的IP上,请检查!若解析设置正确,请等待生效后再重试安装。如果域名使用了CDN,请先关闭!");
return;
}

}
if (serverConfig.Contains("TLS") == true || serverConfig.Contains("http2") == true) {
if (serverConfig.Contains("TLS") == true || serverConfig.Contains("http2") == true || serverConfig.Contains("Http2") == true) {
//检测是否安装lsof
if (string.IsNullOrEmpty(client.RunCommand("command -v lsof").Result) == true)
{
Expand Down Expand Up @@ -667,28 +667,34 @@ private void StartSetUpRemoteHost(ConnectionInfo connectionInfo,TextBlock textBl
JObject serverJson = (JObject)JToken.ReadFrom(new JsonTextReader(reader));
//设置uuid
serverJson["inbounds"][0]["settings"]["clients"][0]["id"] = ReceiveConfigurationParameters[2];
//除WebSocketTLSWeb模式外设置监听端口
if (serverConfig.Contains("WebSocketTLSWeb") == false && serverConfig.Contains("http2Web") == false)
//除WebSocketTLSWeb/http2Web模式外设置监听端口
if (serverConfig.Contains("WebSocketTLSWeb") == false && serverConfig.Contains("Http2Web") == false)
{
serverJson["inbounds"][0]["port"] = int.Parse(ReceiveConfigurationParameters[1]);
}
//TLS自签证书模式下
if (serverConfig.Contains("selfSigned") == true)
//TLS自签证书/http2Web模式下,使用v2ctl 生成自签证书
if (serverConfig.Contains("selfSigned") == true|| serverConfig.Contains("Http2Web") == 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模式,则设置路径
//如果是WebSocketTLSWeb/WebSocketTLS/WebSocketTLS(自签证书)模式,则设置路径
if (serverConfig.Contains("WebSocket") == true)
{
serverJson["inbounds"][0]["streamSettings"]["wsSettings"]["path"] = ReceiveConfigurationParameters[3];
}
//如果是Http2模式下,设置路径
if (serverConfig.Contains("http2") == true)
if (serverConfig.Contains("http2") == true|| serverConfig.Contains("Http2") == true)
{
serverJson["inbounds"][0]["streamSettings"]["httpSettings"]["path"] = ReceiveConfigurationParameters[3];
}
//如果是Http2Web模式下,设置host
if (serverConfig.Contains("Http2Web") == true)
{
serverJson["inbounds"][0]["streamSettings"]["httpSettings"]["path"] = ReceiveConfigurationParameters[3];
serverJson["inbounds"][0]["streamSettings"]["httpSettings"]["host"][0] = ReceiveConfigurationParameters[4];
}
//mkcp模式下,设置伪装类型
if (serverConfig.Contains("mkcp") == true)
{
Expand Down Expand Up @@ -744,7 +750,7 @@ private void StartSetUpRemoteHost(ConnectionInfo connectionInfo,TextBlock textBl
}

//如果是WebSocket + TLS + Web模式,需要安装Caddy
if (serverConfig.Contains("WebSocketTLSWeb")==true || serverConfig.Contains("http2Web") == true)
if (serverConfig.Contains("WebSocketTLSWeb")==true || serverConfig.Contains("Http2Web") == true)
{
currentStatus = "使用WebSocket+TLS+Web/HTTP2+TLS+Web模式,正在安装Caddy......";
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
Expand All @@ -763,9 +769,9 @@ private void StartSetUpRemoteHost(ConnectionInfo connectionInfo,TextBlock textBl
{
serverConfig = "TemplateConfg\\WebSocketTLSWeb_server_config.caddyfile";
}
if (serverConfig.Contains("http2Web") == true)
if (serverConfig.Contains("Http2Web") == true)
{
serverConfig = "TemplateConfg\\http2Web_server_config.caddyfile";
serverConfig = "TemplateConfg\\Http2Web_server_config.caddyfile";
}
upLoadPath = "/etc/caddy/Caddyfile";
UploadConfig(connectionInfo, serverConfig, upLoadPath);
Expand Down Expand Up @@ -804,7 +810,7 @@ private void StartSetUpRemoteHost(ConnectionInfo connectionInfo,TextBlock textBl

if (serverConfig.Contains("http2") == true|| serverConfig.Contains("WebSocket_TLS") ==true|| serverConfig.Contains("tcp_TLS") == true)
{
currentStatus = "使用Http2/WebSocket +TLS/tcp+TLS模式,正在安装acme.sh......";
currentStatus = "使用Http2/WebSocket+TLS/tcp+TLS模式,正在安装acme.sh......";
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
Thread.Sleep(1000);

Expand Down Expand Up @@ -871,10 +877,14 @@ private void StartSetUpRemoteHost(ConnectionInfo connectionInfo,TextBlock textBl
{
clientJson["outbounds"][0]["streamSettings"]["wsSettings"]["path"] = ReceiveConfigurationParameters[3];
}
if (clientConfig.Contains("http2") == true)
if (clientConfig.Contains("http2") == true|| clientConfig.Contains("Http2") == true)
{
clientJson["outbounds"][0]["streamSettings"]["httpSettings"]["path"] = ReceiveConfigurationParameters[3];
}
if (clientConfig.Contains("Http2Web") == true)
{
clientJson["outbounds"][0]["streamSettings"]["httpSettings"]["host"][0] = ReceiveConfigurationParameters[4];
}
if (clientConfig.Contains("mkcp")==true)
{
clientJson["outbounds"][0]["streamSettings"]["kcpSettings"]["header"]["type"] = ReceiveConfigurationParameters[5];
Expand Down
Loading

0 comments on commit 67f31e3

Please sign in to comment.