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

优化MTProto客户端生成流程

This commit is contained in:
ProxySU 2020-10-30 15:26:16 +08:00
parent d3acd25ab9
commit 73a1d2c7ed
8 changed files with 59 additions and 40 deletions

View File

@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:ProxySU" xmlns:local="clr-namespace:ProxySU"
mc:Ignorable="d" mc:Ignorable="d"
Title="ProxySU - v2.4.16" Height="675" Width="650"> Title="ProxySU - v2.4.17" Height="675" Width="650">
<!--以下样式参考自https://yq.aliyun.com/articles/331878 <!--以下样式参考自https://yq.aliyun.com/articles/331878
https://docs.microsoft.com/en-us/dotnet/desktop-wpf/fundamentals/styles-templates-overview--> https://docs.microsoft.com/en-us/dotnet/desktop-wpf/fundamentals/styles-templates-overview-->
<Window.Resources> <Window.Resources>
@ -32,11 +32,15 @@
</Style> </Style>
</Window.Resources> </Window.Resources>
<Grid> <Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="274*"/>
<ColumnDefinition Width="369*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="25"></RowDefinition> <RowDefinition Height="25"></RowDefinition>
<RowDefinition></RowDefinition> <RowDefinition></RowDefinition>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid Grid.Row="0"> <Grid Grid.Row="0" Grid.ColumnSpan="2" Margin="0,0,0.333,0.333">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*"></ColumnDefinition> <ColumnDefinition Width="0.5*"></ColumnDefinition>
<ColumnDefinition Width="1.6*"></ColumnDefinition> <ColumnDefinition Width="1.6*"></ColumnDefinition>
@ -51,7 +55,7 @@
<TextBlock Grid.Column="3" Text="{DynamicResource MainWindowsLanguage}" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="5"></TextBlock> <TextBlock Grid.Column="3" Text="{DynamicResource MainWindowsLanguage}" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="5"></TextBlock>
<ComboBox x:Name="ComboBoxLanguage" Grid.Column="4" Height="20" Width="80" SelectionChanged="ComboBoxLanguage_SelectionChanged"></ComboBox> <ComboBox x:Name="ComboBoxLanguage" Grid.Column="4" Height="20" Width="80" SelectionChanged="ComboBoxLanguage_SelectionChanged"></ComboBox>
</Grid> </Grid>
<Grid Grid.Row="1"> <Grid Grid.ColumnSpan="2" Margin="0,25,0.333,0.333" Grid.RowSpan="2">
<TabControl> <TabControl>
<TabItem Header="{DynamicResource TabItemHeaderAppDeployment}" Width="110" Height="30"> <TabItem Header="{DynamicResource TabItemHeaderAppDeployment}" Width="110" Height="30">
<Grid> <Grid>
@ -219,10 +223,10 @@
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBlock x:Name="TextBlockV2RayShowPort" Text="{DynamicResource TextBlockV2RayServerPort}" Grid.Column="0" Grid.Row="0" HorizontalAlignment="Center" VerticalAlignment="Center"></TextBlock> <TextBlock x:Name="TextBlockV2RayShowPort" Text="{DynamicResource TextBlockV2RayServerPort}" Grid.Column="0" Grid.Row="0" HorizontalAlignment="Center" VerticalAlignment="Center"></TextBlock>
<TextBlock x:Name="TextBlockCurrentlySelectedPlanPort" Grid.Column="1" Grid.Row="0" HorizontalAlignment="Left" VerticalAlignment="Center"></TextBlock> <TextBlock x:Name="TextBlockCurrentlySelectedPlanPort" Grid.Column="1" Grid.Row="0" HorizontalAlignment="Left" VerticalAlignment="Center"></TextBlock>
<TextBlock x:Name="TextBlockV2RayShowUUID" Text="UUID:" Grid.Column="0" Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center"></TextBlock> <TextBlock x:Name="TextBlockV2RayShowUUID" Text="UUID:" Grid.Column="0" Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center"></TextBlock>
<TextBlock x:Name="TextBlockCurrentlySelectedPlanUUID" Grid.Column="1" Grid.Row="1" HorizontalAlignment="Left" VerticalAlignment="Center"></TextBlock> <TextBlock x:Name="TextBlockCurrentlySelectedPlanUUID" Grid.Column="1" Grid.Row="1" HorizontalAlignment="Left" VerticalAlignment="Center"></TextBlock>
<TextBlock x:Name="TextBlockV2RayShowPathSeedKey" Text="Path/mKCP Seed/Quic Key" Visibility="Collapsed" Grid.Column="0" Grid.Row="2" HorizontalAlignment="Center" VerticalAlignment="Center"></TextBlock> <TextBlock x:Name="TextBlockV2RayShowPathSeedKey" Text="Path/mKCP Seed/Quic Key" Visibility="Collapsed" Grid.Column="0" Grid.Row="2" HorizontalAlignment="Center" VerticalAlignment="Center"></TextBlock>
<TextBlock x:Name="TextBlockCurrentlySelectedPlanPathSeedKey" Visibility="Collapsed" Grid.Column="1" Grid.Row="2" HorizontalAlignment="Left" VerticalAlignment="Center"></TextBlock> <TextBlock x:Name="TextBlockCurrentlySelectedPlanPathSeedKey" Visibility="Collapsed" Grid.Column="1" Grid.Row="2" HorizontalAlignment="Left" VerticalAlignment="Center"></TextBlock>
@ -243,10 +247,10 @@
<TextBlock x:Name="TextBlockBoxPathVmessWS" Grid.Column="5" Grid.Row="3" Margin="0"></TextBlock> <TextBlock x:Name="TextBlockBoxPathVmessWS" Grid.Column="5" Grid.Row="3" Margin="0"></TextBlock>
</Grid> </Grid>
<TextBlock x:Name="TextBlockV2RayShowCurrentlySelectedPlanDomain" Text="Domain/Quic Encrypt" Grid.Column="0" Grid.Row="3" HorizontalAlignment="Center" VerticalAlignment="Center"></TextBlock> <TextBlock x:Name="TextBlockV2RayShowCurrentlySelectedPlanDomain" Text="Domain/Quic Encrypt" Grid.Column="0" Grid.Row="3" HorizontalAlignment="Center" VerticalAlignment="Center"></TextBlock>
<TextBlock x:Name="TextBlockCurrentlySelectedPlanDomain" Grid.Column="1" Grid.Row="3" HorizontalAlignment="Left" VerticalAlignment="Center"></TextBlock> <TextBlock x:Name="TextBlockCurrentlySelectedPlanDomain" Grid.Column="1" Grid.Row="3" HorizontalAlignment="Left" VerticalAlignment="Center"></TextBlock>
<TextBlock x:Name="TextBlockV2RayShowCurrentlySelectedPlanFakeWebsite" Text="{DynamicResource TextBlockV2RayMaskSites}" Grid.Column="0" Grid.Row="4" HorizontalAlignment="Center" VerticalAlignment="Center"></TextBlock> <TextBlock x:Name="TextBlockV2RayShowCurrentlySelectedPlanFakeWebsite" Text="{DynamicResource TextBlockV2RayMaskSites}" Grid.Column="0" Grid.Row="4" HorizontalAlignment="Center" VerticalAlignment="Center"></TextBlock>
<TextBlock x:Name="TextBlockCurrentlySelectedPlanFakeWebsite" Grid.Column="1" Grid.Row="4" HorizontalAlignment="Left" VerticalAlignment="Center"></TextBlock> <TextBlock x:Name="TextBlockCurrentlySelectedPlanFakeWebsite" Grid.Column="1" Grid.Row="4" HorizontalAlignment="Left" VerticalAlignment="Center"></TextBlock>
</Grid> </Grid>
@ -415,7 +419,7 @@
<Button x:Name="ButtonNaiveCancel" Content="{DynamicResource ButtonNaiveCancel}" Grid.ColumnSpan="1" Margin="10" Grid.Column="2" Grid.Row="2" Click="Button_canel_Click"></Button> <Button x:Name="ButtonNaiveCancel" Content="{DynamicResource ButtonNaiveCancel}" Grid.ColumnSpan="1" Margin="10" Grid.Column="2" Grid.Row="2" Click="Button_canel_Click"></Button>
</Grid> </Grid>
</TabItem> </TabItem>
<TabItem Header="SSR" Width="60" Height="30"> <TabItem Header="SSR" Width="60" Height="30">
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
@ -467,7 +471,7 @@
<Button x:Name="ButtonSSRCancel" Content="{DynamicResource ButtonTrojanCancel}" Grid.Column="2" Grid.Row="2" Margin="10" Click="Button_canel_Click"></Button> <Button x:Name="ButtonSSRCancel" Content="{DynamicResource ButtonTrojanCancel}" Grid.Column="2" Grid.Row="2" Margin="10" Click="Button_canel_Click"></Button>
</Grid> </Grid>
</TabItem> </TabItem>
<TabItem Header="SS" Width="60" Height="30"> <TabItem Header="SS" Width="60" Height="30">
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>

View File

@ -4842,44 +4842,54 @@ namespace ProxySU
if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; }
//****** "正在启动MTProto......" ****** //****** "正在启动MTProto......" ******
SetUpProgressBarProcessing(80); SetUpProgressBarProcessing(70);
//currentStatus = Application.Current.FindResource("DisplayInstallInfo_StartSoft").ToString() + "MTProto......"; currentStatus = Application.Current.FindResource("DisplayInstallInfo_StartSoft").ToString() + "MTProto......";
//MainWindowsShowInfo(currentStatus); MainWindowsShowInfo(currentStatus);
//启动MTProto服务 //启动MTProto服务
functionResult = SoftStartDetect(client, "mtg", @"/usr/local/bin/mtg"); functionResult = SoftStartDetect(client, "mtg", @"/usr/local/bin/mtg");
if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; }
//****** "生成客户端配置......" ******
SetUpProgressBarProcessing(80);
currentStatus = Application.Current.FindResource("DisplayInstallInfo_GenerateClientConfig").ToString();
MainWindowsShowInfo(currentStatus);
sshShellCommand = @"systemctl stop mtg";
currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand);
sshShellCommand = @"cat /usr/local/etc/mtg.sh";
currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand);
sshShellCommand = currentShellCommandResult;
currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand);
Thread.Sleep(3000);
sshShellCommand = @"cat /usr/local/etc/mtg_info.json";
currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand);
ReceiveConfigurationParameters[9] = currentShellCommandResult;
if (String.IsNullOrEmpty(ReceiveConfigurationParameters[9]) == true)
{
Thread.Sleep(3000);
sshShellCommand = @"cat /usr/local/etc/mtg_info.json";
currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand);
ReceiveConfigurationParameters[9] = currentShellCommandResult;
}
sshShellCommand = @"pkill mtg";
currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand);
sshShellCommand = @"systemctl restart mtg";
currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand);
if (String.IsNullOrEmpty(ReceiveConfigurationParameters[9]) == true)
{
//***客户端配置获取失败!***
currentStatus = Application.Current.FindResource("DisplayInstallInfo_GetClientConfigFailed").ToString();
MainWindowsShowInfo(currentStatus);
FunctionResultErr();
client.Disconnect();
return;
}
//检测BBR满足条件并启动 90--95 //检测BBR满足条件并启动 90--95
functionResult = DetectBBRandEnable(client); functionResult = DetectBBRandEnable(client);
if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; }
//****** "生成客户端配置......" ******
SetUpProgressBarProcessing(96);
currentStatus = Application.Current.FindResource("DisplayInstallInfo_GenerateClientConfig").ToString();
MainWindowsShowInfo(currentStatus);
//读取生成的代理参数
sshShellCommand = @"cat /usr/local/etc/mtg_info.json";
currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand);
ReceiveConfigurationParameters[9] = currentShellCommandResult;
if (currentShellCommandResult.Contains(@"No such file or directory"))
{
sshShellCommand = @"systemctl stop mtg";
currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand);
sshShellCommand = @"cat /usr/local/etc/mtg.sh";
currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand);
sshShellCommand = currentShellCommandResult;
currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand);
sshShellCommand = @"cat /usr/local/etc/mtg_info.json";
currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand);
ReceiveConfigurationParameters[9] = currentShellCommandResult;
sshShellCommand = @"pkill mtg";
currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand);
sshShellCommand = @"systemctl restart mtg";
currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand);
}
client.Disconnect();//断开服务器ssh连接 client.Disconnect();//断开服务器ssh连接

View File

@ -51,5 +51,5 @@ using System.Windows;
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号 // 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
// 方法是按如下所示使用“*”: : // 方法是按如下所示使用“*”: :
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.4.16.0")] [assembly: AssemblyVersion("2.4.17.0")]
[assembly: AssemblyFileVersion("2.4.16.0")] [assembly: AssemblyFileVersion("2.4.17.0")]

View File

@ -594,7 +594,9 @@ namespace ProxySU
string configSavePath = configDomainSavePath; string configSavePath = configDomainSavePath;
RadioButtonMtgIpv4.IsChecked = true; RadioButtonMtgIpv4.IsChecked = true;
//MessageBox.Show(MainWindow.ReceiveConfigurationParameters[9]);
JObject jObjectJson = JObject.Parse(MainWindow.ReceiveConfigurationParameters[9]); JObject jObjectJson = JObject.Parse(MainWindow.ReceiveConfigurationParameters[9]);
//MessageBox.Show(jObjectJson.ToString());
if (jObjectJson["ipv4"]["tg_url"].ToString().Contains("nil") == false) if (jObjectJson["ipv4"]["tg_url"].ToString().Contains("nil") == false)
{ {
RadioButtonMtgIpv4.Visibility = Visibility.Visible; RadioButtonMtgIpv4.Visibility = Visibility.Visible;

View File

@ -345,6 +345,7 @@
<sys:String x:Key="DisplayInstallInfo_BBRFailed">The system does not meet the conditions for enabling BBR, and the enabling failed!</sys:String> <sys:String x:Key="DisplayInstallInfo_BBRFailed">The system does not meet the conditions for enabling BBR, and the enabling failed!</sys:String>
<sys:String x:Key="DisplayInstallInfo_BBREnabledSuccess">BBR is successfully activated!</sys:String> <sys:String x:Key="DisplayInstallInfo_BBREnabledSuccess">BBR is successfully activated!</sys:String>
<sys:String x:Key="DisplayInstallInfo_GenerateClientConfig">Generate client configuration...</sys:String> <sys:String x:Key="DisplayInstallInfo_GenerateClientConfig">Generate client configuration...</sys:String>
<sys:String x:Key="DisplayInstallInfo_GetClientConfigFailed">Failed to obtain client configuration!</sys:String>
<sys:String x:Key="DisplayInstallInfo_ProxyInstalledOK">The installation is successful, Enjoy it!!</sys:String> <sys:String x:Key="DisplayInstallInfo_ProxyInstalledOK">The installation is successful, Enjoy it!!</sys:String>
<sys:String x:Key="DisplayInstallInfo_LoginFailed">Installation Failed!</sys:String> <sys:String x:Key="DisplayInstallInfo_LoginFailed">Installation Failed!</sys:String>
<sys:String x:Key="MessageBoxShow_ErrorLoginOccurred">An error occurred!</sys:String> <sys:String x:Key="MessageBoxShow_ErrorLoginOccurred">An error occurred!</sys:String>

View File

@ -350,6 +350,7 @@
<sys:String x:Key="DisplayInstallInfo_BBRFailed">系统不满足启用BBR的条件启用失败</sys:String> <sys:String x:Key="DisplayInstallInfo_BBRFailed">系统不满足启用BBR的条件启用失败</sys:String>
<sys:String x:Key="DisplayInstallInfo_BBREnabledSuccess">BBR 启用成功!</sys:String> <sys:String x:Key="DisplayInstallInfo_BBREnabledSuccess">BBR 启用成功!</sys:String>
<sys:String x:Key="DisplayInstallInfo_GenerateClientConfig">生成客户端配置......</sys:String> <sys:String x:Key="DisplayInstallInfo_GenerateClientConfig">生成客户端配置......</sys:String>
<sys:String x:Key="DisplayInstallInfo_GetClientConfigFailed">客户端配置获取失败!</sys:String>
<sys:String x:Key="DisplayInstallInfo_ProxyInstalledOK">安装成功,祝你玩的愉快!!</sys:String> <sys:String x:Key="DisplayInstallInfo_ProxyInstalledOK">安装成功,祝你玩的愉快!!</sys:String>
<sys:String x:Key="DisplayInstallInfo_LoginFailed">安装失败!</sys:String> <sys:String x:Key="DisplayInstallInfo_LoginFailed">安装失败!</sys:String>
<sys:String x:Key="MessageBoxShow_ErrorLoginOccurred">发生错误!</sys:String> <sys:String x:Key="MessageBoxShow_ErrorLoginOccurred">发生错误!</sys:String>

View File

@ -345,6 +345,7 @@
<sys:String x:Key="DisplayInstallInfo_BBRFailed">系統不滿足啟用BBR的條件啟用失敗</sys:String> <sys:String x:Key="DisplayInstallInfo_BBRFailed">系統不滿足啟用BBR的條件啟用失敗</sys:String>
<sys:String x:Key="DisplayInstallInfo_BBREnabledSuccess">BBR 啟用成功!</sys:String> <sys:String x:Key="DisplayInstallInfo_BBREnabledSuccess">BBR 啟用成功!</sys:String>
<sys:String x:Key="DisplayInstallInfo_GenerateClientConfig">生成客戶端配置......</sys:String> <sys:String x:Key="DisplayInstallInfo_GenerateClientConfig">生成客戶端配置......</sys:String>
<sys:String x:Key="DisplayInstallInfo_GetClientConfigFailed">客戶端配置獲取失敗!</sys:String>
<sys:String x:Key="DisplayInstallInfo_ProxyInstalledOK">安裝成功,祝你玩的愉快! </sys:String> <sys:String x:Key="DisplayInstallInfo_ProxyInstalledOK">安裝成功,祝你玩的愉快! </sys:String>
<sys:String x:Key="DisplayInstallInfo_LoginFailed">安裝失敗!</sys:String> <sys:String x:Key="DisplayInstallInfo_LoginFailed">安裝失敗!</sys:String>
<sys:String x:Key="MessageBoxShow_ErrorLoginOccurred">發生錯誤!</sys:String> <sys:String x:Key="MessageBoxShow_ErrorLoginOccurred">發生錯誤!</sys:String>

Binary file not shown.