diff --git a/ProxySU_Core/ViewModels/Developers/Project.cs b/ProxySU_Core/ViewModels/Developers/Project.cs
index 5c24a10..dc6cce5 100644
--- a/ProxySU_Core/ViewModels/Developers/Project.cs
+++ b/ProxySU_Core/ViewModels/Developers/Project.cs
@@ -156,8 +156,14 @@ namespace ProxySU_Core.ViewModels.Developers
///
protected void ConfigureSoftware()
{
+ string cmd = RunCmd("command -v sudo");
+ if (string.IsNullOrEmpty(cmd))
+ {
+ RunCmd(GetInstallCmd("sudo"));
+ }
+
// 安装curl,wget,unzip
- string cmd = RunCmd("command -v curl");
+ cmd = RunCmd("command -v curl");
if (string.IsNullOrEmpty(cmd))
{
RunCmd(GetInstallCmd("curl"));
@@ -399,7 +405,7 @@ namespace ProxySU_Core.ViewModels.Developers
{
if (force)
{
- var btnResult = MessageBox.Show("80/443端口之一,或全部被占用,将强制停止占用80/443端口的程序?", "提示", MessageBoxButton.YesNo);
+ var btnResult = MessageBox.Show($"{port}端口被占用,将强制停止占用{port}端口的程序?", "提示", MessageBoxButton.YesNo);
if (btnResult == MessageBoxResult.No)
{
throw new Exception($"{port}端口被占用,安装停止!");
diff --git a/ProxySU_Core/ViewModels/Developers/XrayProject.cs b/ProxySU_Core/ViewModels/Developers/XrayProject.cs
index 420cad9..cd0cf31 100644
--- a/ProxySU_Core/ViewModels/Developers/XrayProject.cs
+++ b/ProxySU_Core/ViewModels/Developers/XrayProject.cs
@@ -29,6 +29,25 @@ namespace ProxySU_Core.ViewModels.Developers
{
}
+ public void InstallCert()
+ {
+ EnsureRootAuth();
+ EnsureSystemEnv();
+ this.InstallCertToXray();
+ RunCmd("systemctl restart xray");
+ }
+
+ public void UploadWeb(Stream stream)
+ {
+ EnsureRootAuth();
+ EnsureSystemEnv();
+ RunCmd("rm -rf /usr/share/caddy/*");
+ UploadFile(stream, "/usr/share/caddy/caddy.zip");
+ RunCmd("unzip /usr/share/caddy/caddy.zip -d /usr/share/caddy");
+ RunCmd("chmod -R 777 /usr/share/caddy");
+ }
+
+
public override void Install()
{
try
@@ -45,25 +64,46 @@ namespace ProxySU_Core.ViewModels.Developers
}
}
+ WriteOutput("检测安装系统环境...");
EnsureSystemEnv();
+ WriteOutput("检测安装系统环境完成");
+ WriteOutput("配置服务器端口...");
ConfigurePort();
+ WriteOutput("端口配置完成");
+ WriteOutput("安装必要的系统工具...");
ConfigureSoftware();
+ WriteOutput("系统工具安装完成");
+ WriteOutput("检测IP6...");
ConfigureIPv6();
+ WriteOutput("检测IP6完成");
+ WriteOutput("配置防火墙...");
ConfigureFirewall();
+ WriteOutput("防火墙配置完成");
+ WriteOutput("同步系统和本地世间...");
SyncTimeDiff();
+ WriteOutput("时间同步完成");
+ WriteOutput("检测域名是否绑定本机IP...");
ValidateDomain();
+ WriteOutput("域名检测完成");
+ WriteOutput("安装Xray-Core...");
InstallXrayWithCert();
+ WriteOutput("Xray-Core安装完成");
+ WriteOutput("安装Caddy...");
InstallCaddy();
+ WriteOutput("Caddy安装完成");
UploadCaddyFile();
+ WriteOutput("************");
+ WriteOutput("安装完成,尽情享用吧......");
+ WriteOutput("************");
}
catch (Exception ex)
{
@@ -84,9 +124,9 @@ namespace ProxySU_Core.ViewModels.Developers
{
RunCmd("bash -c \"$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)\" @ install");
- if (FileExists("/usr/local/bin/xray"))
+ if (!FileExists("/usr/local/bin/xray"))
{
- WriteOutput("Xray安装成功");
+ throw new Exception("Xray-Core安装失败,请联系开发者");
}
RunCmd($"sed -i 's/User=nobody/User=root/g' /etc/systemd/system/xray.service");
@@ -99,7 +139,9 @@ namespace ProxySU_Core.ViewModels.Developers
RunCmd(@"mv /usr/local/etc/xray/config.json /usr/local/etc/xray/config.json.1");
}
+ WriteOutput("安装TLS证书");
InstallCertToXray();
+ WriteOutput("TLS证书安装完成");
var configJson = ConfigBuilder.BuildXrayConfig(Parameters);
diff --git a/ProxySU_Core/ViewModels/Terminal.cs b/ProxySU_Core/ViewModels/Terminal.cs
index 4c5028b..942edc5 100644
--- a/ProxySU_Core/ViewModels/Terminal.cs
+++ b/ProxySU_Core/ViewModels/Terminal.cs
@@ -9,10 +9,25 @@ namespace ProxySU_Core.ViewModels
public class Terminal : BaseViewModel
{
private string outputText;
+ private bool hasConnected;
public Terminal(Host host)
{
Host = host;
+ HasConnected = false;
+ }
+
+ public bool HasConnected
+ {
+ get
+ {
+ return hasConnected;
+ }
+ set
+ {
+ hasConnected = value;
+ Notify("HasConnected");
+ }
}
public Host Host { get; set; }
diff --git a/ProxySU_Core/Views/ClientInfoWindow.xaml b/ProxySU_Core/Views/ClientInfoWindow.xaml
index 5e01deb..687bcc4 100644
--- a/ProxySU_Core/Views/ClientInfoWindow.xaml
+++ b/ProxySU_Core/Views/ClientInfoWindow.xaml
@@ -6,19 +6,309 @@
xmlns:metro="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:local="clr-namespace:ProxySU_Core.Views"
mc:Ignorable="d"
- Title="ClientInfoWindow" Height="450" Width="800">
+ Title="查看配置" Height="450" Width="800">
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ProxySU_Core/Views/ClientInfoWindow.xaml.cs b/ProxySU_Core/Views/ClientInfoWindow.xaml.cs
index 00a0f5d..600d0cb 100644
--- a/ProxySU_Core/Views/ClientInfoWindow.xaml.cs
+++ b/ProxySU_Core/Views/ClientInfoWindow.xaml.cs
@@ -1,4 +1,5 @@
using ProxySU_Core.Models;
+using ProxySU_Core.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -20,13 +21,14 @@ namespace ProxySU_Core.Views
///
public partial class ClientInfoWindow
{
- Record Record { get; set; }
+ public XraySettingsViewModel Settings { get; set; }
+
public ClientInfoWindow(Record record)
{
InitializeComponent();
- this.Record = record;
- DataContext = this.Record;
+ Settings = new XraySettingsViewModel(record.Settings);
+ DataContext = this;
}
}
}
diff --git a/ProxySU_Core/Views/RecordEditorWindow.xaml b/ProxySU_Core/Views/RecordEditorWindow.xaml
index b3d048a..785af14 100644
--- a/ProxySU_Core/Views/RecordEditorWindow.xaml
+++ b/ProxySU_Core/Views/RecordEditorWindow.xaml
@@ -8,7 +8,7 @@
xmlns:local="clr-namespace:ProxySU_Core.Views"
xmlns:converters="clr-namespace:ProxySU_Core.Converters"
mc:Ignorable="d"
- Title="RecordEditorWindow" Height="800" Width="710">
+ Title="编辑主机信息" Height="800" Width="710">
diff --git a/ProxySU_Core/Views/TerminalWindow.xaml b/ProxySU_Core/Views/TerminalWindow.xaml
index 30cb0e4..0820d2d 100644
--- a/ProxySU_Core/Views/TerminalWindow.xaml
+++ b/ProxySU_Core/Views/TerminalWindow.xaml
@@ -6,7 +6,7 @@
xmlns:local="clr-namespace:ProxySU_Core"
xmlns:metro="http://metro.mahapps.com/winfx/xaml/controls"
mc:Ignorable="d"
- Title="TerminalWindow" Height="500" Width="800">
+ Title="主机控制台" Height="500" Width="800">
-
+
+
-
+
+
+
+
+
+
+
+
+
+ Themezy
+
+
+ Themezy
+
+
+ HTML5 UP
+
+
+ template mo
+
diff --git a/ProxySU_Core/Views/TerminalWindow.xaml.cs b/ProxySU_Core/Views/TerminalWindow.xaml.cs
index d1e4d01..7646166 100644
--- a/ProxySU_Core/Views/TerminalWindow.xaml.cs
+++ b/ProxySU_Core/Views/TerminalWindow.xaml.cs
@@ -1,4 +1,5 @@
using MahApps.Metro.Controls.Dialogs;
+using Microsoft.Win32;
using ProxySU_Core.Models;
using ProxySU_Core.ViewModels;
using ProxySU_Core.ViewModels.Developers;
@@ -6,6 +7,8 @@ using ProxySU_Core.Views;
using Renci.SshNet;
using System;
using System.Collections.Generic;
+using System.ComponentModel;
+using System.Diagnostics;
using System.IO;
using System.Text;
using System.Threading.Tasks;
@@ -29,6 +32,8 @@ namespace ProxySU_Core
private readonly Terminal _vm;
private SshClient _sshClient;
+ XrayProject project;
+
public TerminalWindow(Record record)
{
InitializeComponent();
@@ -56,6 +61,7 @@ namespace ProxySU_Core
protected override void OnClosed(EventArgs e)
{
base.OnClosed(e);
+ _vm.HasConnected = false;
if (_sshClient != null)
_sshClient.Disconnect();
@@ -103,6 +109,9 @@ namespace ProxySU_Core
_sshClient = new SshClient(conneInfo);
_sshClient.Connect();
_vm.AddOutput("Connected");
+
+ _vm.HasConnected = true;
+ project = new XrayProject(_sshClient, Record.Settings, WriteShell);
}
private void WriteShell(string outShell)
@@ -116,17 +125,44 @@ namespace ProxySU_Core
private void Install(object sender, RoutedEventArgs e)
{
- XrayProject project = new XrayProject(
- _sshClient,
- Record.Settings,
- WriteShell);
-
Task.Factory.StartNew(() =>
{
project.Install();
});
}
+ private void InstallCert(object sender, RoutedEventArgs e)
+ {
+ Task.Factory.StartNew(() =>
+ {
+ project.InstallCert();
+ });
+ }
+
+ private void UploadWeb(object sender, RoutedEventArgs e)
+ {
+ var fileDialog = new OpenFileDialog();
+ fileDialog.FileOk += OnFileOk;
+ fileDialog.ShowDialog();
+ }
+
+ private void OnFileOk(object sender, CancelEventArgs e)
+ {
+ Task.Factory.StartNew(() =>
+ {
+ var file = sender as OpenFileDialog;
+ using (var stream = file.OpenFile())
+ {
+ project.UploadWeb(stream);
+ }
+ });
+ }
+
+ private void OpenLink(object sender, RoutedEventArgs e)
+ {
+ Hyperlink link = sender as Hyperlink;
+ Process.Start(new ProcessStartInfo(link.NavigateUri.AbsoluteUri));
+ }
}
}