From b20be2ac7541e39cfbabc46e7f5b98d9320d1bbd Mon Sep 17 00:00:00 2001 From: next-autumn Date: Wed, 26 May 2021 16:22:18 +0800 Subject: [PATCH] fix acme.sh update cert issue --- ProxySuper.Core/Models/Hosts/Host.cs | 26 ++++++++++++++++++- ProxySuper.Core/Models/Record.cs | 6 +++-- ProxySuper.Core/Services/ProjectBase.cs | 4 +-- .../ViewModels/NaiveProxyEditorViewModel.cs | 4 ++- ProxySuper.WPF/Controls/HostControl.xaml | 22 +++++++++++----- ProxySuper.WPF/Views/HomeView.xaml | 4 ++- 6 files changed, 52 insertions(+), 14 deletions(-) diff --git a/ProxySuper.Core/Models/Hosts/Host.cs b/ProxySuper.Core/Models/Hosts/Host.cs index af9c61e7..26a11a3d 100644 --- a/ProxySuper.Core/Models/Hosts/Host.cs +++ b/ProxySuper.Core/Models/Hosts/Host.cs @@ -1,8 +1,12 @@ -using System; +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; namespace ProxySuper.Core.Models.Hosts { @@ -30,5 +34,25 @@ public Host() public LocalProxy Proxy { get; set; } public LoginSecretType SecretType { get; set; } + + public IMvxCommand UploadPrivateKeyCommand => new MvxCommand(UploadPrivateKey); + + private void UploadPrivateKey() + { + var fileDialog = new OpenFileDialog(); + fileDialog.FileOk += OnFileOk; + fileDialog.ShowDialog(); + } + + private void OnFileOk(object sender, CancelEventArgs e) + { + var file = sender as OpenFileDialog; + PrivateKeyPath = file.FileName; + + Task.Delay(300).ContinueWith((t) => + { + MessageBox.Show("上传成功", "提示"); + }); + } } } diff --git a/ProxySuper.Core/Models/Record.cs b/ProxySuper.Core/Models/Record.cs index a1feec80..f4a6a67a 100644 --- a/ProxySuper.Core/Models/Record.cs +++ b/ProxySuper.Core/Models/Record.cs @@ -1,4 +1,5 @@ -using MvvmCross; +using Microsoft.Win32; +using MvvmCross; using MvvmCross.Commands; using MvvmCross.Navigation; using MvvmCross.ViewModels; @@ -10,6 +11,7 @@ using ProxySuper.Core.ViewModels; using System; using System.Collections.Generic; +using System.ComponentModel; using System.IO; using System.Linq; using System.Text; @@ -79,7 +81,6 @@ public bool IsChecked } } - public string GetShareLink() { if (Type == ProjectType.Xray) @@ -105,5 +106,6 @@ public string GetShareLink() return string.Empty; } + } } diff --git a/ProxySuper.Core/Services/ProjectBase.cs b/ProxySuper.Core/Services/ProjectBase.cs index 71ba5db2..3e525b31 100644 --- a/ProxySuper.Core/Services/ProjectBase.cs +++ b/ProxySuper.Core/Services/ProjectBase.cs @@ -646,12 +646,12 @@ protected void InstallCert(string dirPath, string certName, string keyName) // 申请证书 if (OnlyIpv6) { - var cmd = $"/root/.acme.sh/acme.sh --force --debug --issue --standalone -d {Parameters.Domain} --listen-v6"; + var cmd = $"/root/.acme.sh/acme.sh --force --debug --issue --standalone -d {Parameters.Domain} --listen-v6 --pre-hook \"service caddy stop\" --post-hook \"service caddy start\""; result = RunCmd(cmd); } else { - var cmd = $"/root/.acme.sh/acme.sh --force --debug --issue --standalone -d {Parameters.Domain}"; + var cmd = $"/root/.acme.sh/acme.sh --force --debug --issue --standalone -d {Parameters.Domain} --pre-hook \"service caddy stop\" --post-hook \"service caddy start\""; result = RunCmd(cmd); } diff --git a/ProxySuper.Core/ViewModels/NaiveProxyEditorViewModel.cs b/ProxySuper.Core/ViewModels/NaiveProxyEditorViewModel.cs index 442d1b60..e0e69e21 100644 --- a/ProxySuper.Core/ViewModels/NaiveProxyEditorViewModel.cs +++ b/ProxySuper.Core/ViewModels/NaiveProxyEditorViewModel.cs @@ -1,4 +1,5 @@ -using MvvmCross.Commands; +using Microsoft.Win32; +using MvvmCross.Commands; using MvvmCross.Navigation; using MvvmCross.ViewModels; using ProxySuper.Core.Models; @@ -7,6 +8,7 @@ using ProxySuper.Core.Services; using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/ProxySuper.WPF/Controls/HostControl.xaml b/ProxySuper.WPF/Controls/HostControl.xaml index b92cfe6c..0a5397f7 100644 --- a/ProxySuper.WPF/Controls/HostControl.xaml +++ b/ProxySuper.WPF/Controls/HostControl.xaml @@ -34,6 +34,7 @@ + @@ -55,20 +56,26 @@ Text="{Binding Host.Address}" VerticalContentAlignment="Center" /> -