1
0
mirror of https://github.com/proxysu/ProxySU.git synced 2024-11-25 22:56: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:local="clr-namespace:ProxySU"
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://docs.microsoft.com/en-us/dotnet/desktop-wpf/fundamentals/styles-templates-overview-->
<Window.Resources>
@ -32,11 +32,15 @@
</Style>
</Window.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="274*"/>
<ColumnDefinition Width="369*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="25"></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid Grid.Row="0" Grid.ColumnSpan="2" Margin="0,0,0.333,0.333">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*"></ColumnDefinition>
<ColumnDefinition Width="1.6*"></ColumnDefinition>
@ -51,7 +55,7 @@
<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>
</Grid>
<Grid Grid.Row="1">
<Grid Grid.ColumnSpan="2" Margin="0,25,0.333,0.333" Grid.RowSpan="2">
<TabControl>
<TabItem Header="{DynamicResource TabItemHeaderAppDeployment}" Width="110" Height="30">
<Grid>

View File

@ -4842,45 +4842,55 @@ namespace ProxySU
if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; }
//****** "正在启动MTProto......" ******
SetUpProgressBarProcessing(80);
//currentStatus = Application.Current.FindResource("DisplayInstallInfo_StartSoft").ToString() + "MTProto......";
//MainWindowsShowInfo(currentStatus);
SetUpProgressBarProcessing(70);
currentStatus = Application.Current.FindResource("DisplayInstallInfo_StartSoft").ToString() + "MTProto......";
MainWindowsShowInfo(currentStatus);
//启动MTProto服务
functionResult = SoftStartDetect(client, "mtg", @"/usr/local/bin/mtg");
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
functionResult = DetectBBRandEnable(client);
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连接
//Thread.Sleep(1000);

View File

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

View File

@ -594,7 +594,9 @@ namespace ProxySU
string configSavePath = configDomainSavePath;
RadioButtonMtgIpv4.IsChecked = true;
//MessageBox.Show(MainWindow.ReceiveConfigurationParameters[9]);
JObject jObjectJson = JObject.Parse(MainWindow.ReceiveConfigurationParameters[9]);
//MessageBox.Show(jObjectJson.ToString());
if (jObjectJson["ipv4"]["tg_url"].ToString().Contains("nil") == false)
{
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_BBREnabledSuccess">BBR is successfully activated!</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_LoginFailed">Installation Failed!</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_BBREnabledSuccess">BBR 启用成功!</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_LoginFailed">安装失败!</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_BBREnabledSuccess">BBR 啟用成功!</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_LoginFailed">安裝失敗!</sys:String>
<sys:String x:Key="MessageBoxShow_ErrorLoginOccurred">發生錯誤!</sys:String>

Binary file not shown.