1
0
mirror of https://github.com/proxysu/ProxySU.git synced 2025-02-16 22:53:13 +03:00

优化MTProto生成客户配置

This commit is contained in:
ProxySU 2020-10-13 09:37:30 +08:00
parent 3724028af8
commit cb224d03f5
5 changed files with 116 additions and 106 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.3" Height="675" Width="650">
Title="ProxySU - v2.4.4" 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>

View File

@ -51,7 +51,7 @@ namespace ProxySU
//ReceiveConfigurationParameters[6]----V2Ray&Trojan-go&SS--Websocket'Path/http2'Path/QUIC密钥/mKCP Seed/VMESS ws Path
//ReceiveConfigurationParameters[7]----伪装网站
//ReceiveConfigurationParameters[8]----方案名称
//ReceiveConfigurationParameters[9]----插件参数选项/VMESS tcp Path
//ReceiveConfigurationParameters[9]----插件参数选项/VMESS tcp Path/MTProto Parameters
//public static ConnectionInfo ConnectionInfo;
public static string proxyType = "V2Ray"; //代理类型标识: V2Ray\TrojanGo\Trojan\NaiveProxy
static bool testDomain = false; //设置标识--域名是否需要检测解析,初始化为不需要
@ -9177,18 +9177,20 @@ namespace ProxySU
//读取生成的代理参数
sshShellCommand = @"cat /usr/local/etc/mtg_info.json";
currentShellCommandResult = client.RunCommand(sshShellCommand).Result;
//结果保存在ReceiveConfigurationParameters[9]中
ReceiveConfigurationParameters[9] = currentShellCommandResult;
client.Disconnect();//断开服务器ssh连接
//Thread.Sleep(1000);
if (!Directory.Exists("mtproto_config"))//如果不存在就创建file文件夹     
{
Directory.CreateDirectory("mtproto_config");//创建该文件夹  
}
using (StreamWriter sw = new StreamWriter(@"mtproto_config\mtproto_info.json"))
{
sw.Write(currentShellCommandResult.ToString());
}
//if (!Directory.Exists("mtproto_config"))//如果不存在就创建file文件夹     
//{
// Directory.CreateDirectory("mtproto_config");//创建该文件夹  
//}
//using (StreamWriter sw = new StreamWriter(@"mtproto_config\mtproto_info.json"))
//{
// sw.Write(currentShellCommandResult.ToString());
//}
//****** "MTProto+TLS安装成功,祝你玩的愉快!!" ******
SetUpProgressBarProcessing(100);
@ -9304,49 +9306,49 @@ namespace ProxySU
}
//检测系统内核是否符合安装要求
private static bool DetectKernelVersion(string kernelVer)
{
string[] linuxKernelCompared = kernelVer.Split('.');
if (int.Parse(linuxKernelCompared[0]) > 2)
{
//MessageBox.Show($"当前系统内核版本为{result.Result},符合安装要求!");
return true;
}
else if (int.Parse(linuxKernelCompared[0]) < 2)
{
//MessageBox.Show($"当前系统内核版本为{result.Result}V2ray要求内核为2.6.23及以上。请升级内核再安装!");
return false;
}
else if (int.Parse(linuxKernelCompared[0]) == 2)
{
if (int.Parse(linuxKernelCompared[1]) > 6)
{
//MessageBox.Show($"当前系统内核版本为{result.Result},符合安装要求!");
return true;
}
else if (int.Parse(linuxKernelCompared[1]) < 6)
{
//MessageBox.Show($"当前系统内核版本为{result.Result}V2ray要求内核为2.6.23及以上。请升级内核再安装!");
return false;
}
else if (int.Parse(linuxKernelCompared[1]) == 6)
{
if (int.Parse(linuxKernelCompared[2]) < 23)
{
//MessageBox.Show($"当前系统内核版本为{result.Result}V2ray要求内核为2.6.23及以上。请升级内核再安装!");
return false;
}
else
{
//MessageBox.Show($"当前系统内核版本为{result.Result},符合安装要求!");
return true;
}
//private static bool DetectKernelVersion(string kernelVer)
//{
// string[] linuxKernelCompared = kernelVer.Split('.');
// if (int.Parse(linuxKernelCompared[0]) > 2)
// {
// //MessageBox.Show($"当前系统内核版本为{result.Result},符合安装要求!");
// return true;
// }
// else if (int.Parse(linuxKernelCompared[0]) < 2)
// {
// //MessageBox.Show($"当前系统内核版本为{result.Result}V2ray要求内核为2.6.23及以上。请升级内核再安装!");
// return false;
// }
// else if (int.Parse(linuxKernelCompared[0]) == 2)
// {
// if (int.Parse(linuxKernelCompared[1]) > 6)
// {
// //MessageBox.Show($"当前系统内核版本为{result.Result},符合安装要求!");
// return true;
// }
// else if (int.Parse(linuxKernelCompared[1]) < 6)
// {
// //MessageBox.Show($"当前系统内核版本为{result.Result}V2ray要求内核为2.6.23及以上。请升级内核再安装!");
// return false;
// }
// else if (int.Parse(linuxKernelCompared[1]) == 6)
// {
// if (int.Parse(linuxKernelCompared[2]) < 23)
// {
// //MessageBox.Show($"当前系统内核版本为{result.Result}V2ray要求内核为2.6.23及以上。请升级内核再安装!");
// return false;
// }
// else
// {
// //MessageBox.Show($"当前系统内核版本为{result.Result},符合安装要求!");
// return true;
// }
}
}
return false;
// }
// }
// return false;
}
//}
//打开系统工具中的校对时间窗口
@ -11693,6 +11695,7 @@ namespace ProxySU
//调用的函数返回false后的提示
private string FunctionResultErr()
{
//*****"发生错误,安装中断......"*****
string currentStatus = Application.Current.FindResource("DisplayInstallInfo_FunctionResultErr").ToString();
MainWindowsShowInfo(currentStatus);
return "";

View File

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

View File

@ -67,10 +67,10 @@ namespace ProxySU
TextBoxTransmission.Text = "";
//伪装类型
TextBoxCamouflageType.Text = MainWindow.ReceiveConfigurationParameters[5];
//TLS的Host /Quic 加密方式
TextBoxHostQuicEncryption.Text = "";
//QUIC密钥/mKCP Seed/路径Path
TextBoxQuicKeyMkcpSeedPath.Text = MainWindow.ReceiveConfigurationParameters[6];
@ -336,7 +336,7 @@ namespace ProxySU
RadioButtonVlessTcpXtls.IsChecked = true;
}
}
else if (String.Equals(MainWindow.proxyType, "TrojanGo"))
{
@ -487,7 +487,7 @@ namespace ProxySU
//TextBoxPluginNameExplainSSpc.Visibility = Visibility.Collapsed;
TextBlockPluginOptionExplainSS.Visibility = Visibility.Collapsed;
TextBoxPluginOptionExplainSS.Visibility = Visibility.Collapsed;
TextBlockClientPromptSS.Visibility = Visibility.Collapsed;
RadioButtonMobile.Visibility = Visibility.Collapsed;
RadioButtonPC.Visibility = Visibility.Collapsed;
@ -553,11 +553,11 @@ namespace ProxySU
//File.Delete($"ss_config\\{saveFileFolder}\\QR.bmp");
//File.Delete($"ss_config\\{saveFileFolder}\\url.txt");
}
}
}
else if(String.Equals(MainWindow.proxyType, "MTProto"))
else if (String.Equals(MainWindow.proxyType, "MTProto"))
{
//显示MTProto参数隐藏其他
GroupBoxClientMTProto.Visibility = Visibility.Visible;
@ -571,57 +571,64 @@ namespace ProxySU
GroupBoxClientSS.Visibility = Visibility.Collapsed;
string proxyfolder = CheckDir("mtproto_config");
configDomainSavePath = CreateConfigSaveDir(proxyfolder,MainWindow.ReceiveConfigurationParameters[4]);
configDomainSavePath = CreateConfigSaveDir(proxyfolder, MainWindow.ReceiveConfigurationParameters[4]);
string configSavePath = configDomainSavePath;
string mtprotoJsonPath = @"mtproto_config\mtproto_info.json";
using (StreamReader readerJson = File.OpenText(mtprotoJsonPath))
//string mtprotoJsonPath = @"mtproto_config\mtproto_info.json";
//using (StreamReader readerJson = File.OpenText(mtprotoJsonPath))
//{
//JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson));
JObject jObjectJson = JObject.Parse(MainWindow.ReceiveConfigurationParameters[9]);
TextBoxURLMtgTgIpv4.Text = jObjectJson["ipv4"]["tg_url"].ToString();
ImageShareQRcodeMtgTgIpv4.Source = CreateQRCode(TextBoxURLMtgTgIpv4.Text, $"{configSavePath}\\QRIpv4Tg.bmp");
using (StreamWriter sw = new StreamWriter($"{configSavePath}\\urlIpv4Tg.txt"))
{
JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson));
TextBoxURLMtgTgIpv4.Text = jObjectJson["ipv4"]["tg_url"].ToString();
ImageShareQRcodeMtgTgIpv4.Source = CreateQRCode(TextBoxURLMtgTgIpv4.Text, $"{configSavePath}\\QRIpv4Tg.bmp");
using (StreamWriter sw = new StreamWriter($"{configSavePath}\\urlIpv4Tg.txt"))
{
sw.WriteLine(TextBoxURLMtgTgIpv4.Text);
}
TextBoxURLMtgTmeIpv4.Text = jObjectJson["ipv4"]["tme_url"].ToString();
ImageShareQRcodeMtgTmeIpv4.Source = CreateQRCode(TextBoxURLMtgTmeIpv4.Text, $"{configSavePath}\\QRIpv4Tme.bmp");
using (StreamWriter sw = new StreamWriter($"{configSavePath}\\urlIpv4Tme.txt"))
{
sw.WriteLine(TextBoxURLMtgTmeIpv4.Text);
}
if (jObjectJson["ipv6"]["tg_url"].ToString().Contains("nil")==false)
{
RadioButtonMtgIpv6.Visibility = Visibility.Visible;
TextBoxURLMtgTgIpv6.Text = jObjectJson["ipv6"]["tg_url"].ToString();
ImageShareQRcodeMtgTgIpv6.Source = CreateQRCode(TextBoxURLMtgTgIpv6.Text, $"{configSavePath}\\QRIpv6Tg.bmp");
using (StreamWriter sw = new StreamWriter($"{configSavePath}\\urlIpv6Tg.txt"))
{
sw.WriteLine(TextBoxURLMtgTgIpv6.Text);
}
TextBoxURLMtgTmeIpv6.Text = jObjectJson["ipv6"]["tme_url"].ToString();
ImageShareQRcodeMtgTmeIpv6.Source = CreateQRCode(TextBoxURLMtgTmeIpv6.Text, $"{configSavePath}\\QRIpv6Tme.bmp");
using (StreamWriter sw = new StreamWriter($"{configSavePath}\\urlIpv6Tme.txt"))
{
sw.WriteLine(TextBoxURLMtgTmeIpv6.Text);
}
}
else
{
RadioButtonMtgIpv6.Visibility = Visibility.Collapsed;
}
RadioButtonMtgIpv4.IsChecked = true;
sw.WriteLine(TextBoxURLMtgTgIpv4.Text);
}
if (File.Exists(@"mtproto_config\mtproto_info.json"))
TextBoxURLMtgTmeIpv4.Text = jObjectJson["ipv4"]["tme_url"].ToString();
ImageShareQRcodeMtgTmeIpv4.Source = CreateQRCode(TextBoxURLMtgTmeIpv4.Text, $"{configSavePath}\\QRIpv4Tme.bmp");
using (StreamWriter sw = new StreamWriter($"{configSavePath}\\urlIpv4Tme.txt"))
{
File.Move(@"mtproto_config\mtproto_info.json", $"{configSavePath}\\mtproto_info.json");
//File.Delete(@"config\config.json");//删除该文件
sw.WriteLine(TextBoxURLMtgTmeIpv4.Text);
}
if (jObjectJson["ipv6"]["tg_url"].ToString().Contains("nil") == false)
{
RadioButtonMtgIpv6.Visibility = Visibility.Visible;
TextBoxURLMtgTgIpv6.Text = jObjectJson["ipv6"]["tg_url"].ToString();
ImageShareQRcodeMtgTgIpv6.Source = CreateQRCode(TextBoxURLMtgTgIpv6.Text, $"{configSavePath}\\QRIpv6Tg.bmp");
using (StreamWriter sw = new StreamWriter($"{configSavePath}\\urlIpv6Tg.txt"))
{
sw.WriteLine(TextBoxURLMtgTgIpv6.Text);
}
TextBoxURLMtgTmeIpv6.Text = jObjectJson["ipv6"]["tme_url"].ToString();
ImageShareQRcodeMtgTmeIpv6.Source = CreateQRCode(TextBoxURLMtgTmeIpv6.Text, $"{configSavePath}\\QRIpv6Tme.bmp");
using (StreamWriter sw = new StreamWriter($"{configSavePath}\\urlIpv6Tme.txt"))
{
sw.WriteLine(TextBoxURLMtgTmeIpv6.Text);
}
}
else
{
RadioButtonMtgIpv6.Visibility = Visibility.Collapsed;
}
RadioButtonMtgIpv4.IsChecked = true;
using (StreamWriter sw = new StreamWriter($"{configSavePath}\\mtproto_info.json"))
{
sw.Write(MainWindow.ReceiveConfigurationParameters[9].ToString());
}
//}
//if (File.Exists(@"mtproto_config\mtproto_info.json"))
//{
// File.Move(@"mtproto_config\mtproto_info.json", $"{configSavePath}\\mtproto_info.json");
// //File.Delete(@"config\config.json");//删除该文件
//}
}
}

Binary file not shown.