From 4cd4509cb92bd3091bf912102e4bdf8550e8b783 Mon Sep 17 00:00:00 2001 From: next-autumn Date: Fri, 21 May 2021 18:03:40 +0800 Subject: [PATCH] save install xray/trojan-go --- ProxySuper.Core/Services/ProjectBase.cs | 4 +- .../Services/TrojanGoConfigBuilder.cs | 4 +- ProxySuper.Core/Services/TrojanGoProject.cs | 54 ++++++++- .../ViewModels/XrayInstallerViewModel.cs | 2 +- ProxySuper.WPF/ProxySuper.WPF.csproj | 114 ++++++++++++++++++ .../Templates/trojan-go/base.caddyfile | 9 ++ .../Templates/trojan-go/trojan-go.json | 16 +++ ProxySuper.WPF/Templates/xray/base.json | 12 ++ .../Templates/xray/caddy/base.caddyfile | 9 ++ .../Templates/xray/client/00_log/00_log.json | 5 + .../Templates/xray/client/01_api/01_api.json | 3 + .../Templates/xray/client/02_dns/02_dns.json | 3 + .../xray/client/03_routing/03_routing.json | 3 + .../xray/client/04_policy/04_policy.json | 3 + .../xray/client/05_inbounds/05_inbounds.json | 23 ++++ .../client/06_outbounds/06_outbounds.json | 3 + .../client/06_outbounds/VLESS_HTTP2_TLS.json | 31 +++++ .../client/06_outbounds/VLESS_TCP_TLS_WS.json | 32 +++++ .../client/07_transport/07_transport.json | 3 + .../xray/client/08_stats/08_stats.json | 3 + .../xray/client/09_reverse/09_reverse.json | 3 + .../Templates/xray/server/00_log/00_log.json | 6 + .../Templates/xray/server/01_api/01_api.json | 3 + .../Templates/xray/server/02_dns/02_dns.json | 3 + .../xray/server/03_routing/03_routing.json | 14 +++ .../xray/server/04_policy/04_policy.json | 3 + .../xray/server/05_inbounds/05_inbounds.json | 3 + .../server/05_inbounds/Shadowsocks-AEAD.json | 13 ++ .../xray/server/05_inbounds/Trojan_TCP.json | 24 ++++ .../xray/server/05_inbounds/Trojan_WS.json | 26 ++++ .../xray/server/05_inbounds/VLESS_HTTP2.json | 19 +++ .../xray/server/05_inbounds/VLESS_KCP.json | 24 ++++ .../server/05_inbounds/VLESS_TCP_XTLS.json | 31 +++++ .../xray/server/05_inbounds/VLESS_WS.json | 21 ++++ .../xray/server/05_inbounds/VLESS_gRPC.json | 25 ++++ .../xray/server/05_inbounds/VMESS_HTTP2.json | 18 +++ .../xray/server/05_inbounds/VMESS_KCP.json | 23 ++++ .../xray/server/05_inbounds/VMESS_TCP.json | 27 +++++ .../xray/server/05_inbounds/VMESS_WS.json | 20 +++ .../server/06_outbounds/06_outbounds.json | 12 ++ .../server/07_transport/07_transport.json | 3 + .../xray/server/08_stats/08_stats.json | 3 + .../xray/server/09_reverse/09_reverse.json | 3 + .../Views/TrojanGoEditorView.xaml.cs | 2 +- .../Views/TrojanGoInstallerView.xaml | 8 +- .../Views/TrojanGoInstallerView.xaml.cs | 43 +++++-- ProxySuper.WPF/Views/XrayEditorView.xaml.cs | 2 +- ProxySuper.WPF/Views/XrayInstallerView.xaml | 3 +- .../Views/XrayInstallerView.xaml.cs | 2 +- 49 files changed, 698 insertions(+), 25 deletions(-) create mode 100644 ProxySuper.WPF/Templates/trojan-go/base.caddyfile create mode 100644 ProxySuper.WPF/Templates/trojan-go/trojan-go.json create mode 100644 ProxySuper.WPF/Templates/xray/base.json create mode 100644 ProxySuper.WPF/Templates/xray/caddy/base.caddyfile create mode 100644 ProxySuper.WPF/Templates/xray/client/00_log/00_log.json create mode 100644 ProxySuper.WPF/Templates/xray/client/01_api/01_api.json create mode 100644 ProxySuper.WPF/Templates/xray/client/02_dns/02_dns.json create mode 100644 ProxySuper.WPF/Templates/xray/client/03_routing/03_routing.json create mode 100644 ProxySuper.WPF/Templates/xray/client/04_policy/04_policy.json create mode 100644 ProxySuper.WPF/Templates/xray/client/05_inbounds/05_inbounds.json create mode 100644 ProxySuper.WPF/Templates/xray/client/06_outbounds/06_outbounds.json create mode 100644 ProxySuper.WPF/Templates/xray/client/06_outbounds/VLESS_HTTP2_TLS.json create mode 100644 ProxySuper.WPF/Templates/xray/client/06_outbounds/VLESS_TCP_TLS_WS.json create mode 100644 ProxySuper.WPF/Templates/xray/client/07_transport/07_transport.json create mode 100644 ProxySuper.WPF/Templates/xray/client/08_stats/08_stats.json create mode 100644 ProxySuper.WPF/Templates/xray/client/09_reverse/09_reverse.json create mode 100644 ProxySuper.WPF/Templates/xray/server/00_log/00_log.json create mode 100644 ProxySuper.WPF/Templates/xray/server/01_api/01_api.json create mode 100644 ProxySuper.WPF/Templates/xray/server/02_dns/02_dns.json create mode 100644 ProxySuper.WPF/Templates/xray/server/03_routing/03_routing.json create mode 100644 ProxySuper.WPF/Templates/xray/server/04_policy/04_policy.json create mode 100644 ProxySuper.WPF/Templates/xray/server/05_inbounds/05_inbounds.json create mode 100644 ProxySuper.WPF/Templates/xray/server/05_inbounds/Shadowsocks-AEAD.json create mode 100644 ProxySuper.WPF/Templates/xray/server/05_inbounds/Trojan_TCP.json create mode 100644 ProxySuper.WPF/Templates/xray/server/05_inbounds/Trojan_WS.json create mode 100644 ProxySuper.WPF/Templates/xray/server/05_inbounds/VLESS_HTTP2.json create mode 100644 ProxySuper.WPF/Templates/xray/server/05_inbounds/VLESS_KCP.json create mode 100644 ProxySuper.WPF/Templates/xray/server/05_inbounds/VLESS_TCP_XTLS.json create mode 100644 ProxySuper.WPF/Templates/xray/server/05_inbounds/VLESS_WS.json create mode 100644 ProxySuper.WPF/Templates/xray/server/05_inbounds/VLESS_gRPC.json create mode 100644 ProxySuper.WPF/Templates/xray/server/05_inbounds/VMESS_HTTP2.json create mode 100644 ProxySuper.WPF/Templates/xray/server/05_inbounds/VMESS_KCP.json create mode 100644 ProxySuper.WPF/Templates/xray/server/05_inbounds/VMESS_TCP.json create mode 100644 ProxySuper.WPF/Templates/xray/server/05_inbounds/VMESS_WS.json create mode 100644 ProxySuper.WPF/Templates/xray/server/06_outbounds/06_outbounds.json create mode 100644 ProxySuper.WPF/Templates/xray/server/07_transport/07_transport.json create mode 100644 ProxySuper.WPF/Templates/xray/server/08_stats/08_stats.json create mode 100644 ProxySuper.WPF/Templates/xray/server/09_reverse/09_reverse.json diff --git a/ProxySuper.Core/Services/ProjectBase.cs b/ProxySuper.Core/Services/ProjectBase.cs index 6fdacc4..71ba5db 100644 --- a/ProxySuper.Core/Services/ProjectBase.cs +++ b/ProxySuper.Core/Services/ProjectBase.cs @@ -619,8 +619,8 @@ namespace ProxySuper.Core.Services /// protected void InstallCert(string dirPath, string certName, string keyName) { - string certPath = Path.Combine(dirPath, certName); - string keyPath = Path.Combine(dirPath, keyName); + string certPath = dirPath + "/" + certName; + string keyPath = dirPath + "/" + keyName; // 安装依赖 RunCmd(GetInstallCmd("socat")); diff --git a/ProxySuper.Core/Services/TrojanGoConfigBuilder.cs b/ProxySuper.Core/Services/TrojanGoConfigBuilder.cs index 770274a..e1151de 100644 --- a/ProxySuper.Core/Services/TrojanGoConfigBuilder.cs +++ b/ProxySuper.Core/Services/TrojanGoConfigBuilder.cs @@ -37,8 +37,8 @@ namespace ProxySuper.Core.Services public static string BuildCaddyConfig(TrojanGoSettings parameters, bool useCustomWeb = false) { var caddyStr = File.ReadAllText(CaddyFilePath); - caddyStr.Replace("##domain##", parameters.Domain); - caddyStr.Replace("##port##", WebPort.ToString()); + caddyStr = caddyStr.Replace("##domain##", parameters.Domain); + caddyStr = caddyStr.Replace("##port##", WebPort.ToString()); if (!useCustomWeb && !string.IsNullOrEmpty(parameters.MaskDomain)) { diff --git a/ProxySuper.Core/Services/TrojanGoProject.cs b/ProxySuper.Core/Services/TrojanGoProject.cs index e0b4125..ec08408 100644 --- a/ProxySuper.Core/Services/TrojanGoProject.cs +++ b/ProxySuper.Core/Services/TrojanGoProject.cs @@ -17,15 +17,58 @@ namespace ProxySuper.Core.Services { } + public void InstallCertToTrojanGo() + { + EnsureRootAuth(); + EnsureSystemEnv(); + InstallCert( + dirPath: "/usr/local/etc/trojan-go", + certName: "trojan-go.crt", + keyName: "trojan-go.key"); + + RunCmd("systemctl restart trojan-go"); + WriteOutput("************ 安装证书完成 ************"); + } + + public void UploadWeb(Stream stream) + { + EnsureRootAuth(); + EnsureSystemEnv(); + if (!FileExists("/usr/share/caddy")) + { + RunCmd("mkdir /usr/share/caddy"); + } + RunCmd("rm -rf /usr/share/caddy/*"); + UploadFile(stream, "/usr/share/caddy/caddy.zip"); + RunCmd("unzip /usr/share/caddy/caddy.zip -d /usr/share/caddy"); + RunCmd("chmod -R 777 /usr/share/caddy"); + UploadCaddyFile(useCustomWeb: true); + WriteOutput("************ 上传网站模板完成 ************"); + } + + public void Uninstall() + { + RunCmd("systemctl stop trojan-go"); + RunCmd("systemctl stop caddy"); + + RunCmd("rm -rf /usr/local/bin/trojan-go"); + RunCmd("rm -rf /usr/local/etc/trojan-go"); + + RunCmd("acme.sh --uninstall"); + RunCmd("rm -r ~/.acme.sh"); + + WriteOutput("卸载Trojan-Go完成"); + } + public override void Install() { try { EnsureRootAuth(); - if (FileExists("/usr/local/bin/xray")) + if (FileExists("/usr/local/bin/trojan-go")) { - var btnResult = MessageBox.Show("已经安装Xray,是否需要重装?", "提示", MessageBoxButton.YesNo); + var btnResult = MessageBox.Show("已经安装Trojan-Go,是否需要重装?", "提示", MessageBoxButton.YesNo); if (btnResult == MessageBoxResult.No) { MessageBox.Show("安装终止", "提示"); @@ -89,7 +132,7 @@ namespace ProxySuper.Core.Services { WriteOutput("安装Trojan-Go"); RunCmd(@"curl https://raw.githubusercontent.com/proxysu/shellscript/master/trojan-go.sh yes | bash"); - var success = FileExists("/usr/local/etc/trojan-go"); + var success = FileExists("/usr/local/bin/trojan-go"); if (success == false) { throw new Exception("trojan-go 安装失败,请联系开发者!"); @@ -114,6 +157,11 @@ namespace ProxySuper.Core.Services RunCmd("mv /usr/local/etc/trojan-go/config.json config.json.old"); } + UploadTrojanGoSettings(); + } + + private void UploadTrojanGoSettings() + { // 上传配置 var settings = TrojanGoConfigBuilder.BuildTrojanGoConfig(Parameters); var stream = new MemoryStream(Encoding.UTF8.GetBytes(settings)); diff --git a/ProxySuper.Core/ViewModels/XrayInstallerViewModel.cs b/ProxySuper.Core/ViewModels/XrayInstallerViewModel.cs index 39c9f61..d96a841 100644 --- a/ProxySuper.Core/ViewModels/XrayInstallerViewModel.cs +++ b/ProxySuper.Core/ViewModels/XrayInstallerViewModel.cs @@ -38,7 +38,7 @@ namespace ProxySuper.Core.ViewModels set { _connected = value; - RaisePropertyChanged("HasConnected"); + RaisePropertyChanged("Connected"); } } diff --git a/ProxySuper.WPF/ProxySuper.WPF.csproj b/ProxySuper.WPF/ProxySuper.WPF.csproj index 31fab7b..6661ee0 100644 --- a/ProxySuper.WPF/ProxySuper.WPF.csproj +++ b/ProxySuper.WPF/ProxySuper.WPF.csproj @@ -178,6 +178,120 @@ SettingsSingleFileGenerator Settings.Designer.cs + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + diff --git a/ProxySuper.WPF/Templates/trojan-go/base.caddyfile b/ProxySuper.WPF/Templates/trojan-go/base.caddyfile new file mode 100644 index 0000000..7975d73 --- /dev/null +++ b/ProxySuper.WPF/Templates/trojan-go/base.caddyfile @@ -0,0 +1,9 @@ +:##port## { + root * /usr/share/caddy + file_server + ##reverse_proxy## +} + +##domain##:80 { + redir https://##domain##{uri} +} \ No newline at end of file diff --git a/ProxySuper.WPF/Templates/trojan-go/trojan-go.json b/ProxySuper.WPF/Templates/trojan-go/trojan-go.json new file mode 100644 index 0000000..acb0207 --- /dev/null +++ b/ProxySuper.WPF/Templates/trojan-go/trojan-go.json @@ -0,0 +1,16 @@ +{ + "run_type": "server", + "local_addr": "0.0.0.0", + "local_port": 443, + "remote_addr": "127.0.0.1", + "remote_port": 80, + "password": [ + "" + ], + "ssl": { + "cert": "/usr/local/etc/trojan-go/trojan-go.crt", + "key": "/usr/local/etc/trojan-go/trojan-go.key", + "sni": "" + } + +} diff --git a/ProxySuper.WPF/Templates/xray/base.json b/ProxySuper.WPF/Templates/xray/base.json new file mode 100644 index 0000000..84a9d1f --- /dev/null +++ b/ProxySuper.WPF/Templates/xray/base.json @@ -0,0 +1,12 @@ +{ + "log": {}, + "api": {}, + "dns": {}, + "routing": {}, + "policy": {}, + "inbounds": [], + "outbounds": [], + "transport": {}, + "stats": {}, + "reverse": {} +} \ No newline at end of file diff --git a/ProxySuper.WPF/Templates/xray/caddy/base.caddyfile b/ProxySuper.WPF/Templates/xray/caddy/base.caddyfile new file mode 100644 index 0000000..7975d73 --- /dev/null +++ b/ProxySuper.WPF/Templates/xray/caddy/base.caddyfile @@ -0,0 +1,9 @@ +:##port## { + root * /usr/share/caddy + file_server + ##reverse_proxy## +} + +##domain##:80 { + redir https://##domain##{uri} +} \ No newline at end of file diff --git a/ProxySuper.WPF/Templates/xray/client/00_log/00_log.json b/ProxySuper.WPF/Templates/xray/client/00_log/00_log.json new file mode 100644 index 0000000..6a4cf00 --- /dev/null +++ b/ProxySuper.WPF/Templates/xray/client/00_log/00_log.json @@ -0,0 +1,5 @@ +{ + "log": { + "loglevel": "warning" + } +} \ No newline at end of file diff --git a/ProxySuper.WPF/Templates/xray/client/01_api/01_api.json b/ProxySuper.WPF/Templates/xray/client/01_api/01_api.json new file mode 100644 index 0000000..aa1982b --- /dev/null +++ b/ProxySuper.WPF/Templates/xray/client/01_api/01_api.json @@ -0,0 +1,3 @@ +{ + "api": null +} \ No newline at end of file diff --git a/ProxySuper.WPF/Templates/xray/client/02_dns/02_dns.json b/ProxySuper.WPF/Templates/xray/client/02_dns/02_dns.json new file mode 100644 index 0000000..63472d2 --- /dev/null +++ b/ProxySuper.WPF/Templates/xray/client/02_dns/02_dns.json @@ -0,0 +1,3 @@ +{ + "dns": {} +} \ No newline at end of file diff --git a/ProxySuper.WPF/Templates/xray/client/03_routing/03_routing.json b/ProxySuper.WPF/Templates/xray/client/03_routing/03_routing.json new file mode 100644 index 0000000..a187d31 --- /dev/null +++ b/ProxySuper.WPF/Templates/xray/client/03_routing/03_routing.json @@ -0,0 +1,3 @@ +{ + "routing": {} +} \ No newline at end of file diff --git a/ProxySuper.WPF/Templates/xray/client/04_policy/04_policy.json b/ProxySuper.WPF/Templates/xray/client/04_policy/04_policy.json new file mode 100644 index 0000000..4beed61 --- /dev/null +++ b/ProxySuper.WPF/Templates/xray/client/04_policy/04_policy.json @@ -0,0 +1,3 @@ +{ + "policy": {} +} \ No newline at end of file diff --git a/ProxySuper.WPF/Templates/xray/client/05_inbounds/05_inbounds.json b/ProxySuper.WPF/Templates/xray/client/05_inbounds/05_inbounds.json new file mode 100644 index 0000000..c402972 --- /dev/null +++ b/ProxySuper.WPF/Templates/xray/client/05_inbounds/05_inbounds.json @@ -0,0 +1,23 @@ +{ + "inbounds": [ + { + "protocol": "http", + "port": 1081 + }, + { + "port": 1080, + "protocol": "socks", + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + }, + "settings": { + "udp": true, + "auth": "noauth" + } + } + ] +} \ No newline at end of file diff --git a/ProxySuper.WPF/Templates/xray/client/06_outbounds/06_outbounds.json b/ProxySuper.WPF/Templates/xray/client/06_outbounds/06_outbounds.json new file mode 100644 index 0000000..20e2beb --- /dev/null +++ b/ProxySuper.WPF/Templates/xray/client/06_outbounds/06_outbounds.json @@ -0,0 +1,3 @@ +{ + "outbounds": [] +} \ No newline at end of file diff --git a/ProxySuper.WPF/Templates/xray/client/06_outbounds/VLESS_HTTP2_TLS.json b/ProxySuper.WPF/Templates/xray/client/06_outbounds/VLESS_HTTP2_TLS.json new file mode 100644 index 0000000..8718383 --- /dev/null +++ b/ProxySuper.WPF/Templates/xray/client/06_outbounds/VLESS_HTTP2_TLS.json @@ -0,0 +1,31 @@ +{ + "outbounds": [ + { + "protocol": "vless", + "settings": { + "vnext": [ + { + "address": "", + "port": 443, + "users": [ + { + "id": "", + "encryption": "none" + } + ] + } + ] + }, + "streamSettings": { + "network": "h2", + "security": "tls", + "httpSettings": { + "host": [ + "" + ], + "path": null + } + } + } + ] +} diff --git a/ProxySuper.WPF/Templates/xray/client/06_outbounds/VLESS_TCP_TLS_WS.json b/ProxySuper.WPF/Templates/xray/client/06_outbounds/VLESS_TCP_TLS_WS.json new file mode 100644 index 0000000..7a3c871 --- /dev/null +++ b/ProxySuper.WPF/Templates/xray/client/06_outbounds/VLESS_TCP_TLS_WS.json @@ -0,0 +1,32 @@ +{ + "outbounds": [ + { + "protocol": "vless", + "settings": { + "vnext": [ + { + "address": "", + "port": 443, + "users": [ + { + "id": "", + "encryption": "none", + "level": 0 + } + ] + } + ] + }, + "streamSettings": { + "network": "ws", + "security": "tls", + "tlsSettings": { + "serverName": "" + }, + "wsSettings": { + "path": "" + } + } + } + ] +} diff --git a/ProxySuper.WPF/Templates/xray/client/07_transport/07_transport.json b/ProxySuper.WPF/Templates/xray/client/07_transport/07_transport.json new file mode 100644 index 0000000..6269103 --- /dev/null +++ b/ProxySuper.WPF/Templates/xray/client/07_transport/07_transport.json @@ -0,0 +1,3 @@ +{ + "transport": {} +} \ No newline at end of file diff --git a/ProxySuper.WPF/Templates/xray/client/08_stats/08_stats.json b/ProxySuper.WPF/Templates/xray/client/08_stats/08_stats.json new file mode 100644 index 0000000..02c9ed0 --- /dev/null +++ b/ProxySuper.WPF/Templates/xray/client/08_stats/08_stats.json @@ -0,0 +1,3 @@ +{ + "stats": null +} \ No newline at end of file diff --git a/ProxySuper.WPF/Templates/xray/client/09_reverse/09_reverse.json b/ProxySuper.WPF/Templates/xray/client/09_reverse/09_reverse.json new file mode 100644 index 0000000..6fa38a4 --- /dev/null +++ b/ProxySuper.WPF/Templates/xray/client/09_reverse/09_reverse.json @@ -0,0 +1,3 @@ +{ + "reverse": {} +} \ No newline at end of file diff --git a/ProxySuper.WPF/Templates/xray/server/00_log/00_log.json b/ProxySuper.WPF/Templates/xray/server/00_log/00_log.json new file mode 100644 index 0000000..40c2cd5 --- /dev/null +++ b/ProxySuper.WPF/Templates/xray/server/00_log/00_log.json @@ -0,0 +1,6 @@ +{ + "log": { + "access": "none", + "loglevel": "none" + } +} \ No newline at end of file diff --git a/ProxySuper.WPF/Templates/xray/server/01_api/01_api.json b/ProxySuper.WPF/Templates/xray/server/01_api/01_api.json new file mode 100644 index 0000000..34c6b17 --- /dev/null +++ b/ProxySuper.WPF/Templates/xray/server/01_api/01_api.json @@ -0,0 +1,3 @@ +{ + "api": {} +} \ No newline at end of file diff --git a/ProxySuper.WPF/Templates/xray/server/02_dns/02_dns.json b/ProxySuper.WPF/Templates/xray/server/02_dns/02_dns.json new file mode 100644 index 0000000..63472d2 --- /dev/null +++ b/ProxySuper.WPF/Templates/xray/server/02_dns/02_dns.json @@ -0,0 +1,3 @@ +{ + "dns": {} +} \ No newline at end of file diff --git a/ProxySuper.WPF/Templates/xray/server/03_routing/03_routing.json b/ProxySuper.WPF/Templates/xray/server/03_routing/03_routing.json new file mode 100644 index 0000000..0aa4964 --- /dev/null +++ b/ProxySuper.WPF/Templates/xray/server/03_routing/03_routing.json @@ -0,0 +1,14 @@ +{ + "routing": { + "domainStrategy": "AsIs", + "rules": [ + { + "type": "field", + "ip": [ + "geoip:private" + ], + "outboundTag": "block" + } + ] + } +} \ No newline at end of file diff --git a/ProxySuper.WPF/Templates/xray/server/04_policy/04_policy.json b/ProxySuper.WPF/Templates/xray/server/04_policy/04_policy.json new file mode 100644 index 0000000..4beed61 --- /dev/null +++ b/ProxySuper.WPF/Templates/xray/server/04_policy/04_policy.json @@ -0,0 +1,3 @@ +{ + "policy": {} +} \ No newline at end of file diff --git a/ProxySuper.WPF/Templates/xray/server/05_inbounds/05_inbounds.json b/ProxySuper.WPF/Templates/xray/server/05_inbounds/05_inbounds.json new file mode 100644 index 0000000..24465ae --- /dev/null +++ b/ProxySuper.WPF/Templates/xray/server/05_inbounds/05_inbounds.json @@ -0,0 +1,3 @@ +{ + "inbounds": [] +} diff --git a/ProxySuper.WPF/Templates/xray/server/05_inbounds/Shadowsocks-AEAD.json b/ProxySuper.WPF/Templates/xray/server/05_inbounds/Shadowsocks-AEAD.json new file mode 100644 index 0000000..e7179e5 --- /dev/null +++ b/ProxySuper.WPF/Templates/xray/server/05_inbounds/Shadowsocks-AEAD.json @@ -0,0 +1,13 @@ +{ + "port": 12345, + "protocol": "shadowsocks", + "settings": { + "clients": [ + { + "password": "", + "method": "aes-128-gcm" + } + ], + "network": "tcp,udp" + } +} \ No newline at end of file diff --git a/ProxySuper.WPF/Templates/xray/server/05_inbounds/Trojan_TCP.json b/ProxySuper.WPF/Templates/xray/server/05_inbounds/Trojan_TCP.json new file mode 100644 index 0000000..8ea5ad9 --- /dev/null +++ b/ProxySuper.WPF/Templates/xray/server/05_inbounds/Trojan_TCP.json @@ -0,0 +1,24 @@ +{ + "port": 1310, + "listen": "127.0.0.1", + "protocol": "trojan", + "settings": { + "clients": [ + { + "password": "" + } + ], + "fallbacks": [ + { + "dest": 8080 + } + ] + }, + "streamSettings": { + "network": "tcp", + "security": "none", + "tcpSettings": { + "acceptProxyProtocol": true + } + } +} diff --git a/ProxySuper.WPF/Templates/xray/server/05_inbounds/Trojan_WS.json b/ProxySuper.WPF/Templates/xray/server/05_inbounds/Trojan_WS.json new file mode 100644 index 0000000..51d725c --- /dev/null +++ b/ProxySuper.WPF/Templates/xray/server/05_inbounds/Trojan_WS.json @@ -0,0 +1,26 @@ +{ + "port": 1320, + "listen": "127.0.0.1", + "protocol": "trojan", + "settings": { + "clients": [ + { + "password": "" + } + ], + "fallbacks": [ + { + "dest": 80 + } + ] + }, + + "streamSettings": { + "network": "ws", + "security": "none", + "wsSettings": { + "acceptProxyProtocol": true, + "path": "/trojanws" + } + } +} diff --git a/ProxySuper.WPF/Templates/xray/server/05_inbounds/VLESS_HTTP2.json b/ProxySuper.WPF/Templates/xray/server/05_inbounds/VLESS_HTTP2.json new file mode 100644 index 0000000..a99e848 --- /dev/null +++ b/ProxySuper.WPF/Templates/xray/server/05_inbounds/VLESS_HTTP2.json @@ -0,0 +1,19 @@ +{ + "port": 1234, + "listen": "127.0.0.1", + "protocol": "vmess", + "settings": { + "decryption": "none", + "clients": [ + { + "id": "" + } + ] + }, + "streamSettings": { + "network": "h2", + "httpSettings": { + "path": "" + } + } +} \ No newline at end of file diff --git a/ProxySuper.WPF/Templates/xray/server/05_inbounds/VLESS_KCP.json b/ProxySuper.WPF/Templates/xray/server/05_inbounds/VLESS_KCP.json new file mode 100644 index 0000000..a619549 --- /dev/null +++ b/ProxySuper.WPF/Templates/xray/server/05_inbounds/VLESS_KCP.json @@ -0,0 +1,24 @@ +{ + "port": 3456, + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "mkcp", + "kcpSettings": { + "uplinkCapacity": 100, + "downlinkCapacity": 100, + "congestion": true, + "header": { + "type": "none" + }, + "seed": null + } + } +} diff --git a/ProxySuper.WPF/Templates/xray/server/05_inbounds/VLESS_TCP_XTLS.json b/ProxySuper.WPF/Templates/xray/server/05_inbounds/VLESS_TCP_XTLS.json new file mode 100644 index 0000000..eab8363 --- /dev/null +++ b/ProxySuper.WPF/Templates/xray/server/05_inbounds/VLESS_TCP_XTLS.json @@ -0,0 +1,31 @@ +{ + "port": 443, + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "", + "flow": "xtls-rprx-direct" + } + ], + "decryption": "none", + "fallbacks": [] + }, + "streamSettings": { + "network": "tcp", + "security": "xtls", + "xtlsSettings": { + "allowInsecure": false, + "minVersion": "1.2", + "alpn": [ + "http/1.1" + ], + "certificates": [ + { + "certificateFile": "/usr/local/etc/xray/ssl/xray_ssl.crt", + "keyFile": "/usr/local/etc/xray/ssl/xray_ssl.key" + } + ] + } + } +} \ No newline at end of file diff --git a/ProxySuper.WPF/Templates/xray/server/05_inbounds/VLESS_WS.json b/ProxySuper.WPF/Templates/xray/server/05_inbounds/VLESS_WS.json new file mode 100644 index 0000000..0abf2e8 --- /dev/null +++ b/ProxySuper.WPF/Templates/xray/server/05_inbounds/VLESS_WS.json @@ -0,0 +1,21 @@ +{ + "port": 1234, + "listen": "127.0.0.1", + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "ws", + "security": "none", + "wsSettings": { + "acceptProxyProtocol": true, + "path": "/websocket" + } + } +} diff --git a/ProxySuper.WPF/Templates/xray/server/05_inbounds/VLESS_gRPC.json b/ProxySuper.WPF/Templates/xray/server/05_inbounds/VLESS_gRPC.json new file mode 100644 index 0000000..319888d --- /dev/null +++ b/ProxySuper.WPF/Templates/xray/server/05_inbounds/VLESS_gRPC.json @@ -0,0 +1,25 @@ +{ + "port": 2002, + "listen": "127.0.0.1", + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "grpc", + "grpcSettings": { + "serviceName": "", + "certificates": [ + { + "certificateFile": "/usr/local/etc/xray/ssl/xray_ssl.crt", + "keyFile": "/usr/local/etc/xray/ssl/xray_ssl.key" + } + ] + } + } +} diff --git a/ProxySuper.WPF/Templates/xray/server/05_inbounds/VMESS_HTTP2.json b/ProxySuper.WPF/Templates/xray/server/05_inbounds/VMESS_HTTP2.json new file mode 100644 index 0000000..9957e76 --- /dev/null +++ b/ProxySuper.WPF/Templates/xray/server/05_inbounds/VMESS_HTTP2.json @@ -0,0 +1,18 @@ +{ + "port": 1234, + "listen": "127.0.0.1", + "protocol": "vmess", + "settings": { + "clients": [ + { + "id": "" + } + ] + }, + "streamSettings": { + "network": "h2", + "httpSettings": { + "path": "" + } + } +} \ No newline at end of file diff --git a/ProxySuper.WPF/Templates/xray/server/05_inbounds/VMESS_KCP.json b/ProxySuper.WPF/Templates/xray/server/05_inbounds/VMESS_KCP.json new file mode 100644 index 0000000..0c3ea2b --- /dev/null +++ b/ProxySuper.WPF/Templates/xray/server/05_inbounds/VMESS_KCP.json @@ -0,0 +1,23 @@ +{ + "port": 3456, + "protocol": "vmess", + "settings": { + "clients": [ + { + "id": "" + } + ] + }, + "streamSettings": { + "network": "mkcp", + "kcpSettings": { + "uplinkCapacity": 100, + "downlinkCapacity": 100, + "congestion": true, + "header": { + "type": "none" + }, + "seed": null + } + } +} diff --git a/ProxySuper.WPF/Templates/xray/server/05_inbounds/VMESS_TCP.json b/ProxySuper.WPF/Templates/xray/server/05_inbounds/VMESS_TCP.json new file mode 100644 index 0000000..b14181e --- /dev/null +++ b/ProxySuper.WPF/Templates/xray/server/05_inbounds/VMESS_TCP.json @@ -0,0 +1,27 @@ +{ + "port": 443, + "listen": "127.0.0.1", + "protocol": "vmess", + "settings": { + "clients": [ + { + "id": "" + } + ] + }, + "streamSettings": { + "network": "tcp", + "security": "none", + "tcpSettings": { + "acceptProxyProtocol": true, + "header": { + "type": "http", + "request": { + "path": [ + "/vmesstcp" + ] + } + } + } + } +} diff --git a/ProxySuper.WPF/Templates/xray/server/05_inbounds/VMESS_WS.json b/ProxySuper.WPF/Templates/xray/server/05_inbounds/VMESS_WS.json new file mode 100644 index 0000000..2e863a4 --- /dev/null +++ b/ProxySuper.WPF/Templates/xray/server/05_inbounds/VMESS_WS.json @@ -0,0 +1,20 @@ +{ + "port": 3456, + "listen": "127.0.0.1", + "protocol": "vmess", + "settings": { + "clients": [ + { + "id": "" + } + ] + }, + "streamSettings": { + "network": "ws", + "security": "none", + "wsSettings": { + "acceptProxyProtocol": true, + "path": "/vmessws" + } + } +} diff --git a/ProxySuper.WPF/Templates/xray/server/06_outbounds/06_outbounds.json b/ProxySuper.WPF/Templates/xray/server/06_outbounds/06_outbounds.json new file mode 100644 index 0000000..467a4e1 --- /dev/null +++ b/ProxySuper.WPF/Templates/xray/server/06_outbounds/06_outbounds.json @@ -0,0 +1,12 @@ +{ + "outbounds": [ + { + "protocol": "freedom", + "tag": "direct" + }, + { + "protocol": "blackhole", + "tag": "block" + } + ] +} \ No newline at end of file diff --git a/ProxySuper.WPF/Templates/xray/server/07_transport/07_transport.json b/ProxySuper.WPF/Templates/xray/server/07_transport/07_transport.json new file mode 100644 index 0000000..6269103 --- /dev/null +++ b/ProxySuper.WPF/Templates/xray/server/07_transport/07_transport.json @@ -0,0 +1,3 @@ +{ + "transport": {} +} \ No newline at end of file diff --git a/ProxySuper.WPF/Templates/xray/server/08_stats/08_stats.json b/ProxySuper.WPF/Templates/xray/server/08_stats/08_stats.json new file mode 100644 index 0000000..b406e15 --- /dev/null +++ b/ProxySuper.WPF/Templates/xray/server/08_stats/08_stats.json @@ -0,0 +1,3 @@ +{ + "stats": {} +} \ No newline at end of file diff --git a/ProxySuper.WPF/Templates/xray/server/09_reverse/09_reverse.json b/ProxySuper.WPF/Templates/xray/server/09_reverse/09_reverse.json new file mode 100644 index 0000000..6fa38a4 --- /dev/null +++ b/ProxySuper.WPF/Templates/xray/server/09_reverse/09_reverse.json @@ -0,0 +1,3 @@ +{ + "reverse": {} +} \ No newline at end of file diff --git a/ProxySuper.WPF/Views/TrojanGoEditorView.xaml.cs b/ProxySuper.WPF/Views/TrojanGoEditorView.xaml.cs index 8765002..bfbddbb 100644 --- a/ProxySuper.WPF/Views/TrojanGoEditorView.xaml.cs +++ b/ProxySuper.WPF/Views/TrojanGoEditorView.xaml.cs @@ -19,7 +19,7 @@ namespace ProxySuper.WPF.Views /// /// TrojanEditorView.xaml 的交互逻辑 /// - [MvxWindowPresentation(Identifier = nameof(XrayEditorView), Modal = true)] + [MvxWindowPresentation(Identifier = nameof(XrayEditorView), Modal = false)] public partial class TrojanGoEditorView : MvxWindow { public TrojanGoEditorView() diff --git a/ProxySuper.WPF/Views/TrojanGoInstallerView.xaml b/ProxySuper.WPF/Views/TrojanGoInstallerView.xaml index 8828d6d..d8c814a 100644 --- a/ProxySuper.WPF/Views/TrojanGoInstallerView.xaml +++ b/ProxySuper.WPF/Views/TrojanGoInstallerView.xaml @@ -8,7 +8,7 @@ mc:Ignorable="d" Icon="/Resources/ProxySU.ico" Title="TrojanGoInstallerView" Height="450" Width="800"> - + - + diff --git a/ProxySuper.WPF/Views/TrojanGoInstallerView.xaml.cs b/ProxySuper.WPF/Views/TrojanGoInstallerView.xaml.cs index 610f258..b3153e3 100644 --- a/ProxySuper.WPF/Views/TrojanGoInstallerView.xaml.cs +++ b/ProxySuper.WPF/Views/TrojanGoInstallerView.xaml.cs @@ -1,4 +1,5 @@ -using MvvmCross.Platforms.Wpf.Presenters.Attributes; +using Microsoft.Win32; +using MvvmCross.Platforms.Wpf.Presenters.Attributes; using MvvmCross.Platforms.Wpf.Views; using ProxySuper.Core.Models.Hosts; using ProxySuper.Core.Services; @@ -6,6 +7,7 @@ using ProxySuper.Core.ViewModels; using Renci.SshNet; using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -23,7 +25,7 @@ namespace ProxySuper.WPF.Views /// /// TrojanGoInstallerView.xaml 的交互逻辑 /// - [MvxWindowPresentation(Identifier = nameof(TrojanGoInstallerView), Modal = true)] + [MvxWindowPresentation(Identifier = nameof(TrojanGoInstallerView), Modal = false)] public partial class TrojanGoInstallerView : MvxWindow { public TrojanGoInstallerView() @@ -120,17 +122,42 @@ namespace ProxySuper.WPF.Views }; } - private void Install(object sender, RoutedEventArgs e) { } + private void Install(object sender, RoutedEventArgs e) + { + Task.Factory.StartNew(Project.Install); + } - private void UpdateSettings(object sender, RoutedEventArgs e) { } - private void Uninstall(object sender, RoutedEventArgs e) { } + private void Uninstall(object sender, RoutedEventArgs e) + { + Task.Factory.StartNew(Project.Uninstall); + } - private void UploadWeb(object sender, RoutedEventArgs e) { } + private void InstallCert(object sender, RoutedEventArgs e) + { + Task.Factory.StartNew(Project.InstallCertToTrojanGo); + } - private void UploadCert(object sender, RoutedEventArgs e) { } - private void InstallCert(object sender, RoutedEventArgs e) { } + private void UploadWeb(object sender, RoutedEventArgs e) + { + var fileDialog = new OpenFileDialog(); + fileDialog.Filter = "压缩文件|*.zip"; + fileDialog.FileOk += DoUploadWeb; + fileDialog.ShowDialog(); + } + + private void DoUploadWeb(object sender, CancelEventArgs e) + { + Task.Factory.StartNew(() => + { + var file = sender as OpenFileDialog; + using (var stream = file.OpenFile()) + { + Project.UploadWeb(stream); + } + }); + } } } diff --git a/ProxySuper.WPF/Views/XrayEditorView.xaml.cs b/ProxySuper.WPF/Views/XrayEditorView.xaml.cs index d9f60d6..d6ad3b7 100644 --- a/ProxySuper.WPF/Views/XrayEditorView.xaml.cs +++ b/ProxySuper.WPF/Views/XrayEditorView.xaml.cs @@ -19,7 +19,7 @@ namespace ProxySuper.WPF.Views /// /// XrayEditorView.xaml 的交互逻辑 /// - [MvxWindowPresentation(Identifier = nameof(XrayEditorView), Modal = true)] + [MvxWindowPresentation(Identifier = nameof(XrayEditorView), Modal = false)] public partial class XrayEditorView : MvxWindow { public XrayEditorView() diff --git a/ProxySuper.WPF/Views/XrayInstallerView.xaml b/ProxySuper.WPF/Views/XrayInstallerView.xaml index 3d73fb0..3d94db0 100644 --- a/ProxySuper.WPF/Views/XrayInstallerView.xaml +++ b/ProxySuper.WPF/Views/XrayInstallerView.xaml @@ -6,6 +6,7 @@ xmlns:views="clr-namespace:MvvmCross.Platforms.Wpf.Views;assembly=MvvmCross.Platforms.Wpf" xmlns:local="clr-namespace:ProxySuper.WPF.Views" mc:Ignorable="d" + WindowStartupLocation="CenterScreen" Icon="/Resources/ProxySU.ico" Title="XrayInstallerView" Height="450" Width="800"> @@ -34,7 +35,7 @@ diff --git a/ProxySuper.WPF/Views/XrayInstallerView.xaml.cs b/ProxySuper.WPF/Views/XrayInstallerView.xaml.cs index f55302e..5289ca3 100644 --- a/ProxySuper.WPF/Views/XrayInstallerView.xaml.cs +++ b/ProxySuper.WPF/Views/XrayInstallerView.xaml.cs @@ -17,7 +17,7 @@ namespace ProxySuper.WPF.Views /// /// XrayInstallerView.xaml 的交互逻辑 /// - [MvxWindowPresentation(Identifier = nameof(XrayInstallerView), Modal = true)] + [MvxWindowPresentation(Identifier = nameof(XrayInstallerView), Modal = false)] public partial class XrayInstallerView : MvxWindow { public XrayInstallerView()