diff --git a/ProxySU/MainWindow.xaml b/ProxySU/MainWindow.xaml index f1e2a15..7729f54 100644 --- a/ProxySU/MainWindow.xaml +++ b/ProxySU/MainWindow.xaml @@ -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.11" Height="675" Width="650"> + Title="ProxySU - v2.4.12" Height="675" Width="650"> diff --git a/ProxySU/MainWindow.xaml.cs b/ProxySU/MainWindow.xaml.cs index 60653f1..bfce48e 100644 --- a/ProxySU/MainWindow.xaml.cs +++ b/ProxySU/MainWindow.xaml.cs @@ -42,6 +42,7 @@ namespace ProxySU public string Value { get; set; } } public static string[] ReceiveConfigurationParameters { get; set; } + //ReceiveConfigurationParameters[0]----模板类型 //ReceiveConfigurationParameters[1]----服务端口 //ReceiveConfigurationParameters[2]----V2Ray uuid/(naive/Trojan-go/Trojan/SSR/SS)' Password @@ -53,6 +54,7 @@ namespace ProxySU //ReceiveConfigurationParameters[8]----方案名称 //ReceiveConfigurationParameters[9]----插件参数选项/VMESS tcp Path/MTProto Parameters //public static ConnectionInfo ConnectionInfo; + public static string proxyType = "V2Ray"; //代理类型标识: V2Ray\TrojanGo\Trojan\NaiveProxy public static readonly string pwdir = AppDomain.CurrentDomain.BaseDirectory; //执行文件所在目录 static bool testDomain = false; //设置标识--域名是否需要检测解析,初始化为不需要 @@ -3467,6 +3469,7 @@ namespace ProxySU //传递参数 ReceiveConfigurationParameters[4] = TextBoxNaiveHostDomain.Text;//传递域名 + ReceiveConfigurationParameters[1] = "443";//传递端口 ReceiveConfigurationParameters[3] = TextBoxNaiveUser.Text;//传递用户名 ReceiveConfigurationParameters[2] = TextBoxNaivePassword.Text;//传递密码 ReceiveConfigurationParameters[7] = TextBoxNaiveSites.Text;//传递伪装网站 @@ -3581,7 +3584,7 @@ namespace ProxySU currentStatus = Application.Current.FindResource("DisplayInstallInfo_UpgradeNaiveProxy").ToString(); MainWindowsShowInfo(currentStatus); - sshShellCommand = $"curl -o /tmp/caddy.zip https://raw.githubusercontent.com/proxysu/Resources/master/Caddy2/caddy20200816.zip"; + sshShellCommand = $"curl -o /tmp/caddy.zip https://raw.githubusercontent.com/proxysu/Resources/master/Caddy2/caddy2.zip"; currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); sshShellCommand = @"yes | unzip -o /tmp/caddy.zip"; @@ -3610,40 +3613,51 @@ namespace ProxySU MainWindowsShowInfo(currentStatus); //生成服务端配置 - string caddyConfig = $"{pwdir}" + @"TemplateConfg\naive\naive_server_config.json"; - using (StreamReader reader = File.OpenText(caddyConfig)) - { - JObject serverJson = (JObject)JToken.ReadFrom(new JsonTextReader(reader)); - serverJson["apps"]["http"]["servers"]["srv0"]["routes"][0]["handle"][0]["auth_user"] = ReceiveConfigurationParameters[3];//----用户名 - serverJson["apps"]["http"]["servers"]["srv0"]["routes"][0]["handle"][0]["auth_pass"] = ReceiveConfigurationParameters[2]; //----密码 + string caddyConfig = $"{pwdir}" + @"TemplateConfg\naive\naive_server.caddyfile"; + string upLoadPath = @"/etc/caddy/Caddyfile"; + UploadConfig(connectionInfo, caddyConfig, upLoadPath); + //$"sed -i 's/##domain##/{ReceiveConfigurationParameters[4]}/' {upLoadPath}" + //$"sed -i 's/##basicauth##/basicauth {ReceiveConfigurationParameters[3]} {ReceiveConfigurationParameters[2]}/' {upLoadPath}" + sshShellCommand = $"sed -i 's/##domain##/{ReceiveConfigurationParameters[4]}/' {upLoadPath}"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - serverJson["apps"]["http"]["servers"]["srv0"]["routes"][1]["match"][0]["host"][0] = ReceiveConfigurationParameters[4]; //----域名 + sshShellCommand = $"sed -i 's/##basicauth##/basic_auth {ReceiveConfigurationParameters[3]} {ReceiveConfigurationParameters[2]}/' {upLoadPath}"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - serverJson["apps"]["http"]["servers"]["srv0"]["tls_connection_policies"][0]["match"]["sni"][0] = ReceiveConfigurationParameters[4]; //----域名 + //string caddyConfig = $"{pwdir}" + @"TemplateConfg\naive\naive_server_config.json"; + //using (StreamReader reader = File.OpenText(caddyConfig)) + //{ + // JObject serverJson = (JObject)JToken.ReadFrom(new JsonTextReader(reader)); + // serverJson["apps"]["http"]["servers"]["srv0"]["routes"][0]["handle"][0]["auth_user"] = ReceiveConfigurationParameters[3];//----用户名 + // serverJson["apps"]["http"]["servers"]["srv0"]["routes"][0]["handle"][0]["auth_pass"] = ReceiveConfigurationParameters[2]; //----密码 - serverJson["apps"]["tls"]["automation"]["policies"][0]["subjects"][0] = ReceiveConfigurationParameters[4]; //-----域名 - serverJson["apps"]["tls"]["automation"]["policies"][0]["issuer"]["email"] = $"user@{ReceiveConfigurationParameters[4]}"; //-----邮箱 - //保存配置文件 - using (StreamWriter sw = new StreamWriter(@"config.json")) - { - sw.Write(serverJson.ToString()); - } - } - string upLoadPath = @"/etc/caddy/config.json"; - UploadConfig(connectionInfo, @"config.json", upLoadPath); + // serverJson["apps"]["http"]["servers"]["srv0"]["routes"][1]["match"][0]["host"][0] = ReceiveConfigurationParameters[4]; //----域名 - File.Delete(@"config.json"); + // serverJson["apps"]["http"]["servers"]["srv0"]["tls_connection_policies"][0]["match"]["sni"][0] = ReceiveConfigurationParameters[4]; //----域名 + + // serverJson["apps"]["tls"]["automation"]["policies"][0]["subjects"][0] = ReceiveConfigurationParameters[4]; //-----域名 + // serverJson["apps"]["tls"]["automation"]["policies"][0]["issuer"]["email"] = $"user@{ReceiveConfigurationParameters[4]}"; //-----邮箱 + // //保存配置文件 + // using (StreamWriter sw = new StreamWriter(@"config.json")) + // { + // sw.Write(serverJson.ToString()); + // } + //} + //string upLoadPath = @"/etc/caddy/config.json"; + //UploadConfig(connectionInfo, @"config.json", upLoadPath); + + //File.Delete(@"config.json"); //****** Caddy配置文件上传成功,OK! ****** SetUpProgressBarProcessing(70); currentStatus = Application.Current.FindResource("DisplayInstallInfo_UploadCaddyConfigOK").ToString(); MainWindowsShowInfo(currentStatus); - sshShellCommand = @"sed -i 's/Caddyfile/config.json/' /lib/systemd/system/caddy.service"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + //sshShellCommand = @"sed -i 's/Caddyfile/config.json/' /lib/systemd/system/caddy.service"; + //currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - sshShellCommand = @"systemctl daemon-reload"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + //sshShellCommand = @"systemctl daemon-reload"; + //currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); //程序启动检测Caddy functionResult = SoftStartDetect(client, "caddy", @"/usr/bin/caddy"); @@ -6075,6 +6089,678 @@ namespace ProxySU } + #region 启用Root密码登录 + private void ButtonEnableRootPassWord_Click(object sender, RoutedEventArgs e) + { + //******"本功能需要当前登录的账户具有sudo权限,是否为远程主机启用root账户并设置密码?"****** + string messageShow = Application.Current.FindResource("MessageBoxShow_EnableRootPassword").ToString(); + MessageBoxResult messageBoxResult = MessageBox.Show(messageShow, "", MessageBoxButton.YesNo, MessageBoxImage.Question); + if (messageBoxResult == MessageBoxResult.Yes) + { + ConnectionInfo connectionInfo = GenerateConnectionInfo(); + if (connectionInfo == null) + { + //****** "远程主机连接信息有误,请检查!" ****** + MessageBox.Show(Application.Current.FindResource("MessageBoxShow_ErrorHostConnection").ToString()); + return; + } + + ReceiveConfigurationParameters[4] = TextBoxHost.Text;//传递主机地址 + ReceiveConfigurationParameters[2] = PasswordBoxHostPassword.Password;//传递当前账户密码 + + installationDegree = 0; + TextBoxMonitorCommandResults.Text = ""; + Thread thread = new Thread(() => EnableRootPassWord(connectionInfo)); + thread.SetApartmentState(ApartmentState.STA); + thread.Start(); + } + } + //启用Root密码登录进程 + private void EnableRootPassWord(ConnectionInfo connectionInfo) + { + functionResult = true; + getApt = false; + getDnf = false; + getYum = false; + onlyIpv6 = false; + + //******"正在登录远程主机......"****** + SetUpProgressBarProcessing(1); + string currentStatus = Application.Current.FindResource("DisplayInstallInfo_Login").ToString(); + MainWindowsShowInfo(currentStatus); + + try + { + #region 主机指纹,暂未启用 + //byte[] expectedFingerPrint = new byte[] { + // 0x66, 0x31, 0xaf, 0x00, 0x54, 0xb9, 0x87, 0x31, + // 0xff, 0x58, 0x1c, 0x31, 0xb1, 0xa2, 0x4c, 0x6b + // }; + #endregion + using (var client = new SshClient(connectionInfo)) + + { + #region ssh登录验证主机指纹代码块,暂未启用 + // client.HostKeyReceived += (sender, e) => + // { + // if (expectedFingerPrint.Length == e.FingerPrint.Length) + // { + // for (var i = 0; i < expectedFingerPrint.Length; i++) + // { + // if (expectedFingerPrint[i] != e.FingerPrint[i]) + // { + // e.CanTrust = false; + // break; + // } + // } + // } + // else + // { + // e.CanTrust = false; + // } + // }; + #endregion + + client.Connect(); + if (client.IsConnected == true) + { + //******"主机登录成功"****** + SetUpProgressBarProcessing(5); + currentStatus = Application.Current.FindResource("DisplayInstallInfo_LoginSuccessful").ToString(); + MainWindowsShowInfo(currentStatus); + } + + //检测root权限 5--7 + //******"检测是否运行在root权限下..."******01 + SetUpProgressBarProcessing(5); + currentStatus = Application.Current.FindResource("DisplayInstallInfo_DetectionRootPermission").ToString(); + MainWindowsShowInfo(currentStatus); + + sshShellCommand = @"id -u"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + if (currentShellCommandResult.TrimEnd('\r', '\n').Equals("0") == true) + { + //******"当前账户已经具有root权限,无需再设置!"****** + currentStatus = Application.Current.FindResource("MessageBoxShow_AlreadyRoot").ToString(); + MainWindowsShowInfo(currentStatus); + MessageBox.Show(currentStatus); + client.Disconnect(); + return; + } + + SetUpProgressBarProcessing(10); + string hostPassword = "'" + ReceiveConfigurationParameters[2] + "'"; + //MessageBox.Show(hostPassword); + sshShellCommand = $"echo {hostPassword} | sudo -S id -u"; + //MessageBox.Show(sshShellCommand); + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + if (currentShellCommandResult.TrimEnd('\r', '\n').Equals("0") == false) + { + //******"当前账户无法获取sudo权限,设置失败!"****** + currentStatus = Application.Current.FindResource("MessageBoxShow_NoSudoToAccount").ToString(); + MainWindowsShowInfo(currentStatus); + MessageBox.Show(currentStatus); + client.Disconnect(); + return; + } + + SetUpProgressBarProcessing(20); + string cmdPre = $"echo {hostPassword} | sudo -S id -u" + ';'; + sshShellCommand = cmdPre + @"sudo sed -i 's/PermitRootLogin /#PermitRootLogin /g' /etc/ssh/sshd_config"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + + sshShellCommand = cmdPre + @"sudo sed -i 's/PasswordAuthentication /#PasswordAuthentication /g' /etc/ssh/sshd_config"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + + SetUpProgressBarProcessing(30); + sshShellCommand = cmdPre + @"sudo sed -i 's/PermitEmptyPasswords /#PermitEmptyPasswords /g' /etc/ssh/sshd_config"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + + sshShellCommand = cmdPre + @"echo 'PermitRootLogin yes' | sudo tee -a /etc/ssh/sshd_config"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + + SetUpProgressBarProcessing(40); + sshShellCommand = cmdPre + @"echo 'PasswordAuthentication yes' | sudo tee -a /etc/ssh/sshd_config"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + + sshShellCommand = cmdPre + @"echo 'PermitEmptyPasswords no' | sudo tee -a /etc/ssh/sshd_config"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + + SetUpProgressBarProcessing(60); + sshShellCommand = cmdPre + @"sudo systemctl restart sshd"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + + //******"生成20位随机密码!"****** + currentStatus = Application.Current.FindResource("DisplayInstallInfo_GenerateRandomPassword").ToString(); + MainWindowsShowInfo(currentStatus); + + sshShellCommand = @"cat /dev/urandom | tr -dc '_A-Z#\-+=a-z(0-9%^>)]{<|' | head -c 20 ; echo ''"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + + SetUpProgressBarProcessing(80); + string setPassword = currentShellCommandResult.TrimEnd('\r', '\n') + '\n'; + + sshShellCommand = cmdPre + $"echo -e \"{setPassword}{setPassword}\" | sudo passwd root"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + + client.Disconnect(); + + //***保存密码信息*** + currentStatus = Application.Current.FindResource("DisplayInstallInfo_EnableRootPasswordSavePasswordInfo").ToString(); + MainWindowsShowInfo(currentStatus); + + string filePath = ReceiveConfigurationParameters[4].Replace(':', '_'); + CheckDir(filePath); + using (StreamWriter sw = new StreamWriter($"{filePath}\\host_password_info.txt")) + { + sw.WriteLine(ReceiveConfigurationParameters[4]); + sw.WriteLine("root"); + sw.WriteLine(setPassword); + } + + SetUpProgressBarProcessing(100); + //***远程主机Root账户密码登录已启用,密码保存在随后打开的文件夹中!*** + currentStatus = Application.Current.FindResource("DisplayInstallInfo_EnableRootPasswordSuccess").ToString(); + MainWindowsShowInfo(currentStatus); + MessageBox.Show(currentStatus); + System.Diagnostics.Process.Start("explorer.exe", filePath); + return; + } + } + catch (Exception ex1)//例外处理 + #region 例外处理 + { + ProcessException(ex1.Message); + + //****** "主机登录失败!" ****** + currentStatus = Application.Current.FindResource("DisplayInstallInfo_LoginFailed").ToString(); + MainWindowsShowInfo(currentStatus); + } + #endregion + + } + + #endregion + + #region 启用Root证书密钥登录 + private void ButtonEnableRootCert_Click(object sender, RoutedEventArgs e) + { + //******"本功能需要当前登录的账户具有root或者sudo权限,是否为远程主机启用root证书密钥登录?"****** + string messageShow = Application.Current.FindResource("MessageBoxShow_ButtonEnableRootCert").ToString(); + MessageBoxResult messageBoxResult = MessageBox.Show(messageShow, "", MessageBoxButton.YesNo, MessageBoxImage.Question); + if (messageBoxResult == MessageBoxResult.Yes) + { + ConnectionInfo connectionInfo = GenerateConnectionInfo(); + if (connectionInfo == null) + { + //****** "远程主机连接信息有误,请检查!" ****** + MessageBox.Show(Application.Current.FindResource("MessageBoxShow_ErrorHostConnection").ToString()); + return; + } + + ReceiveConfigurationParameters[4] = TextBoxHost.Text;//传递主机地址 + ReceiveConfigurationParameters[2] = PasswordBoxHostPassword.Password; + + installationDegree = 0; + TextBoxMonitorCommandResults.Text = ""; + Thread thread = new Thread(() => EnableRootCert(connectionInfo)); + thread.SetApartmentState(ApartmentState.STA); + thread.Start(); + } + } + + //启用Root证书密钥登录进程 + private void EnableRootCert(ConnectionInfo connectionInfo) + { + functionResult = true; + getApt = false; + getDnf = false; + getYum = false; + onlyIpv6 = false; + + string filePath = String.Empty; + + //******"正在登录远程主机......"****** + SetUpProgressBarProcessing(1); + string currentStatus = Application.Current.FindResource("DisplayInstallInfo_Login").ToString(); + MainWindowsShowInfo(currentStatus); + + try + { + #region 主机指纹,暂未启用 + //byte[] expectedFingerPrint = new byte[] { + // 0x66, 0x31, 0xaf, 0x00, 0x54, 0xb9, 0x87, 0x31, + // 0xff, 0x58, 0x1c, 0x31, 0xb1, 0xa2, 0x4c, 0x6b + // }; + #endregion + using (var client = new SshClient(connectionInfo)) + + { + #region ssh登录验证主机指纹代码块,暂未启用 + // client.HostKeyReceived += (sender, e) => + // { + // if (expectedFingerPrint.Length == e.FingerPrint.Length) + // { + // for (var i = 0; i < expectedFingerPrint.Length; i++) + // { + // if (expectedFingerPrint[i] != e.FingerPrint[i]) + // { + // e.CanTrust = false; + // break; + // } + // } + // } + // else + // { + // e.CanTrust = false; + // } + // }; + #endregion + + client.Connect(); + if (client.IsConnected == true) + { + //******"主机登录成功"****** + SetUpProgressBarProcessing(5); + currentStatus = Application.Current.FindResource("DisplayInstallInfo_LoginSuccessful").ToString(); + MainWindowsShowInfo(currentStatus); + } + + //检测root权限 5--7 + //******"检测是否运行在root权限下..."******01 + SetUpProgressBarProcessing(5); + currentStatus = Application.Current.FindResource("DisplayInstallInfo_DetectionRootPermission").ToString(); + MainWindowsShowInfo(currentStatus); + + sshShellCommand = @"id -u"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + if (currentShellCommandResult.TrimEnd('\r', '\n').Equals("0") == true) + { + SetUpProgressBarProcessing(20); + + //***正在生成密钥......*** + currentStatus = Application.Current.FindResource("DisplayInstallInfo_EnableRootCertGenerateCert").ToString(); + MainWindowsShowInfo(currentStatus); + + sshShellCommand = @"rm -rf /tmp/rootuser.key /tmp/rootuser.key.pub"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + + sshShellCommand = @"yes | ssh-keygen -b 2048 -t rsa -f /tmp/rootuser.key -q -N ''"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + + sshShellCommand = @"yes | ssh-keygen -p -P '' -N '' -m PEM -f /tmp/rootuser.key"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + + sshShellCommand = @"mkdir -p /root/.ssh"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + + sshShellCommand = @"cat /tmp/rootuser.key.pub | tee -a /root/.ssh/authorized_keys"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + + sshShellCommand = @"chmod 777 /tmp/rootuser.key"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + + SetUpProgressBarProcessing(30); + //***正在下载密钥......*** + currentStatus = Application.Current.FindResource("DisplayInstallInfo_EnableRootCertDownloadCert").ToString(); + MainWindowsShowInfo(currentStatus); + + filePath = CreateConfigSaveDir(@"root_cert", ReceiveConfigurationParameters[4].Replace(':', '_')); + string localConfigSavePathAndFileName = $"{filePath}\\rootuser.key"; + string remoteConfigPathAndFileName = @"/tmp/rootuser.key"; + DownloadConfig(connectionInfo, localConfigSavePathAndFileName, remoteConfigPathAndFileName); + + localConfigSavePathAndFileName = $"{filePath}\\rootuser.key.pub"; + remoteConfigPathAndFileName = @"/tmp/rootuser.key.pub"; + DownloadConfig(connectionInfo, localConfigSavePathAndFileName, remoteConfigPathAndFileName); + + sshShellCommand = @"rm -rf /tmp/rootuser.key /tmp/rootuser.key.pub"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + + SetUpProgressBarProcessing(50); + //***远程主机启用密钥登录......*** + currentStatus = Application.Current.FindResource("DisplayInstallInfo_EnableRootCertSetCertEnable").ToString(); + MainWindowsShowInfo(currentStatus); + + sshShellCommand = @"sed -i 's/PermitRootLogin /#PermitRootLogin /g' /etc/ssh/sshd_config"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + + sshShellCommand = @"sed -i 's/StrictModes /#StrictModes /g' /etc/ssh/sshd_config"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + + SetUpProgressBarProcessing(70); + sshShellCommand = @"sed -i 's/PubkeyAuthentication /#PubkeyAuthentication /g' /etc/ssh/sshd_config"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + + sshShellCommand = @"sed -i 's/#AuthorizedKeysFile /AuthorizedKeysFile /g' /etc/ssh/sshd_config"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + + SetUpProgressBarProcessing(80); + sshShellCommand = @"sed -i 's/#RSAAuthentication /RSAAuthentication /g' /etc/ssh/sshd_config"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + + sshShellCommand = @"echo 'PermitRootLogin yes' | tee -a /etc/ssh/sshd_config"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + + SetUpProgressBarProcessing(90); + sshShellCommand = @"echo 'StrictModes no' | tee -a /etc/ssh/sshd_config"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + + sshShellCommand = @"echo 'PubkeyAuthentication yes' | tee -a /etc/ssh/sshd_config"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + + sshShellCommand = @"systemctl restart sshd"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + + } + else + { + SetUpProgressBarProcessing(10); + string hostPassword = "'" + ReceiveConfigurationParameters[2] + "'"; + //MessageBox.Show(hostPassword); + sshShellCommand = $"echo {hostPassword} | sudo -S id -u"; + //MessageBox.Show(sshShellCommand); + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + //MessageBox.Show(currentShellCommandResult); + if (currentShellCommandResult.TrimEnd('\r', '\n').Equals("0") == false) + { + //******"当前账户无法获取sudo权限,设置失败!"****** + currentStatus = Application.Current.FindResource("MessageBoxShow_NoSudoToAccount").ToString(); + MainWindowsShowInfo(currentStatus); + MessageBox.Show(currentStatus); + client.Disconnect(); + return; + } + + SetUpProgressBarProcessing(20); + string cmdPre = $"echo {hostPassword} | sudo -S id -u" + ';'; + //***正在生成密钥......*** + currentStatus = Application.Current.FindResource("DisplayInstallInfo_EnableRootCertGenerateCert").ToString(); + MainWindowsShowInfo(currentStatus); + + sshShellCommand = cmdPre + @"sudo rm -rf /tmp/rootuser.key /tmp/rootuser.key.pub"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + + sshShellCommand = cmdPre + @"yes | sudo ssh-keygen -b 2048 -t rsa -f /tmp/rootuser.key -q -N ''"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + + sshShellCommand = cmdPre + @"yes | sudo ssh-keygen -p -P '' -N '' -m PEM -f /tmp/rootuser.key"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + + sshShellCommand = cmdPre + @"sudo mkdir -p /root/.ssh"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + + sshShellCommand = cmdPre + @"cat /tmp/rootuser.key.pub | sudo tee -a /root/.ssh/authorized_keys"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + + sshShellCommand = cmdPre + @"sudo chmod 777 /tmp/rootuser.key"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + + SetUpProgressBarProcessing(30); + //***正在下载密钥......*** + currentStatus = Application.Current.FindResource("DisplayInstallInfo_EnableRootCertDownloadCert").ToString(); + MainWindowsShowInfo(currentStatus); + + filePath = CreateConfigSaveDir(@"root_cert", ReceiveConfigurationParameters[4].Replace(':', '_')); + string localConfigSavePathAndFileName = $"{filePath}\\rootuser.key"; + string remoteConfigPathAndFileName = @"/tmp/rootuser.key"; + DownloadConfig(connectionInfo, localConfigSavePathAndFileName, remoteConfigPathAndFileName); + + localConfigSavePathAndFileName = $"{filePath}\\rootuser.key.pub"; + remoteConfigPathAndFileName = @"/tmp/rootuser.key.pub"; + DownloadConfig(connectionInfo, localConfigSavePathAndFileName, remoteConfigPathAndFileName); + + sshShellCommand = cmdPre + @"sudo rm -rf /tmp/rootuser.key /tmp/rootuser.key.pub"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + + SetUpProgressBarProcessing(50); + //***远程主机启用密钥登录......*** + currentStatus = Application.Current.FindResource("DisplayInstallInfo_EnableRootCertSetCertEnable").ToString(); + MainWindowsShowInfo(currentStatus); + + //string cmdPre = $"echo {hostPassword} | sudo -S id -u" + ';'; + sshShellCommand = cmdPre + @"sudo sed -i 's/PermitRootLogin /#PermitRootLogin /g' /etc/ssh/sshd_config"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + + sshShellCommand = cmdPre + @"sudo sed -i 's/StrictModes /#StrictModes /g' /etc/ssh/sshd_config"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + + SetUpProgressBarProcessing(70); + sshShellCommand = cmdPre + @"sudo sed -i 's/PubkeyAuthentication /#PubkeyAuthentication /g' /etc/ssh/sshd_config"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + + sshShellCommand = cmdPre + @"sudo sed -i 's/#AuthorizedKeysFile /AuthorizedKeysFile /g' /etc/ssh/sshd_config"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + + SetUpProgressBarProcessing(80); + sshShellCommand = cmdPre + @"sudo sed -i 's/#RSAAuthentication /RSAAuthentication /g' /etc/ssh/sshd_config"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + + sshShellCommand = cmdPre + @"echo 'PermitRootLogin yes' | sudo tee -a /etc/ssh/sshd_config"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + + SetUpProgressBarProcessing(90); + sshShellCommand = cmdPre + @"echo 'StrictModes no' | sudo tee -a /etc/ssh/sshd_config"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + + sshShellCommand = cmdPre + @"echo 'PubkeyAuthentication yes' | sudo tee -a /etc/ssh/sshd_config"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + + sshShellCommand = cmdPre + @"sudo systemctl restart sshd"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + + } + client.Disconnect(); + + SetUpProgressBarProcessing(100); + //******"远程主机root账户证书密钥登录已启用,密钥文件rootuser.key保存在随后打开的文件夹中!"****** + currentStatus = Application.Current.FindResource("MessageBoxShow_ButtonEnableRootCertSuccess").ToString(); + MainWindowsShowInfo(currentStatus); + MessageBox.Show(currentStatus); + System.Diagnostics.Process.Start("explorer.exe", filePath); + + return; + } + } + catch (Exception ex1)//例外处理 + #region 例外处理 + { + ProcessException(ex1.Message); + + //****** "主机登录失败!" ****** + currentStatus = Application.Current.FindResource("DisplayInstallInfo_LoginFailed").ToString(); + MainWindowsShowInfo(currentStatus); + } + #endregion + + } + + + #endregion + + #region 禁止root账户密码登录 + //root禁止密码登录 + private void ButtonRootProhibitsPasswordLogin_Click(object sender, RoutedEventArgs e) + { + //******"本功能需要远程主机已经开启了其他登录方式,如密钥方式等,否则将可能造成远程主机无法连接,是否禁止远程主机的root账户密码登录方式?"****** + string messageShow = Application.Current.FindResource("MessageBoxShow_ButtonRootProhibitsPasswordLogin").ToString(); + MessageBoxResult messageBoxResult = MessageBox.Show(messageShow, "", MessageBoxButton.YesNo, MessageBoxImage.Question); + if (messageBoxResult == MessageBoxResult.Yes) + { + ConnectionInfo connectionInfo = GenerateConnectionInfo(); + if (connectionInfo == null) + { + //****** "远程主机连接信息有误,请检查!" ****** + MessageBox.Show(Application.Current.FindResource("MessageBoxShow_ErrorHostConnection").ToString()); + return; + } + + ReceiveConfigurationParameters[4] = TextBoxHost.Text;//传递主机地址 + ReceiveConfigurationParameters[2] = PasswordBoxHostPassword.Password;//传递主机密码 + + installationDegree = 0; + TextBoxMonitorCommandResults.Text = ""; + Thread thread = new Thread(() => RootProhibitsPasswordLogin(connectionInfo)); + thread.SetApartmentState(ApartmentState.STA); + thread.Start(); + } + } + + //禁止root密码登录进程 + private void RootProhibitsPasswordLogin(ConnectionInfo connectionInfo) + { + functionResult = true; + getApt = false; + getDnf = false; + getYum = false; + onlyIpv6 = false; + + string filePath = String.Empty; + + //******"正在登录远程主机......"****** + SetUpProgressBarProcessing(1); + string currentStatus = Application.Current.FindResource("DisplayInstallInfo_Login").ToString(); + MainWindowsShowInfo(currentStatus); + + try + { + #region 主机指纹,暂未启用 + //byte[] expectedFingerPrint = new byte[] { + // 0x66, 0x31, 0xaf, 0x00, 0x54, 0xb9, 0x87, 0x31, + // 0xff, 0x58, 0x1c, 0x31, 0xb1, 0xa2, 0x4c, 0x6b + // }; + #endregion + using (var client = new SshClient(connectionInfo)) + + { + #region ssh登录验证主机指纹代码块,暂未启用 + // client.HostKeyReceived += (sender, e) => + // { + // if (expectedFingerPrint.Length == e.FingerPrint.Length) + // { + // for (var i = 0; i < expectedFingerPrint.Length; i++) + // { + // if (expectedFingerPrint[i] != e.FingerPrint[i]) + // { + // e.CanTrust = false; + // break; + // } + // } + // } + // else + // { + // e.CanTrust = false; + // } + // }; + #endregion + + client.Connect(); + if (client.IsConnected == true) + { + //******"主机登录成功"****** + SetUpProgressBarProcessing(5); + currentStatus = Application.Current.FindResource("DisplayInstallInfo_LoginSuccessful").ToString(); + MainWindowsShowInfo(currentStatus); + } + + //检测root权限 5--7 + //******"检测是否运行在root权限下..."******01 + SetUpProgressBarProcessing(5); + currentStatus = Application.Current.FindResource("DisplayInstallInfo_DetectionRootPermission").ToString(); + MainWindowsShowInfo(currentStatus); + + sshShellCommand = @"id -u"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + if (currentShellCommandResult.TrimEnd('\r', '\n').Equals("0") == true) + { + SetUpProgressBarProcessing(20); + + //***正在关闭root账户密码登录方式......*** + currentStatus = Application.Current.FindResource("DisplayInstallInfo_SetRootProhibitsPasswordLogin").ToString(); + MainWindowsShowInfo(currentStatus); + + sshShellCommand = @"sed -i 's/PasswordAuthentication /#PasswordAuthentication /g' /etc/ssh/sshd_config"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + + sshShellCommand = @"sed -i 's/PermitEmptyPasswords /#PermitEmptyPasswords /g' /etc/ssh/sshd_config"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + + sshShellCommand = @"echo 'PasswordAuthentication no' | tee -a /etc/ssh/sshd_config"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + + sshShellCommand = @"echo 'PermitEmptyPasswords no' | tee -a /etc/ssh/sshd_config"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + + sshShellCommand = @"systemctl restart sshd"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + } + else + { + SetUpProgressBarProcessing(10); + string hostPassword = "'" + ReceiveConfigurationParameters[2] + "'"; + //MessageBox.Show(hostPassword); + sshShellCommand = $"echo {hostPassword} | sudo -S id -u"; + //MessageBox.Show(sshShellCommand); + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + //MessageBox.Show(currentShellCommandResult); + if (currentShellCommandResult.TrimEnd('\r', '\n').Equals("0") == false) + { + //******"当前账户无法获取sudo权限,设置失败!"****** + currentStatus = Application.Current.FindResource("MessageBoxShow_NoSudoToAccount").ToString(); + MainWindowsShowInfo(currentStatus); + MessageBox.Show(currentStatus); + client.Disconnect(); + return; + } + + SetUpProgressBarProcessing(20); + string cmdPre = $"echo {hostPassword} | sudo -S id -u" + ';'; + + //***正在关闭root账户密码登录方式......*** + currentStatus = Application.Current.FindResource("DisplayInstallInfo_SetRootProhibitsPasswordLogin").ToString(); + MainWindowsShowInfo(currentStatus); + + sshShellCommand = cmdPre + @"sudo sed -i 's/PasswordAuthentication /#PasswordAuthentication /g' /etc/ssh/sshd_config"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + + sshShellCommand = cmdPre + @"sudo sed -i 's/PermitEmptyPasswords /#PermitEmptyPasswords /g' /etc/ssh/sshd_config"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + + sshShellCommand = cmdPre + @"echo 'PasswordAuthentication no' | sudo tee -a /etc/ssh/sshd_config"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + + sshShellCommand = cmdPre + @"echo 'PermitEmptyPasswords no' | sudo tee -a /etc/ssh/sshd_config"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + + sshShellCommand = cmdPre + @"sudo systemctl restart sshd"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + + } + client.Disconnect(); + + SetUpProgressBarProcessing(100); + //******"远程主机root账户密码登录方式已关闭!"****** + currentStatus = Application.Current.FindResource("MessageBoxShow_RootProhibitsPasswordLoginOK").ToString(); + MainWindowsShowInfo(currentStatus); + MessageBox.Show(currentStatus); + + return; + } + } + catch (Exception ex1)//例外处理 + #region 例外处理 + { + ProcessException(ex1.Message); + + //****** "主机登录失败!" ****** + currentStatus = Application.Current.FindResource("DisplayInstallInfo_LoginFailed").ToString(); + MainWindowsShowInfo(currentStatus); + } + #endregion + } + #endregion + + #endregion #region 资源工具标签页控制 @@ -6153,991 +6839,6 @@ namespace ProxySU } } - #endregion - - #region 三合一安装过程 - - // //生成三合一的v2ray路径 - // private void ButtonV2rayPath3in1_Click(object sender, RoutedEventArgs e) - // { - // string path = RandomUserName(); - // TextBoxV2rayPath3in1.Text = $"/{path}"; - // } - - // //生成三合一Trojan密码 - // private void ButtonTrojanPassword3in1_Click(object sender, RoutedEventArgs e) - // { - // TextBoxTrojanPassword3in1.Text = RandomUUID(); - // } - - // //生成三合一V2ray的UUID - // private void ButtonV2rayUUID3in1_Click(object sender, RoutedEventArgs e) - // { - // TextBoxV2rayUUID3in1.Text = RandomUUID(); - // } - - // //生成三合一中Naive的用户名 - // private void ButtonNaiveUser3in1_Click(object sender, RoutedEventArgs e) - // { - // TextBoxNaiveUser3in1.Text = RandomUserName(); - // } - - // //生成三合一中Naive的密码 - // private void ButtonNaivePassword3in1_Click(object sender, RoutedEventArgs e) - // { - // TextBoxNaivePassword3in1.Text = RandomUUID(); - // } - - // //启用三合一安装运行 - // private void Button_Login3in1_Click(object sender, RoutedEventArgs e) - // { - // if (string.IsNullOrEmpty(TextBoxDomain3in1.Text) == true) - // { - // MessageBox.Show("域名不能为空!"); - // return; - // } - // //ReceiveConfigurationParameters[0]----模板类型 - // //ReceiveConfigurationParameters[1]----Trojan的密码 - // //ReceiveConfigurationParameters[2]----v2ray的uuid - // //ReceiveConfigurationParameters[3]----v2ray的path - // //ReceiveConfigurationParameters[4]----domain - // //ReceiveConfigurationParameters[5]----Naive的用户名 - // //ReceiveConfigurationParameters[6]----Naive的密码 - // //ReceiveConfigurationParameters[7]----伪装网站 - // ConnectionInfo connectionInfo = GenerateConnectionInfo(); - // if (connectionInfo == null) - // { - // MessageBox.Show("远程主机连接信息有误,请检查"); - // return; - // } - // string serverConfig = ""; //服务端配置文件 - // string clientConfig = ""; //生成的客户端配置文件 - // string upLoadPath = ""; //服务端文件位置 - // //传递参数 - // ReceiveConfigurationParameters[4] = TextBoxDomain3in1.Text;//传递域名 - // ReceiveConfigurationParameters[7] = TextBoxSites3in1.Text;//传递伪装网站 - // ReceiveConfigurationParameters[2] = TextBoxV2rayUUID3in1.Text;//v2ray的uuid - // ReceiveConfigurationParameters[3] = TextBoxV2rayPath3in1.Text;//v2ray的path - // ReceiveConfigurationParameters[1] = TextBoxTrojanPassword3in1.Text;//Trojan的密码 - // ReceiveConfigurationParameters[5] = TextBoxNaiveUser3in1.Text;//Naive的用户名 - // ReceiveConfigurationParameters[6] = TextBoxNaivePassword3in1.Text;//Naive的密码 - // if (TextBoxSites3in1.Text.ToString().Length >= 7) - // { - // string testDomain = TextBoxSites3in1.Text.Substring(0, 7); - // if (String.Equals(testDomain, "https:/") || String.Equals(testDomain, "http://")) - // { - // //MessageBox.Show(testDomain); - // ReceiveConfigurationParameters[7] = TextBoxSites3in1.Text.Replace("/", "\\/"); - // } - // else - // { - // ReceiveConfigurationParameters[7] = "http:\\/\\/" + TextBoxSites3in1.Text; - // } - // } - - // //Thread thread - // Thread thread = new Thread(() => StartSetUp3in1(connectionInfo, TextBlockSetUpProcessing, ProgressBarSetUpProcessing, serverConfig, clientConfig, upLoadPath)); - // thread.SetApartmentState(ApartmentState.STA); - // thread.Start(); - // } - - // //登录远程主机布署三合一程序 - // private void StartSetUp3in1(ConnectionInfo connectionInfo, TextBlock textBlockName, ProgressBar progressBar, string serverConfig, string clientConfig, string upLoadPath) - // { - // string currentStatus = "正在登录远程主机......"; - - // textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); - - // try - // { - // #region 主机指纹,暂未启用 - // //byte[] expectedFingerPrint = new byte[] { - // // 0x66, 0x31, 0xaf, 0x00, 0x54, 0xb9, 0x87, 0x31, - // // 0xff, 0x58, 0x1c, 0x31, 0xb1, 0xa2, 0x4c, 0x6b - // // }; - // #endregion - // using (var client = new SshClient(connectionInfo)) - - // { - // #region ssh登录验证主机指纹代码块,暂未启用 - // // client.HostKeyReceived += (sender, e) => - // // { - // // if (expectedFingerPrint.Length == e.FingerPrint.Length) - // // { - // // for (var i = 0; i < expectedFingerPrint.Length; i++) - // // { - // // if (expectedFingerPrint[i] != e.FingerPrint[i]) - // // { - // // e.CanTrust = false; - // // break; - // // } - // // } - // // } - // // else - // // { - // // e.CanTrust = false; - // // } - // // }; - // #endregion - - // client.Connect(); - // if (client.IsConnected == true) - // { - // currentStatus = "主机登录成功"; - // textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); - // Thread.Sleep(1000); - // } - // //检测是否运行在root权限下 - // string testRootAuthority = client.RunCommand(@"id -u").Result; - // if (testRootAuthority.Equals("0\n") == false) - // { - // MessageBox.Show("请使用具有root权限的账户登录主机!!"); - // client.Disconnect(); - // return; - // } - // //检测是否安装有V2ray - // currentStatus = "检测系统是否已经安装 V2ray or Trojan or NaiveProxy......"; - // textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); - // Thread.Sleep(1000); - - // string cmdTestV2rayInstalled = @"find / -name v2ray"; - // string resultCmdTestV2rayInstalled = client.RunCommand(cmdTestV2rayInstalled).Result; - // string cmdTestTrojanInstalled = @"find / -name trojan"; - // string resultCmdTestTrojanInstall = client.RunCommand(cmdTestTrojanInstalled).Result; - // string cmdTestNaiveInstalled = @"find / -name naive"; - // string resultcmdTestNaiveInstalled = client.RunCommand(cmdTestNaiveInstalled).Result; - // if (resultCmdTestV2rayInstalled.Contains("/usr/bin/v2ray") == true || resultCmdTestTrojanInstall.Contains("/usr/local/bin/trojan") == true || resultcmdTestNaiveInstalled.Contains("/usr/local/bin/naive") == true) - // { - // MessageBoxResult messageBoxResult = MessageBox.Show("远程主机已安装V2ray or Trojan or NaiveProxy,是否强制重新安装?", "", MessageBoxButton.YesNo, MessageBoxImage.Question); - // if (messageBoxResult == MessageBoxResult.No) - // { - // currentStatus = "安装取消,退出"; - // textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); - // Thread.Sleep(1000); - // client.Disconnect(); - // return; - // } - // } - - // //检测远程主机系统环境是否符合要求 - // currentStatus = "检测系统是否符合安装要求......"; - // textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); - // Thread.Sleep(1000); - - // string result = client.RunCommand("uname -r").Result; - - // string[] linuxKernelVerStr = result.Split('-'); - - // bool detectResult = DetectKernelVersion(linuxKernelVerStr[0]); - // if (detectResult == false) - // { - // MessageBox.Show($"当前系统内核版本为{linuxKernelVerStr[0]},V2ray要求内核为2.6.23及以上。请升级内核再安装!"); - // currentStatus = "系统内核版本不符合要求,安装失败!!"; - // textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); - // Thread.Sleep(1000); - // } - // result = client.RunCommand("uname -m").Result; - - // if (result.Contains("x86_64") == false) - // { - // MessageBox.Show($"请在x86_64系统中安装Trojan/NaivProxy"); - // currentStatus = "系统不符合要求,安装失败!!"; - // textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); - // Thread.Sleep(1000); - // } - // //检测系统是否支持yum 或 apt-get或zypper,且支持Systemd - // //如果不存在组件,则命令结果为空,string.IsNullOrEmpty值为真, - // bool getApt = String.IsNullOrEmpty(client.RunCommand("command -v apt-get").Result); - // bool getYum = String.IsNullOrEmpty(client.RunCommand("command -v yum").Result); - // bool getZypper = String.IsNullOrEmpty(client.RunCommand("command -v zypper").Result); - // bool getSystemd = String.IsNullOrEmpty(client.RunCommand("command -v systemctl").Result); - // bool getGetenforce = String.IsNullOrEmpty(client.RunCommand("command -v getenforce").Result); - - // //没有安装apt-get,也没有安装yum,也没有安装zypper,或者没有安装systemd的,不满足安装条件 - // //也就是apt-get ,yum, zypper必须安装其中之一,且必须安装Systemd的系统才能安装。 - // if ((getApt && getYum && getZypper) || getSystemd) - // { - // MessageBox.Show($"系统缺乏必要的安装组件如:apt-get||yum||zypper||Syetemd,主机系统推荐使用:CentOS 7/8,Debian 8/9/10,Ubuntu 16.04及以上版本"); - // currentStatus = "系统环境不满足要求,安装失败!!"; - // textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); - // Thread.Sleep(1000); - // client.Disconnect(); - // return; - // } - // //判断是否启用了SELinux,如果启用了,并且工作在Enforcing模式下,则改为Permissive模式 - // if (getGetenforce == false) - // { - // string testSELinux = client.RunCommand("getenforce").Result; - // if (testSELinux.Contains("Enforcing") == true) - // { - // client.RunCommand("setenforce 0");//不重启改为Permissive模式 - // client.RunCommand("sed -i 's/SELINUX=enforcing/SELINUX=permissive/' /etc/selinux/config");//重启也工作在Permissive模式下 - // } - - // } - - // //校对时间 - // currentStatus = "校对时间......"; - // textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); - // Thread.Sleep(1000); - // //获取远程主机的时间戳 - // long timeStampVPS = Convert.ToInt64(client.RunCommand("date +%s").Result.ToString()); - - // //获取本地时间戳 - // TimeSpan ts = DateTime.Now.ToUniversalTime() - new DateTime(1970, 1, 1, 0, 0, 0, 0); - // long timeStampLocal = Convert.ToInt64(ts.TotalSeconds); - // if (Math.Abs(timeStampLocal - timeStampVPS) >= 90) - // { - - // MessageBox.Show("本地时间与远程主机时间相差超过限制(90秒),请先用\"系统工具-->时间校对\"校对时间后再设置"); - // currentStatus = "时间较对失败......"; - // textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); - // Thread.Sleep(1000); - // client.Disconnect(); - // return; - // } - - // currentStatus = "正在检测域名是否解析到当前VPS的IP上......"; - // textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); - // Thread.Sleep(1000); - - // //在相应系统内安装curl(如果没有安装curl) - // if (string.IsNullOrEmpty(client.RunCommand("command -v curl").Result) == true) - // { - // //为假则表示系统有相应的组件。 - // if (getApt == false) - // { - // client.RunCommand("apt-get -qq update"); - // client.RunCommand("apt-get -y -qq install curl"); - // } - // if (getYum == false) - // { - // client.RunCommand("yum -q makecache"); - // client.RunCommand("yum -y -q install curl"); - // } - // if (getZypper == false) - // { - // client.RunCommand("zypper ref"); - // client.RunCommand("zypper -y install curl"); - // } - // } - - // string vpsIp3in1 = client.RunCommand("curl -4 ip.sb").Result.ToString(); - // string testDomainCmd = "ping " + ReceiveConfigurationParameters[4] + " -c 1 | grep -oE -m1 \"([0-9]{1,3}\\.){3}[0-9]{1,3}\""; - // string resulttestDomainCmd = client.RunCommand(testDomainCmd).Result.ToString(); - - // if (String.Equals(vpsIp3in1, resulttestDomainCmd) == true) - // { - // currentStatus = "解析正确!"; - // textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); - // Thread.Sleep(1000); - // } - // else - // { - // currentStatus = "域名未能正确解析到当前VPS的IP上!安装失败!"; - // textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); - // Thread.Sleep(1000); - // MessageBox.Show("域名未能正确解析到当前VPS的IP上,请检查!若解析设置正确,请等待生效后再重试安装。如果域名使用了CDN,请先关闭!"); - // client.Disconnect(); - // return; - // } - - // //检测是否安装lsof - // if (string.IsNullOrEmpty(client.RunCommand("command -v lsof").Result) == true) - // { - // //为假则表示系统有相应的组件。 - // if (getApt == false) - // { - // client.RunCommand("apt-get -qq update"); - // client.RunCommand("apt-get -y -qq install lsof"); - // } - // if (getYum == false) - // { - // client.RunCommand("yum -q makecache"); - // client.RunCommand("yum -y -q install lsof"); - // } - // if (getZypper == false) - // { - // client.RunCommand("zypper ref"); - // client.RunCommand("zypper -y install lsof"); - // } - // } - // currentStatus = "正在检测端口占用情况......"; - // textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); - // Thread.Sleep(1000); - - // if (String.IsNullOrEmpty(client.RunCommand(@"lsof -n -P -i :80 | grep LISTEN").Result) == false || String.IsNullOrEmpty(client.RunCommand(@"lsof -n -P -i :443 | grep LISTEN").Result) == false) - // { - // //MessageBox.Show("80/443端口之一,或全部被占用,请先用系统工具中的“释放80/443端口”工具,释放出,再重新安装"); - // MessageBoxResult dialogResult = MessageBox.Show("80/443端口之一,或全部被占用,将强制停止占用80/443端口的程序?", "Stop application", MessageBoxButton.YesNo); - // if (dialogResult == MessageBoxResult.No) - // { - // currentStatus = "端口被占用,安装失败......"; - // textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); - // Thread.Sleep(1000); - // client.Disconnect(); - // return; - // } - - // currentStatus = "正在释放80/443端口......"; - // textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); - // Thread.Sleep(1000); - - // string cmdTestPort = @"lsof -n -P -i :443 | grep LISTEN"; - // string cmdResult = client.RunCommand(cmdTestPort).Result; - // if (String.IsNullOrEmpty(cmdResult) == false) - // { - // string[] cmdResultArry443 = cmdResult.Split(' '); - // 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(cmdResult) == false) - // { - // string[] cmdResultArry80 = cmdResult.Split(' '); - // client.RunCommand($"systemctl stop {cmdResultArry80[0]}"); - // client.RunCommand($"systemctl disable {cmdResultArry80[0]}"); - // client.RunCommand($"kill -9 {cmdResultArry80[3]}"); - // } - // currentStatus = "80/443端口释放完毕!"; - // textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); - // Thread.Sleep(1000); - - // } - - // //打开防火墙端口 - - // if (String.IsNullOrEmpty(client.RunCommand("command -v firewall-cmd").Result) == false) - // { - // client.RunCommand("firewall-cmd --zone=public --add-port=80/tcp --permanent"); - // client.RunCommand("firewall-cmd --zone=public --add-port=443/tcp --permanent"); - // client.RunCommand("firewall-cmd --reload"); - - // } - // if (String.IsNullOrEmpty(client.RunCommand("command -v ufw").Result) == false) - // { - - // client.RunCommand("ufw allow 80"); - // client.RunCommand("ufw allow 443"); - // client.RunCommand("yes | ufw reload"); - // } - - // currentStatus = "符合安装要求,V2ray安装中......"; - // textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); - // Thread.Sleep(1000); - - // //下载官方安装脚本安装V2ray - // client.RunCommand($"curl -o /tmp/go.sh https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh"); - // client.RunCommand("yes | bash /tmp/go.sh -f"); - // string installResult = client.RunCommand("find / -name v2ray").Result.ToString(); - - // if (!installResult.Contains("/usr/local/bin/v2ray")) - // { - // MessageBox.Show("安装V2ray失败(官方脚本运行出错!"); - - // currentStatus = "安装V2ray失败(官方脚本运行出错!"; - // textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); - // client.Disconnect(); - // return; - // } - // //client.RunCommand("mv /etc/v2ray/config.json /etc/v2ray/config.json.1"); - - // //上传配置文件 - // currentStatus = "V2ray程序安装完毕,配置文件上传中......"; - // textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); - // Thread.Sleep(1000); - - // //生成服务端配置 - // serverConfig = $"{pwdir}" + @"TemplateConfg\WebSocketTLSWeb_server_config.json"; - // using (StreamReader reader = File.OpenText(serverConfig)) - // { - // JObject serverJson = (JObject)JToken.ReadFrom(new JsonTextReader(reader)); - // //设置uuid - // serverJson["inbounds"][0]["settings"]["clients"][0]["id"] = ReceiveConfigurationParameters[2]; - // //设置路径 - // serverJson["inbounds"][0]["streamSettings"]["wsSettings"]["path"] = ReceiveConfigurationParameters[3]; - - // using (StreamWriter sw = new StreamWriter(@"config.json")) - // { - // sw.Write(serverJson.ToString()); - // } - // } - // upLoadPath = "usr/local/etc/v2ray/config.json"; - // UploadConfig(connectionInfo, @"config.json", upLoadPath); - // File.Delete(@"config.json"); - - // client.RunCommand("systemctl restart v2ray"); - // currentStatus = "启动V2ray,OK!"; - // textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); - // Thread.Sleep(1000); - - // //安装Trojan - // currentStatus = "开始安装Trojan......"; - // textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); - // Thread.Sleep(1000); - - // //下载官方安装脚本安装 - - // client.RunCommand($"curl -o /tmp/trojan-quickstart.sh https://raw.githubusercontent.com/trojan-gfw/trojan-quickstart/master/trojan-quickstart.sh"); - // client.RunCommand("yes | bash /tmp/trojan-quickstart.sh"); - - // installResult = client.RunCommand("find / -name trojan").Result.ToString(); - - // if (!installResult.Contains("/usr/local/bin/trojan")) - // { - // MessageBox.Show("安装Trojan失败(官方脚本运行出错!"); - - // currentStatus = "安装Trojan失败(官方脚本运行出错!"; - // textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); - // client.Disconnect(); - // return; - // } - // client.RunCommand("mv /usr/local/etc/trojan/config.json /usr/local/etc/trojan/config.json.1"); - - // //上传配置文件 - // currentStatus = "Trojan程序安装完毕,配置文件上传中......"; - // textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); - // Thread.Sleep(1000); - - // //生成服务端配置 - // serverConfig = $"{pwdir}" + @"TemplateConfg\trojan_server_config.json"; - // using (StreamReader reader = File.OpenText(serverConfig)) - // { - // JObject serverJson = (JObject)JToken.ReadFrom(new JsonTextReader(reader)); - // //设置密码 - // serverJson["password"][0] = ReceiveConfigurationParameters[1]; - - // using (StreamWriter sw = new StreamWriter(@"config.json")) - // { - // sw.Write(serverJson.ToString()); - // } - // } - // upLoadPath = "/usr/local/etc/trojan/config.json"; - // UploadConfig(connectionInfo, @"config.json", upLoadPath); - // File.Delete(@"config.json"); - - - // //安装NaiveProxy - // currentStatus = "开始安装NaiveProxy......"; - // textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); - // Thread.Sleep(1000); - - // //下载安装脚本安装 - - // client.RunCommand($"curl -o /tmp/naive-quickstart.sh https://raw.githubusercontent.com/proxysu/shellscript/master/naive-quickstart.sh"); - // client.RunCommand("yes | bash /tmp/naive-quickstart.sh"); - - // installResult = client.RunCommand("find / -name naive").Result.ToString(); - - // if (!installResult.Contains("/usr/local/bin/naive")) - // { - // MessageBox.Show("安装NaiveProxy失败(脚本运行出错!"); - // client.Disconnect(); - // currentStatus = "安装NaiveProxy失败(脚本运行出错!"; - // textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); - // client.Disconnect(); - // return; - // } - - // currentStatus = "NaiveProxy程序安装完毕......"; - // textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); - // Thread.Sleep(1000); - - // client.RunCommand("systemctl restart naive"); - // currentStatus = "启动Naive,OK!"; - // textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); - // Thread.Sleep(1000); - - - - - // currentStatus = "正在安装acme.sh......"; - // textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); - // Thread.Sleep(1000); - - // if (getApt == false) - // { - // //client.RunCommand("apt-get -qq update"); - // client.RunCommand("apt-get -y -qq install socat"); - // } - // if (getYum == false) - // { - // //client.RunCommand("yum -q makecache"); - // client.RunCommand("yum -y -q install socat"); - // } - // if (getZypper == false) - // { - // // client.RunCommand("zypper ref"); - // client.RunCommand("zypper -y install socat"); - // } - // client.RunCommand($"curl https://raw.githubusercontent.com/acmesh-official/acme.sh/master/acme.sh | INSTALLONLINE=1 sh"); - // client.RunCommand("cd ~/.acme.sh/"); - // client.RunCommand("alias acme.sh=~/.acme.sh/acme.sh"); - - // currentStatus = "申请域名证书......"; - // textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); - // Thread.Sleep(1000); - - // //client.RunCommand("mkdir -p /etc/v2ray/ssl"); - // client.RunCommand($"/root/.acme.sh/acme.sh --issue --standalone -d {ReceiveConfigurationParameters[4]}"); - - // currentStatus = "正在安装证书......"; - // textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); - // Thread.Sleep(1000); - // client.RunCommand($"/root/.acme.sh/acme.sh --installcert -d {ReceiveConfigurationParameters[4]} --certpath /usr/local/etc/trojan/trojan_ssl.crt --keypath /usr/local/etc/trojan/trojan_ssl.key --capath /usr/local/etc/trojan/trojan_ssl.crt --reloadcmd \"systemctl restart trojan\""); - - // currentStatus = "证书安装,OK!"; - // textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); - // Thread.Sleep(1000); - - // client.RunCommand("systemctl restart trojan"); - - // currentStatus = "Trojan重启加载证书,OK!"; - // textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); - // Thread.Sleep(1000); - - // currentStatus = "正在安装Caddy......"; - // textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); - // Thread.Sleep(1000); - - // client.RunCommand("curl https://getcaddy.com -o getcaddy"); - // client.RunCommand("bash getcaddy personal http.forwardproxy,hook.service"); - // client.RunCommand("mkdir -p /etc/caddy"); - // client.RunCommand("mkdir -p /var/www"); - - - // currentStatus = "上传Caddy配置文件......"; - // textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); - // Thread.Sleep(1000); - - // serverConfig = $"{pwdir}" + @"TemplateConfg\3in1_config.caddyfile"; - - // upLoadPath = "/etc/caddy/Caddyfile"; - // UploadConfig(connectionInfo, serverConfig, upLoadPath); - - // //设置邮箱 - // string email = $"user@{ReceiveConfigurationParameters[4]}"; - // //设置Path - // string sshCmd; - // sshCmd = $"sed -i 's/##path##/\\{ReceiveConfigurationParameters[3]}/' {upLoadPath}"; - // client.RunCommand(sshCmd); - // //设置域名 - // sshCmd = $"sed -i 's/##domain##/{ReceiveConfigurationParameters[4]}:80/' {upLoadPath}"; - // client.RunCommand(sshCmd); - // sshCmd = $"sed -i 's/##basicauth##/basicauth {ReceiveConfigurationParameters[5]} {ReceiveConfigurationParameters[6]}/' {upLoadPath}"; - // client.RunCommand(sshCmd); - // //设置伪装网站 - - // if (String.IsNullOrEmpty(ReceiveConfigurationParameters[7]) == false) - // { - // sshCmd = $"sed -i 's/##sites##/proxy \\/ {ReceiveConfigurationParameters[7]}/' {upLoadPath}"; - // client.RunCommand(sshCmd); - // } - // Thread.Sleep(2000); - - // //安装Caddy服务 - // sshCmd = $"caddy -service install -agree -conf /etc/caddy/Caddyfile -email {email}"; - // client.RunCommand(sshCmd); - - // //启动Caddy服务 - // client.RunCommand("caddy -service restart"); - // currentStatus = "启动Caddy,OK!"; - // textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); - // Thread.Sleep(1000); - - // currentStatus = "正在启用BBR......"; - // textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); - // Thread.Sleep(1000); - // //测试BBR条件,若满足提示是否启用 - // result = client.RunCommand("uname -r").Result; - // //var result = client.RunCommand("cat /root/test.ver"); - // linuxKernelVerStr = result.Split('-'); - - // detectResult = DetectKernelVersionBBR(linuxKernelVerStr[0]); - // string resultCmdTestBBR = client.RunCommand(@"sysctl net.ipv4.tcp_congestion_control | grep bbr").Result; - // //如果内核满足大于等于4.9,且还未启用BBR,则启用BBR - // if (detectResult == true && resultCmdTestBBR.Contains("bbr") == false) - // { - // client.RunCommand(@"bash -c 'echo ""net.core.default_qdisc=fq"" >> /etc/sysctl.conf'"); - // client.RunCommand(@"bash -c 'echo ""net.ipv4.tcp_congestion_control=bbr"" >> /etc/sysctl.conf'"); - // client.RunCommand(@"sysctl -p"); - // } - // resultCmdTestBBR = client.RunCommand(@"sysctl net.ipv4.tcp_congestion_control | grep bbr").Result; - // if (resultCmdTestBBR.Contains("bbr") == true) - // { - // currentStatus = "启用BBR,OK!"; - // textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); - // Thread.Sleep(1000); - // } - // else - // { - // currentStatus = "启用BBR,未成功!"; - // textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); - // Thread.Sleep(1000); - // } - - // currentStatus = "正在优化网络参数......"; - // textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); - // Thread.Sleep(1000); - // //优化网络参数 - // sshCmd = @"bash -c 'echo ""fs.file-max = 51200"" >> /etc/sysctl.conf'"; - // client.RunCommand(sshCmd); - // sshCmd = @"bash -c 'echo ""net.core.rmem_max = 67108864"" >> /etc/sysctl.conf'"; - // client.RunCommand(sshCmd); - // sshCmd = @"bash -c 'echo ""net.core.wmem_max = 67108864"" >> /etc/sysctl.conf'"; - // client.RunCommand(sshCmd); - // sshCmd = @"bash -c 'echo ""net.core.rmem_default = 65536"" >> /etc/sysctl.conf'"; - // client.RunCommand(sshCmd); - // sshCmd = @"bash -c 'echo ""net.core.wmem_default = 65536"" >> /etc/sysctl.conf'"; - // client.RunCommand(sshCmd); - // sshCmd = @"bash -c 'echo ""net.core.netdev_max_backlog = 4096"" >> /etc/sysctl.conf'"; - // client.RunCommand(sshCmd); - // sshCmd = @"bash -c 'echo ""net.core.somaxconn = 4096"" >> /etc/sysctl.conf'"; - // client.RunCommand(sshCmd); - // sshCmd = @"bash -c 'echo ""net.ipv4.tcp_syncookies = 1"" >> /etc/sysctl.conf'"; - // client.RunCommand(sshCmd); - // sshCmd = @"bash -c 'echo ""net.ipv4.tcp_tw_reuse = 1"" >> /etc/sysctl.conf'"; - // client.RunCommand(sshCmd); - // sshCmd = @"bash -c 'echo ""net.ipv4.tcp_tw_recycle = 0"" >> /etc/sysctl.conf'"; - // client.RunCommand(sshCmd); - // sshCmd = @"bash -c 'echo ""net.ipv4.tcp_fin_timeout = 30"" >> /etc/sysctl.conf'"; - // client.RunCommand(sshCmd); - // sshCmd = @"bash -c 'echo ""net.ipv4.tcp_keepalive_time = 1200"" >> /etc/sysctl.conf'"; - // client.RunCommand(sshCmd); - // sshCmd = @"bash -c 'echo ""net.ipv4.ip_local_port_range = 10000 65000"" >> /etc/sysctl.conf'"; - // client.RunCommand(sshCmd); - // sshCmd = @"bash -c 'echo ""net.ipv4.tcp_max_syn_backlog = 4096"" >> /etc/sysctl.conf'"; - // client.RunCommand(sshCmd); - // sshCmd = @"bash -c 'echo ""net.ipv4.tcp_max_tw_buckets = 5000"" >> /etc/sysctl.conf'"; - // client.RunCommand(sshCmd); - // sshCmd = @"bash -c 'echo ""net.ipv4.tcp_rmem = 4096 87380 67108864"" >> /etc/sysctl.conf'"; - // client.RunCommand(sshCmd); - // sshCmd = @"bash -c 'echo ""net.ipv4.tcp_wmem = 4096 65536 67108864"" >> /etc/sysctl.conf'"; - // client.RunCommand(sshCmd); - // sshCmd = @"bash -c 'echo ""net.ipv4.tcp_mtu_probing = 1"" >> /etc/sysctl.conf'"; - // client.RunCommand(sshCmd); - // sshCmd = @"sysctl -p"; - // client.RunCommand(sshCmd); - - // currentStatus = "优化网络参数,OK!"; - // textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); - // Thread.Sleep(1000); - - // //生成客户端配置 - // currentStatus = "生成客户端配置......"; - // textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); - // Thread.Sleep(1000); - // //创建3in1文件夹 - // if (!Directory.Exists("3in1_config"))//如果不存在就创建file文件夹      - // { - // Directory.CreateDirectory("3in1_config");//创建该文件夹   - // } - // //生成v2ray官方客户端配置 - // clientConfig = $"{pwdir}" + @"TemplateConfg\WebSocketTLSWeb_client_config.json"; - // using (StreamReader reader = File.OpenText(clientConfig)) - // { - // JObject clientJson = (JObject)JToken.ReadFrom(new JsonTextReader(reader)); - - // clientJson["outbounds"][0]["settings"]["vnext"][0]["address"] = ReceiveConfigurationParameters[4]; - // clientJson["outbounds"][0]["settings"]["vnext"][0]["port"] = int.Parse("443"); - // clientJson["outbounds"][0]["settings"]["vnext"][0]["users"][0]["id"] = ReceiveConfigurationParameters[2]; - - // clientJson["outbounds"][0]["streamSettings"]["wsSettings"]["path"] = ReceiveConfigurationParameters[3]; - // if (!Directory.Exists(@"3in1_config\v2ray_config"))//如果不存在就创建file文件夹      - // { - // Directory.CreateDirectory(@"3in1_config\v2ray_config");//创建该文件夹   - // } - // using (StreamWriter sw = new StreamWriter(@"3in1_config\v2ray_config\config.json")) - // { - // sw.Write(clientJson.ToString()); - // } - // } - // //生成V2rayN的客户端 - // string v2rayNjsonFile = @" - //{ - // ""v"": """", - // ""ps"": """", - // ""add"": """", - // ""port"": """", - // ""id"": """", - // ""aid"": """", - // ""net"": """", - // ""type"": """", - // ""host"": """", - // ""path"": """", - // ""tls"": """" - //}"; - // JObject v2rayNjsonObject = JObject.Parse(v2rayNjsonFile); - // v2rayNjsonObject["v"] = "2"; - // v2rayNjsonObject["add"] = ReceiveConfigurationParameters[4]; //设置域名 - // v2rayNjsonObject["port"] = "443"; //设置端口 - // v2rayNjsonObject["id"] = ReceiveConfigurationParameters[2]; //设置uuid - // v2rayNjsonObject["aid"] = "16"; //设置额外ID - // v2rayNjsonObject["net"] = "ws"; //设置传输模式 - // v2rayNjsonObject["type"] = "none"; //设置伪装类型 - // v2rayNjsonObject["path"] = ReceiveConfigurationParameters[3];//设置路径 - // v2rayNjsonObject["host"] = "";//设置TLS的Host - // v2rayNjsonObject["tls"] = "tls"; //设置是否启用TLS - // v2rayNjsonObject["ps"] = v2rayNjsonObject["add"]; //设置备注 - - // //如果已存在以前保存目录,则新建后缀数字依次增加 - // string saveFileFolderFirst = v2rayNjsonObject["ps"].ToString(); - // int num = 1; - // string saveFileFolder = saveFileFolderFirst; - // while (Directory.Exists(@"3in1_config\v2ray_config\" + saveFileFolder)) - // { - // saveFileFolder = saveFileFolderFirst + "_copy_" + num.ToString(); - // num++; - // } - // Directory.CreateDirectory(@"3in1_config\v2ray_config\" + saveFileFolder);//创建该文件夹 - - - // //生成url和二维码 - // byte[] textBytes = Encoding.UTF8.GetBytes(v2rayNjsonObject.ToString()); - // string vmessUrl = "vmess://" + Convert.ToBase64String(textBytes); - - // using (StreamWriter sw = new StreamWriter($"3in1_config\\v2ray_config\\{saveFileFolder}\\url.txt")) - // { - // sw.WriteLine(vmessUrl); - - // } - // //生成二维码 - // QRCodeGenerator qrGenerator = new QRCodeGenerator(); - // QRCodeData qrCodeData = qrGenerator.CreateQrCode(vmessUrl, QRCodeGenerator.ECCLevel.Q); - // QRCode qrCode = new QRCode(qrCodeData); - // Bitmap qrCodeImage = qrCode.GetGraphic(20); - // //IntPtr myImagePtr = qrCodeImage.GetHbitmap(); - // //BitmapSource imgsource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(myImagePtr, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); - // //ImageShareQRcode.Source = imgsource; - // ////DeleteObject(myImagePtr); - // qrCodeImage.Save($"3in1_config\\v2ray_config\\{saveFileFolder}\\QR.bmp"); - - // //生成说明文件 - // using (StreamWriter sw = new StreamWriter($"3in1_config\\v2ray_config\\{saveFileFolder}\\说明.txt")) - // { - // sw.WriteLine("config.json"); - // sw.WriteLine("此文件为v2ray官方程序所使用的客户端配置文件,配置为全局模式,socks5地址:127.0.0.1:1080,http代理地址:127.0.0.1:1081"); - // sw.WriteLine("v2ray官方网站:https://www.v2ray.com/"); - // sw.WriteLine("v2ray官方程序下载地址:https://github.com/v2ray/v2ray-core/releases"); - // sw.WriteLine("下载相应版本,Windows选择v2ray-windows-64.zip或者v2ray-windows-32.zip,解压后提取v2ctl.exe和v2ray.exe。与config.json放在同一目录,运行v2ray.exe即可。"); - // sw.WriteLine("-----------------------------------------"); - // sw.WriteLine("QR.bmp"); - // sw.WriteLine("此文件为v2rayN、v2rayNG(Android)、Shadowrocket(ios)扫码导入节点"); - // sw.WriteLine("v2rayN下载网址:https://github.com/2dust/v2rayN/releases"); - // sw.WriteLine("v2rayNG(Android)下载网址:https://github.com/2dust/v2rayNG/releases"); - // sw.WriteLine("v2rayNG(Android)在Google Play下载网址:https://play.google.com/store/apps/details?id=com.v2ray.ang"); - // sw.WriteLine("Shadowrocket(ios)下载,需要使用国外区的AppleID。请自行谷歌方法。"); - - // sw.WriteLine("-----------------------------------------"); - // sw.WriteLine("url.txt"); - // sw.WriteLine("此文件为v2rayN、v2rayNG(Android)、Shadowrocket(ios)复制粘贴导入节点的vmess网址"); - // sw.WriteLine("-----------------------------------------\n"); - // sw.WriteLine("服务器通用连接配置参数"); - // sw.WriteLine($"地址(address):{ReceiveConfigurationParameters[4]}"); - // sw.WriteLine($"端口(Port):443"); - // sw.WriteLine($"用户ID(uuid):{ReceiveConfigurationParameters[2]}"); - // sw.WriteLine($"额外ID:16"); - // sw.WriteLine($"加密方式:auto"); - // sw.WriteLine($"传输协议:ws"); - // sw.WriteLine($"伪装类型:none"); - // sw.WriteLine($"是否使用TLS:tls"); - // sw.WriteLine($"host:"); - // sw.WriteLine($"路径(Path):{ReceiveConfigurationParameters[3]}"); - // sw.WriteLine($"QUIC密钥:"); - // } - // //移动V2ray官方配置config.json到与上述文件同一目录 - // File.Move(@"3in1_config\v2ray_config\config.json", @"3in1_config\v2ray_config\" + saveFileFolder + @"\config.json"); - - // //生成Trojan客户端文件 - // clientConfig = $"{pwdir}" + @"TemplateConfg\trojan_client_config.json"; - // if (!Directory.Exists(@"3in1_config\trojan_config"))//如果不存在就创建file文件夹      - // { - // Directory.CreateDirectory(@"3in1_config\trojan_config");//创建该文件夹   - // } - // using (StreamReader reader = File.OpenText(clientConfig)) - // { - // JObject clientJson = (JObject)JToken.ReadFrom(new JsonTextReader(reader)); - - // clientJson["remote_addr"] = ReceiveConfigurationParameters[4]; - // //clientJson["remote_port"] = int.Parse(ReceiveConfigurationParameters[1]); - // clientJson["password"][0] = ReceiveConfigurationParameters[1]; - - // using (StreamWriter sw = new StreamWriter(@"3in1_config\trojan_config\config.json")) - // { - // sw.Write(clientJson.ToString()); - // } - // } - // //生成二维码和url - // saveFileFolderFirst = ReceiveConfigurationParameters[4]; - // num = 1; - // saveFileFolder = saveFileFolderFirst; - // while (Directory.Exists(@"3in1_config\trojan_config\" + saveFileFolder)) - // { - // saveFileFolder = saveFileFolderFirst + "_copy_" + num.ToString(); - // num++; - // } - // Directory.CreateDirectory(@"3in1_config\trojan_config\" + saveFileFolder);//创建该文件夹 - - // string trojanUrl = $"trojan://{ReceiveConfigurationParameters[1]}@{ReceiveConfigurationParameters[4]}:443#{ReceiveConfigurationParameters[4]}"; - // using (StreamWriter sw = new StreamWriter($"3in1_config\\trojan_config\\{saveFileFolder}\\url.txt")) - // { - // sw.WriteLine(trojanUrl); - - // } - // //生成二维码 - // QRCodeGenerator qrGeneratorTrojan = new QRCodeGenerator(); - // QRCodeData qrCodeDataTrojan = qrGeneratorTrojan.CreateQrCode(trojanUrl, QRCodeGenerator.ECCLevel.Q); - // QRCode qrCodeTrojan = new QRCode(qrCodeDataTrojan); - // Bitmap qrCodeImageTrojan = qrCodeTrojan.GetGraphic(20); - // qrCodeImageTrojan.Save($"3in1_config\\trojan_config\\{saveFileFolder}\\QR.bmp"); - - // //生成说明文件 - // using (StreamWriter sw = new StreamWriter($"3in1_config\\trojan_config\\{saveFileFolder}\\说明.txt")) - // { - // sw.WriteLine("config.json"); - // sw.WriteLine("此文件为Trojan官方程序所使用的客户端配置文件,配置为全局模式,socks5地址:127.0.0.1:1080"); - // sw.WriteLine("Trojan官方网站:https://trojan-gfw.github.io/trojan/"); - // sw.WriteLine("Trojan官方程序下载地址:https://github.com/trojan-gfw/trojan/releases"); - // sw.WriteLine("下载相应版本,Windows选择Trojan-x.xx-win.zip,解压后提取trojan.exe。与config.json放在同一目录,运行trojan.exe即可。"); - // sw.WriteLine("-----------------------------------------\n"); - // sw.WriteLine("QR.bmp"); - // sw.WriteLine("此文件为Trojan-QT5 (windows)、igniter(Android)、Shadowrocket(ios)扫码导入节点"); - // sw.WriteLine("Trojan-QT5 (windows)下载网址:https://github.com/TheWanderingCoel/Trojan-Qt5/releases"); - // sw.WriteLine("igniter(Android)下载网址:https://github.com/trojan-gfw/igniter/releases"); - // sw.WriteLine("Shadowrocket(ios)下载,需要使用国外区的AppleID。请自行谷歌方法。"); - - // sw.WriteLine("-----------------------------------------\n"); - // sw.WriteLine("url.txt"); - // sw.WriteLine("此文件为Trojan-QT5 (windows)、igniter(Android)、Shadowrocket(ios)复制粘贴导入节点的网址"); - // sw.WriteLine("-----------------------------------------\n"); - // sw.WriteLine("服务器通用连接配置参数"); - // sw.WriteLine($"地址(address):{ReceiveConfigurationParameters[4]}"); - // sw.WriteLine($"端口(Port):443"); - // sw.WriteLine($"密钥:{ReceiveConfigurationParameters[1]}"); - - // } - // //移动Trojan官方配置config.json到与上述文件同一目录 - // File.Move(@"3in1_config\trojan_config\config.json", @"3in1_config\trojan_config\" + saveFileFolder + @"\config.json"); - - // //生成NaiveProxy的客户端配置 - // clientConfig = $"{pwdir}" + @"TemplateConfg\Naiveproxy_client_config.json"; - // if (!Directory.Exists(@"3in1_config\naive_config"))//如果不存在就创建file文件夹      - // { - // Directory.CreateDirectory(@"3in1_config\naive_config");//创建该文件夹   - // } - // using (StreamReader reader = File.OpenText(clientConfig)) - // { - // JObject clientJson = (JObject)JToken.ReadFrom(new JsonTextReader(reader)); - - // clientJson["proxy"] = $"https://{ReceiveConfigurationParameters[5]}:{ReceiveConfigurationParameters[6]}@{ReceiveConfigurationParameters[4]}"; - - // using (StreamWriter sw = new StreamWriter(@"3in1_config\naive_config\config.json")) - // { - // sw.Write(clientJson.ToString()); - // } - // } - // //生成用于NaiveGUI的url - // saveFileFolderFirst = ReceiveConfigurationParameters[4]; - // num = 1; - // saveFileFolder = saveFileFolderFirst; - // while (Directory.Exists(@"3in1_config\naive_config\" + saveFileFolder)) - // { - // saveFileFolder = saveFileFolderFirst + "_copy_" + num.ToString(); - // num++; - // } - // Directory.CreateDirectory(@"3in1_config\naive_config\" + saveFileFolder);//创建该文件夹 - - // string naiveUrl = $"https://{ReceiveConfigurationParameters[5]}:{ReceiveConfigurationParameters[6]}@{ReceiveConfigurationParameters[4]}:443/?name={ReceiveConfigurationParameters[4]}&padding=true"; - // using (StreamWriter sw = new StreamWriter($"3in1_config\\naive_config\\{saveFileFolder}\\url.txt")) - // { - // sw.WriteLine(naiveUrl); - // } - // //生成说明文件 - // using (StreamWriter sw = new StreamWriter($"3in1_config\\naive_config\\{saveFileFolder}\\说明.txt")) - // { - // sw.WriteLine("config.json"); - // sw.WriteLine("此文件为NaiveProxy官方程序所使用的客户端配置文件,配置为全局模式,socks5地址:127.0.0.1:1080"); - // sw.WriteLine("NaiveProxy官方网站:https://github.com/klzgrad/naiveproxy"); - // sw.WriteLine("NaiveProxy官方程序下载地址:https://github.com/klzgrad/naiveproxy/releases"); - // sw.WriteLine("下载相应版本,Windows选择naiveproxy-x.xx-win.zip,解压后提取naive.exe。与config.json放在同一目录,运行naive.exe即可。"); - // sw.WriteLine("-----------------------------------------\n"); - // //sw.WriteLine("其他平台的客户端,暂未发布"); - // //sw.WriteLine("QR.bmp"); - // //sw.WriteLine("此文件为Trojan-QT5 (windows)、igniter(Android)、Shadowrocket(ios)扫码导入节点"); - // //sw.WriteLine("Trojan-QT5 (windows)下载网址:https://github.com/TheWanderingCoel/Trojan-Qt5/releases"); - // //sw.WriteLine("igniter(Android)下载网址:https://github.com/trojan-gfw/igniter/releases"); - // //sw.WriteLine("Shadowrocket(ios)下载,需要使用国外区的AppleID。请自行谷歌方法。"); - - // //sw.WriteLine("-----------------------------------------\n"); - // sw.WriteLine("url.txt"); - // sw.WriteLine("此文件为NaiveGUI(windows)复制粘贴导入节点的网址"); - // sw.WriteLine("NaiveGUI(windows)下载网址:https://github.com/ExcitedCodes/NaiveGUI/releases"); - - // sw.WriteLine("-----------------------------------------\n"); - // sw.WriteLine("服务器通用连接配置参数"); - // sw.WriteLine($"地址(address):{ReceiveConfigurationParameters[4]}"); - // sw.WriteLine($"用户名:{ReceiveConfigurationParameters[5]}"); - // sw.WriteLine($"密钥:{ReceiveConfigurationParameters[6]}"); - // } - // //移动Naive官方配置config.json到与上述文件同一目录 - // File.Move(@"3in1_config\naive_config\config.json", @"3in1_config\naive_config\" + saveFileFolder + @"\config.json"); - - // client.Disconnect(); - - // currentStatus = "生成客户端配置,OK! 安装成功!"; - // textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); - // Thread.Sleep(1000); - - // //显示服务端连接参数 - // MessageBox.Show("安装成功,所有相关配置参数与二维码,url都已保存在相应目录下,点击“确定”后打开"); - // string openFolderPath = @"3in1_config\"; - // System.Diagnostics.Process.Start("explorer.exe", openFolderPath); - - // return; - // } - // } - // catch (Exception ex1)//例外处理 - // #region 例外处理 - // { - // //MessageBox.Show(ex1.Message); - // if (ex1.Message.Contains("连接尝试失败") == true) - // { - // MessageBox.Show($"{ex1.Message}\n请检查主机地址及端口是否正确,如果通过代理,请检查代理是否正常工作"); - // } - - // else if (ex1.Message.Contains("denied (password)") == true) - // { - // MessageBox.Show($"{ex1.Message}\n密码错误或用户名错误"); - // } - // else if (ex1.Message.Contains("Invalid private key file") == true) - // { - // MessageBox.Show($"{ex1.Message}\n所选密钥文件错误或者格式不对"); - // } - // else if (ex1.Message.Contains("denied (publickey)") == true) - // { - // MessageBox.Show($"{ex1.Message}\n使用密钥登录,密钥文件错误或用户名错误"); - // } - // else if (ex1.Message.Contains("目标计算机积极拒绝") == true) - // { - // MessageBox.Show($"{ex1.Message}\n主机地址错误,如果使用了代理,也可能是连接代理的端口错误"); - // } - // else - // { - // MessageBox.Show("发生错误"); - // MessageBox.Show(ex1.Message); - // } - // currentStatus = "主机登录失败"; - // textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); - - // } - // #endregion - - // } - - #endregion #region 测试用代码 @@ -7556,13 +7257,12 @@ namespace ProxySU } - + sshShellCommand = $"{sshCmdUpdate}"; + currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); + //在相应系统内安装curl(如果没有安装curl)--此为依赖软件 if (string.IsNullOrEmpty(client.RunCommand("command -v curl").Result) == true) { - sshShellCommand = $"{sshCmdUpdate}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - sshShellCommand = $"{sshCmdInstall}curl"; currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); @@ -7570,9 +7270,6 @@ namespace ProxySU // 在相应系统内安装wget(如果没有安装wget)--此为依赖软件 if (string.IsNullOrEmpty(client.RunCommand("command -v wget").Result) == true) { - sshShellCommand = $"{sshCmdUpdate}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - sshShellCommand = $"{sshCmdInstall}wget"; currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); @@ -7580,9 +7277,6 @@ namespace ProxySU // 在相应系统内安装unzip(如果没有安装unzip)--此为依赖软件 if (string.IsNullOrEmpty(client.RunCommand("command -v unzip").Result) == true) { - sshShellCommand = $"{sshCmdUpdate}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - sshShellCommand = $"{sshCmdInstall}unzip"; currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); @@ -7590,9 +7284,6 @@ namespace ProxySU //处理极其少见的xz-utils未安装的情况 if (string.IsNullOrEmpty(client.RunCommand("command -v xz-utils").Result) == true) { - sshShellCommand = $"{sshCmdUpdate}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - sshShellCommand = $"{sshCmdInstall}xz-utils"; currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); @@ -7600,9 +7291,6 @@ namespace ProxySU //检测是否安装lsof if (string.IsNullOrEmpty(client.RunCommand("command -v lsof").Result) == true) { - sshShellCommand = $"{sshCmdUpdate}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - sshShellCommand = $"{sshCmdInstall}lsof"; currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); @@ -8374,674 +8062,7 @@ namespace ProxySU #endregion - #region 启用Root密码登录 - private void ButtonEnableRootPassWord_Click(object sender, RoutedEventArgs e) - { - //******"本功能需要当前登录的账户具有sudo权限,是否为远程主机启用root账户并设置密码?"****** - string messageShow = Application.Current.FindResource("MessageBoxShow_EnableRootPassword").ToString(); - MessageBoxResult messageBoxResult = MessageBox.Show(messageShow, "", MessageBoxButton.YesNo, MessageBoxImage.Question); - if (messageBoxResult == MessageBoxResult.Yes) - { - ConnectionInfo connectionInfo = GenerateConnectionInfo(); - if (connectionInfo == null) - { - //****** "远程主机连接信息有误,请检查!" ****** - MessageBox.Show(Application.Current.FindResource("MessageBoxShow_ErrorHostConnection").ToString()); - return; - } - ReceiveConfigurationParameters[4] = TextBoxHost.Text;//传递主机地址 - ReceiveConfigurationParameters[2] = PasswordBoxHostPassword.Password;//传递当前账户密码 - - installationDegree = 0; - TextBoxMonitorCommandResults.Text = ""; - Thread thread = new Thread(() => EnableRootPassWord(connectionInfo)); - thread.SetApartmentState(ApartmentState.STA); - thread.Start(); - } - } - //启用Root密码登录进程 - private void EnableRootPassWord(ConnectionInfo connectionInfo) - { - functionResult = true; - getApt = false; - getDnf = false; - getYum = false; - onlyIpv6 = false; - - //******"正在登录远程主机......"****** - SetUpProgressBarProcessing(1); - string currentStatus = Application.Current.FindResource("DisplayInstallInfo_Login").ToString(); - MainWindowsShowInfo(currentStatus); - - try - { - #region 主机指纹,暂未启用 - //byte[] expectedFingerPrint = new byte[] { - // 0x66, 0x31, 0xaf, 0x00, 0x54, 0xb9, 0x87, 0x31, - // 0xff, 0x58, 0x1c, 0x31, 0xb1, 0xa2, 0x4c, 0x6b - // }; - #endregion - using (var client = new SshClient(connectionInfo)) - - { - #region ssh登录验证主机指纹代码块,暂未启用 - // client.HostKeyReceived += (sender, e) => - // { - // if (expectedFingerPrint.Length == e.FingerPrint.Length) - // { - // for (var i = 0; i < expectedFingerPrint.Length; i++) - // { - // if (expectedFingerPrint[i] != e.FingerPrint[i]) - // { - // e.CanTrust = false; - // break; - // } - // } - // } - // else - // { - // e.CanTrust = false; - // } - // }; - #endregion - - client.Connect(); - if (client.IsConnected == true) - { - //******"主机登录成功"****** - SetUpProgressBarProcessing(5); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_LoginSuccessful").ToString(); - MainWindowsShowInfo(currentStatus); - } - - //检测root权限 5--7 - //******"检测是否运行在root权限下..."******01 - SetUpProgressBarProcessing(5); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_DetectionRootPermission").ToString(); - MainWindowsShowInfo(currentStatus); - - sshShellCommand = @"id -u"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - if (currentShellCommandResult.TrimEnd('\r','\n').Equals("0") == true) - { - //******"当前账户已经具有root权限,无需再设置!"****** - currentStatus = Application.Current.FindResource("MessageBoxShow_AlreadyRoot").ToString(); - MainWindowsShowInfo(currentStatus); - MessageBox.Show(currentStatus); - client.Disconnect(); - return; - } - - SetUpProgressBarProcessing(10); - string hostPassword = "'" + ReceiveConfigurationParameters[2] + "'"; - //MessageBox.Show(hostPassword); - sshShellCommand = $"echo {hostPassword} | sudo -S id -u"; - //MessageBox.Show(sshShellCommand); - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - if (currentShellCommandResult.TrimEnd('\r', '\n').Equals("0") == false) - { - //******"当前账户无法获取sudo权限,设置失败!"****** - currentStatus = Application.Current.FindResource("MessageBoxShow_NoSudoToAccount").ToString(); - MainWindowsShowInfo(currentStatus); - MessageBox.Show(currentStatus); - client.Disconnect(); - return; - } - - SetUpProgressBarProcessing(20); - string cmdPre = $"echo {hostPassword} | sudo -S id -u" + ';'; - sshShellCommand = cmdPre + @"sudo sed -i 's/PermitRootLogin /#PermitRootLogin /g' /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = cmdPre + @"sudo sed -i 's/PasswordAuthentication /#PasswordAuthentication /g' /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - SetUpProgressBarProcessing(30); - sshShellCommand = cmdPre + @"sudo sed -i 's/PermitEmptyPasswords /#PermitEmptyPasswords /g' /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = cmdPre + @"echo 'PermitRootLogin yes' | sudo tee -a /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - SetUpProgressBarProcessing(40); - sshShellCommand = cmdPre + @"echo 'PasswordAuthentication yes' | sudo tee -a /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = cmdPre + @"echo 'PermitEmptyPasswords no' | sudo tee -a /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - SetUpProgressBarProcessing(60); - sshShellCommand = cmdPre + @"sudo systemctl restart sshd"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //******"生成20位随机密码!"****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_GenerateRandomPassword").ToString(); - MainWindowsShowInfo(currentStatus); - - sshShellCommand = @"cat /dev/urandom | tr -dc '_A-Z#\-+=a-z(0-9%^>)]{<|' | head -c 20 ; echo ''"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - SetUpProgressBarProcessing(80); - string setPassword = currentShellCommandResult.TrimEnd('\r', '\n') + '\n'; - - sshShellCommand = cmdPre + $"echo -e \"{setPassword}{setPassword}\" | sudo passwd root"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - client.Disconnect(); - - //***保存密码信息*** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_EnableRootPasswordSavePasswordInfo").ToString(); - MainWindowsShowInfo(currentStatus); - - string filePath = ReceiveConfigurationParameters[4].Replace(':', '_'); - CheckDir(filePath); - using (StreamWriter sw = new StreamWriter($"{filePath}\\host_password_info.txt")) - { - sw.WriteLine(ReceiveConfigurationParameters[4]); - sw.WriteLine("root"); - sw.WriteLine(setPassword); - } - - SetUpProgressBarProcessing(100); - //***远程主机Root账户密码登录已启用,密码保存在随后打开的文件夹中!*** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_EnableRootPasswordSuccess").ToString(); - MainWindowsShowInfo(currentStatus); - MessageBox.Show(currentStatus); - System.Diagnostics.Process.Start("explorer.exe", filePath); - return; - } - } - catch (Exception ex1)//例外处理 - #region 例外处理 - { - ProcessException(ex1.Message); - - //****** "主机登录失败!" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_LoginFailed").ToString(); - MainWindowsShowInfo(currentStatus); - } - #endregion - - } - - #endregion - - #region 启用Root证书密钥登录 - private void ButtonEnableRootCert_Click(object sender, RoutedEventArgs e) - { - //******"本功能需要当前登录的账户具有root或者sudo权限,是否为远程主机启用root证书密钥登录?"****** - string messageShow = Application.Current.FindResource("MessageBoxShow_ButtonEnableRootCert").ToString(); - MessageBoxResult messageBoxResult = MessageBox.Show(messageShow, "", MessageBoxButton.YesNo, MessageBoxImage.Question); - if (messageBoxResult == MessageBoxResult.Yes) - { - ConnectionInfo connectionInfo = GenerateConnectionInfo(); - if (connectionInfo == null) - { - //****** "远程主机连接信息有误,请检查!" ****** - MessageBox.Show(Application.Current.FindResource("MessageBoxShow_ErrorHostConnection").ToString()); - return; - } - - ReceiveConfigurationParameters[4] = TextBoxHost.Text;//传递主机地址 - ReceiveConfigurationParameters[2] = PasswordBoxHostPassword.Password; - - installationDegree = 0; - TextBoxMonitorCommandResults.Text = ""; - Thread thread = new Thread(() => EnableRootCert(connectionInfo)); - thread.SetApartmentState(ApartmentState.STA); - thread.Start(); - } - } - - //启用Root证书密钥登录进程 - private void EnableRootCert(ConnectionInfo connectionInfo) - { - functionResult = true; - getApt = false; - getDnf = false; - getYum = false; - onlyIpv6 = false; - - string filePath = String.Empty; - - //******"正在登录远程主机......"****** - SetUpProgressBarProcessing(1); - string currentStatus = Application.Current.FindResource("DisplayInstallInfo_Login").ToString(); - MainWindowsShowInfo(currentStatus); - - try - { - #region 主机指纹,暂未启用 - //byte[] expectedFingerPrint = new byte[] { - // 0x66, 0x31, 0xaf, 0x00, 0x54, 0xb9, 0x87, 0x31, - // 0xff, 0x58, 0x1c, 0x31, 0xb1, 0xa2, 0x4c, 0x6b - // }; - #endregion - using (var client = new SshClient(connectionInfo)) - - { - #region ssh登录验证主机指纹代码块,暂未启用 - // client.HostKeyReceived += (sender, e) => - // { - // if (expectedFingerPrint.Length == e.FingerPrint.Length) - // { - // for (var i = 0; i < expectedFingerPrint.Length; i++) - // { - // if (expectedFingerPrint[i] != e.FingerPrint[i]) - // { - // e.CanTrust = false; - // break; - // } - // } - // } - // else - // { - // e.CanTrust = false; - // } - // }; - #endregion - - client.Connect(); - if (client.IsConnected == true) - { - //******"主机登录成功"****** - SetUpProgressBarProcessing(5); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_LoginSuccessful").ToString(); - MainWindowsShowInfo(currentStatus); - } - - //检测root权限 5--7 - //******"检测是否运行在root权限下..."******01 - SetUpProgressBarProcessing(5); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_DetectionRootPermission").ToString(); - MainWindowsShowInfo(currentStatus); - - sshShellCommand = @"id -u"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - if (currentShellCommandResult.TrimEnd('\r', '\n').Equals("0") == true) - { - SetUpProgressBarProcessing(20); - - //***正在生成密钥......*** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_EnableRootCertGenerateCert").ToString(); - MainWindowsShowInfo(currentStatus); - - sshShellCommand = @"rm -rf /tmp/rootuser.key /tmp/rootuser.key.pub"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"yes | ssh-keygen -b 2048 -t rsa -f /tmp/rootuser.key -q -N ''"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"yes | ssh-keygen -p -P '' -N '' -m PEM -f /tmp/rootuser.key"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"mkdir -p /root/.ssh"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"cat /tmp/rootuser.key.pub | tee -a /root/.ssh/authorized_keys"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"chmod 777 /tmp/rootuser.key"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - SetUpProgressBarProcessing(30); - //***正在下载密钥......*** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_EnableRootCertDownloadCert").ToString(); - MainWindowsShowInfo(currentStatus); - - filePath = CreateConfigSaveDir(@"root_cert", ReceiveConfigurationParameters[4].Replace(':', '_')); - string localConfigSavePathAndFileName = $"{filePath}\\rootuser.key"; - string remoteConfigPathAndFileName = @"/tmp/rootuser.key"; - DownloadConfig(connectionInfo, localConfigSavePathAndFileName, remoteConfigPathAndFileName); - - localConfigSavePathAndFileName = $"{filePath}\\rootuser.key.pub"; - remoteConfigPathAndFileName = @"/tmp/rootuser.key.pub"; - DownloadConfig(connectionInfo, localConfigSavePathAndFileName, remoteConfigPathAndFileName); - - sshShellCommand = @"rm -rf /tmp/rootuser.key /tmp/rootuser.key.pub"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - SetUpProgressBarProcessing(50); - //***远程主机启用密钥登录......*** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_EnableRootCertSetCertEnable").ToString(); - MainWindowsShowInfo(currentStatus); - - sshShellCommand = @"sed -i 's/PermitRootLogin /#PermitRootLogin /g' /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"sed -i 's/StrictModes /#StrictModes /g' /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - SetUpProgressBarProcessing(70); - sshShellCommand = @"sed -i 's/PubkeyAuthentication /#PubkeyAuthentication /g' /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"sed -i 's/#AuthorizedKeysFile /AuthorizedKeysFile /g' /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - SetUpProgressBarProcessing(80); - sshShellCommand = @"sed -i 's/#RSAAuthentication /RSAAuthentication /g' /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"echo 'PermitRootLogin yes' | tee -a /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - SetUpProgressBarProcessing(90); - sshShellCommand = @"echo 'StrictModes no' | tee -a /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"echo 'PubkeyAuthentication yes' | tee -a /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"systemctl restart sshd"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - } - else - { - SetUpProgressBarProcessing(10); - string hostPassword = "'" + ReceiveConfigurationParameters[2] + "'"; - //MessageBox.Show(hostPassword); - sshShellCommand = $"echo {hostPassword} | sudo -S id -u"; - //MessageBox.Show(sshShellCommand); - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - //MessageBox.Show(currentShellCommandResult); - if (currentShellCommandResult.TrimEnd('\r', '\n').Equals("0") == false) - { - //******"当前账户无法获取sudo权限,设置失败!"****** - currentStatus = Application.Current.FindResource("MessageBoxShow_NoSudoToAccount").ToString(); - MainWindowsShowInfo(currentStatus); - MessageBox.Show(currentStatus); - client.Disconnect(); - return; - } - - SetUpProgressBarProcessing(20); - string cmdPre = $"echo {hostPassword} | sudo -S id -u" + ';'; - //***正在生成密钥......*** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_EnableRootCertGenerateCert").ToString(); - MainWindowsShowInfo(currentStatus); - - sshShellCommand = cmdPre + @"sudo rm -rf /tmp/rootuser.key /tmp/rootuser.key.pub"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = cmdPre + @"yes | sudo ssh-keygen -b 2048 -t rsa -f /tmp/rootuser.key -q -N ''"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = cmdPre + @"yes | sudo ssh-keygen -p -P '' -N '' -m PEM -f /tmp/rootuser.key"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = cmdPre + @"sudo mkdir -p /root/.ssh"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = cmdPre + @"cat /tmp/rootuser.key.pub | sudo tee -a /root/.ssh/authorized_keys"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = cmdPre + @"sudo chmod 777 /tmp/rootuser.key"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - SetUpProgressBarProcessing(30); - //***正在下载密钥......*** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_EnableRootCertDownloadCert").ToString(); - MainWindowsShowInfo(currentStatus); - - filePath = CreateConfigSaveDir(@"root_cert", ReceiveConfigurationParameters[4].Replace(':', '_')); - string localConfigSavePathAndFileName = $"{filePath}\\rootuser.key"; - string remoteConfigPathAndFileName = @"/tmp/rootuser.key"; - DownloadConfig(connectionInfo, localConfigSavePathAndFileName, remoteConfigPathAndFileName); - - localConfigSavePathAndFileName = $"{filePath}\\rootuser.key.pub"; - remoteConfigPathAndFileName = @"/tmp/rootuser.key.pub"; - DownloadConfig(connectionInfo, localConfigSavePathAndFileName, remoteConfigPathAndFileName); - - sshShellCommand = cmdPre + @"sudo rm -rf /tmp/rootuser.key /tmp/rootuser.key.pub"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - SetUpProgressBarProcessing(50); - //***远程主机启用密钥登录......*** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_EnableRootCertSetCertEnable").ToString(); - MainWindowsShowInfo(currentStatus); - - //string cmdPre = $"echo {hostPassword} | sudo -S id -u" + ';'; - sshShellCommand = cmdPre + @"sudo sed -i 's/PermitRootLogin /#PermitRootLogin /g' /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = cmdPre + @"sudo sed -i 's/StrictModes /#StrictModes /g' /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - SetUpProgressBarProcessing(70); - sshShellCommand = cmdPre + @"sudo sed -i 's/PubkeyAuthentication /#PubkeyAuthentication /g' /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = cmdPre + @"sudo sed -i 's/#AuthorizedKeysFile /AuthorizedKeysFile /g' /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - SetUpProgressBarProcessing(80); - sshShellCommand = cmdPre + @"sudo sed -i 's/#RSAAuthentication /RSAAuthentication /g' /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = cmdPre + @"echo 'PermitRootLogin yes' | sudo tee -a /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - SetUpProgressBarProcessing(90); - sshShellCommand = cmdPre + @"echo 'StrictModes no' | sudo tee -a /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = cmdPre + @"echo 'PubkeyAuthentication yes' | sudo tee -a /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = cmdPre + @"sudo systemctl restart sshd"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - } - client.Disconnect(); - - SetUpProgressBarProcessing(100); - //******"远程主机root账户证书密钥登录已启用,密钥文件rootuser.key保存在随后打开的文件夹中!"****** - currentStatus = Application.Current.FindResource("MessageBoxShow_ButtonEnableRootCertSuccess").ToString(); - MainWindowsShowInfo(currentStatus); - MessageBox.Show(currentStatus); - System.Diagnostics.Process.Start("explorer.exe", filePath); - - return; - } - } - catch (Exception ex1)//例外处理 - #region 例外处理 - { - ProcessException(ex1.Message); - - //****** "主机登录失败!" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_LoginFailed").ToString(); - MainWindowsShowInfo(currentStatus); - } - #endregion - - } - - - #endregion - - //root禁止密码登录 - private void ButtonRootProhibitsPasswordLogin_Click(object sender, RoutedEventArgs e) - { - //******"本功能需要远程主机已经开启了其他登录方式,如密钥方式等,否则将可能造成远程主机无法连接,是否禁止远程主机的root账户密码登录方式?"****** - string messageShow = Application.Current.FindResource("MessageBoxShow_ButtonRootProhibitsPasswordLogin").ToString(); - MessageBoxResult messageBoxResult = MessageBox.Show(messageShow, "", MessageBoxButton.YesNo, MessageBoxImage.Question); - if (messageBoxResult == MessageBoxResult.Yes) - { - ConnectionInfo connectionInfo = GenerateConnectionInfo(); - if (connectionInfo == null) - { - //****** "远程主机连接信息有误,请检查!" ****** - MessageBox.Show(Application.Current.FindResource("MessageBoxShow_ErrorHostConnection").ToString()); - return; - } - - ReceiveConfigurationParameters[4] = TextBoxHost.Text;//传递主机地址 - ReceiveConfigurationParameters[2] = PasswordBoxHostPassword.Password;//传递主机密码 - - installationDegree = 0; - TextBoxMonitorCommandResults.Text = ""; - Thread thread = new Thread(() => RootProhibitsPasswordLogin(connectionInfo)); - thread.SetApartmentState(ApartmentState.STA); - thread.Start(); - } - } - - //禁止root密码登录进程 - private void RootProhibitsPasswordLogin(ConnectionInfo connectionInfo) - { - functionResult = true; - getApt = false; - getDnf = false; - getYum = false; - onlyIpv6 = false; - - string filePath = String.Empty; - - //******"正在登录远程主机......"****** - SetUpProgressBarProcessing(1); - string currentStatus = Application.Current.FindResource("DisplayInstallInfo_Login").ToString(); - MainWindowsShowInfo(currentStatus); - - try - { - #region 主机指纹,暂未启用 - //byte[] expectedFingerPrint = new byte[] { - // 0x66, 0x31, 0xaf, 0x00, 0x54, 0xb9, 0x87, 0x31, - // 0xff, 0x58, 0x1c, 0x31, 0xb1, 0xa2, 0x4c, 0x6b - // }; - #endregion - using (var client = new SshClient(connectionInfo)) - - { - #region ssh登录验证主机指纹代码块,暂未启用 - // client.HostKeyReceived += (sender, e) => - // { - // if (expectedFingerPrint.Length == e.FingerPrint.Length) - // { - // for (var i = 0; i < expectedFingerPrint.Length; i++) - // { - // if (expectedFingerPrint[i] != e.FingerPrint[i]) - // { - // e.CanTrust = false; - // break; - // } - // } - // } - // else - // { - // e.CanTrust = false; - // } - // }; - #endregion - - client.Connect(); - if (client.IsConnected == true) - { - //******"主机登录成功"****** - SetUpProgressBarProcessing(5); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_LoginSuccessful").ToString(); - MainWindowsShowInfo(currentStatus); - } - - //检测root权限 5--7 - //******"检测是否运行在root权限下..."******01 - SetUpProgressBarProcessing(5); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_DetectionRootPermission").ToString(); - MainWindowsShowInfo(currentStatus); - - sshShellCommand = @"id -u"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - if (currentShellCommandResult.TrimEnd('\r', '\n').Equals("0") == true) - { - SetUpProgressBarProcessing(20); - - //***正在关闭root账户密码登录方式......*** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_SetRootProhibitsPasswordLogin").ToString(); - MainWindowsShowInfo(currentStatus); - - sshShellCommand = @"sed -i 's/PasswordAuthentication /#PasswordAuthentication /g' /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"sed -i 's/PermitEmptyPasswords /#PermitEmptyPasswords /g' /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"echo 'PasswordAuthentication no' | tee -a /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"echo 'PermitEmptyPasswords no' | tee -a /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"systemctl restart sshd"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - } - else - { - SetUpProgressBarProcessing(10); - string hostPassword = "'" + ReceiveConfigurationParameters[2] + "'"; - //MessageBox.Show(hostPassword); - sshShellCommand = $"echo {hostPassword} | sudo -S id -u"; - //MessageBox.Show(sshShellCommand); - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - //MessageBox.Show(currentShellCommandResult); - if (currentShellCommandResult.TrimEnd('\r', '\n').Equals("0") == false) - { - //******"当前账户无法获取sudo权限,设置失败!"****** - currentStatus = Application.Current.FindResource("MessageBoxShow_NoSudoToAccount").ToString(); - MainWindowsShowInfo(currentStatus); - MessageBox.Show(currentStatus); - client.Disconnect(); - return; - } - - SetUpProgressBarProcessing(20); - string cmdPre = $"echo {hostPassword} | sudo -S id -u" + ';'; - - //***正在关闭root账户密码登录方式......*** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_SetRootProhibitsPasswordLogin").ToString(); - MainWindowsShowInfo(currentStatus); - - sshShellCommand = cmdPre + @"sudo sed -i 's/PasswordAuthentication /#PasswordAuthentication /g' /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = cmdPre + @"sudo sed -i 's/PermitEmptyPasswords /#PermitEmptyPasswords /g' /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = cmdPre + @"echo 'PasswordAuthentication no' | sudo tee -a /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = cmdPre + @"echo 'PermitEmptyPasswords no' | sudo tee -a /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = cmdPre + @"sudo systemctl restart sshd"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - } - client.Disconnect(); - - SetUpProgressBarProcessing(100); - //******"远程主机root账户密码登录方式已关闭!"****** - currentStatus = Application.Current.FindResource("MessageBoxShow_RootProhibitsPasswordLoginOK").ToString(); - MainWindowsShowInfo(currentStatus); - MessageBox.Show(currentStatus); - - return; - } - } - catch (Exception ex1)//例外处理 - #region 例外处理 - { - ProcessException(ex1.Message); - - //****** "主机登录失败!" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_LoginFailed").ToString(); - MainWindowsShowInfo(currentStatus); - } - #endregion - } } } diff --git a/ProxySU/Properties/AssemblyInfo.cs b/ProxySU/Properties/AssemblyInfo.cs index 0234378..ff2c8c5 100644 --- a/ProxySU/Properties/AssemblyInfo.cs +++ b/ProxySU/Properties/AssemblyInfo.cs @@ -51,5 +51,5 @@ using System.Windows; // 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号 // 方法是按如下所示使用“*”: : // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.4.11.0")] -[assembly: AssemblyFileVersion("2.4.11.0")] +[assembly: AssemblyVersion("2.4.12.0")] +[assembly: AssemblyFileVersion("2.4.12.0")] diff --git a/ProxySU/ResultClientInformation.xaml.cs b/ProxySU/ResultClientInformation.xaml.cs index c80881a..5e9bf26 100644 --- a/ProxySU/ResultClientInformation.xaml.cs +++ b/ProxySU/ResultClientInformation.xaml.cs @@ -355,7 +355,7 @@ namespace ProxySU TextBlockTrojanGoWebSocketPath.Visibility = Visibility.Hidden; TextBlockTrojanGoCaption.Visibility = Visibility.Hidden; - //******"可用于ShadowRocket (ios)、igniter(Android)、Trojan-QT5 (windows) 扫码和导入url。注意:有的客户端可能不支持WebSocket模式。" ****** + //******"可用于ShadowRocket (ios)、igniter(Android)、Qv2ray (windows) 扫码和导入url。注意:有的客户端可能不支持WebSocket模式。" ****** TextBlockQrURLexplain.Text = Application.Current.FindResource("TextBlockQrURLexplainTrojan-go").ToString(); //主机地址 @@ -985,49 +985,50 @@ namespace ProxySU using (StreamWriter sw = new StreamWriter($"{configSavePath}\\readme.txt")) { - sw.WriteLine("config.json"); - //****** "此文件为v2ray官方程序所使用的客户端配置文件,配置为全局模式,socks5地址:127.0.0.1:1080,http代理地址:127.0.0.1:1081" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine01").ToString()); + ReadmeTxtWriteGenerate(sw); + //sw.WriteLine("config.json"); + ////****** "此文件为v2ray官方程序所使用的客户端配置文件,配置为全局模式,socks5地址:127.0.0.1:1080,http代理地址:127.0.0.1:1081" ****** + //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine01").ToString()); - //****** "v2ray官方网站:https://www.v2ray.com/" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine02").ToString()); + ////****** "v2ray官方网站:https://www.v2ray.com/" ****** + //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine02").ToString()); - //****** "v2ray官方程序下载地址:https://github.com/v2ray/v2ray-core/releases" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine03").ToString()); + ////****** "v2ray官方程序下载地址:https://github.com/v2ray/v2ray-core/releases" ****** + //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine03").ToString()); - //****** "下载相应版本,Windows选择v2ray-windows-64.zip或者v2ray-windows-32.zip,解压后提取v2ctl.exe和v2ray.exe。与config.json放在同一目录,运行v2ray.exe即可。" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine04").ToString()); + ////****** "下载相应版本,Windows选择v2ray-windows-64.zip或者v2ray-windows-32.zip,解压后提取v2ctl.exe和v2ray.exe。与config.json放在同一目录,运行v2ray.exe即可。" ****** + //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine04").ToString()); - sw.WriteLine("-----------------------------------------"); - sw.WriteLine("QR.bmp"); + //sw.WriteLine("-----------------------------------------"); + //sw.WriteLine("QR.bmp"); - //****** "此文件为v2rayN、Trojan-QT5、v2rayNG(Android)、Shadowrocket(ios)扫码导入节点" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine05").ToString()); + ////****** "此文件为v2rayN(windows)、Qv2ray(windows)、v2rayNG(Android)、Shadowrocket(ios)扫码导入节点" ****** + //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine05").ToString()); - //****** "v2rayN下载网址:https://github.com/2dust/v2rayN/releases" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine06").ToString()); + ////****** "v2rayN下载网址:https://github.com/2dust/v2rayN/releases" ****** + //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine06").ToString()); - //****** "Trojan-QT5:https://github.com/Trojan-Qt5/Trojan-Qt5" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine07").ToString()); + ////****** "Qv2ray下载网址:https://github.com/Qv2ray/Qv2ray/releases" ****** + //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine07").ToString()); - //****** "v2rayNG(Android)下载网址:https://github.com/2dust/v2rayNG/releases" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine08").ToString()); + ////****** "v2rayNG(Android)下载网址:https://github.com/2dust/v2rayNG/releases" ****** + //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine08").ToString()); - //****** "v2rayNG(Android)在Google Play下载网址:https://play.google.com/store/apps/details?id=com.v2ray.ang" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine09").ToString()); + ////****** "v2rayNG(Android)在Google Play下载网址:https://play.google.com/store/apps/details?id=com.v2ray.ang" ****** + //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine09").ToString()); - //****** "Shadowrocket(ios)下载,需要使用国外区的AppleID。请自行谷歌方法。" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine10").ToString()); + ////****** "Shadowrocket(ios)下载,需要使用国外区的AppleID。请自行谷歌方法。" ****** + //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine10").ToString()); - sw.WriteLine("-----------------------------------------"); - sw.WriteLine("url.txt"); + //sw.WriteLine("-----------------------------------------"); + //sw.WriteLine("url.txt"); - //****** "此文件为v2rayN、Trojan-QT5、v2rayNG(Android)、Shadowrocket(ios)复制粘贴导入节点的vmess网址" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine11").ToString()); + ////****** "此文件为v2rayN、Qv2ray、v2rayNG(Android)、Shadowrocket(ios)复制粘贴导入节点的vmess网址" ****** + //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine11").ToString()); - //写入通用配置参数 - TxtWriteGeneralParameters(sw); -} + ////写入通用配置参数 + //TxtWriteGeneralParameters(sw); + } } #region VLESS VMESS XTLS WS共存方案生成链接与说明文件 @@ -1140,13 +1141,13 @@ namespace ProxySU sw.WriteLine("-----------------------------------------"); //sw.WriteLine("QR.bmp"); - //****** "此文件为v2rayN、Trojan-QT5、v2rayNG(Android)、Shadowrocket(ios)扫码导入节点" ****** + //****** "此文件为v2rayN、Qv2ray、v2rayNG(Android)、Shadowrocket(ios)扫码导入节点" ****** //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine05").ToString()); //****** "v2rayN下载网址:https://github.com/2dust/v2rayN/releases" ****** //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine06").ToString()); - //****** "Trojan-QT5:https://github.com/Trojan-Qt5/Trojan-Qt5" ****** + //****** "Qv2ray:https://github.com/Qv2ray/Qv2ray/releases" ****** //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine07").ToString()); //****** "v2rayNG(Android)下载网址:https://github.com/2dust/v2rayNG/releases" ****** @@ -1161,7 +1162,7 @@ namespace ProxySU //sw.WriteLine("-----------------------------------------"); //sw.WriteLine("url.txt"); - //****** "此文件为v2rayN、Trojan-QT5、v2rayNG(Android)、Shadowrocket(ios)复制粘贴导入节点的vmess网址" ****** + //****** "此文件为v2rayN、Qv2ray、v2rayNG(Android)、Shadowrocket(ios)复制粘贴导入节点的vmess网址" ****** //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine11").ToString()); //写入通用配置参数 @@ -1278,13 +1279,13 @@ namespace ProxySU //sw.WriteLine("-----------------------------------------"); //sw.WriteLine("QR.bmp"); - //****** "此文件为v2rayN、Trojan-QT5、v2rayNG(Android)、Shadowrocket(ios)扫码导入节点" ****** + //****** "此文件为v2rayN、Qv2ray、v2rayNG(Android)、Shadowrocket(ios)扫码导入节点" ****** //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine05").ToString()); //****** "v2rayN下载网址:https://github.com/2dust/v2rayN/releases" ****** sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine06").ToString()); - //****** "Trojan-QT5:https://github.com/Trojan-Qt5/Trojan-Qt5" ****** + //****** "Qv2ray:https://github.com/Qv2ray/Qv2ray/releases" ****** sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine07").ToString()); //****** "v2rayNG(Android)下载网址:https://github.com/2dust/v2rayNG/releases" ****** @@ -1299,7 +1300,7 @@ namespace ProxySU //sw.WriteLine("-----------------------------------------"); //sw.WriteLine("url.txt"); - //****** "此文件为v2rayN、Trojan-QT5、v2rayNG(Android)、Shadowrocket(ios)复制粘贴导入节点的vmess网址" ****** + //****** "此文件为v2rayN、Qv2ray、v2rayNG(Android)、Shadowrocket(ios)复制粘贴导入节点的vmess网址" ****** //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine11").ToString()); //写入通用配置参数-- @@ -1417,13 +1418,13 @@ namespace ProxySU //sw.WriteLine("-----------------------------------------"); //sw.WriteLine("QR.bmp"); - //****** "此文件为v2rayN、Trojan-QT5、v2rayNG(Android)、Shadowrocket(ios)扫码导入节点" ****** + //****** "此文件为v2rayN、Qv2ray、v2rayNG(Android)、Shadowrocket(ios)扫码导入节点" ****** //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine05").ToString()); //****** "v2rayN下载网址:https://github.com/2dust/v2rayN/releases" ****** sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine06").ToString()); - //****** "Trojan-QT5:https://github.com/Trojan-Qt5/Trojan-Qt5" ****** + //****** "Qv2ray:https://github.com/Qv2ray/Qv2ray/releases" ****** sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine07").ToString()); //****** "v2rayNG(Android)下载网址:https://github.com/2dust/v2rayNG/releases" ****** @@ -1438,7 +1439,7 @@ namespace ProxySU //sw.WriteLine("-----------------------------------------"); //sw.WriteLine("url.txt"); - //****** "此文件为v2rayN、Trojan-QT5、v2rayNG(Android)、Shadowrocket(ios)复制粘贴导入节点的vmess网址" ****** + //****** "此文件为v2rayN、Qv2ray、v2rayNG(Android)、Shadowrocket(ios)复制粘贴导入节点的vmess网址" ****** //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine11").ToString()); //写入通用配置参数-- @@ -1556,13 +1557,13 @@ namespace ProxySU //sw.WriteLine("-----------------------------------------"); //sw.WriteLine("QR.bmp"); - //****** "此文件为v2rayN、Trojan-QT5、v2rayNG(Android)、Shadowrocket(ios)扫码导入节点" ****** + //****** "此文件为v2rayN、Qv2ray、v2rayNG(Android)、Shadowrocket(ios)扫码导入节点" ****** //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine05").ToString()); //****** "v2rayN下载网址:https://github.com/2dust/v2rayN/releases" ****** sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine06").ToString()); - //****** "Trojan-QT5:https://github.com/Trojan-Qt5/Trojan-Qt5" ****** + //****** "Qv2ray:https://github.com/Qv2ray/Qv2ray/releases" ****** sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine07").ToString()); //****** "v2rayNG(Android)下载网址:https://github.com/2dust/v2rayNG/releases" ****** @@ -1577,7 +1578,7 @@ namespace ProxySU //sw.WriteLine("-----------------------------------------"); //sw.WriteLine("url.txt"); - //****** "此文件为v2rayN、Trojan-QT5、v2rayNG(Android)、Shadowrocket(ios)复制粘贴导入节点的vmess网址" ****** + //****** "此文件为v2rayN、Qv2ray、v2rayNG(Android)、Shadowrocket(ios)复制粘贴导入节点的vmess网址" ****** //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine11").ToString()); //写入通用配置参数-- @@ -1664,49 +1665,50 @@ namespace ProxySU using (StreamWriter sw = new StreamWriter($"{configSavePath}\\readme.txt")) { - sw.WriteLine("config.json"); - //****** "此文件为v2ray官方程序所使用的客户端配置文件,配置为全局模式,socks5地址:127.0.0.1:1080,http代理地址:127.0.0.1:1081" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine01").ToString()); + ReadmeTxtWriteGenerate(sw); + //sw.WriteLine("config.json"); + ////****** "此文件为v2ray官方程序所使用的客户端配置文件,配置为全局模式,socks5地址:127.0.0.1:1080,http代理地址:127.0.0.1:1081" ****** + //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine01").ToString()); - //****** "v2ray官方网站:https://www.v2ray.com/" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine02").ToString()); + ////****** "v2ray官方网站:https://www.v2ray.com/" ****** + //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine02").ToString()); - //****** "v2ray官方程序下载地址:https://github.com/v2ray/v2ray-core/releases" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine03").ToString()); + ////****** "v2ray官方程序下载地址:https://github.com/v2ray/v2ray-core/releases" ****** + //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine03").ToString()); - //****** "下载相应版本,Windows选择v2ray-windows-64.zip或者v2ray-windows-32.zip,解压后提取v2ctl.exe和v2ray.exe。与config.json放在同一目录,运行v2ray.exe即可。" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine04").ToString()); + ////****** "下载相应版本,Windows选择v2ray-windows-64.zip或者v2ray-windows-32.zip,解压后提取v2ctl.exe和v2ray.exe。与config.json放在同一目录,运行v2ray.exe即可。" ****** + //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine04").ToString()); - sw.WriteLine("-----------------------------------------"); - sw.WriteLine("QR.bmp"); + //sw.WriteLine("-----------------------------------------"); + //sw.WriteLine("QR.bmp"); - //******"此文件为v2rayN、Trojan-QT5、v2rayNG(Android)、Shadowrocket(ios)扫码导入节点" * ***** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine05").ToString()); + ////******"此文件为v2rayN、Qv2ray、v2rayNG(Android)、Shadowrocket(ios)扫码导入节点" * ***** + //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine05").ToString()); - //****** "v2rayN下载网址:https://github.com/2dust/v2rayN/releases" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine06").ToString()); + ////****** "v2rayN下载网址:https://github.com/2dust/v2rayN/releases" ****** + //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine06").ToString()); - //****** "Trojan-QT5:https://github.com/Trojan-Qt5/Trojan-Qt5" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine07").ToString()); + ////****** "Qv2ray:https://github.com/Qv2ray/Qv2ray/releases" ****** + //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine07").ToString()); - //****** "v2rayNG(Android)下载网址:https://github.com/2dust/v2rayNG/releases" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine08").ToString()); + ////****** "v2rayNG(Android)下载网址:https://github.com/2dust/v2rayNG/releases" ****** + //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine08").ToString()); - //****** "v2rayNG(Android)在Google Play下载网址:https://play.google.com/store/apps/details?id=com.v2ray.ang" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine09").ToString()); + ////****** "v2rayNG(Android)在Google Play下载网址:https://play.google.com/store/apps/details?id=com.v2ray.ang" ****** + //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine09").ToString()); - //****** "Shadowrocket(ios)下载,需要使用国外区的AppleID。请自行谷歌方法。" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine10").ToString()); + ////****** "Shadowrocket(ios)下载,需要使用国外区的AppleID。请自行谷歌方法。" ****** + //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine10").ToString()); - sw.WriteLine("-----------------------------------------"); - sw.WriteLine("url.txt"); + //sw.WriteLine("-----------------------------------------"); + //sw.WriteLine("url.txt"); - //******"此文件为v2rayN、Trojan-QT5、v2rayNG(Android)、Shadowrocket(ios)复制粘贴导入节点的vmess网址" * ***** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine11").ToString()); + ////******"此文件为v2rayN、Qv2ray、v2rayNG(Android)、Shadowrocket(ios)复制粘贴导入节点的vmess网址" * ***** + //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine11").ToString()); + + ////写入通用配置参数-- + //TxtWriteGeneralParameters(sw); - //写入通用配置参数-- - TxtWriteGeneralParameters(sw); - } } @@ -1791,52 +1793,99 @@ namespace ProxySU using (StreamWriter sw = new StreamWriter($"{configSavePath}\\readme.txt")) { - sw.WriteLine("config.json"); - //****** "此文件为v2ray官方程序所使用的客户端配置文件,配置为全局模式,socks5地址:127.0.0.1:1080,http代理地址:127.0.0.1:1081" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine01").ToString()); + ReadmeTxtWriteGenerate(sw); + //sw.WriteLine("config.json"); + ////****** "此文件为v2ray官方程序所使用的客户端配置文件,配置为全局模式,socks5地址:127.0.0.1:1080,http代理地址:127.0.0.1:1081" ****** + //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine01").ToString()); - //****** "v2ray官方网站:https://www.v2ray.com/" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine02").ToString()); + ////****** "v2ray官方网站:https://www.v2ray.com/" ****** + //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine02").ToString()); - //****** "v2ray官方程序下载地址:https://github.com/v2ray/v2ray-core/releases" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine03").ToString()); + ////****** "v2ray官方程序下载地址:https://github.com/v2ray/v2ray-core/releases" ****** + //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine03").ToString()); - //****** "下载相应版本,Windows选择v2ray-windows-64.zip或者v2ray-windows-32.zip,解压后提取v2ctl.exe和v2ray.exe。与config.json放在同一目录,运行v2ray.exe即可。" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine04").ToString()); + ////****** "下载相应版本,Windows选择v2ray-windows-64.zip或者v2ray-windows-32.zip,解压后提取v2ctl.exe和v2ray.exe。与config.json放在同一目录,运行v2ray.exe即可。" ****** + //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine04").ToString()); - sw.WriteLine("-----------------------------------------"); - sw.WriteLine("QR.bmp"); + //sw.WriteLine("-----------------------------------------"); + //sw.WriteLine("QR.bmp"); - //****** "此文件为v2rayN、Trojan-QT5、v2rayNG(Android)、Shadowrocket(ios)扫码导入节点" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine05").ToString()); + ////****** "此文件为v2rayN、Qv2ray、v2rayNG(Android)、Shadowrocket(ios)扫码导入节点" ****** + //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine05").ToString()); - //****** "v2rayN下载网址:https://github.com/2dust/v2rayN/releases" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine06").ToString()); + ////****** "v2rayN下载网址:https://github.com/2dust/v2rayN/releases" ****** + //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine06").ToString()); - //****** "Trojan-QT5:https://github.com/Trojan-Qt5/Trojan-Qt5" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine07").ToString()); + ////****** "Qv2ray:https://github.com/Qv2ray/Qv2ray/releases" ****** + //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine07").ToString()); - //****** "v2rayNG(Android)下载网址:https://github.com/2dust/v2rayNG/releases" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine08").ToString()); + ////****** "v2rayNG(Android)下载网址:https://github.com/2dust/v2rayNG/releases" ****** + //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine08").ToString()); - //****** "v2rayNG(Android)在Google Play下载网址:https://play.google.com/store/apps/details?id=com.v2ray.ang" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine09").ToString()); + ////****** "v2rayNG(Android)在Google Play下载网址:https://play.google.com/store/apps/details?id=com.v2ray.ang" ****** + //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine09").ToString()); - //****** "Shadowrocket(ios)下载,需要使用国外区的AppleID。请自行谷歌方法。" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine10").ToString()); + ////****** "Shadowrocket(ios)下载,需要使用国外区的AppleID。请自行谷歌方法。" ****** + //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine10").ToString()); - sw.WriteLine("-----------------------------------------"); - sw.WriteLine("url.txt"); + //sw.WriteLine("-----------------------------------------"); + //sw.WriteLine("url.txt"); - //****** "此文件为v2rayN、Trojan-QT5、v2rayNG(Android)、Shadowrocket(ios)复制粘贴导入节点的vmess网址" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine11").ToString()); + ////****** "此文件为v2rayN、Qv2ray、v2rayNG(Android)、Shadowrocket(ios)复制粘贴导入节点的vmess网址" ****** + //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine11").ToString()); - //写入通用配置参数-- - TxtWriteGeneralParameters(sw); + ////写入通用配置参数-- + //TxtWriteGeneralParameters(sw); } } + //写入VMESS的readme.txt文件 + private void ReadmeTxtWriteGenerate(StreamWriter sw) + { + sw.WriteLine("config.json"); + //****** "此文件为v2ray官方程序所使用的客户端配置文件,配置为全局模式,socks5地址:127.0.0.1:1080,http代理地址:127.0.0.1:1081" ****** + sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine01").ToString()); + + //****** "v2ray官方网站:https://www.v2ray.com/" ****** + sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine02").ToString()); + + //****** "v2ray官方程序下载地址:https://github.com/v2ray/v2ray-core/releases" ****** + sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine03").ToString()); + + //****** "下载相应版本,Windows选择v2ray-windows-64.zip或者v2ray-windows-32.zip,解压后提取v2ctl.exe和v2ray.exe。与config.json放在同一目录,运行v2ray.exe即可。" ****** + sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine04").ToString()); + + sw.WriteLine("-----------------------------------------"); + sw.WriteLine("QR.bmp"); + + //****** "此文件为v2rayN(windows)、Qv2ray(windows)、v2rayNG(Android)、Shadowrocket(ios)扫码导入节点" ****** + sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine05").ToString()); + + //****** "v2rayN下载网址:https://github.com/2dust/v2rayN/releases" ****** + sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine06").ToString()); + + //****** "Qv2ray下载网址:https://github.com/Qv2ray/Qv2ray/releases" ****** + sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine07").ToString()); + + //****** "v2rayNG(Android)下载网址:https://github.com/2dust/v2rayNG/releases" ****** + sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine08").ToString()); + + //****** "v2rayNG(Android)在Google Play下载网址:https://play.google.com/store/apps/details?id=com.v2ray.ang" ****** + sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine09").ToString()); + + //****** "Shadowrocket(ios)下载,需要使用国外区的AppleID。请自行谷歌方法。" ****** + sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine10").ToString()); + + sw.WriteLine("-----------------------------------------"); + sw.WriteLine("url.txt"); + + //****** "此文件为v2rayN、Qv2ray、v2rayNG(Android)、Shadowrocket(ios)复制粘贴导入节点的vmess网址" ****** + sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine11").ToString()); + + //写入通用配置参数 + TxtWriteGeneralParameters(sw); + } //TXT文件中写入通用配置参数--- private void TxtWriteGeneralParameters(StreamWriter sw,bool alterId = true) { @@ -2146,10 +2195,10 @@ namespace ProxySU sw.WriteLine("-----------------------------------------\n"); sw.WriteLine("QR.bmp"); - //sw.WriteLine("此文件为Trojan-QT5 (windows)、igniter(Android)、Shadowrocket(ios)扫码导入节点"); + //sw.WriteLine("此文件为Qv2ray (windows)、igniter(Android)、Shadowrocket(ios)扫码导入节点"); sw.WriteLine(Application.Current.FindResource("readmeTxtTrojanExplainLine05").ToString()); - //sw.WriteLine("Trojan-QT5 (windows)下载网址:https://github.com/TheWanderingCoel/Trojan-Qt5/releases"); + //sw.WriteLine("Qv2ray (windows)下载网址:https://github.com/Qv2ray/Qv2ray/releases"); sw.WriteLine(Application.Current.FindResource("readmeTxtTrojanExplainLine06").ToString()); //sw.WriteLine("igniter(Android)下载网址:https://github.com/trojan-gfw/igniter/releases"); @@ -2160,7 +2209,7 @@ namespace ProxySU sw.WriteLine("-----------------------------------------\n"); sw.WriteLine("url.txt"); - //sw.WriteLine("此文件为Trojan-QT5 (windows)、igniter(Android)、Shadowrocket(ios)复制粘贴导入节点的网址"); + //sw.WriteLine("此文件为Qv2ray (windows)、igniter(Android)、Shadowrocket(ios)复制粘贴导入节点的网址"); sw.WriteLine(Application.Current.FindResource("readmeTxtTrojanExplainLine09").ToString()); sw.WriteLine("-----------------------------------------\n"); @@ -2222,26 +2271,15 @@ namespace ProxySU configDomainSavePath = CreateConfigSaveDir(proxyfolder, TextBoxNaiveServerHost.Text); string configSavePath = configDomainSavePath; - //string saveFileFolderFirst = TextBoxNaiveServerHost.Text; - //int num = 1; - //saveFileFolder = saveFileFolderFirst; - //CheckDir("naive_config"); - //while (Directory.Exists(@"naive_config\" + saveFileFolder)) - //{ - // saveFileFolder = saveFileFolderFirst + "_copy_" + num.ToString(); - // num++; - //} - //CheckDir(@"naive_config\" + saveFileFolder); - string naiveUrl = $"https://{TextBoxNaiveUser.Text}:{TextBoxNaivePassword.Text}@{TextBoxNaiveServerHost.Text}:443/?name={TextBoxNaiveServerHost.Text}&extra_headers="; - //MessageBox.Show(v2rayNjsonObject.ToString()); - //string trojanUrl = "trojan://" + ToBase64Encode(v2rayNjsonObject.ToString()); + string naiveUrl = $"naive+https://{TextBoxNaiveUser.Text}:{TextBoxNaivePassword.Text}@{TextBoxNaiveServerHost.Text}:443?padding=true#{TextBoxNaiveServerHost.Text}"; + TextBoxURL.Text = naiveUrl; using (StreamWriter sw = new StreamWriter($"{configSavePath}\\url.txt")) { sw.WriteLine(naiveUrl); } - //CreateQRCode(trojanUrl); + ImageShareQRcode.Source = CreateQRCode(naiveUrl, $"{configSavePath}\\QR.bmp"); //移动NaiveProxy官方程序配置文件到相应目录 if (File.Exists(@"naive_config\config.json")) @@ -2266,14 +2304,23 @@ namespace ProxySU //sw.WriteLine("下载相应版本,Windows选择naiveproxy-x.xx-win.zip,解压后提取naive.exe。与config.json放在同一目录,运行naive.exe即可。"); sw.WriteLine(Application.Current.FindResource("readmeTxtNaiveProxyExplainLine04").ToString()); + sw.WriteLine("-----------------------------------------"); + sw.WriteLine("QR.bmp"); + + //sw.WriteLine("此文件为NaiveSharp(windows)复制粘贴导入节点的网址"); + sw.WriteLine(Application.Current.FindResource("readmeTxtNaiveProxyExplainLine05").ToString()); + + //sw.WriteLine("NaiveSharp(windows)下载网址:https://github.com/KevinZonda/NaiveSharp/releases"); + sw.WriteLine(Application.Current.FindResource("readmeTxtNaiveProxyExplainLine06").ToString()); + sw.WriteLine("-----------------------------------------\n"); sw.WriteLine("url.txt"); - //sw.WriteLine("此文件为NaiveGUI(windows)复制粘贴导入节点的网址"); + //sw.WriteLine("此文件为NaiveSharp(windows)复制粘贴导入节点的网址"); sw.WriteLine(Application.Current.FindResource("readmeTxtNaiveProxyExplainLine05").ToString()); - //sw.WriteLine("NaiveGUI(windows)下载网址:https://github.com/ExcitedCodes/NaiveGUI/releases"); + //sw.WriteLine("NaiveSharp(windows)下载网址:https://github.com/KevinZonda/NaiveSharp/releases"); sw.WriteLine(Application.Current.FindResource("readmeTxtNaiveProxyExplainLine06").ToString()); sw.WriteLine("-----------------------------------------\n"); diff --git a/ProxySU/Translations/ProxySU.en-US.xaml b/ProxySU/Translations/ProxySU.en-US.xaml index 1c13f9b..ed2e2b5 100644 --- a/ProxySU/Translations/ProxySU.en-US.xaml +++ b/ProxySU/Translations/ProxySU.en-US.xaml @@ -231,10 +231,10 @@ default auto QR/URL The above parameters can be entered into the client manually or by scanning. The configuration and related files used for the official client have been stored in the directory. Click the OK button to open - QR code and URL link can be used v2rayN(windows) Trojan-QT5(windows) Qv2ray(windows) Shadowrocket(ios) v2rayNG(Android) Import v2ray node Note: The Vless protocol requires manual input of configuration parameters, and the QR code and URL are invalid - " can be used for ShadowRocket (ios), ignore (Android), Trojan-QT5 (windows) to scan codes and import URLs. Note: some clients may not support WebSocket mode ." - "Can be used for ShadowRocket (ios), ignore (Android), Trojan-QT5 (windows) to scan codes and import URLs. Note: Some clients may not support WebSocket mode." - URL import link for NaiveGUI (windows) + QR code and URL link can be used v2rayN(windows) Qv2ray(windows) Qv2ray(windows) Shadowrocket(ios) v2rayNG(Android) Import v2ray node Note: The Vless protocol requires manual input of configuration parameters, and the QR code and URL are invalid + " can be used for ShadowRocket (ios), ignore (Android), Qv2ray (windows) to scan codes and import URLs. Note: some clients may not support WebSocket mode ." + "Can be used for ShadowRocket (ios), ignore (Android), Qv2ray (windows) to scan codes and import URLs. Note: Some clients may not support WebSocket mode." + URL import link for NaiveSharp (windows) Used to scan codes and import URL import links for ShadowsocksR (windows), SSRR (android), Shadowrocket (ios) For mobile phone client shadowsocks(android), Shadowrocket(ios) scan code and URL import link For the computer client Shadowsocks (windows) scan code and URL import link @@ -382,13 +382,13 @@ v2ray official website: https://www.v2ray.com/ v2ray official program download address: https://github.com/v2ray/v2ray-core/releases download the corresponding version, Windows select v2ray-windows-64.zip or v2ray-windows-32.zip, extract v2ctl.exe and v2ray.exe after decompression. Put it in the same directory as config.json, just run v2ray.exe. - This file is v2rayN, Trojan-QT5, v2rayNG(Android), Shadowrocket(ios) scan code import node + This file is v2rayN, Qv2ray, v2rayNG(Android), Shadowrocket(ios) scan code import node v2rayN download URL: https://github.com/2dust/v2rayN/releases - Trojan-QT5: https://github.com/Trojan-Qt5/Trojan-Qt5 + Qv2ray download URL: https://github.com/Qv2ray/Qv2ray/releases v2rayNG(Android) download URL: https://github.com/2dust/v2rayNG/releases v2rayNG (Android) download URL on Google Play: https://play.google.com/store/apps/details?id=com.v2ray.ang Shadowrocket(ios) download, you need to use the AppleID of the foreign region. Please Google method yourself. - This file is v2rayN, Trojan-QT5, v2rayNG(Android), Shadowrocket(ios) copy and paste the vmess URL of the imported node + This file is v2rayN, Qv2ray, v2rayNG(Android), Shadowrocket(ios) copy and paste the vmess URL of the imported node Server general connection configuration parameters This file is the client configuration file used by the official Trojan-go program, configured in global mode, http and socks5 address: 127.0.0.1:1080 @@ -406,19 +406,19 @@ Trojan official website: https://trojan-gfw.github.io/trojan/ Trojan official program download address: https://github.com/trojan-gfw/trojan/releases Download the corresponding version, select Trojan-x.xx-win.zip for Windows, extract trojan.exe after decompression. Put it in the same directory as config.json, just run trojan.exe. - This file is Trojan-QT5 (windows), ignore (Android), Shadowrocket (ios) scan code import node - Trojan-QT5 (windows) download URL: https://github.com/TheWanderingCoel/Trojan-Qt5/releases + This file is Qv2ray (windows), ignore (Android), Shadowrocket (ios) scan code import node + Qv2ray (windows) download URL: https://github.com/Qv2ray/Qv2ray/releases igniter (Android) download URL: https://github.com/trojan-gfw/igniter/releases Shadowrocket(ios) download, you need to use the AppleID of the foreign region. Please Google method yourself. - This file is Trojan-QT5 (windows), ignore (Android), Shadowrocket (ios) copy and paste the URL of the imported node + This file is Qv2ray (windows), ignore (Android), Shadowrocket (ios) copy and paste the URL of the imported node Server general connection configuration parameters This file is the client configuration file used by the official NaiveProxy program, configured in global mode, socks5 address: 127.0.0.1:1080 NaiveProxy official website: https://github.com/klzgrad/naiveproxy NaiveProxy official program download address: https://github.com/klzgrad/naiveproxy/releases download the corresponding version, select naiveproxy-x.xx-win.zip for Windows, extract naive.exe after decompression. Put it in the same directory as config.json, just run naive.exe. - This file is NaiveGUI (windows) copy and paste the URL of the imported node - NaiveGUI(windows) download URL: https://github.com/ExcitedCodes/NaiveGUI/releases + This file is NaiveSharp (windows) copy and paste the URL of the imported node + NaiveSharp(windows) download URL: https://github.com/KevinZonda/NaiveSharp/releases Server general connection configuration parameters This file is for ShadowsocksR (windows), SSRR (Android), Shadowrocket (ios) scan code import node diff --git a/ProxySU/Translations/ProxySU.zh-CN.xaml b/ProxySU/Translations/ProxySU.zh-CN.xaml index 5a7acc8..4906ea7 100644 --- a/ProxySU/Translations/ProxySU.zh-CN.xaml +++ b/ProxySU/Translations/ProxySU.zh-CN.xaml @@ -235,10 +235,10 @@ 默认auto 二维码/URL 以上参数可以手动或扫描输入客户端,用于官方客户端的配置和相关文件已经存放入目录下,点击 确定 按扭可打开 - 二维码和URL链接可用于 v2rayN(windows) Trojan-QT5(windows) Qv2ray(windows) Shadowrocket(ios) v2rayNG(Android) 导入v2ray节点 注意:Vless协议需要手动输入配置参数,二维码和URL无效 - "可用于ShadowRocket (ios)、igniter(Android)、Trojan-QT5 (windows) 扫码和导入url。注意:有的客户端可能不支持WebSocket模式。" - "可用于ShadowRocket (ios)、igniter(Android)、Trojan-QT5 (windows) 扫码和导入url。注意:有的客户端可能不支持WebSocket模式。" - 用于NaiveGUI(windows)的URL导入链接 + 二维码和URL链接可用于 v2rayN(windows) Qv2ray(windows) Qv2ray(windows) Shadowrocket(ios) v2rayNG(Android) 导入v2ray节点 注意:Vless协议需要手动输入配置参数,二维码和URL无效 + "可用于ShadowRocket (ios)、igniter(Android)、Qv2ray (windows) 扫码和导入url。注意:有的客户端可能不支持WebSocket模式。" + "可用于ShadowRocket (ios)、igniter(Android)、Qv2ray (windows) 扫码和导入url。注意:有的客户端可能不支持WebSocket模式。" + 用于NaiveSharp(windows)的URL导入链接 用于ShadowsocksR(windows)、SSRR(android)、Shadowrocket(ios)的扫码和URL导入链接 用于手机客户端shadowsocks(android)、Shadowrocket(ios)的扫码和URL导入链接 用于电脑客户端Shadowsocks (windows)的扫码和URL导入链接 @@ -387,13 +387,13 @@ v2ray官方网站:https://www.v2ray.com/ v2ray官方程序下载地址:https://github.com/v2ray/v2ray-core/releases 下载相应版本,Windows选择v2ray-windows-64.zip或者v2ray-windows-32.zip,解压后提取v2ctl.exe和v2ray.exe。与config.json放在同一目录,运行v2ray.exe即可。 - 此文件为v2rayN、Trojan-QT5、v2rayNG(Android)、Shadowrocket(ios)扫码导入节点 + 此文件为v2rayN(windows)、Qv2ray(windows)、v2rayNG(Android)、Shadowrocket(ios)扫码导入节点 v2rayN下载网址:https://github.com/2dust/v2rayN/releases - Trojan-QT5:https://github.com/Trojan-Qt5/Trojan-Qt5 + Qv2ray下载网址:https://github.com/Qv2ray/Qv2ray/releases v2rayNG(Android)下载网址:https://github.com/2dust/v2rayNG/releases v2rayNG(Android)在Google Play下载网址:https://play.google.com/store/apps/details?id=com.v2ray.ang Shadowrocket(ios)下载,需要使用国外区的AppleID。请自行谷歌方法。 - 此文件为v2rayN、Trojan-QT5、v2rayNG(Android)、Shadowrocket(ios)复制粘贴导入节点的vmess网址 + 此文件为v2rayN、Qv2ray、v2rayNG(Android)、Shadowrocket(ios)复制粘贴导入节点的vmess网址 服务器通用连接配置参数: 此文件为Trojan-go官方程序所使用的客户端配置文件,配置为全局模式,http与socks5地址:127.0.0.1:1080 @@ -411,19 +411,19 @@ Trojan官方网站:https://trojan-gfw.github.io/trojan/ Trojan官方程序下载地址:https://github.com/trojan-gfw/trojan/releases 下载相应版本,Windows选择Trojan-x.xx-win.zip,解压后提取trojan.exe。与config.json放在同一目录,运行trojan.exe即可。 - 此文件为Trojan-QT5 (windows)、igniter(Android)、Shadowrocket(ios)扫码导入节点 - Trojan-QT5 (windows)下载网址:https://github.com/TheWanderingCoel/Trojan-Qt5/releases + 此文件为Qv2ray (windows)、igniter(Android)、Shadowrocket(ios)扫码导入节点 + Qv2ray (windows)下载网址:https://github.com/Qv2ray/Qv2ray/releases igniter(Android)下载网址:https://github.com/trojan-gfw/igniter/releases Shadowrocket(ios)下载,需要使用国外区的AppleID。请自行谷歌方法。 - 此文件为Trojan-QT5 (windows)、igniter(Android)、Shadowrocket(ios)复制粘贴导入节点的网址 + 此文件为Qv2ray (windows)、igniter(Android)、Shadowrocket(ios)复制粘贴导入节点的网址 服务器通用连接配置参数 此文件为NaiveProxy官方程序所使用的客户端配置文件,配置为全局模式,socks5地址:127.0.0.1:1080 NaiveProxy官方网站:https://github.com/klzgrad/naiveproxy NaiveProxy官方程序下载地址:https://github.com/klzgrad/naiveproxy/releases 下载相应版本,Windows选择naiveproxy-x.xx-win.zip,解压后提取naive.exe。与config.json放在同一目录,运行naive.exe即可。 - 此文件为NaiveGUI(windows)复制粘贴导入节点的网址 - NaiveGUI(windows)下载网址:https://github.com/ExcitedCodes/NaiveGUI/releases + 此文件为NaiveSharp(windows)复制粘贴导入节点的网址 + NaiveSharp(windows)下载网址:https://github.com/KevinZonda/NaiveSharp/releases 服务器通用连接配置参数 此文件为ShadowsocksR (windows)、SSRR(Android)、Shadowrocket(ios)扫码导入节点 diff --git a/ProxySU/Translations/ProxySU.zh-TW.xaml b/ProxySU/Translations/ProxySU.zh-TW.xaml index 697bd8e..d60a826 100644 --- a/ProxySU/Translations/ProxySU.zh-TW.xaml +++ b/ProxySU/Translations/ProxySU.zh-TW.xaml @@ -231,10 +231,10 @@ 默認auto 二維碼/URL 以上參數可以手動或掃描輸入客戶端,用於官方客戶端的配置和相關文件已經存放入目錄下,點擊 確定 按扭可打開 - 二維碼和URL鏈接可用於 v2rayN(windows) Trojan-QT5(windows) Qv2ray(windows) Shadowrocket(ios) v2rayNG(Android) 導入v2ray節點 注意:Vless協議需要手動輸入配置參數,二維碼和URL無效 - "可用於ShadowRocket (ios)、igniter(Android)、Trojan-QT5 (windows) 掃碼和導入url。注意:有的客戶端可能不支持WebSocket模式。" - "可用於ShadowRocket (ios)、igniter(Android)、Trojan-QT5 (windows) 掃碼和導入url。注意:有的客戶端可能不支持WebSocket模式。" - 用於NaiveGUI(windows)的URL導入鏈接 + 二維碼和URL鏈接可用於 v2rayN(windows) Qv2ray(windows) Qv2ray(windows) Shadowrocket(ios) v2rayNG(Android) 導入v2ray節點 注意:Vless協議需要手動輸入配置參數,二維碼和URL無效 + "可用於ShadowRocket (ios)、igniter(Android)、Qv2ray (windows) 掃碼和導入url。注意:有的客戶端可能不支持WebSocket模式。" + "可用於ShadowRocket (ios)、igniter(Android)、Qv2ray (windows) 掃碼和導入url。注意:有的客戶端可能不支持WebSocket模式。" + 用於NaiveSharp(windows)的URL導入鏈接 用於ShadowsocksR(windows)、SSRR(android)、Shadowrocket(ios)的掃碼和導入URL導入鏈接 用於手機客戶端shadowsocks(android)、Shadowrocket(ios)的掃碼和URL導入鏈接 用於電腦客戶端Shadowsocks (windows)的掃碼和URL導入鏈接 @@ -383,13 +383,13 @@ v2ray官方網站:https://www.v2ray.com/ v2ray官方程序下載地址:https://github.com/v2ray/v2ray-core/releases 下載相應版本,Windows選擇v2ray-windows-64.zip或者v2ray-windows-32.zip,解壓後提取v2ctl.exe和v2ray.exe。與config.json放在同一目錄,運行v2ray.exe即可。 - 此文件為v2rayN、Trojan-QT5、v2rayNG(Android)、Shadowrocket(ios)掃碼導入節點 + 此文件為v2rayN、Qv2ray、v2rayNG(Android)、Shadowrocket(ios)掃碼導入節點 v2rayN下載網址:https://github.com/2dust/v2rayN/releases - Trojan-QT5:https://github.com/Trojan-Qt5/Trojan-Qt5 + Qv2ray下載網址:https://github.com/Qv2ray/Qv2ray/releases v2rayNG(Android)下載網址:https://github.com/2dust/v2rayNG/releases v2rayNG(Android)在Google Play下載網址:https://play.google.com/store/apps/details?id=com.v2ray.ang Shadowrocket(ios)下載,需要使用國外區的AppleID。請自行谷歌方法。 - 此文件為v2rayN、Trojan-QT5、v2rayNG(Android)、Shadowrocket(ios)複製粘貼導入節點的vmess網址 + 此文件為v2rayN、Qv2ray、v2rayNG(Android)、Shadowrocket(ios)複製粘貼導入節點的vmess網址 服務器通用連接配置參數 此文件為Trojan-go官方程序所使用的客戶端配置文件,配置為全局模式,http與socks5地址:127.0.0.1:1080 @@ -407,19 +407,19 @@ Trojan官方網站:https://trojan-gfw.github.io/trojan/ Trojan官方程序下載地址:https://github.com/trojan-gfw/trojan/releases 下載相應版本,Windows選擇Trojan-x.xx-win.zip,解壓後提取trojan.exe。與config.json放在同一目錄,運行trojan.exe即可。 - 此文件為Trojan-QT5 (windows)、igniter(Android)、Shadowrocket(ios)掃碼導入節點 - Trojan-QT5 (windows)下載網址:https://github.com/TheWanderingCoel/Trojan-Qt5/releases + 此文件為Qv2ray (windows)、igniter(Android)、Shadowrocket(ios)掃碼導入節點 + Qv2ray (windows)下載網址:https://github.com/Qv2ray/Qv2ray/releases igniter(Android)下載網址:https://github.com/trojan-gfw/igniter/releases Shadowrocket(ios)下載,需要使用國外區的AppleID。請自行谷歌方法。 - 此文件為Trojan-QT5 (windows)、igniter(Android)、Shadowrocket(ios)複製粘貼導入節點的網址 + 此文件為Qv2ray (windows)、igniter(Android)、Shadowrocket(ios)複製粘貼導入節點的網址 服務器通用連接配置參數 此文件為NaiveProxy官方程序所使用的客戶端配置文件,配置為全局模式,socks5地址:127.0.0.1:1080 NaiveProxy官方網站:https://github.com/klzgrad/naiveproxy NaiveProxy官方程序下載地址:https://github.com/klzgrad/naiveproxy/releases 下載相應版本,Windows選擇naiveproxy-x.xx-win.zip,解壓後提取naive.exe。與config.json放在同一目錄,運行naive.exe即可。 - 此文件為NaiveGUI(windows)複製粘貼導入節點的網址 - NaiveGUI(windows)下載網址:https://github.com/ExcitedCodes/NaiveGUI/releases + 此文件為NaiveSharp(windows)複製粘貼導入節點的網址 + NaiveSharp(windows)下載網址:https://github.com/KevinZonda/NaiveSharp/releases 服務器通用連接配置參數 此文件為ShadowsocksR (windows)、SSRR(Android)、Shadowrocket(ios)掃碼導入節點 diff --git a/ProxySU/bin/Beta/Beta.zip b/ProxySU/bin/Beta/Beta.zip index d2b310b..362c784 100644 Binary files a/ProxySU/bin/Beta/Beta.zip and b/ProxySU/bin/Beta/Beta.zip differ diff --git a/TemplateConfg/naive/naive_server.caddyfile b/TemplateConfg/naive/naive_server.caddyfile new file mode 100644 index 0000000..f26a145 --- /dev/null +++ b/TemplateConfg/naive/naive_server.caddyfile @@ -0,0 +1,11 @@ +:443, ##domain## +route { + forward_proxy { + ##basicauth## + #basic_auth ##user## ##pass## + hide_ip + hide_via + probe_resistance + } + file_server { root /usr/share/caddy } +} \ No newline at end of file