diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..516f5da
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,4 @@
+[*.cs]
+
+# Default severity for all analyzer diagnostics
+dotnet_analyzer_diagnostic.severity = none
diff --git a/ProxySU.sln b/ProxySU.sln
index 6b8b4af..6f38af8 100644
--- a/ProxySU.sln
+++ b/ProxySU.sln
@@ -7,6 +7,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProxySU", "ProxySU\ProxySU.
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProxySU_Core", "ProxySU_Core\ProxySU_Core.csproj", "{B066015C-D347-4493-92F1-6556D3863996}"
EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{18714411-764D-47E5-AFE6-A96200B7CE41}"
+ ProjectSection(SolutionItems) = preProject
+ .editorconfig = .editorconfig
+ EndProjectSection
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
diff --git a/ProxySU/ProxySU.csproj b/ProxySU/ProxySU.csproj
index be52772..9ae9d06 100644
--- a/ProxySU/ProxySU.csproj
+++ b/ProxySU/ProxySU.csproj
@@ -181,6 +181,9 @@
ResXFileCodeGenerator
Resources.Designer.cs
+
+ .editorconfig
+
SettingsSingleFileGenerator
diff --git a/ProxySU_Core/Models/XraySettings.cs b/ProxySU_Core/Models/XraySettings.cs
index 1c125e2..2b1206f 100644
--- a/ProxySU_Core/Models/XraySettings.cs
+++ b/ProxySU_Core/Models/XraySettings.cs
@@ -105,6 +105,6 @@ namespace ProxySU_Core.Models
VMESS_TCP_TLS,
VMESS_WS_TLS,
- Trojan_TCP_TLS
+ Trojan_TCP_TLS,
}
}
diff --git a/ProxySU_Core/ProxySU_Core.csproj b/ProxySU_Core/ProxySU_Core.csproj
index 270e96a..71ca95f 100644
--- a/ProxySU_Core/ProxySU_Core.csproj
+++ b/ProxySU_Core/ProxySU_Core.csproj
@@ -62,7 +62,7 @@
true
- true
+ false
diff --git a/ProxySU_Core/ViewModels/Developers/XrayProject.cs b/ProxySU_Core/ViewModels/Developers/XrayProject.cs
index 588e506..1d028e1 100644
--- a/ProxySU_Core/ViewModels/Developers/XrayProject.cs
+++ b/ProxySU_Core/ViewModels/Developers/XrayProject.cs
@@ -29,52 +29,10 @@ namespace ProxySU_Core.ViewModels.Developers
{
}
- public void InstallCert()
- {
- EnsureRootAuth();
- EnsureSystemEnv();
- this.InstallCertToXray();
- RunCmd("systemctl restart xray");
- 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 UpdateXraySettings()
- {
- EnsureRootAuth();
- EnsureSystemEnv();
- var configJson = ConfigBuilder.BuildXrayConfig(Parameters);
- var stream = new MemoryStream(Encoding.UTF8.GetBytes(configJson));
- RunCmd("rm -rf /usr/local/etc/xray/config.json");
- UploadFile(stream, "/usr/local/etc/xray/config.json");
- RunCmd("systemctl restart xray");
- WriteOutput("************ 更新Xray配置成功,更新配置不包含域名,如果域名更换请重新安装。 ************");
- }
-
- public void ReinstallCaddy()
- {
- EnsureRootAuth();
- EnsureSystemEnv();
- InstallCaddy();
- UploadCaddyFile();
- WriteOutput("************ 重装Caddy完成 ************");
- }
+ ///
+ /// 安装Xray
+ ///
public override void Install()
{
try
@@ -142,6 +100,130 @@ namespace ProxySU_Core.ViewModels.Developers
}
}
+ ///
+ /// 更新xray内核
+ ///
+ public void UpdateXrayCore()
+ {
+ EnsureRootAuth();
+ EnsureSystemEnv();
+ RunCmd("bash -c \"$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)\" @ install");
+ RunCmd("systemctl restart xray");
+ WriteOutput("************ 更新xray内核完成 ************");
+ }
+
+ ///
+ /// 更新xray配置
+ ///
+ public void UpdateXraySettings()
+ {
+ EnsureRootAuth();
+ EnsureSystemEnv();
+ var configJson = ConfigBuilder.BuildXrayConfig(Parameters);
+ var stream = new MemoryStream(Encoding.UTF8.GetBytes(configJson));
+ RunCmd("rm -rf /usr/local/etc/xray/config.json");
+ UploadFile(stream, "/usr/local/etc/xray/config.json");
+ RunCmd("systemctl restart xray");
+ WriteOutput("************ 更新Xray配置成功,更新配置不包含域名,如果域名更换请重新安装。 ************");
+ }
+
+ ///
+ /// 重装Caddy
+ ///
+ public void ReinstallCaddy()
+ {
+ EnsureRootAuth();
+ EnsureSystemEnv();
+ InstallCaddy();
+ UploadCaddyFile();
+ WriteOutput("************ 重装Caddy完成 ************");
+ }
+
+ ///
+ /// 安装证书
+ ///
+ public void InstallCert()
+ {
+ EnsureRootAuth();
+ EnsureSystemEnv();
+ this.InstallCertToXray();
+ RunCmd("systemctl restart xray");
+ WriteOutput("************ 安装证书完成 ************");
+ }
+
+ ///
+ /// 上传证书
+ ///
+ ///
+ ///
+ public void UploadCert(Stream stream)
+ {
+ EnsureRootAuth();
+ EnsureSystemEnv();
+
+ // 转移旧文件
+ var oldFileName = $"ssl_{DateTime.Now.Ticks}";
+ RunCmd($"mv /usr/local/etc/xray/ssl /usr/local/etc/xray/{oldFileName}");
+
+ // 上传新文件
+ RunCmd("mkdir /usr/local/etc/xray/ssl");
+ UploadFile(stream, "/usr/local/etc/xray/ssl/ssl.zip");
+ RunCmd("unzip /usr/local/etc/xray/ssl/ssl.zip -d /usr/local/etc/xray/ssl");
+
+ // 改名
+ var crtFiles = RunCmd("find /usr/local/etc/xray/ssl/*.crt").Split("\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
+ if (crtFiles.Length > 0)
+ {
+ RunCmd($"mv {crtFiles[0]} /usr/local/etc/xray/ssl/xray_ssl.crt");
+ }
+ else
+ {
+ WriteOutput("************ 上传证书失败,请联系开发者 ************");
+ RunCmd("rm -rf /usr/local/etc/xray/ssl");
+ RunCmd($"mv /usr/local/etc/xray/ssl{oldFileName} /usr/local/etc/xray/ssl");
+ WriteOutput("操作已回滚");
+ return;
+ }
+
+ var keyFiles = RunCmd("find /usr/local/etc/xray/ssl/*.key").Split("\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
+ if (keyFiles.Length > 0)
+ {
+ RunCmd($"mv {keyFiles[0]} /usr/local/etc/xray/ssl/xray_ssl.key");
+ }
+ else
+ {
+ WriteOutput("************ 上传证书失败,请联系开发者 ************");
+ RunCmd("rm -rf /usr/local/etc/xray/ssl");
+ RunCmd($"mv /usr/local/etc/xray/ssl{oldFileName} /usr/local/etc/xray/ssl");
+ WriteOutput("操作已回滚");
+ return;
+ }
+
+ RunCmd("systemctl restart xray");
+ 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("************ 上传网站模板完成 ************");
+ }
+
+
private void UploadCaddyFile(bool useCustomWeb = false)
{
var configJson = ConfigBuilder.BuildCaddyConfig(Parameters, useCustomWeb);
diff --git a/ProxySU_Core/ViewModels/XraySettingsViewModel.cs b/ProxySU_Core/ViewModels/XraySettingsViewModel.cs
index 1df53d4..9da6e85 100644
--- a/ProxySU_Core/ViewModels/XraySettingsViewModel.cs
+++ b/ProxySU_Core/ViewModels/XraySettingsViewModel.cs
@@ -5,6 +5,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using System.Web;
using System.Windows;
namespace ProxySU_Core.ViewModels
@@ -234,5 +235,116 @@ namespace ProxySU_Core.ViewModels
}
}
+ public string VLESS_TCP_XTLS_ShareLink
+ {
+ get => BuildVlessShareLink(XrayType.VLESS_TCP_XTLS);
+ }
+ public string VLESS_TCP_TLS_ShareLink
+ {
+ get => BuildVlessShareLink(XrayType.VLESS_TCP_TLS);
+ }
+ public string VLESS_WS_TLS_ShareLink
+ {
+ get => BuildVlessShareLink(XrayType.VLESS_WS_TLS);
+ }
+ public string VMESS_TCP_TLS_ShareLink
+ {
+ get => BuildVmessShareLink(XrayType.VMESS_TCP_TLS);
+ }
+ public string VMESS_WS_TLS_ShareLink
+ {
+ get => BuildVmessShareLink(XrayType.VMESS_WS_TLS);
+ }
+ public string Trojan_TCP_TLS_ShareLink
+ {
+ get => BuildVlessShareLink(XrayType.Trojan_TCP_TLS);
+ }
+
+ public string BuildVmessShareLink(XrayType xrayType)
+ {
+ return "vmess://xxxxxx";
+ }
+
+ public string BuildVlessShareLink(XrayType xrayType)
+ {
+ var _protocol = string.Empty;
+ var _uuid = settings.UUID;
+ var _domain = settings.Domain;
+ var _port = settings.Port;
+ var _type = string.Empty;
+ var _encryption = string.Empty;
+ var _security = "tls";
+ var _path = "/";
+ var _host = settings.Domain;
+ var _descriptiveText = string.Empty;
+
+ switch (xrayType)
+ {
+ case XrayType.VLESS_TCP_TLS:
+ _protocol = "vless";
+ _type = "tcp";
+ _path = VLESS_TCP_Path;
+ _encryption = "none";
+ _descriptiveText = "vless-tcp-tls";
+ break;
+ case XrayType.VLESS_TCP_XTLS:
+ _protocol = "vless";
+ _type = "tcp";
+ _security = "xtls";
+ _encryption = "none";
+ _descriptiveText = "vless-tcp-xtls";
+ break;
+ case XrayType.VLESS_WS_TLS:
+ _protocol = "vless";
+ _type = "ws";
+ _path = VLESS_WS_Path;
+ _encryption = "none";
+ _descriptiveText = "vless-ws-tls";
+ break;
+ case XrayType.VMESS_TCP_TLS:
+ _protocol = "vmess";
+ _type = "tcp";
+ _path = VMESS_TCP_Path;
+ _encryption = "auto";
+ _descriptiveText = "vmess-tcp-tls";
+ break;
+ case XrayType.VMESS_WS_TLS:
+ _protocol = "vmess";
+ _type = "ws";
+ _path = VMESS_WS_Path;
+ _encryption = "auto";
+ _descriptiveText = "vmess-ws-tls";
+ break;
+ case XrayType.Trojan_TCP_TLS:
+ _protocol = "trojan";
+ _descriptiveText = "trojan-tcp";
+ break;
+ default:
+ throw new Exception("暂未实现的协议");
+ }
+
+
+ string parametersURL = string.Empty;
+ if (xrayType != XrayType.Trojan_TCP_TLS)
+ {
+ // 4.3 传输层相关段
+ parametersURL = $"?type={_type}&encryption={_encryption}&security={_security}&host={_host}&path={HttpUtility.UrlEncode(_path)}";
+
+
+ // if mKCP
+ // if QUIC
+
+ // 4.4 TLS 相关段
+ if (xrayType == XrayType.VLESS_TCP_XTLS)
+ {
+ parametersURL += "&flow=xtls-rprx-direct";
+ }
+ }
+
+
+ return $"{_protocol}://{HttpUtility.UrlEncode(_uuid)}@{_domain}:{_port}{parametersURL}#{HttpUtility.UrlEncode(_descriptiveText)}";
+ }
+
+
}
}
diff --git a/ProxySU_Core/Views/ClientInfoWindow.xaml b/ProxySU_Core/Views/ClientInfoWindow.xaml
index 46e393c..3380bc7 100644
--- a/ProxySU_Core/Views/ClientInfoWindow.xaml
+++ b/ProxySU_Core/Views/ClientInfoWindow.xaml
@@ -65,7 +65,12 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ProxySU_Core/Views/TerminalWindow.xaml b/ProxySU_Core/Views/TerminalWindow.xaml
index 1e9d1f9..d31972f 100644
--- a/ProxySU_Core/Views/TerminalWindow.xaml
+++ b/ProxySU_Core/Views/TerminalWindow.xaml
@@ -15,47 +15,73 @@
FontSize="14"
FontFamily="Consolas"
x:Name="OutputTextBox"
- Height="320"
+ Height="260"
Text="{Binding Path=OutputText}"
/>
+
+
+
+
-
+
-
+
+
-
+
+
-
+
-
+
+
+
+
+
+
diff --git a/ProxySU_Core/Views/TerminalWindow.xaml.cs b/ProxySU_Core/Views/TerminalWindow.xaml.cs
index f11ce26..7f6a7c8 100644
--- a/ProxySU_Core/Views/TerminalWindow.xaml.cs
+++ b/ProxySU_Core/Views/TerminalWindow.xaml.cs
@@ -135,26 +135,11 @@ namespace ProxySU_Core
});
}
- private void InstallCert(object sender, RoutedEventArgs e)
+ private void UpdateXrayCore(object sender, RoutedEventArgs e)
{
Task.Factory.StartNew(() =>
{
- project.InstallCert();
- });
- }
-
- private void UploadWeb(object sender, RoutedEventArgs e)
- {
- var fileDialog = new OpenFileDialog();
- fileDialog.FileOk += OnFileOk;
- fileDialog.ShowDialog();
- }
-
- private void ReinstallCaddy(object sender, RoutedEventArgs e)
- {
- Task.Factory.StartNew(() =>
- {
- project.ReinstallCaddy();
+ project.UpdateXrayCore();
});
}
@@ -166,7 +151,39 @@ namespace ProxySU_Core
});
}
- private void OnFileOk(object sender, CancelEventArgs e)
+ private void InstallCert(object sender, RoutedEventArgs e)
+ {
+ Task.Factory.StartNew(() =>
+ {
+ project.InstallCert();
+ });
+ }
+
+ private void UploadCert(object sender, RoutedEventArgs e)
+ {
+ var fileDialog = new OpenFileDialog();
+ fileDialog.Filter = "压缩文件|*.zip";
+ fileDialog.FileOk += DoUploadCert;
+ fileDialog.ShowDialog();
+ }
+
+ private void UploadWeb(object sender, RoutedEventArgs e)
+ {
+ var fileDialog = new OpenFileDialog();
+ fileDialog.Filter = "压缩文件|*.zip";
+ fileDialog.FileOk += DoUploadWeb;
+ fileDialog.ShowDialog();
+ }
+
+ private void ReinstallCaddy(object sender, RoutedEventArgs e)
+ {
+ Task.Factory.StartNew(() =>
+ {
+ project.ReinstallCaddy();
+ });
+ }
+
+ private void DoUploadWeb(object sender, CancelEventArgs e)
{
Task.Factory.StartNew(() =>
{
@@ -178,6 +195,18 @@ namespace ProxySU_Core
});
}
+ private void DoUploadCert(object sender, CancelEventArgs e)
+ {
+ Task.Factory.StartNew(() =>
+ {
+ var file = sender as OpenFileDialog;
+ using (var stream = file.OpenFile())
+ {
+ project.UploadCert(stream);
+ }
+ });
+ }
+
private void OpenLink(object sender, RoutedEventArgs e)
{
Hyperlink link = sender as Hyperlink;