From 0c146f176d27329ecb587b9632cb370f7e3011b9 Mon Sep 17 00:00:00 2001 From: next-autumn Date: Fri, 26 Mar 2021 11:28:41 +0800 Subject: [PATCH] add uninstall xray fix text issue --- ProxySU_Core/Models/Developers/Project.cs | 31 +++------- ProxySU_Core/Models/Developers/XrayProject.cs | 34 ++++++++++- .../server/05_inbounds/VLESS_TCP_XTLS.json | 6 +- .../ViewModels/XraySettingsViewModel.cs | 6 +- ProxySU_Core/Views/ClientInfoWindow.xaml | 2 +- ProxySU_Core/Views/MainWindow.xaml | 6 +- ProxySU_Core/Views/RecordEditorWindow.xaml | 58 +++++++++++-------- ProxySU_Core/Views/RecordEditorWindow.xaml.cs | 5 ++ ProxySU_Core/Views/TerminalWindow.xaml | 9 ++- ProxySU_Core/Views/TerminalWindow.xaml.cs | 22 ++++++- 10 files changed, 121 insertions(+), 58 deletions(-) diff --git a/ProxySU_Core/Models/Developers/Project.cs b/ProxySU_Core/Models/Developers/Project.cs index c0bc53a..414f3ad 100644 --- a/ProxySU_Core/Models/Developers/Project.cs +++ b/ProxySU_Core/Models/Developers/Project.cs @@ -357,29 +357,16 @@ namespace ProxySU_Core.Models.Developers RunCmd("rm -rf caddy_install.sh"); RunCmd("curl -o caddy_install.sh https://raw.githubusercontent.com/proxysu/shellscript/master/Caddy-Naive/caddy-naive-install.sh"); RunCmd("yes | bash caddy_install.sh"); + RunCmd("rm -rf caddy_install.sh"); + } - //if (CmdType == CmdType.Apt) - //{ - // RunCmd("sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https"); - // RunCmd("curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo apt-key add -"); - // RunCmd("curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee -a /etc/apt/sources.list.d/caddy-stable.list"); - // RunCmd(GetUpdateCmd()); - // RunCmd("sudo apt install caddy"); - //} - //else if (CmdType == CmdType.Dnf) - //{ - // RunCmd("echo y | dnf install 'dnf-command(copr)'"); - // RunCmd("echo y | dnf copr enable @caddy/caddy"); - // RunCmd(GetUpdateCmd()); - // RunCmd("dnf install caddy"); - //} - //else if (CmdType == CmdType.Yum) - //{ - // RunCmd("echo y | echo y | yum install yum-plugin-copr"); - // RunCmd("echo y | echo y | yum copr enable @caddy/caddy"); - // RunCmd(GetUpdateCmd()); - // RunCmd("yum install caddy"); - //} + protected void UninstallCaddy() + { + RunCmd("rm -rf caddy_install.sh"); + RunCmd("curl -o caddy_install.sh https://raw.githubusercontent.com/proxysu/shellscript/master/Caddy-Naive/caddy-naive-install.sh"); + RunCmd("yes | bash caddy_install.sh uninstall"); + RunCmd("rm -rf caddy_install.sh"); + RunCmd("rm -rf /usr/share/caddy"); } diff --git a/ProxySU_Core/Models/Developers/XrayProject.cs b/ProxySU_Core/Models/Developers/XrayProject.cs index 4c65360..309f5fe 100644 --- a/ProxySU_Core/Models/Developers/XrayProject.cs +++ b/ProxySU_Core/Models/Developers/XrayProject.cs @@ -69,7 +69,7 @@ namespace ProxySU_Core.Models.Developers ConfigureFirewall(); WriteOutput("防火墙配置完成"); - WriteOutput("同步系统和本地世间..."); + WriteOutput("同步系统和本地时间..."); SyncTimeDiff(); WriteOutput("时间同步完成"); @@ -96,10 +96,25 @@ namespace ProxySU_Core.Models.Developers } catch (Exception ex) { - MessageBox.Show("安装终止," + ex.Message); + var errorLog = "安装终止," + ex.Message; + WriteOutput(errorLog); + MessageBox.Show(errorLog); } } + public void Uninstall() + { + EnsureRootAuth(); + WriteOutput("卸载Caddy"); + UninstallCaddy(); + WriteOutput("卸载Xray"); + UninstallXray(); + WriteOutput("卸载证书"); + UninstallAcme(); + + WriteOutput("************ 卸载完成 ************"); + } + /// /// 更新xray内核 /// @@ -286,12 +301,24 @@ namespace ProxySU_Core.Models.Developers } + private void UninstallXray() + { + RunCmd("bash -c \"$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)\" @ remove"); + } + + private void UninstallAcme() + { + RunCmd("acme.sh --uninstall"); + RunCmd("rm -r ~/.acme.sh"); + } + private void InstallXrayWithCert() { RunCmd("bash -c \"$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)\" @ install"); if (!FileExists("/usr/local/bin/xray")) { + WriteOutput("Xray-Core安装失败,请联系开发者"); throw new Exception("Xray-Core安装失败,请联系开发者"); } @@ -333,6 +360,7 @@ namespace ProxySU_Core.Models.Developers } else { + WriteOutput("安装 acme.sh 失败,请联系开发者!"); throw new Exception("安装 acme.sh 失败,请联系开发者!"); } @@ -357,6 +385,7 @@ namespace ProxySU_Core.Models.Developers } else { + WriteOutput("申请证书失败,请联系开发者!"); throw new Exception("申请证书失败,请联系开发者!"); } @@ -370,6 +399,7 @@ namespace ProxySU_Core.Models.Developers } else { + WriteOutput("安装证书失败,请联系开发者!"); throw new Exception("安装证书失败,请联系开发者!"); } diff --git a/ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_TCP_XTLS.json b/ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_TCP_XTLS.json index d8cddd9..eab8363 100644 --- a/ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_TCP_XTLS.json +++ b/ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_TCP_XTLS.json @@ -15,7 +15,11 @@ "network": "tcp", "security": "xtls", "xtlsSettings": { - "alpn": [ "h2", "http/1.1" ], + "allowInsecure": false, + "minVersion": "1.2", + "alpn": [ + "http/1.1" + ], "certificates": [ { "certificateFile": "/usr/local/etc/xray/ssl/xray_ssl.crt", diff --git a/ProxySU_Core/ViewModels/XraySettingsViewModel.cs b/ProxySU_Core/ViewModels/XraySettingsViewModel.cs index f11d618..3f81ca1 100644 --- a/ProxySU_Core/ViewModels/XraySettingsViewModel.cs +++ b/ProxySU_Core/ViewModels/XraySettingsViewModel.cs @@ -23,7 +23,11 @@ namespace ProxySU_Core.ViewModels public string UUID { get => settings.UUID; - set => settings.UUID = value; + set + { + settings.UUID = value; + Notify("UUID"); + } } public string Domain diff --git a/ProxySU_Core/Views/ClientInfoWindow.xaml b/ProxySU_Core/Views/ClientInfoWindow.xaml index 3380bc7..a20fb09 100644 --- a/ProxySU_Core/Views/ClientInfoWindow.xaml +++ b/ProxySU_Core/Views/ClientInfoWindow.xaml @@ -254,7 +254,7 @@ + Header="VMESS-WebSocket-TLS">