diff --git a/ProxySuper.Core/App.cs b/ProxySuper.Core/App.cs
index 6c745f8..919fd05 100644
--- a/ProxySuper.Core/App.cs
+++ b/ProxySuper.Core/App.cs
@@ -1,10 +1,5 @@
using MvvmCross.ViewModels;
using ProxySuper.Core.ViewModels;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace ProxySuper.Core
{
diff --git a/ProxySuper.Core/Converters/LoginSecretTypeConverter.cs b/ProxySuper.Core/Converters/LoginSecretTypeConverter.cs
index 07b11e9..56cd875 100644
--- a/ProxySuper.Core/Converters/LoginSecretTypeConverter.cs
+++ b/ProxySuper.Core/Converters/LoginSecretTypeConverter.cs
@@ -1,11 +1,6 @@
-using MvvmCross.Converters;
-using ProxySuper.Core.Models.Hosts;
+using ProxySuper.Core.Models.Hosts;
using System;
-using System.Collections.Generic;
using System.Globalization;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
using System.Windows.Data;
namespace ProxySuper.Core.Converters
diff --git a/ProxySuper.Core/Converters/ProxyTypeConverter.cs b/ProxySuper.Core/Converters/ProxyTypeConverter.cs
index 4d36d15..560c5f1 100644
--- a/ProxySuper.Core/Converters/ProxyTypeConverter.cs
+++ b/ProxySuper.Core/Converters/ProxyTypeConverter.cs
@@ -1,9 +1,5 @@
using System;
-using System.Collections.Generic;
using System.Globalization;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
using System.Windows.Data;
namespace ProxySuper.Core.Converters
diff --git a/ProxySuper.Core/Converters/VisibleConverter.cs b/ProxySuper.Core/Converters/VisibleConverter.cs
index 70eeaa6..ffcdaba 100644
--- a/ProxySuper.Core/Converters/VisibleConverter.cs
+++ b/ProxySuper.Core/Converters/VisibleConverter.cs
@@ -1,9 +1,5 @@
using System;
-using System.Collections.Generic;
using System.Globalization;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
diff --git a/ProxySuper.Core/Helpers/DateTimeUtils.cs b/ProxySuper.Core/Helpers/DateTimeUtils.cs
index 9d1673e..4625b81 100644
--- a/ProxySuper.Core/Helpers/DateTimeUtils.cs
+++ b/ProxySuper.Core/Helpers/DateTimeUtils.cs
@@ -1,12 +1,8 @@
using System;
-using System.Collections.Generic;
using System.Globalization;
-using System.Linq;
using System.Net;
using System.Runtime.InteropServices;
-using System.Text;
-using System.Threading.Tasks;
namespace ProxySuper.Core.Helpers
{
diff --git a/ProxySuper.Core/Helpers/Utils.cs b/ProxySuper.Core/Helpers/Utils.cs
index bb68b88..76e41b1 100644
--- a/ProxySuper.Core/Helpers/Utils.cs
+++ b/ProxySuper.Core/Helpers/Utils.cs
@@ -1,11 +1,6 @@
using Newtonsoft.Json;
using System;
-using System.Collections.Generic;
-using System.IO;
using System.Linq;
-using System.Runtime.Serialization.Formatters.Binary;
-using System.Text;
-using System.Threading.Tasks;
namespace ProxySuper.Core.Services
{
diff --git a/ProxySuper.Core/Models/Hosts/Host.cs b/ProxySuper.Core/Models/Hosts/Host.cs
index 26a11a3..20baa6d 100644
--- a/ProxySuper.Core/Models/Hosts/Host.cs
+++ b/ProxySuper.Core/Models/Hosts/Host.cs
@@ -1,10 +1,6 @@
using Microsoft.Win32;
using MvvmCross.Commands;
-using System;
-using System.Collections.Generic;
using System.ComponentModel;
-using System.Linq;
-using System.Text;
using System.Threading.Tasks;
using System.Windows;
diff --git a/ProxySuper.Core/Models/Hosts/LocalProxy.cs b/ProxySuper.Core/Models/Hosts/LocalProxy.cs
index 38f300a..4078f29 100644
--- a/ProxySuper.Core/Models/Hosts/LocalProxy.cs
+++ b/ProxySuper.Core/Models/Hosts/LocalProxy.cs
@@ -1,10 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace ProxySuper.Core.Models.Hosts
+namespace ProxySuper.Core.Models.Hosts
{
public class LocalProxy
{
@@ -20,5 +14,5 @@ namespace ProxySuper.Core.Models.Hosts
}
-
+
}
diff --git a/ProxySuper.Core/Models/Hosts/LocalProxyType.cs b/ProxySuper.Core/Models/Hosts/LocalProxyType.cs
index 88c3d9d..e055d81 100644
--- a/ProxySuper.Core/Models/Hosts/LocalProxyType.cs
+++ b/ProxySuper.Core/Models/Hosts/LocalProxyType.cs
@@ -1,10 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace ProxySuper.Core.Models.Hosts
+namespace ProxySuper.Core.Models.Hosts
{
public enum LocalProxyType
{
diff --git a/ProxySuper.Core/Models/Hosts/LoginSecretType.cs b/ProxySuper.Core/Models/Hosts/LoginSecretType.cs
index 1791823..8ba540a 100644
--- a/ProxySuper.Core/Models/Hosts/LoginSecretType.cs
+++ b/ProxySuper.Core/Models/Hosts/LoginSecretType.cs
@@ -1,10 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace ProxySuper.Core.Models.Hosts
+namespace ProxySuper.Core.Models.Hosts
{
public enum LoginSecretType
{
diff --git a/ProxySuper.Core/Models/Projects/BrookSettings.cs b/ProxySuper.Core/Models/Projects/BrookSettings.cs
index 0de6c4d..7bf1adb 100644
--- a/ProxySuper.Core/Models/Projects/BrookSettings.cs
+++ b/ProxySuper.Core/Models/Projects/BrookSettings.cs
@@ -1,8 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using System.Collections.Generic;
namespace ProxySuper.Core.Models.Projects
{
diff --git a/ProxySuper.Core/Models/Projects/BrookType.cs b/ProxySuper.Core/Models/Projects/BrookType.cs
index 817d0ec..6f5fc1d 100644
--- a/ProxySuper.Core/Models/Projects/BrookType.cs
+++ b/ProxySuper.Core/Models/Projects/BrookType.cs
@@ -1,10 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace ProxySuper.Core.Models.Projects
+namespace ProxySuper.Core.Models.Projects
{
public enum BrookType
{
diff --git a/ProxySuper.Core/Models/Projects/IProjectSettings.cs b/ProxySuper.Core/Models/Projects/IProjectSettings.cs
index 4d5f085..1570c4e 100644
--- a/ProxySuper.Core/Models/Projects/IProjectSettings.cs
+++ b/ProxySuper.Core/Models/Projects/IProjectSettings.cs
@@ -1,8 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using System.Collections.Generic;
namespace ProxySuper.Core.Models.Projects
{
diff --git a/ProxySuper.Core/Models/Projects/NaiveProxySettings.cs b/ProxySuper.Core/Models/Projects/NaiveProxySettings.cs
index fab1a64..4c17338 100644
--- a/ProxySuper.Core/Models/Projects/NaiveProxySettings.cs
+++ b/ProxySuper.Core/Models/Projects/NaiveProxySettings.cs
@@ -1,9 +1,5 @@
using Newtonsoft.Json;
-using System;
using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace ProxySuper.Core.Models.Projects
{
diff --git a/ProxySuper.Core/Models/Projects/ProjectType.cs b/ProxySuper.Core/Models/Projects/ProjectType.cs
index fe5d8d6..7216689 100644
--- a/ProxySuper.Core/Models/Projects/ProjectType.cs
+++ b/ProxySuper.Core/Models/Projects/ProjectType.cs
@@ -1,10 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace ProxySuper.Core.Models.Projects
+namespace ProxySuper.Core.Models.Projects
{
public enum ProjectType
{
diff --git a/ProxySuper.Core/Models/Projects/TrojanGoSettings.cs b/ProxySuper.Core/Models/Projects/TrojanGoSettings.cs
index 79859f3..427dd86 100644
--- a/ProxySuper.Core/Models/Projects/TrojanGoSettings.cs
+++ b/ProxySuper.Core/Models/Projects/TrojanGoSettings.cs
@@ -1,10 +1,6 @@
using Newtonsoft.Json;
-using ProxySuper.Core.Services;
using System;
using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace ProxySuper.Core.Models.Projects
{
diff --git a/ProxySuper.Core/Models/Projects/XraySettings.cs b/ProxySuper.Core/Models/Projects/XraySettings.cs
index 1441094..a0a14eb 100644
--- a/ProxySuper.Core/Models/Projects/XraySettings.cs
+++ b/ProxySuper.Core/Models/Projects/XraySettings.cs
@@ -2,9 +2,6 @@
using ProxySuper.Core.Services;
using System;
using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace ProxySuper.Core.Models.Projects
{
diff --git a/ProxySuper.Core/Models/Projects/XraySettings_SS.cs b/ProxySuper.Core/Models/Projects/XraySettings_SS.cs
index debe70a..71936dd 100644
--- a/ProxySuper.Core/Models/Projects/XraySettings_SS.cs
+++ b/ProxySuper.Core/Models/Projects/XraySettings_SS.cs
@@ -1,9 +1,4 @@
using ProxySuper.Core.Services;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace ProxySuper.Core.Models.Projects
{
diff --git a/ProxySuper.Core/Models/Projects/XraySettings_Trojan.cs b/ProxySuper.Core/Models/Projects/XraySettings_Trojan.cs
index 301032e..6d110a7 100644
--- a/ProxySuper.Core/Models/Projects/XraySettings_Trojan.cs
+++ b/ProxySuper.Core/Models/Projects/XraySettings_Trojan.cs
@@ -1,9 +1,4 @@
using ProxySuper.Core.Services;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace ProxySuper.Core.Models.Projects
{
diff --git a/ProxySuper.Core/Models/Projects/XraySettings_VLESS.cs b/ProxySuper.Core/Models/Projects/XraySettings_VLESS.cs
index 63d8574..e2b959e 100644
--- a/ProxySuper.Core/Models/Projects/XraySettings_VLESS.cs
+++ b/ProxySuper.Core/Models/Projects/XraySettings_VLESS.cs
@@ -1,9 +1,4 @@
using ProxySuper.Core.Services;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace ProxySuper.Core.Models.Projects
{
diff --git a/ProxySuper.Core/Models/Projects/XraySettings_VMESS.cs b/ProxySuper.Core/Models/Projects/XraySettings_VMESS.cs
index b9c0664..61fce95 100644
--- a/ProxySuper.Core/Models/Projects/XraySettings_VMESS.cs
+++ b/ProxySuper.Core/Models/Projects/XraySettings_VMESS.cs
@@ -1,9 +1,4 @@
using ProxySuper.Core.Services;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace ProxySuper.Core.Models.Projects
{
diff --git a/ProxySuper.Core/Models/Projects/XrayType.cs b/ProxySuper.Core/Models/Projects/XrayType.cs
index 304cd6e..337e220 100644
--- a/ProxySuper.Core/Models/Projects/XrayType.cs
+++ b/ProxySuper.Core/Models/Projects/XrayType.cs
@@ -1,10 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace ProxySuper.Core.Models.Projects
+namespace ProxySuper.Core.Models.Projects
{
public enum XrayType
{
diff --git a/ProxySuper.Core/Models/Record.cs b/ProxySuper.Core/Models/Record.cs
index be09559..b032781 100644
--- a/ProxySuper.Core/Models/Record.cs
+++ b/ProxySuper.Core/Models/Record.cs
@@ -1,21 +1,9 @@
-using Microsoft.Win32;
-using MvvmCross;
-using MvvmCross.Commands;
-using MvvmCross.Navigation;
-using MvvmCross.ViewModels;
+using MvvmCross.ViewModels;
using Newtonsoft.Json;
-using Newtonsoft.Json.Linq;
using ProxySuper.Core.Models.Hosts;
using ProxySuper.Core.Models.Projects;
using ProxySuper.Core.Services;
-using ProxySuper.Core.ViewModels;
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.IO;
-using System.Linq;
using System.Text;
-using System.Threading.Tasks;
namespace ProxySuper.Core.Models
{
diff --git a/ProxySuper.Core/Properties/AssemblyInfo.cs b/ProxySuper.Core/Properties/AssemblyInfo.cs
index 6a26f9f..b26cc8e 100644
--- a/ProxySuper.Core/Properties/AssemblyInfo.cs
+++ b/ProxySuper.Core/Properties/AssemblyInfo.cs
@@ -1,5 +1,4 @@
using System.Reflection;
-using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
diff --git a/ProxySuper.Core/ProxySuper.Core.csproj b/ProxySuper.Core/ProxySuper.Core.csproj
index 4976f9c..0fa66fd 100644
--- a/ProxySuper.Core/ProxySuper.Core.csproj
+++ b/ProxySuper.Core/ProxySuper.Core.csproj
@@ -97,6 +97,7 @@
+
diff --git a/ProxySuper.Core/Services/BrookProject.cs b/ProxySuper.Core/Services/BrookProject.cs
index 2bfb69c..42aaf5e 100644
--- a/ProxySuper.Core/Services/BrookProject.cs
+++ b/ProxySuper.Core/Services/BrookProject.cs
@@ -1,10 +1,6 @@
using ProxySuper.Core.Models.Projects;
using Renci.SshNet;
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace ProxySuper.Core.Services
{
diff --git a/ProxySuper.Core/Services/NaiveProxyProject.cs b/ProxySuper.Core/Services/NaiveProxyProject.cs
index 1939167..9953763 100644
--- a/ProxySuper.Core/Services/NaiveProxyProject.cs
+++ b/ProxySuper.Core/Services/NaiveProxyProject.cs
@@ -1,13 +1,8 @@
-using Newtonsoft.Json;
-using Newtonsoft.Json.Linq;
-using ProxySuper.Core.Models.Projects;
+using ProxySuper.Core.Models.Projects;
using Renci.SshNet;
using System;
-using System.Collections.Generic;
using System.IO;
-using System.Linq;
using System.Text;
-using System.Threading.Tasks;
using System.Windows;
namespace ProxySuper.Core.Services
diff --git a/ProxySuper.Core/Services/ProjectBase.cs b/ProxySuper.Core/Services/ProjectBase.cs
index dd5cfb9..e8d89dd 100644
--- a/ProxySuper.Core/Services/ProjectBase.cs
+++ b/ProxySuper.Core/Services/ProjectBase.cs
@@ -1,13 +1,10 @@
using ProxySuper.Core.Helpers;
-using ProxySuper.Core.Models;
using ProxySuper.Core.Models.Projects;
using Renci.SshNet;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
using System.Windows;
namespace ProxySuper.Core.Services
diff --git a/ProxySuper.Core/Services/ShareLink.cs b/ProxySuper.Core/Services/ShareLink.cs
index 643bebe..f659f41 100644
--- a/ProxySuper.Core/Services/ShareLink.cs
+++ b/ProxySuper.Core/Services/ShareLink.cs
@@ -1,10 +1,7 @@
using Newtonsoft.Json;
using ProxySuper.Core.Models.Projects;
using System;
-using System.Collections.Generic;
-using System.Linq;
using System.Text;
-using System.Threading.Tasks;
using System.Web;
namespace ProxySuper.Core.Services
diff --git a/ProxySuper.Core/Services/TrojanGoConfigBuilder.cs b/ProxySuper.Core/Services/TrojanGoConfigBuilder.cs
index d9743c3..d4c467f 100644
--- a/ProxySuper.Core/Services/TrojanGoConfigBuilder.cs
+++ b/ProxySuper.Core/Services/TrojanGoConfigBuilder.cs
@@ -1,13 +1,7 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
-using ProxySuper.Core.Models;
using ProxySuper.Core.Models.Projects;
-using System;
-using System.Collections.Generic;
using System.IO;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace ProxySuper.Core.Services
{
diff --git a/ProxySuper.Core/Services/TrojanGoProject.cs b/ProxySuper.Core/Services/TrojanGoProject.cs
index 0dd5d13..8903df6 100644
--- a/ProxySuper.Core/Services/TrojanGoProject.cs
+++ b/ProxySuper.Core/Services/TrojanGoProject.cs
@@ -1,12 +1,8 @@
-using ProxySuper.Core.Models;
-using ProxySuper.Core.Models.Projects;
+using ProxySuper.Core.Models.Projects;
using Renci.SshNet;
using System;
-using System.Collections.Generic;
using System.IO;
-using System.Linq;
using System.Text;
-using System.Threading.Tasks;
using System.Windows;
namespace ProxySuper.Core.Services
diff --git a/ProxySuper.Core/Services/XrayConfigBuilder.cs b/ProxySuper.Core/Services/XrayConfigBuilder.cs
index 4d53fbe..0e7beb6 100644
--- a/ProxySuper.Core/Services/XrayConfigBuilder.cs
+++ b/ProxySuper.Core/Services/XrayConfigBuilder.cs
@@ -1,13 +1,9 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
-using ProxySuper.Core.Models;
using ProxySuper.Core.Models.Projects;
-using System;
using System.Collections.Generic;
using System.IO;
-using System.Linq;
using System.Text;
-using System.Threading.Tasks;
namespace ProxySuper.Core.Services
{
diff --git a/ProxySuper.Core/Services/XrayProject.cs b/ProxySuper.Core/Services/XrayProject.cs
index bef0952..9c743cb 100644
--- a/ProxySuper.Core/Services/XrayProject.cs
+++ b/ProxySuper.Core/Services/XrayProject.cs
@@ -1,13 +1,9 @@
using Newtonsoft.Json;
-using ProxySuper.Core.Models;
using ProxySuper.Core.Models.Projects;
using Renci.SshNet;
using System;
-using System.Collections.Generic;
using System.IO;
-using System.Linq;
using System.Text;
-using System.Threading.Tasks;
using System.Windows;
namespace ProxySuper.Core.Services
diff --git a/ProxySuper.Core/ViewModels/BrookConfigViewModel.cs b/ProxySuper.Core/ViewModels/BrookConfigViewModel.cs
index a8cb2f3..99d9421 100644
--- a/ProxySuper.Core/ViewModels/BrookConfigViewModel.cs
+++ b/ProxySuper.Core/ViewModels/BrookConfigViewModel.cs
@@ -1,11 +1,6 @@
using MvvmCross.ViewModels;
using ProxySuper.Core.Models.Projects;
using ProxySuper.Core.Services;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace ProxySuper.Core.ViewModels
{
diff --git a/ProxySuper.Core/ViewModels/BrookEditorViewModel.cs b/ProxySuper.Core/ViewModels/BrookEditorViewModel.cs
index cacc32a..9960068 100644
--- a/ProxySuper.Core/ViewModels/BrookEditorViewModel.cs
+++ b/ProxySuper.Core/ViewModels/BrookEditorViewModel.cs
@@ -7,9 +7,6 @@ using ProxySuper.Core.Models.Projects;
using ProxySuper.Core.Services;
using System;
using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace ProxySuper.Core.ViewModels
{
diff --git a/ProxySuper.Core/ViewModels/BrookInstallerViewModel.cs b/ProxySuper.Core/ViewModels/BrookInstallerViewModel.cs
index 74bae01..10e4084 100644
--- a/ProxySuper.Core/ViewModels/BrookInstallerViewModel.cs
+++ b/ProxySuper.Core/ViewModels/BrookInstallerViewModel.cs
@@ -3,11 +3,6 @@ using ProxySuper.Core.Models;
using ProxySuper.Core.Models.Hosts;
using ProxySuper.Core.Models.Projects;
using ProxySuper.Core.Services;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace ProxySuper.Core.ViewModels
{
diff --git a/ProxySuper.Core/ViewModels/EnableRootViewModel.cs b/ProxySuper.Core/ViewModels/EnableRootViewModel.cs
new file mode 100644
index 0000000..e4bc5d9
--- /dev/null
+++ b/ProxySuper.Core/ViewModels/EnableRootViewModel.cs
@@ -0,0 +1,168 @@
+using MvvmCross.Commands;
+using MvvmCross.ViewModels;
+using ProxySuper.Core.Models.Hosts;
+using Renci.SshNet;
+using System;
+using System.IO;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace ProxySuper.Core.ViewModels
+{
+ public class EnableRootViewModel : MvxViewModel
+ {
+ private SshClient _sshClient;
+
+ public EnableRootViewModel()
+ {
+ Host = new Host();
+ }
+
+ public Host Host { get; set; }
+
+ public string RootUserName { get; set; }
+
+ public string RootPassword { get; set; }
+
+ public string OutputText { get; set; }
+
+ public IMvxCommand ExecuteCommand => new MvxCommand(Execute);
+
+ public override void ViewDisappearing()
+ {
+ base.ViewDisappearing();
+ if (_sshClient != null)
+ {
+ _sshClient.Disconnect();
+ _sshClient.Dispose();
+ }
+ }
+
+ public void Execute()
+ {
+ Task.Factory.StartNew(() =>
+ {
+ OpenConnect();
+ if (!_sshClient.IsConnected)
+ {
+ MessageBox.Show("连接失败,请重试!");
+ return;
+ }
+
+ string result = string.Empty;
+ result = RunCmd("id -u");
+
+ if (result.TrimEnd('\r', '\n') == "0")
+ {
+ MessageBox.Show("当前账户已经具有root权限,无需再设置!");
+ return;
+ }
+
+ result = RunCmd($"echo {Host.Password} | sudo -S id -u");
+ if (result.TrimEnd('\r', '\n') != "0")
+ {
+ MessageBox.Show("当前账户无法获取sudo权限,设置失败!");
+ return;
+ }
+
+ string cmdPre = $"echo {Host.Password} | sudo -S id -u" + ';';
+ RunCmd(cmdPre + "sudo sed -i 's/PermitRootLogin /#PermitRootLogin /g' /etc/ssh/sshd_config");
+ RunCmd(cmdPre + "sudo sed -i 's/PasswordAuthentication /#PasswordAuthentication /g' /etc/ssh/sshd_config");
+ RunCmd(cmdPre + "sudo sed -i 's/PermitEmptyPasswords /#PermitEmptyPasswords /g' /etc/ssh/sshd_config");
+ RunCmd(cmdPre + "echo 'PermitRootLogin yes' | sudo tee -a /etc/ssh/sshd_config");
+ RunCmd(cmdPre + "echo 'PasswordAuthentication yes' | sudo tee -a /etc/ssh/sshd_config");
+ RunCmd(cmdPre + "echo 'PermitEmptyPasswords no' | sudo tee -a /etc/ssh/sshd_config");
+ RunCmd(cmdPre + "sudo systemctl restart sshd");
+
+ result = RunCmd(@"cat /dev/urandom | tr -dc '_A-Z#\-+=a-z(0-9%^>)]{<|' | head -c 20 ; echo ''");
+ string setPassword = result.TrimEnd('\r', '\n') + '\n';
+ RunCmd(cmdPre + $"echo -e \"{setPassword}{setPassword}\" | sudo passwd root");
+ RunCmd("sudo systemctl restart sshd ");
+
+ RootUserName = "root";
+ RootPassword = setPassword.Trim('\n');
+ RaisePropertyChanged("RootUserName");
+ RaisePropertyChanged("RootPassword");
+
+
+ var filePath = Host.Address.Replace(':', '_');
+ using (StreamWriter sw = new StreamWriter("Logs\\host_password_info.txt"))
+ {
+ sw.WriteLine(Host.Address);
+ sw.WriteLine("root");
+ sw.WriteLine(setPassword);
+ }
+ WriteOutput("设置成功,账号信息保存在Logs/host_password_info.txt");
+ WriteOutput("账号:\nroot");
+ WriteOutput($"密码:\n{setPassword}");
+ });
+ }
+
+ protected string RunCmd(string cmdStr)
+ {
+ var cmd = _sshClient.CreateCommand(cmdStr);
+ WriteOutput(cmdStr);
+
+ var result = cmd.Execute();
+ WriteOutput(result);
+ return result;
+ }
+
+ private void WriteOutput(string text)
+ {
+ OutputText += text + '\n';
+ RaisePropertyChanged("OutputText");
+ }
+
+
+ private void OpenConnect()
+ {
+ WriteOutput("正在建立连接...");
+ var conneInfo = CreateConnectionInfo(Host);
+ _sshClient = new SshClient(conneInfo);
+ try
+ {
+ _sshClient.Connect();
+ WriteOutput("Connected...");
+ }
+ catch (Exception ex)
+ {
+ WriteOutput(ex.Message);
+ MessageBox.Show(ex.Message);
+ }
+ }
+
+ private ConnectionInfo CreateConnectionInfo(Host host)
+ {
+ AuthenticationMethod auth = null;
+
+ if (host.SecretType == LoginSecretType.Password)
+ {
+ auth = new PasswordAuthenticationMethod(host.UserName, host.Password);
+ }
+ else if (host.SecretType == LoginSecretType.PrivateKey)
+ {
+ auth = new PrivateKeyAuthenticationMethod(host.UserName, new PrivateKeyFile(host.PrivateKeyPath));
+ }
+
+ if (host.Proxy.Type == LocalProxyType.None)
+ {
+ return new ConnectionInfo(host.Address, host.Port, host.UserName, auth);
+ }
+ else
+ {
+ return new ConnectionInfo(
+ host: host.Address,
+ port: host.Port,
+ username: host.UserName,
+ proxyType: (ProxyTypes)(int)host.Proxy.Type,
+ proxyHost: host.Proxy.Address,
+ proxyPort: host.Proxy.Port,
+ proxyUsername: host.Proxy.UserName,
+ proxyPassword: host.Proxy.Password,
+ authenticationMethods: auth);
+ }
+
+ }
+ }
+}
diff --git a/ProxySuper.Core/ViewModels/HomeViewModel.cs b/ProxySuper.Core/ViewModels/HomeViewModel.cs
index d3e7472..8b749de 100644
--- a/ProxySuper.Core/ViewModels/HomeViewModel.cs
+++ b/ProxySuper.Core/ViewModels/HomeViewModel.cs
@@ -11,8 +11,6 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
-using System.Runtime.CompilerServices;
-using System.Text;
using System.Threading.Tasks;
using System.Windows;
diff --git a/ProxySuper.Core/ViewModels/NaiveProxyConfigViewModel.cs b/ProxySuper.Core/ViewModels/NaiveProxyConfigViewModel.cs
index ca22cd0..8e59f65 100644
--- a/ProxySuper.Core/ViewModels/NaiveProxyConfigViewModel.cs
+++ b/ProxySuper.Core/ViewModels/NaiveProxyConfigViewModel.cs
@@ -1,11 +1,6 @@
using MvvmCross.ViewModels;
using ProxySuper.Core.Models.Projects;
using ProxySuper.Core.Services;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace ProxySuper.Core.ViewModels
{
diff --git a/ProxySuper.Core/ViewModels/NaiveProxyEditorViewModel.cs b/ProxySuper.Core/ViewModels/NaiveProxyEditorViewModel.cs
index e0e69e2..0dda929 100644
--- a/ProxySuper.Core/ViewModels/NaiveProxyEditorViewModel.cs
+++ b/ProxySuper.Core/ViewModels/NaiveProxyEditorViewModel.cs
@@ -1,17 +1,10 @@
-using Microsoft.Win32;
-using MvvmCross.Commands;
+using MvvmCross.Commands;
using MvvmCross.Navigation;
using MvvmCross.ViewModels;
using ProxySuper.Core.Models;
using ProxySuper.Core.Models.Hosts;
using ProxySuper.Core.Models.Projects;
using ProxySuper.Core.Services;
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace ProxySuper.Core.ViewModels
{
diff --git a/ProxySuper.Core/ViewModels/NaiveProxyInstallerViewModel.cs b/ProxySuper.Core/ViewModels/NaiveProxyInstallerViewModel.cs
index e21e425..35381cf 100644
--- a/ProxySuper.Core/ViewModels/NaiveProxyInstallerViewModel.cs
+++ b/ProxySuper.Core/ViewModels/NaiveProxyInstallerViewModel.cs
@@ -3,11 +3,6 @@ using ProxySuper.Core.Models;
using ProxySuper.Core.Models.Hosts;
using ProxySuper.Core.Models.Projects;
using ProxySuper.Core.Services;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace ProxySuper.Core.ViewModels
{
diff --git a/ProxySuper.Core/ViewModels/ShareLinkViewModel.cs b/ProxySuper.Core/ViewModels/ShareLinkViewModel.cs
index d9d79b0..749d86b 100644
--- a/ProxySuper.Core/ViewModels/ShareLinkViewModel.cs
+++ b/ProxySuper.Core/ViewModels/ShareLinkViewModel.cs
@@ -1,10 +1,7 @@
using MvvmCross.ViewModels;
using ProxySuper.Core.Models;
-using System;
using System.Collections.Generic;
-using System.Linq;
using System.Text;
-using System.Threading.Tasks;
namespace ProxySuper.Core.ViewModels
{
diff --git a/ProxySuper.Core/ViewModels/TrojanGoConfigViewModel.cs b/ProxySuper.Core/ViewModels/TrojanGoConfigViewModel.cs
index 63e4fca..ff469e2 100644
--- a/ProxySuper.Core/ViewModels/TrojanGoConfigViewModel.cs
+++ b/ProxySuper.Core/ViewModels/TrojanGoConfigViewModel.cs
@@ -1,11 +1,6 @@
using MvvmCross.ViewModels;
using ProxySuper.Core.Models.Projects;
using ProxySuper.Core.Services;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace ProxySuper.Core.ViewModels
{
diff --git a/ProxySuper.Core/ViewModels/TrojanGoEditorViewModel.cs b/ProxySuper.Core/ViewModels/TrojanGoEditorViewModel.cs
index 84b19f5..4e52497 100644
--- a/ProxySuper.Core/ViewModels/TrojanGoEditorViewModel.cs
+++ b/ProxySuper.Core/ViewModels/TrojanGoEditorViewModel.cs
@@ -5,11 +5,6 @@ using ProxySuper.Core.Models;
using ProxySuper.Core.Models.Hosts;
using ProxySuper.Core.Models.Projects;
using ProxySuper.Core.Services;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace ProxySuper.Core.ViewModels
{
diff --git a/ProxySuper.Core/ViewModels/TrojanGoInstallerViewModel.cs b/ProxySuper.Core/ViewModels/TrojanGoInstallerViewModel.cs
index 55c3d99..41ee15a 100644
--- a/ProxySuper.Core/ViewModels/TrojanGoInstallerViewModel.cs
+++ b/ProxySuper.Core/ViewModels/TrojanGoInstallerViewModel.cs
@@ -3,11 +3,6 @@ using ProxySuper.Core.Models;
using ProxySuper.Core.Models.Hosts;
using ProxySuper.Core.Models.Projects;
using ProxySuper.Core.Services;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace ProxySuper.Core.ViewModels
{
diff --git a/ProxySuper.Core/ViewModels/XrayConfigViewModel.cs b/ProxySuper.Core/ViewModels/XrayConfigViewModel.cs
index f064dca..5988329 100644
--- a/ProxySuper.Core/ViewModels/XrayConfigViewModel.cs
+++ b/ProxySuper.Core/ViewModels/XrayConfigViewModel.cs
@@ -1,16 +1,5 @@
-using Microsoft.Win32;
-using MvvmCross.ViewModels;
+using MvvmCross.ViewModels;
using ProxySuper.Core.Models.Projects;
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Media.Imaging;
-using QRCoder;
namespace ProxySuper.Core.ViewModels
{
diff --git a/ProxySuper.Core/ViewModels/XrayEditorViewModel.cs b/ProxySuper.Core/ViewModels/XrayEditorViewModel.cs
index 20ff3cd..291802c 100644
--- a/ProxySuper.Core/ViewModels/XrayEditorViewModel.cs
+++ b/ProxySuper.Core/ViewModels/XrayEditorViewModel.cs
@@ -1,8 +1,6 @@
-using MvvmCross;
-using MvvmCross.Commands;
+using MvvmCross.Commands;
using MvvmCross.Navigation;
using MvvmCross.ViewModels;
-using Newtonsoft.Json;
using ProxySuper.Core.Models;
using ProxySuper.Core.Models.Hosts;
using ProxySuper.Core.Models.Projects;
@@ -10,10 +8,7 @@ using ProxySuper.Core.Services;
using System;
using System.Collections.Generic;
using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
using System.Windows.Controls;
-using System.Windows.Input;
namespace ProxySuper.Core.ViewModels
{
diff --git a/ProxySuper.Core/ViewModels/XrayInstallerViewModel.cs b/ProxySuper.Core/ViewModels/XrayInstallerViewModel.cs
index d96a841..48597cd 100644
--- a/ProxySuper.Core/ViewModels/XrayInstallerViewModel.cs
+++ b/ProxySuper.Core/ViewModels/XrayInstallerViewModel.cs
@@ -3,13 +3,6 @@ using ProxySuper.Core.Models;
using ProxySuper.Core.Models.Hosts;
using ProxySuper.Core.Models.Projects;
using ProxySuper.Core.Services;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Renci.SshNet;
-using System.Windows.Threading;
namespace ProxySuper.Core.ViewModels
{
diff --git a/ProxySuper.WPF/App.xaml.cs b/ProxySuper.WPF/App.xaml.cs
index 7e3b001..52c5e57 100644
--- a/ProxySuper.WPF/App.xaml.cs
+++ b/ProxySuper.WPF/App.xaml.cs
@@ -1,13 +1,6 @@
-using MvvmCross.Platforms.Wpf.Views;
+using MvvmCross.Core;
using MvvmCross.Platforms.Wpf.Core;
-using MvvmCross.Core;
-using System;
-using System.Collections.Generic;
-using System.Configuration;
-using System.Data;
-using System.Linq;
-using System.Threading.Tasks;
-using System.Windows;
+using MvvmCross.Platforms.Wpf.Views;
namespace ProxySuper.WPF
{
diff --git a/ProxySuper.WPF/Controls/HostControl.xaml b/ProxySuper.WPF/Controls/HostControl.xaml
index 0a5397f..7ec9b0c 100644
--- a/ProxySuper.WPF/Controls/HostControl.xaml
+++ b/ProxySuper.WPF/Controls/HostControl.xaml
@@ -16,8 +16,8 @@
-
-
+
+
diff --git a/ProxySuper.WPF/Controls/HostControl.xaml.cs b/ProxySuper.WPF/Controls/HostControl.xaml.cs
index f13ec61..e4a1959 100644
--- a/ProxySuper.WPF/Controls/HostControl.xaml.cs
+++ b/ProxySuper.WPF/Controls/HostControl.xaml.cs
@@ -1,17 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Navigation;
-using System.Windows.Shapes;
+using System.Windows.Controls;
namespace ProxySuper.WPF.Controls
{
diff --git a/ProxySuper.WPF/Controls/ShadowSocksControl.xaml.cs b/ProxySuper.WPF/Controls/ShadowSocksControl.xaml.cs
index f4d3175..f2e96b3 100644
--- a/ProxySuper.WPF/Controls/ShadowSocksControl.xaml.cs
+++ b/ProxySuper.WPF/Controls/ShadowSocksControl.xaml.cs
@@ -1,17 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Navigation;
-using System.Windows.Shapes;
+using System.Windows.Controls;
namespace ProxySuper.WPF.Controls
{
diff --git a/ProxySuper.WPF/Controls/Trojan_TCP_Control.xaml.cs b/ProxySuper.WPF/Controls/Trojan_TCP_Control.xaml.cs
index 3701ab9..72103e8 100644
--- a/ProxySuper.WPF/Controls/Trojan_TCP_Control.xaml.cs
+++ b/ProxySuper.WPF/Controls/Trojan_TCP_Control.xaml.cs
@@ -1,17 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Navigation;
-using System.Windows.Shapes;
+using System.Windows.Controls;
namespace ProxySuper.WPF.Controls
{
diff --git a/ProxySuper.WPF/Controls/VLESS_KCP_Control.xaml.cs b/ProxySuper.WPF/Controls/VLESS_KCP_Control.xaml.cs
index 414c4b1..2173b7d 100644
--- a/ProxySuper.WPF/Controls/VLESS_KCP_Control.xaml.cs
+++ b/ProxySuper.WPF/Controls/VLESS_KCP_Control.xaml.cs
@@ -1,17 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Navigation;
-using System.Windows.Shapes;
+using System.Windows.Controls;
namespace ProxySuper.WPF.Controls
{
diff --git a/ProxySuper.WPF/Controls/VLESS_TCP_TLS_Control.xaml.cs b/ProxySuper.WPF/Controls/VLESS_TCP_TLS_Control.xaml.cs
index c147188..fcebaef 100644
--- a/ProxySuper.WPF/Controls/VLESS_TCP_TLS_Control.xaml.cs
+++ b/ProxySuper.WPF/Controls/VLESS_TCP_TLS_Control.xaml.cs
@@ -1,17 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Navigation;
-using System.Windows.Shapes;
+using System.Windows.Controls;
namespace ProxySuper.WPF.Controls
{
diff --git a/ProxySuper.WPF/Controls/VLESS_WS_TLS_Control.xaml.cs b/ProxySuper.WPF/Controls/VLESS_WS_TLS_Control.xaml.cs
index 7e3f8a9..5c434da 100644
--- a/ProxySuper.WPF/Controls/VLESS_WS_TLS_Control.xaml.cs
+++ b/ProxySuper.WPF/Controls/VLESS_WS_TLS_Control.xaml.cs
@@ -1,17 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Navigation;
-using System.Windows.Shapes;
+using System.Windows.Controls;
namespace ProxySuper.WPF.Controls
{
diff --git a/ProxySuper.WPF/Controls/VLESS_XTLS_Control.xaml.cs b/ProxySuper.WPF/Controls/VLESS_XTLS_Control.xaml.cs
index 185f6a1..4ee74c9 100644
--- a/ProxySuper.WPF/Controls/VLESS_XTLS_Control.xaml.cs
+++ b/ProxySuper.WPF/Controls/VLESS_XTLS_Control.xaml.cs
@@ -1,17 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Navigation;
-using System.Windows.Shapes;
+using System.Windows.Controls;
namespace ProxySuper.WPF.Controls
{
diff --git a/ProxySuper.WPF/Controls/VLESS_gRPC_Control.xaml.cs b/ProxySuper.WPF/Controls/VLESS_gRPC_Control.xaml.cs
index 2b346ae..87ee670 100644
--- a/ProxySuper.WPF/Controls/VLESS_gRPC_Control.xaml.cs
+++ b/ProxySuper.WPF/Controls/VLESS_gRPC_Control.xaml.cs
@@ -1,17 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Navigation;
-using System.Windows.Shapes;
+using System.Windows.Controls;
namespace ProxySuper.WPF.Controls
{
diff --git a/ProxySuper.WPF/Controls/VMESS_KCP_Control.xaml.cs b/ProxySuper.WPF/Controls/VMESS_KCP_Control.xaml.cs
index 0dccb5a..4183748 100644
--- a/ProxySuper.WPF/Controls/VMESS_KCP_Control.xaml.cs
+++ b/ProxySuper.WPF/Controls/VMESS_KCP_Control.xaml.cs
@@ -1,17 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Navigation;
-using System.Windows.Shapes;
+using System.Windows.Controls;
namespace ProxySuper.WPF.Controls
{
diff --git a/ProxySuper.WPF/Controls/VMESS_TCP_TLS_Control.xaml.cs b/ProxySuper.WPF/Controls/VMESS_TCP_TLS_Control.xaml.cs
index 12714fa..fe42054 100644
--- a/ProxySuper.WPF/Controls/VMESS_TCP_TLS_Control.xaml.cs
+++ b/ProxySuper.WPF/Controls/VMESS_TCP_TLS_Control.xaml.cs
@@ -1,17 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Navigation;
-using System.Windows.Shapes;
+using System.Windows.Controls;
namespace ProxySuper.WPF.Controls
{
diff --git a/ProxySuper.WPF/Controls/VMESS_WS_TLS_Control.xaml.cs b/ProxySuper.WPF/Controls/VMESS_WS_TLS_Control.xaml.cs
index f8502d9..79887c2 100644
--- a/ProxySuper.WPF/Controls/VMESS_WS_TLS_Control.xaml.cs
+++ b/ProxySuper.WPF/Controls/VMESS_WS_TLS_Control.xaml.cs
@@ -1,17 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Navigation;
-using System.Windows.Shapes;
+using System.Windows.Controls;
namespace ProxySuper.WPF.Controls
{
diff --git a/ProxySuper.WPF/Controls/XraySettingsControl.xaml.cs b/ProxySuper.WPF/Controls/XraySettingsControl.xaml.cs
index 402842f..f03b7ac 100644
--- a/ProxySuper.WPF/Controls/XraySettingsControl.xaml.cs
+++ b/ProxySuper.WPF/Controls/XraySettingsControl.xaml.cs
@@ -1,17 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Navigation;
-using System.Windows.Shapes;
+using System.Windows.Controls;
namespace ProxySuper.WPF.Controls
{
diff --git a/ProxySuper.WPF/MainWindow.xaml.cs b/ProxySuper.WPF/MainWindow.xaml.cs
index ae0b3bc..d31f448 100644
--- a/ProxySuper.WPF/MainWindow.xaml.cs
+++ b/ProxySuper.WPF/MainWindow.xaml.cs
@@ -1,17 +1,4 @@
using MvvmCross.Platforms.Wpf.Views;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Shapes;
namespace ProxySuper.WPF
{
diff --git a/ProxySuper.WPF/Properties/AssemblyInfo.cs b/ProxySuper.WPF/Properties/AssemblyInfo.cs
index 89c1abd..508d2fa 100644
--- a/ProxySuper.WPF/Properties/AssemblyInfo.cs
+++ b/ProxySuper.WPF/Properties/AssemblyInfo.cs
@@ -1,6 +1,4 @@
using System.Reflection;
-using System.Resources;
-using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
diff --git a/ProxySuper.WPF/Views/BrookConfigView.xaml.cs b/ProxySuper.WPF/Views/BrookConfigView.xaml.cs
index 963d307..67c7452 100644
--- a/ProxySuper.WPF/Views/BrookConfigView.xaml.cs
+++ b/ProxySuper.WPF/Views/BrookConfigView.xaml.cs
@@ -1,17 +1,4 @@
using MvvmCross.Platforms.Wpf.Views;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Shapes;
namespace ProxySuper.WPF.Views
{
diff --git a/ProxySuper.WPF/Views/BrookEditorView.xaml.cs b/ProxySuper.WPF/Views/BrookEditorView.xaml.cs
index a1de104..00d4726 100644
--- a/ProxySuper.WPF/Views/BrookEditorView.xaml.cs
+++ b/ProxySuper.WPF/Views/BrookEditorView.xaml.cs
@@ -1,18 +1,5 @@
using MvvmCross.Platforms.Wpf.Presenters.Attributes;
using MvvmCross.Platforms.Wpf.Views;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Shapes;
namespace ProxySuper.WPF.Views
{
diff --git a/ProxySuper.WPF/Views/BrookInstallerView.xaml.cs b/ProxySuper.WPF/Views/BrookInstallerView.xaml.cs
index a953bc2..03d4b47 100644
--- a/ProxySuper.WPF/Views/BrookInstallerView.xaml.cs
+++ b/ProxySuper.WPF/Views/BrookInstallerView.xaml.cs
@@ -4,20 +4,11 @@ using ProxySuper.Core.Services;
using ProxySuper.Core.ViewModels;
using Renci.SshNet;
using System;
-using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
-using System.Linq;
-using System.Text;
using System.Threading.Tasks;
using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Shapes;
namespace ProxySuper.WPF.Views
{
@@ -120,6 +111,16 @@ namespace ProxySuper.WPF.Views
Task.Factory.StartNew(OpenConnect);
};
base.Closed += SaveInstallLog;
+ base.Closed += Disconnect;
+ }
+
+ private void Disconnect(object sender, EventArgs e)
+ {
+ if (_sshClient != null)
+ {
+ _sshClient.Disconnect();
+ _sshClient.Dispose();
+ }
}
private void SaveInstallLog(object sender, EventArgs e)
diff --git a/ProxySuper.WPF/Views/EnableRootView.xaml b/ProxySuper.WPF/Views/EnableRootView.xaml
index 3f63477..549b1f8 100644
--- a/ProxySuper.WPF/Views/EnableRootView.xaml
+++ b/ProxySuper.WPF/Views/EnableRootView.xaml
@@ -4,12 +4,68 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:views="clr-namespace:MvvmCross.Platforms.Wpf.Views;assembly=MvvmCross.Platforms.Wpf"
+ xmlns:ctrl="clr-namespace:ProxySuper.WPF.Controls"
xmlns:local="clr-namespace:ProxySuper.WPF.Views"
mc:Ignorable="d"
Icon="/Resources/ProxySU.ico"
+ BorderBrush="#EEE"
+ BorderThickness="1"
WindowStartupLocation="CenterScreen"
- Title="NaiveProxyConfigView" Height="450" Width="800">
-
-
+ Title="NaiveProxyConfigView" Height="610" Width="800">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ProxySuper.WPF/Views/EnableRootView.xaml.cs b/ProxySuper.WPF/Views/EnableRootView.xaml.cs
index 0a215e0..acf18fe 100644
--- a/ProxySuper.WPF/Views/EnableRootView.xaml.cs
+++ b/ProxySuper.WPF/Views/EnableRootView.xaml.cs
@@ -1,27 +1,20 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Shapes;
+using MvvmCross.Platforms.Wpf.Views;
namespace ProxySuper.WPF.Views
{
///
/// EnableRootView.xaml 的交互逻辑
///
- public partial class EnableRootView : Window
+ public partial class EnableRootView : MvxWindow
{
public EnableRootView()
{
InitializeComponent();
}
+
+ private void TextBox_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
+ {
+ OutputText.ScrollToEnd();
+ }
}
}
diff --git a/ProxySuper.WPF/Views/HomeView.xaml b/ProxySuper.WPF/Views/HomeView.xaml
index 0572bf0..fd98283 100644
--- a/ProxySuper.WPF/Views/HomeView.xaml
+++ b/ProxySuper.WPF/Views/HomeView.xaml
@@ -23,6 +23,7 @@
diff --git a/ProxySuper.WPF/Views/HomeView.xaml.cs b/ProxySuper.WPF/Views/HomeView.xaml.cs
index 7b3e18f..2d3fe84 100644
--- a/ProxySuper.WPF/Views/HomeView.xaml.cs
+++ b/ProxySuper.WPF/Views/HomeView.xaml.cs
@@ -6,7 +6,6 @@ using ProxySuper.Core.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
-using System.Text;
using System.Windows;
namespace ProxySuper.WPF.Views
@@ -96,6 +95,10 @@ namespace ProxySuper.WPF.Views
NavigationService.Navigate>(checkedRecords);
}
+ private void GetRoot(object sender, RoutedEventArgs e)
+ {
+ NavigationService.Navigate();
+ }
}
}
diff --git a/ProxySuper.WPF/Views/NaiveProxyConfigView.xaml.cs b/ProxySuper.WPF/Views/NaiveProxyConfigView.xaml.cs
index 5ee9403..bcd9f4d 100644
--- a/ProxySuper.WPF/Views/NaiveProxyConfigView.xaml.cs
+++ b/ProxySuper.WPF/Views/NaiveProxyConfigView.xaml.cs
@@ -1,17 +1,4 @@
using MvvmCross.Platforms.Wpf.Views;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Shapes;
namespace ProxySuper.WPF.Views
{
diff --git a/ProxySuper.WPF/Views/NaiveProxyEditorView.xaml.cs b/ProxySuper.WPF/Views/NaiveProxyEditorView.xaml.cs
index 41d7577..4a948bd 100644
--- a/ProxySuper.WPF/Views/NaiveProxyEditorView.xaml.cs
+++ b/ProxySuper.WPF/Views/NaiveProxyEditorView.xaml.cs
@@ -1,17 +1,4 @@
using MvvmCross.Platforms.Wpf.Views;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Shapes;
namespace ProxySuper.WPF.Views
{
diff --git a/ProxySuper.WPF/Views/NaiveProxyInstallerView.xaml.cs b/ProxySuper.WPF/Views/NaiveProxyInstallerView.xaml.cs
index a88fcd4..76facb5 100644
--- a/ProxySuper.WPF/Views/NaiveProxyInstallerView.xaml.cs
+++ b/ProxySuper.WPF/Views/NaiveProxyInstallerView.xaml.cs
@@ -5,21 +5,12 @@ using ProxySuper.Core.Services;
using ProxySuper.Core.ViewModels;
using Renci.SshNet;
using System;
-using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
-using System.Linq;
-using System.Text;
using System.Threading.Tasks;
using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Shapes;
namespace ProxySuper.WPF.Views
{
@@ -43,6 +34,13 @@ namespace ProxySuper.WPF.Views
public NaiveProxyProject Project { get; set; }
+ protected override void OnClosed(EventArgs e)
+ {
+ base.OnClosed(e);
+ _sshClient.Disconnect();
+ _sshClient.Dispose();
+ }
+
private SshClient _sshClient;
private void OpenConnect()
{
@@ -122,6 +120,16 @@ namespace ProxySuper.WPF.Views
Task.Factory.StartNew(OpenConnect);
};
base.Closed += SaveInstallLog;
+ base.Closed += Disconnect;
+ }
+
+ private void Disconnect(object sender, EventArgs e)
+ {
+ if (_sshClient != null)
+ {
+ _sshClient.Disconnect();
+ _sshClient.Dispose();
+ }
}
private void SaveInstallLog(object sender, EventArgs e)
diff --git a/ProxySuper.WPF/Views/ShareLinkView.xaml.cs b/ProxySuper.WPF/Views/ShareLinkView.xaml.cs
index e6d9945..ea49557 100644
--- a/ProxySuper.WPF/Views/ShareLinkView.xaml.cs
+++ b/ProxySuper.WPF/Views/ShareLinkView.xaml.cs
@@ -1,17 +1,4 @@
using MvvmCross.Platforms.Wpf.Views;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Shapes;
namespace ProxySuper.WPF.Views
{
diff --git a/ProxySuper.WPF/Views/TrojanGoConfigView.xaml.cs b/ProxySuper.WPF/Views/TrojanGoConfigView.xaml.cs
index d2719f8..31a572a 100644
--- a/ProxySuper.WPF/Views/TrojanGoConfigView.xaml.cs
+++ b/ProxySuper.WPF/Views/TrojanGoConfigView.xaml.cs
@@ -1,18 +1,5 @@
using MvvmCross.Platforms.Wpf.Views;
using ProxySuper.Core.ViewModels;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Shapes;
namespace ProxySuper.WPF.Views
{
diff --git a/ProxySuper.WPF/Views/TrojanGoEditorView.xaml.cs b/ProxySuper.WPF/Views/TrojanGoEditorView.xaml.cs
index 0e9a481..beeae43 100644
--- a/ProxySuper.WPF/Views/TrojanGoEditorView.xaml.cs
+++ b/ProxySuper.WPF/Views/TrojanGoEditorView.xaml.cs
@@ -1,18 +1,5 @@
using MvvmCross.Platforms.Wpf.Presenters.Attributes;
using MvvmCross.Platforms.Wpf.Views;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Shapes;
namespace ProxySuper.WPF.Views
{
diff --git a/ProxySuper.WPF/Views/TrojanGoInstallerView.xaml.cs b/ProxySuper.WPF/Views/TrojanGoInstallerView.xaml.cs
index e8ad031..3be2d32 100644
--- a/ProxySuper.WPF/Views/TrojanGoInstallerView.xaml.cs
+++ b/ProxySuper.WPF/Views/TrojanGoInstallerView.xaml.cs
@@ -6,21 +6,12 @@ using ProxySuper.Core.Services;
using ProxySuper.Core.ViewModels;
using Renci.SshNet;
using System;
-using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
-using System.Linq;
-using System.Text;
using System.Threading.Tasks;
using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Shapes;
namespace ProxySuper.WPF.Views
{
@@ -45,6 +36,8 @@ namespace ProxySuper.WPF.Views
public TrojanGoProject Project { get; set; }
+
+
private SshClient _sshClient;
private void OpenConnect()
{
@@ -124,6 +117,16 @@ namespace ProxySuper.WPF.Views
Task.Factory.StartNew(OpenConnect);
};
base.Closed += SaveInstallLog;
+ base.Closed += Disconnect;
+ }
+
+ private void Disconnect(object sender, EventArgs e)
+ {
+ if (_sshClient != null)
+ {
+ _sshClient.Disconnect();
+ _sshClient.Dispose();
+ }
}
private void SaveInstallLog(object sender, EventArgs e)
diff --git a/ProxySuper.WPF/Views/XrayConfigView.xaml.cs b/ProxySuper.WPF/Views/XrayConfigView.xaml.cs
index 2916c11..286ac2a 100644
--- a/ProxySuper.WPF/Views/XrayConfigView.xaml.cs
+++ b/ProxySuper.WPF/Views/XrayConfigView.xaml.cs
@@ -1,24 +1,13 @@
using Microsoft.Win32;
using MvvmCross.Platforms.Wpf.Views;
using ProxySuper.Core.Models.Projects;
-using ProxySuper.Core.Services;
using ProxySuper.Core.ViewModels;
using QRCoder;
-using System;
-using System.Collections.Generic;
using System.Drawing;
using System.IO;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
using System.Windows.Media.Imaging;
-using System.Windows.Shapes;
namespace ProxySuper.WPF.Views
{
diff --git a/ProxySuper.WPF/Views/XrayEditorView.xaml.cs b/ProxySuper.WPF/Views/XrayEditorView.xaml.cs
index d6ad3b7..b29d1df 100644
--- a/ProxySuper.WPF/Views/XrayEditorView.xaml.cs
+++ b/ProxySuper.WPF/Views/XrayEditorView.xaml.cs
@@ -1,18 +1,6 @@
using MvvmCross.Platforms.Wpf.Presenters.Attributes;
using MvvmCross.Platforms.Wpf.Views;
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Shapes;
namespace ProxySuper.WPF.Views
{
diff --git a/ProxySuper.WPF/Views/XrayInstallerView.xaml.cs b/ProxySuper.WPF/Views/XrayInstallerView.xaml.cs
index b582987..7d12d5a 100644
--- a/ProxySuper.WPF/Views/XrayInstallerView.xaml.cs
+++ b/ProxySuper.WPF/Views/XrayInstallerView.xaml.cs
@@ -11,7 +11,6 @@ using System.Diagnostics;
using System.IO;
using System.Threading.Tasks;
using System.Windows;
-using System.Windows.Automation.Peers;
using System.Windows.Documents;
using System.Windows.Threading;
@@ -48,6 +47,16 @@ namespace ProxySuper.WPF.Views
};
base.Closed += SaveInstallLog;
+ base.Closed += Disconnect;
+ }
+
+ private void Disconnect(object sender, EventArgs e)
+ {
+ if (_sshClient != null)
+ {
+ _sshClient.Disconnect();
+ _sshClient.Dispose();
+ }
}
private void SaveInstallLog(object sender, EventArgs e)