mirror of
https://github.com/proxysu/ProxySU.git
synced 2024-11-21 20:56:08 +03:00
enable root account
This commit is contained in:
parent
0859efb2dd
commit
c33de96563
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 有关程序集的一般信息由以下
|
||||
|
@ -97,6 +97,7 @@
|
||||
<Compile Include="ViewModels\BrookConfigViewModel.cs" />
|
||||
<Compile Include="ViewModels\BrookEditorViewModel.cs" />
|
||||
<Compile Include="ViewModels\BrookInstallerViewModel.cs" />
|
||||
<Compile Include="ViewModels\EnableRootViewModel.cs" />
|
||||
<Compile Include="ViewModels\HomeViewModel.cs" />
|
||||
<Compile Include="ViewModels\NaiveProxyConfigViewModel.cs" />
|
||||
<Compile Include="ViewModels\NaiveProxyEditorViewModel.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
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
168
ProxySuper.Core/ViewModels/EnableRootViewModel.cs
Normal file
168
ProxySuper.Core/ViewModels/EnableRootViewModel.cs
Normal file
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -16,8 +16,8 @@
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition Height="300" />
|
||||
<RowDefinition Height="auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<GroupBox Padding="10" Header="{DynamicResource HostGroupName}" Grid.Row="0">
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -1,6 +1,4 @@
|
||||
using System.Reflection;
|
||||
using System.Resources;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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)
|
||||
|
@ -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">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="310" />
|
||||
<ColumnDefinition Width="5" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<ctrl:HostControl Grid.Column="0" Margin="10" />
|
||||
|
||||
<StackPanel Grid.Column="1" Background="#EEE"></StackPanel>
|
||||
|
||||
|
||||
<StackPanel Grid.Column="2" >
|
||||
<TextBox IsReadOnly="True"
|
||||
Block.LineHeight="18"
|
||||
Background="#000"
|
||||
Foreground="LawnGreen"
|
||||
FontSize="14"
|
||||
FontFamily="Consolas"
|
||||
Text="{Binding OutputText}"
|
||||
Height="260"
|
||||
Padding="10"
|
||||
BorderThickness="0"
|
||||
VerticalAlignment="Top"
|
||||
VerticalContentAlignment="Top"
|
||||
TextWrapping="WrapWithOverflow"
|
||||
x:Name="OutputText"
|
||||
TextChanged="TextBox_TextChanged"
|
||||
Margin="10" />
|
||||
|
||||
<GroupBox Header="Root Account" Margin="10" Padding="20">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto" />
|
||||
<RowDefinition Height="36" />
|
||||
<RowDefinition Height="36" />
|
||||
<RowDefinition Height="36" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="100" />
|
||||
<ColumnDefinition Width="200" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Label Content="Root" Grid.Row="1" Grid.Column="0" />
|
||||
<TextBox IsReadOnly="True" Text="{Binding RootUserName}" Grid.Row="1" Grid.Column="1" />
|
||||
|
||||
<Label Content="{DynamicResource HostPassword}" Grid.Row="2" Grid.Column="0" />
|
||||
<TextBox IsReadOnly="True" Text="{Binding RootPassword}" Grid.Row="2" Grid.Column="1" />
|
||||
|
||||
<Button Height="28" Grid.Row="3" Grid.Column="3" Command="{Binding ExecuteCommand}">一键Root</Button>
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
</StackPanel>
|
||||
|
||||
</Grid>
|
||||
</views:MvxWindow>
|
||||
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// EnableRootView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
<MenuItem Header="{DynamicResource MainMenuActions}" Padding="10,3">
|
||||
<MenuItem Padding="0,5" Header="{DynamicResource MainMenuActionsExportSettings}" Click="ShowShareLinks"></MenuItem>
|
||||
<MenuItem Padding="0,5" Header="{DynamicResource MainMenuActionsGetRoot}" Click="GetRoot"></MenuItem>
|
||||
</MenuItem>
|
||||
|
||||
<MenuItem Header="{DynamicResource MainMenuLanguage}" Padding="10,3">
|
||||
|
@ -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<ShareLinkViewModel, List<Record>>(checkedRecords);
|
||||
}
|
||||
|
||||
private void GetRoot(object sender, RoutedEventArgs e)
|
||||
{
|
||||
NavigationService.Navigate<EnableRootViewModel>();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user