diff --git a/ProxySU_Core/Converters/VisibleConverter.cs b/ProxySU_Core/Converters/VisibleConverter.cs new file mode 100644 index 0000000..f52a08d --- /dev/null +++ b/ProxySU_Core/Converters/VisibleConverter.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Data; + +namespace ProxySU_Core.Converters +{ + public class VisibleConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return value.Equals(true) ? Visibility.Visible : Visibility.Collapsed; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value == null) + { + return false; + } + + if (value.Equals(Visibility.Visible)) + { + return true; + } + + return false; + } + } +} diff --git a/ProxySU_Core/Models/Developers/ConfigBuilder.cs b/ProxySU_Core/Models/Developers/ConfigBuilder.cs index 78bb2d8..fdd6425 100644 --- a/ProxySU_Core/Models/Developers/ConfigBuilder.cs +++ b/ProxySU_Core/Models/Developers/ConfigBuilder.cs @@ -38,6 +38,8 @@ namespace ProxySU_Core.Models.Developers public const int Trojan_TCP_Port = 3110; public const int Trojan_WS_Port = 3111; + public const int ShadowSocksPort = 4110; + public static dynamic LoadXrayConfig() { @@ -95,7 +97,7 @@ namespace ProxySU_Core.Models.Developers public static string BuildXrayConfig(XraySettings parameters) { var xrayConfig = LoadXrayConfig(); - var baseBound = LoadJsonObj(Path.Combine(ServerInboundsDir, "VLESS_TCP_XTLS.json")); + var baseBound = GetBound("VLESS_TCP_XTLS.json"); baseBound.port = parameters.Port; baseBound.settings.fallbacks.Add(JToken.FromObject(new { @@ -104,42 +106,24 @@ namespace ProxySU_Core.Models.Developers xrayConfig.inbounds.Add(baseBound); baseBound.settings.clients[0].id = parameters.UUID; - if (parameters.Types.Contains(XrayType.VLESS_WS_TLS)) + if (parameters.Types.Contains(XrayType.VLESS_WS)) { - var wsInbound = LoadJsonObj(Path.Combine(ServerInboundsDir, "VLESS_WS_TLS.json")); + var wsInbound = GetBound("VLESS_WS.json"); wsInbound.port = VLESS_WS_Port; wsInbound.settings.clients[0].id = parameters.UUID; wsInbound.streamSettings.wsSettings.path = parameters.VLESS_WS_Path; baseBound.settings.fallbacks.Add(JToken.FromObject(new { dest = VLESS_WS_Port, - path = parameters.VLESS_WS_Path + path = parameters.VLESS_WS_Path, + xver = 1, })); xrayConfig.inbounds.Add(JToken.FromObject(wsInbound)); } - if (parameters.Types.Contains(XrayType.VLESS_H2_TLS)) + if (parameters.Types.Contains(XrayType.VMESS_TCP)) { - var h2Inbound = LoadJsonObj(Path.Combine(ServerInboundsDir, "VLESS_HTTP2_TLS.json")); - h2Inbound.port = VLESS_H2_Port; - h2Inbound.settings.clients[0].id = parameters.UUID; - h2Inbound.streamSettings.httpSettings.path = parameters.VLESS_H2_Path; - baseBound.settings.fallbacks.Add(JToken.FromObject(new - { - dest = VLESS_H2_Port, - path = parameters.VLESS_H2_Path - })); - xrayConfig.inbounds.Add(JToken.FromObject(h2Inbound)); - } - - if (parameters.Types.Contains(XrayType.VLESS_mKCP_Speed)) - { - var kcpInbound = LoadJsonObj(Path.Combine(ServerInboundsDir, "VLESS_mKCP")); - } - - if (parameters.Types.Contains(XrayType.VMESS_TCP_TLS)) - { - var mtcpBound = LoadJsonObj(Path.Combine(ServerInboundsDir, "VMESS_TCP_TLS.json")); + var mtcpBound = GetBound("VMESS_TCP.json"); mtcpBound.port = VMESS_TCP_Port; mtcpBound.settings.clients[0].id = parameters.UUID; mtcpBound.streamSettings.tcpSettings.header.request.path = parameters.VMESS_TCP_Path; @@ -152,9 +136,9 @@ namespace ProxySU_Core.Models.Developers xrayConfig.inbounds.Add(JToken.FromObject(mtcpBound)); } - if (parameters.Types.Contains(XrayType.VMESS_WS_TLS)) + if (parameters.Types.Contains(XrayType.VMESS_WS)) { - var mwsBound = LoadJsonObj(Path.Combine(ServerInboundsDir, "VMESS_WS_TLS.json")); + var mwsBound = GetBound("VMESS_WS.json"); mwsBound.port = VMESS_WS_Port; mwsBound.settings.clients[0].id = parameters.UUID; mwsBound.streamSettings.wsSettings.path = parameters.VMESS_WS_Path; @@ -167,13 +151,9 @@ namespace ProxySU_Core.Models.Developers xrayConfig.inbounds.Add(JToken.FromObject(mwsBound)); } - if (parameters.Types.Contains(XrayType.VMESS_H2_TLS)) { } - - if (parameters.Types.Contains(XrayType.VMESS_mKCP_Speed)) { } - - if (parameters.Types.Contains(XrayType.Trojan_TCP_TLS)) + if (parameters.Types.Contains(XrayType.Trojan_TCP)) { - var trojanTcpBound = LoadJsonObj(Path.Combine(ServerInboundsDir, "Trojan_TCP_TLS.json")); + var trojanTcpBound = GetBound("Trojan_TCP.json"); trojanTcpBound.port = Trojan_TCP_Port; trojanTcpBound.settings.clients[0].password = parameters.TrojanPassword; baseBound.settings.fallbacks[0] = JToken.FromObject(new @@ -184,7 +164,25 @@ namespace ProxySU_Core.Models.Developers xrayConfig.inbounds.Add(JToken.FromObject(trojanTcpBound)); } - if (parameters.Types.Contains(XrayType.Trojan_WS_TLS)) { } + if (parameters.Types.Contains(XrayType.VMESS_KCP)) + { + var kcpBound = GetBound("VMESS_KCP.json"); + kcpBound.port = VMESS_mKCP_Port; + kcpBound.settings.clients[0].id = parameters.UUID; + kcpBound.streamSettings.kcpSettings.header.type = parameters.VMESS_KCP_Type; + kcpBound.streamSettings.kcpSettings.seed = parameters.VMESS_KCP_Seed; + xrayConfig.inbounds.Add(JToken.FromObject(kcpBound)); + } + + + if (parameters.Types.Contains(XrayType.ShadowsocksAEAD)) + { + var ssBound = GetBound("Shadowsocks-AEAD.json"); + ssBound.port = ShadowSocksPort; + ssBound.settings.clients[0].password = parameters.ShadowsocksPassword; + ssBound.settings.clients[0].method = parameters.ShadowsocksMethod; + xrayConfig.inbounds.Add(JToken.FromObject(ssBound)); + } return JsonConvert.SerializeObject( xrayConfig, @@ -195,6 +193,11 @@ namespace ProxySU_Core.Models.Developers }); } + private static dynamic GetBound(string name) + { + return LoadJsonObj(Path.Combine(ServerInboundsDir, name)); + } + private static dynamic LoadJsonObj(string path) { if (File.Exists(path)) diff --git a/ProxySU_Core/Models/Developers/IParameters.cs b/ProxySU_Core/Models/Developers/IParameters.cs index 11554c0..e532214 100644 --- a/ProxySU_Core/Models/Developers/IParameters.cs +++ b/ProxySU_Core/Models/Developers/IParameters.cs @@ -9,5 +9,7 @@ namespace ProxySU_Core.Models.Developers int Port { get; set; } string Domain { get; set; } + + List Types { get; set; } } } diff --git a/ProxySU_Core/Models/Developers/Project.cs b/ProxySU_Core/Models/Developers/Project.cs index c0bc53a..7f23b83 100644 --- a/ProxySU_Core/Models/Developers/Project.cs +++ b/ProxySU_Core/Models/Developers/Project.cs @@ -222,10 +222,7 @@ namespace ProxySU_Core.Models.Developers } } - /// - /// 配置防火墙 - /// - protected void ConfigureFirewall() + protected void ClosePort(params int[] portList) { string cmd; @@ -240,43 +237,88 @@ namespace ProxySU_Core.Models.Developers RunCmd("systemctl restart firewalld"); } - if (Parameters.Port == 443) + foreach (var port in portList) { - RunCmd("firewall-cmd --zone=public --add-port=80/tcp --permanent"); - RunCmd("firewall-cmd --zone=public --add-port=443/tcp --permanent"); - RunCmd("firewall-cmd --zone=public --add-port=80/udp --permanent"); - RunCmd("firewall-cmd --zone=public --add-port=443/udp --permanent"); - RunCmd("yes | firewall-cmd --reload"); + RunCmd($"firewall-cmd --zone=public --remove-port={port}/tcp --permanent"); + RunCmd($"firewall-cmd --zone=public --remove-port={port}/udp --permanent"); } - else - { - RunCmd($"firewall-cmd --zone=public --add-port={Parameters.Port}/tcp --permanent"); - RunCmd($"firewall-cmd --zone=public --add-port={Parameters.Port}/udp --permanent"); - RunCmd("yes | firewall-cmd --reload"); - } - return; + RunCmd("yes | firewall-cmd --reload"); } + else + { + cmd = RunCmd("command -v ufw"); + if (!string.IsNullOrEmpty(cmd)) + { + foreach (var port in portList) + { + RunCmd($"ufw delete allow {port}/tcp"); + RunCmd($"ufw delete allow {port}/udp"); + } + RunCmd("yes | ufw reload"); + } + } + } - cmd = RunCmd("command -v ufw"); + protected void OpenPort(params int[] portList) + { + + string cmd; + + cmd = RunCmd("command -v firewall-cmd"); if (!string.IsNullOrEmpty(cmd)) { - if (Parameters.Port == 443) + //有很奇怪的vps主机,在firewalld未运行时,端口是关闭的,无法访问。所以要先启动firewalld + //用于保证acme.sh申请证书成功 + cmd = RunCmd("firewall-cmd --state"); + if (cmd.Trim() != "running") { - RunCmd("ufw allow 80/tcp"); - RunCmd("ufw allow 443/tcp"); - RunCmd("ufw allow 80/udp"); - RunCmd("ufw allow 443/udp"); - RunCmd("yes | ufw reload"); + RunCmd("systemctl restart firewalld"); } - else + + foreach (var port in portList) { - RunCmd($"ufw allow {Parameters.Port}/tcp"); - RunCmd($"ufw allow {Parameters.Port}/udp"); + RunCmd($"firewall-cmd --zone=public --add-port={port}/tcp --permanent"); + RunCmd($"firewall-cmd --zone=public --add-port={port}/udp --permanent"); + } + RunCmd("yes | firewall-cmd --reload"); + } + else + { + cmd = RunCmd("command -v ufw"); + if (!string.IsNullOrEmpty(cmd)) + { + foreach (var port in portList) + { + RunCmd($"ufw allow {port}/tcp"); + RunCmd($"ufw allow {port}/udp"); + } RunCmd("yes | ufw reload"); } } } + /// + /// 配置防火墙 + /// + protected void ConfigureFirewall() + { + var portList = new List(); + portList.Add(80); + portList.Add(Parameters.Port); + + if (Parameters.Types.Contains(XrayType.ShadowsocksAEAD)) + { + portList.Add(ConfigBuilder.ShadowSocksPort); + } + + if (Parameters.Types.Contains(XrayType.VMESS_KCP)) + { + portList.Add(ConfigBuilder.VMESS_mKCP_Port); + } + + OpenPort(portList.ToArray()); + } + /// /// 配置同步时间差 /// @@ -357,29 +399,16 @@ namespace ProxySU_Core.Models.Developers RunCmd("rm -rf caddy_install.sh"); RunCmd("curl -o caddy_install.sh https://raw.githubusercontent.com/proxysu/shellscript/master/Caddy-Naive/caddy-naive-install.sh"); RunCmd("yes | bash caddy_install.sh"); + RunCmd("rm -rf caddy_install.sh"); + } - //if (CmdType == CmdType.Apt) - //{ - // RunCmd("sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https"); - // RunCmd("curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo apt-key add -"); - // RunCmd("curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee -a /etc/apt/sources.list.d/caddy-stable.list"); - // RunCmd(GetUpdateCmd()); - // RunCmd("sudo apt install caddy"); - //} - //else if (CmdType == CmdType.Dnf) - //{ - // RunCmd("echo y | dnf install 'dnf-command(copr)'"); - // RunCmd("echo y | dnf copr enable @caddy/caddy"); - // RunCmd(GetUpdateCmd()); - // RunCmd("dnf install caddy"); - //} - //else if (CmdType == CmdType.Yum) - //{ - // RunCmd("echo y | echo y | yum install yum-plugin-copr"); - // RunCmd("echo y | echo y | yum copr enable @caddy/caddy"); - // RunCmd(GetUpdateCmd()); - // RunCmd("yum install caddy"); - //} + protected void UninstallCaddy() + { + RunCmd("rm -rf caddy_install.sh"); + RunCmd("curl -o caddy_install.sh https://raw.githubusercontent.com/proxysu/shellscript/master/Caddy-Naive/caddy-naive-install.sh"); + RunCmd("yes | bash caddy_install.sh uninstall"); + RunCmd("rm -rf caddy_install.sh"); + RunCmd("rm -rf /usr/share/caddy"); } diff --git a/ProxySU_Core/Models/Developers/XrayProject.cs b/ProxySU_Core/Models/Developers/XrayProject.cs index 4c65360..98a550e 100644 --- a/ProxySU_Core/Models/Developers/XrayProject.cs +++ b/ProxySU_Core/Models/Developers/XrayProject.cs @@ -69,7 +69,7 @@ namespace ProxySU_Core.Models.Developers ConfigureFirewall(); WriteOutput("防火墙配置完成"); - WriteOutput("同步系统和本地世间..."); + WriteOutput("同步系统和本地时间..."); SyncTimeDiff(); WriteOutput("时间同步完成"); @@ -96,10 +96,27 @@ namespace ProxySU_Core.Models.Developers } catch (Exception ex) { - MessageBox.Show("安装终止," + ex.Message); + var errorLog = "安装终止," + ex.Message; + WriteOutput(errorLog); + MessageBox.Show(errorLog); } } + public void Uninstall() + { + EnsureRootAuth(); + WriteOutput("卸载Caddy"); + UninstallCaddy(); + WriteOutput("卸载Xray"); + UninstallXray(); + WriteOutput("卸载证书"); + UninstallAcme(); + WriteOutput("关闭端口"); + ClosePort(ConfigBuilder.ShadowSocksPort, ConfigBuilder.VLESS_mKCP_Port, ConfigBuilder.VMESS_mKCP_Port); + + WriteOutput("************ 卸载完成 ************"); + } + /// /// 更新xray内核 /// @@ -119,6 +136,7 @@ namespace ProxySU_Core.Models.Developers { EnsureRootAuth(); EnsureSystemEnv(); + ConfigureFirewall(); var configJson = ConfigBuilder.BuildXrayConfig(Parameters); var stream = new MemoryStream(Encoding.UTF8.GetBytes(configJson)); RunCmd("rm -rf /usr/local/etc/xray/config.json"); @@ -286,12 +304,24 @@ namespace ProxySU_Core.Models.Developers } + private void UninstallXray() + { + RunCmd("bash -c \"$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)\" @ remove"); + } + + private void UninstallAcme() + { + RunCmd("acme.sh --uninstall"); + RunCmd("rm -r ~/.acme.sh"); + } + private void InstallXrayWithCert() { RunCmd("bash -c \"$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)\" @ install"); if (!FileExists("/usr/local/bin/xray")) { + WriteOutput("Xray-Core安装失败,请联系开发者"); throw new Exception("Xray-Core安装失败,请联系开发者"); } @@ -333,6 +363,7 @@ namespace ProxySU_Core.Models.Developers } else { + WriteOutput("安装 acme.sh 失败,请联系开发者!"); throw new Exception("安装 acme.sh 失败,请联系开发者!"); } @@ -357,6 +388,7 @@ namespace ProxySU_Core.Models.Developers } else { + WriteOutput("申请证书失败,请联系开发者!"); throw new Exception("申请证书失败,请联系开发者!"); } @@ -370,6 +402,7 @@ namespace ProxySU_Core.Models.Developers } else { + WriteOutput("安装证书失败,请联系开发者!"); throw new Exception("安装证书失败,请联系开发者!"); } diff --git a/ProxySU_Core/Models/ShareLink.cs b/ProxySU_Core/Models/ShareLink.cs index dec2823..13a33be 100644 --- a/ProxySU_Core/Models/ShareLink.cs +++ b/ProxySU_Core/Models/ShareLink.cs @@ -1,5 +1,6 @@ using Newtonsoft.Json; using ProxySU_Core.Common; +using ProxySU_Core.Models.Developers; using System; using System.Collections.Generic; using System.Linq; @@ -13,21 +14,35 @@ namespace ProxySU_Core.Models { public static string Build(XrayType xrayType, XraySettings settings) { + switch (xrayType) { - case XrayType.VLESS_TCP_TLS: + case XrayType.VLESS_TCP: case XrayType.VLESS_TCP_XTLS: - case XrayType.VLESS_WS_TLS: - case XrayType.Trojan_TCP_TLS: + case XrayType.VLESS_WS: + case XrayType.Trojan_TCP: return BuildVlessShareLink(xrayType, settings); - case XrayType.VMESS_TCP_TLS: - case XrayType.VMESS_WS_TLS: + case XrayType.VMESS_TCP: + case XrayType.VMESS_WS: + case XrayType.VMESS_KCP: return BuildVmessShareLink(xrayType, settings); + case XrayType.ShadowsocksAEAD: + return BuildShadowSocksShareLink(settings); default: return string.Empty; } } + private static string BuildShadowSocksShareLink(XraySettings settings) + { + var _method = settings.ShadowsocksMethod; + var _password = settings.ShadowsocksPassword; + var _server = settings.Domain; + var _port = ConfigBuilder.ShadowSocksPort; + + var base64URL = Base64.Encode($"{_method}:{_password}@{_server}:{_port}"); + return "ss://" + base64URL; + } private static string BuildVmessShareLink(XrayType xrayType, XraySettings settings) { @@ -46,21 +61,28 @@ namespace ProxySU_Core.Models ps = "", }; - switch (xrayType) { - case XrayType.VMESS_TCP_TLS: + case XrayType.VMESS_TCP: vmess.ps = "vmess-tcp-tls"; vmess.net = "tcp"; vmess.type = "http"; vmess.path = settings.VMESS_TCP_Path; break; - case XrayType.VMESS_WS_TLS: + case XrayType.VMESS_WS: vmess.ps = "vmess-ws-tls"; vmess.net = "ws"; vmess.type = "none"; vmess.path = settings.VMESS_WS_Path; break; + case XrayType.VMESS_KCP: + vmess.ps = "vmess-mKCP"; + vmess.port = ConfigBuilder.VMESS_mKCP_Port.ToString(); + vmess.net = "kcp"; + vmess.type = settings.VMESS_KCP_Type; + vmess.path = settings.VMESS_KCP_Seed; + vmess.tls = ""; + break; default: return string.Empty; } @@ -84,10 +106,9 @@ namespace ProxySU_Core.Models switch (xrayType) { - case XrayType.VLESS_TCP_TLS: + case XrayType.VLESS_TCP: _protocol = "vless"; _type = "tcp"; - _path = settings.VLESS_TCP_Path; _encryption = "none"; _descriptiveText = "vless-tcp-tls"; break; @@ -98,29 +119,30 @@ namespace ProxySU_Core.Models _encryption = "none"; _descriptiveText = "vless-tcp-xtls"; break; - case XrayType.VLESS_WS_TLS: + case XrayType.VLESS_WS: _protocol = "vless"; _type = "ws"; _path = settings.VLESS_WS_Path; _encryption = "none"; _descriptiveText = "vless-ws-tls"; break; - case XrayType.VMESS_TCP_TLS: + case XrayType.VMESS_TCP: _protocol = "vmess"; _type = "tcp"; _path = settings.VMESS_TCP_Path; _encryption = "auto"; _descriptiveText = "vmess-tcp-tls"; break; - case XrayType.VMESS_WS_TLS: + case XrayType.VMESS_WS: _protocol = "vmess"; _type = "ws"; _path = settings.VMESS_WS_Path; _encryption = "auto"; _descriptiveText = "vmess-ws-tls"; break; - case XrayType.Trojan_TCP_TLS: + case XrayType.Trojan_TCP: _protocol = "trojan"; + _uuid = settings.TrojanPassword; _descriptiveText = "trojan-tcp"; break; default: @@ -129,7 +151,7 @@ namespace ProxySU_Core.Models string parametersURL = string.Empty; - if (xrayType != XrayType.Trojan_TCP_TLS) + if (xrayType != XrayType.Trojan_TCP) { // 4.3 传输层相关段 parametersURL = $"?type={_type}&encryption={_encryption}&security={_security}&host={_host}&path={HttpUtility.UrlEncode(_path)}"; diff --git a/ProxySU_Core/Models/XraySettings.cs b/ProxySU_Core/Models/XraySettings.cs index 56dbda9..fcea1fb 100644 --- a/ProxySU_Core/Models/XraySettings.cs +++ b/ProxySU_Core/Models/XraySettings.cs @@ -19,11 +19,21 @@ namespace ProxySU_Core.Models Port = 443; UUID = guid; Types = new List(); + VLESS_WS_Path = "/vlessws"; - VLESS_TCP_Path = "/vlesstcp"; + VLESS_H2_Path = "/vlessh2"; + VMESS_WS_Path = "/vmessws"; VMESS_TCP_Path = "/vmesstcp"; + VMESS_H2_Path = "/vmessh2"; + VMESS_KCP_Seed = guid; + VMESS_KCP_Type = "none"; + TrojanPassword = guid; + Trojan_WS_Path = "/trojanws"; + + ShadowsocksPassword = guid; + ShadowsocksMethod = "aes-128-gcm"; } /// @@ -36,26 +46,19 @@ namespace ProxySU_Core.Models /// public string UUID { get; set; } + #region vless /// /// vless ws路径 /// public string VLESS_WS_Path { get; set; } - /// - /// vless tcp路径 - /// - public string VLESS_TCP_Path { get; set; } - /// /// vless http2 path /// public string VLESS_H2_Path { get; set; } + #endregion - /// - /// vless mKcp seed - /// - public string VLESS_mKCP_Seed { get; set; } - + #region vmess /// /// vmess ws路径 /// @@ -69,13 +72,20 @@ namespace ProxySU_Core.Models /// /// vmess http2 path /// - public string VMESS_HTTP2_Path { get; set; } + public string VMESS_H2_Path { get; set; } /// - /// vmess mKcp seed + /// vmess kcp seed /// - public string VMESS_mKCP_Seed { get; set; } + public string VMESS_KCP_Seed { get; set; } + /// + /// vmess kcp type + /// + public string VMESS_KCP_Type { get; set; } + #endregion + + #region Trojan /// /// trojan密码 /// @@ -85,6 +95,20 @@ namespace ProxySU_Core.Models /// trojan ws path /// public string Trojan_WS_Path { get; set; } + #endregion + + #region ShadowsocksAEAD + /// + /// ss password + /// + public string ShadowsocksPassword { get; set; } + + /// + /// ss method + /// + public string ShadowsocksMethod { get; set; } + #endregion + /// /// 域名 @@ -106,26 +130,24 @@ namespace ProxySU_Core.Models { switch (type) { - case XrayType.VLESS_TCP_TLS: - return VLESS_TCP_Path; - case XrayType.VLESS_TCP_XTLS: - return VLESS_TCP_Path; - case XrayType.VLESS_WS_TLS: + case XrayType.VLESS_WS: return VLESS_WS_Path; - case XrayType.VLESS_H2_TLS: + case XrayType.VLESS_H2: return VLESS_H2_Path; - case XrayType.VMESS_TCP_TLS: + case XrayType.VMESS_TCP: return VMESS_TCP_Path; - case XrayType.VMESS_WS_TLS: + case XrayType.VMESS_WS: return VMESS_WS_Path; - case XrayType.Trojan_WS_TLS: + case XrayType.Trojan_WS: return Trojan_WS_Path; // no path - case XrayType.VLESS_mKCP_Speed: - case XrayType.Trojan_TCP_TLS: - case XrayType.VMESS_mKCP_Speed: + case XrayType.VLESS_TCP_XTLS: + case XrayType.VLESS_TCP: + case XrayType.VLESS_KCP: + case XrayType.VMESS_KCP: + case XrayType.Trojan_TCP: return string.Empty; default: return string.Empty; @@ -141,19 +163,22 @@ namespace ProxySU_Core.Models VLESS_TCP_XTLS = 100, // vless 101开头 - VLESS_TCP_TLS = 101, - VLESS_WS_TLS = 102, - VLESS_H2_TLS = 103, - VLESS_mKCP_Speed = 104, + VLESS_TCP = 101, + VLESS_WS = 102, + VLESS_H2 = 103, + VLESS_KCP = 104, // vmess 201开头 - VMESS_TCP_TLS = 201, - VMESS_WS_TLS = 202, - VMESS_H2_TLS = 203, - VMESS_mKCP_Speed = 204, + VMESS_TCP = 201, + VMESS_WS = 202, + VMESS_H2 = 203, + VMESS_KCP = 204, // trojan 301开头 - Trojan_TCP_TLS = 301, - Trojan_WS_TLS = 302, + Trojan_TCP = 301, + Trojan_WS = 302, + + // ss + ShadowsocksAEAD = 401 } } diff --git a/ProxySU_Core/Properties/AssemblyInfo.cs b/ProxySU_Core/Properties/AssemblyInfo.cs index 82eaa44..52079d5 100644 --- a/ProxySU_Core/Properties/AssemblyInfo.cs +++ b/ProxySU_Core/Properties/AssemblyInfo.cs @@ -51,5 +51,5 @@ using System.Windows; //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 //通过使用 "*",如下所示: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("3.1.0.0")] +[assembly: AssemblyFileVersion("3.1.0.0")] diff --git a/ProxySU_Core/ProxySU.ico b/ProxySU_Core/ProxySU.ico new file mode 100644 index 0000000..9d7a128 Binary files /dev/null and b/ProxySU_Core/ProxySU.ico differ diff --git a/ProxySU_Core/ProxySU_Core.csproj b/ProxySU_Core/ProxySU_Core.csproj index 8de2020..b9a1d8e 100644 --- a/ProxySU_Core/ProxySU_Core.csproj +++ b/ProxySU_Core/ProxySU_Core.csproj @@ -64,6 +64,9 @@ false + + ProxySU.ico + ..\packages\ControlzEx.5.0.0\lib\net452\ControlzEx.dll @@ -119,6 +122,7 @@ + @@ -135,6 +139,7 @@ + @@ -238,34 +243,37 @@ PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + + PreserveNewest + + PreserveNewest PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest @@ -333,6 +341,12 @@ false + + + + + + diff --git a/ProxySU_Core/Resources/ProxySU.ico b/ProxySU_Core/Resources/ProxySU.ico new file mode 100644 index 0000000..9d7a128 Binary files /dev/null and b/ProxySU_Core/Resources/ProxySU.ico differ diff --git a/ProxySU_Core/Templates/xray/server/05_inbounds/Shadowsocks-AEAD.json b/ProxySU_Core/Templates/xray/server/05_inbounds/Shadowsocks-AEAD.json new file mode 100644 index 0000000..e7179e5 --- /dev/null +++ b/ProxySU_Core/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/ProxySU_Core/Templates/xray/server/05_inbounds/Trojan_TCP_TLS.json b/ProxySU_Core/Templates/xray/server/05_inbounds/Trojan_TCP.json similarity index 100% rename from ProxySU_Core/Templates/xray/server/05_inbounds/Trojan_TCP_TLS.json rename to ProxySU_Core/Templates/xray/server/05_inbounds/Trojan_TCP.json diff --git a/ProxySU_Core/Templates/xray/server/05_inbounds/Trojan_WS_TLS.json b/ProxySU_Core/Templates/xray/server/05_inbounds/Trojan_WS.json similarity index 100% rename from ProxySU_Core/Templates/xray/server/05_inbounds/Trojan_WS_TLS.json rename to ProxySU_Core/Templates/xray/server/05_inbounds/Trojan_WS.json diff --git a/ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_HTTP2_TLS.json b/ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_HTTP2.json similarity index 100% rename from ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_HTTP2_TLS.json rename to ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_HTTP2.json diff --git a/ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_mKCP.json b/ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_KCP.json similarity index 93% rename from ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_mKCP.json rename to ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_KCP.json index 77b6aba..8421a45 100644 --- a/ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_mKCP.json +++ b/ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_KCP.json @@ -1,6 +1,5 @@ { "port": 3456, - "listen": "127.0.0.1", "protocol": "vless", "settings": { "clients": [ diff --git a/ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_TCP_XTLS.json b/ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_TCP_XTLS.json index d8cddd9..eab8363 100644 --- a/ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_TCP_XTLS.json +++ b/ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_TCP_XTLS.json @@ -15,7 +15,11 @@ "network": "tcp", "security": "xtls", "xtlsSettings": { - "alpn": [ "h2", "http/1.1" ], + "allowInsecure": false, + "minVersion": "1.2", + "alpn": [ + "http/1.1" + ], "certificates": [ { "certificateFile": "/usr/local/etc/xray/ssl/xray_ssl.crt", diff --git a/ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_WS_TLS.json b/ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_WS.json similarity index 100% rename from ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_WS_TLS.json rename to ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_WS.json diff --git a/ProxySU_Core/Templates/xray/server/05_inbounds/VMESS_HTTP2_TLS.json b/ProxySU_Core/Templates/xray/server/05_inbounds/VMESS_HTTP2.json similarity index 100% rename from ProxySU_Core/Templates/xray/server/05_inbounds/VMESS_HTTP2_TLS.json rename to ProxySU_Core/Templates/xray/server/05_inbounds/VMESS_HTTP2.json diff --git a/ProxySU_Core/Templates/xray/server/05_inbounds/VMESS_mKCP.json b/ProxySU_Core/Templates/xray/server/05_inbounds/VMESS_KCP.json similarity index 93% rename from ProxySU_Core/Templates/xray/server/05_inbounds/VMESS_mKCP.json rename to ProxySU_Core/Templates/xray/server/05_inbounds/VMESS_KCP.json index 63bcf27..0c3ea2b 100644 --- a/ProxySU_Core/Templates/xray/server/05_inbounds/VMESS_mKCP.json +++ b/ProxySU_Core/Templates/xray/server/05_inbounds/VMESS_KCP.json @@ -1,6 +1,5 @@ { "port": 3456, - "listen": "127.0.0.1", "protocol": "vmess", "settings": { "clients": [ diff --git a/ProxySU_Core/Templates/xray/server/05_inbounds/VMESS_TCP_TLS.json b/ProxySU_Core/Templates/xray/server/05_inbounds/VMESS_TCP.json similarity index 100% rename from ProxySU_Core/Templates/xray/server/05_inbounds/VMESS_TCP_TLS.json rename to ProxySU_Core/Templates/xray/server/05_inbounds/VMESS_TCP.json diff --git a/ProxySU_Core/Templates/xray/server/05_inbounds/VMESS_WS_TLS.json b/ProxySU_Core/Templates/xray/server/05_inbounds/VMESS_WS.json similarity index 100% rename from ProxySU_Core/Templates/xray/server/05_inbounds/VMESS_WS_TLS.json rename to ProxySU_Core/Templates/xray/server/05_inbounds/VMESS_WS.json diff --git a/ProxySU_Core/ViewModels/IdValueViewModel.cs b/ProxySU_Core/ViewModels/IdValueViewModel.cs new file mode 100644 index 0000000..d7b8fbf --- /dev/null +++ b/ProxySU_Core/ViewModels/IdValueViewModel.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProxySU_Core.ViewModels +{ + public class IdValueViewModel + { + public IdValueViewModel(int id, string value) + { + Id = id; + Value = value; + } + + public int Id { get; set; } + + public string Value { get; set; } + } +} diff --git a/ProxySU_Core/ViewModels/XraySettingsViewModel.cs b/ProxySU_Core/ViewModels/XraySettingsViewModel.cs index 54d1435..eacf8ec 100644 --- a/ProxySU_Core/ViewModels/XraySettingsViewModel.cs +++ b/ProxySU_Core/ViewModels/XraySettingsViewModel.cs @@ -3,27 +3,34 @@ using ProxySU_Core.Common; using ProxySU_Core.Models; using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Web; using System.Windows; +using System.Windows.Controls; namespace ProxySU_Core.ViewModels { - public class XraySettingsViewModel : BaseViewModel + public partial class XraySettingsViewModel : BaseViewModel { public XraySettings settings; public XraySettingsViewModel(XraySettings parameters) { this.settings = parameters; + Notify("VMESS_KCP_Type"); } public string UUID { get => settings.UUID; - set => settings.UUID = value; + set + { + settings.UUID = value; + Notify("UUID"); + } } public string Domain @@ -38,227 +45,224 @@ namespace ProxySU_Core.ViewModels set => settings.MaskDomain = value; } - public string VLESS_TCP_Path - { - get => settings.VLESS_TCP_Path; - set => settings.VLESS_TCP_Path = value; - } - - public string VLESS_WS_Path - { - get => settings.VLESS_WS_Path; - set => settings.VLESS_WS_Path = value; - } - - public string VMESS_TCP_Path - { - get => settings.VMESS_TCP_Path; - set => settings.VMESS_TCP_Path = value; - } - - public string VMESS_WS_Path - { - get => settings.VMESS_WS_Path; - set => settings.VMESS_WS_Path = value; - } - public string TrojanPassword { get => settings.TrojanPassword; set => settings.TrojanPassword = value; } - - public bool Checked_VLESS_TCP - { - get - { - return settings.Types.Contains(XrayType.VLESS_TCP_TLS); - } - set - { - if (value == true) - { - if (!settings.Types.Contains(XrayType.VLESS_TCP_TLS)) - settings.Types.Add(XrayType.VLESS_TCP_TLS); - - } - else - { - settings.Types.Remove(XrayType.VLESS_TCP_TLS); - } - Notify("Checked_VLESS_TCP"); - Notify("VLESS_TCP_Path_Visibility"); - } - } - - public bool Checked_VLESS_XTLS - { - get - { - return settings.Types.Contains(XrayType.VLESS_TCP_XTLS); - } - set - { - if (value == true) - { - if (!settings.Types.Contains(XrayType.VLESS_TCP_XTLS)) - settings.Types.Add(XrayType.VLESS_TCP_XTLS); - } - else - { - settings.Types.Remove(XrayType.VLESS_TCP_XTLS); - } - Notify("Checked_VLESS_XTLS"); - } - } - - public bool Checked_VLESS_WS - { - get - { - return settings.Types.Contains(XrayType.VLESS_WS_TLS); - } - set - { - if (value == true) - { - if (!settings.Types.Contains(XrayType.VLESS_WS_TLS)) - settings.Types.Add(XrayType.VLESS_WS_TLS); - } - else - { - settings.Types.Remove(XrayType.VLESS_WS_TLS); - } - Notify("Checked_VLESS_WS"); - Notify("VLESS_WS_Path_Visibility"); - } - } - - public bool Checked_VMESS_TCP - { - get - { - return settings.Types.Contains(XrayType.VMESS_TCP_TLS); - } - set - { - if (value == true) - { - if (!settings.Types.Contains(XrayType.VMESS_TCP_TLS)) - settings.Types.Add(XrayType.VMESS_TCP_TLS); - } - else - { - settings.Types.Remove(XrayType.VMESS_TCP_TLS); - } - Notify("Checked_VMESS_TCP"); - Notify("VMESS_TCP_Path_Visibility"); - } - } - - public bool Checked_VMESS_WS - { - get - { - return settings.Types.Contains(XrayType.VMESS_WS_TLS); - } - set - { - if (value == true) - { - if (!settings.Types.Contains(XrayType.VMESS_WS_TLS)) - settings.Types.Add(XrayType.VMESS_WS_TLS); - } - else - { - settings.Types.Remove(XrayType.VMESS_WS_TLS); - } - Notify("Checked_VMESS_WS"); - Notify("VMESS_WS_Path_Visibility"); - } - } - public bool Checked_Trojan_TCP { get { - return settings.Types.Contains(XrayType.Trojan_TCP_TLS); + return settings.Types.Contains(XrayType.Trojan_TCP); } set { if (value == true) { - if (!settings.Types.Contains(XrayType.Trojan_TCP_TLS)) - settings.Types.Add(XrayType.Trojan_TCP_TLS); + if (!settings.Types.Contains(XrayType.Trojan_TCP)) + settings.Types.Add(XrayType.Trojan_TCP); } else { - settings.Types.Remove(XrayType.Trojan_TCP_TLS); + settings.Types.Remove(XrayType.Trojan_TCP); } Notify("Checked_Trojan_TCP"); - Notify("Trojan_TCP_Pwd_Visibility"); + } + } + public string Trojan_TCP_ShareLink + { + get => ShareLink.Build(XrayType.Trojan_TCP, settings); + } + + private List _ssMethods = new List { "aes-256-gcm", "aes-128-gcm", "chacha20-poly1305", "chacha20-ietf-poly1305" }; + public List ShadowSocksMethods => _ssMethods; + public bool CheckedShadowSocks + { + + get => settings.Types.Contains(XrayType.ShadowsocksAEAD); + set + { + CheckBoxChanged(value, XrayType.ShadowsocksAEAD); + Notify("CheckedShadowSocks"); + } + } + public string ShadowSocksPassword + { + get => settings.ShadowsocksPassword; + set => settings.ShadowsocksPassword = value; + } + public string ShadowSocksMethod + { + get => settings.ShadowsocksMethod; + set + { + var namespaceStr = typeof(ComboBoxItem).FullName + ":"; + var trimValue = value.Replace(namespaceStr, ""); + trimValue = trimValue.Trim(); + settings.ShadowsocksMethod = trimValue; + Notify("ShadowSocksMethod"); + } + } + public string ShadowSocksShareLink + { + get => ShareLink.Build(XrayType.ShadowsocksAEAD, settings); + } + + + private void CheckBoxChanged(bool value, XrayType type) + { + if (value == true) + { + if (!settings.Types.Contains(type)) + { + settings.Types.Add(type); + } + } + else + { + settings.Types.RemoveAll(x => x == type); } } - public Visibility VLESS_TCP_Path_Visibility + } + + public partial class XraySettingsViewModel + { + // vmess tcp + public bool Checked_VMESS_TCP { - get + get => settings.Types.Contains(XrayType.VMESS_TCP); + set { - return Checked_VLESS_TCP ? Visibility.Visible : Visibility.Hidden; + CheckBoxChanged(value, XrayType.VMESS_TCP); + Notify("Checked_VMESS_TCP"); } } - public Visibility VLESS_WS_Path_Visibility + public string VMESS_TCP_Path { - get - { - return Checked_VLESS_WS ? Visibility.Visible : Visibility.Hidden; - } + get => settings.VMESS_TCP_Path; + set => settings.VMESS_TCP_Path = value; } - public Visibility VMESS_TCP_Path_Visibility + public string VMESS_TCP_ShareLink { - get - { - return Checked_VMESS_TCP ? Visibility.Visible : Visibility.Hidden; - } - } - public Visibility VMESS_WS_Path_Visibility - { - get - { - return Checked_VMESS_WS ? Visibility.Visible : Visibility.Hidden; - } - } - public Visibility Trojan_TCP_Pwd_Visibility - { - get - { - return Checked_Trojan_TCP ? Visibility.Visible : Visibility.Hidden; - } + get => ShareLink.Build(XrayType.VMESS_TCP, settings); } + // vmess ws + public bool Checked_VMESS_WS + { + get => settings.Types.Contains(XrayType.VMESS_WS); + set + { + CheckBoxChanged(value, XrayType.VMESS_WS); + Notify("Checked_VMESS_WS"); + } + } + public string VMESS_WS_Path + { + get => settings.VMESS_WS_Path; + set => settings.VMESS_WS_Path = value; + } + public string VMESS_WS_ShareLink + { + get => ShareLink.Build(XrayType.VMESS_WS, settings); + } + + // vmess kcp + public string VMESS_KCP_Seed + { + get => settings.VMESS_KCP_Seed; + set => settings.VMESS_KCP_Seed = value; + } + public string VMESS_KCP_Type + { + get => settings.VMESS_KCP_Type; + set + { + var namespaceStr = typeof(ComboBoxItem).FullName + ":"; + var trimValue = value.Replace(namespaceStr, ""); + trimValue = trimValue.Trim(); + settings.VMESS_KCP_Type = trimValue; + Notify("VMESS_KCP_Type"); + } + } + public bool Checked_VMESS_KCP + { + get => settings.Types.Contains(XrayType.VMESS_KCP); + set + { + CheckBoxChanged(value, XrayType.VMESS_KCP); + Notify("Checked_VMESS_KCP"); + } + } + public string VMESS_KCP_ShareLink + { + get => ShareLink.Build(XrayType.VMESS_KCP, settings); + } + + + private List _kcpTypes = new List { "none", "srtp", "utp", "wechat-video", "dtls", "wireguard", }; + public List KcpTypes => _kcpTypes; + } + + + public partial class XraySettingsViewModel + { + + // vless xtls + public bool Checked_VLESS_TCP_XTLS + { + get => settings.Types.Contains(XrayType.VLESS_TCP_XTLS); + set + { + CheckBoxChanged(value, XrayType.VLESS_TCP_XTLS); + Notify("Checked_VLESS_XTLS"); + } + } public string VLESS_TCP_XTLS_ShareLink { get => ShareLink.Build(XrayType.VLESS_TCP_XTLS, settings); } - public string VLESS_TCP_TLS_ShareLink + + + // vless tcp + public bool Checked_VLESS_TCP { - get => ShareLink.Build(XrayType.VLESS_TCP_TLS, settings); + get => settings.Types.Contains(XrayType.VLESS_TCP); + set + { + CheckBoxChanged(value, XrayType.VLESS_TCP); + Notify("Checked_VLESS_TCP"); + } } - public string VLESS_WS_TLS_ShareLink + public string VLESS_TCP_ShareLink { - get => ShareLink.Build(XrayType.VLESS_WS_TLS, settings); + get => ShareLink.Build(XrayType.VLESS_TCP, settings); } - public string VMESS_TCP_TLS_ShareLink + + + // vless ws + public string VLESS_WS_Path { - get => ShareLink.Build(XrayType.VMESS_TCP_TLS, settings); + get => settings.VLESS_WS_Path; + set => settings.VLESS_WS_Path = value; } - public string VMESS_WS_TLS_ShareLink + public bool Checked_VLESS_WS { - get => ShareLink.Build(XrayType.VMESS_WS_TLS, settings); + get + { + return settings.Types.Contains(XrayType.VLESS_WS); + } + set + { + CheckBoxChanged(value, XrayType.VLESS_WS); + Notify("Checked_VLESS_WS"); + } } - public string Trojan_TCP_TLS_ShareLink + public string VLESS_WS_ShareLink { - get => ShareLink.Build(XrayType.Trojan_TCP_TLS, settings); + get => ShareLink.Build(XrayType.VLESS_WS, settings); } } diff --git a/ProxySU_Core/Views/ClientInfoWindow.xaml b/ProxySU_Core/Views/ClientInfoWindow.xaml index 3380bc7..18ba595 100644 --- a/ProxySU_Core/Views/ClientInfoWindow.xaml +++ b/ProxySU_Core/Views/ClientInfoWindow.xaml @@ -5,8 +5,11 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:metro="http://metro.mahapps.com/winfx/xaml/controls" xmlns:local="clr-namespace:ProxySU_Core.Views" + xmlns:dev="clr-namespace:ProxySU_Core.Models.Developers" mc:Ignorable="d" - Title="查看配置" Height="450" Width="800"> + Title="查看配置" Height="500" Width="800"> + + diff --git a/ProxySU_Core/Views/MainWindow.xaml b/ProxySU_Core/Views/MainWindow.xaml index 2649b91..cfbdef0 100644 --- a/ProxySU_Core/Views/MainWindow.xaml +++ b/ProxySU_Core/Views/MainWindow.xaml @@ -26,6 +26,7 @@ @@ -106,10 +107,10 @@ - diff --git a/ProxySU_Core/Views/RecordEditorWindow.xaml.cs b/ProxySU_Core/Views/RecordEditorWindow.xaml.cs index d62e097..4a0c19f 100644 --- a/ProxySU_Core/Views/RecordEditorWindow.xaml.cs +++ b/ProxySU_Core/Views/RecordEditorWindow.xaml.cs @@ -48,5 +48,11 @@ namespace ProxySU_Core.Views DialogResult = true; Close(); } + + public void RandomUuid(object sender, RoutedEventArgs e) + { + Settings.UUID = Guid.NewGuid().ToString(); + } + } } diff --git a/ProxySU_Core/Views/TerminalWindow.xaml b/ProxySU_Core/Views/TerminalWindow.xaml index d31972f..ff0576b 100644 --- a/ProxySU_Core/Views/TerminalWindow.xaml +++ b/ProxySU_Core/Views/TerminalWindow.xaml @@ -46,6 +46,13 @@ Height="26" IsEnabled="{Binding HasConnected}" Width="120"/> + +