diff --git a/ProxySU/MainWindow.xaml b/ProxySU/MainWindow.xaml index 30e512e..b0704e0 100644 --- a/ProxySU/MainWindow.xaml +++ b/ProxySU/MainWindow.xaml @@ -5,7 +5,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:ProxySU" mc:Ignorable="d" - Title="ProxySU - v2.0.3" Height="625" Width="530"> + Title="ProxySU - v2.0.4" Height="625" Width="530"> @@ -134,7 +134,7 @@ - + @@ -150,6 +150,36 @@ --> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -164,7 +194,7 @@ - + @@ -174,6 +204,35 @@ diff --git a/ProxySU/MainWindow.xaml.cs b/ProxySU/MainWindow.xaml.cs index 79ca0ad..e361dc6 100644 --- a/ProxySU/MainWindow.xaml.cs +++ b/ProxySU/MainWindow.xaml.cs @@ -35,7 +35,7 @@ namespace ProxySU /// public partial class MainWindow : Window { - //语言参数 + //多语言参数 public class LanguageInfo { public string Name { get; set; } @@ -48,15 +48,17 @@ namespace ProxySU //ReceiveConfigurationParameters[3]----path/naive'user //ReceiveConfigurationParameters[4]----domain //ReceiveConfigurationParameters[5]----伪装类型 - //ReceiveConfigurationParameters[6]----QUIC密钥 + //ReceiveConfigurationParameters[6]----QUIC密钥/mKCP Seed //ReceiveConfigurationParameters[7]----伪装网站 + //ReceiveConfigurationParameters[8]----方案名称 //public static ConnectionInfo ConnectionInfo; - public static string proxyType = "V2Ray"; //代理类型标识: V2Ray\TrojanGo\Trojan\NaiveProxy + public static string proxyType = "V2Ray"; //代理类型标识: V2Ray\TrojanGo\Trojan\NaiveProxy static bool testDomain = false; //设置标识--域名是否需要检测解析,初始化为不需要 static string sshShellCommand; //定义保存执行的命令 static string currentShellCommandResult; //定义Shell命令执行结果保存变量 static string sshCmdUpdate; //保存软件安装所用更新软件库命令 static string sshCmdInstall; //保存软件安装所用命令格式 + static int randomCaddyListenPort = 8800; //Caddy做伪装网站所监听的端口,随机2000-9000 //****** ****** // Application.Current.FindResource("").ToString() @@ -66,6 +68,7 @@ namespace ProxySU { InitializeComponent(); + #region 多语言选择设置 初始设置为auto List languageList = new List(); languageList.Add(new LanguageInfo { Name = "auto", Value = "auto" }); @@ -83,6 +86,11 @@ namespace ProxySU string Culture = System.Globalization.CultureInfo.InstalledUICulture.Name; //Culture = "en-US"; ResourcesLoad(Culture); + #endregion + + //初始化参数设置数组 + ReceiveConfigurationParameters = new string[9]; + //初始化选定密码登录 RadioButtonPasswordLogin.IsChecked = true; //初始化选定无代理 @@ -91,8 +99,6 @@ namespace ProxySU RadioButtonProxyNoLogin.IsChecked = true; //初始化隐藏Socks4代理, RadioButtonSocks4.Visibility = Visibility.Collapsed; - //初始化参数给 - ReceiveConfigurationParameters = new string[8]; //初始化Trojan的密码 TextBoxTrojanPassword.Text = RandomUUID(); @@ -110,6 +116,7 @@ namespace ProxySU //TextBoxNaiveUser3in1.Text = RandomUserName(); //TextBoxNaivePassword3in1.Text= RandomUUID(); + //自动检查ProxySU是否有新版本发布,有则显示更新提示 Thread thread = new Thread(() => TestLatestVersionProxySU(TextBlockLastVersionProxySU, TextBlockNewVersionReminder, ButtonUpgradeProxySU)); thread.SetApartmentState(ApartmentState.STA); thread.Start(); @@ -133,15 +140,9 @@ namespace ProxySU { TextBlockLastVersionProxySU.Dispatcher.BeginInvoke(updateNewVersionProxySUAction, TextBlockLastVersionProxySU, TextBlockNewVersionReminder, ButtonUpgradeProxySU, lastVersion); } - else - { - } - } - else - { - //MessageBox.Show("获取Json失败"); } + } //下载最新版ProxySU @@ -156,16 +157,25 @@ namespace ProxySU if (String.IsNullOrEmpty(strJson) == false) { JObject lastVerJsonObj = JObject.Parse(strJson); - string latestVerDownUrl = (string)lastVerJsonObj["assets"][0]["browser_download_url"]; - - Uri latestVerDownUri = new Uri(latestVerDownUrl); - string latestNewVerFileName = (string)lastVerJsonObj["assets"][0]["name"]; + string lastVersion = (string)lastVerJsonObj["tag_name"];//得到远程版本信息 + string latestVerDownUrl = (string)lastVerJsonObj["assets"][0]["browser_download_url"];//得到最新版文件下载地址 + string latestNewVerFileName = (string)lastVerJsonObj["assets"][0]["name"];//得到最新版文件名 + string latestNewVerExplanation = (string)lastVerJsonObj["body"];//得到更新说明 WebClient webClientNewVer = new WebClient(); webClientNewVer.DownloadFileCompleted += new AsyncCompletedEventHandler(Completed); //webClientNewVer.DownloadProgressChanged += new DownloadProgressChangedEventHandler(ProgressChanged); - webClientNewVer.DownloadFileAsync(latestVerDownUri, latestNewVerFileName); - //webClientNewVer.DownloadFile(latestVerDownUrl, latestNewVerFileName); + if (CheckDir(lastVersion)) + { + Uri latestVerDownUri = new Uri(latestVerDownUrl); + webClientNewVer.DownloadFileAsync(latestVerDownUri, lastVersion + @"\" + latestNewVerFileName); + //webClientNewVer.DownloadFile(latestVerDownUrl, latestNewVerFileName); + + using (StreamWriter sw = new StreamWriter(lastVersion + @"\" + "readme.txt")) + { + sw.WriteLine(latestNewVerExplanation); + } + } } } catch (Exception ex1) @@ -215,6 +225,21 @@ namespace ProxySU } } + //判断目录是否存在,不存在则创建 + private static bool CheckDir(string folder) + { + try + { + if (!Directory.Exists(folder))//如果不存在就创建file文件夹 + Directory.CreateDirectory(folder);//创建该文件夹   + return true; + } + catch (Exception) + { + return false; + } + } + //更新新版本提醒显示 Action updateNewVersionProxySUAction = new Action(UpdateNewVersionProxySU); private static void UpdateNewVersionProxySU(TextBlock TextBlockLastVersionProxySU, TextBlock TextBlockNewVersionReminder, Button ButtonUpgradeProxySU, string theLatestVersion) @@ -296,7 +321,7 @@ namespace ProxySU #endregion #region 主界面控件的有效无效控制代码块及界面语言 - + //加载语言资源文件 private void ResourcesLoad(string Culture) { @@ -611,8 +636,162 @@ namespace ProxySU ReceiveConfigurationParameters[i] = ""; } WindowTemplateConfiguration windowTemplateConfiguration = new WindowTemplateConfiguration(); + windowTemplateConfiguration.Closed += windowTemplateConfigurationClosed; windowTemplateConfiguration.ShowDialog(); } + //V2Ray模板设置窗口关闭后,触发事件,将所选的方案与其参数显示在UI上 + private void windowTemplateConfigurationClosed(object sender, System.EventArgs e) + { + if (String.IsNullOrEmpty(ReceiveConfigurationParameters[0]) == true) + { + //显示"未选择方案!" + TextBlockCurrentlySelectedPlan.Text = Application.Current.FindResource("TextBlockCurrentlySelectedPlanNo").ToString(); + + TextBlockV2RayShowPort.Visibility = Visibility.Hidden; + TextBlockCurrentlySelectedPlanPort.Visibility = Visibility.Hidden; + + TextBlockV2RayShowUUID.Visibility = Visibility.Hidden; + TextBlockCurrentlySelectedPlanUUID.Visibility = Visibility.Hidden; + + TextBlockV2RayShowPathSeedKey.Visibility = Visibility.Hidden; + TextBlockCurrentlySelectedPlanPathSeedKey.Visibility = Visibility.Hidden; + + TextBlockV2RayShowCurrentlySelectedPlanDomain.Visibility = Visibility.Hidden; + TextBlockCurrentlySelectedPlanDomain.Visibility = Visibility.Hidden; + + TextBlockV2RayShowCurrentlySelectedPlanFakeWebsite.Visibility = Visibility.Hidden; + TextBlockCurrentlySelectedPlanFakeWebsite.Visibility = Visibility.Hidden; + return; + } + TextBlockCurrentlySelectedPlan.Text = ReceiveConfigurationParameters[8]; //所选方案名称 + TextBlockCurrentlySelectedPlanPort.Text = ReceiveConfigurationParameters[1]; //服务器端口 + TextBlockCurrentlySelectedPlanUUID.Text = ReceiveConfigurationParameters[2]; //UUID + TextBlockCurrentlySelectedPlanPathSeedKey.Text = ReceiveConfigurationParameters[6]; //mKCP Seed\Quic Key\Path + TextBlockCurrentlySelectedPlanDomain.Text = ReceiveConfigurationParameters[4]; //域名 + TextBlockCurrentlySelectedPlanFakeWebsite.Text = ReceiveConfigurationParameters[7]; //伪装网站 + + if (String.Equals(ReceiveConfigurationParameters[0],"TCP") + || String.Equals(ReceiveConfigurationParameters[0], "TCPhttp") + || String.Equals(ReceiveConfigurationParameters[0], "tcpTLSselfSigned") + || String.Equals(ReceiveConfigurationParameters[0], "webSocket")) + { + TextBlockV2RayShowPort.Visibility = Visibility.Visible; + TextBlockCurrentlySelectedPlanPort.Visibility = Visibility.Visible; + + TextBlockV2RayShowUUID.Visibility = Visibility.Visible; + TextBlockCurrentlySelectedPlanUUID.Visibility = Visibility.Visible; + + TextBlockV2RayShowPathSeedKey.Visibility = Visibility.Hidden; + TextBlockCurrentlySelectedPlanPathSeedKey.Visibility = Visibility.Hidden; + + TextBlockV2RayShowCurrentlySelectedPlanDomain.Visibility = Visibility.Hidden; + TextBlockCurrentlySelectedPlanDomain.Visibility = Visibility.Hidden; + + TextBlockV2RayShowCurrentlySelectedPlanFakeWebsite.Visibility = Visibility.Hidden; + TextBlockCurrentlySelectedPlanFakeWebsite.Visibility = Visibility.Hidden; + + } + else if (String.Equals(ReceiveConfigurationParameters[0], "tcpTLS") || String.Equals(ReceiveConfigurationParameters[0], "VlessTcpTlsWeb")) + { + TextBlockV2RayShowPort.Visibility = Visibility.Visible; + TextBlockCurrentlySelectedPlanPort.Visibility = Visibility.Visible; + + TextBlockV2RayShowUUID.Visibility = Visibility.Visible; + TextBlockCurrentlySelectedPlanUUID.Visibility = Visibility.Visible; + + TextBlockV2RayShowPathSeedKey.Visibility = Visibility.Hidden; + TextBlockCurrentlySelectedPlanPathSeedKey.Visibility = Visibility.Hidden; + + TextBlockV2RayShowCurrentlySelectedPlanDomain.Visibility = Visibility.Visible; + TextBlockCurrentlySelectedPlanDomain.Visibility = Visibility.Visible; + + TextBlockV2RayShowCurrentlySelectedPlanFakeWebsite.Visibility = Visibility.Hidden; + TextBlockCurrentlySelectedPlanFakeWebsite.Visibility = Visibility.Hidden; + } + else if (String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLS") + || String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLS2Web") + || String.Equals(ReceiveConfigurationParameters[0], "Http2") + || String.Equals(ReceiveConfigurationParameters[0], "http2Web")) + { + TextBlockV2RayShowPort.Visibility = Visibility.Visible; + TextBlockCurrentlySelectedPlanPort.Visibility = Visibility.Visible; + + TextBlockV2RayShowUUID.Visibility = Visibility.Visible; + TextBlockCurrentlySelectedPlanUUID.Visibility = Visibility.Visible; + + TextBlockV2RayShowPathSeedKey.Text = "Path:"; + TextBlockCurrentlySelectedPlanPathSeedKey.Text = ReceiveConfigurationParameters[3]; //mKCP Seed\Quic Key\Path + + TextBlockV2RayShowPathSeedKey.Visibility = Visibility.Visible; + TextBlockCurrentlySelectedPlanPathSeedKey.Visibility = Visibility.Visible; + + TextBlockV2RayShowCurrentlySelectedPlanDomain.Visibility = Visibility.Visible; + TextBlockCurrentlySelectedPlanDomain.Visibility = Visibility.Visible; + + TextBlockV2RayShowCurrentlySelectedPlanFakeWebsite.Visibility = Visibility.Hidden; + TextBlockCurrentlySelectedPlanFakeWebsite.Visibility = Visibility.Hidden; + } + else if (String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLSselfSigned") || String.Equals(ReceiveConfigurationParameters[0], "http2selfSigned")) + { + TextBlockV2RayShowPort.Visibility = Visibility.Visible; + TextBlockCurrentlySelectedPlanPort.Visibility = Visibility.Visible; + + TextBlockV2RayShowUUID.Visibility = Visibility.Visible; + TextBlockCurrentlySelectedPlanUUID.Visibility = Visibility.Visible; + + TextBlockV2RayShowPathSeedKey.Text = "Path:"; + TextBlockCurrentlySelectedPlanPathSeedKey.Text = ReceiveConfigurationParameters[3]; //mKCP Seed\Quic Key\Path + + TextBlockV2RayShowPathSeedKey.Visibility = Visibility.Visible; + TextBlockCurrentlySelectedPlanPathSeedKey.Visibility = Visibility.Visible; + + TextBlockV2RayShowCurrentlySelectedPlanDomain.Visibility = Visibility.Hidden; + TextBlockCurrentlySelectedPlanDomain.Visibility = Visibility.Hidden; + + TextBlockV2RayShowCurrentlySelectedPlanFakeWebsite.Visibility = Visibility.Hidden; + TextBlockCurrentlySelectedPlanFakeWebsite.Visibility = Visibility.Hidden; + } + else if (ReceiveConfigurationParameters[0].Contains("mKCP")) + { + TextBlockV2RayShowPort.Visibility = Visibility.Visible; + TextBlockCurrentlySelectedPlanPort.Visibility = Visibility.Visible; + + TextBlockV2RayShowUUID.Visibility = Visibility.Visible; + TextBlockCurrentlySelectedPlanUUID.Visibility = Visibility.Visible; + + TextBlockV2RayShowPathSeedKey.Text = "mKCP Seed:"; + TextBlockCurrentlySelectedPlanPathSeedKey.Text = ReceiveConfigurationParameters[6]; //mKCP Seed\Quic Key\Path + + TextBlockV2RayShowPathSeedKey.Visibility = Visibility.Visible; + TextBlockCurrentlySelectedPlanPathSeedKey.Visibility = Visibility.Visible; + + TextBlockV2RayShowCurrentlySelectedPlanDomain.Visibility = Visibility.Hidden; + TextBlockCurrentlySelectedPlanDomain.Visibility = Visibility.Hidden; + + TextBlockV2RayShowCurrentlySelectedPlanFakeWebsite.Visibility = Visibility.Hidden; + TextBlockCurrentlySelectedPlanFakeWebsite.Visibility = Visibility.Hidden; + } + else if (ReceiveConfigurationParameters[0].Contains("Quic")) + { + TextBlockV2RayShowPort.Visibility = Visibility.Visible; + TextBlockCurrentlySelectedPlanPort.Visibility = Visibility.Visible; + + TextBlockV2RayShowUUID.Visibility = Visibility.Visible; + TextBlockCurrentlySelectedPlanUUID.Visibility = Visibility.Visible; + + TextBlockV2RayShowPathSeedKey.Text = "QUIC Key:"; + TextBlockCurrentlySelectedPlanPathSeedKey.Text = ReceiveConfigurationParameters[6]; //mKCP Seed\Quic Key\Path + + TextBlockV2RayShowPathSeedKey.Visibility = Visibility.Visible; + TextBlockCurrentlySelectedPlanPathSeedKey.Visibility = Visibility.Visible; + + TextBlockV2RayShowCurrentlySelectedPlanDomain.Visibility = Visibility.Hidden; + TextBlockCurrentlySelectedPlanDomain.Visibility = Visibility.Hidden; + + TextBlockV2RayShowCurrentlySelectedPlanFakeWebsite.Visibility = Visibility.Hidden; + TextBlockCurrentlySelectedPlanFakeWebsite.Visibility = Visibility.Hidden; + } + } //传送V2Ray模板参数,启动V2Ray安装进程 private void Button_Login_Click(object sender, RoutedEventArgs e) @@ -1422,6 +1601,14 @@ namespace ProxySU { serverJson["inbounds"][0]["port"] = int.Parse(ReceiveConfigurationParameters[1]); } + if (String.Equals(ReceiveConfigurationParameters[0], "VlessTcpTlsWeb") == true) + { + //设置Caddy随机监听的端口,用于Trojan-go,Trojan,V2Ray vless TLS + Random random = new Random(); + randomCaddyListenPort = random.Next(2000, 9000); + //指向Caddy监听的随机端口 + serverJson["inbounds"][0]["settings"]["fallbacks"][0]["dest"] = randomCaddyListenPort; + } //TLS自签证书/WebSocketTLS(自签证书)/http2自签证书模式下,使用v2ctl 生成自签证书 if (String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLSselfSigned") == true || String.Equals(ReceiveConfigurationParameters[0], "tcpTLSselfSigned") == true || String.Equals(ReceiveConfigurationParameters[0], "http2selfSigned") == true) { @@ -1803,8 +1990,15 @@ namespace ProxySU //设置Caddyfile文件中的tls 邮箱,在caddy2中已经不需要设置。 - //设置域名 + //设置Caddy监听的随机端口 + string randomCaddyListenPortStr = randomCaddyListenPort.ToString(); + sshShellCommand = $"sed -i 's/8800/{randomCaddyListenPortStr}/' {upLoadPath}"; + TextBoxMonitorCommandResults.Dispatcher.BeginInvoke(updateMonitorAction, TextBoxMonitorCommandResults, sshShellCommand);//显示执行的命令 + currentShellCommandResult = client.RunCommand(sshShellCommand).Result; + TextBoxMonitorCommandResults.Dispatcher.BeginInvoke(updateMonitorAction, TextBoxMonitorCommandResults, currentShellCommandResult);//显示命令执行的结果 + + //设置域名 sshShellCommand = $"sed -i 's/##domain##/{ReceiveConfigurationParameters[4]}/' {upLoadPath}"; TextBoxMonitorCommandResults.Dispatcher.BeginInvoke(updateMonitorAction, TextBoxMonitorCommandResults, sshShellCommand);//显示执行的命令 currentShellCommandResult = client.RunCommand(sshShellCommand).Result; @@ -2590,8 +2784,81 @@ namespace ProxySU ReceiveConfigurationParameters[i] = ""; } TrojanGoTemplateWindow windowTrojanGoTemplateConfiguration = new TrojanGoTemplateWindow(); + windowTrojanGoTemplateConfiguration.Closed += windowTrojanGoTemplateConfigurationClosed; windowTrojanGoTemplateConfiguration.ShowDialog(); } + //TrojanGo模板设置窗口关闭后,触发事件,将所选的方案与其参数显示在UI上 + private void windowTrojanGoTemplateConfigurationClosed(object sender, System.EventArgs e) + { + if (String.IsNullOrEmpty(ReceiveConfigurationParameters[0]) == true) + { + //显示"未选择方案!" + TextBlockCurrentlySelectedPlan.Text = Application.Current.FindResource("TextBlockCurrentlySelectedPlanNo").ToString(); + + TextBlockTrojanGoShowPort.Visibility = Visibility.Hidden; + TextBlockTrojanGoCurrentlySelectedPlanPort.Visibility = Visibility.Hidden; + + TextBlockTrojanGoShowPassword.Visibility = Visibility.Hidden; + TextBlockTrojanGoCurrentlySelectedPlanPassword.Visibility = Visibility.Hidden; + + TextBlockTrojanGoShowPath.Visibility = Visibility.Hidden; + TextBlockTrojanGoCurrentlySelectedPlanPathSeedKey.Visibility = Visibility.Hidden; + + TextBlockTrojanGoShowCurrentlySelectedPlanDomain.Visibility = Visibility.Hidden; + TextBlockTrojanGoCurrentlySelectedPlanDomain.Visibility = Visibility.Hidden; + + TextBlockTrojanGoShowCurrentlySelectedPlanFakeWebsite.Visibility = Visibility.Hidden; + TextBlockTrojanGoCurrentlySelectedPlanFakeWebsite.Visibility = Visibility.Hidden; + return; + } + TextBlockTrojanGoCurrentlySelectedPlan.Text = ReceiveConfigurationParameters[8]; //所选方案名称 + TextBlockTrojanGoCurrentlySelectedPlanPort.Text = ReceiveConfigurationParameters[1]; //服务器端口 + TextBlockTrojanGoCurrentlySelectedPlanPassword.Text = ReceiveConfigurationParameters[2]; //UUID + TextBlockTrojanGoCurrentlySelectedPlanPathSeedKey.Text = ReceiveConfigurationParameters[6]; //mKCP Seed\Quic Key\Path + TextBlockTrojanGoCurrentlySelectedPlanDomain.Text = ReceiveConfigurationParameters[4]; //域名 + TextBlockTrojanGoCurrentlySelectedPlanFakeWebsite.Text = ReceiveConfigurationParameters[7]; //伪装网站 + + if (String.Equals(ReceiveConfigurationParameters[0], "TrojanGoTLS2Web")) + { + TextBlockTrojanGoShowPort.Visibility = Visibility.Visible; + TextBlockTrojanGoCurrentlySelectedPlanPort.Visibility = Visibility.Visible; + + TextBlockTrojanGoShowPassword.Visibility = Visibility.Visible; + TextBlockTrojanGoCurrentlySelectedPlanPassword.Visibility = Visibility.Visible; + + TextBlockTrojanGoShowPath.Visibility = Visibility.Hidden; + TextBlockTrojanGoCurrentlySelectedPlanPathSeedKey.Visibility = Visibility.Hidden; + + TextBlockTrojanGoShowCurrentlySelectedPlanDomain.Visibility = Visibility.Visible; + TextBlockTrojanGoCurrentlySelectedPlanDomain.Visibility = Visibility.Visible; + + TextBlockTrojanGoShowCurrentlySelectedPlanFakeWebsite.Visibility = Visibility.Hidden; + TextBlockTrojanGoCurrentlySelectedPlanFakeWebsite.Visibility = Visibility.Hidden; + + } + else if (String.Equals(ReceiveConfigurationParameters[0], "TrojanGoWebSocketTLS2Web")) + { + TextBlockTrojanGoShowPort.Visibility = Visibility.Visible; + TextBlockTrojanGoCurrentlySelectedPlanPort.Visibility = Visibility.Visible; + + TextBlockTrojanGoShowPassword.Visibility = Visibility.Visible; + TextBlockTrojanGoCurrentlySelectedPlanPassword.Visibility = Visibility.Visible; + + TextBlockTrojanGoShowPath.Text = "WebSocket Path:"; + TextBlockTrojanGoCurrentlySelectedPlanPathSeedKey.Text = ReceiveConfigurationParameters[3]; //mKCP Seed\Quic Key\Path + + + TextBlockTrojanGoShowPath.Visibility = Visibility.Visible; + TextBlockTrojanGoCurrentlySelectedPlanPathSeedKey.Visibility = Visibility.Visible; + + TextBlockTrojanGoShowCurrentlySelectedPlanDomain.Visibility = Visibility.Visible; + TextBlockTrojanGoCurrentlySelectedPlanDomain.Visibility = Visibility.Visible; + + TextBlockTrojanGoShowCurrentlySelectedPlanFakeWebsite.Visibility = Visibility.Hidden; + TextBlockTrojanGoCurrentlySelectedPlanFakeWebsite.Visibility = Visibility.Hidden; + } + + } //传递TrojanGo参数 private void ButtonTrojanGoSetUp_Click(object sender, RoutedEventArgs e) @@ -3213,12 +3480,16 @@ namespace ProxySU //生成服务端配置 using (StreamReader reader = File.OpenText(serverConfig)) { + //设置Caddy随机监听的端口,用于Trojan-go,Trojan,V2Ray vless TLS + Random random = new Random(); + randomCaddyListenPort = random.Next(2000, 9000); + JObject serverJson = (JObject)JToken.ReadFrom(new JsonTextReader(reader)); serverJson["run_type"] = "server"; serverJson["local_addr"] = "0.0.0.0"; serverJson["local_port"] = 443; serverJson["remote_addr"] = "127.0.0.1"; - serverJson["remote_port"] = 88; + serverJson["remote_port"] = randomCaddyListenPort; //设置密码 serverJson["password"][0] = ReceiveConfigurationParameters[2]; //设置证书 @@ -3510,7 +3781,14 @@ namespace ProxySU //设置Caddyfile文件中的tls 邮箱 - //string email = $"user@{ReceiveConfigurationParameters[4]}"; + //设置Caddy监听的随机端口 + string randomCaddyListenPortStr = randomCaddyListenPort.ToString(); + + sshShellCommand = $"sed -i 's/8800/{randomCaddyListenPortStr}/' {upLoadPath}"; + TextBoxMonitorCommandResults.Dispatcher.BeginInvoke(updateMonitorAction, TextBoxMonitorCommandResults, sshShellCommand);//显示执行的命令 + currentShellCommandResult = client.RunCommand(sshShellCommand).Result; + TextBoxMonitorCommandResults.Dispatcher.BeginInvoke(updateMonitorAction, TextBoxMonitorCommandResults, currentShellCommandResult);//显示命令执行的结果 + //设置域名 sshShellCommand = $"sed -i 's/##domain##/{ReceiveConfigurationParameters[4]}/' {upLoadPath}"; TextBoxMonitorCommandResults.Dispatcher.BeginInvoke(updateMonitorAction, TextBoxMonitorCommandResults, sshShellCommand);//显示执行的命令 @@ -4798,8 +5076,13 @@ namespace ProxySU JObject serverJson = (JObject)JToken.ReadFrom(new JsonTextReader(reader)); //设置密码 serverJson["password"][0] = ReceiveConfigurationParameters[2]; - //设置监听端口 - //serverJson["inbounds"][0]["port"] = int.Parse(ReceiveConfigurationParameters[1]); + + //设置Caddy随机监听的端口,用于Trojan-go,Trojan,V2Ray vless TLS + Random random = new Random(); + randomCaddyListenPort = random.Next(2000, 9000); + + //设置转发到Caddy的随机监听端口 + serverJson["remote_port"] = randomCaddyListenPort; using (StreamWriter sw = new StreamWriter(@"config.json")) { @@ -5078,7 +5361,15 @@ namespace ProxySU UploadConfig(connectionInfo, caddyConfig, upLoadPath); - + //设置Caddy监听的随机端口 + string randomCaddyListenPortStr = randomCaddyListenPort.ToString(); + + sshShellCommand = $"sed -i 's/8800/{randomCaddyListenPortStr}/' {upLoadPath}"; + TextBoxMonitorCommandResults.Dispatcher.BeginInvoke(updateMonitorAction, TextBoxMonitorCommandResults, sshShellCommand);//显示执行的命令 + currentShellCommandResult = client.RunCommand(sshShellCommand).Result; + TextBoxMonitorCommandResults.Dispatcher.BeginInvoke(updateMonitorAction, TextBoxMonitorCommandResults, currentShellCommandResult);//显示命令执行的结果 + + //设置域名 sshShellCommand = $"sed -i 's/##domain##/{ReceiveConfigurationParameters[4]}/' {upLoadPath}"; @@ -7250,7 +7541,9 @@ namespace ProxySU } } - #endregion + + + #endregion // #region 三合一安装过程 diff --git a/ProxySU/Properties/AssemblyInfo.cs b/ProxySU/Properties/AssemblyInfo.cs index 1d41a49..c6eca19 100644 --- a/ProxySU/Properties/AssemblyInfo.cs +++ b/ProxySU/Properties/AssemblyInfo.cs @@ -51,5 +51,5 @@ using System.Windows; // 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号 // 方法是按如下所示使用“*”: : // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.0.3.0")] -[assembly: AssemblyFileVersion("2.0.3.0")] +[assembly: AssemblyVersion("2.0.4.0")] +[assembly: AssemblyFileVersion("2.0.4.0")] diff --git a/ProxySU/ProxySU.csproj b/ProxySU/ProxySU.csproj index bf6e05f..09026e3 100644 --- a/ProxySU/ProxySU.csproj +++ b/ProxySU/ProxySU.csproj @@ -173,15 +173,14 @@ del "$(TargetDir)*.xml" del "$(TargetDir)*.pdb" del "$(TargetDir)*.zip" -del /F /S /Q "$(TargetDir)naive_config" -del /F /S /Q "$(TargetDir)trojan_config" -del /F /S /Q "$(TargetDir)v2ray_config" -del /F /S /Q "$(TargetDir)TemplateConfg" mkdir "$(TargetDir)TemplateConfg" copy /Y "$(TargetDir)..\..\..\TemplateConfg\*.*" "$(TargetDir)TemplateConfg\" "$(TargetDir)..\..\..\7z\7z.exe" a $(TargetDir)Release.zip $(TargetDir) -xr!*config -del /F /S /Q "$(TargetDir)..\Beta" +rmdir /S /Q "$(TargetDir)..\Beta" mkdir "$(TargetDir)..\Beta" copy /Y "$(TargetDir)Release.zip" "$(TargetDir)..\Beta\Beta.zip" + + rmdir /S /Q "$(TargetDir) + \ No newline at end of file diff --git a/ProxySU/Translations/ProxySU.en-US.xaml b/ProxySU/Translations/ProxySU.en-US.xaml index 7a657db..c1de2e4 100644 --- a/ProxySU/Translations/ProxySU.en-US.xaml +++ b/ProxySU/Translations/ProxySU.en-US.xaml @@ -26,6 +26,8 @@ Trojan-Go install Upgrade Trojan-Go Cancel + Currently selected plan: + No plan selected Parameter settings Mode: Trojan+TLS+Caddy diff --git a/ProxySU/Translations/ProxySU.zh-CN.xaml b/ProxySU/Translations/ProxySU.zh-CN.xaml index 5f47548..56b58e8 100644 --- a/ProxySU/Translations/ProxySU.zh-CN.xaml +++ b/ProxySU/Translations/ProxySU.zh-CN.xaml @@ -26,6 +26,8 @@ Trojan-Go一键安装 升级Trojan-Go 取消 + 当前所选方案: + 未选择方案 参数设置 模式:Trojan+TLS+Caddy diff --git a/ProxySU/Translations/ProxySU.zh-TW.xaml b/ProxySU/Translations/ProxySU.zh-TW.xaml index 6f44171..bab5f8f 100644 --- a/ProxySU/Translations/ProxySU.zh-TW.xaml +++ b/ProxySU/Translations/ProxySU.zh-TW.xaml @@ -26,7 +26,8 @@ Trojan-Go一鍵安裝 升級Trojan-Go 取消 - + 當前所選方案: + 未選擇方案 參數設置 模式:Trojan+TLS+Caddy diff --git a/ProxySU/TrojanGoTemplateWindow.xaml.cs b/ProxySU/TrojanGoTemplateWindow.xaml.cs index f279d5a..4be8596 100644 --- a/ProxySU/TrojanGoTemplateWindow.xaml.cs +++ b/ProxySU/TrojanGoTemplateWindow.xaml.cs @@ -58,11 +58,16 @@ namespace ProxySU { //传递模板类型 MainWindow.ReceiveConfigurationParameters[0] = "TrojanGoTLS2Web"; + //传递方案名称 + MainWindow.ReceiveConfigurationParameters[8] = RadioButtonTrojanGoTLS2Web.Content.ToString(); + } else if (RadioButtonTrojanGoWebSocketTLS2Web.IsChecked == true) { //传递模板类型 MainWindow.ReceiveConfigurationParameters[0] = "TrojanGoWebSocketTLS2Web"; + //传递方案名称 + MainWindow.ReceiveConfigurationParameters[8] = RadioButtonTrojanGoWebSocketTLS2Web.Content.ToString(); MainWindow.ReceiveConfigurationParameters[3] = TextBoxPath.Text; } diff --git a/ProxySU/V2RayTemplateWindow.xaml.cs b/ProxySU/V2RayTemplateWindow.xaml.cs index 0d73703..ecbd674 100644 --- a/ProxySU/V2RayTemplateWindow.xaml.cs +++ b/ProxySU/V2RayTemplateWindow.xaml.cs @@ -53,6 +53,8 @@ namespace ProxySU { //传递模板类型 MainWindow.ReceiveConfigurationParameters[0] = "TCP"; + //传递方案名称 + MainWindow.ReceiveConfigurationParameters[8] = RadioButtonTCP.Content.ToString(); } //TCP+http伪装模式被选中 @@ -60,8 +62,11 @@ namespace ProxySU { //传递模板类型 MainWindow.ReceiveConfigurationParameters[0] = "TCPhttp"; + //传递方案名称 + MainWindow.ReceiveConfigurationParameters[8] = RadioButtonTCPhttp.Content.ToString(); //伪装类型 MainWindow.ReceiveConfigurationParameters[5] = "http"; + } //TCP+TLS模式被选中 else if (RadioButtonTCP2TLS.IsChecked == true) @@ -74,6 +79,8 @@ namespace ProxySU } //传递模板类型 MainWindow.ReceiveConfigurationParameters[0] = "tcpTLS"; + //传递方案名称 + MainWindow.ReceiveConfigurationParameters[8] = RadioButtonTCP2TLS.Content.ToString(); //传递域名 MainWindow.ReceiveConfigurationParameters[4] = TextBoxDomain.Text.ToString(); @@ -84,9 +91,11 @@ namespace ProxySU { //传递模板类型 MainWindow.ReceiveConfigurationParameters[0] = "tcpTLSselfSigned"; + //传递方案名称 + MainWindow.ReceiveConfigurationParameters[8] = RadioButtonTcpTLS2SelfSigned.Content.ToString(); //传递域名 - // MainWindow.ReceiveConfigurationParameters[4] = TextBoxDomain.Text.ToString(); + // MainWindow.ReceiveConfigurationParameters[4] = TextBoxDomain.Text.ToString(); } //VLESS+TCP+TLS+Caddy模式选中 @@ -100,6 +109,8 @@ namespace ProxySU } //传递模板类型 MainWindow.ReceiveConfigurationParameters[0] = "VlessTcpTlsWeb"; + //传递方案名称 + MainWindow.ReceiveConfigurationParameters[8] = RadioButtonVlessTcpTlsWeb.Content.ToString(); //传递域名 MainWindow.ReceiveConfigurationParameters[4] = TextBoxDomain.Text.ToString(); @@ -126,6 +137,8 @@ namespace ProxySU { //传递模板类型 MainWindow.ReceiveConfigurationParameters[0] = "webSocket"; + //传递方案名称 + MainWindow.ReceiveConfigurationParameters[8] = RadioButtonWebSocket.Content.ToString(); } //WebSocket+TLS模式被选中 @@ -139,6 +152,8 @@ namespace ProxySU } //传递模板类型 MainWindow.ReceiveConfigurationParameters[0] = "WebSocketTLS"; + //传递方案名称 + MainWindow.ReceiveConfigurationParameters[8] = RadioButtonWebSocketTLS.Content.ToString(); //传递路径 MainWindow.ReceiveConfigurationParameters[3] = TextBoxPath.Text.ToString(); //传递域名 @@ -157,6 +172,9 @@ namespace ProxySU } //传递模板类型 MainWindow.ReceiveConfigurationParameters[0] = "WebSocketTLS2Web"; + //传递方案名称 + MainWindow.ReceiveConfigurationParameters[8] = RadioButtonWebSocketTLS2Web.Content.ToString(); + //传递路径 MainWindow.ReceiveConfigurationParameters[3] = TextBoxPath.Text.ToString(); //传递域名 @@ -184,6 +202,9 @@ namespace ProxySU { //传递模板类型 MainWindow.ReceiveConfigurationParameters[0] = "WebSocketTLSselfSigned"; + //传递方案名称 + MainWindow.ReceiveConfigurationParameters[8] = RadioButtonWebSocketTLSselfSigned.Content.ToString(); + //传递路径 MainWindow.ReceiveConfigurationParameters[3] = TextBoxPath.Text.ToString(); //传递域名 @@ -201,6 +222,9 @@ namespace ProxySU } //传递模板类型 MainWindow.ReceiveConfigurationParameters[0] = "Http2"; + //传递方案名称 + MainWindow.ReceiveConfigurationParameters[8] = RadioButtonHTTP2.Content.ToString(); + //传递路径 MainWindow.ReceiveConfigurationParameters[3] = TextBoxPath.Text.ToString(); //传递域名 @@ -218,6 +242,9 @@ namespace ProxySU } //传递模板类型 MainWindow.ReceiveConfigurationParameters[0] = "http2Web"; + //传递方案名称 + MainWindow.ReceiveConfigurationParameters[8] = RadioButtonHTTP2Web.Content.ToString(); + //传递路径 MainWindow.ReceiveConfigurationParameters[3] = TextBoxPath.Text.ToString(); //传递域名 @@ -245,6 +272,9 @@ namespace ProxySU { //传递模板类型 MainWindow.ReceiveConfigurationParameters[0] = "http2selfSigned"; + //传递方案名称 + MainWindow.ReceiveConfigurationParameters[8] = RadioButtonHTTP2selfSigned.Content.ToString(); + //传递路径 MainWindow.ReceiveConfigurationParameters[3] = TextBoxPath.Text.ToString(); //传递域名 @@ -256,6 +286,9 @@ namespace ProxySU { //传递模板类型 MainWindow.ReceiveConfigurationParameters[0] = "mKCPNone"; + //传递方案名称 + MainWindow.ReceiveConfigurationParameters[8] = RadioButtonMkcpNone.Content.ToString(); + MainWindow.ReceiveConfigurationParameters[5] = "none"; //传递mKCP Seed if (String.IsNullOrEmpty(TextBoxQuicUUID.Text)==false) @@ -268,6 +301,9 @@ namespace ProxySU { //传递模板类型 MainWindow.ReceiveConfigurationParameters[0] = "mKCP2SRTP"; + //传递方案名称 + MainWindow.ReceiveConfigurationParameters[8] = RadioButton2mKCP2SRTP.Content.ToString(); + MainWindow.ReceiveConfigurationParameters[5] = "srtp"; //传递mKCP Seed if (String.IsNullOrEmpty(TextBoxQuicUUID.Text) == false) @@ -280,6 +316,9 @@ namespace ProxySU { //传递模板类型 MainWindow.ReceiveConfigurationParameters[0] = "mKCPuTP"; + //传递方案名称 + MainWindow.ReceiveConfigurationParameters[8] = RadioButton2mKCPuTP.Content.ToString(); + MainWindow.ReceiveConfigurationParameters[5] = "utp"; //传递mKCP Seed if (String.IsNullOrEmpty(TextBoxQuicUUID.Text) == false) @@ -292,6 +331,9 @@ namespace ProxySU { //传递模板类型 MainWindow.ReceiveConfigurationParameters[0] = "mKCP2WechatVideo"; + //传递方案名称 + MainWindow.ReceiveConfigurationParameters[8] = RadioButton2mKCP2WechatVideo.Content.ToString(); + MainWindow.ReceiveConfigurationParameters[5] = "wechat-video"; //传递mKCP Seed if (String.IsNullOrEmpty(TextBoxQuicUUID.Text) == false) @@ -304,6 +346,9 @@ namespace ProxySU { //传递模板类型 MainWindow.ReceiveConfigurationParameters[0] = "mKCP2DTLS"; + //传递方案名称 + MainWindow.ReceiveConfigurationParameters[8] = RadioButton2mKCP2DTLS.Content.ToString(); + MainWindow.ReceiveConfigurationParameters[5] = "dtls"; //传递mKCP Seed if (String.IsNullOrEmpty(TextBoxQuicUUID.Text) == false) @@ -316,6 +361,9 @@ namespace ProxySU { //传递模板类型 MainWindow.ReceiveConfigurationParameters[0] = "mKCP2WireGuard"; + //传递方案名称 + MainWindow.ReceiveConfigurationParameters[8] = RadioButton2mKCP2WireGuard.Content.ToString(); + MainWindow.ReceiveConfigurationParameters[5] = "wireguard"; //传递mKCP Seed if (String.IsNullOrEmpty(TextBoxQuicUUID.Text) == false) @@ -328,6 +376,9 @@ namespace ProxySU { //传递模板类型 MainWindow.ReceiveConfigurationParameters[0] = "QuicNone"; + //传递方案名称 + MainWindow.ReceiveConfigurationParameters[8] = RadioButtonQuicNone.Content.ToString(); + MainWindow.ReceiveConfigurationParameters[5] = "none"; MainWindow.ReceiveConfigurationParameters[6] = TextBoxQuicUUID.Text; } @@ -336,6 +387,9 @@ namespace ProxySU { //传递模板类型 MainWindow.ReceiveConfigurationParameters[0] = "QuicSRTP"; + //传递方案名称 + MainWindow.ReceiveConfigurationParameters[8] = RadioButtonQuicSRTP.Content.ToString(); + MainWindow.ReceiveConfigurationParameters[5] = "srtp"; MainWindow.ReceiveConfigurationParameters[6] = TextBoxQuicUUID.Text; } @@ -344,6 +398,9 @@ namespace ProxySU { //传递模板类型 MainWindow.ReceiveConfigurationParameters[0] = "Quic2uTP"; + //传递方案名称 + MainWindow.ReceiveConfigurationParameters[8] = RadioButtonQuic2uTP.Content.ToString(); + MainWindow.ReceiveConfigurationParameters[5] = "utp"; MainWindow.ReceiveConfigurationParameters[6] = TextBoxQuicUUID.Text; } @@ -352,6 +409,9 @@ namespace ProxySU { //传递模板类型 MainWindow.ReceiveConfigurationParameters[0] = "QuicWechatVideo"; + //传递方案名称 + MainWindow.ReceiveConfigurationParameters[8] = RadioButtonQuicWechatVideo.Content.ToString(); + MainWindow.ReceiveConfigurationParameters[5] = "wechat-video"; MainWindow.ReceiveConfigurationParameters[6] = TextBoxQuicUUID.Text; } @@ -360,6 +420,9 @@ namespace ProxySU { //传递模板类型 MainWindow.ReceiveConfigurationParameters[0] = "QuicDTLS"; + //传递方案名称 + MainWindow.ReceiveConfigurationParameters[8] = RadioButtonQuicDTLS.Content.ToString(); + MainWindow.ReceiveConfigurationParameters[5] = "dtls"; MainWindow.ReceiveConfigurationParameters[6] = TextBoxQuicUUID.Text; } @@ -368,20 +431,26 @@ namespace ProxySU { //传递模板类型 MainWindow.ReceiveConfigurationParameters[0] = "QuicWireGuard"; + //传递方案名称 + MainWindow.ReceiveConfigurationParameters[8] = RadioButtonQuicWireGuard.Content.ToString(); + MainWindow.ReceiveConfigurationParameters[5] = "wireguard"; MainWindow.ReceiveConfigurationParameters[6] = TextBoxQuicUUID.Text; } - //默认模式为 TCP - else - { - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "TCP"; - } + ////默认模式为 TCP + //else + //{ + // //传递模板类型 + // MainWindow.ReceiveConfigurationParameters[0] = "TCP"; + // //传递方案名称 + // MainWindow.ReceiveConfigurationParameters[8] = RadioButtonTCP.Content.ToString(); + + //} //传递服务端口 MainWindow.ReceiveConfigurationParameters[1] = TextBoxServerListenPort.Text.ToString(); //传递uuid MainWindow.ReceiveConfigurationParameters[2] = TextBoxNewUUID.Text.ToString(); - + this.Close(); } diff --git a/ProxySU/bin/Beta/Beta.zip b/ProxySU/bin/Beta/Beta.zip index 99213d9..a9b9770 100644 Binary files a/ProxySU/bin/Beta/Beta.zip and b/ProxySU/bin/Beta/Beta.zip differ diff --git a/TemplateConfg/ssr_tls_caddy_config.caddyfile b/TemplateConfg/ssr_tls_caddy_config.caddyfile new file mode 100644 index 0000000..d27ff82 --- /dev/null +++ b/TemplateConfg/ssr_tls_caddy_config.caddyfile @@ -0,0 +1,8 @@ +https://##domain##:8800 { + root * /usr/share/caddy + file_server + ##sites## +} +##domain##:80 { + redir https://##domain##{uri} +} \ No newline at end of file diff --git a/TemplateConfg/tcp_vless_tls_caddy_server_config.json b/TemplateConfg/tcp_vless_tls_caddy_server_config.json index d60afc8..60501a1 100644 --- a/TemplateConfg/tcp_vless_tls_caddy_server_config.json +++ b/TemplateConfg/tcp_vless_tls_caddy_server_config.json @@ -15,7 +15,7 @@ "decryption": "none", "fallbacks": [ { - "dest": 88 + "dest": 8800 } ] }, diff --git a/TemplateConfg/trojan_caddy_config.caddyfile b/TemplateConfg/trojan_caddy_config.caddyfile index f6bf8a8..6001c60 100644 --- a/TemplateConfg/trojan_caddy_config.caddyfile +++ b/TemplateConfg/trojan_caddy_config.caddyfile @@ -1,4 +1,4 @@ -:88 { +:8800 { root * /usr/share/caddy file_server ##sites## diff --git a/TemplateConfg/trojan_server_config.json b/TemplateConfg/trojan_server_config.json index 608ff61..ba5a6fa 100644 --- a/TemplateConfg/trojan_server_config.json +++ b/TemplateConfg/trojan_server_config.json @@ -3,7 +3,7 @@ "local_addr": "::", "local_port": 443, "remote_addr": "127.0.0.1", - "remote_port": 88, + "remote_port": 8800, "password": [ "" ],