From 05f96fc79021ac40ff63f6011c339d4685f34810 Mon Sep 17 00:00:00 2001 From: next-autumn Date: Sat, 29 May 2021 11:43:06 +0800 Subject: [PATCH 01/32] cmt --- ProxySuper.WPF/Resources/Languages/en.xaml | 3 +++ ProxySuper.WPF/Resources/Languages/tw_cn.xaml | 3 +++ ProxySuper.WPF/Resources/Languages/zh_cn.xaml | 3 +++ ProxySuper.WPF/Views/HomeView.xaml | 3 +++ ProxySuper.WPF/Views/HomeView.xaml.cs | 17 +++++++++++++++++ 5 files changed, 29 insertions(+) diff --git a/ProxySuper.WPF/Resources/Languages/en.xaml b/ProxySuper.WPF/Resources/Languages/en.xaml index b3aed44..b9bf2a1 100644 --- a/ProxySuper.WPF/Resources/Languages/en.xaml +++ b/ProxySuper.WPF/Resources/Languages/en.xaml @@ -23,6 +23,9 @@ Helper Github + UseRoot + CertQuestion + PrivateKey Tag diff --git a/ProxySuper.WPF/Resources/Languages/tw_cn.xaml b/ProxySuper.WPF/Resources/Languages/tw_cn.xaml index fa1569c..0459f0c 100644 --- a/ProxySuper.WPF/Resources/Languages/tw_cn.xaml +++ b/ProxySuper.WPF/Resources/Languages/tw_cn.xaml @@ -22,6 +22,9 @@ 正體 幫助 Github + 啓用Root賬戶 + 證書問題 + 私鑰問題 diff --git a/ProxySuper.WPF/Resources/Languages/zh_cn.xaml b/ProxySuper.WPF/Resources/Languages/zh_cn.xaml index 8faa65e..e7b5232 100644 --- a/ProxySuper.WPF/Resources/Languages/zh_cn.xaml +++ b/ProxySuper.WPF/Resources/Languages/zh_cn.xaml @@ -22,6 +22,9 @@ 正體 帮助 Github + 启用Root账户 + 证书问题 + 私钥问题 diff --git a/ProxySuper.WPF/Views/HomeView.xaml b/ProxySuper.WPF/Views/HomeView.xaml index 3147341..96455c9 100644 --- a/ProxySuper.WPF/Views/HomeView.xaml +++ b/ProxySuper.WPF/Views/HomeView.xaml @@ -32,6 +32,9 @@ + + + diff --git a/ProxySuper.WPF/Views/HomeView.xaml.cs b/ProxySuper.WPF/Views/HomeView.xaml.cs index d8b839f..7b3e18f 100644 --- a/ProxySuper.WPF/Views/HomeView.xaml.cs +++ b/ProxySuper.WPF/Views/HomeView.xaml.cs @@ -47,6 +47,21 @@ namespace ProxySuper.WPF.Views System.Diagnostics.Process.Start("explorer.exe", "https://github.com/proxysu/ProxySU"); } + private void LaunchUseRootSite(object sender, RoutedEventArgs e) + { + System.Diagnostics.Process.Start("explorer.exe", "https://github.com/proxysu/ProxySU/wiki/%E8%B0%B7%E6%AD%8C%E4%BA%91%E5%BC%80%E5%90%AFroot%E8%B4%A6%E6%88%B7%E4%B8%8E%E5%AF%86%E7%A0%81%E7%99%BB%E5%BD%95"); + } + + private void LaunchCertQuestion(object sender, RoutedEventArgs e) + { + System.Diagnostics.Process.Start("explorer.exe", "https://github.com/proxysu/ProxySU/wiki/%E5%B8%B8%E8%A7%81%E8%AF%81%E4%B9%A6%E7%94%B3%E8%AF%B7%E5%A4%B1%E8%B4%A5%E9%97%AE%E9%A2%98"); + } + + private void LaunchPrivateKeyQuestion(object sender, RoutedEventArgs e) + { + System.Diagnostics.Process.Start("explorer.exe", "https://github.com/proxysu/ProxySU/wiki/PrivateKey%E8%BD%AC%E6%8D%A2"); + } + ResourceDictionary resource = new ResourceDictionary(); private void SetSimpleChinese(object sender, RoutedEventArgs e) @@ -80,5 +95,7 @@ namespace ProxySuper.WPF.Views NavigationService.Navigate>(checkedRecords); } + + } } From 2c9e2777bd956d3ec39c8916040dca23ba43a193 Mon Sep 17 00:00:00 2001 From: next-autumn <73510229+next-autumn@users.noreply.github.com> Date: Mon, 31 May 2021 17:23:49 +0800 Subject: [PATCH 02/32] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index d2ddb19..3d5994e 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ BBR一键开启(仅支持CentOS8/Debian9/10/Ubuntu18.04及以上),支持语 编译环境Visual Studio 2017 使用WPF界面。可一键安装V2ray、Xray,Trojan、NaiveProxy,Trojan-Go,ShadowsocksR(SSR),Shadowsocks-libev and Plugins、MTProto+TLS 后续还会再添加其他。 +![photo_2021-05-31_17-23-29](https://user-images.githubusercontent.com/73510229/120171754-f46ffd00-c234-11eb-8105-4e6a941a65bb.jpg) #### 免责声明:ProxySU属于自用分享工具,请勿用于违背良知与道德之事,否则后果自负。 From b7e44dbdca64896186a992bd93e2e2ee62a6c986 Mon Sep 17 00:00:00 2001 From: next-autumn <73510229+next-autumn@users.noreply.github.com> Date: Mon, 31 May 2021 17:24:54 +0800 Subject: [PATCH 03/32] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 3d5994e..a50da1d 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ +![Uploading photo_2021-05-31_17-24-29.jpg…]() +![Uploading photo_2021-05-31_17-24-29.jpg…]() + # ProxySU V2ray, Xray,Trojan, NaiveProxy, Trojan-Go, ShadowsocksR(SSR),Shadowsocks-libev and Plugins,MTProto+TLS,BBR install tools for windows。 From ca2bc405f5ce2dbe375c15d09858cb821d6ce020 Mon Sep 17 00:00:00 2001 From: next-autumn <73510229+next-autumn@users.noreply.github.com> Date: Mon, 31 May 2021 17:25:18 +0800 Subject: [PATCH 04/32] Update README.md --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a50da1d..a7201cf 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,3 @@ -![Uploading photo_2021-05-31_17-24-29.jpg…]() -![Uploading photo_2021-05-31_17-24-29.jpg…]() - - # ProxySU V2ray, Xray,Trojan, NaiveProxy, Trojan-Go, ShadowsocksR(SSR),Shadowsocks-libev and Plugins,MTProto+TLS,BBR install tools for windows。 V2ray,Xray,Trojan,NaiveProxy, Trojan-Go, ShadowsocksR(SSR),Shadowsocks-libev及相关插件,MTProto+TLS 一键安装工具。支持纯ipv6主机一键安装代理。 @@ -10,6 +6,8 @@ BBR一键开启(仅支持CentOS8/Debian9/10/Ubuntu18.04及以上),支持语 编译环境Visual Studio 2017 使用WPF界面。可一键安装V2ray、Xray,Trojan、NaiveProxy,Trojan-Go,ShadowsocksR(SSR),Shadowsocks-libev and Plugins、MTProto+TLS 后续还会再添加其他。 ![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) + #### 免责声明:ProxySU属于自用分享工具,请勿用于违背良知与道德之事,否则后果自负。 From 7263459a74fdb2f98afa711fdab76c9b960a9122 Mon Sep 17 00:00:00 2001 From: next-autumn Date: Wed, 2 Jun 2021 17:51:27 +0800 Subject: [PATCH 05/32] sharelink --- ProxySuper.Core/Services/ShareLink.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ProxySuper.Core/Services/ShareLink.cs b/ProxySuper.Core/Services/ShareLink.cs index d669aaf..0879484 100644 --- a/ProxySuper.Core/Services/ShareLink.cs +++ b/ProxySuper.Core/Services/ShareLink.cs @@ -28,10 +28,9 @@ namespace ProxySuper.Core.Services strBuilder.Append("trojan-go://"); strBuilder.Append($"{HttpUtility.UrlEncode(settings.Password)}@{settings.Domain}:{settings.Port}/?"); - strBuilder.Append($"sni={HttpUtility.UrlEncode(settings.Domain)}&"); if (settings.EnableWebSocket) { - strBuilder.Append($"type=ws&host={HttpUtility.UrlEncode(settings.Domain)}&path={HttpUtility.UrlEncode(settings.WebSocketPath)}&"); + strBuilder.Append($"type=ws&path={HttpUtility.UrlEncode(settings.WebSocketPath)}&"); } else { @@ -87,7 +86,7 @@ namespace ProxySuper.Core.Services aid = "0", net = "", type = "none", - host = settings.Domain, + host = "", path = "", tls = "tls", ps = "", From 3f397dbbf76e1198648966d7bc847fd62c058784 Mon Sep 17 00:00:00 2001 From: next-autumn Date: Fri, 4 Jun 2021 16:48:05 +0800 Subject: [PATCH 06/32] fix config port issue --- ProxySuper.WPF/Controls/ShadowSocksControl.xaml | 2 +- ProxySuper.WPF/Controls/Trojan_TCP_Control.xaml | 2 +- ProxySuper.WPF/Controls/VLESS_TCP_TLS_Control.xaml | 2 +- ProxySuper.WPF/Controls/VLESS_WS_TLS_Control.xaml | 2 +- ProxySuper.WPF/Controls/VLESS_XTLS_Control.xaml | 2 +- ProxySuper.WPF/Controls/VMESS_TCP_TLS_Control.xaml | 2 +- ProxySuper.WPF/Controls/VMESS_WS_TLS_Control.xaml | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ProxySuper.WPF/Controls/ShadowSocksControl.xaml b/ProxySuper.WPF/Controls/ShadowSocksControl.xaml index d0e6e75..b95d392 100644 --- a/ProxySuper.WPF/Controls/ShadowSocksControl.xaml +++ b/ProxySuper.WPF/Controls/ShadowSocksControl.xaml @@ -13,7 +13,7 @@ diff --git a/ProxySuper.WPF/Controls/Trojan_TCP_Control.xaml b/ProxySuper.WPF/Controls/Trojan_TCP_Control.xaml index 46f848e..39ae13f 100644 --- a/ProxySuper.WPF/Controls/Trojan_TCP_Control.xaml +++ b/ProxySuper.WPF/Controls/Trojan_TCP_Control.xaml @@ -13,7 +13,7 @@ diff --git a/ProxySuper.WPF/Controls/VLESS_TCP_TLS_Control.xaml b/ProxySuper.WPF/Controls/VLESS_TCP_TLS_Control.xaml index f892b30..6328d5a 100644 --- a/ProxySuper.WPF/Controls/VLESS_TCP_TLS_Control.xaml +++ b/ProxySuper.WPF/Controls/VLESS_TCP_TLS_Control.xaml @@ -13,7 +13,7 @@ diff --git a/ProxySuper.WPF/Controls/VLESS_WS_TLS_Control.xaml b/ProxySuper.WPF/Controls/VLESS_WS_TLS_Control.xaml index 0b28fba..1bde58e 100644 --- a/ProxySuper.WPF/Controls/VLESS_WS_TLS_Control.xaml +++ b/ProxySuper.WPF/Controls/VLESS_WS_TLS_Control.xaml @@ -13,7 +13,7 @@ diff --git a/ProxySuper.WPF/Controls/VLESS_XTLS_Control.xaml b/ProxySuper.WPF/Controls/VLESS_XTLS_Control.xaml index b596ca2..971d8cd 100644 --- a/ProxySuper.WPF/Controls/VLESS_XTLS_Control.xaml +++ b/ProxySuper.WPF/Controls/VLESS_XTLS_Control.xaml @@ -13,7 +13,7 @@ diff --git a/ProxySuper.WPF/Controls/VMESS_TCP_TLS_Control.xaml b/ProxySuper.WPF/Controls/VMESS_TCP_TLS_Control.xaml index e22f34f..1747181 100644 --- a/ProxySuper.WPF/Controls/VMESS_TCP_TLS_Control.xaml +++ b/ProxySuper.WPF/Controls/VMESS_TCP_TLS_Control.xaml @@ -13,7 +13,7 @@ diff --git a/ProxySuper.WPF/Controls/VMESS_WS_TLS_Control.xaml b/ProxySuper.WPF/Controls/VMESS_WS_TLS_Control.xaml index 4532868..7e885f7 100644 --- a/ProxySuper.WPF/Controls/VMESS_WS_TLS_Control.xaml +++ b/ProxySuper.WPF/Controls/VMESS_WS_TLS_Control.xaml @@ -13,7 +13,7 @@ From 7f7c92d22b5b763d7afbd3193f074cb3e250d996 Mon Sep 17 00:00:00 2001 From: next-autumn <73510229+next-autumn@users.noreply.github.com> Date: Tue, 8 Jun 2021 10:27:03 +0800 Subject: [PATCH 07/32] Update README.md --- README.md | 46 ---------------------------------------------- 1 file changed, 46 deletions(-) diff --git a/README.md b/README.md index a7201cf..98a09f3 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,6 @@ BBR一键开启(仅支持CentOS8/Debian9/10/Ubuntu18.04及以上),支持语 ##### ProxySU本着技术中立的原则,没有任何立场,也不持任何见解,更不涉及任何政治因素。ProxySU仅仅主张人的知情权,这是一项天赋人权,也是各国宪法所保障的最基本人权。知情权包含对同一事物正负两方面评价的知情,至于相信哪个,由人自己选择。正如李文亮医生临终所言:一个正常的社会是不应该只有一种声音的。如果真的存在对某一事物只有一种声音的评价,无论其评价是正面还是负面,都是要慎重对待,并需要重新审视的。 ##### Xray可一键安装的模式有: -当前Xray是V2Ray的超集,未来Xray会有不同的发展方向。 * VLESS+TCP+XTLS+Web (最新黑科技) * Vless+tcp+TLS+Web (新热门协议) * VLESS+WebSocket+TLS+Web @@ -30,32 +29,7 @@ BBR一键开启(仅支持CentOS8/Debian9/10/Ubuntu18.04及以上),支持语 * WebSocket+TLS * WebSocket+TLS+Web * WebSocket+TLS(自签证书) -* http2 -* http2+TLS+Web -* http2(自签证书) * mKCP及各种伪装 -* QUIC及各种伪装。 - -##### V2ray可一键安装的模式有: - -* Vless+tcp+TLS+Web (新热门协议) -* VLESS+WebSocket+TLS+Web -* VLESS+http2+TLS+Web -* VLESS+mKCP -* tcp -* tcp+http伪装 -* tcp+TLS -* tcp+TLS (自签证书) -* WebSocket -* WebSocket+TLS -* WebSocket+TLS+Web -* WebSocket+TLS(自签证书) -* http2 -* http2+TLS+Web -* http2(自签证书) -* mKCP及各种伪装 -* QUIC及各种伪装。 -注:mKCP和QUIC模式使用udp协议,可以有效减少网络延时,有加速的作用,但在网络管控严厉时期,会导致端口或IP被封。以上模式最推荐的是WebSocket+TLS+Web 和http2+TLS+Web 需要有一个域名。如果能加上CDN则稳定性更好。加上CDN后,是加速还是减速,与线路有关,也与当前所用的CDN的IP有关,这里是一个筛选CDN最优IP的工具: [better-cloudflare-ip](https://github.com/badafans/better-cloudflare-ip) -----适用于使用 Cloudflare 的CDN。 ##### Trojan 可一键安装: * Trojan + TLS + Web @@ -67,21 +41,6 @@ BBR一键开启(仅支持CentOS8/Debian9/10/Ubuntu18.04及以上),支持语 ##### NaiveProxy一键安装: * NaiveProxy + TLS +Web -##### ShadowsocksR(SSR)一键安装: -* SSR+TLS+Caddy - -##### SS (Shadowsocks-libev) 及相关插件一键安装: -* SS 经典模式 -* SS+WebSocket+TLS+Caddy(Web前置) (推荐) -* SS+WebSocket -* SS+QUIC -* SS+kcptun -* SS+obfs+http+Web -* SS+obfs+TLS+Web - -##### MTProto+TLS电报代理一键安装: -* MTProto+TLS - ##### 支持的VPS系统为: * CentOS 7/8 * Debian 8/9/10 (推荐 10) @@ -183,11 +142,6 @@ Let's Encrypt证书申请频率的限制 * [Qv2ray (windows)](https://github.com/Qv2ray/Qv2ray)客户端导入二维码和URL 注:这里多说几句NaiveProxy,现在墙越来越高,翻墙软件需要隐藏访问目标网址和加密数据的同时,还要隐藏自己的流量特征,不被识别出是代理流量。V2ray,Trojan都有其自己的实现。而NaiveProxy是配合Caddy的一个http.forwardproxy插件,插件有防嗅探,转发流量的功能。代理http流量很完美,但是在代理https流量时,会出现长度特征,NaiverProxy则弥补了这一点,消除了代理https时的流量特征,另外还应用 [Chrome's network stack](https://www.chromium.org/developers/design-documents/network-stack).更好的消除TLS的指纹特征。详细介绍请看项目官方介绍:[NaiveProxy官方文档](https://github.com/klzgrad/naiveproxy)。有兴趣的不妨一试。 -###### SSR+TLS+Caddy 模式目前已支持生成用于 - -* [ShadowsocksR (windows)](https://github.com/shadowsocksrr/shadowsocksr-csharp/releases)客户端导入二维码和URL -* [SSRR(Android)](https://github.com/shadowsocksrr/shadowsocksr-android/releases)导入二维码和URL -* [Shadowrocket (ios)](https://apps.apple.com/us/app/shadowrocket/id932747118)导入二维码和URL ###### SS (Shadowsocks-libev) 目前已支持生成用于 From 424e0945dbf6aa835daf5cc907e3446854fc80e7 Mon Sep 17 00:00:00 2001 From: autumn Date: Fri, 11 Jun 2021 11:00:57 +0800 Subject: [PATCH 08/32] caddy arm issue --- ProxySuper.Core/Services/NaiveProxyProject.cs | 5 +- ProxySuper.Core/Services/ProjectBase.cs | 61 ++++++++++++++----- ProxySuper.Core/Services/TrojanGoProject.cs | 5 +- ProxySuper.Core/Services/XrayProject.cs | 2 + .../ViewModels/XrayInstallerViewModel.cs | 2 - .../Views/NaiveProxyInstallerView.xaml | 1 - .../Views/TrojanGoInstallerView.xaml | 1 - ProxySuper.WPF/Views/XrayInstallerView.xaml | 1 - .../Views/XrayInstallerView.xaml.cs | 1 - 9 files changed, 56 insertions(+), 23 deletions(-) diff --git a/ProxySuper.Core/Services/NaiveProxyProject.cs b/ProxySuper.Core/Services/NaiveProxyProject.cs index 0d25b6b..26d125a 100644 --- a/ProxySuper.Core/Services/NaiveProxyProject.cs +++ b/ProxySuper.Core/Services/NaiveProxyProject.cs @@ -20,7 +20,10 @@ namespace ProxySuper.Core.Services public void Uninstall() { - 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"); WriteOutput("ProxyNaive卸载完成"); } diff --git a/ProxySuper.Core/Services/ProjectBase.cs b/ProxySuper.Core/Services/ProjectBase.cs index 3e525b3..970217a 100644 --- a/ProxySuper.Core/Services/ProjectBase.cs +++ b/ProxySuper.Core/Services/ProjectBase.cs @@ -395,10 +395,29 @@ namespace ProxySuper.Core.Services /// protected void InstallCaddy() { - 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 -y install 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 -y install caddy"); + } + + if (CmdType == CmdType.Dnf) + { + RunCmd("dnf -y install 'dnf-command(copr)'"); + RunCmd("dnf -y copr enable @caddy/caddy"); + RunCmd("dnf -y install caddy"); + } + + if (CmdType == CmdType.Yum) + { + RunCmd("yum -y install yum-plugin-copr"); + RunCmd("yum -y copr enable @caddy/caddy"); + RunCmd("yum -y install caddy"); + } + RunCmd("systemctl enable caddy.service"); } @@ -407,11 +426,25 @@ namespace ProxySuper.Core.Services /// 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("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("rm -rf /usr/bin/caddy"); RunCmd("rm -rf /usr/share/caddy"); + RunCmd("rm -rf /etc/caddy"); } @@ -435,7 +468,7 @@ namespace ProxySuper.Core.Services if (string.IsNullOrEmpty(IPv6)) { - throw new Exception("未检测可用的的IP地址"); + throw new Exception("未检测到可用的的IP地址"); } OnlyIpv6 = true; @@ -646,12 +679,12 @@ namespace ProxySuper.Core.Services // 申请证书 if (OnlyIpv6) { - 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\""; + var cmd = $"/root/.acme.sh/acme.sh --force --debug --issue --standalone -d {Parameters.Domain} --listen-v6 --pre-hook \"systemctl stop caddy\" --post-hook \"systemctl start caddy\""; result = RunCmd(cmd); } else { - var cmd = $"/root/.acme.sh/acme.sh --force --debug --issue --standalone -d {Parameters.Domain} --pre-hook \"service caddy stop\" --post-hook \"service caddy start\""; + var cmd = $"/root/.acme.sh/acme.sh --force --debug --issue --standalone -d {Parameters.Domain} --pre-hook \"systemctl stop caddy\" --post-hook \"systemctl start caddy\""; result = RunCmd(cmd); } @@ -730,15 +763,15 @@ namespace ProxySuper.Core.Services { if (CmdType == CmdType.Apt) { - return "echo y | apt-get install " + soft; + return "apt-get -y install " + soft; } else if (CmdType == CmdType.Dnf) { - return "echo y | dnf -y install " + soft; + return "dnf -y install " + soft; } else if (CmdType == CmdType.Yum) { - return "echo y | yum -y install " + soft; + return "yum -y install " + soft; } throw new Exception("未识别的系统"); diff --git a/ProxySuper.Core/Services/TrojanGoProject.cs b/ProxySuper.Core/Services/TrojanGoProject.cs index 4519f0d..554eb60 100644 --- a/ProxySuper.Core/Services/TrojanGoProject.cs +++ b/ProxySuper.Core/Services/TrojanGoProject.cs @@ -48,8 +48,10 @@ namespace ProxySuper.Core.Services public void Uninstall() { + EnsureRootAuth(); + EnsureSystemEnv(); + RunCmd("systemctl stop trojan-go"); - RunCmd("systemctl stop caddy"); base.UninstallCaddy(); RunCmd("rm -rf /usr/local/bin/trojan-go"); @@ -133,7 +135,6 @@ namespace ProxySuper.Core.Services private void InstallTrojanGo() { - WriteOutput("安装Trojan-Go"); RunCmd(@"curl https://raw.githubusercontent.com/proxysu/shellscript/master/trojan-go.sh yes | bash"); var success = FileExists("/usr/local/bin/trojan-go"); if (success == false) diff --git a/ProxySuper.Core/Services/XrayProject.cs b/ProxySuper.Core/Services/XrayProject.cs index 4dd6043..d57e30c 100644 --- a/ProxySuper.Core/Services/XrayProject.cs +++ b/ProxySuper.Core/Services/XrayProject.cs @@ -105,6 +105,7 @@ namespace ProxySuper.Core.Services public void UninstallProxy() { EnsureRootAuth(); + EnsureSystemEnv(); WriteOutput("卸载Caddy"); UninstallCaddy(); WriteOutput("卸载Xray"); @@ -153,6 +154,7 @@ namespace ProxySuper.Core.Services public void DoUninstallCaddy() { EnsureRootAuth(); + EnsureSystemEnv(); UninstallCaddy(); WriteOutput("************ 卸载Caddy完成 ************"); } diff --git a/ProxySuper.Core/ViewModels/XrayInstallerViewModel.cs b/ProxySuper.Core/ViewModels/XrayInstallerViewModel.cs index 8074b25..d96a841 100644 --- a/ProxySuper.Core/ViewModels/XrayInstallerViewModel.cs +++ b/ProxySuper.Core/ViewModels/XrayInstallerViewModel.cs @@ -43,7 +43,5 @@ namespace ProxySuper.Core.ViewModels } public string CommandText { get; set; } - - public string OutputText { get; set; } } } diff --git a/ProxySuper.WPF/Views/NaiveProxyInstallerView.xaml b/ProxySuper.WPF/Views/NaiveProxyInstallerView.xaml index 379e94d..5ca4f0c 100644 --- a/ProxySuper.WPF/Views/NaiveProxyInstallerView.xaml +++ b/ProxySuper.WPF/Views/NaiveProxyInstallerView.xaml @@ -23,7 +23,6 @@ VerticalAlignment="Top" VerticalContentAlignment="Top" TextWrapping="WrapWithOverflow" - Text="{Binding Path=OutputText}" /> diff --git a/ProxySuper.WPF/Views/TrojanGoInstallerView.xaml b/ProxySuper.WPF/Views/TrojanGoInstallerView.xaml index 3dd9fc7..bc9138e 100644 --- a/ProxySuper.WPF/Views/TrojanGoInstallerView.xaml +++ b/ProxySuper.WPF/Views/TrojanGoInstallerView.xaml @@ -23,7 +23,6 @@ VerticalAlignment="Top" VerticalContentAlignment="Top" TextWrapping="WrapWithOverflow" - Text="{Binding Path=OutputText}" /> diff --git a/ProxySuper.WPF/Views/XrayInstallerView.xaml b/ProxySuper.WPF/Views/XrayInstallerView.xaml index f0461dc..01c380b 100644 --- a/ProxySuper.WPF/Views/XrayInstallerView.xaml +++ b/ProxySuper.WPF/Views/XrayInstallerView.xaml @@ -23,7 +23,6 @@ VerticalAlignment="Top" VerticalContentAlignment="Top" TextWrapping="WrapWithOverflow" - Text="{Binding Path=OutputText}" /> diff --git a/ProxySuper.WPF/Views/XrayInstallerView.xaml.cs b/ProxySuper.WPF/Views/XrayInstallerView.xaml.cs index feb2632..525dff7 100644 --- a/ProxySuper.WPF/Views/XrayInstallerView.xaml.cs +++ b/ProxySuper.WPF/Views/XrayInstallerView.xaml.cs @@ -76,7 +76,6 @@ namespace ProxySuper.WPF.Views outShell += "\n"; } - ViewModel.OutputText += outShell; Dispatcher.Invoke(() => { OutputTextBox.AppendText(outShell); From e05e9cff3dc03d05dfe2a4dd3658e7c4c13383b0 Mon Sep 17 00:00:00 2001 From: next-autumn <73510229+next-autumn@users.noreply.github.com> Date: Wed, 16 Jun 2021 10:34:58 +0800 Subject: [PATCH 09/32] Update README.md --- README.md | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 98a09f3..d2dfab1 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # ProxySU -V2ray, Xray,Trojan, NaiveProxy, Trojan-Go, ShadowsocksR(SSR),Shadowsocks-libev and Plugins,MTProto+TLS,BBR install tools for windows。 -V2ray,Xray,Trojan,NaiveProxy, Trojan-Go, ShadowsocksR(SSR),Shadowsocks-libev及相关插件,MTProto+TLS 一键安装工具。支持纯ipv6主机一键安装代理。 +V2ray, Xray,Trojan, NaiveProxy, Trojan-Go,BBR install tools for windows。 +V2ray,Xray,Trojan,NaiveProxy, Trojan-Go, 及相关插件。支持纯ipv6主机一键安装代理。 BBR一键开启(仅支持CentOS8/Debian9/10/Ubuntu18.04及以上),支持语言:English、简体中文、正体(繁体)中文。 编译环境Visual Studio 2017 使用WPF界面。可一键安装V2ray、Xray,Trojan、NaiveProxy,Trojan-Go,ShadowsocksR(SSR),Shadowsocks-libev and Plugins、MTProto+TLS 后续还会再添加其他。 @@ -31,15 +31,8 @@ BBR一键开启(仅支持CentOS8/Debian9/10/Ubuntu18.04及以上),支持语 * WebSocket+TLS(自签证书) * mKCP及各种伪装 -##### Trojan 可一键安装: -* Trojan + TLS + Web - -##### Trojan-Go 可一键安装: -* Trojan-Go + TLS + Web -* Trojan-Go + WebSocket + TLS + Web - -##### NaiveProxy一键安装: -* NaiveProxy + TLS +Web +##### 上传自有证书 ##### +需要将crt和key文件打包成zip,在安装界面选择“上传自有证书” ##### 支持的VPS系统为: * CentOS 7/8 @@ -142,13 +135,6 @@ Let's Encrypt证书申请频率的限制 * [Qv2ray (windows)](https://github.com/Qv2ray/Qv2ray)客户端导入二维码和URL 注:这里多说几句NaiveProxy,现在墙越来越高,翻墙软件需要隐藏访问目标网址和加密数据的同时,还要隐藏自己的流量特征,不被识别出是代理流量。V2ray,Trojan都有其自己的实现。而NaiveProxy是配合Caddy的一个http.forwardproxy插件,插件有防嗅探,转发流量的功能。代理http流量很完美,但是在代理https流量时,会出现长度特征,NaiverProxy则弥补了这一点,消除了代理https时的流量特征,另外还应用 [Chrome's network stack](https://www.chromium.org/developers/design-documents/network-stack).更好的消除TLS的指纹特征。详细介绍请看项目官方介绍:[NaiveProxy官方文档](https://github.com/klzgrad/naiveproxy)。有兴趣的不妨一试。 - -###### SS (Shadowsocks-libev) 目前已支持生成用于 - -* [Shadowsocks (windows)](https://github.com/shadowsocks/shadowsocks-windows/releases)客户端导入二维码和URL -* [shadowsocks(Android)](https://github.com/shadowsocks/shadowsocks-android/releases)导入二维码和URL -* [Shadowrocket (ios)](https://apps.apple.com/us/app/shadowrocket/id932747118)导入二维码和URL - ## 程序工作流程: 1. 使用[SSH.NET](https://github.com/sshnet/SSH.NET)登录远程主机 2. 根据选择的代理来调用相应的脚本: @@ -158,8 +144,6 @@ Let's Encrypt证书申请频率的限制 * 选择Trojan-Go,则调用本项目内的trojan-go.sh安装, `curl -o /tmp/trojan-go.sh https://raw.githubusercontent.com/proxysu/shellscript/master/trojan-go.sh` `yes | bash /tmp/trojan-go.sh -f` 安装Trojan-GO。 * 选择NaiveProxy,先安装Caddy2,方法源自[Caddy官方文档](https://caddyserver.com/docs/download)。再用自编译的Caddy2(带forward_proxy插件)替换原来的Caddy运行文件。自编译Caddy2文件方法源自[NaiveProxy官方文档](https://github.com/klzgrad/naiveproxy#setup)。 * 选择SSR+TLS+Caddy模式,则调用本项目内的ssr.sh安装, `curl -o /tmp/ssr.sh https://raw.githubusercontent.com/proxysu/shellscript/master/ssr/ssr.sh` `yes | bash /tmp/ssr.sh -f` 安装SSR。 - * 选择Shadowsocks-libev与插件模式,则调用本项目内的ss-install.sh安装,`curl -o /tmp/install.sh https://raw.githubusercontent.com/proxysu/shellscript/master/ss/ss-install.sh` `yes | bash /tmp/install.sh` - * 先择MTProto+TLS模式,则调用本项目内的mtg_install.sh安装,`curl -o /tmp/mtg_install.sh https://raw.githubusercontent.com/proxysu/shellscript/master/MTProto/mtg_install.sh` `yes | bash /tmp/mtg_install.sh` 3. 根据选择读取相应配置模板,调用[Newtonsoft.Json](https://github.com/JamesNK/Newtonsoft.Json)生成相应配置文件,并上传到服务器。所有模板及配置文件 [在这里](https://github.com/proxysu/windows/tree/master/TemplateConfg) 4. 如果使用WebSocket+TLS+Web/http2+TLS+Web/Trojan+TLS+Web/Trojan-go+TLS+Web/SSR+TLS+Caddy/SS+WebSocket+TLS+Caddy/SS+obfs+http+Web/SS+obfs+TLS+Web 模式,则安装Caddy2,方法源自[Caddy官方文档](https://caddyserver.com/docs/download)。 5. 如果使用Http2/tcp+TLS/WebSocket+TLS/Trojan+TLS+Web/Trojan-go+TLS+Web/SS+QUIC模式,则调用 `curl https://raw.githubusercontent.com/acmesh-official/acme.sh/master/acme.sh | INSTALLONLINE=1 sh` 安装acme.sh,使用acme.sh申请证书. From 11021fac1a8305961c2802ba0ef104b1528d241f Mon Sep 17 00:00:00 2001 From: autumn Date: Thu, 17 Jun 2021 18:54:07 +0800 Subject: [PATCH 10/32] 4.0.2 update --- .../Models/Projects/IProjectSettings.cs | 5 +++ .../Models/Projects/NaiveProxySettings.cs | 22 ++++++++++- .../Models/Projects/TrojanGoSettings.cs | 21 ++++++++++ .../Models/Projects/XraySettings.cs | 21 +++++++++- ProxySuper.Core/Services/NaiveProxyProject.cs | 2 + ProxySuper.Core/Services/ProjectBase.cs | 38 +++++++++---------- ProxySuper.WPF/Properties/AssemblyInfo.cs | 4 +- .../Templates/NaiveProxy/caddy.service | 20 ++++++++++ 8 files changed, 110 insertions(+), 23 deletions(-) create mode 100644 ProxySuper.WPF/Templates/NaiveProxy/caddy.service diff --git a/ProxySuper.Core/Models/Projects/IProjectSettings.cs b/ProxySuper.Core/Models/Projects/IProjectSettings.cs index 6bd2874..4d5f085 100644 --- a/ProxySuper.Core/Models/Projects/IProjectSettings.cs +++ b/ProxySuper.Core/Models/Projects/IProjectSettings.cs @@ -27,5 +27,10 @@ namespace ProxySuper.Core.Models.Projects /// 类型 /// ProjectType Type { get; set; } + + /// + /// 邮箱 + /// + string Email { get; } } } diff --git a/ProxySuper.Core/Models/Projects/NaiveProxySettings.cs b/ProxySuper.Core/Models/Projects/NaiveProxySettings.cs index 76fb1c4..fab1a64 100644 --- a/ProxySuper.Core/Models/Projects/NaiveProxySettings.cs +++ b/ProxySuper.Core/Models/Projects/NaiveProxySettings.cs @@ -1,4 +1,5 @@ -using System; +using Newtonsoft.Json; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -26,5 +27,24 @@ namespace ProxySuper.Core.Models.Projects public string Password { get; set; } public string MaskDomain { get; set; } + + [JsonIgnore] + public string Email + { + get + { + if (!string.IsNullOrEmpty(Domain)) + { + var arr = Domain.Split('.'); + if (arr.Length == 3) + { + return $"{arr[0]}@{arr[1]}.{arr[2]}"; + } + } + + + return $"{UserName + Port.ToString()}@gmail.com"; + } + } } } diff --git a/ProxySuper.Core/Models/Projects/TrojanGoSettings.cs b/ProxySuper.Core/Models/Projects/TrojanGoSettings.cs index cf84518..79859f3 100644 --- a/ProxySuper.Core/Models/Projects/TrojanGoSettings.cs +++ b/ProxySuper.Core/Models/Projects/TrojanGoSettings.cs @@ -14,6 +14,7 @@ namespace ProxySuper.Core.Models.Projects { Port = 443; WebSocketPath = "/ws"; + Password = Guid.NewGuid().ToString(); } public List FreePorts @@ -63,5 +64,25 @@ namespace ProxySuper.Core.Models.Projects /// public string WebSocketPath { get; set; } + + [JsonIgnore] + public string Email + { + get + { + if (!string.IsNullOrEmpty(Domain)) + { + var arr = Domain.Split('.'); + if (arr.Length == 3) + { + return $"{arr[0]}@{arr[1]}.{arr[2]}"; + } + } + + var prefix = Password.Length > 7 ? Password.Substring(0, 7) : Password; + return $"{prefix}@gmail.com"; + } + } + } } diff --git a/ProxySuper.Core/Models/Projects/XraySettings.cs b/ProxySuper.Core/Models/Projects/XraySettings.cs index d9fe96f..f74272a 100644 --- a/ProxySuper.Core/Models/Projects/XraySettings.cs +++ b/ProxySuper.Core/Models/Projects/XraySettings.cs @@ -1,4 +1,5 @@ -using System; +using Newtonsoft.Json; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -71,6 +72,24 @@ namespace ProxySuper.Core.Models.Projects /// public string MaskDomain { get; set; } + [JsonIgnore] + public string Email + { + get + { + if (!string.IsNullOrEmpty(Domain)) + { + var arr = Domain.Split('.'); + if (arr.Length == 3) + { + return $"{arr[0]}@{arr[1]}.{arr[2]}"; + } + } + + return $"{UUID.Substring(2, 6)}@gmail.com"; + } + } + /// /// 安装类型 /// diff --git a/ProxySuper.Core/Services/NaiveProxyProject.cs b/ProxySuper.Core/Services/NaiveProxyProject.cs index 26d125a..0c11622 100644 --- a/ProxySuper.Core/Services/NaiveProxyProject.cs +++ b/ProxySuper.Core/Services/NaiveProxyProject.cs @@ -101,6 +101,8 @@ namespace ProxySuper.Core.Services { WriteOutput("安装 NaiveProxy"); RunCmd(@"curl https://raw.githubusercontent.com/proxysu/shellscript/master/Caddy-Naive/caddy-naive-install.sh yes | bash"); + // 允许开机启动 + RunCmd("systemctl enable caddy"); UploadCaddyFile(false); ConfigNetwork(); WriteOutput("NaiveProxy 安装完成"); diff --git a/ProxySuper.Core/Services/ProjectBase.cs b/ProxySuper.Core/Services/ProjectBase.cs index 970217a..4cee6b8 100644 --- a/ProxySuper.Core/Services/ProjectBase.cs +++ b/ProxySuper.Core/Services/ProjectBase.cs @@ -70,7 +70,7 @@ namespace ProxySuper.Core.Services // 确认安装命令 if (CmdType == CmdType.None) { - cmd = RunCmd("command -v apt-get"); + cmd = RunCmd("command -v apt"); if (!string.IsNullOrEmpty(cmd)) { CmdType = CmdType.Apt; @@ -105,7 +105,7 @@ namespace ProxySuper.Core.Services if (CmdType == CmdType.None || !hasSystemCtl) { - throw new Exception("系统缺乏必要的安装组件如:apt-get||dnf||yum||Syetemd,主机系统推荐使用:CentOS 7/8,Debian 8/9/10,Ubuntu 16.04及以上版本"); + throw new Exception("系统缺乏必要的安装组件如:apt||dnf||yum||Syetemd,主机系统推荐使用:CentOS 7/8,Debian 8/9/10,Ubuntu 16.04及以上版本"); } @@ -157,6 +157,8 @@ namespace ProxySuper.Core.Services /// protected void ConfigureSoftware() { + RunCmd(GetUpdateCmd()); + string cmd = RunCmd("command -v sudo"); if (string.IsNullOrEmpty(cmd)) { @@ -188,17 +190,14 @@ namespace ProxySuper.Core.Services { if (CmdType == CmdType.Apt) { - RunCmd(GetUpdateCmd()); RunCmd(GetInstallCmd("dnsutils")); } else if (CmdType == CmdType.Dnf) { - RunCmd(GetUpdateCmd()); RunCmd(GetInstallCmd("bind-utils")); } else if (CmdType == CmdType.Yum) { - RunCmd(GetUpdateCmd()); RunCmd(GetInstallCmd("bind-utils")); } } @@ -397,25 +396,25 @@ namespace ProxySuper.Core.Services { if (CmdType == CmdType.Apt) { - RunCmd("sudo apt -y install debian-keyring debian-archive-keyring apt-transport-https"); + 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 -y install caddy"); + RunCmd("sudo apt install -y caddy"); } if (CmdType == CmdType.Dnf) { - RunCmd("dnf -y install 'dnf-command(copr)'"); - RunCmd("dnf -y copr enable @caddy/caddy"); - RunCmd("dnf -y install caddy"); + RunCmd("dnf install -y 'dnf-command(copr)'"); + RunCmd("dnf copr enable @caddy/caddy"); + RunCmd("dnf install -y caddy"); } if (CmdType == CmdType.Yum) { - RunCmd("yum -y install yum-plugin-copr"); - RunCmd("yum -y copr enable @caddy/caddy"); - RunCmd("yum -y install caddy"); + RunCmd("yum install -y yum-plugin-copr"); + RunCmd("yum copr enable @caddy/caddy"); + RunCmd("yum install -y caddy"); } RunCmd("systemctl enable caddy.service"); @@ -468,7 +467,7 @@ namespace ProxySuper.Core.Services if (string.IsNullOrEmpty(IPv6)) { - throw new Exception("未检测到可用的的IP地址"); + throw new Exception("未检测到可用的的IP地址,请重试安装"); } OnlyIpv6 = true; @@ -662,7 +661,8 @@ namespace ProxySuper.Core.Services RunCmd(GetInstallCmd("automake autoconf libtool")); // 安装Acme - var result = RunCmd($"curl https://get.acme.sh yes | sh"); + + var result = RunCmd($"curl https://get.acme.sh yes | sh -s email={Parameters.Email}"); if (result.Contains("Install success")) { WriteOutput("安装 acme.sh 成功"); @@ -740,7 +740,7 @@ namespace ProxySuper.Core.Services { if (CmdType == CmdType.Apt) { - return "apt-get update"; + return "apt update"; } else if (CmdType == CmdType.Dnf) { @@ -763,15 +763,15 @@ namespace ProxySuper.Core.Services { if (CmdType == CmdType.Apt) { - return "apt-get -y install " + soft; + return "apt install -y " + soft; } else if (CmdType == CmdType.Dnf) { - return "dnf -y install " + soft; + return "dnf install -y " + soft; } else if (CmdType == CmdType.Yum) { - return "yum -y install " + soft; + return "yum install -y " + soft; } throw new Exception("未识别的系统"); diff --git a/ProxySuper.WPF/Properties/AssemblyInfo.cs b/ProxySuper.WPF/Properties/AssemblyInfo.cs index 945398a..48b954e 100644 --- a/ProxySuper.WPF/Properties/AssemblyInfo.cs +++ b/ProxySuper.WPF/Properties/AssemblyInfo.cs @@ -51,5 +51,5 @@ using System.Windows; //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 //通过使用 "*",如下所示: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("4.0.1.0")] -[assembly: AssemblyFileVersion("4.0.1.0")] +[assembly: AssemblyVersion("4.0.2.0")] +[assembly: AssemblyFileVersion("4.0.2.0")] diff --git a/ProxySuper.WPF/Templates/NaiveProxy/caddy.service b/ProxySuper.WPF/Templates/NaiveProxy/caddy.service new file mode 100644 index 0000000..aa0070b --- /dev/null +++ b/ProxySuper.WPF/Templates/NaiveProxy/caddy.service @@ -0,0 +1,20 @@ +[Unit] +Description=Caddy +Documentation=https://caddyserver.com/docs/ +After=network.target network-online.target +Requires=network-online.target + +[Service] +User=caddy +Group=caddy +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 \ No newline at end of file From 63c7f8b7a7092c6092242669628427b3f66dad57 Mon Sep 17 00:00:00 2001 From: autumn Date: Fri, 18 Jun 2021 20:53:46 +0800 Subject: [PATCH 11/32] 4.0.3 --- ProxySuper.Core/Services/NaiveProxyProject.cs | 2 +- ProxySuper.Core/Services/ProjectBase.cs | 6 +++--- ProxySuper.Core/Services/TrojanGoProject.cs | 2 +- ProxySuper.Core/Services/XrayProject.cs | 2 +- ProxySuper.WPF/Properties/AssemblyInfo.cs | 4 ++-- .../Views/NaiveProxyInstallerView.xaml.cs | 13 +++++++++++++ .../Views/TrojanGoInstallerView.xaml.cs | 13 +++++++++++++ ProxySuper.WPF/Views/XrayInstallerView.xaml.cs | 18 ++++++++++++++++++ 8 files changed, 52 insertions(+), 8 deletions(-) diff --git a/ProxySuper.Core/Services/NaiveProxyProject.cs b/ProxySuper.Core/Services/NaiveProxyProject.cs index 0c11622..6d9ae64 100644 --- a/ProxySuper.Core/Services/NaiveProxyProject.cs +++ b/ProxySuper.Core/Services/NaiveProxyProject.cs @@ -93,7 +93,7 @@ namespace ProxySuper.Core.Services { var errorLog = "安装终止," + ex.Message; WriteOutput(errorLog); - MessageBox.Show(errorLog); + MessageBox.Show("安装失败,请联系开发者或上传日志文件(Logs文件夹下)到github提问。"); } } diff --git a/ProxySuper.Core/Services/ProjectBase.cs b/ProxySuper.Core/Services/ProjectBase.cs index 4cee6b8..7ce26c9 100644 --- a/ProxySuper.Core/Services/ProjectBase.cs +++ b/ProxySuper.Core/Services/ProjectBase.cs @@ -662,7 +662,7 @@ namespace ProxySuper.Core.Services // 安装Acme - var result = RunCmd($"curl https://get.acme.sh yes | sh -s email={Parameters.Email}"); + var result = RunCmd($"curl https://get.acme.sh yes | sh"); if (result.Contains("Install success")) { WriteOutput("安装 acme.sh 成功"); @@ -679,12 +679,12 @@ namespace ProxySuper.Core.Services // 申请证书 if (OnlyIpv6) { - var cmd = $"/root/.acme.sh/acme.sh --force --debug --issue --standalone -d {Parameters.Domain} --listen-v6 --pre-hook \"systemctl stop caddy\" --post-hook \"systemctl start caddy\""; + var cmd = $"/root/.acme.sh/acme.sh --force --debug --issue --standalone -d {Parameters.Domain} --listen-v6 --pre-hook \"systemctl stop caddy\" --post-hook \"systemctl start caddy\" --server letsencrypt"; result = RunCmd(cmd); } else { - var cmd = $"/root/.acme.sh/acme.sh --force --debug --issue --standalone -d {Parameters.Domain} --pre-hook \"systemctl stop caddy\" --post-hook \"systemctl start caddy\""; + var cmd = $"/root/.acme.sh/acme.sh --force --debug --issue --standalone -d {Parameters.Domain} --pre-hook \"systemctl stop caddy\" --post-hook \"systemctl start caddy\" --server letsencrypt"; result = RunCmd(cmd); } diff --git a/ProxySuper.Core/Services/TrojanGoProject.cs b/ProxySuper.Core/Services/TrojanGoProject.cs index 554eb60..98783dd 100644 --- a/ProxySuper.Core/Services/TrojanGoProject.cs +++ b/ProxySuper.Core/Services/TrojanGoProject.cs @@ -129,7 +129,7 @@ namespace ProxySuper.Core.Services { var errorLog = "安装终止," + ex.Message; WriteOutput(errorLog); - MessageBox.Show(errorLog); + MessageBox.Show("安装失败,请联系开发者或上传日志文件(Logs文件夹下)到github提问。"); } } diff --git a/ProxySuper.Core/Services/XrayProject.cs b/ProxySuper.Core/Services/XrayProject.cs index d57e30c..a079ca6 100644 --- a/ProxySuper.Core/Services/XrayProject.cs +++ b/ProxySuper.Core/Services/XrayProject.cs @@ -98,7 +98,7 @@ namespace ProxySuper.Core.Services { var errorLog = "安装终止," + ex.Message; WriteOutput(errorLog); - MessageBox.Show(errorLog); + MessageBox.Show("安装失败,请联系开发者或上传日志文件(Logs文件夹下)到github提问。"); } } diff --git a/ProxySuper.WPF/Properties/AssemblyInfo.cs b/ProxySuper.WPF/Properties/AssemblyInfo.cs index 48b954e..89c1abd 100644 --- a/ProxySuper.WPF/Properties/AssemblyInfo.cs +++ b/ProxySuper.WPF/Properties/AssemblyInfo.cs @@ -51,5 +51,5 @@ using System.Windows; //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 //通过使用 "*",如下所示: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("4.0.2.0")] -[assembly: AssemblyFileVersion("4.0.2.0")] +[assembly: AssemblyVersion("4.0.3.0")] +[assembly: AssemblyFileVersion("4.0.3.0")] diff --git a/ProxySuper.WPF/Views/NaiveProxyInstallerView.xaml.cs b/ProxySuper.WPF/Views/NaiveProxyInstallerView.xaml.cs index af015dc..a88fcd4 100644 --- a/ProxySuper.WPF/Views/NaiveProxyInstallerView.xaml.cs +++ b/ProxySuper.WPF/Views/NaiveProxyInstallerView.xaml.cs @@ -8,6 +8,7 @@ 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; @@ -71,6 +72,7 @@ namespace ProxySuper.WPF.Views { outShell += "\n"; } + ViewModel.CommandText += outShell; Dispatcher.Invoke(() => { @@ -119,8 +121,19 @@ namespace ProxySuper.WPF.Views { Task.Factory.StartNew(OpenConnect); }; + base.Closed += SaveInstallLog; } + private void SaveInstallLog(object sender, EventArgs e) + { + if (!Directory.Exists("Logs")) + { + Directory.CreateDirectory("Logs"); + } + + var fileName = System.IO.Path.Combine("Logs", DateTime.Now.ToString("yyyy-MM-dd hh-mm") + ".naiveproxy.txt"); + File.WriteAllText(fileName, ViewModel.CommandText); + } private void OpenLink(object sender, RoutedEventArgs e) { diff --git a/ProxySuper.WPF/Views/TrojanGoInstallerView.xaml.cs b/ProxySuper.WPF/Views/TrojanGoInstallerView.xaml.cs index 4368c0b..e8ad031 100644 --- a/ProxySuper.WPF/Views/TrojanGoInstallerView.xaml.cs +++ b/ProxySuper.WPF/Views/TrojanGoInstallerView.xaml.cs @@ -9,6 +9,7 @@ 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; @@ -73,6 +74,7 @@ namespace ProxySuper.WPF.Views { outShell += "\n"; } + ViewModel.CommandText += outShell; Dispatcher.Invoke(() => { @@ -121,8 +123,19 @@ namespace ProxySuper.WPF.Views { Task.Factory.StartNew(OpenConnect); }; + base.Closed += SaveInstallLog; } + private void SaveInstallLog(object sender, EventArgs e) + { + if (!Directory.Exists("Logs")) + { + Directory.CreateDirectory("Logs"); + } + + var fileName = System.IO.Path.Combine("Logs", DateTime.Now.ToString("yyyy-MM-dd hh-mm") + ".trojan-go.txt"); + File.WriteAllText(fileName, ViewModel.CommandText); + } private void OpenLink(object sender, RoutedEventArgs e) { diff --git a/ProxySuper.WPF/Views/XrayInstallerView.xaml.cs b/ProxySuper.WPF/Views/XrayInstallerView.xaml.cs index 525dff7..b582987 100644 --- a/ProxySuper.WPF/Views/XrayInstallerView.xaml.cs +++ b/ProxySuper.WPF/Views/XrayInstallerView.xaml.cs @@ -8,6 +8,7 @@ using Renci.SshNet; using System; using System.ComponentModel; using System.Diagnostics; +using System.IO; using System.Threading.Tasks; using System.Windows; using System.Windows.Automation.Peers; @@ -45,6 +46,19 @@ namespace ProxySuper.WPF.Views { Task.Factory.StartNew(OpenConnect); }; + + base.Closed += SaveInstallLog; + } + + private void SaveInstallLog(object sender, EventArgs e) + { + if (!Directory.Exists("Logs")) + { + Directory.CreateDirectory("Logs"); + } + + var fileName = Path.Combine("Logs", DateTime.Now.ToString("yyyy-MM-dd hh-mm") + ".xary.txt"); + File.WriteAllText(fileName, ViewModel.CommandText); } private SshClient _sshClient; @@ -75,6 +89,7 @@ namespace ProxySuper.WPF.Views { outShell += "\n"; } + ViewModel.CommandText += outShell; Dispatcher.Invoke(() => { @@ -116,6 +131,8 @@ namespace ProxySuper.WPF.Views } + #region 功能 + private void OpenLink(object sender, RoutedEventArgs e) { Hyperlink link = sender as Hyperlink; @@ -186,6 +203,7 @@ namespace ProxySuper.WPF.Views } }); } + #endregion } } From 395d01aea8131cc0ede734c9a7a37e1c46aefceb Mon Sep 17 00:00:00 2001 From: autumn Date: Sat, 19 Jun 2021 11:57:16 +0800 Subject: [PATCH 12/32] update --- ProxySuper.Core/Services/ProjectBase.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ProxySuper.Core/Services/ProjectBase.cs b/ProxySuper.Core/Services/ProjectBase.cs index 7ce26c9..aaa5eb3 100644 --- a/ProxySuper.Core/Services/ProjectBase.cs +++ b/ProxySuper.Core/Services/ProjectBase.cs @@ -83,6 +83,8 @@ namespace ProxySuper.Core.Services if (!string.IsNullOrEmpty(cmd)) { CmdType = CmdType.Dnf; + //RunCmd("echo \"export LC_ALL=en_US.UTF-8\" >> /etc/profile"); + //RunCmd("source /etc/profile"); } } @@ -406,14 +408,14 @@ namespace ProxySuper.Core.Services if (CmdType == CmdType.Dnf) { RunCmd("dnf install -y 'dnf-command(copr)'"); - RunCmd("dnf copr enable @caddy/caddy"); + 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 enable @caddy/caddy"); + RunCmd("yum copr -y enable @caddy/caddy"); RunCmd("yum install -y caddy"); } From 2f0f9fb09d3153738920c94fc66d484eb1c22d45 Mon Sep 17 00:00:00 2001 From: autumn Date: Tue, 29 Jun 2021 16:08:45 +0800 Subject: [PATCH 13/32] merge --- ProxySuper.Core/ProxySuper.Core.csproj | 1 + ProxySuper.Core/Services/ProjectBase.cs | 7 + .../Controls/XraySettingsControl.xaml | 272 ++++++++++-------- ProxySuper.WPF/Resources/Languages/en.xaml | 2 + ProxySuper.WPF/Resources/Languages/tw_cn.xaml | 2 + ProxySuper.WPF/Resources/Languages/zh_cn.xaml | 2 + 6 files changed, 161 insertions(+), 125 deletions(-) diff --git a/ProxySuper.Core/ProxySuper.Core.csproj b/ProxySuper.Core/ProxySuper.Core.csproj index db1bc85..ef51069 100644 --- a/ProxySuper.Core/ProxySuper.Core.csproj +++ b/ProxySuper.Core/ProxySuper.Core.csproj @@ -67,6 +67,7 @@ + diff --git a/ProxySuper.Core/Services/ProjectBase.cs b/ProxySuper.Core/Services/ProjectBase.cs index aaa5eb3..9563c58 100644 --- a/ProxySuper.Core/Services/ProjectBase.cs +++ b/ProxySuper.Core/Services/ProjectBase.cs @@ -215,6 +215,13 @@ namespace ProxySuper.Core.Services RunCmd(GetInstallCmd("xz-devel")); } + // 检测是否安装cron + cmd = RunCmd("command -v cron"); + if (string.IsNullOrEmpty(cmd)) + { + RunCmd(GetInstallCmd("cron")); + } + // 检测是否安装lsof cmd = RunCmd("command -v lsof"); if (string.IsNullOrEmpty(cmd)) diff --git a/ProxySuper.WPF/Controls/XraySettingsControl.xaml b/ProxySuper.WPF/Controls/XraySettingsControl.xaml index 4be4fad..d9e9b48 100644 --- a/ProxySuper.WPF/Controls/XraySettingsControl.xaml +++ b/ProxySuper.WPF/Controls/XraySettingsControl.xaml @@ -10,165 +10,165 @@ - + - - + - + - - + - + - - + - + - - + - + - - + - - + - + - - + - + - - + - + - - + - + - - + - + - - + - + - - + - + - - + - + diff --git a/ProxySuper.WPF/Views/EnableRootView.xaml.cs b/ProxySuper.WPF/Views/EnableRootView.xaml.cs index 0a215e0..acf18fe 100644 --- a/ProxySuper.WPF/Views/EnableRootView.xaml.cs +++ b/ProxySuper.WPF/Views/EnableRootView.xaml.cs @@ -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 { /// /// EnableRootView.xaml 的交互逻辑 /// - 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(); + } } } diff --git a/ProxySuper.WPF/Views/HomeView.xaml b/ProxySuper.WPF/Views/HomeView.xaml index 0572bf0..fd98283 100644 --- a/ProxySuper.WPF/Views/HomeView.xaml +++ b/ProxySuper.WPF/Views/HomeView.xaml @@ -23,6 +23,7 @@ + diff --git a/ProxySuper.WPF/Views/HomeView.xaml.cs b/ProxySuper.WPF/Views/HomeView.xaml.cs index 7b3e18f..2d3fe84 100644 --- a/ProxySuper.WPF/Views/HomeView.xaml.cs +++ b/ProxySuper.WPF/Views/HomeView.xaml.cs @@ -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>(checkedRecords); } + private void GetRoot(object sender, RoutedEventArgs e) + { + NavigationService.Navigate(); + } } } diff --git a/ProxySuper.WPF/Views/NaiveProxyConfigView.xaml.cs b/ProxySuper.WPF/Views/NaiveProxyConfigView.xaml.cs index 5ee9403..bcd9f4d 100644 --- a/ProxySuper.WPF/Views/NaiveProxyConfigView.xaml.cs +++ b/ProxySuper.WPF/Views/NaiveProxyConfigView.xaml.cs @@ -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 { diff --git a/ProxySuper.WPF/Views/NaiveProxyEditorView.xaml.cs b/ProxySuper.WPF/Views/NaiveProxyEditorView.xaml.cs index 41d7577..4a948bd 100644 --- a/ProxySuper.WPF/Views/NaiveProxyEditorView.xaml.cs +++ b/ProxySuper.WPF/Views/NaiveProxyEditorView.xaml.cs @@ -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 { diff --git a/ProxySuper.WPF/Views/NaiveProxyInstallerView.xaml.cs b/ProxySuper.WPF/Views/NaiveProxyInstallerView.xaml.cs index a88fcd4..76facb5 100644 --- a/ProxySuper.WPF/Views/NaiveProxyInstallerView.xaml.cs +++ b/ProxySuper.WPF/Views/NaiveProxyInstallerView.xaml.cs @@ -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) diff --git a/ProxySuper.WPF/Views/ShareLinkView.xaml.cs b/ProxySuper.WPF/Views/ShareLinkView.xaml.cs index e6d9945..ea49557 100644 --- a/ProxySuper.WPF/Views/ShareLinkView.xaml.cs +++ b/ProxySuper.WPF/Views/ShareLinkView.xaml.cs @@ -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 { diff --git a/ProxySuper.WPF/Views/TrojanGoConfigView.xaml.cs b/ProxySuper.WPF/Views/TrojanGoConfigView.xaml.cs index d2719f8..31a572a 100644 --- a/ProxySuper.WPF/Views/TrojanGoConfigView.xaml.cs +++ b/ProxySuper.WPF/Views/TrojanGoConfigView.xaml.cs @@ -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 { diff --git a/ProxySuper.WPF/Views/TrojanGoEditorView.xaml.cs b/ProxySuper.WPF/Views/TrojanGoEditorView.xaml.cs index 0e9a481..beeae43 100644 --- a/ProxySuper.WPF/Views/TrojanGoEditorView.xaml.cs +++ b/ProxySuper.WPF/Views/TrojanGoEditorView.xaml.cs @@ -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 { diff --git a/ProxySuper.WPF/Views/TrojanGoInstallerView.xaml.cs b/ProxySuper.WPF/Views/TrojanGoInstallerView.xaml.cs index e8ad031..3be2d32 100644 --- a/ProxySuper.WPF/Views/TrojanGoInstallerView.xaml.cs +++ b/ProxySuper.WPF/Views/TrojanGoInstallerView.xaml.cs @@ -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) diff --git a/ProxySuper.WPF/Views/XrayConfigView.xaml.cs b/ProxySuper.WPF/Views/XrayConfigView.xaml.cs index 2916c11..286ac2a 100644 --- a/ProxySuper.WPF/Views/XrayConfigView.xaml.cs +++ b/ProxySuper.WPF/Views/XrayConfigView.xaml.cs @@ -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 { diff --git a/ProxySuper.WPF/Views/XrayEditorView.xaml.cs b/ProxySuper.WPF/Views/XrayEditorView.xaml.cs index d6ad3b7..b29d1df 100644 --- a/ProxySuper.WPF/Views/XrayEditorView.xaml.cs +++ b/ProxySuper.WPF/Views/XrayEditorView.xaml.cs @@ -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 { diff --git a/ProxySuper.WPF/Views/XrayInstallerView.xaml.cs b/ProxySuper.WPF/Views/XrayInstallerView.xaml.cs index b582987..7d12d5a 100644 --- a/ProxySuper.WPF/Views/XrayInstallerView.xaml.cs +++ b/ProxySuper.WPF/Views/XrayInstallerView.xaml.cs @@ -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) From 6be1fdb84a0b9e87244e3c4526b9a5fdcf7888a2 Mon Sep 17 00:00:00 2001 From: autumn Date: Sat, 10 Jul 2021 11:57:56 +0800 Subject: [PATCH 23/32] =?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 @@