From 6be1fdb84a0b9e87244e3c4526b9a5fdcf7888a2 Mon Sep 17 00:00:00 2001 From: autumn Date: Sat, 10 Jul 2021 11:57:56 +0800 Subject: [PATCH 01/26] =?UTF-8?q?=E4=BC=98=E5=8C=96Caddy=E5=AE=89=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProxySuper.Core/Models/Caddy.cs | 42 ++++++ ProxySuper.Core/ProxySuper.Core.csproj | 1 + ProxySuper.Core/Services/NaiveProxyProject.cs | 4 +- ProxySuper.Core/Services/ProjectBase.cs | 127 ++++++++++++------ ProxySuper.Core/Services/XrayProject.cs | 8 +- .../ViewModels/EnableRootViewModel.cs | 4 +- ProxySuper.WPF/Resources/Languages/en.xaml | 2 +- ProxySuper.WPF/Resources/Languages/zh_cn.xaml | 2 +- .../Views/BrookInstallerView.xaml.cs | 1 + ProxySuper.WPF/Views/EnableRootView.xaml | 2 +- .../Views/NaiveProxyInstallerView.xaml.cs | 1 + .../Views/TrojanGoInstallerView.xaml.cs | 1 + .../Views/XrayInstallerView.xaml.cs | 1 + 13 files changed, 141 insertions(+), 55 deletions(-) create mode 100644 ProxySuper.Core/Models/Caddy.cs diff --git a/ProxySuper.Core/Models/Caddy.cs b/ProxySuper.Core/Models/Caddy.cs new file mode 100644 index 0000000..93e3c22 --- /dev/null +++ b/ProxySuper.Core/Models/Caddy.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProxySuper.Core.Models +{ + public static class Caddy + { + public static string Service = @" +[Unit] +Description=Caddy +Documentation=https://caddyserver.com/docs/ +After=network.target network-online.target +Requires=network-online.target + +[Service] +#User=caddy +#Group=caddy +User=root +Group=root +ExecStart=/usr/bin/caddy run --environ --config /etc/caddy/Caddyfile +ExecReload=/usr/bin/caddy reload --config /etc/caddy/Caddyfile +TimeoutStopSec=5s +#LimitNOFILE=1048576 +#LimitNPROC=512 +PrivateTmp=true +ProtectSystem=full +#AmbientCapabilities=CAP_NET_BIND_SERVICE + +[Install] +WantedBy=multi-user.target +"; + + public static string DefaultCaddyFile = @" +:80 { + respond ""Hello world!""; +} +"; + } +} diff --git a/ProxySuper.Core/ProxySuper.Core.csproj b/ProxySuper.Core/ProxySuper.Core.csproj index 0fa66fd..5de987e 100644 --- a/ProxySuper.Core/ProxySuper.Core.csproj +++ b/ProxySuper.Core/ProxySuper.Core.csproj @@ -67,6 +67,7 @@ + diff --git a/ProxySuper.Core/Services/NaiveProxyProject.cs b/ProxySuper.Core/Services/NaiveProxyProject.cs index 9953763..0e53a52 100644 --- a/ProxySuper.Core/Services/NaiveProxyProject.cs +++ b/ProxySuper.Core/Services/NaiveProxyProject.cs @@ -127,13 +127,13 @@ namespace ProxySuper.Core.Services private void UploadCaddyFile(bool useCustomWeb = false) { var caddyStr = BuildConfig(useCustomWeb); - var stream = new MemoryStream(Encoding.UTF8.GetBytes(caddyStr)); if (FileExists("/etc/caddy/Caddyfile")) { RunCmd("mv /etc/caddy/Caddyfile /etc/caddy/Caddyfile.back"); } - UploadFile(stream, "/etc/caddy/Caddyfile"); + + RunCmd($"echo {caddyStr} > /etc/caddy/Caddyfile"); RunCmd("systemctl restart caddy"); } diff --git a/ProxySuper.Core/Services/ProjectBase.cs b/ProxySuper.Core/Services/ProjectBase.cs index e8d89dd..8986d42 100644 --- a/ProxySuper.Core/Services/ProjectBase.cs +++ b/ProxySuper.Core/Services/ProjectBase.cs @@ -1,10 +1,13 @@ using ProxySuper.Core.Helpers; +using ProxySuper.Core.Models; +using ProxySuper.Core.Models.Hosts; 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.Windows; namespace ProxySuper.Core.Services @@ -25,6 +28,8 @@ namespace ProxySuper.Core.Services public abstract class ProjectBase where TSettings : IProjectSettings { + + private SshClient _sshClient; protected Action WriteOutput; @@ -55,7 +60,9 @@ namespace ProxySuper.Core.Services var cmd = _sshClient.CreateCommand(cmdStr); WriteOutput(cmdStr); - var result = cmd.Execute(); + var exe = cmd.BeginExecute(); + var result = cmd.EndExecute(exe); + //var result = cmd.Execute(); WriteOutput(result); return result; } @@ -299,7 +306,6 @@ namespace ProxySuper.Core.Services /// protected void OpenPort(params int[] portList) { - string cmd; cmd = RunCmd("command -v firewall-cmd"); @@ -323,15 +329,19 @@ namespace ProxySuper.Core.Services else { cmd = RunCmd("command -v ufw"); - if (!string.IsNullOrEmpty(cmd)) + if (string.IsNullOrEmpty(cmd)) { - foreach (var port in portList) - { - RunCmd($"ufw allow {port}/tcp"); - RunCmd($"ufw allow {port}/udp"); - } - RunCmd("yes | ufw reload"); + RunCmd(GetInstallCmd("ufw")); + RunCmd("echo y | ufw enable"); } + + foreach (var port in portList) + { + RunCmd($"ufw allow {port}/tcp"); + RunCmd($"ufw allow {port}/udp"); + } + RunCmd("yes | ufw reload"); + } } @@ -425,30 +435,55 @@ namespace ProxySuper.Core.Services /// protected void InstallCaddy() { - if (CmdType == CmdType.Apt) + #region 二进制文件安装 + RunCmd("rm -rf caddy.tar.gz"); + RunCmd("rm -rf /etc/caddy"); + RunCmd("rm -rf /usr/share/caddy"); + + var url = "https://github.com/caddyserver/caddy/releases/download/v2.4.3/caddy_2.4.3_linux_amd64.tar.gz"; + if (ArchType == ArchType.arm) { - RunCmd("apt install -y debian-keyring debian-archive-keyring apt-transport-https"); - RunCmd("echo yes | curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo apt-key add -"); - RunCmd("echo yes | curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list"); - RunCmd("sudo apt -y update"); - RunCmd("sudo apt install -y caddy"); + url = "https://github.com/caddyserver/caddy/releases/download/v2.4.3/caddy_2.4.3_linux_armv7.tar.gz"; } - if (CmdType == CmdType.Dnf) - { - RunCmd("dnf install -y 'dnf-command(copr)'"); - RunCmd("dnf copr -y enable @caddy/caddy"); - RunCmd("dnf install -y caddy"); - } + RunCmd($"wget -O caddy.tar.gz {url}"); + RunCmd("mkdir /etc/caddy"); + RunCmd("tar -zxvf caddy.tar.gz caddy -C /etc/caddy"); + RunCmd("cp -rf /etc/caddy/caddy /usr/bin"); + WriteToFile(Caddy.DefaultCaddyFile, "/etc/caddy/Caddyfile"); + WriteToFile(Caddy.Service, "/etc/systemd/system/caddy.service"); + RunCmd("systemctl daemon-reload"); + RunCmd("systemctl enable caddy"); - if (CmdType == CmdType.Yum) - { - RunCmd("yum install -y yum-plugin-copr"); - RunCmd("yum copr -y enable @caddy/caddy"); - RunCmd("yum install -y caddy"); - } + RunCmd("mkdir /usr/share/caddy"); + #endregion - RunCmd("systemctl enable caddy.service"); + #region 官方安装步骤 + //if (CmdType == CmdType.Apt) + //{ + // RunCmd("apt install -y debian-keyring debian-archive-keyring apt-transport-https"); + // RunCmd("echo yes | curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo apt-key add -"); + // RunCmd("echo yes | curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list"); + // RunCmd("sudo apt -y update"); + // RunCmd("sudo apt install -y caddy"); + //} + + //if (CmdType == CmdType.Dnf) + //{ + // RunCmd("dnf install -y 'dnf-command(copr)'"); + // RunCmd("dnf copr -y enable @caddy/caddy"); + // RunCmd("dnf install -y caddy"); + //} + + //if (CmdType == CmdType.Yum) + //{ + // RunCmd("yum install -y yum-plugin-copr"); + // RunCmd("yum copr -y enable @caddy/caddy"); + // RunCmd("yum install -y caddy"); + //} + + //RunCmd("systemctl enable caddy.service"); + #endregion } /// @@ -457,21 +492,8 @@ namespace ProxySuper.Core.Services protected void UninstallCaddy() { RunCmd("systemctl stop caddy"); - if (CmdType == CmdType.Apt) - { - RunCmd("sudo apt -y remove caddy"); - } - - if (CmdType == CmdType.Dnf) - { - RunCmd("dnf -y remove caddy"); - } - - if (CmdType == CmdType.Yum) - { - RunCmd("yum -y remove caddy"); - } - + RunCmd("systemctl disable caddy"); + RunCmd("rm -rf /etc/systemd/system/caddy.service"); RunCmd("rm -rf /usr/bin/caddy"); RunCmd("rm -rf /usr/share/caddy"); RunCmd("rm -rf /etc/caddy"); @@ -748,6 +770,25 @@ namespace ProxySuper.Core.Services RunCmd($"chmod 755 {dirPath}"); } + protected void WriteToFile(string text, string path) + { + using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(text))) + { + using (var sftp = new SftpClient(_sshClient.ConnectionInfo)) + { + sftp.Connect(); + try + { + sftp.UploadFile(stream, path, true); + } + finally + { + sftp.Disconnect(); + } + } + } + } + /// /// 上传文件 /// diff --git a/ProxySuper.Core/Services/XrayProject.cs b/ProxySuper.Core/Services/XrayProject.cs index 9c743cb..8c4e4bf 100644 --- a/ProxySuper.Core/Services/XrayProject.cs +++ b/ProxySuper.Core/Services/XrayProject.cs @@ -164,7 +164,6 @@ namespace ProxySuper.Core.Services certName: "xray_ssl.crt", keyName: "xray_ssl.key"); - RunCmd("systemctl restart xray"); WriteOutput("************ 安装证书完成 ************"); } @@ -247,12 +246,12 @@ namespace ProxySuper.Core.Services private void UploadCaddyFile(bool useCustomWeb = false) { var configJson = XrayConfigBuilder.BuildCaddyConfig(Parameters, useCustomWeb); - var stream = new MemoryStream(Encoding.UTF8.GetBytes(configJson)); + if (FileExists("/etc/caddy/Caddyfile")) { RunCmd("mv /etc/caddy/Caddyfile /etc/caddy/Caddyfile.back"); } - UploadFile(stream, "/etc/caddy/Caddyfile"); + WriteToFile(configJson, "/etc/caddy/Caddyfile"); RunCmd("systemctl restart caddy"); } @@ -295,8 +294,7 @@ namespace ProxySuper.Core.Services var configJson = XrayConfigBuilder.BuildXrayConfig(Parameters); - var stream = new MemoryStream(Encoding.UTF8.GetBytes(configJson)); - UploadFile(stream, "/usr/local/etc/xray/config.json"); + WriteToFile(configJson, "/usr/local/etc/xray/config.json"); RunCmd("systemctl restart xray"); } diff --git a/ProxySuper.Core/ViewModels/EnableRootViewModel.cs b/ProxySuper.Core/ViewModels/EnableRootViewModel.cs index e4bc5d9..96b45d1 100644 --- a/ProxySuper.Core/ViewModels/EnableRootViewModel.cs +++ b/ProxySuper.Core/ViewModels/EnableRootViewModel.cs @@ -76,8 +76,8 @@ namespace ProxySuper.Core.ViewModels 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 "); + RunCmd(cmdPre + $"echo \"{setPassword}{setPassword}\" | sudo passwd root"); + RunCmd("sudo systemctl restart sshd"); RootUserName = "root"; RootPassword = setPassword.Trim('\n'); diff --git a/ProxySuper.WPF/Resources/Languages/en.xaml b/ProxySuper.WPF/Resources/Languages/en.xaml index e6ec17b..6e66ce3 100644 --- a/ProxySuper.WPF/Resources/Languages/en.xaml +++ b/ProxySuper.WPF/Resources/Languages/en.xaml @@ -9,7 +9,7 @@ Install Settings The following is a static web page connection provided by netizens, please check whether there is an index.html file by yourself - + Add Host Actions diff --git a/ProxySuper.WPF/Resources/Languages/zh_cn.xaml b/ProxySuper.WPF/Resources/Languages/zh_cn.xaml index c927ee1..8db8c0a 100644 --- a/ProxySuper.WPF/Resources/Languages/zh_cn.xaml +++ b/ProxySuper.WPF/Resources/Languages/zh_cn.xaml @@ -9,7 +9,7 @@ 安装 配置 如下是网友提供的静态网页连接,请自行检查是否有index.html文件 - + 添加主机 操作 diff --git a/ProxySuper.WPF/Views/BrookInstallerView.xaml.cs b/ProxySuper.WPF/Views/BrookInstallerView.xaml.cs index 03d4b47..071fa64 100644 --- a/ProxySuper.WPF/Views/BrookInstallerView.xaml.cs +++ b/ProxySuper.WPF/Views/BrookInstallerView.xaml.cs @@ -38,6 +38,7 @@ namespace ProxySuper.WPF.Views WriteOutput("正在登陆服务器 ..."); var conneInfo = CreateConnectionInfo(ViewModel.Host); + conneInfo.Timeout = TimeSpan.FromSeconds(60); _sshClient = new SshClient(conneInfo); try { diff --git a/ProxySuper.WPF/Views/EnableRootView.xaml b/ProxySuper.WPF/Views/EnableRootView.xaml index 549b1f8..a3c1fe1 100644 --- a/ProxySuper.WPF/Views/EnableRootView.xaml +++ b/ProxySuper.WPF/Views/EnableRootView.xaml @@ -62,7 +62,7 @@ - public partial class MTProxyInstallView : MvxWindow + public partial class MTProxyGoInstallView : MvxWindow { - public MTProxyInstallView() + public MTProxyGoInstallView() { InitializeComponent(); } From 6e61ef1ff60bfaf5ea8c5725b2a6941c33887613 Mon Sep 17 00:00:00 2001 From: autumn Date: Tue, 24 Aug 2021 10:36:41 +0800 Subject: [PATCH 19/26] =?UTF-8?q?MTProxy=20->=20MTProto=20|=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8Dssh=E7=A7=81=E9=92=A5=E5=B8=A6=E5=AF=86=E7=A0=81?= =?UTF-8?q?=E7=99=BB=E9=99=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProxySuper.Core/Models/Hosts/Host.cs | 1 + ...roxyGoSettings.cs => MTProtoGoSettings.cs} | 4 +- .../Models/Projects/ProjectType.cs | 2 +- ProxySuper.Core/Models/Record.cs | 8 +- ProxySuper.Core/ProxySuper.Core.csproj | 10 +-- ProxySuper.Core/Services/BrookService.cs | 3 + ...TProxyGoService.cs => MTProtoGoService.cs} | 18 ++-- ProxySuper.Core/Services/NaiveProxyService.cs | 3 + ProxySuper.Core/Services/ServiceBase.cs | 85 +++++++++++++------ ProxySuper.Core/Services/TrojanGoService.cs | 7 +- ProxySuper.Core/Services/V2rayService.cs | 10 +++ ProxySuper.Core/Services/XrayService.cs | 10 +++ ProxySuper.Core/ViewModels/HomeViewModel.cs | 22 ++--- ...ewModel.cs => MTProtoGoConfigViewModel.cs} | 6 +- ...ewModel.cs => MTProtoGoEditorViewModel.cs} | 14 +-- ...wModel.cs => MTProtoGoInstallViewModel.cs} | 10 +-- ProxySuper.WPF/ProxySuper.WPF.csproj | 18 ++-- ProxySuper.WPF/Resources/Languages/en.xaml | 10 +-- ProxySuper.WPF/Resources/Languages/tw_cn.xaml | 10 +-- ProxySuper.WPF/Resources/Languages/zh_cn.xaml | 10 +-- ProxySuper.WPF/Views/HomeView.xaml | 2 +- .../Views/MTProxyGo/MTProxyGoConfigView.xaml | 6 +- .../MTProxyGo/MTProxyGoConfigView.xaml.cs | 8 +- .../Views/MTProxyGo/MTProxyGoEditorView.xaml | 12 +-- .../MTProxyGo/MTProxyGoEditorView.xaml.cs | 8 +- .../Views/MTProxyGo/MTProxyGoInstallView.xaml | 6 +- .../MTProxyGo/MTProxyGoInstallView.xaml.cs | 8 +- .../NaiveProtoConfigView.xaml} | 2 +- .../NaiveProtoConfigView.xaml.cs} | 4 +- .../NaiveProtoEditorView.xaml} | 2 +- .../NaiveProtoEditorView.xaml.cs} | 4 +- .../NaiveProtoInstallView.xaml} | 2 +- .../NaiveProtoInstallView.xaml.cs} | 4 +- 33 files changed, 198 insertions(+), 131 deletions(-) rename ProxySuper.Core/Models/Projects/{MTProxyGoSettings.cs => MTProtoGoSettings.cs} (87%) rename ProxySuper.Core/Services/{MTProxyGoService.cs => MTProtoGoService.cs} (89%) rename ProxySuper.Core/ViewModels/{MTProxyGoConfigViewModel.cs => MTProtoGoConfigViewModel.cs} (64%) rename ProxySuper.Core/ViewModels/{MTProxyGoEditorViewModel.cs => MTProtoGoEditorViewModel.cs} (78%) rename ProxySuper.Core/ViewModels/{MTProxyGoInstallViewModel.cs => MTProtoGoInstallViewModel.cs} (89%) rename ProxySuper.WPF/Views/{NaiveProxy/NaiveProxyConfigView.xaml => NaiveProto/NaiveProtoConfigView.xaml} (96%) rename ProxySuper.WPF/Views/{NaiveProxy/NaiveProxyConfigView.xaml.cs => NaiveProto/NaiveProtoConfigView.xaml.cs} (70%) rename ProxySuper.WPF/Views/{NaiveProxy/NaiveProxyEditorView.xaml => NaiveProto/NaiveProtoEditorView.xaml} (98%) rename ProxySuper.WPF/Views/{NaiveProxy/NaiveProxyEditorView.xaml.cs => NaiveProto/NaiveProtoEditorView.xaml.cs} (70%) rename ProxySuper.WPF/Views/{NaiveProxy/NaiveProxyInstallView.xaml => NaiveProto/NaiveProtoInstallView.xaml} (99%) rename ProxySuper.WPF/Views/{NaiveProxy/NaiveProxyInstallView.xaml.cs => NaiveProto/NaiveProtoInstallView.xaml.cs} (85%) diff --git a/ProxySuper.Core/Models/Hosts/Host.cs b/ProxySuper.Core/Models/Hosts/Host.cs index 20baa6d..eb0b2c6 100644 --- a/ProxySuper.Core/Models/Hosts/Host.cs +++ b/ProxySuper.Core/Models/Hosts/Host.cs @@ -1,5 +1,6 @@ using Microsoft.Win32; using MvvmCross.Commands; +using Newtonsoft.Json; using System.ComponentModel; using System.Threading.Tasks; using System.Windows; diff --git a/ProxySuper.Core/Models/Projects/MTProxyGoSettings.cs b/ProxySuper.Core/Models/Projects/MTProtoGoSettings.cs similarity index 87% rename from ProxySuper.Core/Models/Projects/MTProxyGoSettings.cs rename to ProxySuper.Core/Models/Projects/MTProtoGoSettings.cs index 532207b..26cfabd 100644 --- a/ProxySuper.Core/Models/Projects/MTProxyGoSettings.cs +++ b/ProxySuper.Core/Models/Projects/MTProtoGoSettings.cs @@ -6,9 +6,9 @@ using System.Threading.Tasks; namespace ProxySuper.Core.Models.Projects { - public class MTProxyGoSettings : IProjectSettings + public class MTProtoGoSettings : IProjectSettings { - public MTProxyGoSettings() + public MTProtoGoSettings() { Port = 443; diff --git a/ProxySuper.Core/Models/Projects/ProjectType.cs b/ProxySuper.Core/Models/Projects/ProjectType.cs index 58549b0..15b3e48 100644 --- a/ProxySuper.Core/Models/Projects/ProjectType.cs +++ b/ProxySuper.Core/Models/Projects/ProjectType.cs @@ -7,6 +7,6 @@ NaiveProxy = 2, Brook = 3, V2ray = 4, - MTProxyGo = 5, + MTProtoGo = 5, } } diff --git a/ProxySuper.Core/Models/Record.cs b/ProxySuper.Core/Models/Record.cs index 522920a..0363a9b 100644 --- a/ProxySuper.Core/Models/Record.cs +++ b/ProxySuper.Core/Models/Record.cs @@ -42,14 +42,14 @@ namespace ProxySuper.Core.Models [JsonProperty("trojanGoSettings")] public TrojanGoSettings TrojanGoSettings { get; set; } - [JsonProperty("naiveProxySettings")] + [JsonProperty("naiveProtoSettings")] public NaiveProxySettings NaiveProxySettings { get; set; } [JsonProperty("brook")] public BrookSettings BrookSettings { get; set; } - [JsonProperty("mtProxyGoSettings")] - public MTProxyGoSettings MTProxyGoSettings { get; set; } + [JsonProperty("mtProtoGoSettings")] + public MTProtoGoSettings MTProtoGoSettings { get; set; } [JsonIgnore] @@ -65,7 +65,7 @@ namespace ProxySuper.Core.Models if (NaiveProxySettings != null) return ProjectType.NaiveProxy; - if (MTProxyGoSettings != null) return ProjectType.MTProxyGo; + if (MTProtoGoSettings != null) return ProjectType.MTProtoGo; return ProjectType.Brook; } diff --git a/ProxySuper.Core/ProxySuper.Core.csproj b/ProxySuper.Core/ProxySuper.Core.csproj index bb0752f..2b7140f 100644 --- a/ProxySuper.Core/ProxySuper.Core.csproj +++ b/ProxySuper.Core/ProxySuper.Core.csproj @@ -75,7 +75,7 @@ - + @@ -90,7 +90,7 @@ - + @@ -105,9 +105,9 @@ - - - + + + diff --git a/ProxySuper.Core/Services/BrookService.cs b/ProxySuper.Core/Services/BrookService.cs index aefa01a..d5904ff 100644 --- a/ProxySuper.Core/Services/BrookService.cs +++ b/ProxySuper.Core/Services/BrookService.cs @@ -1,5 +1,6 @@ using ProxySuper.Core.Models.Hosts; using ProxySuper.Core.Models.Projects; +using ProxySuper.Core.ViewModels; using System; using System.Collections.Generic; using System.Linq; @@ -72,6 +73,8 @@ namespace ProxySuper.Core.Services AppendCommand("分享连接:"); AppendCommand(ShareLink.BuildBrook(Settings)); + + NavigationService.Navigate(Settings); } catch (Exception ex) { diff --git a/ProxySuper.Core/Services/MTProxyGoService.cs b/ProxySuper.Core/Services/MTProtoGoService.cs similarity index 89% rename from ProxySuper.Core/Services/MTProxyGoService.cs rename to ProxySuper.Core/Services/MTProtoGoService.cs index acb6a24..b6992c4 100644 --- a/ProxySuper.Core/Services/MTProxyGoService.cs +++ b/ProxySuper.Core/Services/MTProtoGoService.cs @@ -1,5 +1,6 @@ using ProxySuper.Core.Models.Hosts; using ProxySuper.Core.Models.Projects; +using ProxySuper.Core.ViewModels; using System; using System.Collections.Generic; using System.Linq; @@ -9,9 +10,9 @@ using System.Windows; namespace ProxySuper.Core.Services { - public class MTProxyGoService : ServiceBase + public class MTProtoGoService : ServiceBase { - public MTProxyGoService(Host host, MTProxyGoSettings settings) : base(host, settings) + public MTProtoGoService(Host host, MTProtoGoSettings settings) : base(host, settings) { } @@ -53,9 +54,9 @@ namespace ProxySuper.Core.Services RunCmd($"echo \"bind-to=\\\"0.0.0.0:{Settings.Port}\\\"\" >> /etc/mtg.toml"); Progress.Percentage = 80; - Progress.Step = "7. 启动MTProxy服务"; + Progress.Step = "7. 启动MTProto服务"; RunCmd($"docker run -d -v /etc/mtg.toml:/config.toml --name=mtg --restart=always -p {Settings.Port + ":" + Settings.Port} nineseconds/mtg"); - Progress.Desc = "设置自启动MTProxy服务"; + Progress.Desc = "设置自启动MTProto服务"; Progress.Step = "安装完成"; Progress.Percentage = 100; @@ -64,6 +65,7 @@ namespace ProxySuper.Core.Services AppendCommand("Port: " + Settings.Port); AppendCommand("Secret: " + Settings.SecretText); + NavigationService.Navigate(Settings); } catch (Exception ex) { @@ -79,7 +81,7 @@ namespace ProxySuper.Core.Services try { Progress.Percentage = 0; - Progress.Step = "卸载MTProxy"; + Progress.Step = "卸载MTProto"; Progress.Desc = "检测系统环境"; EnsureRootUser(); @@ -106,9 +108,9 @@ namespace ProxySuper.Core.Services try { Progress.Percentage = 0; - Progress.Step = "更新MTProxy配置"; + Progress.Step = "更新MTProto配置"; - Progress.Desc = "暂停MTProxy服务"; + Progress.Desc = "暂停MTProto服务"; var cid = RunCmd("docker ps -q --filter name=mtg"); RunCmd($"docker stop {cid}"); Progress.Percentage = 50; @@ -122,7 +124,7 @@ namespace ProxySuper.Core.Services RunCmd($"echo \"bind-to=\\\"0.0.0.0:{Settings.Port}\\\"\" >> /etc/mtg.toml"); Progress.Percentage = 80; - Progress.Desc = "重启MTProxy服务"; + Progress.Desc = "重启MTProto服务"; RunCmd($"docker restart {cid}"); Progress.Percentage = 100; diff --git a/ProxySuper.Core/Services/NaiveProxyService.cs b/ProxySuper.Core/Services/NaiveProxyService.cs index dfbf008..47980f5 100644 --- a/ProxySuper.Core/Services/NaiveProxyService.cs +++ b/ProxySuper.Core/Services/NaiveProxyService.cs @@ -3,6 +3,7 @@ using MvvmCross.ViewModels; using ProxySuper.Core.Models; using ProxySuper.Core.Models.Hosts; using ProxySuper.Core.Models.Projects; +using ProxySuper.Core.ViewModels; using System; using System.Collections.Generic; using System.ComponentModel; @@ -69,6 +70,8 @@ namespace ProxySuper.Core.Services AppendCommand("分享连接:"); AppendCommand(ShareLink.BuildNaiveProxy(Settings)); + + NavigationService.Navigate(Settings); } catch (Exception ex) { diff --git a/ProxySuper.Core/Services/ServiceBase.cs b/ProxySuper.Core/Services/ServiceBase.cs index d6168b9..fcda9c0 100644 --- a/ProxySuper.Core/Services/ServiceBase.cs +++ b/ProxySuper.Core/Services/ServiceBase.cs @@ -1,4 +1,6 @@ -using ProxySuper.Core.Helpers; +using MvvmCross; +using MvvmCross.Navigation; +using ProxySuper.Core.Helpers; using ProxySuper.Core.Models; using ProxySuper.Core.Models.Hosts; using ProxySuper.Core.Models.Projects; @@ -9,6 +11,8 @@ using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows; +using System.Windows.Navigation; namespace ProxySuper.Core.Services { @@ -30,7 +34,6 @@ namespace ProxySuper.Core.Services { private Host _host; - private SshClient _sshClient; private ProjectProgress _progress; @@ -41,7 +44,11 @@ namespace ProxySuper.Core.Services Settings = settings; - _sshClient = new SshClient(CreateConnectionInfo()); + var connection = CreateConnectionInfo(); + if (connection != null) + { + _sshClient = new SshClient(connection); + } _progress = new ProjectProgress(); @@ -54,6 +61,8 @@ namespace ProxySuper.Core.Services IPv6 = string.Empty; IsOnlyIPv6 = false; + + NavigationService = Mvx.IoCProvider.Resolve(); } public string RunCmd(string command) @@ -89,12 +98,20 @@ namespace ProxySuper.Core.Services public bool IsOnlyIPv6 { get; set; } + public IMvxNavigationService NavigationService { get; set; } + #region 公用方法 public void Connect() { Task.Run(() => { + if (_sshClient == null) + { + MessageBox.Show("无法建立连接,连接参数有误!"); + return; + } + if (_sshClient.IsConnected == false) { Progress.Desc = ("正在与服务器建立连接"); @@ -115,7 +132,7 @@ namespace ProxySuper.Core.Services { Task.Run(() => { - _sshClient.Disconnect(); + _sshClient?.Disconnect(); }); } @@ -314,7 +331,6 @@ namespace ProxySuper.Core.Services } } - public void UninstallCaddy() { Progress.Desc = "关闭Caddy服务"; @@ -751,35 +767,52 @@ namespace ProxySuper.Core.Services private ConnectionInfo CreateConnectionInfo() { - var authMethods = new List(); - - if (!string.IsNullOrEmpty(_host.Password)) + try { - authMethods.Add(new PasswordAuthenticationMethod(_host.UserName, _host.Password)); - } + var authMethods = new List(); - if (_host.SecretType == LoginSecretType.PrivateKey) - { - authMethods.Add(new PrivateKeyAuthenticationMethod(_host.UserName, new PrivateKeyFile(_host.PrivateKeyPath))); - } + if (_host.SecretType == LoginSecretType.Password) + { + authMethods.Add(new PasswordAuthenticationMethod(_host.UserName, _host.Password)); + } + + if (_host.SecretType == LoginSecretType.PrivateKey) + { + PrivateKeyFile keyFile; + if (string.IsNullOrEmpty(_host.Password)) + { + keyFile = new PrivateKeyFile(_host.PrivateKeyPath); + } + else + { + keyFile = new PrivateKeyFile(_host.PrivateKeyPath, _host.Password); + } + authMethods.Add(new PrivateKeyAuthenticationMethod(_host.UserName, keyFile)); + } + + if (_host.Proxy.Type == ProxyTypes.None) + { + return new ConnectionInfo( + host: _host.Address, + username: _host.UserName, + authenticationMethods: authMethods.ToArray()); + } - if (_host.Proxy.Type == ProxyTypes.None) - { return new ConnectionInfo( host: _host.Address, + port: _host.Port, username: _host.UserName, + proxyType: _host.Proxy.Type, + proxyHost: _host.Proxy.Address, + proxyPort: _host.Proxy.Port, + proxyUsername: _host.Proxy.UserName, proxyPassword: _host.Proxy.Password, authenticationMethods: authMethods.ToArray()); } - - return new ConnectionInfo( - host: _host.Address, - port: _host.Port, - username: _host.UserName, - proxyType: _host.Proxy.Type, - proxyHost: _host.Proxy.Address, - proxyPort: _host.Proxy.Port, - proxyUsername: _host.Proxy.UserName, proxyPassword: _host.Proxy.Password, - authenticationMethods: authMethods.ToArray()); + catch (Exception ex) + { + MessageBox.Show(ex.Message); + return null; + } } #endregion } diff --git a/ProxySuper.Core/Services/TrojanGoService.cs b/ProxySuper.Core/Services/TrojanGoService.cs index eac9470..11264be 100644 --- a/ProxySuper.Core/Services/TrojanGoService.cs +++ b/ProxySuper.Core/Services/TrojanGoService.cs @@ -1,6 +1,7 @@ using Microsoft.Win32; using ProxySuper.Core.Models.Hosts; using ProxySuper.Core.Models.Projects; +using ProxySuper.Core.ViewModels; using System; using System.Collections.Generic; using System.ComponentModel; @@ -93,6 +94,10 @@ namespace ProxySuper.Core.Services { Progress.Step = "安装成功,请上传您的 TLS 证书。"; } + else + { + NavigationService.Navigate(Settings); + } } catch (Exception ex) { @@ -202,12 +207,12 @@ namespace ProxySuper.Core.Services { try { - EnsureRootUser(); Progress.Step = "续签证书"; Progress.Percentage = 0; Progress.Desc = "检测系统环境"; + EnsureRootUser(); EnsureSystemEnv(); Progress.Percentage = 20; diff --git a/ProxySuper.Core/Services/V2rayService.cs b/ProxySuper.Core/Services/V2rayService.cs index c6d5236..a061443 100644 --- a/ProxySuper.Core/Services/V2rayService.cs +++ b/ProxySuper.Core/Services/V2rayService.cs @@ -1,6 +1,7 @@ using Microsoft.Win32; using ProxySuper.Core.Models.Hosts; using ProxySuper.Core.Models.Projects; +using ProxySuper.Core.ViewModels; using System; using System.Collections.Generic; using System.ComponentModel; @@ -88,6 +89,10 @@ namespace ProxySuper.Core.Services { Progress.Step = "安装成功,请上传您的 TLS 证书。"; } + else + { + NavigationService.Navigate(Settings); + } } catch (Exception ex) { @@ -236,6 +241,11 @@ namespace ProxySuper.Core.Services Progress.Percentage = 0; Progress.Step = "续签证书"; + Progress.Desc = "检测系统环境"; + EnsureRootUser(); + EnsureSystemEnv(); + + Progress.Desc = "安装证书"; InstallCert( dirPath: "/usr/local/etc/v2ray/ssl", certName: "v2ray_ssl.crt", diff --git a/ProxySuper.Core/Services/XrayService.cs b/ProxySuper.Core/Services/XrayService.cs index 7dae882..dce2df3 100644 --- a/ProxySuper.Core/Services/XrayService.cs +++ b/ProxySuper.Core/Services/XrayService.cs @@ -2,6 +2,7 @@ using ProxySuper.Core.Helpers; using ProxySuper.Core.Models.Hosts; using ProxySuper.Core.Models.Projects; +using ProxySuper.Core.ViewModels; using System; using System.Collections.Generic; using System.ComponentModel; @@ -90,6 +91,10 @@ namespace ProxySuper.Core.Services { Progress.Step = "安装成功,请上传您的 TLS 证书。"; } + else + { + NavigationService.Navigate(Settings); + } } catch (Exception ex) { @@ -238,6 +243,11 @@ namespace ProxySuper.Core.Services Progress.Percentage = 0; Progress.Step = "续签证书"; + Progress.Desc = "检测系统环境"; + EnsureRootUser(); + EnsureSystemEnv(); + + Progress.Desc = "安装证书"; InstallCert( dirPath: "/usr/local/etc/xray/ssl", certName: "xray_ssl.crt", diff --git a/ProxySuper.Core/ViewModels/HomeViewModel.cs b/ProxySuper.Core/ViewModels/HomeViewModel.cs index 2d01c58..f01c7c5 100644 --- a/ProxySuper.Core/ViewModels/HomeViewModel.cs +++ b/ProxySuper.Core/ViewModels/HomeViewModel.cs @@ -100,7 +100,7 @@ namespace ProxySuper.Core.ViewModels public IMvxCommand AddNaiveProxyCommand => new MvxAsyncCommand(AddNaiveProxyRecord); - public IMvxCommand AddMTProxyGoCommand => new MvxAsyncCommand(AddMTProxyGoRecord); + public IMvxCommand AddMTProtoGoCommand => new MvxAsyncCommand(AddMTProtoGoRecord); public IMvxCommand AddBrookCommand => new MvxAsyncCommand(AddBrookRecord); @@ -155,14 +155,14 @@ namespace ProxySuper.Core.ViewModels SaveToJson(); } - public async Task AddMTProxyGoRecord() + public async Task AddMTProtoGoRecord() { Record record = new Record(); record.Id = Utils.GetTickID(); record.Host = new Host(); - record.MTProxyGoSettings = new MTProxyGoSettings(); + record.MTProtoGoSettings = new MTProtoGoSettings(); - var result = await _navigationService.Navigate(record); + var result = await _navigationService.Navigate(record); if (result == null) return; Records.Add(result); @@ -247,13 +247,13 @@ namespace ProxySuper.Core.ViewModels record.Host = result.Host; record.BrookSettings = result.BrookSettings; } - if (record.Type == ProjectType.MTProxyGo) + if (record.Type == ProjectType.MTProtoGo) { - result = await _navigationService.Navigate(record); + result = await _navigationService.Navigate(record); if (result == null) return; record.Host = result.Host; - record.MTProxyGoSettings = result.MTProxyGoSettings; + record.MTProtoGoSettings = result.MTProtoGoSettings; } SaveToJson(); @@ -299,9 +299,9 @@ namespace ProxySuper.Core.ViewModels { await _navigationService.Navigate(record.BrookSettings); } - if (record.Type == ProjectType.MTProxyGo) + if (record.Type == ProjectType.MTProtoGo) { - await _navigationService.Navigate(record.MTProxyGoSettings); + await _navigationService.Navigate(record.MTProtoGoSettings); } } @@ -331,9 +331,9 @@ namespace ProxySuper.Core.ViewModels { await _navigationService.Navigate(record); } - if (record.Type == ProjectType.MTProxyGo) + if (record.Type == ProjectType.MTProtoGo) { - await _navigationService.Navigate(record); + await _navigationService.Navigate(record); } SaveToJson(); diff --git a/ProxySuper.Core/ViewModels/MTProxyGoConfigViewModel.cs b/ProxySuper.Core/ViewModels/MTProtoGoConfigViewModel.cs similarity index 64% rename from ProxySuper.Core/ViewModels/MTProxyGoConfigViewModel.cs rename to ProxySuper.Core/ViewModels/MTProtoGoConfigViewModel.cs index b9473dc..a6058ca 100644 --- a/ProxySuper.Core/ViewModels/MTProxyGoConfigViewModel.cs +++ b/ProxySuper.Core/ViewModels/MTProtoGoConfigViewModel.cs @@ -9,11 +9,11 @@ using System.Threading.Tasks; namespace ProxySuper.Core.ViewModels { - public class MTProxyGoConfigViewModel : MvxViewModel + public class MTProtoGoConfigViewModel : MvxViewModel { - public MTProxyGoSettings Settings { get; set; } + public MTProtoGoSettings Settings { get; set; } - public override void Prepare(MTProxyGoSettings parameter) + public override void Prepare(MTProtoGoSettings parameter) { Settings = parameter; } diff --git a/ProxySuper.Core/ViewModels/MTProxyGoEditorViewModel.cs b/ProxySuper.Core/ViewModels/MTProtoGoEditorViewModel.cs similarity index 78% rename from ProxySuper.Core/ViewModels/MTProxyGoEditorViewModel.cs rename to ProxySuper.Core/ViewModels/MTProtoGoEditorViewModel.cs index 4ab5336..fa983bf 100644 --- a/ProxySuper.Core/ViewModels/MTProxyGoEditorViewModel.cs +++ b/ProxySuper.Core/ViewModels/MTProtoGoEditorViewModel.cs @@ -13,9 +13,9 @@ using System.Threading.Tasks; namespace ProxySuper.Core.ViewModels { - public class MTProxyGoEditorViewModel : MvxViewModel + public class MTProtoGoEditorViewModel : MvxViewModel { - public MTProxyGoEditorViewModel(IMvxNavigationService navigationService) + public MTProtoGoEditorViewModel(IMvxNavigationService navigationService) { NavigationService = navigationService; } @@ -30,7 +30,7 @@ namespace ProxySuper.Core.ViewModels public Host Host { get; set; } - public MTProxyGoSettings Settings { get; set; } + public MTProtoGoSettings Settings { get; set; } public override void Prepare(Record parameter) { @@ -38,7 +38,7 @@ namespace ProxySuper.Core.ViewModels Id = record.Id; Host = record.Host; - Settings = record.MTProxyGoSettings; + Settings = record.MTProtoGoSettings; } private void Save() @@ -47,7 +47,7 @@ namespace ProxySuper.Core.ViewModels { Id = this.Id, Host = this.Host, - MTProxyGoSettings = Settings, + MTProtoGoSettings = Settings, }); } @@ -57,10 +57,10 @@ namespace ProxySuper.Core.ViewModels { Id = this.Id, Host = this.Host, - MTProxyGoSettings = Settings, + MTProtoGoSettings = Settings, }; NavigationService.Close(this, record); - NavigationService.Navigate(record); + NavigationService.Navigate(record); } } } diff --git a/ProxySuper.Core/ViewModels/MTProxyGoInstallViewModel.cs b/ProxySuper.Core/ViewModels/MTProtoGoInstallViewModel.cs similarity index 89% rename from ProxySuper.Core/ViewModels/MTProxyGoInstallViewModel.cs rename to ProxySuper.Core/ViewModels/MTProtoGoInstallViewModel.cs index 74888c1..794d4f1 100644 --- a/ProxySuper.Core/ViewModels/MTProxyGoInstallViewModel.cs +++ b/ProxySuper.Core/ViewModels/MTProtoGoInstallViewModel.cs @@ -13,26 +13,26 @@ using System.Threading.Tasks; namespace ProxySuper.Core.ViewModels { - public class MTProxyGoInstallViewModel : MvxViewModel + public class MTProtoGoInstallViewModel : MvxViewModel { Host _host; - MTProxyGoSettings _settings; + MTProtoGoSettings _settings; - MTProxyGoService _mtproxyService; + MTProtoGoService _mtproxyService; Action _onSave; public override void Prepare(Record parameter) { _host = parameter.Host; - _settings = parameter.MTProxyGoSettings; + _settings = parameter.MTProtoGoSettings; _onSave = parameter.OnSave; } public override Task Initialize() { - _mtproxyService = new MTProxyGoService(_host, _settings); + _mtproxyService = new MTProtoGoService(_host, _settings); _mtproxyService.Progress.StepUpdate = () => RaisePropertyChanged("Progress"); _mtproxyService.Progress.LogsUpdate = () => RaisePropertyChanged("Logs"); _mtproxyService.Connect(); diff --git a/ProxySuper.WPF/ProxySuper.WPF.csproj b/ProxySuper.WPF/ProxySuper.WPF.csproj index bc4d57b..d10a899 100644 --- a/ProxySuper.WPF/ProxySuper.WPF.csproj +++ b/ProxySuper.WPF/ProxySuper.WPF.csproj @@ -144,14 +144,14 @@ MTProxyGoInstallView.xaml - - NaiveProxyConfigView.xaml + + NaiveProtoConfigView.xaml - - NaiveProxyEditorView.xaml + + NaiveProtoEditorView.xaml - - NaiveProxyInstallView.xaml + + NaiveProtoInstallView.xaml ShareLinkView.xaml @@ -299,15 +299,15 @@ Designer MSBuild:Compile - + Designer MSBuild:Compile - + Designer MSBuild:Compile - + Designer MSBuild:Compile diff --git a/ProxySuper.WPF/Resources/Languages/en.xaml b/ProxySuper.WPF/Resources/Languages/en.xaml index f9872c9..50a5e08 100644 --- a/ProxySuper.WPF/Resources/Languages/en.xaml +++ b/ProxySuper.WPF/Resources/Languages/en.xaml @@ -127,9 +127,9 @@ Password GuiseHost - - Address - Port - Cleantext - Secret + + Address + Port + Cleantext + Secret \ No newline at end of file diff --git a/ProxySuper.WPF/Resources/Languages/tw_cn.xaml b/ProxySuper.WPF/Resources/Languages/tw_cn.xaml index dce35ce..48c8c5f 100644 --- a/ProxySuper.WPF/Resources/Languages/tw_cn.xaml +++ b/ProxySuper.WPF/Resources/Languages/tw_cn.xaml @@ -127,9 +127,9 @@ 密碼 偽裝網站 - - 域名/IP - 端口 - 加密前字符 - 密鑰 + + 域名/IP + 端口 + 加密前字符 + 密鑰 \ No newline at end of file diff --git a/ProxySuper.WPF/Resources/Languages/zh_cn.xaml b/ProxySuper.WPF/Resources/Languages/zh_cn.xaml index 4aeb1bd..c33beca 100644 --- a/ProxySuper.WPF/Resources/Languages/zh_cn.xaml +++ b/ProxySuper.WPF/Resources/Languages/zh_cn.xaml @@ -128,9 +128,9 @@ 密码 伪装网站 - - 域名/IP - 端口 - 加密前字符 - 密钥 + + 域名/IP + 端口 + 加密前字符 + 密钥 \ No newline at end of file diff --git a/ProxySuper.WPF/Views/HomeView.xaml b/ProxySuper.WPF/Views/HomeView.xaml index 7e5d14b..34c5ff3 100644 --- a/ProxySuper.WPF/Views/HomeView.xaml +++ b/ProxySuper.WPF/Views/HomeView.xaml @@ -17,7 +17,7 @@ - + diff --git a/ProxySuper.WPF/Views/MTProxyGo/MTProxyGoConfigView.xaml b/ProxySuper.WPF/Views/MTProxyGo/MTProxyGoConfigView.xaml index 064606e..238cbf4 100644 --- a/ProxySuper.WPF/Views/MTProxyGo/MTProxyGoConfigView.xaml +++ b/ProxySuper.WPF/Views/MTProxyGo/MTProxyGoConfigView.xaml @@ -1,14 +1,14 @@ - + Title="MTProto-Go节点配置" Height="450" Width="800"> diff --git a/ProxySuper.WPF/Views/MTProxyGo/MTProxyGoConfigView.xaml.cs b/ProxySuper.WPF/Views/MTProxyGo/MTProxyGoConfigView.xaml.cs index d64b71e..243d354 100644 --- a/ProxySuper.WPF/Views/MTProxyGo/MTProxyGoConfigView.xaml.cs +++ b/ProxySuper.WPF/Views/MTProxyGo/MTProxyGoConfigView.xaml.cs @@ -13,14 +13,14 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; -namespace ProxySuper.WPF.Views.MTProxyGo +namespace ProxySuper.WPF.Views.MTProtoGo { /// - /// MTProxyGoConfigView.xaml 的交互逻辑 + /// MTProtoGoConfigView.xaml 的交互逻辑 /// - public partial class MTProxyGoConfigView : MvxWindow + public partial class MTProtoGoConfigView : MvxWindow { - public MTProxyGoConfigView() + public MTProtoGoConfigView() { InitializeComponent(); } diff --git a/ProxySuper.WPF/Views/MTProxyGo/MTProxyGoEditorView.xaml b/ProxySuper.WPF/Views/MTProxyGo/MTProxyGoEditorView.xaml index da02520..b410ee2 100644 --- a/ProxySuper.WPF/Views/MTProxyGo/MTProxyGoEditorView.xaml +++ b/ProxySuper.WPF/Views/MTProxyGo/MTProxyGoEditorView.xaml @@ -1,9 +1,9 @@ - + Title="MTProto-Go编辑配置" Height="600" Width="1000"> @@ -36,13 +36,13 @@ - diff --git a/ProxySuper.WPF/Views/MTProxyGo/MTProxyGoEditorView.xaml.cs b/ProxySuper.WPF/Views/MTProxyGo/MTProxyGoEditorView.xaml.cs index 1ba51ba..231813a 100644 --- a/ProxySuper.WPF/Views/MTProxyGo/MTProxyGoEditorView.xaml.cs +++ b/ProxySuper.WPF/Views/MTProxyGo/MTProxyGoEditorView.xaml.cs @@ -13,14 +13,14 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; -namespace ProxySuper.WPF.Views.MTProxyGo +namespace ProxySuper.WPF.Views.MTProtoGo { /// - /// MTProxyGoEditorView.xaml 的交互逻辑 + /// MTProtoGoEditorView.xaml 的交互逻辑 /// - public partial class MTProxyGoEditorView : MvxWindow + public partial class MTProtoGoEditorView : MvxWindow { - public MTProxyGoEditorView() + public MTProtoGoEditorView() { InitializeComponent(); } diff --git a/ProxySuper.WPF/Views/MTProxyGo/MTProxyGoInstallView.xaml b/ProxySuper.WPF/Views/MTProxyGo/MTProxyGoInstallView.xaml index a67d821..ba763e3 100644 --- a/ProxySuper.WPF/Views/MTProxyGo/MTProxyGoInstallView.xaml +++ b/ProxySuper.WPF/Views/MTProxyGo/MTProxyGoInstallView.xaml @@ -1,14 +1,14 @@ - + Title="MTProto-Go安装" Height="600" Width="1000"> diff --git a/ProxySuper.WPF/Views/MTProxyGo/MTProxyGoInstallView.xaml.cs b/ProxySuper.WPF/Views/MTProxyGo/MTProxyGoInstallView.xaml.cs index 377c8d9..5f7af9c 100644 --- a/ProxySuper.WPF/Views/MTProxyGo/MTProxyGoInstallView.xaml.cs +++ b/ProxySuper.WPF/Views/MTProxyGo/MTProxyGoInstallView.xaml.cs @@ -13,14 +13,14 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; -namespace ProxySuper.WPF.Views.MTProxyGo +namespace ProxySuper.WPF.Views.MTProtoGo { /// - /// MTProxyInstallView.xaml 的交互逻辑 + /// MTProtoInstallView.xaml 的交互逻辑 /// - public partial class MTProxyGoInstallView : MvxWindow + public partial class MTProtoGoInstallView : MvxWindow { - public MTProxyGoInstallView() + public MTProtoGoInstallView() { InitializeComponent(); } diff --git a/ProxySuper.WPF/Views/NaiveProxy/NaiveProxyConfigView.xaml b/ProxySuper.WPF/Views/NaiveProto/NaiveProtoConfigView.xaml similarity index 96% rename from ProxySuper.WPF/Views/NaiveProxy/NaiveProxyConfigView.xaml rename to ProxySuper.WPF/Views/NaiveProto/NaiveProtoConfigView.xaml index c5b29ac..ab48e08 100644 --- a/ProxySuper.WPF/Views/NaiveProxy/NaiveProxyConfigView.xaml +++ b/ProxySuper.WPF/Views/NaiveProto/NaiveProtoConfigView.xaml @@ -1,4 +1,4 @@ - /// NaiveProxyConfigView.xaml 的交互逻辑 /// - public partial class NaiveProxyConfigView : MvxWindow + public partial class NaiveProtoConfigView : MvxWindow { - public NaiveProxyConfigView() + public NaiveProtoConfigView() { InitializeComponent(); } diff --git a/ProxySuper.WPF/Views/NaiveProxy/NaiveProxyEditorView.xaml b/ProxySuper.WPF/Views/NaiveProto/NaiveProtoEditorView.xaml similarity index 98% rename from ProxySuper.WPF/Views/NaiveProxy/NaiveProxyEditorView.xaml rename to ProxySuper.WPF/Views/NaiveProto/NaiveProtoEditorView.xaml index 43158fb..cbd2b58 100644 --- a/ProxySuper.WPF/Views/NaiveProxy/NaiveProxyEditorView.xaml +++ b/ProxySuper.WPF/Views/NaiveProto/NaiveProtoEditorView.xaml @@ -1,4 +1,4 @@ - /// NaiveProxyEditorView.xaml 的交互逻辑 /// - public partial class NaiveProxyEditorView : MvxWindow + public partial class NaiveProtoEditorView : MvxWindow { - public NaiveProxyEditorView() + public NaiveProtoEditorView() { InitializeComponent(); } diff --git a/ProxySuper.WPF/Views/NaiveProxy/NaiveProxyInstallView.xaml b/ProxySuper.WPF/Views/NaiveProto/NaiveProtoInstallView.xaml similarity index 99% rename from ProxySuper.WPF/Views/NaiveProxy/NaiveProxyInstallView.xaml rename to ProxySuper.WPF/Views/NaiveProto/NaiveProtoInstallView.xaml index aecd9c0..0798cd3 100644 --- a/ProxySuper.WPF/Views/NaiveProxy/NaiveProxyInstallView.xaml +++ b/ProxySuper.WPF/Views/NaiveProto/NaiveProtoInstallView.xaml @@ -1,4 +1,4 @@ - /// NaiveProxyInstallViewModel.xaml 的交互逻辑 /// - public partial class NaiveProxyInstallView : MvxWindow + public partial class NaiveProtoInstallView : MvxWindow { - public NaiveProxyInstallView() + public NaiveProtoInstallView() { InitializeComponent(); } From 7869e771268a0bf028497e7dd7c03d9dc6aefc80 Mon Sep 17 00:00:00 2001 From: next-autumn <73510229+next-autumn@users.noreply.github.com> Date: Tue, 24 Aug 2021 10:44:24 +0800 Subject: [PATCH 20/26] Update README.md --- README.md | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index a0aedf9..800f065 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # ProxySU -V2ray, Xray,Trojan, NaiveProxy, Trojan-Go, Brook,BBR install tools for windows。 -V2ray,Xray,Trojan,NaiveProxy, Trojan-Go, Brook 及相关插件。支持纯ipv6主机一键安装代理。 +V2ray, Xray, Trojan, NaiveProxy, Trojan-Go, MTProto Go, Brook,BBR install tools for windows。 +V2ray,Xray, Trojan,NaiveProxy, Trojan-Go, MTProto Go, Brook 及相关插件。支持纯ipv6主机一键安装代理。 BBR一键开启(仅支持CentOS8/Debian9/10/Ubuntu18.04及以上),支持语言:English、简体中文、正体(繁体)中文。 编译环境Visual Studio 2017 使用WPF界面。可一键安装 V2ray/Xray, Shadowsocks, Trojan, Trojan-Go, NaiveProxy, Brook 后续还会再添加其他。 @@ -110,13 +110,3 @@ Microsoft [.NET Framework 4.7.2](https://dotnet.microsoft.com/download/dotnet-fr * 在线提问 https://github.com/proxysu/windows/issues 在使用遇到问题时,请先看一下[常见问题集锦](https://github.com/proxysu/windows/wiki/CommonError),如果还不能解决,可以到以上平台询问,个人精力有限,尽力解答。 -## v1.0.0发布小记 - 足足用了近两个月的业余时间,终于做成一个功能还算完善的版本。虽是一个简单的小工具,没想到对于我这个初学C#的人,还是有点小吃力,如果不是因为新冠肺炎疫情,被禁足在家,还真没时间。学习C#,为啥编写这样一个小工具软件来练手?现在一键安装脚本多的是,这样的工具还有必要吗?咋说呢?我也不知道有多少人会喜欢这个小工具,只是觉得自己用着方便,也想方便一下别人吧,喜欢用就用,不喜欢,也随意。 - 生意又忙起来了,对于我这个业余的编程爱好者,可能没有多少业余时间继续折腾了,尽力吧。 - (记于2020.4.18) -## V2.0.0发布小记 - 哎呀吗!增加一个多语言切换,真是麻烦啊,最初就没有想支持多语言(PS:其实是不会`^_^`) 。中途再添加,真的是累啊!整了一个星期才完事。主要代码简单,就是把所有的中文显示信息替换,那真是一个晕!!英文水平太菜,用谷歌翻译做的,凑合着用吧。 -## V3.0.0发布小记 - 旧版本功能大而全,如果配置需要修改,或操作多个主机,就没办法做了。也总结了开发WPF经验后,尝试着改变一下,结果衍生了一个尝试的版本。 -## V4.0.1发布小记 - 在V3.x.x版本中,属于尝试性的改进和开发,应大家要求,在v4版本中保留了TrojanGo、NaiveProxy...。 From 2b1e65adb4b35c250370b24fdc52d27e0b2928ce Mon Sep 17 00:00:00 2001 From: next-autumn <73510229+next-autumn@users.noreply.github.com> Date: Tue, 24 Aug 2021 10:49:32 +0800 Subject: [PATCH 21/26] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 800f065..d3ade94 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ V2ray, Xray, Trojan, NaiveProxy, Trojan-Go, MTProto Go, Brook,BBR install tools V2ray,Xray, Trojan,NaiveProxy, Trojan-Go, MTProto Go, Brook 及相关插件。支持纯ipv6主机一键安装代理。 BBR一键开启(仅支持CentOS8/Debian9/10/Ubuntu18.04及以上),支持语言:English、简体中文、正体(繁体)中文。 -编译环境Visual Studio 2017 使用WPF界面。可一键安装 V2ray/Xray, Shadowsocks, Trojan, Trojan-Go, NaiveProxy, Brook 后续还会再添加其他。 +编译环境Visual Studio 2019 使用WPF界面。可一键安装 V2ray/Xray, Shadowsocks, Trojan, Trojan-Go, NaiveProxy, MTProto Go, Brook 后续还会再添加其他。 ![photo_2021-05-31_17-23-29](https://user-images.githubusercontent.com/73510229/120171754-f46ffd00-c234-11eb-8105-4e6a941a65bb.jpg) ![photo_2021-05-31_17-24-29](https://user-images.githubusercontent.com/73510229/120171966-297c4f80-c235-11eb-921a-2ddebad5dc58.jpg) @@ -20,8 +20,8 @@ BBR一键开启(仅支持CentOS8/Debian9/10/Ubuntu18.04及以上),支持语 ##### 支持的VPS系统为: * CentOS 7/8 -* Debian 8/9/10 (推荐 10) -* Ubuntu 16.04及以上 +* Debian 9/10 (推荐 10) +* Ubuntu 18及以上 (注意:如果系统启用了SELinux且工作在Enforcing模式下时,需要将Enforcing更改为Permissive模式,否则使用WebSocket+TLS+Web时,Caddy的service无法开机启动,这种情形一般出现在Centos7/8中,程序在安装过程中将自动处理。) From 553cb7b43175f3dff53251df847178b68fa0c988 Mon Sep 17 00:00:00 2001 From: next-autumn <73510229+next-autumn@users.noreply.github.com> Date: Tue, 24 Aug 2021 11:07:40 +0800 Subject: [PATCH 22/26] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d3ade94..bb57f0f 100644 --- a/README.md +++ b/README.md @@ -92,9 +92,9 @@ Let's Encrypt证书申请频率的限制 * 正式版(正式发布的版本,新功能完善后发布) [下载](https://github.com/proxysu/windows/releases) -## Windows系统需要安装net4.7.2或以上 +## Windows系统需要安装net4.8或以上 -Microsoft [.NET Framework 4.7.2](https://dotnet.microsoft.com/download/dotnet-framework/thank-you/net472-offline-installer) or higher +Microsoft [.NET Framework 4.8](https://dotnet.microsoft.com/download/dotnet-framework/thank-you/net472-offline-installer) or higher ## 使用的C# 库 [SSH.NET --------------- https://github.com/sshnet/SSH.NET](https://github.com/sshnet/SSH.NET) From 81ae945e4f7d739b5cc7e97d25a78082cc0f71d4 Mon Sep 17 00:00:00 2001 From: autumn Date: Wed, 25 Aug 2021 10:04:41 +0800 Subject: [PATCH 23/26] update v2rayinstallview title --- ProxySuper.WPF/Views/V2ray/V2rayInstallView.xaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ProxySuper.WPF/Views/V2ray/V2rayInstallView.xaml b/ProxySuper.WPF/Views/V2ray/V2rayInstallView.xaml index c6b6bab..38cc14b 100644 --- a/ProxySuper.WPF/Views/V2ray/V2rayInstallView.xaml +++ b/ProxySuper.WPF/Views/V2ray/V2rayInstallView.xaml @@ -8,7 +8,7 @@ xmlns:views="clr-namespace:MvvmCross.Platforms.Wpf.Views;assembly=MvvmCross.Platforms.Wpf" mc:Ignorable="d" WindowStartupLocation="CenterScreen" - Title="Trojan-Go安装" Height="600" Width="1000"> + Title="V2ray安装" Height="600" Width="1000"> From d5e1125c3684a5f32b2494da8bf0e4b4a0828634 Mon Sep 17 00:00:00 2001 From: autumn Date: Wed, 25 Aug 2021 11:12:47 +0800 Subject: [PATCH 24/26] fix issue 188 --- ProxySuper.Core/Services/ServiceBase.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ProxySuper.Core/Services/ServiceBase.cs b/ProxySuper.Core/Services/ServiceBase.cs index fcda9c0..7558a60 100644 --- a/ProxySuper.Core/Services/ServiceBase.cs +++ b/ProxySuper.Core/Services/ServiceBase.cs @@ -289,7 +289,7 @@ namespace ProxySuper.Core.Services #endregion // 安装证书 - Progress.Desc = ("安装Xray证书"); + Progress.Desc = ("安装TLS证书"); RunCmd($"mkdir -p {dirPath}"); RunCmd($"/root/.acme.sh/acme.sh --installcert -d {Settings.Domain} --certpath {certPath} --keypath {keyPath} --capath {certPath}"); @@ -676,6 +676,8 @@ namespace ProxySuper.Core.Services RunCmd("systemctl restart firewalld"); } + // 保持 ssh 端口开放 + RunCmd($"firewall-cmd --add-port={_host.Port}/tcp --permanent"); foreach (var port in portList) { RunCmd($"firewall-cmd --add-port={port}/tcp --permanent"); @@ -693,6 +695,8 @@ namespace ProxySuper.Core.Services RunCmd("echo y | ufw enable"); } + // 保持 ssh 端口开放 + RunCmd($"ufw allow {_host.Port}/tcp"); foreach (var port in portList) { RunCmd($"ufw allow {port}/tcp"); From 524c341e9a4b0eeca690df73573ac466759225e1 Mon Sep 17 00:00:00 2001 From: next-autumn <73510229+next-autumn@users.noreply.github.com> Date: Fri, 27 Aug 2021 16:07:48 +0800 Subject: [PATCH 25/26] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bb57f0f..6f4a85d 100644 --- a/README.md +++ b/README.md @@ -94,7 +94,7 @@ Let's Encrypt证书申请频率的限制 ## Windows系统需要安装net4.8或以上 -Microsoft [.NET Framework 4.8](https://dotnet.microsoft.com/download/dotnet-framework/thank-you/net472-offline-installer) or higher +Microsoft [.NET Framework 4.8](https://dotnet.microsoft.com/download/dotnet-framework/thank-you/net48-offline-installer) or higher ## 使用的C# 库 [SSH.NET --------------- https://github.com/sshnet/SSH.NET](https://github.com/sshnet/SSH.NET) From 2cffa483aaa060247976f3e71eede93efa379039 Mon Sep 17 00:00:00 2001 From: autumn Date: Fri, 27 Aug 2021 16:37:46 +0800 Subject: [PATCH 26/26] mg --- ProxySuper.Core/Services/V2rayService.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ProxySuper.Core/Services/V2rayService.cs b/ProxySuper.Core/Services/V2rayService.cs index a061443..98266d2 100644 --- a/ProxySuper.Core/Services/V2rayService.cs +++ b/ProxySuper.Core/Services/V2rayService.cs @@ -78,6 +78,7 @@ namespace ProxySuper.Core.Services EnableBBR(); Progress.Desc = "重启V2ray服务"; + RunCmd("systemctl restart caddy"); RunCmd("systemctl restart v2ray"); @@ -389,6 +390,7 @@ namespace ProxySuper.Core.Services RunCmd($"sed -i 's/CapabilityBoundingSet=/#CapabilityBoundingSet=/g' /etc/systemd/system/v2ray.service"); RunCmd($"sed -i 's/AmbientCapabilities=/#AmbientCapabilities=/g' /etc/systemd/system/v2ray.service"); RunCmd($"systemctl daemon-reload"); + RunCmd("systemctl enable v2ray"); if (FileExists("/usr/local/etc/v2ray/config.json")) {