diff --git a/7z/7z.exe b/7z/7z.exe deleted file mode 100644 index 3a8ee47..0000000 Binary files a/7z/7z.exe and /dev/null differ diff --git a/7z/readme.md b/7z/readme.md deleted file mode 100644 index 892f500..0000000 --- a/7z/readme.md +++ /dev/null @@ -1 +0,0 @@ -这个7z.exe文件,只是为了生成Release.zip方便。可有可无。ProxySU并不调用。 \ No newline at end of file diff --git a/ProxySU.sln b/ProxySU.sln index b6c6063..78ce6b6 100644 --- a/ProxySU.sln +++ b/ProxySU.sln @@ -3,15 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.31005.135 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProxySU", "ProxySU\ProxySU.csproj", "{DD5505BC-E7F1-4D03-ABC7-B636E893FC09}" -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 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Libs", "Libs", "{CE908112-DB46-4B91-8236-9139A19D66E9}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProxySuper.WPF", "ProxySuper.WPF\ProxySuper.WPF.csproj", "{B083EBFD-2925-46C9-8B00-E2C1300CEBA1}" @@ -24,14 +15,6 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {DD5505BC-E7F1-4D03-ABC7-B636E893FC09}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DD5505BC-E7F1-4D03-ABC7-B636E893FC09}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DD5505BC-E7F1-4D03-ABC7-B636E893FC09}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DD5505BC-E7F1-4D03-ABC7-B636E893FC09}.Release|Any CPU.Build.0 = Release|Any CPU - {B066015C-D347-4493-92F1-6556D3863996}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B066015C-D347-4493-92F1-6556D3863996}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B066015C-D347-4493-92F1-6556D3863996}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B066015C-D347-4493-92F1-6556D3863996}.Release|Any CPU.Build.0 = Release|Any CPU {B083EBFD-2925-46C9-8B00-E2C1300CEBA1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B083EBFD-2925-46C9-8B00-E2C1300CEBA1}.Debug|Any CPU.Build.0 = Debug|Any CPU {B083EBFD-2925-46C9-8B00-E2C1300CEBA1}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/ProxySU/App.xaml b/ProxySU/App.xaml deleted file mode 100644 index 4a9db0e..0000000 --- a/ProxySU/App.xaml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - diff --git a/ProxySU/App.xaml.cs b/ProxySU/App.xaml.cs deleted file mode 100644 index 6ed5114..0000000 --- a/ProxySU/App.xaml.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Configuration; -using System.Data; -using System.Linq; -using System.Windows; - -namespace ProxySU -{ - /// - /// App.xaml 的交互逻辑 - /// - public partial class App : Application - { - } -} diff --git a/ProxySU/ClassModel.cs b/ProxySU/ClassModel.cs deleted file mode 100644 index 4bea9a7..0000000 --- a/ProxySU/ClassModel.cs +++ /dev/null @@ -1,86 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; -using System.Text.RegularExpressions; -using System.Threading; -using System.Threading.Tasks; -using System.IO; -using Renci.SshNet; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using Newtonsoft.Json.Serialization; -using System.Drawing; -using QRCoder; -using System.Net; -using System.ComponentModel; -using System.Net.Sockets; -using System.Runtime.InteropServices; -using System.Runtime; -using System.Globalization; -using Microsoft.Win32; -using System.Security; - -namespace ProxySU -{ - class ClassModel - { - //检测域名是否为空 - public static bool TestDomainIsEmpty(string domainStr) - { - domainStr = domainStr.Trim(); - if (string.IsNullOrEmpty(domainStr) == true) - { - //****** "域名不能为空,请检查相关参数设置!" ****** - MessageBox.Show(Application.Current.FindResource("MessageBoxShow_DomainNotEmpty").ToString()); - return false; - } - else - { - return true; - } - } - //伪装网站预处理 - public static bool PreDomainMask(string uri) - { - uri = uri.Trim(); - if (String.IsNullOrEmpty(uri) == false) - { - if (uri.Contains("/") == true) - { - //MessageBox.Show("伪装网址输入格式错误!请重新输入!"); - MessageBox.Show(Application.Current.FindResource("MessageBoxShow_MaskSitesToolTip").ToString()); - return false; - } - } - return true; - } - //伪装网址的处理 - public static string DisguiseURLprocessing(string fakeUrl) - { - fakeUrl = fakeUrl.Trim(); - return fakeUrl; - //处理伪装网站域名中的前缀 - //if (fakeUrl.Length >= 7) - //{ - // string testDomainMask = fakeUrl.Substring(0, 7); - // if (String.Equals(testDomainMask, "https:/") || String.Equals(testDomainMask, "http://")) - // { - // var uri = new Uri(fakeUrl); - // return uri.Host; - // } - - //} - - } - } -} diff --git a/ProxySU/MainWindow.xaml b/ProxySU/MainWindow.xaml deleted file mode 100644 index 9a26b7b..0000000 --- a/ProxySU/MainWindow.xaml +++ /dev/null @@ -1,849 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ProxySU/MainWindow.xaml.cs b/ProxySU/MainWindow.xaml.cs deleted file mode 100644 index 7350959..0000000 --- a/ProxySU/MainWindow.xaml.cs +++ /dev/null @@ -1,10528 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; -using System.Text.RegularExpressions; -using System.Threading; -using System.Threading.Tasks; -using System.IO; -using Renci.SshNet; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using Newtonsoft.Json.Serialization; -using System.Drawing; -using QRCoder; -using System.Net; -using System.ComponentModel; -using System.Net.Sockets; -using System.Runtime.InteropServices; -using System.Runtime; -using System.Globalization; -using Microsoft.Win32; -using System.Security; - -namespace ProxySU -{ - class NatDns64 - { - private string ipaddr { set; get; } //Dns64网关地址 - private int avg { set; get; } //ping的平均值 - - public NatDns64(string IpAddr, int Avg) - { - this.ipaddr = IpAddr; - this.avg = Avg; - } - - public string IpAddr - { - get { return ipaddr; } - set { this.ipaddr = IpAddr; } - } - - public int Avg - { - get { return avg; } - set { this.avg = Avg; } - } - } - /// - /// MainWindow.xaml 的交互逻辑 - /// - public partial class MainWindow : Window - { - //多语言参数 - public class LanguageInfo - { - public string Name { get; set; } - public string Value { get; set; } - } - public static string[] ReceiveConfigurationParameters { get; set; } - - //ReceiveConfigurationParameters[0]----模板类型 - //ReceiveConfigurationParameters[1]----服务端口 - //ReceiveConfigurationParameters[2]----V2Ray uuid/(naive/Trojan-go/Trojan/SSR/SS)' Password - //ReceiveConfigurationParameters[3]----QUIC加密方式/SSR 加密方法/SS 加密方式/naive'user/VLESS ws Path/trojan-go mux concurrency - //ReceiveConfigurationParameters[4]----Domain - //ReceiveConfigurationParameters[5]----伪装类型/插件名称/trojan-go mux idle_timeout - //ReceiveConfigurationParameters[6]----V2Ray&Trojan-go&SS--Websocket'Path/http2'Path/QUIC密钥/mKCP Seed/VMESS ws Path - //ReceiveConfigurationParameters[7]----伪装网站 - //ReceiveConfigurationParameters[8]----方案名称 - //ReceiveConfigurationParameters[9]----插件参数选项/VMESS tcp Path/MTProto Parameters/trojan-go是否启用Mux(true) - //public static ConnectionInfo ConnectionInfo; - - public static string proxyType = "V2Ray"; //代理类型标识: V2Ray\TrojanGo\Trojan\NaiveProxy - public static readonly string pwdir = AppDomain.CurrentDomain.BaseDirectory; //执行文件所在目录 - public static bool mKCPvlessIsSet = false; //mKCP是否使用VLESS协议 - static bool testDomain = false; //设置标识--域名是否需要检测解析,初始化为不需要 - static string ipv4 = String.Empty; //保存获取的ipv4地址 - static string ipv6 = String.Empty; //保存获取的ipv6地址 - static bool onlyIpv6 = false; //主机是否基于纯ipv6地址 - static bool functionResult = true; //标示功能函数是否执行状态(true无错误发生/false有错误发生) - static string sshShellCommand = String.Empty; //定义保存执行的命令 - static string currentStatus = String.Empty; //定议保存要显示的状态 - static string currentShellCommandResult = String.Empty; //定义Shell命令执行结果保存变量 - static bool getApt = false; //判断系统软件管理,下同 - static bool getDnf = false; - static bool getYum = false; - static string sshCmdUpdate = String.Empty; //保存软件安装所用更新软件库命令 - static string sshCmdInstall = String.Empty; //保存软件安装所用命令格式 - static int randomCaddyListenPort = 8800; //Caddy做伪装网站所监听的端口,随机10001-60000 - static int installationDegree = 0; //安装进度条显示的百分比 - static string saveShellScriptFileName = "install.sh"; //用来保存下载的脚本名称 - static string acmeEmail = ""; - - //****** ****** - // Application.Current.FindResource("").ToString() - // - // {DynamicResource } - //SetUpProgressBarProcessing(0); - public MainWindow() - { - InitializeComponent(); - - #region 多语言选择设置 初始设置为auto - List languageList = new List(); - - languageList.Add(new LanguageInfo { Name = "auto", Value = "auto" }); - languageList.Add(new LanguageInfo { Name = "English", Value = "en-US" }); - languageList.Add(new LanguageInfo { Name = "简体中文", Value = "zh-CN" }); - languageList.Add(new LanguageInfo { Name = "正體中文", Value = "zh-TW" }); - - ComboBoxLanguage.ItemsSource = languageList; - - ComboBoxLanguage.DisplayMemberPath = "Name";//显示出来的值 - ComboBoxLanguage.SelectedValuePath = "Value";//实际选中后获取的结果的值 - ComboBoxLanguage.SelectedIndex = 0; - - DataContext = this; - string Culture = System.Globalization.CultureInfo.InstalledUICulture.Name; - //Culture = "en-US"; - ResourcesLoad(Culture); - #endregion - - //初始化参数设置数组 - ReceiveConfigurationParameters = new string[10]; - - //初始化选定密码登录 - RadioButtonPasswordLogin.IsChecked = true; - //初始化选定无代理 - RadioButtonNoProxy.IsChecked = true; - //初始化代理无需登录 - RadioButtonProxyNoLogin.IsChecked = true; - //初始化隐藏Socks4代理, - RadioButtonSocks4.Visibility = Visibility.Collapsed; - - //初始化Trojan的密码 - TextBoxTrojanPassword.Text = RandomUUID(); - - //初始化NaiveProxy的用户名和密码 - TextBoxNaivePassword.Text = RandomUUID(); - TextBoxNaiveUser.Text = RandomUserName(); - - //初始化SSR的密码 - TextBoxSSRPassword.Text = RandomUUID(); - - //初始化V2Ray所选方案面板为不显示 - GridV2rayCurrentlyPlan.Visibility = Visibility.Hidden; - - //初始化Xray所选方案面板为不显示 - GridXrayCurrentlyPlan.Visibility = Visibility.Hidden; - - //自动检查ProxySU是否有新版本发布,有则显示更新提示 - Thread thread = new Thread(() => TestLatestVersionProxySU(TextBlockLastVersionProxySU, TextBlockNewVersionReminder, ButtonUpgradeProxySU)); - thread.SetApartmentState(ApartmentState.STA); - thread.Start(); - } - - #region 检测新版本代码 - - //检测ProxySU新版本 - private void TestLatestVersionProxySU(TextBlock TextBlockLastVersionProxySU, TextBlock TextBlockNewVersionReminder, Button ButtonUpgradeProxySU) - { - string strJson = GetLatestJson(@"https://api.github.com/repos/proxysu/windows/releases/latest"); - if (String.IsNullOrEmpty(strJson) == false) - { - JObject lastVerJsonObj = JObject.Parse(strJson); - string lastVersion = (string)lastVerJsonObj["tag_name"];//得到远程版本信息 - - string lastVersionNoV = lastVersion.Replace("v", String.Empty); - - Version version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; - //MessageBox.Show(version.ToString()); - string cerversion = version.ToString().Substring(0, 6); //获取本地版本信息 - //MessageBox.Show(cerversion); - string[] lastVerComp = lastVersionNoV.Split('.'); - string[] localVerComp = cerversion.Split('.'); - - //版本信息不相同,则认为新版本发布,显示出新版本信息及更新提醒,下载按钮 - if (int.Parse(lastVerComp[0]) > int.Parse(localVerComp[0])) - { - TextBlockLastVersionProxySU.Dispatcher.BeginInvoke(updateNewVersionProxySUAction, TextBlockLastVersionProxySU, TextBlockNewVersionReminder, ButtonUpgradeProxySU, lastVersion); - return; - } - else if (int.Parse(lastVerComp[0]) == int.Parse(localVerComp[0])) - { - if (int.Parse(lastVerComp[1]) > int.Parse(localVerComp[1])) - { - TextBlockLastVersionProxySU.Dispatcher.BeginInvoke(updateNewVersionProxySUAction, TextBlockLastVersionProxySU, TextBlockNewVersionReminder, ButtonUpgradeProxySU, lastVersion); - return; - } - else if (int.Parse(lastVerComp[1]) == int.Parse(localVerComp[1])) - { - if (int.Parse(lastVerComp[2]) > int.Parse(localVerComp[2])) - { - TextBlockLastVersionProxySU.Dispatcher.BeginInvoke(updateNewVersionProxySUAction, TextBlockLastVersionProxySU, TextBlockNewVersionReminder, ButtonUpgradeProxySU, lastVersion); - return; - } - } - } - } - } - - //下载最新版ProxySU - private void ButtonUpgradeProxySU_Click(object sender, RoutedEventArgs e) - { - TextBlockNewVersionReminder.Visibility = Visibility.Hidden; - TextBlockNewVersionDown.Visibility = Visibility.Visible; - //TextBlockNewVersionReminder.Text = Application.Current.FindResource("TextBlockNewVersionDown").ToString(); - try - { - string strJson = GetLatestJson(@"https://api.github.com/repos/proxysu/windows/releases/latest"); - if (String.IsNullOrEmpty(strJson) == false) - { - JObject lastVerJsonObj = JObject.Parse(strJson); - 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); - 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) - { - // MessageBox.Show(ex1.ToString()); - - return; - } - } - //文件下载完处理方法 - private void Completed(object sender, AsyncCompletedEventArgs e) - { - if (e.Cancelled == true) - { - MessageBox.Show(e.Error.ToString()); - MessageBox.Show(Application.Current.FindResource("MessageBoxShow_ErrorDownProxyFail").ToString()); - //label1.Text = "Download cancelled!"; - } - else - { - MessageBox.Show(Application.Current.FindResource("MessageBoxShow_ErrorDownProxySuccess").ToString()); - } - } - - //获取LatestJson - private string GetLatestJson(string theLatestUrl) - { - try - { - //ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | (SecurityProtocolType)3072 | (SecurityProtocolType)768 | SecurityProtocolType.Tls; - ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072; - // ServicePointManager.SecurityProtocol = (SecurityProtocolType)(0xc0 | 0x300 | 0xc00 | 0x30); - //string url = "https://api.github.com/repos/proxysu/windows/releases/latest"; - Uri uri = new Uri(theLatestUrl); - HttpWebRequest req = (HttpWebRequest)WebRequest.Create(uri); - req.Accept = @"application/json"; - req.UserAgent = @"Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:74.0) Gecko/20100101 Firefox/74.0"; - HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); - Stream stream = resp.GetResponseStream(); - StreamReader sr = new StreamReader(stream); - string strJson = sr.ReadToEnd(); - return strJson; - } - catch (Exception ex1) - { - return null; - } - } - - - //更新新版本提醒显示 - Action updateNewVersionProxySUAction = new Action(UpdateNewVersionProxySU); - private static void UpdateNewVersionProxySU(TextBlock TextBlockLastVersionProxySU, TextBlock TextBlockNewVersionReminder, Button ButtonUpgradeProxySU, string theLatestVersion) - { - TextBlockLastVersionProxySU.Text = theLatestVersion; - TextBlockLastVersionProxySU.Visibility = Visibility.Visible; - TextBlockNewVersionReminder.Visibility = Visibility.Visible; - ButtonUpgradeProxySU.Visibility = Visibility.Visible; - } - - #endregion - - #region 安装过程信息显示 端口数字防错代码,密钥选择代码 - - //更新状态条显示 - Action updateAction = new Action(UpdateTextBlock); - private static void UpdateTextBlock(TextBlock textBlockName, ProgressBar progressBar, string currentStatus) - { - textBlockName.Text = currentStatus; - - //if (currentStatus.Contains("成功") == true || currentStatus.ToLower().Contains("success") == true) - //{ - // progressBar.IsIndeterminate = false; - // progressBar.Value = 100; - //} - //else - if (currentStatus.Contains("失败") == true || currentStatus.Contains("取消") == true || currentStatus.Contains("退出") == true || currentStatus.ToLower().Contains("fail") == true || currentStatus.ToLower().Contains("cancel") == true || currentStatus.ToLower().Contains("exit") == true) - { - progressBar.IsIndeterminate = false; - progressBar.Value = 0; - } - //else - //{ - // progressBar.IsIndeterminate = true; - // //progressBar.Value = 0; - //} - - - } - - //进度条更新百分比 - private void SetUpProgressBarProcessing(int max) - { - - for (int i = installationDegree; i <= max; i++) - { - Thread.Sleep(100); - Dispatcher.Invoke(new Action(ProgressBarSetUpProcessing.SetValue), System.Windows.Threading.DispatcherPriority.Background, new object[] { ProgressBar.ValueProperty, Convert.ToDouble(i) }); - } - installationDegree = max; - } - - - //更新监视窗内的显示 - //结尾自动添加一个换行符 - Action updateMonitorAction = new Action(UpdateTextBox); - private static void UpdateTextBox(TextBox textBoxName, string currentResult) - { - textBoxName.Text = textBoxName.Text + currentResult + Environment.NewLine; - textBoxName.ScrollToEnd(); - } - - //结尾不添加换行符 - Action updateMonitorActionNoWrap = new Action(UpdateTextBoxNoWrap); - private static void UpdateTextBoxNoWrap(TextBox textBoxName, string currentResult) - { - textBoxName.Text = textBoxName.Text + currentResult; - textBoxName.ScrollToEnd(); - } - - //退出主程序 - private void Button_canel_Click(object sender, RoutedEventArgs e) - { - Application.Current.Shutdown(); - } - - // private static readonly Regex _regex = new Regex("[^0-9]+"); - - //检测数字输入 - private void TextBoxPort_PreviewTextInput(object sender, TextCompositionEventArgs e) - { - Regex regex = new Regex("[^0-9]+"); - e.Handled = regex.IsMatch(e.Text); - } - - //检测字符串是否只由数字组成 - private bool IsOnlyNumber(string value) - { - value = value.Trim(); - Regex r = new Regex(@"^[0-9]+$"); - return r.Match(value).Success; - } - - //端口输入框是否可使用粘贴命令 - private void TextBoxPort_PreviewExecuted(object sender, ExecutedRoutedEventArgs e) - { - if (e.Command == ApplicationCommands.Paste) - { - e.Handled = false;//true为不能使用粘贴命令,false为可以使用粘贴命令 - } - } - - //打开证书浏览 - private void ButtonOpenFileDialog_Click(object sender, RoutedEventArgs e) - { - var openFileDialog = new Microsoft.Win32.OpenFileDialog() - { - Filter = "Cert Files (*.*)|*.*" - }; - var result = openFileDialog.ShowDialog(); - if (result == true) - { - TextBoxCertFilePath.Text = openFileDialog.FileName; - } - } - #endregion - - #region 主界面控件的有效无效控制代码块及界面语言 - - //加载语言资源文件 - private void ResourcesLoad(string Culture) - { - List dictionaryList = new List(); - foreach (ResourceDictionary dictionary in Application.Current.Resources.MergedDictionaries) - { - dictionaryList.Add(dictionary); - } - string requestedCulture = string.Format(@"Translations\ProxySU.{0}.xaml", Culture); - //string requestedCulture = string.Format(@"Translations\ProxySU.{0}.xaml", "default"); - ResourceDictionary resourceDictionary = dictionaryList.FirstOrDefault(d => d.Source.OriginalString.Equals(requestedCulture)); - if (resourceDictionary == null) - { - requestedCulture = @"Translations\ProxySU.en-US.xaml"; - resourceDictionary = dictionaryList.FirstOrDefault(d => d.Source.OriginalString.Equals(requestedCulture)); - } - if (resourceDictionary != null) - { - Application.Current.Resources.MergedDictionaries.Remove(resourceDictionary); - Application.Current.Resources.MergedDictionaries.Add(resourceDictionary); - } - } - - //界面语言处理 - private void ComboBoxLanguage_SelectionChanged(object sender, SelectionChangedEventArgs e) - { - string languageCulture; - object languageSelected; - languageSelected = ComboBoxLanguage.SelectedValue; - languageCulture = languageSelected.ToString(); - if (languageCulture.Equals("auto")) - { - languageCulture = System.Globalization.CultureInfo.InstalledUICulture.Name; - ResourcesLoad(languageCulture); - } - else - { - ResourcesLoad(languageCulture); - } - //display.Text = language; - } - private void RadioButtonNoProxy_Checked(object sender, RoutedEventArgs e) - { - TextBlockProxyHost.IsEnabled = false; - TextBlockProxyHost.Visibility = Visibility.Collapsed; - TextBoxProxyHost.IsEnabled = false; - TextBoxProxyHost.Visibility = Visibility.Collapsed; - TextBlockProxyPort.IsEnabled = false; - TextBlockProxyPort.Visibility = Visibility.Collapsed; - TextBoxProxyPort.IsEnabled = false; - TextBoxProxyPort.Visibility = Visibility.Collapsed; - RadioButtonProxyNoLogin.IsEnabled = false; - RadioButtonProxyNoLogin.Visibility = Visibility.Collapsed; - RadiobuttonProxyYesLogin.IsEnabled = false; - RadiobuttonProxyYesLogin.Visibility = Visibility.Collapsed; - TextBlockProxyUser.IsEnabled = false; - TextBlockProxyUser.Visibility = Visibility.Collapsed; - TextBoxProxyUserName.IsEnabled = false; - TextBoxProxyUserName.Visibility = Visibility.Collapsed; - TextBlockProxyPassword.IsEnabled = false; - TextBlockProxyPassword.Visibility = Visibility.Collapsed; - PasswordBoxProxyPassword.IsEnabled = false; - PasswordBoxProxyPassword.Visibility = Visibility.Collapsed; - } - - private void RadioButtonNoProxy_Unchecked(object sender, RoutedEventArgs e) - { - TextBlockProxyHost.IsEnabled = true; - TextBlockProxyHost.Visibility = Visibility.Visible; - TextBoxProxyHost.IsEnabled = true; - TextBoxProxyHost.Visibility = Visibility.Visible; - TextBlockProxyPort.IsEnabled = true; - TextBlockProxyPort.Visibility = Visibility.Visible; - TextBoxProxyPort.IsEnabled = true; - TextBoxProxyPort.Visibility = Visibility.Visible; - RadioButtonProxyNoLogin.IsEnabled = true; - RadioButtonProxyNoLogin.Visibility = Visibility.Visible; - RadiobuttonProxyYesLogin.IsEnabled = true; - RadiobuttonProxyYesLogin.Visibility = Visibility.Visible; - if (RadioButtonProxyNoLogin.IsChecked == true) - { - TextBlockProxyUser.IsEnabled = false; - TextBlockProxyUser.Visibility = Visibility.Collapsed; - TextBlockProxyPassword.IsEnabled = false; - TextBlockProxyPassword.Visibility = Visibility.Collapsed; - TextBoxProxyUserName.IsEnabled = false; - TextBoxProxyUserName.Visibility = Visibility.Collapsed; - PasswordBoxProxyPassword.IsEnabled = false; - PasswordBoxProxyPassword.Visibility = Visibility.Collapsed; - } - else - { - TextBlockProxyUser.IsEnabled = true; - TextBlockProxyUser.Visibility = Visibility.Visible; - TextBoxProxyUserName.IsEnabled = true; - TextBoxProxyUserName.Visibility = Visibility.Visible; - TextBlockProxyPassword.IsEnabled = true; - TextBlockProxyPassword.Visibility = Visibility.Visible; - PasswordBoxProxyPassword.IsEnabled = true; - PasswordBoxProxyPassword.Visibility = Visibility.Visible; - } - } - - private void RadioButtonPasswordLogin_Checked(object sender, RoutedEventArgs e) - { - ButtonOpenFileDialog.IsEnabled = false; - ButtonOpenFileDialog.Visibility = Visibility.Collapsed; - TextBoxCertFilePath.IsEnabled = false; - TextBoxCertFilePath.Visibility = Visibility.Collapsed; - TextBlockCert.Visibility = Visibility.Collapsed; - TextBlockPassword.Visibility = Visibility.Visible; - PasswordBoxHostPassword.IsEnabled = true; - PasswordBoxHostPassword.Visibility = Visibility.Visible; - } - - private void RadioButtonCertLogin_Checked(object sender, RoutedEventArgs e) - { - //TextBlockPassword.Text = "密钥:"; - TextBlockCert.Visibility = Visibility.Visible; - TextBlockPassword.Visibility = Visibility.Collapsed; - PasswordBoxHostPassword.IsEnabled = false; - PasswordBoxHostPassword.Visibility = Visibility.Collapsed; - ButtonOpenFileDialog.IsEnabled = true; - ButtonOpenFileDialog.Visibility = Visibility.Visible; - TextBoxCertFilePath.IsEnabled = true; - TextBoxCertFilePath.Visibility = Visibility.Visible; - } - - private void RadioButtonProxyNoLogin_Checked(object sender, RoutedEventArgs e) - { - TextBlockProxyUser.IsEnabled = false; - TextBlockProxyUser.Visibility = Visibility.Collapsed; - TextBlockProxyPassword.IsEnabled = false; - TextBlockProxyPassword.Visibility = Visibility.Collapsed; - TextBoxProxyUserName.IsEnabled = false; - TextBoxProxyUserName.Visibility = Visibility.Collapsed; - PasswordBoxProxyPassword.IsEnabled = false; - PasswordBoxProxyPassword.Visibility = Visibility.Collapsed; - } - - private void RadiobuttonProxyYesLogin_Checked(object sender, RoutedEventArgs e) - { - TextBlockProxyUser.IsEnabled = true; - TextBlockProxyUser.Visibility = Visibility.Visible; - TextBlockProxyPassword.IsEnabled = true; - TextBlockProxyPassword.Visibility = Visibility.Visible; - TextBoxProxyUserName.IsEnabled = true; - TextBoxProxyUserName.Visibility = Visibility.Visible; - PasswordBoxProxyPassword.IsEnabled = true; - PasswordBoxProxyPassword.Visibility = Visibility.Visible; - } - #endregion - - //远程主机连接信息 - private ConnectionInfo GenerateConnectionInfo() - { - acmeEmail = AcmeEmailTextBox.Text; - - ConnectionInfo connectionInfo; - - if (string.IsNullOrEmpty(acmeEmail)) - { - var acmeEmailDesc = Application.Current.FindResource("AcmeEmailDesc").ToString(); - MessageBox.Show(acmeEmailDesc); - return connectionInfo = null; - } - - #region 检测输入的内容是否有错,并读取内容 - if (string.IsNullOrEmpty(PreTrim(TextBoxHost.Text)) == true || string.IsNullOrEmpty(PreTrim(TextBoxPort.Text)) == true || string.IsNullOrEmpty(PreTrim(TextBoxUserName.Text)) == true) - { - //******"主机地址、主机端口、用户名为必填项,不能为空"****** - MessageBox.Show(Application.Current.FindResource("MessageBoxShow_ErrorHostPortUserNotEmpty").ToString()); - - return connectionInfo = null; - } - string sshHostName = PreTrim(TextBoxHost.Text); - int sshPort = 22; - - if (IsOnlyNumber(PreTrim(TextBoxPort.Text)) == true) - { - TextBoxPort.Text = PreTrim(TextBoxPort.Text); - sshPort = int.Parse(TextBoxPort.Text); - } - else - { - //******"连接端口含有非数字字符!"****** - MessageBox.Show("Host Port" + Application.Current.FindResource("MessageBoxShow_ErrorHostPortErr").ToString()); - return connectionInfo = null; - } - - string sshUser = PreTrim(TextBoxUserName.Text); - - if (RadioButtonPasswordLogin.IsChecked == true && string.IsNullOrEmpty(PasswordBoxHostPassword.Password) == true) - { - //****** "登录密码为必填项,不能为空!!" ****** - MessageBox.Show(Application.Current.FindResource("MessageBoxShow_ErrorHostPasswordNotEmpty").ToString()); - return connectionInfo = null; - } - string sshPassword = PasswordBoxHostPassword.Password.ToString(); - if (RadioButtonCertLogin.IsChecked == true && string.IsNullOrEmpty(TextBoxCertFilePath.Text) == true) - { - //****** "密钥文件为必填项,不能为空!" ****** - MessageBox.Show(Application.Current.FindResource("MessageBoxShow_ErrorHostKeyNotEmpty").ToString()); - return connectionInfo = null; - } - string sshPrivateKey = TextBoxCertFilePath.Text.ToString(); - ProxyTypes proxyTypes = new ProxyTypes();//默认为None - - //proxyTypes = ProxyTypes.Socks5; - if (RadioButtonHttp.IsChecked == true) - { - proxyTypes = ProxyTypes.Http; - } - else if (RadioButtonSocks4.IsChecked == true) - { - proxyTypes = ProxyTypes.Socks4; - } - else if (RadioButtonSocks5.IsChecked == true) - { - proxyTypes = ProxyTypes.Socks5; - } - else - { - proxyTypes = ProxyTypes.None; - } - - //MessageBox.Show(proxyTypes.ToString()); - if (RadioButtonNoProxy.IsChecked == false && (string.IsNullOrEmpty(PreTrim(TextBoxProxyHost.Text)) == true || string.IsNullOrEmpty(PreTrim(TextBoxProxyPort.Text)) == true)) - { - //****** "如果选择了代理,则代理地址与端口不能为空!" ****** - MessageBox.Show(Application.Current.FindResource("MessageBoxShow_ErrorProxyAddressPortNotEmpty").ToString()); - return connectionInfo = null; - } - string sshProxyHost = PreTrim(TextBoxProxyHost.Text); - - int sshProxyPort = 1080; - if (IsOnlyNumber(PreTrim(TextBoxProxyPort.Text)) == true) - { - TextBoxProxyPort.Text = PreTrim(TextBoxProxyPort.Text); - sshProxyPort = int.Parse(TextBoxProxyPort.Text); - } - else - { - //******"连接端口含有非数字字符!"****** - MessageBox.Show("Proxy Port" + Application.Current.FindResource("MessageBoxShow_ErrorHostPortErr").ToString()); - return connectionInfo = null; - } - - if (RadioButtonNoProxy.IsChecked == false && RadiobuttonProxyYesLogin.IsChecked == true && (string.IsNullOrEmpty(PreTrim(TextBoxProxyUserName.Text)) == true || string.IsNullOrEmpty(PasswordBoxProxyPassword.Password) == true)) - { - //****** "如果代理需要登录,则代理登录的用户名与密码不能为空!" ****** - MessageBox.Show(Application.Current.FindResource("MessageBoxShow_ErrorProxyUserPasswordNotEmpty").ToString()); - return connectionInfo = null; - } - string sshProxyUser = PreTrim(TextBoxProxyUserName.Text); - string sshProxyPassword = PasswordBoxProxyPassword.Password; - - #endregion - - - //var connectionInfo = new PasswordConnectionInfo(sshHostName, sshPort, sshUser, sshPassword); - - connectionInfo = new ConnectionInfo( - sshHostName, - sshPort, - sshUser, - proxyTypes, - sshProxyHost, - sshProxyPort, - sshProxyUser, - sshProxyPassword, - new PasswordAuthenticationMethod(sshUser, sshPassword) - //new PrivateKeyAuthenticationMethod(sshUser, new PrivateKeyFile(sshPrivateKey)) - ); - - if (RadioButtonCertLogin.IsChecked == true) - { - connectionInfo = new ConnectionInfo( - sshHostName, - sshPort, - sshUser, - proxyTypes, - sshProxyHost, - sshProxyPort, - sshProxyUser, - sshProxyPassword, - //new PasswordAuthenticationMethod(sshUser, sshPassword) - new PrivateKeyAuthenticationMethod(sshUser, new PrivateKeyFile(sshPrivateKey)) - ); - - } - return connectionInfo; - } - - //登录主机过程中出现的异常处理 - private void ProcessException(string exceptionMessage) - { - //下面代码需要保留,以备将来启用 - //if (exceptionMessage.Contains("连接尝试失败") == true) - //{ - // //****** "请检查主机地址及端口是否正确,如果通过代理,请检查代理是否正常工作!" ****** - // MessageBox.Show($"{exceptionMessage}\n" + - // Application.Current.FindResource("MessageBoxShow_ErrorLoginHostOrPort").ToString()); - //} - - //else if (exceptionMessage.Contains("denied (password)") == true) - //{ - // //****** "密码错误或用户名错误" ****** - // MessageBox.Show($"{exceptionMessage}\n" + - // Application.Current.FindResource("MessageBoxShow_ErrorLoginUserOrPassword").ToString()); - //} - //else if (exceptionMessage.Contains("Invalid private key file") == true) - //{ - // //****** "所选密钥文件错误或者格式不对!" ****** - // MessageBox.Show($"{exceptionMessage}\n" + - // Application.Current.FindResource("MessageBoxShow_ErrorLoginKey").ToString()); - //} - //else if (exceptionMessage.Contains("denied (publickey)") == true) - //{ - // //****** "使用密钥登录,密钥文件错误或用户名错误" ****** - // MessageBox.Show($"{exceptionMessage}\n" + - // Application.Current.FindResource("MessageBoxShow_ErrorLoginKeyOrUser").ToString()); - //} - //else if (exceptionMessage.Contains("目标计算机积极拒绝") == true) - //{ - // //****** "主机地址错误,如果使用了代理,也可能是连接代理的端口错误" ****** - // MessageBox.Show($"{exceptionMessage}\n" + - // Application.Current.FindResource("MessageBoxShow_ErrorLoginHostOrProxyPort").ToString()); - //} - //else - //{ - //****** "发生错误" ****** - MessageBox.Show(Application.Current.FindResource("MessageBoxShow_ErrorLoginOccurred").ToString()); - MessageBox.Show(exceptionMessage); - //} - - } - - - #region V2Ray相关 - - //打开v2ray模板设置窗口 - private void ButtonTemplateConfiguration_Click(object sender, RoutedEventArgs e) - { - //清空初始化模板参数 - for (int i = 0; i != ReceiveConfigurationParameters.Length; i++) - - { - 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(); - - GridV2rayCurrentlyPlan.Visibility = Visibility.Hidden; - - return; - } - else - { - GridV2rayCurrentlyPlan.Visibility = Visibility.Visible; - } - TextBlockCurrentlySelectedPlan.Text = ReceiveConfigurationParameters[8]; //所选方案名称 - TextBlockCurrentlySelectedPlanPort.Text = ReceiveConfigurationParameters[1]; //服务器端口 - TextBlockCurrentlySelectedPlanUUID.Text = ReceiveConfigurationParameters[2]; //UUID - TextBlockCurrentlySelectedPlanPathSeedKey.Text = ReceiveConfigurationParameters[6]; //mKCP Seed\Quic Key\Path - //MessageBox.Show(ReceiveConfigurationParameters[7]); - TextBlockCurrentlySelectedPlanFakeWebsite.Text = ReceiveConfigurationParameters[7]; //伪装网站 - - if (String.Equals(ReceiveConfigurationParameters[0], "TCP") == true - || String.Equals(ReceiveConfigurationParameters[0], "TCPhttp") == true - || String.Equals(ReceiveConfigurationParameters[0], "tcpTLSselfSigned") == true - || String.Equals(ReceiveConfigurationParameters[0], "webSocket") == true) - { - //隐藏Path/mKCP Seed/Quic Key - HideV2RayPathSeedKey(); - HideVlessVmessXtlsTcpWs(); - - //隐藏域名/Quic加密方式 - HideV2RayDomainQuicEncrypt(); - - //隐藏伪装网站 - HideV2RayMaskSites(); - - } - else if (String.Equals(ReceiveConfigurationParameters[0], "tcpTLS") == true) - { - //隐藏Path/mKCP Seed/Quic Key - HideV2RayPathSeedKey(); - HideVlessVmessXtlsTcpWs(); - - //显示域名 - ShowV2RayDomainQuicEncrypt(); - - //隐藏伪装网站 - HideV2RayMaskSites(); - } - else if (String.Equals(ReceiveConfigurationParameters[0], "VlessVmessXtlsTcpWebSocketWeb") == true) - { - //显示复合方案路径 - ShowVlessVmessXtlsTcpWs(); - - //显示域名 - ShowV2RayDomainQuicEncrypt(); - - //显示伪装网站(暂时不显示) - ShowV2RayMaskSites(); - - } - else if (String.Equals(ReceiveConfigurationParameters[0], "VlessTcpTlsWeb") == true - || String.Equals(ReceiveConfigurationParameters[0], "VlessXtlsTcp") == true) - { - //隐藏Path/mKCP Seed/Quic Key - HideV2RayPathSeedKey(); - HideVlessVmessXtlsTcpWs(); - - //显示域名 - ShowV2RayDomainQuicEncrypt(); - - //显示伪装网站(暂时不显示) - ShowV2RayMaskSites(); - } - else if (String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLS") == true - || String.Equals(ReceiveConfigurationParameters[0], "Http2") == true) - { - //显示Path - ShowV2RayPathSeedKey(); - TextBlockV2RayShowPathSeedKey.Text = "Path:"; - TextBlockCurrentlySelectedPlanPathSeedKey.Text = ReceiveConfigurationParameters[6]; //mKCP Seed\Quic Key\Path - - - //显示域名 - ShowV2RayDomainQuicEncrypt(); - - //显示伪装网站(暂时不显示) - HideV2RayMaskSites(); - } - else if (String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLS2Web") == true - || String.Equals(ReceiveConfigurationParameters[0], "http2Web") == true - || String.Equals(ReceiveConfigurationParameters[0], "VlessWebSocketTlsWeb") == true - || String.Equals(ReceiveConfigurationParameters[0], "VlessHttp2Web") == true) - { - //显示Path - ShowV2RayPathSeedKey(); - TextBlockV2RayShowPathSeedKey.Text = "Path:"; - TextBlockCurrentlySelectedPlanPathSeedKey.Text = ReceiveConfigurationParameters[6]; //mKCP Seed\Quic Key\Path - - //显示域名 - ShowV2RayDomainQuicEncrypt(); - - //显示伪装网站(暂时不显示) - ShowV2RayMaskSites(); - } - else if (String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLSselfSigned") == true - || String.Equals(ReceiveConfigurationParameters[0], "http2selfSigned") == true) - { - //显示Path - ShowV2RayPathSeedKey(); - TextBlockV2RayShowPathSeedKey.Text = "Path:"; - TextBlockCurrentlySelectedPlanPathSeedKey.Text = ReceiveConfigurationParameters[6]; //mKCP Seed\Quic Key\Path - - //隐藏域名/Quic加密方式 - HideV2RayDomainQuicEncrypt(); - - //隐藏伪装网站 - HideV2RayMaskSites(); - } - else if (ReceiveConfigurationParameters[0].Contains("mKCP") == true) - { - //显示mKCP Seed - ShowV2RayPathSeedKey(); - TextBlockV2RayShowPathSeedKey.Text = "mKCP Seed:"; - TextBlockCurrentlySelectedPlanPathSeedKey.Text = ReceiveConfigurationParameters[6]; //mKCP Seed\Quic Key\Path - - //隐藏域名/Quic加密方式 - HideV2RayDomainQuicEncrypt(); - - //隐藏伪装网站 - HideV2RayMaskSites(); - } - else if (ReceiveConfigurationParameters[0].Contains("Quic") == true) - { - //显示QUIC Key - ShowV2RayPathSeedKey(); - TextBlockV2RayShowPathSeedKey.Text = "QUIC Key:"; - TextBlockCurrentlySelectedPlanPathSeedKey.Text = ReceiveConfigurationParameters[6]; //mKCP Seed\Quic Key\Path - - //显示Quic加密方式 - ShowV2RayDomainQuicEncrypt(); - TextBlockV2RayShowCurrentlySelectedPlanDomain.Text = Application.Current.FindResource("TextBlockQuicEncryption").ToString(); - TextBlockCurrentlySelectedPlanDomain.Text = ReceiveConfigurationParameters[3]; //Quic加密方式 - if (String.Equals(TextBlockCurrentlySelectedPlanDomain.Text, "none") == true) - { - HideV2RayPathSeedKey(); - } - - - //隐藏伪装网站 - HideV2RayMaskSites(); - } - } - - #region 当前方案界面控制 - //显示端口与UUID - private void ShowV2RayCurrentPortUUID() - { - TextBlockV2RayShowPort.Visibility = Visibility.Visible; - TextBlockCurrentlySelectedPlanPort.Visibility = Visibility.Visible; - - TextBlockV2RayShowUUID.Visibility = Visibility.Visible; - TextBlockCurrentlySelectedPlanUUID.Visibility = Visibility.Visible; - } - - //显示Path/mKCP Seed/Quic Key - private void ShowV2RayPathSeedKey() - { - HideVlessVmessXtlsTcpWs(); - TextBlockV2RayShowPathSeedKey.Visibility = Visibility.Visible; - TextBlockCurrentlySelectedPlanPathSeedKey.Visibility = Visibility.Visible; - } - - //隐藏Path/mKCP Seed/Quic Key - private void HideV2RayPathSeedKey() - { - TextBlockV2RayShowPathSeedKey.Visibility = Visibility.Hidden; - TextBlockCurrentlySelectedPlanPathSeedKey.Visibility = Visibility.Hidden; - } - - //显示VLESS VMESS XTLS TCP WS 复合方案 - private void ShowVlessVmessXtlsTcpWs() - { - HideV2RayPathSeedKey(); - GridVlessVmessXtlsTcpWs.Visibility = Visibility.Visible; - TextBlockBoxPathVlessWS.Text = ReceiveConfigurationParameters[3]; - TextBlockBoxPathVmessTcp.Text = ReceiveConfigurationParameters[9]; - TextBlockBoxPathVmessWS.Text = ReceiveConfigurationParameters[6]; - } - - //隐藏VLESS VMESS XTLS TCP WS 复合方案 - private void HideVlessVmessXtlsTcpWs() - { - GridVlessVmessXtlsTcpWs.Visibility = Visibility.Collapsed; - } - - //显示域名/Quic加密方式 - private void ShowV2RayDomainQuicEncrypt() - { - TextBlockV2RayShowCurrentlySelectedPlanDomain.Visibility = Visibility.Visible; - TextBlockCurrentlySelectedPlanDomain.Visibility = Visibility.Visible; - TextBlockV2RayShowCurrentlySelectedPlanDomain.Text = Application.Current.FindResource("TextBlockV2RayDomain").ToString(); - TextBlockCurrentlySelectedPlanDomain.Text = ReceiveConfigurationParameters[4]; //域名 - - } - - //隐藏域名/Quic加密方式 - private void HideV2RayDomainQuicEncrypt() - { - TextBlockV2RayShowCurrentlySelectedPlanDomain.Visibility = Visibility.Hidden; - TextBlockCurrentlySelectedPlanDomain.Visibility = Visibility.Hidden; - } - //显示伪装网站 - private void ShowV2RayMaskSites() - { - TextBlockV2RayShowCurrentlySelectedPlanFakeWebsite.Visibility = Visibility.Visible; - TextBlockCurrentlySelectedPlanFakeWebsite.Visibility = Visibility.Visible; - } - - //隐藏伪装网站 - private void HideV2RayMaskSites() - { - TextBlockV2RayShowCurrentlySelectedPlanFakeWebsite.Visibility = Visibility.Hidden; - TextBlockCurrentlySelectedPlanFakeWebsite.Visibility = Visibility.Hidden; - } - #endregion - - //传送V2Ray模板参数,启动V2Ray安装进程 - private void Button_Login_Click(object sender, RoutedEventArgs e) - - { - ConnectionInfo connectionInfo = GenerateConnectionInfo(); - if (connectionInfo == null) - { - //****** "远程主机连接信息有误,请检查!" ****** - MessageBox.Show(Application.Current.FindResource("MessageBoxShow_ErrorHostConnection").ToString()); - return; - } - - - //生成客户端配置时,连接的服务主机的IP或者域名 - if (String.IsNullOrEmpty(ReceiveConfigurationParameters[4]) == true) - { - ReceiveConfigurationParameters[4] = PreTrim(TextBoxHost.Text); - testDomain = false; - } - //选择模板 - if (String.IsNullOrEmpty(ReceiveConfigurationParameters[0]) == true) - { - //******"请先选择配置模板!"****** - MessageBox.Show(Application.Current.FindResource("MessageBoxShow_ChooseTemplate").ToString()); - return; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "TCP") == true - || String.Equals(ReceiveConfigurationParameters[0], "TCPhttp") == true - || String.Equals(ReceiveConfigurationParameters[0], "tcpTLSselfSigned") == true - || String.Equals(ReceiveConfigurationParameters[0], "webSocket") == true - || String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLSselfSigned") == true - || String.Equals(ReceiveConfigurationParameters[0], "http2selfSigned") == true - || ReceiveConfigurationParameters[0].Contains("mKCP") == true - || ReceiveConfigurationParameters[0].Contains("Quic") == true) - { - testDomain = false; - - } - else if (String.Equals(ReceiveConfigurationParameters[0], "tcpTLS") == true - || String.Equals(ReceiveConfigurationParameters[0], "VlessXtlsTcp") == true - || String.Equals(ReceiveConfigurationParameters[0], "VlessTcpTlsWeb") == true - || String.Equals(ReceiveConfigurationParameters[0], "VlessWebSocketTlsWeb") == true - || String.Equals(ReceiveConfigurationParameters[0], "VlessHttp2Web") == true - || String.Equals(ReceiveConfigurationParameters[0], "VlessVmessXtlsTcpWebSocketWeb") == true - || String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLS2Web") == true - || String.Equals(ReceiveConfigurationParameters[0], "Http2") == true - || String.Equals(ReceiveConfigurationParameters[0], "http2Web") == true) - { - testDomain = true; - - } - - - //Thread thread - //SetUpProgressBarProcessing(0); //重置安装进度 - installationDegree = 0; - TextBoxMonitorCommandResults.Text = ""; - //Thread thread = new Thread(() => StartSetUpV2ray(connectionInfo, TextBlockSetUpProcessing, ProgressBarSetUpProcessing)); - Thread thread = new Thread(() => StartSetUpV2ray(connectionInfo)); - - thread.SetApartmentState(ApartmentState.STA); - thread.Start(); - - - } - - //登录远程主机布署V2ray程序 - private void StartSetUpV2ray(ConnectionInfo connectionInfo) - { - functionResult = true; - onlyIpv6 = false; - getApt = false; - getDnf = false; - getYum = false; - - //******"正在登录远程主机......"****** - SetUpProgressBarProcessing(1); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_Login").ToString(); - MainWindowsShowInfo(currentStatus); - - try - { - #region 主机指纹,暂未启用 - //byte[] expectedFingerPrint = new byte[] { - // 0x66, 0x31, 0xaf, 0x00, 0x54, 0xb9, 0x87, 0x31, - // 0xff, 0x58, 0x1c, 0x31, 0xb1, 0xa2, 0x4c, 0x6b - // }; - #endregion - using (var client = new SshClient(connectionInfo)) - { - #region ssh登录验证主机指纹代码块,暂未启用 - // client.HostKeyReceived += (sender, e) => - // { - // if (expectedFingerPrint.Length == e.FingerPrint.Length) - // { - // for (var i = 0; i < expectedFingerPrint.Length; i++) - // { - // if (expectedFingerPrint[i] != e.FingerPrint[i]) - // { - // e.CanTrust = false; - // break; - // } - // } - // } - // else - // { - // e.CanTrust = false; - // } - // }; - #endregion - - client.Connect(); - if (client.IsConnected == true) - { - //******"主机登录成功"****** - SetUpProgressBarProcessing(3); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_LoginSuccessful").ToString(); - MainWindowsShowInfo(currentStatus); - //Thread.Sleep(3000); - } - - //检测root权限 5--7 - functionResult = RootAuthorityDetect(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //检测是否已安装代理 8--10 - functionResult = SoftInstalledIsNoYes(client, "v2ray", @"/usr/local/bin/v2ray"); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //检测系统是否符合安装要求 11--30 - //检测关闭Selinux及系统组件是否齐全(apt-get/yum/dnf/systemctl) - //安装依赖软件,检测端口,防火墙开启端口 - functionResult = ShutDownSelinuxAndSysComponentsDetect(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //检测校对时间 31--33 - functionResult = CheckProofreadingTime(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //检测域名解析是否正确 34---36 - if (testDomain == true) - { - functionResult = DomainResolutionCurrentIPDetect(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - } - - //下载安装脚本安装 37--40 - functionResult = ProxySoftInstall(client, @"V2Ray", @"https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh"); - //functionResult = ProxySoftInstallV2ray(client, @"V2Ray", @"https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh"); - - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - //functionResult = V2RayInstallScript(client); - //if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //程序是否安装成功检测 41--43 - functionResult = SoftInstalledSuccessOrFail(client, "v2ray", @"/usr/local/bin/v2ray"); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //生成服务端配置 44--46 - functionResult = GenerateServerConfigurationV2Ray(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //****** "上传配置文件......" ****** 47--50 - currentStatus = Application.Current.FindResource("DisplayInstallInfo_UploadSoftConfig").ToString(); - MainWindowsShowInfo(currentStatus); - string serverRemoteConfig = @"/usr/local/etc/v2ray/config.json"; - UploadConfig(connectionInfo, @"config.json", serverRemoteConfig); - File.Delete(@"config.json"); - SetUpProgressBarProcessing(50); - - //如果使用http2/WebSocketTLS/tcpTLS/VlessTcpTlsWeb/VLESS+TCP+XTLS+Web模式,先要安装acme.sh,申请证书 - if (String.Equals(ReceiveConfigurationParameters[0], "Http2") == true - || String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLS") == true - || String.Equals(ReceiveConfigurationParameters[0], "tcpTLS") == true - || String.Equals(ReceiveConfigurationParameters[0], "VlessXtlsTcp") == true - || String.Equals(ReceiveConfigurationParameters[0], "VlessTcpTlsWeb") == true - || String.Equals(ReceiveConfigurationParameters[0], "VlessVmessXtlsTcpWebSocketWeb") == true) - { - //安装acme.sh与申请证书 51--57 - functionResult = AcmeShInstall(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //安装证书到V2Ray 58--60 - functionResult = CertInstallToV2ray(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - } - - - #region Caddy安装 61--70 - - //如果是VLESS+TCP+XTLS+Web/VLESS+TCP+TLS+Web/VLESS+WebSocket+TLS+Web/VLESS+http2+TLS+Web/WebSocket+TLS+Web/http2Web模式,需要安装Caddy - if (String.Equals(ReceiveConfigurationParameters[0], "VlessXtlsTcp") == true - || String.Equals(ReceiveConfigurationParameters[0], "VlessTcpTlsWeb") == true - || String.Equals(ReceiveConfigurationParameters[0], "VlessWebSocketTlsWeb") == true - || String.Equals(ReceiveConfigurationParameters[0], "VlessHttp2Web") == true - || String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLS2Web") == true - || String.Equals(ReceiveConfigurationParameters[0], "http2Web") == true - || String.Equals(ReceiveConfigurationParameters[0], "VlessVmessXtlsTcpWebSocketWeb") == true) - { - //安装Caddy 61--66 - functionResult = CaddyInstall(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - - #region 上传Caddy配置文件 67--70 - - //******"上传Caddy配置文件"****** - SetUpProgressBarProcessing(67); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_UploadCaddyConfig").ToString(); - MainWindowsShowInfo(currentStatus); - - string serverConfig = ""; - sshShellCommand = @"mv /etc/caddy/Caddyfile /etc/caddy/Caddyfile.bak"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - if (String.Equals(ReceiveConfigurationParameters[0], "VlessXtlsTcp") == true - || String.Equals(ReceiveConfigurationParameters[0], "VlessTcpTlsWeb") == true - || String.Equals(ReceiveConfigurationParameters[0], "VlessVmessXtlsTcpWebSocketWeb") == true) - { - serverConfig = $"{pwdir}" + @"TemplateConfg\v2ray\caddy\vlessTcpTlsWeb.caddyfile"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "VlessWebSocketTlsWeb") == true - || String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLS2Web") == true) - { - serverConfig = $"{pwdir}" + @"TemplateConfg\v2ray\caddy\WebSocketTLSWeb.caddyfile"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "VlessHttp2Web") == true - || String.Equals(ReceiveConfigurationParameters[0], "http2Web") == true) - { - serverConfig = $"{pwdir}" + @"TemplateConfg\v2ray\caddy\Http2Web.caddyfile"; - } - - string upLoadPath = "/etc/caddy/Caddyfile"; - client.RunCommand("mv /etc/caddy/Caddyfile /etc/caddy/Caddyfile.bak"); - UploadConfig(connectionInfo, serverConfig, upLoadPath); - - functionResult = FileCheckExists(client, @"/etc/caddy/Caddyfile"); - if (functionResult == false) - { - //****** "Caddy配置文件上传失败!" ******32 - currentStatus = Application.Current.FindResource("DisplayInstallInfo_UploadCaddyConfigFailed").ToString(); - MainWindowsShowInfo(currentStatus); - FunctionResultErr(); - client.Disconnect(); - return; - } - - //****** "Caddy配置文件上传成功,OK!" ******32 - SetUpProgressBarProcessing(70); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_UploadCaddyConfigOK").ToString(); - MainWindowsShowInfo(currentStatus); - - //设置Caddy配置文件 - functionResult = SetCaddyfile(client, upLoadPath); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - - #endregion - - //启动Caddy服务 - functionResult = SoftStartDetect(client, "caddy", @"/usr/bin/caddy"); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - } - #endregion - - //****** "正在启动V2ray......" ******35 - functionResult = SoftStartDetect(client, "v2ray", @"/usr/local/bin/v2ray"); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //测试BBR条件,若满足提示是否启用 - functionResult = DetectBBRandEnable(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - client.Disconnect();//断开服务器ssh连接 - - //生成客户端配置 96--98 - functionResult = GenerateClientConfigurationV2Ray(); - - //****** "V2Ray安装成功,祝你玩的愉快!!" ******40 - SetUpProgressBarProcessing(100); - currentStatus = "V2Ray" + Application.Current.FindResource("DisplayInstallInfo_ProxyInstalledOK").ToString(); - MainWindowsShowInfo(currentStatus); - - Thread.Sleep(1000); - - //显示服务端连接参数 - proxyType = "V2Ray"; - ResultClientInformation resultClientInformation = new ResultClientInformation(); - resultClientInformation.ShowDialog(); - - return; - - } - } - catch (Exception ex1)//例外处理 - { - ProcessException(ex1.Message); - - //****** "安装失败!" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_LoginFailed").ToString(); - MainWindowsShowInfo(currentStatus); - } - } - - #region V2Ray专用调用函数 - //安装代理程序 37--40 - //functionResult = ProxySoftInstall(client,@"",@""); - //if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - private bool ProxySoftInstallV2ray(SshClient client, string proxyName, string downloadUrl) - { - //****** "系统环境检测完毕,符合安装要求,开始布署......" ****** - SetUpProgressBarProcessing(37); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_StartInstalling").ToString(); - MainWindowsShowInfo(currentStatus); - - //****** "正在安装{proxyName}......" ****** - SetUpProgressBarProcessing(38); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_StartInstallSoft").ToString() + $"{proxyName}......"; - MainWindowsShowInfo(currentStatus); - - saveShellScriptFileName = GenerateRandomScriptFileName(GenerateRandomStr(10)); - - sshShellCommand = $"curl -o {saveShellScriptFileName} {downloadUrl}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - functionResult = FileCheckExists(client, $"{saveShellScriptFileName}"); - if (functionResult == false) - { - //***文件下载失败!*** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_DownloadScriptFailed").ToString(); - MainWindowsShowInfo(currentStatus); - return false; - - } - sshShellCommand = $"yes | bash {saveShellScriptFileName} --version v4.32.1"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = $"rm -f {saveShellScriptFileName}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - SetUpProgressBarProcessing(40); - return true; - } - - - //生成V2Ray服务端配置 44--46 - //functionResult = GenerateServerConfiguration(client); - //if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - private bool GenerateServerConfigurationV2Ray(SshClient client) - { - SetUpProgressBarProcessing(44); - //修改v2ray.service - - sshShellCommand = $"sed -i 's/User=nobody/User=root/g' /etc/systemd/system/v2ray.service"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = $"sed -i 's/CapabilityBoundingSet=/#CapabilityBoundingSet=/g' /etc/systemd/system/v2ray.service"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = $"sed -i 's/AmbientCapabilities=/#AmbientCapabilities=/g' /etc/systemd/system/v2ray.service"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = $"systemctl daemon-reload"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //备用下载地址:https://raw.githubusercontent.com/proxysu/Resources/master/v2ray/v2ray.service - - //sshShellCommand = $"yes | curl -o /etc/systemd/system/v2ray.service https://raw.githubusercontent.com/proxysu/Resources/master/v2ray/v2ray.service"; - //currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //备份原来的文件 - functionResult = FileCheckExists(client, @"/usr/local/etc/v2ray/config.json"); - if (functionResult == true) - { - - sshShellCommand = @"mv /usr/local/etc/v2ray/config.json /usr/local/etc/v2ray/config.json.1"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - } - //读取配置文件各个模块 - string logConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\server\00_log\00_log.json"; - string apiConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\server\01_api\01_api.json"; - string dnsConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\server\02_dns\02_dns.json"; - string routingConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\server\03_routing\03_routing.json"; - string policyConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\server\04_policy\04_policy.json"; - string inboundsConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\server\05_inbounds\05_inbounds.json"; - string outboundsConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\server\06_outbounds\06_outbounds.json"; - string transportConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\server\07_transport\07_transport.json"; - string statsConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\server\08_stats\08_stats.json"; - string reverseConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\server\09_reverse\09_reverse.json"; - string baseConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\base.json"; - - //配置文件模块合成 - using (StreamReader reader = File.OpenText(baseConfigJson)) - { - JObject serverJson = (JObject)JToken.ReadFrom(new JsonTextReader(reader)); - //读取"log" - using (StreamReader readerJson = File.OpenText(logConfigJson)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - serverJson["log"] = jObjectJson["log"]; - } - //读取"api" - using (StreamReader readerJson = File.OpenText(apiConfigJson)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - serverJson["api"] = jObjectJson["api"]; - } - //读取"dns" - using (StreamReader readerJson = File.OpenText(dnsConfigJson)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - serverJson["dns"] = jObjectJson["dns"]; - } - //读取"routing" - using (StreamReader readerJson = File.OpenText(routingConfigJson)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - serverJson["routing"] = jObjectJson["routing"]; - } - //读取"policy" - using (StreamReader readerJson = File.OpenText(policyConfigJson)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - serverJson["policy"] = jObjectJson["policy"]; - } - //读取"inbounds" - using (StreamReader readerJson = File.OpenText(inboundsConfigJson)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - serverJson["inbounds"] = jObjectJson["inbounds"]; - } - //读取"outbounds" - using (StreamReader readerJson = File.OpenText(outboundsConfigJson)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - serverJson["outbounds"] = jObjectJson["outbounds"]; - } - //读取"transport" - using (StreamReader readerJson = File.OpenText(transportConfigJson)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - serverJson["transport"] = jObjectJson["transport"]; - } - //读取"stats" - using (StreamReader readerJson = File.OpenText(statsConfigJson)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - serverJson["stats"] = jObjectJson["stats"]; - } - //读取"reverse" - using (StreamReader readerJson = File.OpenText(reverseConfigJson)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - serverJson["reverse"] = jObjectJson["reverse"]; - } - - //依据安装模式读取相应模板 - if (String.Equals(ReceiveConfigurationParameters[0], "TCP") == true) - { - inboundsConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\server\05_inbounds\tcp_server_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "TCPhttp") == true) - { - inboundsConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\server\05_inbounds\tcp_http_server_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "tcpTLS") == true) - { - inboundsConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\server\05_inbounds\tcp_TLS_server_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "tcpTLSselfSigned") == true) - { - inboundsConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\server\05_inbounds\tcpTLSselfSigned_server_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "VlessXtlsTcp") == true) - { - inboundsConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\server\05_inbounds\vless_tcp_xtls_server_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "VlessTcpTlsWeb") == true) - { - inboundsConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\server\05_inbounds\vless_tcp_tls_server_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "VlessWebSocketTlsWeb") == true) - { - inboundsConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\server\05_inbounds\vless_ws_tls_server_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "VlessHttp2Web") == true) - { - inboundsConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\server\05_inbounds\vless_http2_tls_server_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "VlessVmessXtlsTcpWebSocketWeb") == true) - { - inboundsConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\server\05_inbounds\vless_vmess_xtls_tcp_websocket_server_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "webSocket") == true) - { - inboundsConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\server\05_inbounds\webSocket_server_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLS") == true) - { - inboundsConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\server\05_inbounds\WebSocket_TLS_server_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLSselfSigned") == true) - { - inboundsConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\server\05_inbounds\WebSocketTLS_selfSigned_server_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLS2Web") == true) - { - inboundsConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\server\05_inbounds\WebSocketTLSWeb_server_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "Http2") == true) - { - inboundsConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\server\05_inbounds\http2_server_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "http2Web") == true) - { - inboundsConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\server\05_inbounds\Http2Web_server_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "http2selfSigned") == true) - { - inboundsConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\server\Http2selfSigned_server_config.json"; - } - //else if (String.Equals(ReceiveConfigurationParameters[0], "MkcpNone")|| String.Equals(ReceiveConfigurationParameters[0], "mKCP2SRTP")||String.Equals(ReceiveConfigurationParameters[0], "mKCPuTP")|| String.Equals(ReceiveConfigurationParameters[0], "mKCP2WechatVideo")|| String.Equals(ReceiveConfigurationParameters[0], "mKCP2DTLS")|| String.Equals(ReceiveConfigurationParameters[0], "mKCP2WireGuard")) - else if (ReceiveConfigurationParameters[0].Contains("mKCP") == true) - { - if (mKCPvlessIsSet == true) - { - inboundsConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\server\05_inbounds\vless_mkcp_server_config.json"; - } - else - { - inboundsConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\server\05_inbounds\mkcp_server_config.json"; - } - - } - - // else if (String.Equals(ReceiveConfigurationParameters[0], "QuicNone") || String.Equals(ReceiveConfigurationParameters[0], "QuicSRTP") || String.Equals(ReceiveConfigurationParameters[0], "Quic2uTP") || String.Equals(ReceiveConfigurationParameters[0], "QuicWechatVideo") || String.Equals(ReceiveConfigurationParameters[0], "QuicDTLS") || String.Equals(ReceiveConfigurationParameters[0], "QuicWireGuard")) - else if (ReceiveConfigurationParameters[0].Contains("Quic") == true) - { - inboundsConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\server\05_inbounds\quic_server_config.json"; - } - - //读取"inbounds" - using (StreamReader readerJson = File.OpenText(inboundsConfigJson)) - { - JObject jObjectJsonTmp = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - var jObjectJson = (dynamic)jObjectJsonTmp; - - //Padavan路由固件服务端设置(因为客户端分流有问题所以在服务端弥补)加上后会影响一定的速度 - - //string sniffingAddServer = $"{pwdir}" + @"TemplateConfg\v2ray\server\05_inbounds\00_padavan_router.json"; - //using (StreamReader readerSniffingJson = File.OpenText(sniffingAddServer)) - //{ - // JObject jObjectSniffingJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerSniffingJson)); - // jObjectJson["inbounds"][0]["sniffing"] = jObjectSniffingJson["sniffing"]; - //} - - //设置uuid - jObjectJson["inbounds"][0]["settings"]["clients"][0]["id"] = ReceiveConfigurationParameters[2]; - - //除WebSocketTLSWeb/http2Web/VLESS+WebSocket+TLS+Web/VLESS+http2+TLS+Web模式外设置监听端口 - if (String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLS2Web") == false - && String.Equals(ReceiveConfigurationParameters[0], "http2Web") == false - && String.Equals(ReceiveConfigurationParameters[0], "VlessWebSocketTlsWeb") == false - && String.Equals(ReceiveConfigurationParameters[0], "VlessHttp2Web") == false) - { - jObjectJson["inbounds"][0]["port"] = int.Parse(ReceiveConfigurationParameters[1]); - } - - //设置VLESS协议的回落端口,指向Caddy - if (String.Equals(ReceiveConfigurationParameters[0], "VlessTcpTlsWeb") == true - || String.Equals(ReceiveConfigurationParameters[0], "VlessXtlsTcp") == true) - { - //设置Caddy随机监听的端口 - randomCaddyListenPort = GetRandomPort(); - - //指向Caddy监听的随机端口 - jObjectJson["inbounds"][0]["settings"]["fallbacks"][0]["dest"] = randomCaddyListenPort; - } - //设置VLESS+VMESS+Trojan+XTLS+TCP+WebSocket+Web协议 - if (String.Equals(ReceiveConfigurationParameters[0], "VlessVmessXtlsTcpWebSocketWeb") == true) - { - //设置Caddy随机监听的端口 - randomCaddyListenPort = GetRandomPort(); - - //指向Caddy监听的随机端口 - jObjectJson["inbounds"][1]["settings"]["fallbacks"][0]["dest"] = randomCaddyListenPort; - //设置其他模式的UUID - jObjectJson["inbounds"][1]["settings"]["clients"][0]["password"] = ReceiveConfigurationParameters[2]; - jObjectJson["inbounds"][2]["settings"]["clients"][0]["id"] = ReceiveConfigurationParameters[2]; - jObjectJson["inbounds"][3]["settings"]["clients"][0]["id"] = ReceiveConfigurationParameters[2]; - jObjectJson["inbounds"][4]["settings"]["clients"][0]["id"] = ReceiveConfigurationParameters[2]; - - //设置Vless回落与分流的Path - jObjectJson["inbounds"][0]["settings"]["fallbacks"][1]["path"] = ReceiveConfigurationParameters[3]; - jObjectJson["inbounds"][0]["settings"]["fallbacks"][2]["path"] = ReceiveConfigurationParameters[9]; - jObjectJson["inbounds"][0]["settings"]["fallbacks"][3]["path"] = ReceiveConfigurationParameters[6]; - - //设置Vless ws Path - jObjectJson["inbounds"][2]["streamSettings"]["wsSettings"]["path"] = ReceiveConfigurationParameters[3]; - //设置Vmess tcp Path - jObjectJson["inbounds"][3]["streamSettings"]["tcpSettings"]["header"]["request"]["path"][0] = ReceiveConfigurationParameters[9]; - //设置Vmess ws Path - jObjectJson["inbounds"][4]["streamSettings"]["wsSettings"]["path"] = ReceiveConfigurationParameters[6]; - - } - - //TLS自签证书/WebSocketTLS(自签证书)/http2自签证书模式下,使用v2ctl 生成自签证书 - if (String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLSselfSigned") == true - || String.Equals(ReceiveConfigurationParameters[0], "tcpTLSselfSigned") == true - || String.Equals(ReceiveConfigurationParameters[0], "http2selfSigned") == true) - { - string selfSignedCa = client.RunCommand("/usr/local/bin/v2ctl cert --ca").Result; - JObject selfSignedCaJObject = JObject.Parse(selfSignedCa); - jObjectJson["inbounds"][0]["streamSettings"]["tlsSettings"]["certificates"][0] = selfSignedCaJObject; - } - - //如果是WebSocketTLSWeb/WebSocketTLS/WebSocketTLS(自签证书)/VLESS+WebSocket+TLS+Web模式,则设置路径 - if (String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLS") == true - || String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLSselfSigned") == true - || String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLS2Web") == true - || String.Equals(ReceiveConfigurationParameters[0], "VlessWebSocketTlsWeb") == true) - { - jObjectJson["inbounds"][0]["streamSettings"]["wsSettings"]["path"] = ReceiveConfigurationParameters[6]; - } - - //如果是Http2/http2Web/http2自签/VLESS+http2+TLS+Web模式下,设置路径 - if (String.Equals(ReceiveConfigurationParameters[0], "Http2") == true - || String.Equals(ReceiveConfigurationParameters[0], "http2Web") == true - || String.Equals(ReceiveConfigurationParameters[0], "http2selfSigned") == true - || String.Equals(ReceiveConfigurationParameters[0], "VlessHttp2Web") == true) - { - jObjectJson["inbounds"][0]["streamSettings"]["httpSettings"]["path"] = ReceiveConfigurationParameters[6]; - } - - //如果是Http2+Web/VLESS+http2+TLS+Web模式下,设置host - if (String.Equals(ReceiveConfigurationParameters[0], "http2Web") == true - || String.Equals(ReceiveConfigurationParameters[0], "VlessHttp2Web") == true) - { - jObjectJson["inbounds"][0]["streamSettings"]["httpSettings"]["host"][0] = ReceiveConfigurationParameters[4]; - } - - //mkcp模式下,设置伪装类型 - if (ReceiveConfigurationParameters[0].Contains("mKCP") == true) - { - jObjectJson["inbounds"][0]["streamSettings"]["kcpSettings"]["header"]["type"] = ReceiveConfigurationParameters[5]; - if (String.IsNullOrEmpty(ReceiveConfigurationParameters[6]) == false) - { - jObjectJson["inbounds"][0]["streamSettings"]["kcpSettings"]["seed"] = ReceiveConfigurationParameters[6]; - } - } - - //quic模式下设置伪装类型及密钥 - if (ReceiveConfigurationParameters[0].Contains("Quic") == true) - { - jObjectJson["inbounds"][0]["streamSettings"]["quicSettings"]["header"]["type"] = ReceiveConfigurationParameters[5]; - jObjectJson["inbounds"][0]["streamSettings"]["quicSettings"]["security"] = ReceiveConfigurationParameters[3]; - - if (String.Equals(ReceiveConfigurationParameters[3], "none") == true) - { - ReceiveConfigurationParameters[6] = ""; - } - jObjectJson["inbounds"][0]["streamSettings"]["quicSettings"]["key"] = ReceiveConfigurationParameters[6]; - } - - serverJson["inbounds"] = jObjectJson["inbounds"]; - } - - using (StreamWriter sw = new StreamWriter(@"config.json")) - { - sw.Write(serverJson.ToString()); - } - } - SetUpProgressBarProcessing(46); - return true; - } - - //安装证书到V2Ray 58--60 - //functionResult = CertInstallToV2ray(client); - //if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - private bool CertInstallToV2ray(SshClient client) - { - //****** "安装证书到V2ray......" ******26 - SetUpProgressBarProcessing(58); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_IntallCertToSoft").ToString() + "V2ray......"; - MainWindowsShowInfo(currentStatus); - - sshShellCommand = @"mkdir -p /usr/local/etc/v2ray/ssl"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = $"/root/.acme.sh/acme.sh --installcert -d {ReceiveConfigurationParameters[4]} --certpath /usr/local/etc/v2ray/ssl/v2ray_ssl.crt --keypath /usr/local/etc/v2ray/ssl/v2ray_ssl.key --capath /usr/local/etc/v2ray/ssl/v2ray_ssl.crt --reloadcmd \"systemctl restart v2ray\""; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"if [ ! -f ""/usr/local/etc/v2ray/ssl/v2ray_ssl.key"" ]; then echo ""0""; else echo ""1""; fi | head -n 1"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - if (currentShellCommandResult.Contains("1") == true) - { - //****** "证书成功安装到V2ray!" ******27 - SetUpProgressBarProcessing(60); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_IntallCertToSoftOK").ToString() + "V2Ray!"; - MainWindowsShowInfo(currentStatus); - } - else - { - //****** "证书安装到V2ray失败,原因未知,可以向开发者提问!" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_IntallCertToSoftFail").ToString() + - "V2Ray" + - Application.Current.FindResource("DisplayInstallInfo_InstallCertFailAsk").ToString(); - MainWindowsShowInfo(currentStatus); - return false; - } - - //设置私钥权限 - sshShellCommand = @"chmod 644 /usr/local/etc/v2ray/ssl/v2ray_ssl.key"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - return true; - } - - //生成V2Ray客户端配置 96--98 - //functionResult = GenerateClientConfiguration(); - //if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - private bool GenerateClientConfigurationV2Ray() - { - //****** "生成客户端配置......" ******39 - SetUpProgressBarProcessing(96); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_GenerateClientConfig").ToString(); - MainWindowsShowInfo(currentStatus); - - string logConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\client\00_log\00_log.json"; - string apiConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\client\01_api\01_api.json"; - string dnsConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\client\02_dns\02_dns.json"; - string routingConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\client\03_routing\03_routing.json"; - string policyConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\client\04_policy\04_policy.json"; - string inboundsConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\client\05_inbounds\05_inbounds.json"; - string outboundsConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\client\06_outbounds\06_outbounds.json"; - string transportConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\client\07_transport\07_transport.json"; - string statsConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\client\08_stats\08_stats.json"; - string reverseConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\client\09_reverse\09_reverse.json"; - string baseConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\base.json"; - //Thread.Sleep(1000); - if (!Directory.Exists("v2ray_config"))//如果不存在就创建file文件夹      - { - Directory.CreateDirectory("v2ray_config");//创建该文件夹   - } - - using (StreamReader reader = File.OpenText(baseConfigJson)) - { - JObject clientJson = (JObject)JToken.ReadFrom(new JsonTextReader(reader)); - //读取"log" - using (StreamReader readerJson = File.OpenText(logConfigJson)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - clientJson["log"] = jObjectJson["log"]; - } - //读取"api" - using (StreamReader readerJson = File.OpenText(apiConfigJson)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - clientJson["api"] = jObjectJson["api"]; - } - //读取"dns" - using (StreamReader readerJson = File.OpenText(dnsConfigJson)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - clientJson["dns"] = jObjectJson["dns"]; - } - //读取"routing" - using (StreamReader readerJson = File.OpenText(routingConfigJson)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - clientJson["routing"] = jObjectJson["routing"]; - } - //读取"policy" - using (StreamReader readerJson = File.OpenText(policyConfigJson)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - clientJson["policy"] = jObjectJson["policy"]; - } - //读取"inbounds" - using (StreamReader readerJson = File.OpenText(inboundsConfigJson)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - clientJson["inbounds"] = jObjectJson["inbounds"]; - } - //读取"outbounds" - using (StreamReader readerJson = File.OpenText(outboundsConfigJson)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - clientJson["outbounds"] = jObjectJson["outbounds"]; - } - //读取"transport" - using (StreamReader readerJson = File.OpenText(transportConfigJson)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - clientJson["transport"] = jObjectJson["transport"]; - } - //读取"stats" - using (StreamReader readerJson = File.OpenText(statsConfigJson)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - clientJson["stats"] = jObjectJson["stats"]; - } - //读取"reverse" - using (StreamReader readerJson = File.OpenText(reverseConfigJson)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - clientJson["reverse"] = jObjectJson["reverse"]; - } - - //根据不同的安装方案,选择相应的客户端模板 - if (String.Equals(ReceiveConfigurationParameters[0], "VlessVmessXtlsTcpWebSocketWeb") == false) - { - #region 单模式方案 - //根据选择的不同模式,选择相应的配置文件 - if (String.Equals(ReceiveConfigurationParameters[0], "TCP") == true) - { - outboundsConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\client\06_outbounds\tcp_client_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "TCPhttp") == true) - { - outboundsConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\client\06_outbounds\tcp_http_client_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "tcpTLS") == true) - { - outboundsConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\client\06_outbounds\tcp_TLS_client_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "tcpTLSselfSigned") == true) - { - outboundsConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\client\06_outbounds\tcpTLSselfSigned_client_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "VlessXtlsTcp") == true) - { - outboundsConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\client\06_outbounds\vless_tcp_xtls_client_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "VlessTcpTlsWeb") == true) - { - outboundsConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\client\06_outbounds\vless_tcp_tls_caddy_cilent_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "VlessWebSocketTlsWeb") == true) - { - outboundsConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\client\06_outbounds\vless_ws_tls_client_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "VlessHttp2Web") == true) - { - outboundsConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\client\06_outbounds\vless_http2_tls_server_config.json"; - } - - else if (String.Equals(ReceiveConfigurationParameters[0], "webSocket") == true) - { - outboundsConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\client\06_outbounds\webSocket_client_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLS") == true) - { - outboundsConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\client\06_outbounds\WebSocket_TLS_client_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLSselfSigned") == true) - { - outboundsConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\client\06_outbounds\WebSocketTLS_selfSigned_client_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLS2Web") == true) - { - outboundsConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\client\06_outbounds\WebSocketTLSWeb_client_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "Http2") == true) - { - outboundsConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\client\06_outbounds\http2_client_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "http2Web") == true) - { - outboundsConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\client\06_outbounds\Http2Web_client_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "http2selfSigned") == true) - { - outboundsConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\client\06_outbounds\Http2selfSigned_client_config.json"; - } - //else if (String.Equals(ReceiveConfigurationParameters[0], "MkcpNone")|| String.Equals(ReceiveConfigurationParameters[0], "mKCP2SRTP")||String.Equals(ReceiveConfigurationParameters[0], "mKCPuTP")|| String.Equals(ReceiveConfigurationParameters[0], "mKCP2WechatVideo")|| String.Equals(ReceiveConfigurationParameters[0], "mKCP2DTLS")|| String.Equals(ReceiveConfigurationParameters[0], "mKCP2WireGuard")) - else if (ReceiveConfigurationParameters[0].Contains("mKCP") == true) - { - if (mKCPvlessIsSet == true) - { - outboundsConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\client\06_outbounds\vless_mkcp_client_config.json"; - } - else - { - outboundsConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\client\06_outbounds\mkcp_client_config.json"; - } - - } - // else if (String.Equals(ReceiveConfigurationParameters[0], "QuicNone") || String.Equals(ReceiveConfigurationParameters[0], "QuicSRTP") || String.Equals(ReceiveConfigurationParameters[0], "Quic2uTP") || String.Equals(ReceiveConfigurationParameters[0], "QuicWechatVideo") || String.Equals(ReceiveConfigurationParameters[0], "QuicDTLS") || String.Equals(ReceiveConfigurationParameters[0], "QuicWireGuard")) - else if (ReceiveConfigurationParameters[0].Contains("Quic") == true) - { - outboundsConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\client\06_outbounds\quic_client_config.json"; - } - - - //读取"相应模板的outbounds" - using (StreamReader readerJson = File.OpenText(outboundsConfigJson)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - - //设置客户端的地址/端口/id - jObjectJson["outbounds"][0]["settings"]["vnext"][0]["address"] = ReceiveConfigurationParameters[4]; - jObjectJson["outbounds"][0]["settings"]["vnext"][0]["port"] = int.Parse(ReceiveConfigurationParameters[1]); - jObjectJson["outbounds"][0]["settings"]["vnext"][0]["users"][0]["id"] = ReceiveConfigurationParameters[2]; - - - //设置WebSocket模式下的path - if (String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLS") == true - || String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLSselfSigned") == true - || String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLS2Web") == true - || String.Equals(ReceiveConfigurationParameters[0], "VlessWebSocketTlsWeb") == true) - { - jObjectJson["outbounds"][0]["streamSettings"]["wsSettings"]["path"] = ReceiveConfigurationParameters[6]; - } - - //设置http2模式下的path - if (String.Equals(ReceiveConfigurationParameters[0], "Http2") == true - || String.Equals(ReceiveConfigurationParameters[0], "http2Web") == true - || String.Equals(ReceiveConfigurationParameters[0], "http2selfSigned") == true - || String.Equals(ReceiveConfigurationParameters[0], "VlessHttp2Web") == true) - { - jObjectJson["outbounds"][0]["streamSettings"]["httpSettings"]["path"] = ReceiveConfigurationParameters[6]; - } - - //设置http2+TLS+Web/VLESS+http2+TLS+Web模式下的host - if (String.Equals(ReceiveConfigurationParameters[0], "http2Web") == true - || String.Equals(ReceiveConfigurationParameters[0], "VlessHttp2Web") == true) - { - jObjectJson["outbounds"][0]["streamSettings"]["httpSettings"]["host"][0] = ReceiveConfigurationParameters[4]; - } - - //设置VLESS+TCP+XTLS+Web模式下的serverName - //if (String.Equals(ReceiveConfigurationParameters[0], "VlessXtlsTcp") == true) - //{ - // jObjectJson["outbounds"][0]["streamSettings"]["xtlsSettings"]["serverName"] = ReceiveConfigurationParameters[4]; - //} - - //设置mkcp - if (ReceiveConfigurationParameters[0].Contains("mKCP") == true) - { - jObjectJson["outbounds"][0]["streamSettings"]["kcpSettings"]["header"]["type"] = ReceiveConfigurationParameters[5]; - if (String.IsNullOrEmpty(ReceiveConfigurationParameters[6]) == false) - { - jObjectJson["outbounds"][0]["streamSettings"]["kcpSettings"]["seed"] = ReceiveConfigurationParameters[6]; - } - } - - //设置QUIC - if (ReceiveConfigurationParameters[0].Contains("Quic") == true) - { - jObjectJson["outbounds"][0]["streamSettings"]["quicSettings"]["header"]["type"] = ReceiveConfigurationParameters[5]; - jObjectJson["outbounds"][0]["streamSettings"]["quicSettings"]["security"] = ReceiveConfigurationParameters[3]; - if (String.Equals(ReceiveConfigurationParameters[3], "none") == true) - { - ReceiveConfigurationParameters[6] = ""; - } - jObjectJson["outbounds"][0]["streamSettings"]["quicSettings"]["key"] = ReceiveConfigurationParameters[6]; - } - - clientJson["outbounds"] = jObjectJson["outbounds"]; - - } - - using (StreamWriter sw = new StreamWriter(@"v2ray_config\config.json")) - { - sw.Write(clientJson.ToString()); - } - - #endregion - - } - else - { - //复合方案所需要的配置文件 - //VLESS over TCP with XTLS模式 - //string outboundsConfigJsons = $"{pwdir}" + @"TemplateConfg\v2ray\client\06_outbounds\vless_tcp_xtls_client_config.json"; - //using (StreamReader readerJson = File.OpenText(outboundsConfigJsons)) - //{ - // JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - - // //设置客户端的地址/端口/id - // jObjectJson["outbounds"][0]["settings"]["vnext"][0]["address"] = ReceiveConfigurationParameters[4]; - // jObjectJson["outbounds"][0]["settings"]["vnext"][0]["port"] = int.Parse(ReceiveConfigurationParameters[1]); - // jObjectJson["outbounds"][0]["settings"]["vnext"][0]["users"][0]["id"] = ReceiveConfigurationParameters[2]; - - // clientJson["outbounds"] = jObjectJson["outbounds"]; - // if (!Directory.Exists(@"v2ray_config\vless_tcp_xtls_client_config"))//如果不存在就创建file文件夹      - // { - // Directory.CreateDirectory(@"v2ray_config\vless_tcp_xtls_client_config");//创建该文件夹   - // } - // using (StreamWriter sw = new StreamWriter(@"v2ray_config\vless_tcp_xtls_client_config\config.json")) - // { - // sw.Write(clientJson.ToString()); - // } - //} - - //VLESS over TCP with TLS模式 - string outboundsConfigJsons = $"{pwdir}" + @"TemplateConfg\v2ray\client\06_outbounds\vless_tcp_tls_caddy_cilent_config.json"; - using (StreamReader readerJson = File.OpenText(outboundsConfigJsons)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - - //设置客户端的地址/端口/id - jObjectJson["outbounds"][0]["settings"]["vnext"][0]["address"] = ReceiveConfigurationParameters[4]; - jObjectJson["outbounds"][0]["settings"]["vnext"][0]["port"] = int.Parse(ReceiveConfigurationParameters[1]); - jObjectJson["outbounds"][0]["settings"]["vnext"][0]["users"][0]["id"] = ReceiveConfigurationParameters[2]; - - clientJson["outbounds"] = jObjectJson["outbounds"]; - if (!Directory.Exists(@"v2ray_config\vless_tcp_tls_client_config"))//如果不存在就创建file文件夹      - { - Directory.CreateDirectory(@"v2ray_config\vless_tcp_tls_client_config");//创建该文件夹   - } - using (StreamWriter sw = new StreamWriter(@"v2ray_config\vless_tcp_tls_client_config\config.json")) - { - sw.Write(clientJson.ToString()); - } - } - - //VLESS over WS with TLS 模式 - outboundsConfigJsons = $"{pwdir}" + @"TemplateConfg\v2ray\client\06_outbounds\vless_ws_tls_client_config.json"; - using (StreamReader readerJson = File.OpenText(outboundsConfigJsons)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - - //设置客户端的地址/端口/id - jObjectJson["outbounds"][0]["settings"]["vnext"][0]["address"] = ReceiveConfigurationParameters[4]; - jObjectJson["outbounds"][0]["settings"]["vnext"][0]["port"] = int.Parse(ReceiveConfigurationParameters[1]); - jObjectJson["outbounds"][0]["settings"]["vnext"][0]["users"][0]["id"] = ReceiveConfigurationParameters[2]; - jObjectJson["outbounds"][0]["streamSettings"]["wsSettings"]["path"] = ReceiveConfigurationParameters[3]; - - clientJson["outbounds"] = jObjectJson["outbounds"]; - if (!Directory.Exists(@"v2ray_config\vless_ws_tls_client_config"))//如果不存在就创建file文件夹      - { - Directory.CreateDirectory(@"v2ray_config\vless_ws_tls_client_config");//创建该文件夹   - } - using (StreamWriter sw = new StreamWriter(@"v2ray_config\vless_ws_tls_client_config\config.json")) - { - sw.Write(clientJson.ToString()); - } - } - - //VMess over TCP with TLS模式 - outboundsConfigJsons = $"{pwdir}" + @"TemplateConfg\v2ray\client\06_outbounds\vmess_tcp_tls_client_config.json"; - using (StreamReader readerJson = File.OpenText(outboundsConfigJsons)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - - //设置客户端的地址/端口/id - jObjectJson["outbounds"][0]["settings"]["vnext"][0]["address"] = ReceiveConfigurationParameters[4]; - jObjectJson["outbounds"][0]["settings"]["vnext"][0]["port"] = int.Parse(ReceiveConfigurationParameters[1]); - jObjectJson["outbounds"][0]["settings"]["vnext"][0]["users"][0]["id"] = ReceiveConfigurationParameters[2]; - jObjectJson["outbounds"][0]["streamSettings"]["tcpSettings"]["header"]["request"]["path"][0] = ReceiveConfigurationParameters[9]; - - clientJson["outbounds"] = jObjectJson["outbounds"]; - if (!Directory.Exists(@"v2ray_config\vmess_tcp_tls_client_config"))//如果不存在就创建file文件夹      - { - Directory.CreateDirectory(@"v2ray_config\vmess_tcp_tls_client_config");//创建该文件夹   - } - using (StreamWriter sw = new StreamWriter(@"v2ray_config\vmess_tcp_tls_client_config\config.json")) - { - sw.Write(clientJson.ToString()); - } - } - - //VMess over WS with TLS模式 - outboundsConfigJsons = $"{pwdir}" + @"TemplateConfg\v2ray\client\06_outbounds\WebSocketTLSWeb_client_config.json"; - using (StreamReader readerJson = File.OpenText(outboundsConfigJsons)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - - //设置客户端的地址/端口/id - jObjectJson["outbounds"][0]["settings"]["vnext"][0]["address"] = ReceiveConfigurationParameters[4]; - jObjectJson["outbounds"][0]["settings"]["vnext"][0]["port"] = int.Parse(ReceiveConfigurationParameters[1]); - jObjectJson["outbounds"][0]["settings"]["vnext"][0]["users"][0]["id"] = ReceiveConfigurationParameters[2]; - jObjectJson["outbounds"][0]["streamSettings"]["wsSettings"]["path"] = ReceiveConfigurationParameters[6]; - - clientJson["outbounds"] = jObjectJson["outbounds"]; - if (!Directory.Exists(@"v2ray_config\vmess_ws_tls_client_config"))//如果不存在就创建file文件夹      - { - Directory.CreateDirectory(@"v2ray_config\vmess_ws_tls_client_config");//创建该文件夹   - } - using (StreamWriter sw = new StreamWriter(@"v2ray_config\vmess_ws_tls_client_config\config.json")) - { - sw.Write(clientJson.ToString()); - } - } - - //Trojan over TCP with TLS模式 - outboundsConfigJsons = $"{pwdir}" + @"TemplateConfg\v2ray\client\06_outbounds\trojan_tcp_tls.json"; - using (StreamReader readerJson = File.OpenText(outboundsConfigJsons)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - - //设置客户端的地址/端口/id - jObjectJson["outbounds"][0]["settings"]["servers"][0]["address"] = ReceiveConfigurationParameters[4]; - jObjectJson["outbounds"][0]["settings"]["servers"][0]["port"] = int.Parse(ReceiveConfigurationParameters[1]); - jObjectJson["outbounds"][0]["settings"]["servers"][0]["password"] = ReceiveConfigurationParameters[2]; - jObjectJson["outbounds"][0]["streamSettings"]["tlsSettings"]["serverName"] = ReceiveConfigurationParameters[4]; - - clientJson["outbounds"] = jObjectJson["outbounds"]; - if (!Directory.Exists(@"v2ray_config\trojan_tcp_tls_client_config"))//如果不存在就创建file文件夹      - { - Directory.CreateDirectory(@"v2ray_config\trojan_tcp_tls_client_config");//创建该文件夹   - } - using (StreamWriter sw = new StreamWriter(@"v2ray_config\trojan_tcp_tls_client_config\config.json")) - { - sw.Write(clientJson.ToString()); - } - } - - } - } - SetUpProgressBarProcessing(98); - return true; - } - - - #endregion - - //检测升级远程主机端的V2Ray版本 - private void ButtonUpdateV2ray_Click(object sender, RoutedEventArgs e) - { - ConnectionInfo connectionInfo = GenerateConnectionInfo(); - if (connectionInfo == null) - { - //****** "远程主机连接信息有误,请检查!" ****** - MessageBox.Show(Application.Current.FindResource("MessageBoxShow_ErrorHostConnection").ToString()); - return; - } - installationDegree = 0; - TextBoxMonitorCommandResults.Text = ""; - Thread thread = new Thread(() => UpdateV2ray(connectionInfo)); - thread.SetApartmentState(ApartmentState.STA); - thread.Start(); - } - - //升级V2ray主程序 - private void UpdateV2ray(ConnectionInfo connectionInfo) - { - functionResult = true; - onlyIpv6 = false; - getApt = false; - getDnf = false; - getYum = false; - - //******"正在登录远程主机......"****** - SetUpProgressBarProcessing(1); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_Login").ToString(); - MainWindowsShowInfo(currentStatus); - - try - { - #region 主机指纹,暂未启用 - //byte[] expectedFingerPrint = new byte[] { - // 0x66, 0x31, 0xaf, 0x00, 0x54, 0xb9, 0x87, 0x31, - // 0xff, 0x58, 0x1c, 0x31, 0xb1, 0xa2, 0x4c, 0x6b - // }; - #endregion - using (var client = new SshClient(connectionInfo)) - - { - #region ssh登录验证主机指纹代码块,暂未启用 - // client.HostKeyReceived += (sender, e) => - // { - // if (expectedFingerPrint.Length == e.FingerPrint.Length) - // { - // for (var i = 0; i < expectedFingerPrint.Length; i++) - // { - // if (expectedFingerPrint[i] != e.FingerPrint[i]) - // { - // e.CanTrust = false; - // break; - // } - // } - // } - // else - // { - // e.CanTrust = false; - // } - // }; - #endregion - - client.Connect(); - if (client.IsConnected == true) - { - //******"主机登录成功"****** - SetUpProgressBarProcessing(3); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_LoginSuccessful").ToString(); - MainWindowsShowInfo(currentStatus); - } - - //检测root权限 5--7 - functionResult = RootAuthorityDetect(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - - //******"检测系统是否已经安装V2ray......"****** - SetUpProgressBarProcessing(20); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_TestExistSoft").ToString() + "V2ray......"; - MainWindowsShowInfo(currentStatus); - - //Thread.Sleep(1000); - //检测是否安装V2Ray - //sshShellCommand = @"find / -name v2ray"; - //sshShellCommand = @"if [[ -f /usr/local/bin/v2ray ]];then echo '1';else echo '0'; fi"; - //currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //if (currentShellCommandResult.Contains("/usr/local/bin/v2ray") == false) - //if (currentShellCommandResult.Trim().Equals("0") == true) - functionResult = FileCheckExists(client, @"/usr/local/bin/v2ray"); - if (functionResult == false) - { - //******"退出!原因:远程主机未安装V2ray"****** - currentStatus = Application.Current.FindResource("MessageBoxShow_ErrorUpgradeSoftNotInstall").ToString() + "V2Ray!"; - MainWindowsShowInfo(currentStatus); - MessageBox.Show(currentStatus); - client.Disconnect(); - return; - - } - - //sshcmd = @"/usr/local/bin/v2ray -version | head -n 1 | cut -d "" "" -f2"; - sshShellCommand = @"/usr/local/bin/v2ray -version | head -n 1 | cut -d "" "" -f2"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - string v2rayCurrentVersion = currentShellCommandResult;//不含字母v - - //sshcmd = @"curl -H ""Accept: application/json"" -H ""User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0"" -s ""https://api.github.com/repos/v2fly/v2ray-core/releases/latest"" --connect-timeout 10| grep 'tag_name' | cut -d\"" -f4"; - sshShellCommand = @"curl -H ""Accept: application/json"" -H ""User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0"" -s ""https://api.github.com/repos/v2fly/v2ray-core/releases/latest"" --connect-timeout 10 | grep 'tag_name' | cut -d\"" -f4"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - string v2rayNewVersion = currentShellCommandResult;//包含字母v - - if (v2rayNewVersion.Contains(v2rayCurrentVersion) == false) - { - MessageBoxResult messageBoxResult = MessageBox.Show( - //****** "远程主机当前版本为:v" ****** - Application.Current.FindResource("DisplayInstallInfo_CurrentVersion").ToString() + - $"{v2rayCurrentVersion}\n" + - //****** "最新版本为:" ****** - Application.Current.FindResource("DisplayInstallInfo_NewVersion").ToString() + - $"{v2rayNewVersion}\n" + - //****** "是否升级为最新版本?" ****** - Application.Current.FindResource("DisplayInstallInfo_IsOrNoUpgradeNewVersion").ToString(), "", MessageBoxButton.YesNo, MessageBoxImage.Question); - if (messageBoxResult == MessageBoxResult.Yes) - { - //****** "正在升级到最新版本......" ****** - SetUpProgressBarProcessing(60); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_StartUpgradeNewVersion").ToString(); - MainWindowsShowInfo(currentStatus); - - //client.RunCommand(@"bash <(curl -L -s https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh)"); - sshShellCommand = $"bash <(curl -L -s https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh)"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - SetUpProgressBarProcessing(80); - //sshcmd = @"/usr/local/bin/v2ray -version | head -n 1 | cut -d "" "" -f2"; - sshShellCommand = @"/usr/local/bin/v2ray -version | head -n 1 | cut -d "" "" -f2"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - v2rayCurrentVersion = currentShellCommandResult;//不含字母v - if (v2rayNewVersion.Contains(v2rayCurrentVersion) == true) - { - //****** "升级成功!当前已是最新版本!" ****** - MessageBox.Show(Application.Current.FindResource("DisplayInstallInfo_UpgradeNewVersionOK").ToString()); - //****** "升级成功!当前已是最新版本!" ****** - SetUpProgressBarProcessing(100); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_UpgradeNewVersionOK").ToString(); - MainWindowsShowInfo(currentStatus); - } - else - { - //****** "升级失败,原因未知,请向开发者提问!" ****** - MessageBox.Show(Application.Current.FindResource("DisplayInstallInfo_UpgradeNewVersionFail").ToString()); - //****** "升级失败,原因未知,请向开发者提问!" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_UpgradeNewVersionFail").ToString(); - MainWindowsShowInfo(currentStatus); - } - } - else - { - //****** "升级取消,退出!" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_UpgradeVersionCancel").ToString(); - MainWindowsShowInfo(currentStatus); - - client.Disconnect(); - return; - } - } - else - { - //****** "远程主机当前已是最新版本:" ****** - SetUpProgressBarProcessing(100); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_IsNewVersion").ToString() + - $"{v2rayNewVersion}\n" + - //****** "无需升级!退出!" ****** - Application.Current.FindResource("DisplayInstallInfo_NotUpgradeVersion").ToString(); - MessageBox.Show(currentStatus); - MainWindowsShowInfo(currentStatus); - } - - client.Disconnect(); - return; - } - } - catch (Exception ex1)//例外处理 - #region 例外处理 - { - ProcessException(ex1.Message); - - //****** "主机登录失败!" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_LoginFailed").ToString(); - MainWindowsShowInfo(currentStatus); - } - #endregion - - } - #endregion - - #region Xray相关 - //打开Xray模板设置窗口 - private void ButtonTemplateConfigurationXray_Click(object sender, RoutedEventArgs e) - { - //清空初始化模板参数 - for (int i = 0; i != ReceiveConfigurationParameters.Length; i++) - - { - ReceiveConfigurationParameters[i] = ""; - } - XrayWindowTemplateConfiguration XraywindowTemplateConfiguration = new XrayWindowTemplateConfiguration(); - XraywindowTemplateConfiguration.Closed += XraywindowTemplateConfigurationClosed; - XraywindowTemplateConfiguration.ShowDialog(); - } - - //Xay模板设置窗口关闭后,触发事件,将所选的方案与其参数显示在UI上 - private void XraywindowTemplateConfigurationClosed(object sender, System.EventArgs e) - { - if (String.IsNullOrEmpty(ReceiveConfigurationParameters[0]) == true) - { - //显示"未选择方案!" - TextBlockCurrentlySelectedPlanXray.Text = Application.Current.FindResource("TextBlockCurrentlySelectedPlanNo").ToString(); - - GridXrayCurrentlyPlan.Visibility = Visibility.Hidden; - - return; - } - else - { - GridXrayCurrentlyPlan.Visibility = Visibility.Visible; - } - TextBlockCurrentlySelectedPlanXray.Text = ReceiveConfigurationParameters[8]; //所选方案名称 - TextBlockCurrentlySelectedPlanPortXray.Text = ReceiveConfigurationParameters[1]; //服务器端口 - TextBlockCurrentlySelectedPlanUUIDXray.Text = ReceiveConfigurationParameters[2]; //UUID - TextBlockCurrentlySelectedPlanPathSeedKeyXray.Text = ReceiveConfigurationParameters[6]; //mKCP Seed\Quic Key\Path - //MessageBox.Show(ReceiveConfigurationParameters[7]); - TextBlockCurrentlySelectedPlanFakeWebsiteXray.Text = ReceiveConfigurationParameters[7]; //伪装网站 - - if (String.Equals(ReceiveConfigurationParameters[0], "TCP") == true - || String.Equals(ReceiveConfigurationParameters[0], "TCPhttp") == true - || String.Equals(ReceiveConfigurationParameters[0], "tcpTLSselfSigned") == true - || String.Equals(ReceiveConfigurationParameters[0], "webSocket") == true) - { - //隐藏Path/mKCP Seed/Quic Key - HideXayPathSeedKey(); - HideVlessVmessXtlsTcpWsXray(); - - //隐藏域名/Quic加密方式 - HideXrayDomainQuicEncrypt(); - - //隐藏伪装网站 - HideXrayMaskSites(); - - } - else if (String.Equals(ReceiveConfigurationParameters[0], "tcpTLS") == true) - { - //隐藏Path/mKCP Seed/Quic Key - HideXayPathSeedKey(); - HideVlessVmessXtlsTcpWsXray(); - - //显示域名 - ShowXrayDomainQuicEncrypt(); - - //隐藏伪装网站 - HideXrayMaskSites(); - } - else if (String.Equals(ReceiveConfigurationParameters[0], "VlessVmessXtlsTcpWebSocketWeb") == true) - { - //显示复合方案路径 - ShowVlessVmessXtlsTcpWsXray(); - - //显示域名 - ShowXrayDomainQuicEncrypt(); - - //显示伪装网站 - ShowXayMaskSites(); - - } - else if (String.Equals(ReceiveConfigurationParameters[0], "VlessTcpTlsWeb") == true - || String.Equals(ReceiveConfigurationParameters[0], "VlessXtlsTcp") == true) - { - //隐藏Path/mKCP Seed/Quic Key - HideXayPathSeedKey(); - HideVlessVmessXtlsTcpWsXray(); - - //显示域名 - ShowXrayDomainQuicEncrypt(); - - //显示伪装网站 - ShowXayMaskSites(); - } - else if (String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLS") == true - || String.Equals(ReceiveConfigurationParameters[0], "Http2") == true) - { - //显示Path - ShowXayPathSeedKey(); - TextBlockXrayShowPathSeedKey.Text = "Path:"; - TextBlockCurrentlySelectedPlanPathSeedKeyXray.Text = ReceiveConfigurationParameters[6]; //mKCP Seed\Quic Key\Path - - - //显示域名 - ShowXrayDomainQuicEncrypt(); - - //显示伪装网站(暂时不显示) - HideXrayMaskSites(); - } - else if (String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLS2Web") == true - || String.Equals(ReceiveConfigurationParameters[0], "http2Web") == true - || String.Equals(ReceiveConfigurationParameters[0], "VlessWebSocketTlsWeb") == true - || String.Equals(ReceiveConfigurationParameters[0], "VlessHttp2Web") == true) - { - //显示Path - ShowXayPathSeedKey(); - TextBlockXrayShowPathSeedKey.Text = "Path:"; - TextBlockCurrentlySelectedPlanPathSeedKeyXray.Text = ReceiveConfigurationParameters[6]; //mKCP Seed\Quic Key\Path - - //显示域名 - ShowXrayDomainQuicEncrypt(); - - //显示伪装网站 - ShowXayMaskSites(); - } - else if (String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLSselfSigned") == true - || String.Equals(ReceiveConfigurationParameters[0], "http2selfSigned") == true) - { - //显示Path - ShowXayPathSeedKey(); - TextBlockXrayShowPathSeedKey.Text = "Path:"; - TextBlockCurrentlySelectedPlanPathSeedKeyXray.Text = ReceiveConfigurationParameters[6]; //mKCP Seed\Quic Key\Path - - //隐藏域名/Quic加密方式 - HideXrayDomainQuicEncrypt(); - - //隐藏伪装网站 - HideXrayMaskSites(); - } - else if (ReceiveConfigurationParameters[0].Contains("mKCP") == true) - { - //显示mKCP Seed - ShowXayPathSeedKey(); - TextBlockXrayShowPathSeedKey.Text = "mKCP Seed:"; - TextBlockCurrentlySelectedPlanPathSeedKeyXray.Text = ReceiveConfigurationParameters[6]; //mKCP Seed\Quic Key\Path - - //隐藏域名/Quic加密方式 - HideXrayDomainQuicEncrypt(); - - //隐藏伪装网站 - HideXrayMaskSites(); - } - else if (ReceiveConfigurationParameters[0].Contains("Quic") == true) - { - //显示QUIC Key - ShowXayPathSeedKey(); - TextBlockXrayShowPathSeedKey.Text = "QUIC Key:"; - TextBlockCurrentlySelectedPlanPathSeedKeyXray.Text = ReceiveConfigurationParameters[6]; //mKCP Seed\Quic Key\Path - - //显示Quic加密方式 - ShowXrayDomainQuicEncrypt(); - TextBlockXrayShowCurrentlySelectedPlanDomain.Text = Application.Current.FindResource("TextBlockQuicEncryption").ToString(); - TextBlockCurrentlySelectedPlanDomainXray.Text = ReceiveConfigurationParameters[3]; //Quic加密方式 - if (String.Equals(TextBlockCurrentlySelectedPlanDomain.Text, "none") == true) - { - HideXayPathSeedKey(); - } - - - //隐藏伪装网站 - HideXrayMaskSites(); - } - } - - #region 当前方案界面控制 - //显示端口与UUID - private void ShowXrayCurrentPortUUID() - { - TextBlockXrayShowPort.Visibility = Visibility.Visible; - TextBlockCurrentlySelectedPlanPortXray.Visibility = Visibility.Visible; - - TextBlockXrayShowUUID.Visibility = Visibility.Visible; - TextBlockCurrentlySelectedPlanUUIDXray.Visibility = Visibility.Visible; - } - - //显示Path/mKCP Seed/Quic Key - private void ShowXayPathSeedKey() - { - HideVlessVmessXtlsTcpWsXray(); - TextBlockXrayShowPathSeedKey.Visibility = Visibility.Visible; - TextBlockCurrentlySelectedPlanPathSeedKeyXray.Visibility = Visibility.Visible; - } - - //隐藏Path/mKCP Seed/Quic Key - private void HideXayPathSeedKey() - { - TextBlockXrayShowPathSeedKey.Visibility = Visibility.Hidden; - TextBlockCurrentlySelectedPlanPathSeedKeyXray.Visibility = Visibility.Hidden; - } - - //显示VLESS VMESS XTLS TCP WS 复合方案 - private void ShowVlessVmessXtlsTcpWsXray() - { - HideXayPathSeedKey(); - GridVlessVmessXtlsTcpWsXray.Visibility = Visibility.Visible; - TextBlockBoxPathVlessWSXray.Text = ReceiveConfigurationParameters[3]; - TextBlockBoxPathVmessTcpXray.Text = ReceiveConfigurationParameters[9]; - TextBlockBoxPathVmessWSXray.Text = ReceiveConfigurationParameters[6]; - } - - //隐藏VLESS VMESS XTLS TCP WS 复合方案 - private void HideVlessVmessXtlsTcpWsXray() - { - GridVlessVmessXtlsTcpWsXray.Visibility = Visibility.Collapsed; - } - - //显示域名/Quic加密方式 - private void ShowXrayDomainQuicEncrypt() - { - TextBlockXrayShowCurrentlySelectedPlanDomain.Visibility = Visibility.Visible; - TextBlockCurrentlySelectedPlanDomainXray.Visibility = Visibility.Visible; - TextBlockXrayShowCurrentlySelectedPlanDomain.Text = Application.Current.FindResource("TextBlockV2RayDomain").ToString(); - TextBlockCurrentlySelectedPlanDomainXray.Text = ReceiveConfigurationParameters[4]; //域名 - - } - - //隐藏域名/Quic加密方式 - private void HideXrayDomainQuicEncrypt() - { - TextBlockXrayShowCurrentlySelectedPlanDomain.Visibility = Visibility.Hidden; - TextBlockCurrentlySelectedPlanDomainXray.Visibility = Visibility.Hidden; - } - //显示伪装网站 - private void ShowXayMaskSites() - { - TextBlockXrayShowCurrentlySelectedPlanFakeWebsite.Visibility = Visibility.Visible; - TextBlockCurrentlySelectedPlanFakeWebsiteXray.Visibility = Visibility.Visible; - } - - //隐藏伪装网站 - private void HideXrayMaskSites() - { - TextBlockXrayShowCurrentlySelectedPlanFakeWebsite.Visibility = Visibility.Hidden; - TextBlockCurrentlySelectedPlanFakeWebsiteXray.Visibility = Visibility.Hidden; - } - #endregion - - //传送Xray模板参数,启动Xray安装进程 - private void ButtonXraySetUP_Click(object sender, RoutedEventArgs e) - - { - ConnectionInfo connectionInfo = GenerateConnectionInfo(); - if (connectionInfo == null) - { - //****** "远程主机连接信息有误,请检查!" ****** - MessageBox.Show(Application.Current.FindResource("MessageBoxShow_ErrorHostConnection").ToString()); - return; - } - - - //生成客户端配置时,连接的服务主机的IP或者域名 - if (String.IsNullOrEmpty(ReceiveConfigurationParameters[4]) == true) - { - ReceiveConfigurationParameters[4] = PreTrim(TextBoxHost.Text); - testDomain = false; - } - //选择模板 - if (String.IsNullOrEmpty(ReceiveConfigurationParameters[0]) == true) - { - //******"请先选择配置模板!"****** - MessageBox.Show(Application.Current.FindResource("MessageBoxShow_ChooseTemplate").ToString()); - return; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "TCP") == true - || String.Equals(ReceiveConfigurationParameters[0], "TCPhttp") == true - || String.Equals(ReceiveConfigurationParameters[0], "tcpTLSselfSigned") == true - || String.Equals(ReceiveConfigurationParameters[0], "webSocket") == true - || String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLSselfSigned") == true - || String.Equals(ReceiveConfigurationParameters[0], "http2selfSigned") == true - || ReceiveConfigurationParameters[0].Contains("mKCP") == true - || ReceiveConfigurationParameters[0].Contains("Quic") == true) - { - testDomain = false; - - } - else if (String.Equals(ReceiveConfigurationParameters[0], "tcpTLS") == true - || String.Equals(ReceiveConfigurationParameters[0], "VlessXtlsTcp") == true - || String.Equals(ReceiveConfigurationParameters[0], "VlessTcpTlsWeb") == true - || String.Equals(ReceiveConfigurationParameters[0], "VlessWebSocketTlsWeb") == true - || String.Equals(ReceiveConfigurationParameters[0], "VlessHttp2Web") == true - || String.Equals(ReceiveConfigurationParameters[0], "VlessVmessXtlsTcpWebSocketWeb") == true - || String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLS2Web") == true - || String.Equals(ReceiveConfigurationParameters[0], "Http2") == true - || String.Equals(ReceiveConfigurationParameters[0], "http2Web") == true) - { - testDomain = true; - - } - - - //Thread thread - //SetUpProgressBarProcessing(0); //重置安装进度 - installationDegree = 0; - TextBoxMonitorCommandResults.Text = ""; - //Thread thread = new Thread(() => StartSetUpXray(connectionInfo, TextBlockSetUpProcessing, ProgressBarSetUpProcessing)); - Thread thread = new Thread(() => StartSetUpXray(connectionInfo)); - - thread.SetApartmentState(ApartmentState.STA); - thread.Start(); - - - } - - //登录远程主机布署Xray程序 - private void StartSetUpXray(ConnectionInfo connectionInfo) - { - functionResult = true; - onlyIpv6 = false; - getApt = false; - getDnf = false; - getYum = false; - - //******"正在登录远程主机......"****** - SetUpProgressBarProcessing(1); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_Login").ToString(); - MainWindowsShowInfo(currentStatus); - - try - { - #region 主机指纹,暂未启用 - //byte[] expectedFingerPrint = new byte[] { - // 0x66, 0x31, 0xaf, 0x00, 0x54, 0xb9, 0x87, 0x31, - // 0xff, 0x58, 0x1c, 0x31, 0xb1, 0xa2, 0x4c, 0x6b - // }; - #endregion - using (var client = new SshClient(connectionInfo)) - { - #region ssh登录验证主机指纹代码块,暂未启用 - // client.HostKeyReceived += (sender, e) => - // { - // if (expectedFingerPrint.Length == e.FingerPrint.Length) - // { - // for (var i = 0; i < expectedFingerPrint.Length; i++) - // { - // if (expectedFingerPrint[i] != e.FingerPrint[i]) - // { - // e.CanTrust = false; - // break; - // } - // } - // } - // else - // { - // e.CanTrust = false; - // } - // }; - #endregion - - client.Connect(); - if (client.IsConnected == true) - { - //******"主机登录成功"****** - SetUpProgressBarProcessing(3); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_LoginSuccessful").ToString(); - MainWindowsShowInfo(currentStatus); - //Thread.Sleep(3000); - } - - //检测root权限 5--7 - functionResult = RootAuthorityDetect(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //检测是否已安装代理 8--10 - functionResult = SoftInstalledIsNoYes(client, "xray", @"/usr/local/bin/xray"); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //检测系统是否符合安装要求 11--30 - //检测关闭Selinux及系统组件是否齐全(apt-get/yum/dnf/systemctl) - //安装依赖软件,检测端口,防火墙开启端口 - functionResult = ShutDownSelinuxAndSysComponentsDetect(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //检测校对时间 31--33 - functionResult = CheckProofreadingTime(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //检测域名解析是否正确 34---36 - if (testDomain == true) - { - functionResult = DomainResolutionCurrentIPDetect(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - } - - //下载安装脚本安装 37--40 - //functionResult = ProxySoftInstall(client, @"Xray", @"https://raw.githubusercontent.com/v2fly/fhs-install-Xray/master/install-release.sh"); - functionResult = ProxySoftInstall(client, @"Xray", @"https://raw.githubusercontent.com/XTLS/Xray-install/main/install-release.sh"); - - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - //functionResult = XrayInstallScript(client); - //if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //程序是否安装成功检测 41--43 - functionResult = SoftInstalledSuccessOrFail(client, "xray", @"/usr/local/bin/xray"); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //生成服务端配置 44--46 - functionResult = GenerateServerConfigurationXray(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //****** "上传配置文件......" ****** 47--50 - currentStatus = Application.Current.FindResource("DisplayInstallInfo_UploadSoftConfig").ToString(); - MainWindowsShowInfo(currentStatus); - string serverRemoteConfig = @"/usr/local/etc/xray/config.json"; - UploadConfig(connectionInfo, @"config.json", serverRemoteConfig); - File.Delete(@"config.json"); - SetUpProgressBarProcessing(50); - - //如果使用http2/WebSocketTLS/tcpTLS/VlessTcpTlsWeb/VLESS+TCP+XTLS+Web模式,先要安装acme.sh,申请证书 - if (String.Equals(ReceiveConfigurationParameters[0], "Http2") == true - || String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLS") == true - || String.Equals(ReceiveConfigurationParameters[0], "tcpTLS") == true - || String.Equals(ReceiveConfigurationParameters[0], "VlessXtlsTcp") == true - || String.Equals(ReceiveConfigurationParameters[0], "VlessTcpTlsWeb") == true - || String.Equals(ReceiveConfigurationParameters[0], "VlessVmessXtlsTcpWebSocketWeb") == true) - { - //安装acme.sh与申请证书 51--57 - functionResult = AcmeShInstall(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //安装证书到Xray 58--60 - functionResult = CertInstallToXray(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - } - - - #region Caddy安装 61--70 - - //如果是VLESS+TCP+XTLS+Web/VLESS+TCP+TLS+Web/VLESS+WebSocket+TLS+Web/VLESS+http2+TLS+Web/WebSocket+TLS+Web/http2Web模式,需要安装Caddy - if (String.Equals(ReceiveConfigurationParameters[0], "VlessXtlsTcp") == true - || String.Equals(ReceiveConfigurationParameters[0], "VlessTcpTlsWeb") == true - || String.Equals(ReceiveConfigurationParameters[0], "VlessWebSocketTlsWeb") == true - || String.Equals(ReceiveConfigurationParameters[0], "VlessHttp2Web") == true - || String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLS2Web") == true - || String.Equals(ReceiveConfigurationParameters[0], "http2Web") == true - || String.Equals(ReceiveConfigurationParameters[0], "VlessVmessXtlsTcpWebSocketWeb") == true) - { - //安装Caddy 61--66 - functionResult = CaddyInstall(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - - #region 上传Caddy配置文件 67--70 - - //******"上传Caddy配置文件"****** - SetUpProgressBarProcessing(67); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_UploadCaddyConfig").ToString(); - MainWindowsShowInfo(currentStatus); - - string serverConfig = ""; - sshShellCommand = @"mv /etc/caddy/Caddyfile /etc/caddy/Caddyfile.bak"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - if (String.Equals(ReceiveConfigurationParameters[0], "VlessXtlsTcp") == true - || String.Equals(ReceiveConfigurationParameters[0], "VlessTcpTlsWeb") == true - || String.Equals(ReceiveConfigurationParameters[0], "VlessVmessXtlsTcpWebSocketWeb") == true) - { - serverConfig = $"{pwdir}" + @"TemplateConfg\xray\caddy\vlessTcpTlsWeb.caddyfile"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "VlessWebSocketTlsWeb") == true - || String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLS2Web") == true) - { - serverConfig = $"{pwdir}" + @"TemplateConfg\xray\caddy\WebSocketTLSWeb.caddyfile"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "VlessHttp2Web") == true - || String.Equals(ReceiveConfigurationParameters[0], "http2Web") == true) - { - serverConfig = $"{pwdir}" + @"TemplateConfg\xray\caddy\Http2Web.caddyfile"; - } - - string upLoadPath = "/etc/caddy/Caddyfile"; - client.RunCommand("mv /etc/caddy/Caddyfile /etc/caddy/Caddyfile.bak"); - UploadConfig(connectionInfo, serverConfig, upLoadPath); - - functionResult = FileCheckExists(client, @"/etc/caddy/Caddyfile"); - if (functionResult == false) - { - //****** "Caddy配置文件上传失败!" ******32 - currentStatus = Application.Current.FindResource("DisplayInstallInfo_UploadCaddyConfigFailed").ToString(); - MainWindowsShowInfo(currentStatus); - FunctionResultErr(); - client.Disconnect(); - return; - } - - //****** "Caddy配置文件上传成功,OK!" ******32 - SetUpProgressBarProcessing(70); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_UploadCaddyConfigOK").ToString(); - MainWindowsShowInfo(currentStatus); - - //设置Caddy配置文件 - functionResult = SetCaddyfile(client, upLoadPath); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - - #endregion - - //启动Caddy服务 - functionResult = SoftStartDetect(client, "caddy", @"/usr/bin/caddy"); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - } - #endregion - - //****** "正在启动Xray......" ******35 - functionResult = SoftStartDetect(client, "xray", @"/usr/local/bin/xray"); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //测试BBR条件,若满足提示是否启用 - functionResult = DetectBBRandEnable(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - client.Disconnect();//断开服务器ssh连接 - - //生成客户端配置 96--98 - functionResult = GenerateClientConfigurationXray(); - - //****** "Xray安装成功,祝你玩的愉快!!" ******40 - SetUpProgressBarProcessing(100); - currentStatus = "Xray" + Application.Current.FindResource("DisplayInstallInfo_ProxyInstalledOK").ToString(); - MainWindowsShowInfo(currentStatus); - - Thread.Sleep(1000); - - //显示服务端连接参数 - proxyType = "Xray"; - ResultClientInformation resultClientInformation = new ResultClientInformation(); - resultClientInformation.ShowDialog(); - - return; - - } - } - catch (Exception ex1)//例外处理 - { - ProcessException(ex1.Message); - - //****** "安装失败!" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_LoginFailed").ToString(); - MainWindowsShowInfo(currentStatus); - } - } - - #region Xray专用调用函数 - //安装代理程序 37--40 - //functionResult = ProxySoftInstall(client,@"",@""); - //if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - /* private bool ProxySoftInstallV2ray(SshClient client, string proxyName, string downloadUrl) - { - //****** "系统环境检测完毕,符合安装要求,开始布署......" ****** - SetUpProgressBarProcessing(37); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_StartInstalling").ToString(); - MainWindowsShowInfo(currentStatus); - - //****** "正在安装{proxyName}......" ****** - SetUpProgressBarProcessing(38); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_StartInstallSoft").ToString() + $"{proxyName}......"; - MainWindowsShowInfo(currentStatus); - - saveShellScriptFileName = GenerateRandomScriptFileName(GenerateRandomStr(10)); - - sshShellCommand = $"curl -o {saveShellScriptFileName} {downloadUrl}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - functionResult = FileCheckExists(client, $"{saveShellScriptFileName}"); - if (functionResult == false) - { - //***文件下载失败!*** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_DownloadScriptFailed").ToString(); - MainWindowsShowInfo(currentStatus); - return false; - - } - sshShellCommand = $"yes | bash {saveShellScriptFileName} --version v4.32.1"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = $"rm -f {saveShellScriptFileName}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - SetUpProgressBarProcessing(40); - return true; - } */ - - - //生成Xray服务端配置 44--46 - //functionResult = GenerateServerConfiguration(client); - //if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - private bool GenerateServerConfigurationXray(SshClient client) - { - SetUpProgressBarProcessing(44); - //修改xray.service - - sshShellCommand = $"sed -i 's/User=nobody/User=root/g' /etc/systemd/system/xray.service"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = $"sed -i 's/CapabilityBoundingSet=/#CapabilityBoundingSet=/g' /etc/systemd/system/xray.service"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = $"sed -i 's/AmbientCapabilities=/#AmbientCapabilities=/g' /etc/systemd/system/xray.service"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = $"systemctl daemon-reload"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //备用下载地址:https://raw.githubusercontent.com/proxysu/Resources/master/xray/xray.service - - //sshShellCommand = $"yes | curl -o /etc/systemd/system/xray.service https://raw.githubusercontent.com/proxysu/Resources/master/xray/xray.service"; - //currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //备份原来的文件 - functionResult = FileCheckExists(client, @"/usr/local/etc/xray/config.json"); - if (functionResult == true) - { - - sshShellCommand = @"mv /usr/local/etc/xray/config.json /usr/local/etc/xray/config.json.1"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - } - //读取配置文件各个模块 - string logConfigJson = $"{pwdir}" + @"TemplateConfg\xray\server\00_log\00_log.json"; - string apiConfigJson = $"{pwdir}" + @"TemplateConfg\xray\server\01_api\01_api.json"; - string dnsConfigJson = $"{pwdir}" + @"TemplateConfg\xray\server\02_dns\02_dns.json"; - string routingConfigJson = $"{pwdir}" + @"TemplateConfg\xray\server\03_routing\03_routing.json"; - string policyConfigJson = $"{pwdir}" + @"TemplateConfg\xray\server\04_policy\04_policy.json"; - string inboundsConfigJson = $"{pwdir}" + @"TemplateConfg\xray\server\05_inbounds\05_inbounds.json"; - string outboundsConfigJson = $"{pwdir}" + @"TemplateConfg\xray\server\06_outbounds\06_outbounds.json"; - string transportConfigJson = $"{pwdir}" + @"TemplateConfg\xray\server\07_transport\07_transport.json"; - string statsConfigJson = $"{pwdir}" + @"TemplateConfg\xray\server\08_stats\08_stats.json"; - string reverseConfigJson = $"{pwdir}" + @"TemplateConfg\xray\server\09_reverse\09_reverse.json"; - string baseConfigJson = $"{pwdir}" + @"TemplateConfg\xray\base.json"; - - //配置文件模块合成 - using (StreamReader reader = File.OpenText(baseConfigJson)) - { - JObject serverJson = (JObject)JToken.ReadFrom(new JsonTextReader(reader)); - //读取"log" - using (StreamReader readerJson = File.OpenText(logConfigJson)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - serverJson["log"] = jObjectJson["log"]; - } - //读取"api" - using (StreamReader readerJson = File.OpenText(apiConfigJson)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - serverJson["api"] = jObjectJson["api"]; - } - //读取"dns" - using (StreamReader readerJson = File.OpenText(dnsConfigJson)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - serverJson["dns"] = jObjectJson["dns"]; - } - //读取"routing" - using (StreamReader readerJson = File.OpenText(routingConfigJson)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - serverJson["routing"] = jObjectJson["routing"]; - } - //读取"policy" - using (StreamReader readerJson = File.OpenText(policyConfigJson)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - serverJson["policy"] = jObjectJson["policy"]; - } - //读取"inbounds" - using (StreamReader readerJson = File.OpenText(inboundsConfigJson)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - serverJson["inbounds"] = jObjectJson["inbounds"]; - } - //读取"outbounds" - using (StreamReader readerJson = File.OpenText(outboundsConfigJson)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - serverJson["outbounds"] = jObjectJson["outbounds"]; - } - //读取"transport" - using (StreamReader readerJson = File.OpenText(transportConfigJson)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - serverJson["transport"] = jObjectJson["transport"]; - } - //读取"stats" - using (StreamReader readerJson = File.OpenText(statsConfigJson)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - serverJson["stats"] = jObjectJson["stats"]; - } - //读取"reverse" - using (StreamReader readerJson = File.OpenText(reverseConfigJson)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - serverJson["reverse"] = jObjectJson["reverse"]; - } - - //依据安装模式读取相应模板 - if (String.Equals(ReceiveConfigurationParameters[0], "TCP") == true) - { - inboundsConfigJson = $"{pwdir}" + @"TemplateConfg\xray\server\05_inbounds\tcp_server_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "TCPhttp") == true) - { - inboundsConfigJson = $"{pwdir}" + @"TemplateConfg\xray\server\05_inbounds\tcp_http_server_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "tcpTLS") == true) - { - inboundsConfigJson = $"{pwdir}" + @"TemplateConfg\xray\server\05_inbounds\tcp_TLS_server_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "tcpTLSselfSigned") == true) - { - inboundsConfigJson = $"{pwdir}" + @"TemplateConfg\xray\server\05_inbounds\tcpTLSselfSigned_server_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "VlessXtlsTcp") == true) - { - inboundsConfigJson = $"{pwdir}" + @"TemplateConfg\xray\server\05_inbounds\vless_tcp_xtls_server_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "VlessTcpTlsWeb") == true) - { - inboundsConfigJson = $"{pwdir}" + @"TemplateConfg\xray\server\05_inbounds\vless_tcp_tls_server_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "VlessWebSocketTlsWeb") == true) - { - inboundsConfigJson = $"{pwdir}" + @"TemplateConfg\xray\server\05_inbounds\vless_ws_tls_server_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "VlessHttp2Web") == true) - { - inboundsConfigJson = $"{pwdir}" + @"TemplateConfg\xray\server\05_inbounds\vless_http2_tls_server_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "VlessVmessXtlsTcpWebSocketWeb") == true) - { - inboundsConfigJson = $"{pwdir}" + @"TemplateConfg\xray\server\05_inbounds\vless_vmess_xtls_tcp_websocket_server_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "webSocket") == true) - { - inboundsConfigJson = $"{pwdir}" + @"TemplateConfg\xray\server\05_inbounds\webSocket_server_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLS") == true) - { - inboundsConfigJson = $"{pwdir}" + @"TemplateConfg\xray\server\05_inbounds\WebSocket_TLS_server_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLSselfSigned") == true) - { - inboundsConfigJson = $"{pwdir}" + @"TemplateConfg\xray\server\05_inbounds\WebSocketTLS_selfSigned_server_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLS2Web") == true) - { - inboundsConfigJson = $"{pwdir}" + @"TemplateConfg\xray\server\05_inbounds\WebSocketTLSWeb_server_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "Http2") == true) - { - inboundsConfigJson = $"{pwdir}" + @"TemplateConfg\xray\server\05_inbounds\http2_server_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "http2Web") == true) - { - inboundsConfigJson = $"{pwdir}" + @"TemplateConfg\xray\server\05_inbounds\Http2Web_server_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "http2selfSigned") == true) - { - inboundsConfigJson = $"{pwdir}" + @"TemplateConfg\xray\server\Http2selfSigned_server_config.json"; - } - //else if (String.Equals(ReceiveConfigurationParameters[0], "MkcpNone")|| String.Equals(ReceiveConfigurationParameters[0], "mKCP2SRTP")||String.Equals(ReceiveConfigurationParameters[0], "mKCPuTP")|| String.Equals(ReceiveConfigurationParameters[0], "mKCP2WechatVideo")|| String.Equals(ReceiveConfigurationParameters[0], "mKCP2DTLS")|| String.Equals(ReceiveConfigurationParameters[0], "mKCP2WireGuard")) - else if (ReceiveConfigurationParameters[0].Contains("mKCP") == true) - { - if (mKCPvlessIsSet == true) - { - inboundsConfigJson = $"{pwdir}" + @"TemplateConfg\xray\server\05_inbounds\vless_mkcp_server_config.json"; - } - else - { - inboundsConfigJson = $"{pwdir}" + @"TemplateConfg\xray\server\05_inbounds\mkcp_server_config.json"; - } - - } - - // else if (String.Equals(ReceiveConfigurationParameters[0], "QuicNone") || String.Equals(ReceiveConfigurationParameters[0], "QuicSRTP") || String.Equals(ReceiveConfigurationParameters[0], "Quic2uTP") || String.Equals(ReceiveConfigurationParameters[0], "QuicWechatVideo") || String.Equals(ReceiveConfigurationParameters[0], "QuicDTLS") || String.Equals(ReceiveConfigurationParameters[0], "QuicWireGuard")) - else if (ReceiveConfigurationParameters[0].Contains("Quic") == true) - { - inboundsConfigJson = $"{pwdir}" + @"TemplateConfg\xray\server\05_inbounds\quic_server_config.json"; - } - - //读取"inbounds" - using (StreamReader readerJson = File.OpenText(inboundsConfigJson)) - { - JObject jObjectJsonTmp = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - var jObjectJson = (dynamic)jObjectJsonTmp; - - //Padavan路由固件服务端设置(因为客户端分流有问题所以在服务端弥补)加上后会影响一定的速度 - - //string sniffingAddServer = $"{pwdir}" + @"TemplateConfg\xray\server\05_inbounds\00_padavan_router.json"; - //using (StreamReader readerSniffingJson = File.OpenText(sniffingAddServer)) - //{ - // JObject jObjectSniffingJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerSniffingJson)); - // jObjectJson["inbounds"][0]["sniffing"] = jObjectSniffingJson["sniffing"]; - //} - - //设置uuid - jObjectJson["inbounds"][0]["settings"]["clients"][0]["id"] = ReceiveConfigurationParameters[2]; - - //除WebSocketTLSWeb/http2Web/VLESS+WebSocket+TLS+Web/VLESS+http2+TLS+Web模式外设置监听端口 - if (String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLS2Web") == false - && String.Equals(ReceiveConfigurationParameters[0], "http2Web") == false - && String.Equals(ReceiveConfigurationParameters[0], "VlessWebSocketTlsWeb") == false - && String.Equals(ReceiveConfigurationParameters[0], "VlessHttp2Web") == false) - { - jObjectJson["inbounds"][0]["port"] = int.Parse(ReceiveConfigurationParameters[1]); - } - - //设置VLESS协议的回落端口,指向Caddy - if (String.Equals(ReceiveConfigurationParameters[0], "VlessTcpTlsWeb") == true - || String.Equals(ReceiveConfigurationParameters[0], "VlessXtlsTcp") == true) - { - //设置Caddy随机监听的端口 - randomCaddyListenPort = GetRandomPort(); - - //指向Caddy监听的随机端口 - jObjectJson["inbounds"][0]["settings"]["fallbacks"][0]["dest"] = randomCaddyListenPort; - } - //设置VLESS+VMESS+Trojan+XTLS+TCP+WebSocket+Web协议 - if (String.Equals(ReceiveConfigurationParameters[0], "VlessVmessXtlsTcpWebSocketWeb") == true) - { - //设置Caddy随机监听的端口 - randomCaddyListenPort = GetRandomPort(); - - //指向Caddy监听的随机端口 - jObjectJson["inbounds"][1]["settings"]["fallbacks"][0]["dest"] = randomCaddyListenPort; - //设置其他模式的UUID - jObjectJson["inbounds"][1]["settings"]["clients"][0]["password"] = ReceiveConfigurationParameters[2]; - jObjectJson["inbounds"][2]["settings"]["clients"][0]["id"] = ReceiveConfigurationParameters[2]; - jObjectJson["inbounds"][3]["settings"]["clients"][0]["id"] = ReceiveConfigurationParameters[2]; - jObjectJson["inbounds"][4]["settings"]["clients"][0]["id"] = ReceiveConfigurationParameters[2]; - - //设置Vless回落与分流的Path - jObjectJson["inbounds"][0]["settings"]["fallbacks"][1]["path"] = ReceiveConfigurationParameters[3]; - jObjectJson["inbounds"][0]["settings"]["fallbacks"][2]["path"] = ReceiveConfigurationParameters[9]; - jObjectJson["inbounds"][0]["settings"]["fallbacks"][3]["path"] = ReceiveConfigurationParameters[6]; - - //设置Vless ws Path - jObjectJson["inbounds"][2]["streamSettings"]["wsSettings"]["path"] = ReceiveConfigurationParameters[3]; - //设置Vmess tcp Path - jObjectJson["inbounds"][3]["streamSettings"]["tcpSettings"]["header"]["request"]["path"][0] = ReceiveConfigurationParameters[9]; - //设置Vmess ws Path - jObjectJson["inbounds"][4]["streamSettings"]["wsSettings"]["path"] = ReceiveConfigurationParameters[6]; - - } - - //TLS自签证书/WebSocketTLS(自签证书)/http2自签证书模式下,使用v2ctl 生成自签证书 - if (String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLSselfSigned") == true - || String.Equals(ReceiveConfigurationParameters[0], "tcpTLSselfSigned") == true - || String.Equals(ReceiveConfigurationParameters[0], "http2selfSigned") == true) - { - string selfSignedCa = client.RunCommand("/usr/local/bin/xray tls cert --ca").Result; - JObject selfSignedCaJObject = JObject.Parse(selfSignedCa); - jObjectJson["inbounds"][0]["streamSettings"]["tlsSettings"]["certificates"][0] = selfSignedCaJObject; - } - - //如果是WebSocketTLSWeb/WebSocketTLS/WebSocketTLS(自签证书)/VLESS+WebSocket+TLS+Web模式,则设置路径 - if (String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLS") == true - || String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLSselfSigned") == true - || String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLS2Web") == true - || String.Equals(ReceiveConfigurationParameters[0], "VlessWebSocketTlsWeb") == true) - { - jObjectJson["inbounds"][0]["streamSettings"]["wsSettings"]["path"] = ReceiveConfigurationParameters[6]; - } - - //如果是Http2/http2Web/http2自签/VLESS+http2+TLS+Web模式下,设置路径 - if (String.Equals(ReceiveConfigurationParameters[0], "Http2") == true - || String.Equals(ReceiveConfigurationParameters[0], "http2Web") == true - || String.Equals(ReceiveConfigurationParameters[0], "http2selfSigned") == true - || String.Equals(ReceiveConfigurationParameters[0], "VlessHttp2Web") == true) - { - jObjectJson["inbounds"][0]["streamSettings"]["httpSettings"]["path"] = ReceiveConfigurationParameters[6]; - } - - //如果是Http2+Web/VLESS+http2+TLS+Web模式下,设置host - if (String.Equals(ReceiveConfigurationParameters[0], "http2Web") == true - || String.Equals(ReceiveConfigurationParameters[0], "VlessHttp2Web") == true) - { - jObjectJson["inbounds"][0]["streamSettings"]["httpSettings"]["host"][0] = ReceiveConfigurationParameters[4]; - } - - //mkcp模式下,设置伪装类型 - if (ReceiveConfigurationParameters[0].Contains("mKCP") == true) - { - jObjectJson["inbounds"][0]["streamSettings"]["kcpSettings"]["header"]["type"] = ReceiveConfigurationParameters[5]; - if (String.IsNullOrEmpty(ReceiveConfigurationParameters[6]) == false) - { - jObjectJson["inbounds"][0]["streamSettings"]["kcpSettings"]["seed"] = ReceiveConfigurationParameters[6]; - } - } - - //quic模式下设置伪装类型及密钥 - if (ReceiveConfigurationParameters[0].Contains("Quic") == true) - { - jObjectJson["inbounds"][0]["streamSettings"]["quicSettings"]["header"]["type"] = ReceiveConfigurationParameters[5]; - jObjectJson["inbounds"][0]["streamSettings"]["quicSettings"]["security"] = ReceiveConfigurationParameters[3]; - - if (String.Equals(ReceiveConfigurationParameters[3], "none") == true) - { - ReceiveConfigurationParameters[6] = ""; - } - jObjectJson["inbounds"][0]["streamSettings"]["quicSettings"]["key"] = ReceiveConfigurationParameters[6]; - } - - serverJson["inbounds"] = jObjectJson["inbounds"]; - } - - using (StreamWriter sw = new StreamWriter(@"config.json")) - { - sw.Write(serverJson.ToString()); - } - } - SetUpProgressBarProcessing(46); - return true; - } - - //安装证书到Xray 58--60 - //functionResult = CertInstallToXray(client); - //if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - private bool CertInstallToXray(SshClient client) - { - //****** "安装证书到Xray......" ******26 - SetUpProgressBarProcessing(58); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_IntallCertToSoft").ToString() + "Xray......"; - MainWindowsShowInfo(currentStatus); - - sshShellCommand = @"mkdir -p /usr/local/etc/xray/ssl"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = $"/root/.acme.sh/acme.sh --installcert -d {ReceiveConfigurationParameters[4]} --certpath /usr/local/etc/xray/ssl/xray_ssl.crt --keypath /usr/local/etc/xray/ssl/xray_ssl.key --capath /usr/local/etc/xray/ssl/xray_ssl.crt --reloadcmd \"systemctl restart xray\""; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"if [ ! -f ""/usr/local/etc/xray/ssl/xray_ssl.key"" ]; then echo ""0""; else echo ""1""; fi | head -n 1"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - if (currentShellCommandResult.Contains("1") == true) - { - //****** "证书成功安装到Xray!" ******27 - SetUpProgressBarProcessing(60); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_IntallCertToSoftOK").ToString() + "Xray!"; - MainWindowsShowInfo(currentStatus); - } - else - { - //****** "证书安装到Xray失败,原因未知,可以向开发者提问!" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_IntallCertToSoftFail").ToString() + - "Xray" + - Application.Current.FindResource("DisplayInstallInfo_InstallCertFailAsk").ToString(); - MainWindowsShowInfo(currentStatus); - return false; - } - - //设置私钥权限 - sshShellCommand = @"chmod 644 /usr/local/etc/xray/ssl/xray_ssl.key"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - return true; - } - - //生成Xray客户端配置 96--98 - //functionResult = GenerateClientConfiguration(); - //if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - private bool GenerateClientConfigurationXray() - { - //****** "生成客户端配置......" ******39 - SetUpProgressBarProcessing(96); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_GenerateClientConfig").ToString(); - MainWindowsShowInfo(currentStatus); - - string logConfigJson = $"{pwdir}" + @"TemplateConfg\xray\client\00_log\00_log.json"; - string apiConfigJson = $"{pwdir}" + @"TemplateConfg\xray\client\01_api\01_api.json"; - string dnsConfigJson = $"{pwdir}" + @"TemplateConfg\xray\client\02_dns\02_dns.json"; - string routingConfigJson = $"{pwdir}" + @"TemplateConfg\xray\client\03_routing\03_routing.json"; - string policyConfigJson = $"{pwdir}" + @"TemplateConfg\xray\client\04_policy\04_policy.json"; - string inboundsConfigJson = $"{pwdir}" + @"TemplateConfg\xray\client\05_inbounds\05_inbounds.json"; - string outboundsConfigJson = $"{pwdir}" + @"TemplateConfg\xray\client\06_outbounds\06_outbounds.json"; - string transportConfigJson = $"{pwdir}" + @"TemplateConfg\xray\client\07_transport\07_transport.json"; - string statsConfigJson = $"{pwdir}" + @"TemplateConfg\xray\client\08_stats\08_stats.json"; - string reverseConfigJson = $"{pwdir}" + @"TemplateConfg\xray\client\09_reverse\09_reverse.json"; - string baseConfigJson = $"{pwdir}" + @"TemplateConfg\xray\base.json"; - //Thread.Sleep(1000); - if (!Directory.Exists("xray_config"))//如果不存在就创建file文件夹      - { - Directory.CreateDirectory("xray_config");//创建该文件夹   - } - - using (StreamReader reader = File.OpenText(baseConfigJson)) - { - JObject clientJson = (JObject)JToken.ReadFrom(new JsonTextReader(reader)); - //读取"log" - using (StreamReader readerJson = File.OpenText(logConfigJson)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - clientJson["log"] = jObjectJson["log"]; - } - //读取"api" - using (StreamReader readerJson = File.OpenText(apiConfigJson)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - clientJson["api"] = jObjectJson["api"]; - } - //读取"dns" - using (StreamReader readerJson = File.OpenText(dnsConfigJson)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - clientJson["dns"] = jObjectJson["dns"]; - } - //读取"routing" - using (StreamReader readerJson = File.OpenText(routingConfigJson)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - clientJson["routing"] = jObjectJson["routing"]; - } - //读取"policy" - using (StreamReader readerJson = File.OpenText(policyConfigJson)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - clientJson["policy"] = jObjectJson["policy"]; - } - //读取"inbounds" - using (StreamReader readerJson = File.OpenText(inboundsConfigJson)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - clientJson["inbounds"] = jObjectJson["inbounds"]; - } - //读取"outbounds" - using (StreamReader readerJson = File.OpenText(outboundsConfigJson)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - clientJson["outbounds"] = jObjectJson["outbounds"]; - } - //读取"transport" - using (StreamReader readerJson = File.OpenText(transportConfigJson)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - clientJson["transport"] = jObjectJson["transport"]; - } - //读取"stats" - using (StreamReader readerJson = File.OpenText(statsConfigJson)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - clientJson["stats"] = jObjectJson["stats"]; - } - //读取"reverse" - using (StreamReader readerJson = File.OpenText(reverseConfigJson)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - clientJson["reverse"] = jObjectJson["reverse"]; - } - - //根据不同的安装方案,选择相应的客户端模板 - if (String.Equals(ReceiveConfigurationParameters[0], "VlessVmessXtlsTcpWebSocketWeb") == false) - { - #region 单模式方案 - //根据选择的不同模式,选择相应的配置文件 - if (String.Equals(ReceiveConfigurationParameters[0], "TCP") == true) - { - outboundsConfigJson = $"{pwdir}" + @"TemplateConfg\xray\client\06_outbounds\tcp_client_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "TCPhttp") == true) - { - outboundsConfigJson = $"{pwdir}" + @"TemplateConfg\xray\client\06_outbounds\tcp_http_client_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "tcpTLS") == true) - { - outboundsConfigJson = $"{pwdir}" + @"TemplateConfg\xray\client\06_outbounds\tcp_TLS_client_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "tcpTLSselfSigned") == true) - { - outboundsConfigJson = $"{pwdir}" + @"TemplateConfg\xray\client\06_outbounds\tcpTLSselfSigned_client_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "VlessXtlsTcp") == true) - { - outboundsConfigJson = $"{pwdir}" + @"TemplateConfg\xray\client\06_outbounds\vless_tcp_xtls_client_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "VlessTcpTlsWeb") == true) - { - outboundsConfigJson = $"{pwdir}" + @"TemplateConfg\xray\client\06_outbounds\vless_tcp_tls_caddy_cilent_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "VlessWebSocketTlsWeb") == true) - { - outboundsConfigJson = $"{pwdir}" + @"TemplateConfg\xray\client\06_outbounds\vless_ws_tls_client_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "VlessHttp2Web") == true) - { - outboundsConfigJson = $"{pwdir}" + @"TemplateConfg\xray\client\06_outbounds\vless_http2_tls_server_config.json"; - } - - else if (String.Equals(ReceiveConfigurationParameters[0], "webSocket") == true) - { - outboundsConfigJson = $"{pwdir}" + @"TemplateConfg\xray\client\06_outbounds\webSocket_client_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLS") == true) - { - outboundsConfigJson = $"{pwdir}" + @"TemplateConfg\xray\client\06_outbounds\WebSocket_TLS_client_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLSselfSigned") == true) - { - outboundsConfigJson = $"{pwdir}" + @"TemplateConfg\xray\client\06_outbounds\WebSocketTLS_selfSigned_client_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLS2Web") == true) - { - outboundsConfigJson = $"{pwdir}" + @"TemplateConfg\xray\client\06_outbounds\WebSocketTLSWeb_client_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "Http2") == true) - { - outboundsConfigJson = $"{pwdir}" + @"TemplateConfg\xray\client\06_outbounds\http2_client_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "http2Web") == true) - { - outboundsConfigJson = $"{pwdir}" + @"TemplateConfg\xray\client\06_outbounds\Http2Web_client_config.json"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "http2selfSigned") == true) - { - outboundsConfigJson = $"{pwdir}" + @"TemplateConfg\xray\client\06_outbounds\Http2selfSigned_client_config.json"; - } - //else if (String.Equals(ReceiveConfigurationParameters[0], "MkcpNone")|| String.Equals(ReceiveConfigurationParameters[0], "mKCP2SRTP")||String.Equals(ReceiveConfigurationParameters[0], "mKCPuTP")|| String.Equals(ReceiveConfigurationParameters[0], "mKCP2WechatVideo")|| String.Equals(ReceiveConfigurationParameters[0], "mKCP2DTLS")|| String.Equals(ReceiveConfigurationParameters[0], "mKCP2WireGuard")) - else if (ReceiveConfigurationParameters[0].Contains("mKCP") == true) - { - if (mKCPvlessIsSet == true) - { - outboundsConfigJson = $"{pwdir}" + @"TemplateConfg\xray\client\06_outbounds\vless_mkcp_client_config.json"; - } - else - { - outboundsConfigJson = $"{pwdir}" + @"TemplateConfg\xray\client\06_outbounds\mkcp_client_config.json"; - } - - } - // else if (String.Equals(ReceiveConfigurationParameters[0], "QuicNone") || String.Equals(ReceiveConfigurationParameters[0], "QuicSRTP") || String.Equals(ReceiveConfigurationParameters[0], "Quic2uTP") || String.Equals(ReceiveConfigurationParameters[0], "QuicWechatVideo") || String.Equals(ReceiveConfigurationParameters[0], "QuicDTLS") || String.Equals(ReceiveConfigurationParameters[0], "QuicWireGuard")) - else if (ReceiveConfigurationParameters[0].Contains("Quic") == true) - { - outboundsConfigJson = $"{pwdir}" + @"TemplateConfg\xray\client\06_outbounds\quic_client_config.json"; - } - - - //读取"相应模板的outbounds" - using (StreamReader readerJson = File.OpenText(outboundsConfigJson)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - - //设置客户端的地址/端口/id - jObjectJson["outbounds"][0]["settings"]["vnext"][0]["address"] = ReceiveConfigurationParameters[4]; - jObjectJson["outbounds"][0]["settings"]["vnext"][0]["port"] = int.Parse(ReceiveConfigurationParameters[1]); - jObjectJson["outbounds"][0]["settings"]["vnext"][0]["users"][0]["id"] = ReceiveConfigurationParameters[2]; - - - //设置WebSocket模式下的path - if (String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLS") == true - || String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLSselfSigned") == true - || String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLS2Web") == true - || String.Equals(ReceiveConfigurationParameters[0], "VlessWebSocketTlsWeb") == true) - { - jObjectJson["outbounds"][0]["streamSettings"]["wsSettings"]["path"] = ReceiveConfigurationParameters[6]; - } - - //设置http2模式下的path - if (String.Equals(ReceiveConfigurationParameters[0], "Http2") == true - || String.Equals(ReceiveConfigurationParameters[0], "http2Web") == true - || String.Equals(ReceiveConfigurationParameters[0], "http2selfSigned") == true - || String.Equals(ReceiveConfigurationParameters[0], "VlessHttp2Web") == true) - { - jObjectJson["outbounds"][0]["streamSettings"]["httpSettings"]["path"] = ReceiveConfigurationParameters[6]; - } - - //设置http2+TLS+Web/VLESS+http2+TLS+Web模式下的host - if (String.Equals(ReceiveConfigurationParameters[0], "http2Web") == true - || String.Equals(ReceiveConfigurationParameters[0], "VlessHttp2Web") == true) - { - jObjectJson["outbounds"][0]["streamSettings"]["httpSettings"]["host"][0] = ReceiveConfigurationParameters[4]; - } - - //设置VLESS+TCP+XTLS+Web模式下的serverName - //if (String.Equals(ReceiveConfigurationParameters[0], "VlessXtlsTcp") == true) - //{ - // jObjectJson["outbounds"][0]["streamSettings"]["xtlsSettings"]["serverName"] = ReceiveConfigurationParameters[4]; - //} - - //设置mkcp - if (ReceiveConfigurationParameters[0].Contains("mKCP") == true) - { - jObjectJson["outbounds"][0]["streamSettings"]["kcpSettings"]["header"]["type"] = ReceiveConfigurationParameters[5]; - if (String.IsNullOrEmpty(ReceiveConfigurationParameters[6]) == false) - { - jObjectJson["outbounds"][0]["streamSettings"]["kcpSettings"]["seed"] = ReceiveConfigurationParameters[6]; - } - } - - //设置QUIC - if (ReceiveConfigurationParameters[0].Contains("Quic") == true) - { - jObjectJson["outbounds"][0]["streamSettings"]["quicSettings"]["header"]["type"] = ReceiveConfigurationParameters[5]; - jObjectJson["outbounds"][0]["streamSettings"]["quicSettings"]["security"] = ReceiveConfigurationParameters[3]; - if (String.Equals(ReceiveConfigurationParameters[3], "none") == true) - { - ReceiveConfigurationParameters[6] = ""; - } - jObjectJson["outbounds"][0]["streamSettings"]["quicSettings"]["key"] = ReceiveConfigurationParameters[6]; - } - - clientJson["outbounds"] = jObjectJson["outbounds"]; - - } - - using (StreamWriter sw = new StreamWriter(@"xray_config\config.json")) - { - sw.Write(clientJson.ToString()); - } - - #endregion - - } - else - { - //复合方案所需要的配置文件 - //VLESS over TCP with XTLS模式 - string outboundsConfigJsons = $"{pwdir}" + @"TemplateConfg\xray\client\06_outbounds\vless_tcp_xtls_client_config.json"; - using (StreamReader readerJson = File.OpenText(outboundsConfigJsons)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - - //设置客户端的地址/端口/id - jObjectJson["outbounds"][0]["settings"]["vnext"][0]["address"] = ReceiveConfigurationParameters[4]; - jObjectJson["outbounds"][0]["settings"]["vnext"][0]["port"] = int.Parse(ReceiveConfigurationParameters[1]); - jObjectJson["outbounds"][0]["settings"]["vnext"][0]["users"][0]["id"] = ReceiveConfigurationParameters[2]; - - clientJson["outbounds"] = jObjectJson["outbounds"]; - if (!Directory.Exists(@"xray_config\vless_tcp_xtls_client_config"))//如果不存在就创建file文件夹      - { - Directory.CreateDirectory(@"xray_config\vless_tcp_xtls_client_config");//创建该文件夹   - } - using (StreamWriter sw = new StreamWriter(@"xray_config\vless_tcp_xtls_client_config\config.json")) - { - sw.Write(clientJson.ToString()); - } - } - - //VLESS over TCP with TLS模式 - outboundsConfigJsons = $"{pwdir}" + @"TemplateConfg\xray\client\06_outbounds\vless_tcp_tls_caddy_cilent_config.json"; - using (StreamReader readerJson = File.OpenText(outboundsConfigJsons)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - - //设置客户端的地址/端口/id - jObjectJson["outbounds"][0]["settings"]["vnext"][0]["address"] = ReceiveConfigurationParameters[4]; - jObjectJson["outbounds"][0]["settings"]["vnext"][0]["port"] = int.Parse(ReceiveConfigurationParameters[1]); - jObjectJson["outbounds"][0]["settings"]["vnext"][0]["users"][0]["id"] = ReceiveConfigurationParameters[2]; - - clientJson["outbounds"] = jObjectJson["outbounds"]; - if (!Directory.Exists(@"xray_config\vless_tcp_tls_client_config"))//如果不存在就创建file文件夹      - { - Directory.CreateDirectory(@"xray_config\vless_tcp_tls_client_config");//创建该文件夹   - } - using (StreamWriter sw = new StreamWriter(@"xray_config\vless_tcp_tls_client_config\config.json")) - { - sw.Write(clientJson.ToString()); - } - } - - //VLESS over WS with TLS 模式 - outboundsConfigJsons = $"{pwdir}" + @"TemplateConfg\xray\client\06_outbounds\vless_ws_tls_client_config.json"; - using (StreamReader readerJson = File.OpenText(outboundsConfigJsons)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - - //设置客户端的地址/端口/id - jObjectJson["outbounds"][0]["settings"]["vnext"][0]["address"] = ReceiveConfigurationParameters[4]; - jObjectJson["outbounds"][0]["settings"]["vnext"][0]["port"] = int.Parse(ReceiveConfigurationParameters[1]); - jObjectJson["outbounds"][0]["settings"]["vnext"][0]["users"][0]["id"] = ReceiveConfigurationParameters[2]; - jObjectJson["outbounds"][0]["streamSettings"]["wsSettings"]["path"] = ReceiveConfigurationParameters[3]; - - clientJson["outbounds"] = jObjectJson["outbounds"]; - if (!Directory.Exists(@"xray_config\vless_ws_tls_client_config"))//如果不存在就创建file文件夹      - { - Directory.CreateDirectory(@"xray_config\vless_ws_tls_client_config");//创建该文件夹   - } - using (StreamWriter sw = new StreamWriter(@"xray_config\vless_ws_tls_client_config\config.json")) - { - sw.Write(clientJson.ToString()); - } - } - - //VMess over TCP with TLS模式 - outboundsConfigJsons = $"{pwdir}" + @"TemplateConfg\xray\client\06_outbounds\vmess_tcp_tls_client_config.json"; - using (StreamReader readerJson = File.OpenText(outboundsConfigJsons)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - - //设置客户端的地址/端口/id - jObjectJson["outbounds"][0]["settings"]["vnext"][0]["address"] = ReceiveConfigurationParameters[4]; - jObjectJson["outbounds"][0]["settings"]["vnext"][0]["port"] = int.Parse(ReceiveConfigurationParameters[1]); - jObjectJson["outbounds"][0]["settings"]["vnext"][0]["users"][0]["id"] = ReceiveConfigurationParameters[2]; - jObjectJson["outbounds"][0]["streamSettings"]["tcpSettings"]["header"]["request"]["path"][0] = ReceiveConfigurationParameters[9]; - - clientJson["outbounds"] = jObjectJson["outbounds"]; - if (!Directory.Exists(@"xray_config\vmess_tcp_tls_client_config"))//如果不存在就创建file文件夹      - { - Directory.CreateDirectory(@"xray_config\vmess_tcp_tls_client_config");//创建该文件夹   - } - using (StreamWriter sw = new StreamWriter(@"xray_config\vmess_tcp_tls_client_config\config.json")) - { - sw.Write(clientJson.ToString()); - } - } - - //VMess over WS with TLS模式 - outboundsConfigJsons = $"{pwdir}" + @"TemplateConfg\xray\client\06_outbounds\WebSocketTLSWeb_client_config.json"; - using (StreamReader readerJson = File.OpenText(outboundsConfigJsons)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - - //设置客户端的地址/端口/id - jObjectJson["outbounds"][0]["settings"]["vnext"][0]["address"] = ReceiveConfigurationParameters[4]; - jObjectJson["outbounds"][0]["settings"]["vnext"][0]["port"] = int.Parse(ReceiveConfigurationParameters[1]); - jObjectJson["outbounds"][0]["settings"]["vnext"][0]["users"][0]["id"] = ReceiveConfigurationParameters[2]; - jObjectJson["outbounds"][0]["streamSettings"]["wsSettings"]["path"] = ReceiveConfigurationParameters[6]; - - clientJson["outbounds"] = jObjectJson["outbounds"]; - if (!Directory.Exists(@"xray_config\vmess_ws_tls_client_config"))//如果不存在就创建file文件夹      - { - Directory.CreateDirectory(@"xray_config\vmess_ws_tls_client_config");//创建该文件夹   - } - using (StreamWriter sw = new StreamWriter(@"xray_config\vmess_ws_tls_client_config\config.json")) - { - sw.Write(clientJson.ToString()); - } - } - - //Trojan over TCP with TLS模式 - outboundsConfigJsons = $"{pwdir}" + @"TemplateConfg\xray\client\06_outbounds\trojan_tcp_tls.json"; - using (StreamReader readerJson = File.OpenText(outboundsConfigJsons)) - { - JObject jObjectJson = (JObject)JToken.ReadFrom(new JsonTextReader(readerJson)); - - //设置客户端的地址/端口/id - jObjectJson["outbounds"][0]["settings"]["servers"][0]["address"] = ReceiveConfigurationParameters[4]; - jObjectJson["outbounds"][0]["settings"]["servers"][0]["port"] = int.Parse(ReceiveConfigurationParameters[1]); - jObjectJson["outbounds"][0]["settings"]["servers"][0]["password"] = ReceiveConfigurationParameters[2]; - jObjectJson["outbounds"][0]["streamSettings"]["tlsSettings"]["serverName"] = ReceiveConfigurationParameters[4]; - - clientJson["outbounds"] = jObjectJson["outbounds"]; - if (!Directory.Exists(@"xray_config\trojan_tcp_tls_client_config"))//如果不存在就创建file文件夹      - { - Directory.CreateDirectory(@"xray_config\trojan_tcp_tls_client_config");//创建该文件夹   - } - using (StreamWriter sw = new StreamWriter(@"xray_config\trojan_tcp_tls_client_config\config.json")) - { - sw.Write(clientJson.ToString()); - } - } - - } - } - SetUpProgressBarProcessing(98); - return true; - } - - - #endregion - - //检测升级远程主机端的Xray版本 - private void ButtonUpdateXray_Click(object sender, RoutedEventArgs e) - { - ConnectionInfo connectionInfo = GenerateConnectionInfo(); - if (connectionInfo == null) - { - //****** "远程主机连接信息有误,请检查!" ****** - MessageBox.Show(Application.Current.FindResource("MessageBoxShow_ErrorHostConnection").ToString()); - return; - } - installationDegree = 0; - TextBoxMonitorCommandResults.Text = ""; - Thread thread = new Thread(() => UpdateXray(connectionInfo)); - thread.SetApartmentState(ApartmentState.STA); - thread.Start(); - } - - //升级Xray主程序 - private void UpdateXray(ConnectionInfo connectionInfo) - { - functionResult = true; - onlyIpv6 = false; - getApt = false; - getDnf = false; - getYum = false; - - //******"正在登录远程主机......"****** - SetUpProgressBarProcessing(1); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_Login").ToString(); - MainWindowsShowInfo(currentStatus); - - try - { - #region 主机指纹,暂未启用 - //byte[] expectedFingerPrint = new byte[] { - // 0x66, 0x31, 0xaf, 0x00, 0x54, 0xb9, 0x87, 0x31, - // 0xff, 0x58, 0x1c, 0x31, 0xb1, 0xa2, 0x4c, 0x6b - // }; - #endregion - using (var client = new SshClient(connectionInfo)) - - { - #region ssh登录验证主机指纹代码块,暂未启用 - // client.HostKeyReceived += (sender, e) => - // { - // if (expectedFingerPrint.Length == e.FingerPrint.Length) - // { - // for (var i = 0; i < expectedFingerPrint.Length; i++) - // { - // if (expectedFingerPrint[i] != e.FingerPrint[i]) - // { - // e.CanTrust = false; - // break; - // } - // } - // } - // else - // { - // e.CanTrust = false; - // } - // }; - #endregion - - client.Connect(); - if (client.IsConnected == true) - { - //******"主机登录成功"****** - SetUpProgressBarProcessing(3); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_LoginSuccessful").ToString(); - MainWindowsShowInfo(currentStatus); - } - - //检测root权限 5--7 - functionResult = RootAuthorityDetect(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - - //******"检测系统是否已经安装Xray......"****** - SetUpProgressBarProcessing(20); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_TestExistSoft").ToString() + "Xray......"; - MainWindowsShowInfo(currentStatus); - - //Thread.Sleep(1000); - //检测是否安装Xray - //sshShellCommand = @"find / -name xray"; - //sshShellCommand = @"if [[ -f /usr/local/bin/xray ]];then echo '1';else echo '0'; fi"; - //currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //if (currentShellCommandResult.Contains("/usr/local/bin/xray") == false) - //if (currentShellCommandResult.Trim().Equals("0") == true) - functionResult = FileCheckExists(client, @"/usr/local/bin/xray"); - if (functionResult == false) - { - //******"退出!原因:远程主机未安装Xray"****** - currentStatus = Application.Current.FindResource("MessageBoxShow_ErrorUpgradeSoftNotInstall").ToString() + "Xray!"; - MainWindowsShowInfo(currentStatus); - MessageBox.Show(currentStatus); - - client.Disconnect(); - return; - - } - - //sshcmd = @"/usr/local/bin/xray -version | head -n 1 | cut -d "" "" -f2"; - sshShellCommand = @"/usr/local/bin/xray -version | head -n 1 | cut -d "" "" -f2"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - string xrayCurrentVersion = currentShellCommandResult;//不含字母v - - //sshcmd = @"curl -H ""Accept: application/json"" -H ""User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0"" -s ""https://api.github.com/repos/v2fly/xray-core/releases/latest"" --connect-timeout 10| grep 'tag_name' | cut -d\"" -f4"; - sshShellCommand = @"curl -H ""Accept: application/json"" -H ""User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0"" -sS ""https://api.github.com/repos/XTLS/Xray-core/releases/latest"" --connect-timeout 10 | grep 'tag_name' | cut -d\"" -f4"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - string xrayNewVersion = currentShellCommandResult;//包含字母v - - if (xrayNewVersion.Contains(xrayCurrentVersion) == false) - { - MessageBoxResult messageBoxResult = MessageBox.Show( - //****** "远程主机当前版本为:v" ****** - Application.Current.FindResource("DisplayInstallInfo_CurrentVersion").ToString() + - $"{xrayCurrentVersion}\n" + - //****** "最新版本为:" ****** - Application.Current.FindResource("DisplayInstallInfo_NewVersion").ToString() + - $"{xrayNewVersion}\n" + - //****** "是否升级为最新版本?" ****** - Application.Current.FindResource("DisplayInstallInfo_IsOrNoUpgradeNewVersion").ToString(), "", MessageBoxButton.YesNo, MessageBoxImage.Question); - if (messageBoxResult == MessageBoxResult.Yes) - { - //****** "正在升级到最新版本......" ****** - SetUpProgressBarProcessing(60); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_StartUpgradeNewVersion").ToString(); - MainWindowsShowInfo(currentStatus); - - //client.RunCommand(@"bash <(curl -L -s https://raw.githubusercontent.com/v2fly/fhs-install-xray/master/install-release.sh)"); - sshShellCommand = $"bash <(curl -L -s https://raw.githubusercontent.com/XTLS/Xray-install/main/install-release.sh)"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - SetUpProgressBarProcessing(80); - //sshcmd = @"/usr/local/bin/xray -version | head -n 1 | cut -d "" "" -f2"; - sshShellCommand = @"/usr/local/bin/xray -version | head -n 1 | cut -d "" "" -f2"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - xrayCurrentVersion = currentShellCommandResult;//不含字母v - if (xrayNewVersion.Contains(xrayCurrentVersion) == true) - { - //****** "升级成功!当前已是最新版本!" ****** - SetUpProgressBarProcessing(100); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_UpgradeNewVersionOK").ToString(); - MainWindowsShowInfo(currentStatus); - MessageBox.Show(currentStatus); - } - else - { - //****** "升级失败,原因未知,请向开发者提问!" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_UpgradeNewVersionFail").ToString(); - MainWindowsShowInfo(currentStatus); - MessageBox.Show(currentStatus); - } - } - else - { - //****** "升级取消,退出!" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_UpgradeVersionCancel").ToString(); - MainWindowsShowInfo(currentStatus); - - client.Disconnect(); - return; - } - } - else - { - //****** "远程主机当前已是最新版本:" ****** - SetUpProgressBarProcessing(100); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_IsNewVersion").ToString() + - $"{xrayNewVersion}\n" + - //****** "无需升级!退出!" ****** - Application.Current.FindResource("DisplayInstallInfo_NotUpgradeVersion").ToString(); - MessageBox.Show(currentStatus); - MainWindowsShowInfo(currentStatus); - } - - client.Disconnect(); - return; - } - } - catch (Exception ex1)//例外处理 - #region 例外处理 - { - ProcessException(ex1.Message); - - //****** "主机登录失败!" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_LoginFailed").ToString(); - MainWindowsShowInfo(currentStatus); - } - #endregion - - } - - #endregion - - #region Trojan-go相关 - - //打开设置TrojanGo参数窗口 - private void ButtonTrojanGoTemplate_Click(object sender, RoutedEventArgs e) - { - for (int i = 0; i != ReceiveConfigurationParameters.Length; i++) - - { - 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[6]; //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) - { - ConnectionInfo connectionInfo = GenerateConnectionInfo(); - if (connectionInfo == null) - { - //****** "远程主机连接信息有误,请检查!" ****** - MessageBox.Show(Application.Current.FindResource("MessageBoxShow_ErrorHostConnection").ToString()); - return; - } - - if (String.IsNullOrEmpty(ReceiveConfigurationParameters[0]) == true) - { - //******"请先选择配置模板!"****** - MessageBox.Show(Application.Current.FindResource("MessageBoxShow_ChooseTemplate").ToString()); - return; - } - if (String.IsNullOrEmpty(ReceiveConfigurationParameters[4]) == true) - { - //****** "域名不能为空,请检查相关参数设置!" ****** - MessageBox.Show(Application.Current.FindResource("MessageBoxShow_DomainNotEmpty").ToString()); - return; - } - installationDegree = 0; - TextBoxMonitorCommandResults.Text = ""; - Thread thread = new Thread(() => StartSetUpTrojanGo(connectionInfo)); - thread.SetApartmentState(ApartmentState.STA); - thread.Start(); - } - - //登录远程主机布署Trojan-Go程序 - private void StartSetUpTrojanGo(ConnectionInfo connectionInfo) - { - functionResult = true; - onlyIpv6 = false; - getApt = false; - getDnf = false; - getYum = false; - - //******"正在登录远程主机......"****** - SetUpProgressBarProcessing(1); - string currentStatus = Application.Current.FindResource("DisplayInstallInfo_Login").ToString(); - MainWindowsShowInfo(currentStatus); - - try - { - #region 主机指纹,暂未启用 - //byte[] expectedFingerPrint = new byte[] { - // 0x66, 0x31, 0xaf, 0x00, 0x54, 0xb9, 0x87, 0x31, - // 0xff, 0x58, 0x1c, 0x31, 0xb1, 0xa2, 0x4c, 0x6b - // }; - #endregion - using (var client = new SshClient(connectionInfo)) - - { - #region ssh登录验证主机指纹代码块,暂未启用 - // client.HostKeyReceived += (sender, e) => - // { - // if (expectedFingerPrint.Length == e.FingerPrint.Length) - // { - // for (var i = 0; i < expectedFingerPrint.Length; i++) - // { - // if (expectedFingerPrint[i] != e.FingerPrint[i]) - // { - // e.CanTrust = false; - // break; - // } - // } - // } - // else - // { - // e.CanTrust = false; - // } - // }; - #endregion - - client.Connect(); - if (client.IsConnected == true) - { - //******"主机登录成功"****** - SetUpProgressBarProcessing(3); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_LoginSuccessful").ToString(); - MainWindowsShowInfo(currentStatus); - - } - - //检测root权限 5--7 - functionResult = RootAuthorityDetect(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //检测是否已安装代理 8--10 - functionResult = SoftInstalledIsNoYes(client, "trojan-go", @"/usr/local/bin/trojan-go"); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //检测关闭Selinux及系统组件是否齐全(apt-get/yum/dnf/systemctl)11--30 - //安装依赖软件,检测端口,防火墙开启端口 - functionResult = ShutDownSelinuxAndSysComponentsDetect(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //检测域名是否解析到当前IP上 34---36 - functionResult = DomainResolutionCurrentIPDetect(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //下载脚本安装Trojan-go 37--40 - functionResult = ProxySoftInstall(client, @"Trojan-go", @"https://raw.githubusercontent.com/proxysu/shellscript/master/trojan-go.sh"); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - //functionResult = TrojanGoInstall(client); - //if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //程序是否安装成功检测并设置开机启动 41--43 - functionResult = SoftInstalledSuccessOrFail(client, "trojan-go", @"/usr/local/bin/trojan-go"); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //生成Trojan-go服务端配置 44--46 - functionResult = GenerateServerConfigurationTrojanGo(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //上传配置文件 - string upLoadPath = "/usr/local/etc/trojan-go/config.json"; - UploadConfig(connectionInfo, @"config.json", upLoadPath); - File.Delete(@"config.json"); - - //acme.sh安装与申请证书 51--57 - functionResult = AcmeShInstall(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - - //****** "安装证书到Trojan-go......" ****** - SetUpProgressBarProcessing(58); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_IntallCertToSoft").ToString() + "Trojan-go......"; - MainWindowsShowInfo(currentStatus); - - sshShellCommand = $"/root/.acme.sh/acme.sh --installcert -d {ReceiveConfigurationParameters[4]} --certpath /usr/local/etc/trojan-go/trojan-go.crt --keypath /usr/local/etc/trojan-go/trojan-go.key --capath /usr/local/etc/trojan-go/trojan-go.crt --reloadcmd \"systemctl restart trojan-go\""; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"if [ ! -f ""/usr/local/etc/trojan-go/trojan-go.key"" ]; then echo ""0""; else echo ""1""; fi | head -n 1"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - if (currentShellCommandResult.Contains("1") == true) - { - //****** "证书成功安装到Trojan-go!" ****** - SetUpProgressBarProcessing(60); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_IntallCertToSoftOK").ToString() + "Trojan-go!"; - MainWindowsShowInfo(currentStatus); - } - else - { - //****** "证书安装到Trojan-go失败,原因未知,可以向开发者提问!" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_IntallCertToSoftFail").ToString() + - "Trojan-go" + - Application.Current.FindResource("DisplayInstallInfo_InstallCertFailAsk").ToString(); - MainWindowsShowInfo(currentStatus); - client.Disconnect(); - return; - } - - //设置证书权限 - sshShellCommand = @"chmod 644 /usr/local/etc/trojan-go/trojan-go.key"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //Caddy安装与检测安装是否成功 61--66 - functionResult = CaddyInstall(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - - //****** "上传Caddy配置文件......" ****** - SetUpProgressBarProcessing(67); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_UploadCaddyConfig").ToString(); - MainWindowsShowInfo(currentStatus); - - sshShellCommand = @"mv /etc/caddy/Caddyfile /etc/caddy/Caddyfile.bak"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - string caddyConfig = $"{pwdir}" + @"TemplateConfg\trojan-go\trojan-go.caddyfile"; - - upLoadPath = "/etc/caddy/Caddyfile"; - UploadConfig(connectionInfo, caddyConfig, upLoadPath); - - //设置Caddy配置文件 - functionResult = SetCaddyfile(client, upLoadPath); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - - //****** "Caddy配置文件上传成功,OK!" ****** - SetUpProgressBarProcessing(70); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_UploadCaddyConfigOK").ToString(); - MainWindowsShowInfo(currentStatus); - - //程序启动检测Caddy - functionResult = SoftStartDetect(client, "caddy", @"/usr/bin/caddy"); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //程序启动检测Trojan-go - functionResult = SoftStartDetect(client, "trojan-go", @"/usr/local/bin/trojan-go"); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //检测BBR,满足条件并启动 90--95 - functionResult = DetectBBRandEnable(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - client.Disconnect();//断开服务器ssh连接 - - - //****** "生成客户端配置......" ****** - SetUpProgressBarProcessing(96); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_GenerateClientConfig").ToString(); - MainWindowsShowInfo(currentStatus); - - if (!Directory.Exists("trojan-go_config"))//如果不存在就创建file文件夹      - { - Directory.CreateDirectory("trojan-go_config");//创建该文件夹   - } - - string clientConfig = $"{pwdir}" + @"TemplateConfg\trojan-go\trojan-go_all_config.json"; //生成的客户端配置文件 - - using (StreamReader reader = File.OpenText(clientConfig)) - { - JObject clientJson = (JObject)JToken.ReadFrom(new JsonTextReader(reader)); - clientJson["run_type"] = "client"; - clientJson["local_addr"] = "127.0.0.1"; - clientJson["local_port"] = 1080; - clientJson["remote_addr"] = ReceiveConfigurationParameters[4]; - clientJson["remote_port"] = 443; - //设置密码 - clientJson["password"][0] = ReceiveConfigurationParameters[2]; - clientJson["ssl"]["sni"] = ReceiveConfigurationParameters[4]; - //如果是WebSocket协议则设置路径 - if (String.Equals(ReceiveConfigurationParameters[0], "TrojanGoWebSocketTLS2Web")) - { - clientJson["websocket"]["enabled"] = true; - clientJson["websocket"]["path"] = ReceiveConfigurationParameters[6]; - clientJson["websocket"]["host"] = ReceiveConfigurationParameters[4]; - } - //如果开启了mux,设置客户端配置文件参数 - if (String.Equals(ReceiveConfigurationParameters[9], "true") == true) - { - clientJson["mux"]["enabled"] = true; - clientJson["mux"]["concurrency"] = int.Parse(ReceiveConfigurationParameters[3]); - clientJson["mux"]["idle_timeout"] = int.Parse(ReceiveConfigurationParameters[5]); - //if(int.TryParse(ReceiveConfigurationParameters[3],out int value) == true) - //{ - // clientJson["mux"]["concurrency"] = value; - //} - //if (int.TryParse(ReceiveConfigurationParameters[5], out int value2) == true) - //{ - // clientJson["mux"]["idle_timeout"] = value2; - //} - //clientJson["mux"]["idle_timeout"] = int.TryParse(ReceiveConfigurationParameters[5], out int value2); - //clientJson["mux"]["idle_timeout"] = value2; - } - - using (StreamWriter sw = new StreamWriter(@"trojan-go_config\config.json")) - { - sw.Write(clientJson.ToString()); - } - } - - //****** "Trojan-go安装成功,祝你玩的愉快!!" ****** - SetUpProgressBarProcessing(100); - currentStatus = "Trojan-go" + Application.Current.FindResource("DisplayInstallInfo_ProxyInstalledOK").ToString(); - MainWindowsShowInfo(currentStatus); - - //显示服务端连接参数 - proxyType = "TrojanGo"; - - ResultClientInformation resultClientInformation = new ResultClientInformation(); - resultClientInformation.ShowDialog(); - return; - } - } - catch (Exception ex1)//例外处理 - #region 例外处理 - { - ProcessException(ex1.Message); - - //****** "安装失败!" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_LoginFailed").ToString(); - MainWindowsShowInfo(currentStatus); - } - #endregion - - } - - //下载脚本安装Trojan-go 37--40 - //functionResult = TrojanGoInstall(client); - //if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - //private bool TrojanGoInstall(SshClient client) - //{ - // //****** "系统环境检测完毕,符合安装要求,开始布署......" ****** - // SetUpProgressBarProcessing(37); - // currentStatus = Application.Current.FindResource("DisplayInstallInfo_StartInstalling").ToString(); - // MainWindowsShowInfo(currentStatus); - - // //****** "正在安装Trojan-go......" ****** - // SetUpProgressBarProcessing(38); - // currentStatus = Application.Current.FindResource("DisplayInstallInfo_StartInstallSoft").ToString() + "Trojan-go......"; - // MainWindowsShowInfo(currentStatus); - - // sshShellCommand = $"curl -o /tmp/trojan-go.sh https://raw.githubusercontent.com/proxysu/shellscript/master/trojan-go.sh"; - // currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - // functionResult = FileCheckExists(client, @"/tmp/trojan-go.sh"); - // if (functionResult == true) - // { - // sshShellCommand = @"yes | bash /tmp/trojan-go.sh -f"; - // currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - // sshShellCommand = @"rm -f /tmp/trojan-go.sh"; - // currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - // } - // else - // { - // //***安装脚本下载失败!*** - // currentStatus = Application.Current.FindResource("DisplayInstallInfo_DownloadScriptFailed").ToString(); - // MainWindowsShowInfo(currentStatus); - // return false; - // } - - - // SetUpProgressBarProcessing(40); - // return true; - //} - - //生成Trojan-go服务端配置 44--46 - //functionResult = GenerateServerConfigurationTrojanGo(client); - //if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - private bool GenerateServerConfigurationTrojanGo(SshClient client) - { - //备份原配置文件 - sshShellCommand = @"mv /etc/trojan-go/config.json /etc/trojan-go/config.json.1"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //****** "安装完毕,上传配置文件......" ****** - SetUpProgressBarProcessing(44); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_UploadSoftConfig").ToString(); - MainWindowsShowInfo(currentStatus); - - string serverConfig = $"{pwdir}" + @"TemplateConfg\trojan-go\trojan-go_all_config.json"; //服务端配置文件 - //string upLoadPath = @"/usr/local/etc/trojan-go/config.json"; //服务端文件位置 - - //生成服务端配置 - using (StreamReader reader = File.OpenText(serverConfig)) - { - //设置Caddy随机监听的端口,用于Trojan-go,Trojan,V2Ray vless TLS - //Random random = new Random(); - randomCaddyListenPort = GetRandomPort(); - - 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"] = randomCaddyListenPort; - //设置密码 - serverJson["password"][0] = ReceiveConfigurationParameters[2]; - //设置证书 - serverJson["ssl"]["cert"] = "/usr/local/etc/trojan-go/trojan-go.crt"; - serverJson["ssl"]["key"] = "/usr/local/etc/trojan-go/trojan-go.key"; - serverJson["ssl"]["sni"] = ReceiveConfigurationParameters[4]; - - if (String.Equals(ReceiveConfigurationParameters[0], "TrojanGoWebSocketTLS2Web")) - { - serverJson["websocket"]["enabled"] = true; - serverJson["websocket"]["path"] = ReceiveConfigurationParameters[6]; - serverJson["websocket"]["host"] = ReceiveConfigurationParameters[4]; - } - - using (StreamWriter sw = new StreamWriter(@"config.json")) - { - sw.Write(serverJson.ToString()); - } - } - - - SetUpProgressBarProcessing(46); - return true; - } - - - //检测升级Trojan-Go版本传递参数 - private void ButtonUpdateTrojanGo_Click(object sender, RoutedEventArgs e) - { - ConnectionInfo connectionInfo = GenerateConnectionInfo(); - if (connectionInfo == null) - { - //****** "远程主机连接信息有误,请检查!" ****** - MessageBox.Show(Application.Current.FindResource("MessageBoxShow_ErrorHostConnection").ToString()); - return; - } - installationDegree = 0; - Thread thread = new Thread(() => UpdateTojanGo(connectionInfo)); - thread.SetApartmentState(ApartmentState.STA); - thread.Start(); - } - - //升级Trojan-go主程序 - private void UpdateTojanGo(ConnectionInfo connectionInfo) - { - functionResult = true; - onlyIpv6 = false; - getApt = false; - getDnf = false; - getYum = false; - - //******"正在登录远程主机......"****** - SetUpProgressBarProcessing(1); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_Login").ToString(); - MainWindowsShowInfo(currentStatus); - - try - { - #region 主机指纹,暂未启用 - //byte[] expectedFingerPrint = new byte[] { - // 0x66, 0x31, 0xaf, 0x00, 0x54, 0xb9, 0x87, 0x31, - // 0xff, 0x58, 0x1c, 0x31, 0xb1, 0xa2, 0x4c, 0x6b - // }; - #endregion - using (var client = new SshClient(connectionInfo)) - - { - #region ssh登录验证主机指纹代码块,暂未启用 - // client.HostKeyReceived += (sender, e) => - // { - // if (expectedFingerPrint.Length == e.FingerPrint.Length) - // { - // for (var i = 0; i < expectedFingerPrint.Length; i++) - // { - // if (expectedFingerPrint[i] != e.FingerPrint[i]) - // { - // e.CanTrust = false; - // break; - // } - // } - // } - // else - // { - // e.CanTrust = false; - // } - // }; - #endregion - - client.Connect(); - if (client.IsConnected == true) - { - //******"主机登录成功"****** - SetUpProgressBarProcessing(3); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_LoginSuccessful").ToString(); - MainWindowsShowInfo(currentStatus); - } - - //检测root权限 5--7 - functionResult = RootAuthorityDetect(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - - //******"检测系统是否已经安装Trojan-go......"****** - SetUpProgressBarProcessing(20); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_TestExistSoft").ToString() + "Trojan-go......"; - MainWindowsShowInfo(currentStatus); - - //string cmdTestTrojanInstalled = @"find / -name trojan-go"; - - //sshShellCommand = @"find / -name trojan-go"; - //sshShellCommand = @"if [[ -f /usr/local/bin/trojan-go ]];then echo '1';else echo '0'; fi"; - //currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //if (currentShellCommandResult.Contains("/usr/local/bin/trojan-go") == false) - //if (currentShellCommandResult.Trim().Equals("0") == true) - functionResult = FileCheckExists(client, @"/usr/local/bin/trojan-go"); - if (functionResult == false) - { - //******"退出!原因:远程主机未安装Trojan-go"****** - currentStatus = Application.Current.FindResource("MessageBoxShow_ErrorUpgradeSoftNotInstall").ToString() + "Trojan-go!"; - MainWindowsShowInfo(currentStatus); - MessageBox.Show(currentStatus); - client.Disconnect(); - return; - - } - SetUpProgressBarProcessing(40); - //获取当前安装的版本 - //string sshcmd = @"echo ""$(/usr/local/bin/trojan-go -version)"" | head -n 1 | cut -d "" "" -f2"; - sshShellCommand = @"echo ""$(/usr/local/bin/trojan-go -version)"" | head -n 1 | cut -d "" "" -f2"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - string trojanCurrentVersion = currentShellCommandResult;//含字母v - - //获取最新版本 - //sshcmd = @"curl -s https://api.github.com/repos/p4gefau1t/trojan-go/tags | grep 'name' | cut -d\"" -f4 | head -1"; - sshShellCommand = @"curl -s https://api.github.com/repos/p4gefau1t/trojan-go/tags | grep 'name' | cut -d\"" -f4 | head -1"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - string trojanNewVersion = currentShellCommandResult;//含字母v - - if (trojanNewVersion.Equals(trojanCurrentVersion) == false) - { - MessageBoxResult messageBoxResult = MessageBox.Show( - //****** "远程主机当前版本为:v" ****** - Application.Current.FindResource("DisplayInstallInfo_CurrentVersion").ToString() + - $"{trojanCurrentVersion}\n" + - //****** "最新版本为:" ****** - Application.Current.FindResource("DisplayInstallInfo_NewVersion").ToString() + - $"{trojanNewVersion}\n" + - //****** "是否升级为最新版本?" ****** - Application.Current.FindResource("DisplayInstallInfo_IsOrNoUpgradeNewVersion").ToString(), "", MessageBoxButton.YesNo, MessageBoxImage.Question); - if (messageBoxResult == MessageBoxResult.Yes) - { - //****** "正在升级到最新版本......" ****** - SetUpProgressBarProcessing(60); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_StartUpgradeNewVersion").ToString(); - MainWindowsShowInfo(currentStatus); - - //备份配置文件 - //sshcmd = @"mv /usr/local/etc/trojan/config.json /usr/local/etc/trojan/config.json.bak"; - //client.RunCommand(sshcmd); - //升级Trojan-Go主程序 - //client.RunCommand("curl -o /tmp/trojan-go.sh https://raw.githubusercontent.com/proxysu/shellscript/master/trojan-go.sh"); - //client.RunCommand("yes | bash /tmp/trojan-go.sh -f"); - - saveShellScriptFileName = GenerateRandomScriptFileName(GenerateRandomStr(10)); - - sshShellCommand = $"curl -o {saveShellScriptFileName} https://raw.githubusercontent.com/proxysu/shellscript/master/trojan-go.sh"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - functionResult = FileCheckExists(client, $"{saveShellScriptFileName}"); - if (functionResult == false) - { - //***文件下载失败!*** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_DownloadScriptFailed").ToString(); - MainWindowsShowInfo(currentStatus); - return; - } - - sshShellCommand = $"yes | bash {saveShellScriptFileName}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = $"rm -f {saveShellScriptFileName}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - SetUpProgressBarProcessing(80); - - //获取升级后的版本 - //sshcmd = @"echo ""$(/usr/local/bin/trojan-go -version)"" | head -n 1 | cut -d "" "" -f2"; - sshShellCommand = @"echo ""$(/usr/local/bin/trojan-go -version)"" | head -n 1 | cut -d "" "" -f2"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - trojanCurrentVersion = currentShellCommandResult;//含字母v - if (trojanNewVersion.Equals(trojanCurrentVersion) == true) - { - //恢复原来的配置文件备份 - //sshcmd = @"rm -f /usr/local/etc/trojan/config.json"; - //client.RunCommand(sshcmd); - //sshcmd = @"mv /usr/local/etc/trojan/config.json.bak /usr/local/etc/trojan/config.json"; - //client.RunCommand(sshcmd); - - //****** "升级成功!当前已是最新版本!" ****** - MessageBox.Show(Application.Current.FindResource("DisplayInstallInfo_UpgradeNewVersionOK").ToString()); - //****** "升级成功!当前已是最新版本!" ****** - SetUpProgressBarProcessing(100); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_UpgradeNewVersionOK").ToString(); - MainWindowsShowInfo(currentStatus); - } - else - { - //****** "升级失败,原因未知,请向开发者提问!" ****** - MessageBox.Show(Application.Current.FindResource("DisplayInstallInfo_UpgradeNewVersionFail").ToString()); - //****** "升级失败,原因未知,请向开发者提问!" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_UpgradeNewVersionFail").ToString(); - MainWindowsShowInfo(currentStatus); - - client.Disconnect(); - return; - } - } - - else - { - //****** "升级取消,退出!" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_UpgradeVersionCancel").ToString(); - MainWindowsShowInfo(currentStatus); - - client.Disconnect(); - return; - } - } - else - { - //****** "远程主机当前已是最新版本:" ****** - SetUpProgressBarProcessing(100); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_IsNewVersion").ToString() + - $"{trojanNewVersion}\n" + - //****** "无需升级!退出!" ****** - Application.Current.FindResource("DisplayInstallInfo_NotUpgradeVersion").ToString(); - MessageBox.Show(currentStatus); - MainWindowsShowInfo(currentStatus); - } - - client.Disconnect(); - return; - } - } - catch (Exception ex1)//例外处理 - #region 例外处理 - { - ProcessException(ex1.Message); - - //****** "主机登录失败!" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_LoginFailed").ToString(); - MainWindowsShowInfo(currentStatus); - } - #endregion - - } - #endregion - - #region Trojan相关 - - //Trojan参数传递 - private void ButtonTrojanSetUp_Click(object sender, RoutedEventArgs e) - { - ConnectionInfo connectionInfo = GenerateConnectionInfo(); - if (connectionInfo == null) - { - //****** "远程主机连接信息有误,请检查!" ****** - MessageBox.Show(Application.Current.FindResource("MessageBoxShow_ErrorHostConnection").ToString()); - return; - } - //清空参数空间 - for (int i = 0; i != ReceiveConfigurationParameters.Length; i++) - - { - ReceiveConfigurationParameters[i] = ""; - } - bool preDomainMask = ClassModel.PreDomainMask(TextBoxTrojanSites.Text); - bool domainNotEmpty = ClassModel.TestDomainIsEmpty(TextBoxTrojanHostDomain.Text); - //if (string.IsNullOrEmpty(PreTrim(TextBoxTrojanHostDomain.Text)) == true) - //{ - // //****** "域名不能为空,请检查相关参数设置!" ****** - // MessageBox.Show(Application.Current.FindResource("MessageBoxShow_DomainNotEmpty").ToString()); - // return; - //} - if (domainNotEmpty == false || preDomainMask == false) - { - return; - } - //传递模板类型 - ReceiveConfigurationParameters[0] = "TrojanTLS2Web"; - - //传递域名 - ReceiveConfigurationParameters[4] = PreTrim(TextBoxTrojanHostDomain.Text); - //传递伪装网站 - ReceiveConfigurationParameters[7] = ClassModel.DisguiseURLprocessing(PreTrim(TextBoxTrojanSites.Text)); - - //传递服务端口 - ReceiveConfigurationParameters[1] = "443"; - //传递密码(uuid) - ReceiveConfigurationParameters[2] = TextBoxTrojanPassword.Text.ToString(); - - //启动布署进程 - installationDegree = 0; - TextBoxMonitorCommandResults.Text = ""; - Thread thread = new Thread(() => StartSetUpTrojan(connectionInfo)); - thread.SetApartmentState(ApartmentState.STA); - thread.Start(); - } - - //登录远程主机布署Trojan程序 - private void StartSetUpTrojan(ConnectionInfo connectionInfo) - { - functionResult = true; - onlyIpv6 = false; - getApt = false; - getDnf = false; - getYum = false; - - //******"正在登录远程主机......"****** - SetUpProgressBarProcessing(1); - string currentStatus = Application.Current.FindResource("DisplayInstallInfo_Login").ToString(); - MainWindowsShowInfo(currentStatus); - - try - { - #region 主机指纹,暂未启用 - //byte[] expectedFingerPrint = new byte[] { - // 0x66, 0x31, 0xaf, 0x00, 0x54, 0xb9, 0x87, 0x31, - // 0xff, 0x58, 0x1c, 0x31, 0xb1, 0xa2, 0x4c, 0x6b - // }; - #endregion - using (var client = new SshClient(connectionInfo)) - - { - #region ssh登录验证主机指纹代码块,暂未启用 - // client.HostKeyReceived += (sender, e) => - // { - // if (expectedFingerPrint.Length == e.FingerPrint.Length) - // { - // for (var i = 0; i < expectedFingerPrint.Length; i++) - // { - // if (expectedFingerPrint[i] != e.FingerPrint[i]) - // { - // e.CanTrust = false; - // break; - // } - // } - // } - // else - // { - // e.CanTrust = false; - // } - // }; - #endregion - - client.Connect(); - if (client.IsConnected == true) - { - //******"主机登录成功"****** - SetUpProgressBarProcessing(3); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_LoginSuccessful").ToString(); - MainWindowsShowInfo(currentStatus); - } - - //检测root权限 5--7 - functionResult = RootAuthorityDetect(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //检测是否已安装代理 8--10 - functionResult = SoftInstalledIsNoYes(client, "trojan", @"/usr/local/bin/trojan"); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //检测关闭Selinux及系统组件是否齐全(apt-get/yum/dnf/systemctl)11--30 - //安装依赖软件,检测端口,防火墙开启端口 - functionResult = ShutDownSelinuxAndSysComponentsDetect(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - - //检测是否为64位系统 - sshShellCommand = @"uname -m"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - string resultCmd = currentShellCommandResult; - if (resultCmd.Contains("x86_64") == false) - { - //******"请在x86_64系统中安装Trojan" ****** - MessageBox.Show(Application.Current.FindResource("MessageBoxShow_PleaseInstallSoftAtX64").ToString() + "NaiveProxy......"); - //****** "系统环境不满足要求,安装失败!!" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_MissingSystemComponents").ToString(); - MainWindowsShowInfo(currentStatus); - return; - } - - //检测域名是否解析到当前IP上 34---36 - functionResult = DomainResolutionCurrentIPDetect(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //下载安装脚本安装 37-40 - functionResult = ProxySoftInstall(client, @"Trojan", @"https://raw.githubusercontent.com/trojan-gfw/trojan-quickstart/master/trojan-quickstart.sh"); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - ////****** "正在安装Trojan......" ****** - //SetUpProgressBarProcessing(37); - //currentStatus = Application.Current.FindResource("DisplayInstallInfo_StartInstallSoft").ToString() + "Trojan......"; - //MainWindowsShowInfo(currentStatus); - - //sshShellCommand = $"curl -o /tmp/trojan-quickstart.sh https://raw.githubusercontent.com/trojan-gfw/trojan-quickstart/master/trojan-quickstart.sh"; - //currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //sshShellCommand = @"yes | bash /tmp/trojan-quickstart.sh"; - //currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //sshShellCommand = @"rm -f /tmp/trojan-quickstart.sh"; - //currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //程序是否安装成功检测并设置开机启动 41--43 - functionResult = SoftInstalledSuccessOrFail(client, "trojan", @"/usr/local/bin/trojan"); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //****** "安装完毕,上传配置文件......" ****** - SetUpProgressBarProcessing(44); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_UploadSoftConfig").ToString(); - MainWindowsShowInfo(currentStatus); - - sshShellCommand = @"mv /usr/local/etc/trojan/config.json /usr/local/etc/trojan/config.json.1"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - string serverConfig = $"{pwdir}" + @"TemplateConfg\trojan\trojan_server_config.json"; //服务端配置文件 - string upLoadPath = @"/usr/local/etc/trojan/config.json"; //服务端文件位置 - - //生成服务端配置 - using (StreamReader reader = File.OpenText(serverConfig)) - { - JObject serverJson = (JObject)JToken.ReadFrom(new JsonTextReader(reader)); - //设置密码 - serverJson["password"][0] = ReceiveConfigurationParameters[2]; - - //设置Caddy随机监听的端口,用于Trojan-go,Trojan,V2Ray vless TLS - //Random random = new Random(); - randomCaddyListenPort = GetRandomPort(); - - //设置转发到Caddy的随机监听端口 - serverJson["remote_port"] = randomCaddyListenPort; - - using (StreamWriter sw = new StreamWriter(@"config.json")) - { - sw.Write(serverJson.ToString()); - } - } - UploadConfig(connectionInfo, @"config.json", upLoadPath); - - File.Delete(@"config.json"); - - //acme.sh安装与申请证书 51--57 - functionResult = AcmeShInstall(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //****** "安装证书到Trojan......" ****** - SetUpProgressBarProcessing(58); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_IntallCertToSoft").ToString() + "Trojan......"; - MainWindowsShowInfo(currentStatus); - - sshShellCommand = $"/root/.acme.sh/acme.sh --installcert -d {ReceiveConfigurationParameters[4]} --certpath /usr/local/etc/trojan/trojan_ssl.crt --keypath /usr/local/etc/trojan/trojan_ssl.key --capath /usr/local/etc/trojan/trojan_ssl.crt --reloadcmd \"systemctl restart trojan\""; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"if [ ! -f ""/usr/local/etc/trojan/trojan_ssl.key"" ]; then echo ""0""; else echo ""1""; fi | head -n 1"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - if (currentShellCommandResult.Contains("1") == true) - { - //****** "证书成功安装到Trojan!" ****** - SetUpProgressBarProcessing(60); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_IntallCertToSoftOK").ToString() + "Trojan!"; - MainWindowsShowInfo(currentStatus); - } - else - { - //****** "证书安装到Trojan失败,原因未知,可以向开发者提问!" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_IntallCertToSoftFail").ToString() + - "Trojan" + - Application.Current.FindResource("DisplayInstallInfo_InstallCertFailAsk").ToString(); - MainWindowsShowInfo(currentStatus); - return; - } - - //设置证书权限 - sshShellCommand = @"chmod 644 /usr/local/etc/trojan/trojan_ssl.key"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //Caddy安装 61--66 - functionResult = CaddyInstall(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //****** "上传Caddy配置文件......" ****** - SetUpProgressBarProcessing(67); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_UploadCaddyConfig").ToString(); - MainWindowsShowInfo(currentStatus); - - sshShellCommand = @"mv /etc/caddy/Caddyfile /etc/caddy/Caddyfile.bak"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - string caddyConfig = $"{pwdir}" + @"TemplateConfg\trojan\trojan.caddyfile"; - upLoadPath = @"/etc/caddy/Caddyfile"; - - UploadConfig(connectionInfo, caddyConfig, upLoadPath); - - //设置Caddy配置文件 - functionResult = SetCaddyfile(client, upLoadPath); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //****** "Caddy配置文件上传成功,OK!" ****** - SetUpProgressBarProcessing(70); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_UploadCaddyConfigOK").ToString(); - MainWindowsShowInfo(currentStatus); - - //程序启动检测Caddy - functionResult = SoftStartDetect(client, "caddy", @"/usr/bin/caddy"); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //程序启动检测Trojan - functionResult = SoftStartDetect(client, "trojan", @"/usr/local/bin/trojan"); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //检测BBR,满足条件并启动 90--95 - functionResult = DetectBBRandEnable(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - client.Disconnect();//断开服务器ssh连接 - - //****** "生成客户端配置......" ****** - SetUpProgressBarProcessing(96); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_GenerateClientConfig").ToString(); - MainWindowsShowInfo(currentStatus); - if (!Directory.Exists("trojan_config"))//如果不存在就创建file文件夹      - { - Directory.CreateDirectory("trojan_config");//创建该文件夹   - } - - string clientConfig = $"{pwdir}" + @"TemplateConfg\trojan\trojan_client_config.json"; //生成的客户端配置文件 - using (StreamReader reader = File.OpenText(clientConfig)) - { - JObject clientJson = (JObject)JToken.ReadFrom(new JsonTextReader(reader)); - - clientJson["remote_addr"] = ReceiveConfigurationParameters[4]; - clientJson["remote_port"] = int.Parse(ReceiveConfigurationParameters[1]); - clientJson["password"][0] = ReceiveConfigurationParameters[2]; - - using (StreamWriter sw = new StreamWriter(@"trojan_config\config.json")) - { - sw.Write(clientJson.ToString()); - } - } - - //****** "Trojan安装成功,祝你玩的愉快!!" ****** - SetUpProgressBarProcessing(100); - currentStatus = "Trojan" + Application.Current.FindResource("DisplayInstallInfo_ProxyInstalledOK").ToString(); - MainWindowsShowInfo(currentStatus); - - //显示服务端连接参数 - proxyType = "Trojan"; - - ResultClientInformation resultClientInformation = new ResultClientInformation(); - resultClientInformation.ShowDialog(); - return; - } - } - catch (Exception ex1)//例外处理 - #region 例外处理 - { - ProcessException(ex1.Message); - - //****** "安装失败!" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_LoginFailed").ToString(); - MainWindowsShowInfo(currentStatus); - } - #endregion - - } - - //检测升级远程主机Trojan版本传递参数 - private void ButtonUpdateTrojan_Click(object sender, RoutedEventArgs e) - { - ConnectionInfo connectionInfo = GenerateConnectionInfo(); - if (connectionInfo == null) - { - //****** "远程主机连接信息有误,请检查!" ****** - MessageBox.Show(Application.Current.FindResource("MessageBoxShow_ErrorHostConnection").ToString()); - return; - } - installationDegree = 0; - TextBoxMonitorCommandResults.Text = ""; - Thread thread = new Thread(() => UpdateTojan(connectionInfo)); - thread.SetApartmentState(ApartmentState.STA); - thread.Start(); - } - - //升级Trojan主程序 - private void UpdateTojan(ConnectionInfo connectionInfo) - { - functionResult = true; - onlyIpv6 = false; - getApt = false; - getDnf = false; - getYum = false; - - //******"正在登录远程主机......"****** - SetUpProgressBarProcessing(1); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_Login").ToString(); - MainWindowsShowInfo(currentStatus); - - try - { - #region 主机指纹,暂未启用 - //byte[] expectedFingerPrint = new byte[] { - // 0x66, 0x31, 0xaf, 0x00, 0x54, 0xb9, 0x87, 0x31, - // 0xff, 0x58, 0x1c, 0x31, 0xb1, 0xa2, 0x4c, 0x6b - // }; - #endregion - using (var client = new SshClient(connectionInfo)) - - { - #region ssh登录验证主机指纹代码块,暂未启用 - // client.HostKeyReceived += (sender, e) => - // { - // if (expectedFingerPrint.Length == e.FingerPrint.Length) - // { - // for (var i = 0; i < expectedFingerPrint.Length; i++) - // { - // if (expectedFingerPrint[i] != e.FingerPrint[i]) - // { - // e.CanTrust = false; - // break; - // } - // } - // } - // else - // { - // e.CanTrust = false; - // } - // }; - #endregion - - client.Connect(); - if (client.IsConnected == true) - { - //******"主机登录成功"****** - SetUpProgressBarProcessing(3); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_LoginSuccessful").ToString(); - MainWindowsShowInfo(currentStatus); - } - - //检测root权限 5--7 - functionResult = RootAuthorityDetect(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - - //******"检测系统是否已经安装Trojan......"****** - SetUpProgressBarProcessing(20); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_TestExistSoft").ToString() + "Trojan......"; - MainWindowsShowInfo(currentStatus); - - - //string cmdTestTrojanInstalled = @"find / -name trojan"; - //string resultCmdTestTrojanInstalled = client.RunCommand(cmdTestTrojanInstalled).Result; - //sshShellCommand = @"find / -name trojan"; - //sshShellCommand = @"if [[ -f /usr/local/bin/trojan ]];then echo '1';else echo '0'; fi"; - //currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //if (currentShellCommandResult.Contains("/usr/local/bin/trojan") == false) - //if (currentShellCommandResult.Trim().Equals("0") == true) - functionResult = FileCheckExists(client, @"/usr/local/bin/trojan"); - if (functionResult == false) - { - //******"退出!原因:远程主机未安装Trojan"****** - currentStatus = Application.Current.FindResource("MessageBoxShow_ErrorUpgradeSoftNotInstall").ToString() + "Trojan!"; - MainWindowsShowInfo(currentStatus); - MessageBox.Show(currentStatus); - client.Disconnect(); - return; - - } - - SetUpProgressBarProcessing(40); - - //获取当前安装的版本 - //string sshcmd = @"echo ""$(/usr/local/bin/trojan -v 2>&1)"" | head -n 1 | cut -d "" "" -f4"; - //string trojanCurrentVersion = client.RunCommand(sshcmd).Result;//不含字母v - sshShellCommand = @"echo ""$(/usr/local/bin/trojan -v 2>&1)"" | head -n 1 | cut -d "" "" -f4"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - string trojanCurrentVersion = currentShellCommandResult;//不含字母v - - - //sshcmd = @"curl -fsSL https://api.github.com/repos/trojan-gfw/trojan/releases/latest | grep tag_name | sed -E 's/.*""v(.*)"".*/\1/'"; - //获取最新版本 - - sshShellCommand = @"curl -fsSL https://api.github.com/repos/trojan-gfw/trojan/releases/latest | grep tag_name | sed -E 's/.*""v(.*)"".*/\1/'"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - string trojanNewVersion = currentShellCommandResult;//不含字母v - - if (trojanNewVersion.Equals(trojanCurrentVersion) == false) - { - MessageBoxResult messageBoxResult = MessageBox.Show( - //****** "远程主机当前版本为:v" ****** - Application.Current.FindResource("DisplayInstallInfo_CurrentVersion").ToString() + - $"{trojanCurrentVersion}\n" + - //****** "最新版本为:" ****** - Application.Current.FindResource("DisplayInstallInfo_NewVersion").ToString() + - $"{trojanNewVersion}\n" + - //****** "是否升级为最新版本?" ****** - Application.Current.FindResource("DisplayInstallInfo_IsOrNoUpgradeNewVersion").ToString(), "", MessageBoxButton.YesNo, MessageBoxImage.Question); - if (messageBoxResult == MessageBoxResult.Yes) - { - //****** "正在升级到最新版本......" ****** - SetUpProgressBarProcessing(60); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_StartUpgradeNewVersion").ToString(); - MainWindowsShowInfo(currentStatus); - - //****** "备份Trojan配置文件......" ****** - SetUpProgressBarProcessing(80); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_BackTrojanConfig").ToString(); - MainWindowsShowInfo(currentStatus); - - //string sshcmd = @"mv /usr/local/etc/trojan/config.json /usr/local/etc/trojan/config.json.bak"; - //client.RunCommand(sshcmd); - sshShellCommand = @"mv /usr/local/etc/trojan/config.json /usr/local/etc/trojan/config.json.bak"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //升级Trojan主程序 - //client.RunCommand("curl -o /tmp/trojan-quickstart.sh https://raw.githubusercontent.com/trojan-gfw/trojan-quickstart/master/trojan-quickstart.sh"); - //client.RunCommand("yes | bash /tmp/trojan-quickstart.sh"); - - saveShellScriptFileName = GenerateRandomScriptFileName(GenerateRandomStr(10)); - - sshShellCommand = $"curl -o {saveShellScriptFileName} https://raw.githubusercontent.com/trojan-gfw/trojan-quickstart/master/trojan-quickstart.sh"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - functionResult = FileCheckExists(client, $"{saveShellScriptFileName}"); - if (functionResult == false) - { - //***文件下载失败!*** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_DownloadScriptFailed").ToString(); - MainWindowsShowInfo(currentStatus); - return; - } - - sshShellCommand = $"yes | bash {saveShellScriptFileName}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = $"rm -f {saveShellScriptFileName}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //sshcmd = @"echo ""$(/usr/local/bin/trojan -v 2>&1)"" | head -n 1 | cut -d "" "" -f4"; - sshShellCommand = @"echo ""$(/usr/local/bin/trojan -v 2>&1)"" | head -n 1 | cut -d "" "" -f4"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - trojanCurrentVersion = currentShellCommandResult;//不含字母v - //trojanCurrentVersion = client.RunCommand(sshcmd).Result;//不含字母v - if (trojanNewVersion.Equals(trojanCurrentVersion) == true) - { - //****** "恢复Trojan配置文件......" ****** - SetUpProgressBarProcessing(90); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_RestoreTrojanConfig").ToString(); - MainWindowsShowInfo(currentStatus); - - //sshcmd = @"rm -f /usr/local/etc/trojan/config.json"; - //client.RunCommand(sshcmd); - sshShellCommand = @"rm -f /usr/local/etc/trojan/config.json"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //sshcmd = @"mv /usr/local/etc/trojan/config.json.bak /usr/local/etc/trojan/config.json"; - //client.RunCommand(sshcmd); - sshShellCommand = @"mv /usr/local/etc/trojan/config.json.bak /usr/local/etc/trojan/config.json"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //****** "升级成功!当前已是最新版本!" ****** - SetUpProgressBarProcessing(100); - MessageBox.Show(Application.Current.FindResource("DisplayInstallInfo_UpgradeNewVersionOK").ToString()); - //****** "升级成功!当前已是最新版本!" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_UpgradeNewVersionOK").ToString(); - MainWindowsShowInfo(currentStatus); - - } - else - { - //****** "升级失败,原因未知,请向开发者提问!" ****** - MessageBox.Show(Application.Current.FindResource("DisplayInstallInfo_UpgradeNewVersionFail").ToString()); - //****** "升级失败,原因未知,请向开发者提问!" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_UpgradeNewVersionFail").ToString(); - MainWindowsShowInfo(currentStatus); - } - } - - else - { - //****** "升级取消,退出!" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_UpgradeVersionCancel").ToString(); - MainWindowsShowInfo(currentStatus); - - client.Disconnect(); - return; - } - } - else - { - //****** "远程主机当前已是最新版本:" ****** - SetUpProgressBarProcessing(100); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_IsNewVersion").ToString() + - $"{trojanNewVersion}\n" + - //****** "无需升级!退出!" ****** - Application.Current.FindResource("DisplayInstallInfo_NotUpgradeVersion").ToString(); - MessageBox.Show(currentStatus); - MainWindowsShowInfo(currentStatus); - } - - client.Disconnect(); - return; - } - } - catch (Exception ex1)//例外处理 - #region 例外处理 - { - ProcessException(ex1.Message); - //****** "主机登录失败!" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_LoginFailed").ToString(); - MainWindowsShowInfo(currentStatus); - } - #endregion - - } - - //更新Trojan的密码 - private void ButtonTrojanPassword_Click(object sender, RoutedEventArgs e) - { - TextBoxTrojanPassword.Text = RandomUUID(); - } - #endregion - - #region NaiveProxy相关 - - //NaiveProxy一键安装开始传递参数 - private void ButtonNavieSetUp_Click(object sender, RoutedEventArgs e) - { - //if (string.IsNullOrEmpty(PreTrim(TextBoxNaiveHostDomain.Text)) == true) - //{ - // //****** "域名不能为空,请检查相关参数设置!" ****** - // MessageBox.Show(Application.Current.FindResource("MessageBoxShow_DomainNotEmpty").ToString()); - // return; - //} - - ConnectionInfo connectionInfo = GenerateConnectionInfo(); - if (connectionInfo == null) - { - //****** "远程主机连接信息有误,请检查!" ****** - MessageBox.Show(Application.Current.FindResource("MessageBoxShow_ErrorHostConnection").ToString()); - return; - } - //清空参数空间 - for (int i = 0; i != ReceiveConfigurationParameters.Length; i++) - - { - ReceiveConfigurationParameters[i] = ""; - } - - bool preDomainMask = ClassModel.PreDomainMask(TextBoxNaiveSites.Text); - bool domainNotEmpty = ClassModel.TestDomainIsEmpty(TextBoxNaiveHostDomain.Text); - if (domainNotEmpty == false || preDomainMask == false) - { - return; - } - //传递参数 - ReceiveConfigurationParameters[4] = PreTrim(TextBoxNaiveHostDomain.Text);//传递域名 - ReceiveConfigurationParameters[1] = "443";//传递端口 - ReceiveConfigurationParameters[3] = TextBoxNaiveUser.Text;//传递用户名 - ReceiveConfigurationParameters[2] = TextBoxNaivePassword.Text;//传递密码 - ReceiveConfigurationParameters[7] = ClassModel.DisguiseURLprocessing(PreTrim(TextBoxNaiveSites.Text));//传递伪装网站 - - //启动布署进程 - installationDegree = 0; - TextBoxMonitorCommandResults.Text = ""; - Thread thread = new Thread(() => StartSetUpNaive(connectionInfo)); - thread.SetApartmentState(ApartmentState.STA); - thread.Start(); - } - - //登录远程主机布署NaiveProxy程序 - private void StartSetUpNaive(ConnectionInfo connectionInfo) - { - functionResult = true; - onlyIpv6 = false; - getApt = false; - getDnf = false; - getYum = false; - - //******"正在登录远程主机......"****** - SetUpProgressBarProcessing(1); - string currentStatus = Application.Current.FindResource("DisplayInstallInfo_Login").ToString(); - MainWindowsShowInfo(currentStatus); - - try - { - #region 主机指纹,暂未启用 - //byte[] expectedFingerPrint = new byte[] { - // 0x66, 0x31, 0xaf, 0x00, 0x54, 0xb9, 0x87, 0x31, - // 0xff, 0x58, 0x1c, 0x31, 0xb1, 0xa2, 0x4c, 0x6b - // }; - #endregion - using (var client = new SshClient(connectionInfo)) - - { - #region ssh登录验证主机指纹代码块,暂未启用 - // client.HostKeyReceived += (sender, e) => - // { - // if (expectedFingerPrint.Length == e.FingerPrint.Length) - // { - // for (var i = 0; i < expectedFingerPrint.Length; i++) - // { - // if (expectedFingerPrint[i] != e.FingerPrint[i]) - // { - // e.CanTrust = false; - // break; - // } - // } - // } - // else - // { - // e.CanTrust = false; - // } - // }; - #endregion - - client.Connect(); - if (client.IsConnected == true) - { - //******"主机登录成功"****** - SetUpProgressBarProcessing(3); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_LoginSuccessful").ToString(); - MainWindowsShowInfo(currentStatus); - - } - - //检测root权限 5--7 - functionResult = RootAuthorityDetect(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //检测是否已安装代理 8--10 - functionResult = SoftInstalledIsNoYes(client, "caddy", @"/usr/bin/caddy"); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //检测关闭Selinux及系统组件是否齐全(apt-get/yum/dnf/systemctl)11--30 - //安装依赖软件,检测端口,防火墙开启端口 - functionResult = ShutDownSelinuxAndSysComponentsDetect(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //检测域名是否解析到当前IP上 34---36 - functionResult = DomainResolutionCurrentIPDetect(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //安装代理程序 37--40 - functionResult = ProxySoftInstall(client, @"NaiveProxy", @"https://raw.githubusercontent.com/proxysu/shellscript/master/Caddy-Naive/caddy-naive-install.sh"); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - ////****** "系统环境检测完毕,符合安装要求,开始布署......" ****** - //SetUpProgressBarProcessing(60); - //currentStatus = Application.Current.FindResource("DisplayInstallInfo_StartInstalling").ToString(); - //MainWindowsShowInfo(currentStatus); - - ////Caddy安装与检测安装是否成功 61--66 - //functionResult = CaddyInstall(client); - //if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - - ////使用带插件的Caddy替换 - ////****** "正在为NaiveProxy升级服务端!" ****** - ////SetUpProgressBarProcessing(76); - //currentStatus = Application.Current.FindResource("DisplayInstallInfo_UpgradeNaiveProxy").ToString(); - //MainWindowsShowInfo(currentStatus); - - //sshShellCommand = $"curl -o /tmp/caddy.zip https://raw.githubusercontent.com/proxysu/Resources/master/Caddy2/caddy2.zip"; - //currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //functionResult = FileCheckExists(client, @"/tmp/caddy.zip"); - //if (functionResult == false) - //{ - // //***文件下载失败!*** - // currentStatus = Application.Current.FindResource("DisplayInstallInfo_DownloadScriptFailed").ToString(); - // MainWindowsShowInfo(currentStatus); - // return; - //} - //sshShellCommand = @"yes | unzip -o /tmp/caddy.zip"; - //currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //sshShellCommand = @"chmod +x ./caddy"; - //currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //sshShellCommand = @"systemctl stop caddy;rm -f /usr/bin/caddy"; - //currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //sshShellCommand = @"cp caddy /usr/bin/"; - //currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //sshShellCommand = @"rm -f /tmp/caddy.zip caddy"; - //currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - ////****** "升级完毕,OK!" ****** - ////SetUpProgressBarProcessing(79); - //currentStatus = Application.Current.FindResource("DisplayInstallInfo_UpgradeNaiveProxyOK").ToString(); - //MainWindowsShowInfo(currentStatus); - - //****** "上传Caddy配置文件......" ****** - SetUpProgressBarProcessing(67); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_UploadCaddyConfig").ToString(); - MainWindowsShowInfo(currentStatus); - - //生成服务端配置 - string caddyConfig = $"{pwdir}" + @"TemplateConfg\naive\naive_server.caddyfile"; - string upLoadPath = @"/etc/caddy/Caddyfile"; - UploadConfig(connectionInfo, caddyConfig, upLoadPath); - //$"sed -i 's/##domain##/{ReceiveConfigurationParameters[4]}/' {upLoadPath}" - //$"sed -i 's/##basicauth##/basicauth {ReceiveConfigurationParameters[3]} {ReceiveConfigurationParameters[2]}/' {upLoadPath}" - - //设置Caddy配置文件 - functionResult = SetCaddyfile(client, upLoadPath); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - sshShellCommand = $"sed -i 's/##basicauth##/basic_auth {ReceiveConfigurationParameters[3]} {ReceiveConfigurationParameters[2]}/' {upLoadPath}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = $"sed -i 's/file_server/#file_server/' {upLoadPath}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //string caddyConfig = $"{pwdir}" + @"TemplateConfg\naive\naive_server_config.json"; - //using (StreamReader reader = File.OpenText(caddyConfig)) - //{ - // JObject serverJson = (JObject)JToken.ReadFrom(new JsonTextReader(reader)); - // serverJson["apps"]["http"]["servers"]["srv0"]["routes"][0]["handle"][0]["auth_user"] = ReceiveConfigurationParameters[3];//----用户名 - // serverJson["apps"]["http"]["servers"]["srv0"]["routes"][0]["handle"][0]["auth_pass"] = ReceiveConfigurationParameters[2]; //----密码 - - // serverJson["apps"]["http"]["servers"]["srv0"]["routes"][1]["match"][0]["host"][0] = ReceiveConfigurationParameters[4]; //----域名 - - // serverJson["apps"]["http"]["servers"]["srv0"]["tls_connection_policies"][0]["match"]["sni"][0] = ReceiveConfigurationParameters[4]; //----域名 - - // serverJson["apps"]["tls"]["automation"]["policies"][0]["subjects"][0] = ReceiveConfigurationParameters[4]; //-----域名 - // serverJson["apps"]["tls"]["automation"]["policies"][0]["issuer"]["email"] = $"user@{ReceiveConfigurationParameters[4]}"; //-----邮箱 - // //保存配置文件 - // using (StreamWriter sw = new StreamWriter(@"config.json")) - // { - // sw.Write(serverJson.ToString()); - // } - //} - //string upLoadPath = @"/etc/caddy/config.json"; - //UploadConfig(connectionInfo, @"config.json", upLoadPath); - - //File.Delete(@"config.json"); - - //****** Caddy配置文件上传成功,OK! ****** - SetUpProgressBarProcessing(70); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_UploadCaddyConfigOK").ToString(); - MainWindowsShowInfo(currentStatus); - - //sshShellCommand = @"sed -i 's/Caddyfile/config.json/' /lib/systemd/system/caddy.service"; - //currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //sshShellCommand = @"systemctl daemon-reload"; - //currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //程序启动检测Caddy - functionResult = SoftStartDetect(client, "caddy", @"/usr/bin/caddy"); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - ////设置伪装网站 - //if (String.IsNullOrEmpty(ReceiveConfigurationParameters[7]) == false) - //{ - // sshCmd = $"sed -i 's/##sites##/proxy \\/ {ReceiveConfigurationParameters[7]}/' {upLoadPath}"; - // //MessageBox.Show(sshCmd); - // client.RunCommand(sshCmd); - //} - //Thread.Sleep(2000); - - //****** "正在优化网络参数......" ****** - SetUpProgressBarProcessing(80); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_OptimizeNetwork").ToString(); - MainWindowsShowInfo(currentStatus); - - //优化网络参数 - sshShellCommand = @"bash -c 'echo ""fs.file-max = 51200"" >> /etc/sysctl.conf'"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"bash -c 'echo ""net.core.rmem_max = 67108864"" >> /etc/sysctl.conf'"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"bash -c 'echo ""net.core.wmem_max = 67108864"" >> /etc/sysctl.conf'"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"bash -c 'echo ""net.core.rmem_default = 65536"" >> /etc/sysctl.conf'"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"bash -c 'echo ""net.core.wmem_default = 65536"" >> /etc/sysctl.conf'"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"bash -c 'echo ""net.core.netdev_max_backlog = 4096"" >> /etc/sysctl.conf'"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"bash -c 'echo ""net.core.somaxconn = 4096"" >> /etc/sysctl.conf'"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"bash -c 'echo ""net.ipv4.tcp_syncookies = 1"" >> /etc/sysctl.conf'"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"bash -c 'echo ""net.ipv4.tcp_tw_reuse = 1"" >> /etc/sysctl.conf'"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"bash -c 'echo ""net.ipv4.tcp_tw_recycle = 0"" >> /etc/sysctl.conf'"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"bash -c 'echo ""net.ipv4.tcp_fin_timeout = 30"" >> /etc/sysctl.conf'"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"bash -c 'echo ""net.ipv4.tcp_keepalive_time = 1200"" >> /etc/sysctl.conf'"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"bash -c 'echo ""net.ipv4.ip_local_port_range = 10000 65000"" >> /etc/sysctl.conf'"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"bash -c 'echo ""net.ipv4.tcp_max_syn_backlog = 4096"" >> /etc/sysctl.conf'"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"bash -c 'echo ""net.ipv4.tcp_max_tw_buckets = 5000"" >> /etc/sysctl.conf'"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"bash -c 'echo ""net.ipv4.tcp_rmem = 4096 87380 67108864"" >> /etc/sysctl.conf'"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"bash -c 'echo ""net.ipv4.tcp_wmem = 4096 65536 67108864"" >> /etc/sysctl.conf'"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"bash -c 'echo ""net.ipv4.tcp_mtu_probing = 1"" >> /etc/sysctl.conf'"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"sysctl -p"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //****** "优化网络参数,OK!" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_OptimizeNetworkOK").ToString(); ; - MainWindowsShowInfo(currentStatus); - - //检测BBR,满足条件并启动 90--95 - functionResult = DetectBBRandEnable(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - client.Disconnect();//断开服务器ssh连接 - - //****** "生成客户端配置......" ****** - SetUpProgressBarProcessing(96); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_GenerateClientConfig").ToString(); - MainWindowsShowInfo(currentStatus); - - if (!Directory.Exists("naive_config"))//如果不存在就创建file文件夹      - { - Directory.CreateDirectory("naive_config");//创建该文件夹   - } - - string clientConfig = $"{pwdir}" + @"TemplateConfg\naive\naive_client_config.json"; //生成的客户端配置文件 - using (StreamReader reader = File.OpenText(clientConfig)) - { - JObject clientJson = (JObject)JToken.ReadFrom(new JsonTextReader(reader)); - - clientJson["proxy"] = $"https://{ReceiveConfigurationParameters[3]}:{ReceiveConfigurationParameters[2]}@{ReceiveConfigurationParameters[4]}"; - using (StreamWriter sw = new StreamWriter(@"naive_config\config.json")) - { - sw.Write(clientJson.ToString()); - } - } - - - //****** "NaiveProxy安装成功,祝你玩的愉快!!" ****** - SetUpProgressBarProcessing(100); - currentStatus = "NaiveProxy" + Application.Current.FindResource("DisplayInstallInfo_ProxyInstalledOK").ToString(); - MainWindowsShowInfo(currentStatus); - - //显示服务端连接参数 - proxyType = "NaiveProxy"; - ResultClientInformation resultClientInformation = new ResultClientInformation(); - resultClientInformation.ShowDialog(); - return; - } - } - catch (Exception ex1)//例外处理 - #region 例外处理 - { - ProcessException(ex1.Message); - - //****** "安装失败!" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_LoginFailed").ToString(); - MainWindowsShowInfo(currentStatus); - } - #endregion - - } - - //更新NaiveProxy的密码 - private void ButtonNaivePassword_Click(object sender, RoutedEventArgs e) - { - TextBoxNaivePassword.Text = RandomUUID(); - } - - //生成随机UUID - private string RandomUUID() - { - Guid uuid = Guid.NewGuid(); - //TextBoxNaivePassword.Text = uuid.ToString(); - return uuid.ToString(); - } - - //NaiveProxy产生随机用户名 - private string RandomUserName() - { - Random random = new Random(); - int randomSerialNum = random.Next(0, 4); - Guid uuid = Guid.NewGuid(); - string[] pathArray = uuid.ToString().Split('-'); - string path = pathArray[randomSerialNum]; - return path; - // TextBoxPath.Text = $"/{path}"; - //MessageBox.Show(path); - } - - //NaiveProxy更改用户名,随机方式 - private void ButtonNaiveUser_Click(object sender, RoutedEventArgs e) - { - TextBoxNaiveUser.Text = RandomUserName(); - } - - #endregion - - #region SSR+TLS+Caddy相关 - - //SSR参数传递 - private void ButtonSSRSetUp_Click(object sender, RoutedEventArgs e) - { - ConnectionInfo connectionInfo = GenerateConnectionInfo(); - if (connectionInfo == null) - { - //****** "远程主机连接信息有误,请检查!" ****** - MessageBox.Show(Application.Current.FindResource("MessageBoxShow_ErrorHostConnection").ToString()); - return; - } - //清空参数空间 - for (int i = 0; i != ReceiveConfigurationParameters.Length; i++) - - { - ReceiveConfigurationParameters[i] = ""; - } - - bool domainNotEmpty = ClassModel.TestDomainIsEmpty(TextBoxSSRHostDomain.Text); - bool preDomainMask = ClassModel.PreDomainMask(TextBoxSSRSites.Text); - if (domainNotEmpty == false || preDomainMask == false) - { - return; - } - //if (string.IsNullOrEmpty(PreTrim(TextBoxSSRHostDomain.Text)) == true) - //{ - // //****** "域名不能为空,请检查相关参数设置!" ****** - // MessageBox.Show(Application.Current.FindResource("MessageBoxShow_DomainNotEmpty").ToString()); - // return; - //} - - //传递域名 - ReceiveConfigurationParameters[4] = PreTrim(TextBoxSSRHostDomain.Text); - //传递伪装网站 - ReceiveConfigurationParameters[7] = ClassModel.DisguiseURLprocessing(PreTrim(TextBoxSSRSites.Text)); - - //传递服务端口 - ReceiveConfigurationParameters[1] = "443"; - //传递密码(uuid) - ReceiveConfigurationParameters[2] = TextBoxSSRPassword.Text.ToString(); - - - installationDegree = 0; - TextBoxMonitorCommandResults.Text = ""; - Thread thread = new Thread(() => StartSetUpSSR(connectionInfo)); - thread.SetApartmentState(ApartmentState.STA); - thread.Start(); - } - - //登录远程主机布署SSR+TLS+Caddy程序 - private void StartSetUpSSR(ConnectionInfo connectionInfo) - { - functionResult = true; - onlyIpv6 = false; - getApt = false; - getDnf = false; - getYum = false; - - //******"正在登录远程主机......"****** - SetUpProgressBarProcessing(1); - string currentStatus = Application.Current.FindResource("DisplayInstallInfo_Login").ToString(); - MainWindowsShowInfo(currentStatus); - - try - { - #region 主机指纹,暂未启用 - //byte[] expectedFingerPrint = new byte[] { - // 0x66, 0x31, 0xaf, 0x00, 0x54, 0xb9, 0x87, 0x31, - // 0xff, 0x58, 0x1c, 0x31, 0xb1, 0xa2, 0x4c, 0x6b - // }; - #endregion - using (var client = new SshClient(connectionInfo)) - - { - #region ssh登录验证主机指纹代码块,暂未启用 - // client.HostKeyReceived += (sender, e) => - // { - // if (expectedFingerPrint.Length == e.FingerPrint.Length) - // { - // for (var i = 0; i < expectedFingerPrint.Length; i++) - // { - // if (expectedFingerPrint[i] != e.FingerPrint[i]) - // { - // e.CanTrust = false; - // break; - // } - // } - // } - // else - // { - // e.CanTrust = false; - // } - // }; - #endregion - - client.Connect(); - if (client.IsConnected == true) - { - //******"主机登录成功"****** - SetUpProgressBarProcessing(3); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_LoginSuccessful").ToString(); - MainWindowsShowInfo(currentStatus); - } - - //检测root权限 5--7 - functionResult = RootAuthorityDetect(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //检测是否已安装代理 8--10 - functionResult = SoftInstalledIsNoYes(client, "server.py", @"/usr/local/shadowsocks/server.py"); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //检测关闭Selinux及系统组件是否齐全(apt-get/yum/dnf/systemctl)11--30 - //安装依赖软件,检测端口,防火墙开启端口 - functionResult = ShutDownSelinuxAndSysComponentsDetect(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //检测域名是否解析到当前IP上 34---36 - functionResult = DomainResolutionCurrentIPDetect(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //下载脚本安装SSR 37--40 - functionResult = ProxySoftInstall(client, @"SSR", @"https://raw.githubusercontent.com/proxysu/shellscript/master/ssr/ssr.sh"); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - ////****** "系统环境检测完毕,符合安装要求,开始布署......" ****** - //SetUpProgressBarProcessing(37); - //currentStatus = Application.Current.FindResource("DisplayInstallInfo_StartInstalling").ToString(); - //MainWindowsShowInfo(currentStatus); - - ////下载安装脚本安装 - ////****** "正在安装SSR......" ****** - //SetUpProgressBarProcessing(38); - //currentStatus = Application.Current.FindResource("DisplayInstallInfo_StartInstallSoft").ToString() + "SSR......"; - //MainWindowsShowInfo(currentStatus); - - //sshShellCommand = $"curl -o /tmp/ssr.sh https://raw.githubusercontent.com/proxysu/shellscript/master/ssr/ssr.sh"; - //currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //sshShellCommand = @"yes | bash /tmp/ssr.sh"; - //currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //sshShellCommand = @"rm -f /tmp/ssr.sh"; - //currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //程序是否安装成功检测并设置开机启动 41--43 - functionResult = SoftInstalledSuccessOrFail(client, "server.py", @"/usr/local/shadowsocks/server.py"); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - - //****** "安装完毕,上传配置文件......" ****** - SetUpProgressBarProcessing(44); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_UploadSoftConfig").ToString(); - MainWindowsShowInfo(currentStatus); - - //生成服务端配置 - string upLoadPath = @"/etc/shadowsocks.json"; - - //设置指向Caddy监听的随机端口 - randomCaddyListenPort = GetRandomPort(); - string randomSSRListenPortStr = randomCaddyListenPort.ToString(); - - sshShellCommand = $"sed -i 's/8800/{randomSSRListenPortStr}/' {upLoadPath}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //设置密码 - sshShellCommand = $"sed -i 's/##password##/{ReceiveConfigurationParameters[2]}/' {upLoadPath}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //Caddy安装与检测安装是否成功 61--66 - functionResult = CaddyInstall(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //****** "上传Caddy配置文件......" ****** - SetUpProgressBarProcessing(67); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_UploadCaddyConfig").ToString(); - MainWindowsShowInfo(currentStatus); - - sshShellCommand = @"mv /etc/caddy/Caddyfile /etc/caddy/Caddyfile.bak"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - string caddyConfig = $"{pwdir}" + @"TemplateConfg\ssr\ssr_tls.caddyfile"; - upLoadPath = @"/etc/caddy/Caddyfile"; - - UploadConfig(connectionInfo, caddyConfig, upLoadPath); - - functionResult = SetCaddyfile(client, @"/etc/caddy/Caddyfile"); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //****** "Caddy配置文件上传成功,OK!" ****** - SetUpProgressBarProcessing(70); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_UploadCaddyConfigOK").ToString(); - MainWindowsShowInfo(currentStatus); - - //程序启动检测Caddy - functionResult = SoftStartDetect(client, "caddy", @"/usr/bin/caddy"); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //程序启动检测SSR - functionResult = SoftStartDetect(client, "ssr", @"/usr/bin/ssr"); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //检测BBR,满足条件并启动 90--95 - functionResult = DetectBBRandEnable(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - client.Disconnect();//断开服务器ssh连接 - - //****** "生成客户端配置......" ****** - SetUpProgressBarProcessing(96); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_GenerateClientConfig").ToString(); - MainWindowsShowInfo(currentStatus); - - if (!Directory.Exists("ssr_config"))//如果不存在就创建file文件夹      - { - Directory.CreateDirectory("ssr_config");//创建该文件夹   - } - - - //****** "SSR+TLS+Caddy安装成功,祝你玩的愉快!!" ****** - SetUpProgressBarProcessing(100); - currentStatus = "SSR+TLS+Caddy" + Application.Current.FindResource("DisplayInstallInfo_ProxyInstalledOK").ToString(); - MainWindowsShowInfo(currentStatus); - - //显示服务端连接参数 - proxyType = "SSR"; - - ResultClientInformation resultClientInformation = new ResultClientInformation(); - resultClientInformation.ShowDialog(); - return; - } - } - catch (Exception ex1)//例外处理 - #region 例外处理 - { - ProcessException(ex1.Message); - - //****** "安装失败!" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_LoginFailed").ToString(); - MainWindowsShowInfo(currentStatus); - } - #endregion - - } - - //更新SSR的密码 - private void ButtonSSRPassword_Click(object sender, RoutedEventArgs e) - { - TextBoxSSRPassword.Text = RandomUUID(); - } - - - #endregion - - #region SS相关 - - //打开SS Plugin设置窗口 - private void ButtonTemplateConfigurationSS_Click(object sender, RoutedEventArgs e) - { - //清空初始化模板参数 - for (int i = 0; i != ReceiveConfigurationParameters.Length; i++) - - { - ReceiveConfigurationParameters[i] = ""; - } - SSpluginWindow windowTemplateConfigurationSS = new SSpluginWindow(); - windowTemplateConfigurationSS.Closed += windowTemplateConfigurationSSClosed; - windowTemplateConfigurationSS.ShowDialog(); - } - //SS Plugin设置窗口关闭后,触发事件,将所选的方案与其参数显示在UI上 - private void windowTemplateConfigurationSSClosed(object sender, System.EventArgs e) - { - if (String.IsNullOrEmpty(ReceiveConfigurationParameters[0]) == true) - { - //显示"未选择方案!" - TextBlockCurrentlySelectedPlanSS.Text = Application.Current.FindResource("TextBlockCurrentlySelectedPlanNo").ToString(); - - TextBlockShowPortSS.Visibility = Visibility.Hidden; - TextBlockCurrentlySelectedPlanPortSS.Visibility = Visibility.Hidden; - - TextBlockShowUUIDSS.Visibility = Visibility.Hidden; - TextBlockCurrentlySelectedPlanUUIDSS.Visibility = Visibility.Hidden; - - TextBlockShowMethodSS.Visibility = Visibility.Hidden; - TextBlockCurrentlySelectedPlanMethodSS.Visibility = Visibility.Hidden; - - TextBlockShowDomainSS.Visibility = Visibility.Hidden; - TextBlockCurrentlySelectedPlanDomainSS.Visibility = Visibility.Hidden; - - TextBlockShowPathSS.Visibility = Visibility.Hidden; - TextBlockCurrentlySelectedPlanPathSS.Visibility = Visibility.Hidden; - - TextBlockShowFakeWebsiteSS.Visibility = Visibility.Hidden; - TextBlockCurrentlySelectedPlanFakeWebsite.Visibility = Visibility.Hidden; - return; - } - TextBlockCurrentlySelectedPlanSS.Text = ReceiveConfigurationParameters[8]; //所选方案名称 - TextBlockCurrentlySelectedPlanPortSS.Text = ReceiveConfigurationParameters[1]; //服务器端口 - TextBlockCurrentlySelectedPlanUUIDSS.Text = ReceiveConfigurationParameters[2]; //密码 - TextBlockCurrentlySelectedPlanMethodSS.Text = ReceiveConfigurationParameters[3]; //加密方法 - TextBlockCurrentlySelectedPlanDomainSS.Text = ReceiveConfigurationParameters[4]; //域名 - TextBlockCurrentlySelectedPlanPathSS.Text = ReceiveConfigurationParameters[6]; //WebSocket Path - TextBlockCurrentlySelectedPlanFakeWebsite.Text = ReceiveConfigurationParameters[7]; //伪装网站 - - if (String.Equals(ReceiveConfigurationParameters[0], "NonePluginSS") - || String.Equals(ReceiveConfigurationParameters[0], "ObfsPluginHttpWebSS") - || String.Equals(ReceiveConfigurationParameters[0], "WebSocketSS") - || String.Equals(ReceiveConfigurationParameters[0], "KcptunPluginSS") - ) - { - //显示端口 - TextBlockShowPortSS.Visibility = Visibility.Visible; - TextBlockCurrentlySelectedPlanPortSS.Visibility = Visibility.Visible; - //显示密码 - TextBlockShowUUIDSS.Visibility = Visibility.Visible; - TextBlockCurrentlySelectedPlanUUIDSS.Visibility = Visibility.Visible; - //显示加密方式 - TextBlockShowMethodSS.Visibility = Visibility.Visible; - TextBlockCurrentlySelectedPlanMethodSS.Visibility = Visibility.Visible; - //隐藏域名 - TextBlockShowDomainSS.Visibility = Visibility.Hidden; - TextBlockCurrentlySelectedPlanDomainSS.Visibility = Visibility.Hidden; - //隐藏WebSocket路径 - TextBlockShowPathSS.Visibility = Visibility.Hidden; - TextBlockCurrentlySelectedPlanPathSS.Visibility = Visibility.Hidden; - //隐藏伪装网站 - TextBlockShowFakeWebsiteSS.Visibility = Visibility.Hidden; - TextBlockCurrentlySelectedPlanFakeWebsiteSS.Visibility = Visibility.Hidden; - - } - else if (String.Equals(ReceiveConfigurationParameters[0], "ObfsPluginHttpsWebSS") - || String.Equals(ReceiveConfigurationParameters[0], "QuicSS") - || String.Equals(ReceiveConfigurationParameters[0], "GoQuietPluginSS") - || String.Equals(ReceiveConfigurationParameters[0], "CloakPluginSS") - ) - { - //显示端口 - TextBlockShowPortSS.Visibility = Visibility.Visible; - TextBlockCurrentlySelectedPlanPortSS.Visibility = Visibility.Visible; - //显示密码 - TextBlockShowUUIDSS.Visibility = Visibility.Visible; - TextBlockCurrentlySelectedPlanUUIDSS.Visibility = Visibility.Visible; - //显示加密方式 - TextBlockShowMethodSS.Visibility = Visibility.Visible; - TextBlockCurrentlySelectedPlanMethodSS.Visibility = Visibility.Visible; - //显示域名 - TextBlockShowDomainSS.Visibility = Visibility.Visible; - TextBlockCurrentlySelectedPlanDomainSS.Visibility = Visibility.Visible; - //隐藏WebSocket路径 - TextBlockShowPathSS.Visibility = Visibility.Hidden; - TextBlockCurrentlySelectedPlanPathSS.Visibility = Visibility.Hidden; - //显示伪装网站 - TextBlockShowFakeWebsiteSS.Visibility = Visibility.Visible; - TextBlockCurrentlySelectedPlanFakeWebsiteSS.Visibility = Visibility.Visible; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLSWebFrontSS")) - { - //显示端口 - TextBlockShowPortSS.Visibility = Visibility.Visible; - TextBlockCurrentlySelectedPlanPortSS.Visibility = Visibility.Visible; - //显示密码 - TextBlockShowUUIDSS.Visibility = Visibility.Visible; - TextBlockCurrentlySelectedPlanUUIDSS.Visibility = Visibility.Visible; - //显示加密方式 - TextBlockShowMethodSS.Visibility = Visibility.Visible; - TextBlockCurrentlySelectedPlanMethodSS.Visibility = Visibility.Visible; - //显示域名 - TextBlockShowDomainSS.Visibility = Visibility.Visible; - TextBlockCurrentlySelectedPlanDomainSS.Visibility = Visibility.Visible; - //隐藏WebSocket路径 - TextBlockShowPathSS.Visibility = Visibility.Visible; - TextBlockCurrentlySelectedPlanPathSS.Visibility = Visibility.Visible; - //显示伪装网站 - TextBlockShowFakeWebsiteSS.Visibility = Visibility.Visible; - TextBlockCurrentlySelectedPlanFakeWebsiteSS.Visibility = Visibility.Visible; - } - - } - - //传送SS参数,启动SS安装进程 - private void Button_LoginSS_Click(object sender, RoutedEventArgs e) - - { - ConnectionInfo connectionInfo = GenerateConnectionInfo(); - if (connectionInfo == null) - { - //****** "远程主机连接信息有误,请检查!" ****** - MessageBox.Show(Application.Current.FindResource("MessageBoxShow_ErrorHostConnection").ToString()); - return; - } - - //读取模板配置 - - //生成客户端配置时,连接的服务主机的IP或者域名 - if (String.IsNullOrEmpty(ReceiveConfigurationParameters[4]) == true) - { - ReceiveConfigurationParameters[4] = PreTrim(TextBoxHost.Text); - testDomain = false; - } - //选择模板 - if (String.IsNullOrEmpty(ReceiveConfigurationParameters[0]) == true) - { - //******"请先选择配置模板!"****** - MessageBox.Show(Application.Current.FindResource("MessageBoxShow_ChooseTemplate").ToString()); - return; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "NonePluginSS") - || String.Equals(ReceiveConfigurationParameters[0], "ObfsPluginHttpWebSS") - || String.Equals(ReceiveConfigurationParameters[0], "WebSocketSS") - || String.Equals(ReceiveConfigurationParameters[0], "KcptunPluginSS") - ) - { - testDomain = false; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "GoQuietPluginSS") - || String.Equals(ReceiveConfigurationParameters[0], "CloakPluginSS") - || String.Equals(ReceiveConfigurationParameters[0], "QuicSS") - || String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLSWebFrontSS") - || String.Equals(ReceiveConfigurationParameters[0], "ObfsPluginHttpsWebSS") - ) - { - testDomain = true; - } - - installationDegree = 0; - TextBoxMonitorCommandResults.Text = ""; - Thread thread = new Thread(() => StartSetUpSS(connectionInfo)); - thread.SetApartmentState(ApartmentState.STA); - thread.Start(); - - } - - //登录远程主机布署SS程序 - private void StartSetUpSS(ConnectionInfo connectionInfo) - { - functionResult = true; - onlyIpv6 = false; - getApt = false; - getDnf = false; - getYum = false; - - //******"正在登录远程主机......"****** - SetUpProgressBarProcessing(1); - string currentStatus = Application.Current.FindResource("DisplayInstallInfo_Login").ToString(); - MainWindowsShowInfo(currentStatus); - - try - { - #region 主机指纹,暂未启用 - //byte[] expectedFingerPrint = new byte[] { - // 0x66, 0x31, 0xaf, 0x00, 0x54, 0xb9, 0x87, 0x31, - // 0xff, 0x58, 0x1c, 0x31, 0xb1, 0xa2, 0x4c, 0x6b - // }; - #endregion - using (var client = new SshClient(connectionInfo)) - - { - #region ssh登录验证主机指纹代码块,暂未启用 - // client.HostKeyReceived += (sender, e) => - // { - // if (expectedFingerPrint.Length == e.FingerPrint.Length) - // { - // for (var i = 0; i < expectedFingerPrint.Length; i++) - // { - // if (expectedFingerPrint[i] != e.FingerPrint[i]) - // { - // e.CanTrust = false; - // break; - // } - // } - // } - // else - // { - // e.CanTrust = false; - // } - // }; - #endregion - - client.Connect(); - if (client.IsConnected == true) - { - //******"主机登录成功"****** - SetUpProgressBarProcessing(3); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_LoginSuccessful").ToString(); - MainWindowsShowInfo(currentStatus); - } - - //检测root权限 5--7 - functionResult = RootAuthorityDetect(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //检测是否已安装代理 8--10 - functionResult = SoftInstalledIsNoYes(client, "ss-server", @"/usr/local/bin/ss-server"); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //检测关闭Selinux及系统组件是否齐全(apt-get/yum/dnf/systemctl)11--30 - //安装依赖软件,检测端口,防火墙开启端口 - functionResult = ShutDownSelinuxAndSysComponentsDetect(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //如果使用是TLS模式,需要检测域名解析是否正确 - if (testDomain == true) - { - //检测域名是否解析到当前IP上 34---36 - functionResult = DomainResolutionCurrentIPDetect(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - } - //****** "系统环境检测完毕,符合安装要求,开始布署......" ****** - SetUpProgressBarProcessing(37); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_StartInstalling").ToString(); - MainWindowsShowInfo(currentStatus); - - //下载安装脚本安装 - //****** "正在安装SS,使用编译方式,时间稍长,请耐心等待............" ****** - SetUpProgressBarProcessing(38); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_StartInstallSoft").ToString() + "SS," + Application.Current.FindResource("DisplayInstallInfo_ExplainBuildSS").ToString(); - MainWindowsShowInfo(currentStatus); - - saveShellScriptFileName = GenerateRandomScriptFileName(GenerateRandomStr(10)); - - sshShellCommand = $"curl -o {saveShellScriptFileName} https://raw.githubusercontent.com/proxysu/shellscript/master/ss/ss-install.sh"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - functionResult = FileCheckExists(client, $"{saveShellScriptFileName}"); - if (functionResult == false) - { - //***文件下载失败!*** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_DownloadScriptFailed").ToString(); - MainWindowsShowInfo(currentStatus); - return; - } - - sshShellCommand = $"yes | bash {saveShellScriptFileName}"; - TextBoxMonitorCommandResults.Dispatcher.BeginInvoke(updateMonitorAction, TextBoxMonitorCommandResults, sshShellCommand);//显示执行的命令 - - //****** "编译中,请耐心等待............" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_CompilingSS").ToString(); - MainWindowsShowInfo(currentStatus); - - Thread threadWaitSScompile = new Thread(() => MonitorCompileSSprocess()); - threadWaitSScompile.SetApartmentState(ApartmentState.STA); - threadWaitSScompile.Start(); - - //开始编译。。。 - currentShellCommandResult = client.RunCommand(sshShellCommand).Result; - compileSSend = true; //中止显示"**"的线程 - threadWaitSScompile.Abort(); - TextBoxMonitorCommandResults.Dispatcher.BeginInvoke(updateMonitorAction, TextBoxMonitorCommandResults, currentShellCommandResult);//显示命令执行的结果 - - sshShellCommand = $"rm -f {saveShellScriptFileName}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //程序是否安装成功检测并设置开机启动 41--43 - functionResult = SoftInstalledSuccessOrFail(client, "ss-server", @"/usr/local/bin/ss-server"); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //****** "上传配置文件......" ****** - SetUpProgressBarProcessing(44); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_UploadSoftConfig").ToString(); - MainWindowsShowInfo(currentStatus); - - sshShellCommand = @"mv /etc/shadowsocks-libev/config.json /etc/shadowsocks-libev/config.json.1"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //string getIpv4 = client.RunCommand(@"curl -4 ip.sb").Result; - //string getIpv6 = client.RunCommand(@"wget -qO- -t1 -T2 ipv6.icanhazip.com").Result; - - //生成服务端配置 - - string serverConfig = $"{pwdir}" + @"TemplateConfg\ss\ss_server_config.json"; - string ssPluginType = ""; - using (StreamReader reader = File.OpenText(serverConfig)) - { - JObject serverJson = (JObject)JToken.ReadFrom(new JsonTextReader(reader)); - - //设置服务器监听地址 - //if (String.IsNullOrEmpty(getIpv6) == true) - //{ - serverJson["server"] = "0.0.0.0"; - //} - //else - //{ - // JArray serverIp = JArray.Parse(@"[""[::0]"", ""0.0.0.0""]"); - // serverJson["server"] = serverIp; - //} - - //设置密码 - serverJson["password"] = ReceiveConfigurationParameters[2]; - //设置监听端口 - serverJson["server_port"] = int.Parse(ReceiveConfigurationParameters[1]); - //设置加密方式 - serverJson["method"] = ReceiveConfigurationParameters[3]; - //产生伪装Web的监听端口 - randomCaddyListenPort = GetRandomPort(); - - string failoverPort = randomCaddyListenPort.ToString(); - //obfs http模式 - if (String.Equals(ReceiveConfigurationParameters[0], "ObfsPluginHttpWebSS") == true) - { - serverJson["plugin"] = @"obfs-server"; - serverJson["plugin_opts"] = $"obfs=http;failover=127.0.0.1:{failoverPort}"; - //客户端项 - ReceiveConfigurationParameters[5] = @"obfs-local"; - ReceiveConfigurationParameters[9] = "obfs=http;obfs-host=www.bing.com"; - - } - else if (String.Equals(ReceiveConfigurationParameters[0], "ObfsPluginHttpsWebSS") == true) - { - serverJson["plugin"] = @"obfs-server"; - serverJson["plugin_opts"] = $"obfs=tls;failover=127.0.0.1:{failoverPort}"; - //客户端项 - ReceiveConfigurationParameters[5] = @"obfs-local"; - ReceiveConfigurationParameters[9] = $"obfs=tls;obfs-host={ReceiveConfigurationParameters[4]}"; - - } - else if (String.Equals(ReceiveConfigurationParameters[0], "WebSocketSS") == true) - { - serverJson["plugin"] = @"v2ray-plugin"; - serverJson["plugin_opts"] = $"server"; - //客户端项 - ReceiveConfigurationParameters[5] = @"v2ray-plugin"; - ReceiveConfigurationParameters[9] = ""; - - } - else if (String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLSWebFrontSS") == true) - { - serverJson["server_port"] = 10000; - serverJson["plugin"] = @"v2ray-plugin"; - serverJson["plugin_opts"] = $"server;host={ReceiveConfigurationParameters[4]};path={ReceiveConfigurationParameters[6]}"; - - //客户端项 - ReceiveConfigurationParameters[5] = @"v2ray-plugin"; - ReceiveConfigurationParameters[9] = $"tls;host={ReceiveConfigurationParameters[4]};path={ReceiveConfigurationParameters[6]}"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "QuicSS") == true) - { - serverJson["mode"] = "tcp"; - serverJson["plugin"] = @"v2ray-plugin"; - serverJson["plugin_opts"] = $"server;mode=quic;host={ReceiveConfigurationParameters[4]}"; - //客户端项 - ReceiveConfigurationParameters[5] = @"v2ray-plugin"; - ReceiveConfigurationParameters[9] = $"mode=quic;host={ReceiveConfigurationParameters[4]}"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "KcptunPluginSS") == true) - { - serverJson["mode"] = "tcp"; - serverJson["plugin"] = @"kcptun-plugin-server"; - serverJson["plugin_opts"] = $"key={ReceiveConfigurationParameters[2]}"; - //客户端项 - ReceiveConfigurationParameters[5] = @"kcptun"; - ReceiveConfigurationParameters[9] = $"key={ReceiveConfigurationParameters[2]}"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "GoQuietPluginSS") == true) - { - serverJson["plugin"] = @"goquiet-plugin-server"; - serverJson["plugin_opts"] = $"WebServerAddr=127.0.0.1:{failoverPort};Key={ReceiveConfigurationParameters[2]}"; - //客户端项 - ReceiveConfigurationParameters[5] = @"goquiet"; - ReceiveConfigurationParameters[9] = $"ServerName={ReceiveConfigurationParameters[4]};Key={ReceiveConfigurationParameters[2]};Browser=chrome"; - - } - else if (String.Equals(ReceiveConfigurationParameters[0], "CloakPluginSS") == true) - { - //****** "正在安装 Cloak-Plugin......" ****** - SetUpProgressBarProcessing(48); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_StartInstallSoft").ToString() + " Cloak-Plugin......"; - MainWindowsShowInfo(currentStatus); - - saveShellScriptFileName = GenerateRandomScriptFileName(GenerateRandomStr(10)); - - sshShellCommand = $"curl -o {saveShellScriptFileName} https://raw.githubusercontent.com/proxysu/shellscript/master/ss/ss-plugins/cloak-plugin-install.sh"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - functionResult = FileCheckExists(client, $"{saveShellScriptFileName}"); - if (functionResult == false) - { - //***文件下载失败!*** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_DownloadScriptFailed").ToString(); - MainWindowsShowInfo(currentStatus); - return; - } - - sshShellCommand = $"yes | bash {saveShellScriptFileName}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = $"rm -f {saveShellScriptFileName}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //程序是否安装成功检测并设置开机启动 41--43 - functionResult = SoftInstalledSuccessOrFail(client, "cloak-plugin-server", @"/usr/local/bin/cloak-plugin-server"); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - - string bypassUID = client.RunCommand(@"/usr/local/bin/cloak-plugin-server -u").Result.TrimEnd('\r', '\n'); - string generateKey = client.RunCommand(@"/usr/local/bin/cloak-plugin-server -k").Result.TrimEnd('\r', '\n'); - string[] keyCloak = generateKey.Split(new char[] { ',' }); - string publicKey = keyCloak[0]; - string privateKey = keyCloak[1]; - - serverJson["plugin"] = @"cloak-plugin-server"; - serverJson["plugin_opts"] = $"BypassUID={bypassUID};PrivateKey={privateKey};RedirAddr=127.0.0.1:{failoverPort};DatabasePath=/etc/shadowsocks-libev/userinfo.db;StreamTimeout=300"; - //客户端项 - ReceiveConfigurationParameters[5] = @"cloak"; - ReceiveConfigurationParameters[9] = $"UID={bypassUID};PublicKey={publicKey};Transport=direct;ServerName={ReceiveConfigurationParameters[4]};BrowserSig=chrome;NumConn=4;EncryptionMethod=plain;StreamTimeout=300"; - - } - ssPluginType = (string)serverJson["plugin"]; - using (StreamWriter sw = new StreamWriter(@"config.json")) - { - sw.Write(serverJson.ToString()); - } - } - - string upLoadPath = @"/etc/shadowsocks-libev/config.json"; - UploadConfig(connectionInfo, @"config.json", upLoadPath); - - File.Delete(@"config.json"); - - //安装所使用的插件 - if (String.Equals(ssPluginType, "obfs-server")) - { - //****** "正在安装 Simple-obfs Plugin......" ****** - SetUpProgressBarProcessing(48); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_StartInstallSoft").ToString() + " Simple-obfs Plugin......"; - MainWindowsShowInfo(currentStatus); - - saveShellScriptFileName = GenerateRandomScriptFileName(GenerateRandomStr(10)); - - sshShellCommand = $"curl -o {saveShellScriptFileName} https://raw.githubusercontent.com/proxysu/shellscript/master/ss/ss-plugins/obfs-install.sh"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - functionResult = FileCheckExists(client, $"{saveShellScriptFileName}"); - if (functionResult == false) - { - //***文件下载失败!*** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_DownloadScriptFailed").ToString(); - MainWindowsShowInfo(currentStatus); - return; - } - - sshShellCommand = $"yes | bash {saveShellScriptFileName}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = $"rm -f {saveShellScriptFileName}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //程序是否安装成功检测并设置开机启动 41--43 - functionResult = SoftInstalledSuccessOrFail(client, "obfs-server", @"/usr/local/bin/obfs-server"); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - - } - else if (String.Equals(ssPluginType, "v2ray-plugin")) - { - //****** "正在安装 V2Ray-Plugin......" ****** - SetUpProgressBarProcessing(48); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_StartInstallSoft").ToString() + " V2Ray-Plugin......"; - MainWindowsShowInfo(currentStatus); - - saveShellScriptFileName = GenerateRandomScriptFileName(GenerateRandomStr(10)); - - sshShellCommand = $"curl -o {saveShellScriptFileName} https://raw.githubusercontent.com/proxysu/shellscript/master/ss/ss-plugins/v2ray-plugin-install.sh"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - functionResult = FileCheckExists(client, $"{saveShellScriptFileName}"); - if (functionResult == false) - { - //***文件下载失败!*** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_DownloadScriptFailed").ToString(); - MainWindowsShowInfo(currentStatus); - return; - } - - sshShellCommand = $"yes | bash {saveShellScriptFileName}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = $"rm -f {saveShellScriptFileName}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //程序是否安装成功检测并设置开机启动 41--43 - functionResult = SoftInstalledSuccessOrFail(client, "v2ray-plugin", @"/usr/local/bin/v2ray-plugin"); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - } - else if (String.Equals(ssPluginType, "kcptun-plugin-server")) - { - //****** "正在安装 Kcptun-Plugin......" ****** - SetUpProgressBarProcessing(48); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_StartInstallSoft").ToString() + " Kcptun-Plugin......"; - MainWindowsShowInfo(currentStatus); - - saveShellScriptFileName = GenerateRandomScriptFileName(GenerateRandomStr(10)); - - sshShellCommand = $"curl -o {saveShellScriptFileName} https://raw.githubusercontent.com/proxysu/shellscript/master/ss/ss-plugins/kcptun-plugin-install.sh"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - functionResult = FileCheckExists(client, $"{saveShellScriptFileName}"); - if (functionResult == false) - { - //***文件下载失败!*** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_DownloadScriptFailed").ToString(); - MainWindowsShowInfo(currentStatus); - return; - } - - sshShellCommand = $"yes | bash {saveShellScriptFileName}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = $"rm -f {saveShellScriptFileName}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //程序是否安装成功检测并设置开机启动 41--43 - functionResult = SoftInstalledSuccessOrFail(client, "kcptun-plugin-server", @"/usr/local/bin/kcptun-plugin-server"); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - } - else if (String.Equals(ssPluginType, "goquiet-plugin-server")) - { - //****** "正在安装 GoQuiet-Plugin......" ****** - SetUpProgressBarProcessing(48); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_StartInstallSoft").ToString() + " GoQuiet-Plugin......"; - MainWindowsShowInfo(currentStatus); - - saveShellScriptFileName = GenerateRandomScriptFileName(GenerateRandomStr(10)); - - sshShellCommand = $"curl -o {saveShellScriptFileName} https://raw.githubusercontent.com/proxysu/shellscript/master/ss/ss-plugins/goquiet-plugin-install.sh"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - functionResult = FileCheckExists(client, $"{saveShellScriptFileName}"); - if (functionResult == false) - { - //***文件下载失败!*** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_DownloadScriptFailed").ToString(); - MainWindowsShowInfo(currentStatus); - return; - } - - sshShellCommand = $"yes | bash {saveShellScriptFileName}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = $"rm -f {saveShellScriptFileName}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //程序是否安装成功检测并设置开机启动 41--43 - functionResult = SoftInstalledSuccessOrFail(client, "goquiet-plugin-server", @"/usr/local/bin/goquiet-plugin-server"); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - } - else if (String.Equals(ssPluginType, "cloak-plugin-server")) - { - - } - - - //如果使用v2ray-plugin Quic模式,先要安装acme.sh,申请证书 - if (String.Equals(ReceiveConfigurationParameters[0], "QuicSS") == true) - { - //acme.sh安装与申请证书 51--57 - functionResult = AcmeShInstall(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - } - - //如果使用Web伪装网站模式,需要安装Caddy - if (String.Equals(ReceiveConfigurationParameters[0], "ObfsPluginHttpWebSS") == true - || String.Equals(ReceiveConfigurationParameters[0], "ObfsPluginHttpsWebSS") == true - || String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLSWebFrontSS") == true - || String.Equals(ReceiveConfigurationParameters[0], "GoQuietPluginSS") == true - || String.Equals(ReceiveConfigurationParameters[0], "CloakPluginSS") == true - ) - { - //Caddy安装 61--66 - functionResult = CaddyInstall(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //****** "上传Caddy配置文件......" ****** - SetUpProgressBarProcessing(67); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_UploadCaddyConfig").ToString(); - MainWindowsShowInfo(currentStatus); - - sshShellCommand = @"mv /etc/caddy/Caddyfile /etc/caddy/Caddyfile.bak"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - if (String.Equals(ReceiveConfigurationParameters[0], "ObfsPluginHttpWebSS") == true) - { - serverConfig = $"{pwdir}" + @"TemplateConfg\ss\ss_obfs_http_web_config.caddyfile"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "ObfsPluginHttpsWebSS") == true - || String.Equals(ReceiveConfigurationParameters[0], "GoQuietPluginSS") == true - || String.Equals(ReceiveConfigurationParameters[0], "CloakPluginSS") == true) - { - serverConfig = $"{pwdir}" + @"TemplateConfg\ss\ss_tls_caddy_config.caddyfile"; - } - else if (String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLSWebFrontSS") == true) - { - serverConfig = $"{pwdir}" + @"TemplateConfg\ss\WebSocketTLSWeb.caddyfile"; - } - - upLoadPath = @"/etc/caddy/Caddyfile"; - - UploadConfig(connectionInfo, serverConfig, upLoadPath); - - //设置Caddy配置文件 - functionResult = SetCaddyfile(client, @"/etc/caddy/Caddyfile"); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //****** "Caddy配置文件上传成功,OK!" ****** - SetUpProgressBarProcessing(70); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_UploadCaddyConfigOK").ToString(); - MainWindowsShowInfo(currentStatus); - - //程序启动检测Caddy - functionResult = SoftStartDetect(client, "caddy", @"/usr/bin/caddy"); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - } - - //程序启动检测SS - functionResult = SoftStartDetect(client, "ss-server", @"/usr/local/bin/ss-server"); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //检测BBR,满足条件并启动 90--95 - functionResult = DetectBBRandEnable(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - - client.Disconnect();//断开服务器ssh连接 - - //****** "生成客户端配置......" ****** - SetUpProgressBarProcessing(96); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_GenerateClientConfig").ToString(); - MainWindowsShowInfo(currentStatus); - - //****** "SS安装成功,祝你玩的愉快!!" ****** - SetUpProgressBarProcessing(100); - currentStatus = "SS" + Application.Current.FindResource("DisplayInstallInfo_ProxyInstalledOK").ToString(); - MainWindowsShowInfo(currentStatus); - - //显示服务端连接参数 - proxyType = "SS"; - ResultClientInformation resultClientInformation = new ResultClientInformation(); - resultClientInformation.ShowDialog(); - - return; - } - } - catch (Exception ex1)//例外处理 - #region 例外处理 - { - ProcessException(ex1.Message); - - //****** "安装失败!" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_LoginFailed").ToString(); - MainWindowsShowInfo(currentStatus); - } - #endregion - } - - //编译SS时,中间监视窗口显示"****"不断增长进度,直到编译结束 - private static bool compileSSend = false; - private void MonitorCompileSSprocess() - { - currentShellCommandResult = "**"; - while (compileSSend == false) - { - TextBoxMonitorCommandResults.Dispatcher.BeginInvoke(updateMonitorActionNoWrap, TextBoxMonitorCommandResults, currentShellCommandResult);//显示命令执行的结果 - Thread.Sleep(1000); - } - } - - #endregion - - #region MTProto相关 - //传递参数启动安装进程 - private void ButtonMtgSetUp_Click(object sender, RoutedEventArgs e) - { - ConnectionInfo connectionInfo = GenerateConnectionInfo(); - if (connectionInfo == null) - { - //****** "远程主机连接信息有误,请检查!" ****** - MessageBox.Show(Application.Current.FindResource("MessageBoxShow_ErrorHostConnection").ToString()); - return; - } - //清空参数空间 - for (int i = 0; i != ReceiveConfigurationParameters.Length; i++) - - { - ReceiveConfigurationParameters[i] = ""; - } - //传递服务器地址 - ReceiveConfigurationParameters[4] = PreTrim(TextBoxHost.Text); ; - //传递服务端口 - ReceiveConfigurationParameters[1] = PreTrim(TextBoxMtgHostPort.Text); - //传递伪装域名 - if (String.IsNullOrEmpty(PreTrim(TextBoxMtgSites.Text)) == true) - { - ReceiveConfigurationParameters[7] = "azure.microsoft.com"; - } - else - { - ReceiveConfigurationParameters[7] = PreTrim(TextBoxMtgSites.Text); - } - installationDegree = 0; - TextBoxMonitorCommandResults.Text = ""; - Thread thread = new Thread(() => StartSetUpMtg(connectionInfo)); - thread.SetApartmentState(ApartmentState.STA); - thread.Start(); - } - - //Mtg安装进程 - private void StartSetUpMtg(ConnectionInfo connectionInfo) - { - functionResult = true; - onlyIpv6 = false; - getApt = false; - getDnf = false; - getYum = false; - - //******"正在登录远程主机......"****** - SetUpProgressBarProcessing(1); - string currentStatus = Application.Current.FindResource("DisplayInstallInfo_Login").ToString(); - MainWindowsShowInfo(currentStatus); - - try - { - #region 主机指纹,暂未启用 - //byte[] expectedFingerPrint = new byte[] { - // 0x66, 0x31, 0xaf, 0x00, 0x54, 0xb9, 0x87, 0x31, - // 0xff, 0x58, 0x1c, 0x31, 0xb1, 0xa2, 0x4c, 0x6b - // }; - #endregion - using (var client = new SshClient(connectionInfo)) - - { - #region ssh登录验证主机指纹代码块,暂未启用 - // client.HostKeyReceived += (sender, e) => - // { - // if (expectedFingerPrint.Length == e.FingerPrint.Length) - // { - // for (var i = 0; i < expectedFingerPrint.Length; i++) - // { - // if (expectedFingerPrint[i] != e.FingerPrint[i]) - // { - // e.CanTrust = false; - // break; - // } - // } - // } - // else - // { - // e.CanTrust = false; - // } - // }; - #endregion - - client.Connect(); - if (client.IsConnected == true) - { - //******"主机登录成功"****** - SetUpProgressBarProcessing(3); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_LoginSuccessful").ToString(); - MainWindowsShowInfo(currentStatus); - } - - //检测root权限 5--7 - functionResult = RootAuthorityDetect(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //检测是否已安装代理 8--10 - functionResult = SoftInstalledIsNoYes(client, "mtg", @"/usr/local/bin/mtg"); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //检测关闭Selinux及系统组件是否齐全(apt-get/yum/dnf/systemctl)11--30 - //安装依赖软件,检测端口,防火墙开启端口 - functionResult = ShutDownSelinuxAndSysComponentsDetect(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //检测是否为64位系统 - sshShellCommand = @"uname -m"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - string resultCmd = currentShellCommandResult; - if (resultCmd.Contains("x86_64") == false) - { - //******"请在x86_64系统中安装MTProto" ****** - MessageBox.Show(Application.Current.FindResource("MessageBoxShow_PleaseInstallSoftAtX64").ToString() + "MTProto......"); - //****** "系统环境不满足要求,安装失败!!" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_MissingSystemComponents").ToString(); - MainWindowsShowInfo(currentStatus); - return; - } - - //下载安装脚本安装MTProto 37--40 - - functionResult = MTProtoInstall(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //程序是否安装成功检测并设置开机启动 41--43 - functionResult = SoftInstalledSuccessOrFail(client, "mtg", @"/usr/local/bin/mtg"); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //****** "正在启动MTProto......" ****** - SetUpProgressBarProcessing(70); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_StartSoft").ToString() + "MTProto......"; - MainWindowsShowInfo(currentStatus); - - //启动MTProto服务 - functionResult = SoftStartDetect(client, "mtg", @"/usr/local/bin/mtg"); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - //****** "生成客户端配置......" ****** - SetUpProgressBarProcessing(80); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_GenerateClientConfig").ToString(); - MainWindowsShowInfo(currentStatus); - - sshShellCommand = @"systemctl stop mtg"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - sshShellCommand = @"cat /usr/local/etc/mtg.sh"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - sshShellCommand = currentShellCommandResult; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - Thread.Sleep(3000); - sshShellCommand = @"cat /usr/local/etc/mtg_info.json"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - ReceiveConfigurationParameters[9] = currentShellCommandResult; - if (String.IsNullOrEmpty(ReceiveConfigurationParameters[9]) == true) - { - Thread.Sleep(3000); - sshShellCommand = @"cat /usr/local/etc/mtg_info.json"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - ReceiveConfigurationParameters[9] = currentShellCommandResult; - } - sshShellCommand = @"pkill mtg"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - sshShellCommand = @"systemctl restart mtg"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - if (String.IsNullOrEmpty(ReceiveConfigurationParameters[9]) == true) - { - //***客户端配置获取失败!*** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_GetClientConfigFailed").ToString(); - MainWindowsShowInfo(currentStatus); - FunctionResultErr(); - client.Disconnect(); - return; - } - - //检测BBR,满足条件并启动 90--95 - functionResult = DetectBBRandEnable(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - client.Disconnect();//断开服务器ssh连接 - - //Thread.Sleep(1000); - //if (!Directory.Exists("mtproto_config"))//如果不存在就创建file文件夹      - //{ - // Directory.CreateDirectory("mtproto_config");//创建该文件夹   - //} - //using (StreamWriter sw = new StreamWriter(@"mtproto_config\mtproto_info.json")) - //{ - // sw.Write(currentShellCommandResult.ToString()); - //} - - //****** "MTProto+TLS安装成功,祝你玩的愉快!!" ****** - SetUpProgressBarProcessing(100); - currentStatus = "MTProto+TLS" + Application.Current.FindResource("DisplayInstallInfo_ProxyInstalledOK").ToString(); - MainWindowsShowInfo(currentStatus); - - //显示服务端连接参数 - proxyType = "MTProto"; - - ResultClientInformation resultClientInformation = new ResultClientInformation(); - resultClientInformation.ShowDialog(); - return; - } - } - catch (Exception ex1)//例外处理 - #region 例外处理 - { - ProcessException(ex1.Message); - - //****** "安装失败!" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_LoginFailed").ToString(); - MainWindowsShowInfo(currentStatus); - } - #endregion - - } - - //下载安装脚本安装MTProto 37--40 - //functionResult = MTProtoInstall(client); - //if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - private bool MTProtoInstall(SshClient client) - { - //****** "系统环境检测完毕,符合安装要求,开始布署......" ****** - SetUpProgressBarProcessing(37); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_StartInstalling").ToString(); - MainWindowsShowInfo(currentStatus); - - //下载安装脚本安装 - //****** "正在安装MTProto......" ****** - SetUpProgressBarProcessing(38); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_StartInstallSoft").ToString() + "MTProto......"; - MainWindowsShowInfo(currentStatus); - - saveShellScriptFileName = GenerateRandomScriptFileName(GenerateRandomStr(10)); - - sshShellCommand = $"curl -o {saveShellScriptFileName} https://raw.githubusercontent.com/proxysu/shellscript/master/MTProto/mtg_install.sh"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - functionResult = FileCheckExists(client, $"{saveShellScriptFileName}"); - if (functionResult == false) - { - //***文件下载失败!*** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_DownloadScriptFailed").ToString(); - MainWindowsShowInfo(currentStatus); - return false; - } - - sshShellCommand = $"yes | bash {saveShellScriptFileName} {ReceiveConfigurationParameters[1]} {ReceiveConfigurationParameters[7]}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = $"rm -f {saveShellScriptFileName}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - SetUpProgressBarProcessing(40); - return true; - } - #endregion - - #region 其他功能函数及系统工具相关 - //TextBox输入内容做预处理 - private string PreTrim(string preString) - { - return preString.Trim(); - } - //产生随机端口 - private int GetRandomPort() - { - Random random = new Random(); - return random.Next(10001, 60000); - } - - //产生随机字符串 - private string GenerateRandomStr(int length) - { - var rand = System.Security.Cryptography.RandomNumberGenerator.Create(); - byte[] bytes = new byte[length * 2]; - rand.GetBytes(bytes); - string randStr = Convert.ToBase64String(bytes); - randStr = randStr.Replace("+", "").Replace("/", "").Replace("=", "").Substring(0, length); - //MessageBox.Show(randStr); - return randStr; - } - //生成保存的shell脚本名称 - private string GenerateRandomScriptFileName(string filename) - { - return "/tmp/tmp." + filename + ".sh"; - } - //判断目录是否存在,不存在则创建 - private static bool CheckDir(string folder) - { - try - { - if (!Directory.Exists(folder))//如果不存在就创建file文件夹 - Directory.CreateDirectory(folder);//创建该文件夹   - return true; - } - catch (Exception) - { - return false; - } - } - - //目录已存在则生成序号递增,并返回所创建的目录路径。 - private string CreateConfigSaveDir(string upperDir, string configDir) - { - try - { - //string saveFileFolderFirst = configDir; - int num = 1; - //string saveFileFolder; - //saveFileFolder = EncodeURIComponent(configDir); - string saveFileFolder = configDir.Replace(":", "_"); - CheckDir(upperDir); - while (Directory.Exists(upperDir + @"\" + saveFileFolder) == true) - { - saveFileFolder = configDir + "_copy_" + num.ToString(); - num++; - } - CheckDir(upperDir + @"\" + saveFileFolder); - return upperDir + @"\" + saveFileFolder; - } - catch (Exception) - { - //string saveFileFolder = ""; - //return upperDir + @"\" + saveFileFolder; - return upperDir; - } - - } - - - //上传配置文件 - private void UploadConfig(ConnectionInfo connectionInfo, string uploadConfig, string upLoadPath) - { - try - { - using (var sftpClient = new SftpClient(connectionInfo)) - { - sftpClient.Connect(); - FileStream openUploadConfigFile = File.OpenRead(uploadConfig); - sftpClient.UploadFile(openUploadConfigFile, upLoadPath, true); - openUploadConfigFile.Close(); - sftpClient.Disconnect(); - } - - } - catch (Exception ex2) - { - MessageBox.Show("sftp" + ex2.ToString()); - //MessageBox.Show("sftp出现未知错误,上传文件失败,请重试!"); - return; - } - } - - //下载配置文件 - private void DownloadConfig(ConnectionInfo connectionInfo, string localConfigSavePathAndFileName, string remoteConfigPathAndFileName) - { - try - { - using (var sftpClient = new SftpClient(connectionInfo)) - { - sftpClient.Connect(); - FileStream createDownloadConfig = File.Open(localConfigSavePathAndFileName, FileMode.Create); - sftpClient.DownloadFile(remoteConfigPathAndFileName, createDownloadConfig); - createDownloadConfig.Close(); - - sftpClient.Disconnect(); - } - - } - catch (Exception ex2) - { - MessageBox.Show("sftp" + ex2.ToString()); - //MessageBox.Show("sftp出现未知错误,下载文件失败,请重试!"); - return; - } - } - - //伪装网站处理 - //private string DisguiseURLprocessing(string fakeUrl) - //{ - //var uri = new Uri(fakeUrl); - //return uri.Host; - - ////处理伪装网站域名中的前缀 - //if (fakeUrl.Length >= 7) - //{ - // string testDomainMask = fakeUrl.Substring(0, 7); - // if (String.Equals(testDomainMask, "https:/") || String.Equals(testDomainMask, "http://")) - // { - // //MessageBox.Show(testDomain); - // string[] tmpUrl = fakeUrl.Split('/'); - // //MainWindow.ReceiveConfigurationParameters[7] = TextBoxMaskSites.Text.Replace("/", "\\/"); - // fakeUrl = tmpUrl[2]; - // } - - //} - //return fakeUrl; - // } - - #region 检测系统内核是否符合安装要求 - //private static bool DetectKernelVersion(string kernelVer) - //{ - // string[] linuxKernelCompared = kernelVer.Split('.'); - // if (int.Parse(linuxKernelCompared[0]) > 2) - // { - // //MessageBox.Show($"当前系统内核版本为{result.Result},符合安装要求!"); - // return true; - // } - // else if (int.Parse(linuxKernelCompared[0]) < 2) - // { - // //MessageBox.Show($"当前系统内核版本为{result.Result},V2ray要求内核为2.6.23及以上。请升级内核再安装!"); - // return false; - // } - // else if (int.Parse(linuxKernelCompared[0]) == 2) - // { - // if (int.Parse(linuxKernelCompared[1]) > 6) - // { - // //MessageBox.Show($"当前系统内核版本为{result.Result},符合安装要求!"); - // return true; - // } - // else if (int.Parse(linuxKernelCompared[1]) < 6) - // { - // //MessageBox.Show($"当前系统内核版本为{result.Result},V2ray要求内核为2.6.23及以上。请升级内核再安装!"); - // return false; - // } - // else if (int.Parse(linuxKernelCompared[1]) == 6) - // { - // if (int.Parse(linuxKernelCompared[2]) < 23) - // { - // //MessageBox.Show($"当前系统内核版本为{result.Result},V2ray要求内核为2.6.23及以上。请升级内核再安装!"); - // return false; - // } - // else - // { - // //MessageBox.Show($"当前系统内核版本为{result.Result},符合安装要求!"); - // return true; - // } - - // } - // } - // return false; - - //} - #endregion - - //打开系统工具中的校对时间窗口 - private void ButtonProofreadTime_Click(object sender, RoutedEventArgs e) - { - ConnectionInfo connectionInfo = GenerateConnectionInfo(); - if (connectionInfo == null) - { - //****** "远程主机连接信息有误,请检查!" ****** - MessageBox.Show(Application.Current.FindResource("MessageBoxShow_ErrorHostConnection").ToString()); - return; - } - - ProofreadTimeWindow proofreadTimeWindow = new ProofreadTimeWindow(); - ProofreadTimeWindow.ProfreadTimeReceiveConnectionInfo = connectionInfo; - - proofreadTimeWindow.ShowDialog(); - - } - //释放80/443端口 - private void ButtonClearOccupiedPorts_Click(object sender, RoutedEventArgs e) - { - //****** "80/443端口之一,或全部被占用,将强制停止占用80/443端口的程序?" ****** - MessageBoxResult dialogResult = MessageBox.Show(Application.Current.FindResource("MessageBoxShow_ErrorPortUsed").ToString(), "Stop application", MessageBoxButton.YesNo); - if (dialogResult == MessageBoxResult.No) - { - return; - } - - ConnectionInfo testconnect = GenerateConnectionInfo(); - try - { - using (var client = new SshClient(testconnect)) - { - client.Connect(); - - //检测是否运行在root权限下 - string testRootAuthority = client.RunCommand(@"id -u").Result; - if (testRootAuthority.Equals("0\n") == false) - { - //******"请使用具有root权限的账户登录主机!!"****** - MessageBox.Show(Application.Current.FindResource("MessageBoxShow_ErrorRootPermission").ToString()); - client.Disconnect(); - return; - } - string cmdTestPort; - string cmdResult; - cmdTestPort = @"lsof -n -P -i :443 | grep LISTEN"; - cmdResult = client.RunCommand(cmdTestPort).Result; - - if (String.IsNullOrEmpty(cmdResult) == false) - { - - string[] cmdResultArry443 = cmdResult.Split(' '); - client.RunCommand($"systemctl stop {cmdResultArry443[0]}"); - client.RunCommand($"systemctl disable {cmdResultArry443[0]}"); - client.RunCommand($"kill -9 {cmdResultArry443[3]}"); - } - - cmdTestPort = @"lsof -n -P -i :80 | grep LISTEN"; - cmdResult = client.RunCommand(cmdTestPort).Result; - if (String.IsNullOrEmpty(cmdResult) == false) - { - string[] cmdResultArry80 = cmdResult.Split(' '); - client.RunCommand($"systemctl stop {cmdResultArry80[0]}"); - client.RunCommand($"systemctl disable {cmdResultArry80[0]}"); - client.RunCommand($"kill -9 {cmdResultArry80[3]}"); - } - //****** "80/443端口释放完毕!" ****** - MessageBox.Show(Application.Current.FindResource("DisplayInstallInfo_ReleasePortOK").ToString()); - client.Disconnect(); - } - } - catch (Exception ex) - { - MessageBox.Show(ex.Message); - } - } - - //启用BBR - private void ButtonTestAndEnableBBR_Click(object sender, RoutedEventArgs e) - { - ConnectionInfo connectionInfo = GenerateConnectionInfo(); - if (connectionInfo == null) - { - //****** "远程主机连接信息有误,请检查!" ****** - MessageBox.Show(Application.Current.FindResource("MessageBoxShow_ErrorHostConnection").ToString()); - return; - } - - installationDegree = 0; - TextBoxMonitorCommandResults.Text = ""; - Thread thread = new Thread(() => StartTestAndEnableBBR(connectionInfo)); - thread.SetApartmentState(ApartmentState.STA); - thread.Start(); - } - - //启用BBR的主要进程 - private void StartTestAndEnableBBR(ConnectionInfo connectionInfo) - { - functionResult = true; - onlyIpv6 = false; - getApt = false; - getDnf = false; - getYum = false; - - //******"正在登录远程主机......"****** - SetUpProgressBarProcessing(1); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_Login").ToString(); - MainWindowsShowInfo(currentStatus); - - try - { - #region 主机指纹,暂未启用 - //byte[] expectedFingerPrint = new byte[] { - // 0x66, 0x31, 0xaf, 0x00, 0x54, 0xb9, 0x87, 0x31, - // 0xff, 0x58, 0x1c, 0x31, 0xb1, 0xa2, 0x4c, 0x6b - // }; - #endregion - using (var client = new SshClient(connectionInfo)) - - { - #region ssh登录验证主机指纹代码块,暂未启用 - // client.HostKeyReceived += (sender, e) => - // { - // if (expectedFingerPrint.Length == e.FingerPrint.Length) - // { - // for (var i = 0; i < expectedFingerPrint.Length; i++) - // { - // if (expectedFingerPrint[i] != e.FingerPrint[i]) - // { - // e.CanTrust = false; - // break; - // } - // } - // } - // else - // { - // e.CanTrust = false; - // } - // }; - #endregion - - client.Connect(); - if (client.IsConnected == true) - { - //******"主机登录成功"****** - SetUpProgressBarProcessing(5); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_LoginSuccessful").ToString(); - MainWindowsShowInfo(currentStatus); - } - - //检测root权限 5--7 - functionResult = RootAuthorityDetect(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - SetUpProgressBarProcessing(30); - //****** "BBR测试......" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_TestBBR").ToString(); - MainWindowsShowInfo(currentStatus); - - sshShellCommand = @"uname -r"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - string[] linuxKernelVerStrBBR = currentShellCommandResult.Split('-'); - - bool detectResultBBR = DetectKernelVersionBBR(linuxKernelVerStrBBR[0]); - - sshShellCommand = @"sysctl net.ipv4.tcp_congestion_control | grep bbr"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - string resultCmdTestBBR = currentShellCommandResult; - //如果内核满足大于等于4.9,且还未启用BBR,则启用BBR - if (detectResultBBR == true && resultCmdTestBBR.Contains("bbr") == false) - { - SetUpProgressBarProcessing(60); - //****** "正在启用BBR......" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_EnableBBR").ToString(); - MainWindowsShowInfo(currentStatus); - - sshShellCommand = @"bash -c 'echo ""net.core.default_qdisc=fq"" >> /etc/sysctl.conf'"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"bash -c 'echo ""net.ipv4.tcp_congestion_control=bbr"" >> /etc/sysctl.conf'"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"sysctl -p"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - } - else if (resultCmdTestBBR.Contains("bbr") == true) - { - SetUpProgressBarProcessing(100); - //****** "BBR已经启用了!" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_BBRisEnabled").ToString(); - MainWindowsShowInfo(currentStatus); - - } - else - { - //****** "系统不满足启用BBR的条件,启用失败!" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_BBRFailed").ToString(); - MainWindowsShowInfo(currentStatus); - } - - client.Disconnect();//断开服务器ssh连接 - - return; - } - } - catch (Exception ex1)//例外处理 - #region 例外处理 - { - ProcessException(ex1.Message); - - //****** "主机登录失败!" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_LoginFailed").ToString(); - MainWindowsShowInfo(currentStatus); - } - #endregion - - } - - //检测要启用BBR主要的内核版本 - private static bool DetectKernelVersionBBR(string kernelVer) - { - string[] linuxKernelCompared = kernelVer.Split('.'); - if (int.Parse(linuxKernelCompared[0]) > 4) - { - return true; - } - else if (int.Parse(linuxKernelCompared[0]) < 4) - { - return false; - } - else if (int.Parse(linuxKernelCompared[0]) == 4) - { - if (int.Parse(linuxKernelCompared[1]) >= 9) - { - return true; - } - else if (int.Parse(linuxKernelCompared[1]) < 9) - { - return false; - } - - } - return false; - - } - - //启动卸载代理 - private void ButtonRemoveAllSoft_Click(object sender, RoutedEventArgs e) - { - //******"仅支持卸载由ProxySU安装的代理软件及相关配置,请确保重要配置已备份。不支持卸载使用其他方法或脚本安装的代理。确定要卸载远程主机上的代理软件吗?"****** - string messageShow = Application.Current.FindResource("MessageBoxShow_RemoveAllSoft").ToString(); - MessageBoxResult messageBoxResult = MessageBox.Show(messageShow, "", MessageBoxButton.YesNo, MessageBoxImage.Question); - if (messageBoxResult == MessageBoxResult.Yes) - { - - ConnectionInfo connectionInfo = GenerateConnectionInfo(); - if (connectionInfo == null) - { - //****** "远程主机连接信息有误,请检查!" ****** - MessageBox.Show(Application.Current.FindResource("MessageBoxShow_ErrorHostConnection").ToString()); - return; - } - - installationDegree = 0; - TextBoxMonitorCommandResults.Text = ""; - Thread thread = new Thread(() => StartRemoveProxySoft(connectionInfo)); - thread.SetApartmentState(ApartmentState.STA); - thread.Start(); - } - - } - //卸载代理进程 - private void StartRemoveProxySoft(ConnectionInfo connectionInfo) - { - functionResult = true; - getApt = false; - getDnf = false; - getYum = false; - onlyIpv6 = false; - - //******"正在登录远程主机......"****** - SetUpProgressBarProcessing(1); - string currentStatus = Application.Current.FindResource("DisplayInstallInfo_Login").ToString(); - MainWindowsShowInfo(currentStatus); - - try - { - #region 主机指纹,暂未启用 - //byte[] expectedFingerPrint = new byte[] { - // 0x66, 0x31, 0xaf, 0x00, 0x54, 0xb9, 0x87, 0x31, - // 0xff, 0x58, 0x1c, 0x31, 0xb1, 0xa2, 0x4c, 0x6b - // }; - #endregion - using (var client = new SshClient(connectionInfo)) - - { - #region ssh登录验证主机指纹代码块,暂未启用 - // client.HostKeyReceived += (sender, e) => - // { - // if (expectedFingerPrint.Length == e.FingerPrint.Length) - // { - // for (var i = 0; i < expectedFingerPrint.Length; i++) - // { - // if (expectedFingerPrint[i] != e.FingerPrint[i]) - // { - // e.CanTrust = false; - // break; - // } - // } - // } - // else - // { - // e.CanTrust = false; - // } - // }; - #endregion - - client.Connect(); - if (client.IsConnected == true) - { - //******"主机登录成功"****** - SetUpProgressBarProcessing(5); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_LoginSuccessful").ToString(); - MainWindowsShowInfo(currentStatus); - //Thread.Sleep(3000); - } - - - //检测root权限 5--7 - functionResult = RootAuthorityDetect(client); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - functionResult = FileCheckExists(client, @"/etc/resolv.conf.proxysu"); - if (functionResult == true) - { - sshShellCommand = @"mv /etc/resolv.conf.proxysu /etc/resolv.conf "; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - } - - sshShellCommand = @"command -v apt-get"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - getApt = !String.IsNullOrEmpty(currentShellCommandResult); - - sshShellCommand = @"command -v dnf"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - getDnf = !String.IsNullOrEmpty(currentShellCommandResult); - - sshShellCommand = @"command -v yum"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - getYum = !String.IsNullOrEmpty(currentShellCommandResult); - - //设置安装软件所用的命令格式 - if (getApt == true) - { - sshCmdUpdate = @"apt-get update"; - //sshCmdInstall = @"apt-get -y install "; - } - else if (getDnf == true) - { - sshCmdUpdate = @"dnf clean all;dnf makecache"; - //sshCmdInstall = @"dnf -y install "; - } - else if (getYum == true) - { - sshCmdUpdate = @"yum clean all; yum makecache"; - //sshCmdInstall = @"yum -y install "; - } - - //检测主机是否为纯ipv6的主机 - onlyIpv6 = OnlyIpv6HostDetect(client); - - //如果未检测到有效的ip,连接就会被断开 - if (client.IsConnected == false) - { - return; - } - if (onlyIpv6 == true) - { - functionResult = SetUpNat64(client, true); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - //SetUpNat64(client, true); - //sshShellCommand = $"{sshCmdUpdate}"; - //currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - } - - - //******"开始卸载......"****** - SetUpProgressBarProcessing(10); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_StartRemoveProxy").ToString() + "......"; - MainWindowsShowInfo(currentStatus); - - #region 卸载V2Ray - - //******"检测系统是否已经安装V2ray......"******03 - SetUpProgressBarProcessing(11); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_TestExistSoft").ToString() + "V2ray......"; - MainWindowsShowInfo(currentStatus); - - //sshShellCommand = @"find / -name v2ray"; - //currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - functionResult = FileCheckExists(client, @"/usr/local/bin/v2ray"); - if (functionResult == true) - { - //******"检测到已安装V2Ray!开始卸载V2Ray......"****** - SetUpProgressBarProcessing(12); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_DiscoverProxySoft").ToString() - + "V2Ray!" - + Application.Current.FindResource("DisplayInstallInfo_StartRemoveProxy").ToString() - + "V2Ray......"; - MainWindowsShowInfo(currentStatus); - - sshShellCommand = @"systemctl stop v2ray"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - saveShellScriptFileName = GenerateRandomScriptFileName(GenerateRandomStr(10)); - - sshShellCommand = $"curl -o {saveShellScriptFileName} https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - functionResult = FileCheckExists(client, $"{saveShellScriptFileName}"); - if (functionResult == false) - { - //***文件下载失败!*** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_DownloadScriptFailed").ToString(); - MainWindowsShowInfo(currentStatus); - return; - } - - sshShellCommand = $"bash {saveShellScriptFileName} --remove"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"systemctl disable v2ray"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"rm -rf /usr/local/etc/v2ray /var/log/v2ray"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = $"rm -f {saveShellScriptFileName}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //sshShellCommand = @"find / -name v2ray"; - //currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - functionResult = FileCheckExists(client, @"/usr/local/bin/v2ray"); - if (functionResult == true) - //if (currentShellCommandResult.Contains("/usr/local/bin/v2ray") == true) - { - //******"V2Ray卸载失败!请向开发者问询!"****** - currentStatus = "V2Ray" + Application.Current.FindResource("DisplayInstallInfo_RemoveProxySoftFailed").ToString(); - MainWindowsShowInfo(currentStatus); - } - else - { - //******"V2Ray卸载成功!"****** - SetUpProgressBarProcessing(16); - currentStatus = "V2Ray" + Application.Current.FindResource("DisplayInstallInfo_RemoveProxySoftSuccess").ToString(); - MainWindowsShowInfo(currentStatus); - } - - } - else - { - //******"检测结果:未安装V2Ray!"******04 - SetUpProgressBarProcessing(16); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_NoInstalledSoft").ToString() + "V2Ray!"; - MainWindowsShowInfo(currentStatus); - } - - #endregion - - #region 卸载Trojan-go - - //******"检测系统是否已经安装Trojan-go......"******03 - SetUpProgressBarProcessing(17); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_TestExistSoft").ToString() + "Trojan-go......"; - MainWindowsShowInfo(currentStatus); - - //sshShellCommand = @"find / -name trojan-go"; - //currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //if (currentShellCommandResult.Contains("/usr/local/bin/trojan-go") == true) - functionResult = FileCheckExists(client, @"/usr/local/bin/trojan-go"); - if (functionResult == true) - { - //******"检测到已安装Trojan-go,开始卸载Trojan-go......"****** - SetUpProgressBarProcessing(18); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_DiscoverProxySoft").ToString() - + "Trojan-go!" - + Application.Current.FindResource("DisplayInstallInfo_StartRemoveProxy").ToString() - + "Trojan-go......"; - MainWindowsShowInfo(currentStatus); - - sshShellCommand = @"systemctl stop trojan-go"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - saveShellScriptFileName = GenerateRandomScriptFileName(GenerateRandomStr(10)); - - sshShellCommand = $"curl -o {saveShellScriptFileName} https://raw.githubusercontent.com/proxysu/shellscript/master/trojan-go.sh"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - functionResult = FileCheckExists(client, $"{saveShellScriptFileName}"); - if (functionResult == false) - { - //***文件下载失败!*** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_DownloadScriptFailed").ToString(); - MainWindowsShowInfo(currentStatus); - return; - } - - sshShellCommand = $"bash {saveShellScriptFileName} --remove"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"systemctl disable trojan-go"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"rm -rf /usr/local/etc/trojan-go /var/log/trojan-go"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = $"rm -f {saveShellScriptFileName}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //sshShellCommand = @"find / -name trojan-go"; - //currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //if (currentShellCommandResult.Contains("/usr/local/bin/trojan-go") == true) - functionResult = FileCheckExists(client, @"/usr/local/bin/trojan-go"); - if (functionResult == true) - { - //******"Trojan-go卸载失败!请向开发者问询!"****** - currentStatus = "Trojan-go" + Application.Current.FindResource("DisplayInstallInfo_RemoveProxySoftFailed").ToString(); - MainWindowsShowInfo(currentStatus); - } - else - { - //******"Trojan-go卸载成功!"****** - SetUpProgressBarProcessing(22); - currentStatus = "Trojan-go" + Application.Current.FindResource("DisplayInstallInfo_RemoveProxySoftSuccess").ToString(); - MainWindowsShowInfo(currentStatus); - } - - } - else - { - //******"检测结果:未安装Trojan-go!"******04 - SetUpProgressBarProcessing(22); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_NoInstalledSoft").ToString() + "Trojan-go!"; - MainWindowsShowInfo(currentStatus); - } - - #endregion - - #region 卸载Trojan - - //******"检测系统是否已经安装Trojan......"******03 - SetUpProgressBarProcessing(23); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_TestExistSoft").ToString() + "Trojan......"; - MainWindowsShowInfo(currentStatus); - - //sshShellCommand = @"find / -name trojan"; - //currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //if (currentShellCommandResult.Contains("/usr/local/bin/trojan") == true) - functionResult = FileCheckExists(client, @"/usr/local/bin/trojan"); - if (functionResult == true) - { - //******"检测到已安装Trojan,开始卸载Trojan......"****** - SetUpProgressBarProcessing(24); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_DiscoverProxySoft").ToString() - + "Trojan!" - + Application.Current.FindResource("DisplayInstallInfo_StartRemoveProxy").ToString() - + "Trojan......"; - MainWindowsShowInfo(currentStatus); - - sshShellCommand = @"systemctl stop trojan"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"systemctl disable trojan"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"rm -rf /usr/local/bin/trojan /etc/systemd/system/trojan.service /usr/local/etc/trojan"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //sshShellCommand = @"find / -name trojan"; - //currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //if (currentShellCommandResult.Contains("/usr/local/bin/trojan") == true) - functionResult = FileCheckExists(client, @"/usr/local/bin/trojan"); - if (functionResult == true) - { - //******"Trojan卸载失败!请向开发者问询!"****** - currentStatus = "Trojan" + Application.Current.FindResource("DisplayInstallInfo_RemoveProxySoftFailed").ToString(); - MainWindowsShowInfo(currentStatus); - } - else - { - //******"Trojan卸载成功!"****** - SetUpProgressBarProcessing(30); - currentStatus = "Trojan" + Application.Current.FindResource("DisplayInstallInfo_RemoveProxySoftSuccess").ToString(); - MainWindowsShowInfo(currentStatus); - } - - } - else - { - //******"检测结果:未安装Trojan!"******04 - SetUpProgressBarProcessing(30); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_NoInstalledSoft").ToString() + "Trojan!"; - MainWindowsShowInfo(currentStatus); - } - - #endregion - - #region 卸载SSR - - //******"检测系统是否已经安装SSR......"******03 - SetUpProgressBarProcessing(31); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_TestExistSoft").ToString() + "SSR......"; - MainWindowsShowInfo(currentStatus); - - //sshShellCommand = @"if [ -f /usr/local/shadowsocks/server.py ];then echo '1';else echo '0'; fi"; - //currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //if (currentShellCommandResult.Contains("1") == true) - functionResult = FileCheckExists(client, @"/usr/local/shadowsocks/server.py"); - if (functionResult == true) - { - //******"检测到已安装SSR,开始卸载SSR......"****** - SetUpProgressBarProcessing(32); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_DiscoverProxySoft").ToString() - + "SSR!" - + Application.Current.FindResource("DisplayInstallInfo_StartRemoveProxy").ToString() - + "SSR......"; - MainWindowsShowInfo(currentStatus); - - sshShellCommand = @"systemctl stop ssr"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - saveShellScriptFileName = GenerateRandomScriptFileName(GenerateRandomStr(10)); - - sshShellCommand = $"curl -o {saveShellScriptFileName} https://raw.githubusercontent.com/proxysu/shellscript/master/ssr/ssr.sh"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - functionResult = FileCheckExists(client, $"{saveShellScriptFileName}"); - if (functionResult == false) - { - //***文件下载失败!*** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_DownloadScriptFailed").ToString(); - MainWindowsShowInfo(currentStatus); - return; - } - - sshShellCommand = $"bash {saveShellScriptFileName} uninstall"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"systemctl disable ssr"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = $"rm -f {saveShellScriptFileName}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //sshShellCommand = @"if [ -f /usr/local/shadowsocks/server.py ];then echo '1';else echo '0'; fi"; - //currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //if (currentShellCommandResult.Contains("1") == true) - functionResult = FileCheckExists(client, @"/usr/local/shadowsocks/server.py"); - if (functionResult == true) - { - //******"SSR卸载失败!请向开发者问询!"****** - currentStatus = "SSR" + Application.Current.FindResource("DisplayInstallInfo_RemoveProxySoftFailed").ToString(); - MainWindowsShowInfo(currentStatus); - } - else - { - //******"SSR卸载成功!"****** - SetUpProgressBarProcessing(36); - currentStatus = "SSR" + Application.Current.FindResource("DisplayInstallInfo_RemoveProxySoftSuccess").ToString(); - MainWindowsShowInfo(currentStatus); - } - - } - else - { - //******"检测结果:未安装SSR!"******04 - SetUpProgressBarProcessing(36); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_NoInstalledSoft").ToString() + "SSR!"; - MainWindowsShowInfo(currentStatus); - } - - #endregion - - #region 卸载SS (Shadowsoks-libev) - - //******"检测系统是否已经安装SS (Shadowsoks-libev)......"******03 - SetUpProgressBarProcessing(37); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_TestExistSoft").ToString() + "SS (Shadowsoks-libev)......"; - MainWindowsShowInfo(currentStatus); - - //sshShellCommand = @"find / -name ss-server"; - //currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //if (currentShellCommandResult.Contains("/usr/local/bin/ss-server") == true) - functionResult = FileCheckExists(client, @"/usr/local/bin/ss-server"); - if (functionResult == true) - { - //******"检测到SS(Shadowsoks-libev),开始卸载SS(Shadowsoks-libev)......"****** - SetUpProgressBarProcessing(38); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_DiscoverProxySoft").ToString() - + "SS (Shadowsoks-libev)!" - + Application.Current.FindResource("DisplayInstallInfo_StartRemoveProxy").ToString() - + "SS (Shadowsoks-libev)......"; - MainWindowsShowInfo(currentStatus); - - sshShellCommand = @"systemctl stop ss-server"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - saveShellScriptFileName = GenerateRandomScriptFileName(GenerateRandomStr(10)); - - sshShellCommand = $"curl -o {saveShellScriptFileName} https://raw.githubusercontent.com/proxysu/shellscript/master/ss/ss-install.sh"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - functionResult = FileCheckExists(client, $"{saveShellScriptFileName}"); - if (functionResult == false) - { - //***文件下载失败!*** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_DownloadScriptFailed").ToString(); - MainWindowsShowInfo(currentStatus); - return; - } - - sshShellCommand = $"bash {saveShellScriptFileName} uninstall"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"systemctl disable ss-server"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = $"rm -f {saveShellScriptFileName}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //卸载插件 - sshShellCommand = @"rm -f /usr/local/bin/obfs-server /usr/local/bin/obfs-local /usr/local/bin/v2ray-plugin /usr/local/bin/kcptun-plugin-server /usr/local/bin/goquiet-plugin-server /usr/local/bin/cloak-plugin-server"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //sshShellCommand = @"find / -name ss-server"; - //currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //if (currentShellCommandResult.Contains("/usr/local/bin/ss-server") == true) - functionResult = FileCheckExists(client, @"/usr/local/bin/ss-server"); - if (functionResult == true) - { - //******"SS(Shadowsoks-libev)卸载失败!请向开发者问询!"****** - currentStatus = "SS (Shadowsoks-libev)" + Application.Current.FindResource("DisplayInstallInfo_RemoveProxySoftFailed").ToString(); - MainWindowsShowInfo(currentStatus); - } - else - { - //******"SS (Shadowsoks-libev)卸载成功!"****** - SetUpProgressBarProcessing(40); - currentStatus = "SS (Shadowsoks-libev)" + Application.Current.FindResource("DisplayInstallInfo_RemoveProxySoftSuccess").ToString(); - MainWindowsShowInfo(currentStatus); - } - - } - else - { - //******"检测结果:未安装SS(Shadowsoks-libev)!"******04 - SetUpProgressBarProcessing(40); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_NoInstalledSoft").ToString() + "SS (Shadowsoks-libev)!"; - MainWindowsShowInfo(currentStatus); - } - - - #endregion - - #region 卸载acme.sh - - //******"检测系统是否已经安装acme.sh......"******03 - SetUpProgressBarProcessing(41); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_TestExistSoft").ToString() + "acme.sh......"; - MainWindowsShowInfo(currentStatus); - - sshShellCommand = @"if [[ -d ~/.acme.sh ]];then echo '1';else echo '0'; fi"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - if (currentShellCommandResult.Contains("1") == true) - { - //******"检测到acme.sh,开始卸载acme.sh......"****** - SetUpProgressBarProcessing(42); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_DiscoverProxySoft").ToString() - + "acme.sh!" - + Application.Current.FindResource("DisplayInstallInfo_StartRemoveProxy").ToString() - + "acme.sh......"; - MainWindowsShowInfo(currentStatus); - - sshShellCommand = @"/root/.acme.sh/acme.sh --uninstall"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"rm -r ~/.acme.sh"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"if [[ -d ~/.acme.sh ]];then echo '1';else echo '0'; fi"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - if (currentShellCommandResult.Contains("1") == true) - { - //******"acme.sh卸载失败!请向开发者问询!"****** - currentStatus = "acme.sh" + Application.Current.FindResource("DisplayInstallInfo_RemoveProxySoftFailed").ToString(); - MainWindowsShowInfo(currentStatus); - } - else - { - sshShellCommand = @"sed -i 's/. ""/root/.acme.sh/acme.sh.env""//g' /root/.bashrc"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //******"acme.sh卸载成功!"****** - SetUpProgressBarProcessing(46); - currentStatus = "acme.sh" + Application.Current.FindResource("DisplayInstallInfo_RemoveProxySoftSuccess").ToString(); - MainWindowsShowInfo(currentStatus); - } - - } - else - { - //******"检测结果:未安装acme.sh!"******04 - SetUpProgressBarProcessing(46); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_NoInstalledSoft").ToString() + "acme.sh!"; - MainWindowsShowInfo(currentStatus); - } - - #endregion - - - #region 卸载NaiveProxy - - //******"检测系统是否已经安装NaiveProxy......"******03 - SetUpProgressBarProcessing(48); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_TestExistSoft").ToString() + "NaiveProxy......"; - MainWindowsShowInfo(currentStatus); - - //sshShellCommand = @"find / -name caddy"; - //currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //if (currentShellCommandResult.Contains("/usr/bin/caddy") == true) - functionResult = FileCheckExists(client, @"/etc/caddy/naive"); - if (functionResult == true) - { - //******"检测到NaiveProxy,开始卸载NaiveProxy......"****** - SetUpProgressBarProcessing(49); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_DiscoverProxySoft").ToString() - + "NaiveProxy!" - + Application.Current.FindResource("DisplayInstallInfo_StartRemoveProxy").ToString() - + "NaiveProxy......"; - MainWindowsShowInfo(currentStatus); - - sshShellCommand = @"systemctl stop caddy"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"systemctl disable caddy"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - saveShellScriptFileName = GenerateRandomScriptFileName(GenerateRandomStr(10)); - - sshShellCommand = $"curl -o {saveShellScriptFileName} https://raw.githubusercontent.com/proxysu/shellscript/master/Caddy-Naive/caddy-naive-install.sh"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - functionResult = FileCheckExists(client, $"{saveShellScriptFileName}"); - if (functionResult == false) - { - //***文件下载失败!*** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_DownloadScriptFailed").ToString(); - MainWindowsShowInfo(currentStatus); - return; - } - - sshShellCommand = $"bash {saveShellScriptFileName} uninstall"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = $"rm -f {saveShellScriptFileName}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - - - //sshShellCommand = @"find / -name caddy"; - //currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //if (currentShellCommandResult.Contains("/usr/local/bin/caddy") == true) - functionResult = FileCheckExists(client, @"/usr/bin/naive"); - if (functionResult == true) - { - //******"Caddy/NaiveProxy卸载失败!请向开发者问询!"****** - currentStatus = "NaiveProxy" + Application.Current.FindResource("DisplayInstallInfo_RemoveProxySoftFailed").ToString(); - MainWindowsShowInfo(currentStatus); - } - else - { - //******"Caddy/NaiveProxy卸载成功!"****** - SetUpProgressBarProcessing(60); - currentStatus = "NaiveProxy" + Application.Current.FindResource("DisplayInstallInfo_RemoveProxySoftSuccess").ToString(); - MainWindowsShowInfo(currentStatus); - } - - } - else - { - //******"检测结果:未安装NaiveProxy!"******04 - SetUpProgressBarProcessing(60); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_NoInstalledSoft").ToString() + "NaiveProxy!"; - MainWindowsShowInfo(currentStatus); - } - - #endregion - - - #region 卸载Caddy - - //******"检测系统是否已经安装Caddy......"******03 - SetUpProgressBarProcessing(48); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_TestExistSoft").ToString() + "Caddy......"; - MainWindowsShowInfo(currentStatus); - - //sshShellCommand = @"find / -name caddy"; - //currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //if (currentShellCommandResult.Contains("/usr/bin/caddy") == true) - functionResult = FileCheckExists(client, @"/usr/bin/caddy"); - if (functionResult == true) - { - //******"检测到Caddy,开始卸载Caddy......"****** - SetUpProgressBarProcessing(49); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_DiscoverProxySoft").ToString() - + "Caddy!" - + Application.Current.FindResource("DisplayInstallInfo_StartRemoveProxy").ToString() - + "Caddy......"; - MainWindowsShowInfo(currentStatus); - - sshShellCommand = @"systemctl stop caddy"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"systemctl disable caddy"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //检测系统是否支持yum 或 apt-get或zypper - //如果不存在组件,则命令结果为空,string.IsNullOrEmpty值为真, - - sshShellCommand = @"command -v apt-get"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - bool getApt = !String.IsNullOrEmpty(currentShellCommandResult); - - sshShellCommand = @"command -v dnf"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - bool getDnf = !String.IsNullOrEmpty(currentShellCommandResult); - - sshShellCommand = @"command -v yum"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - bool getYum = !String.IsNullOrEmpty(currentShellCommandResult); - - SetUpProgressBarProcessing(55); - - sshShellCommand = @"command -v zypper"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - bool getZypper = String.IsNullOrEmpty(currentShellCommandResult); - - - string sshCmdRemove = ""; - //string sshCmdRemove2; - //设置安装软件所用的命令格式 - if (getApt == true) - { - //sshCmdUpdate = @"apt-get update"; - sshCmdRemove = @"apt-get -y autoremove --purge "; - } - else if (getDnf == true) - { - //sshCmdUpdate = @"dnf -q makecache"; - sshCmdRemove = @"dnf -y remove "; - } - else if (getYum == true) - { - //sshCmdUpdate = @"yum -q makecache"; - sshCmdRemove = @"yum -y remove "; - } - else if (getZypper == true) - { - //sshCmdUpdate = @"zypper ref"; - sshCmdRemove = @"zypper -y remove "; - } - - sshShellCommand = $"{sshCmdRemove}caddy"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //sshShellCommand = @"find / -name caddy"; - //currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //if (currentShellCommandResult.Contains("/usr/local/bin/caddy") == true) - functionResult = FileCheckExists(client, @"/usr/bin/caddy"); - if (functionResult == true) - { - //******"Caddy卸载失败!请向开发者问询!"****** - currentStatus = "Caddy" + Application.Current.FindResource("DisplayInstallInfo_RemoveProxySoftFailed").ToString(); - MainWindowsShowInfo(currentStatus); - } - else - { - //******"Caddy卸载成功!"****** - SetUpProgressBarProcessing(60); - currentStatus = "Caddy" + Application.Current.FindResource("DisplayInstallInfo_RemoveProxySoftSuccess").ToString(); - MainWindowsShowInfo(currentStatus); - } - - } - else - { - //******"检测结果:未安装Caddy!"******04 - SetUpProgressBarProcessing(60); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_NoInstalledSoft").ToString() + "Caddy!"; - MainWindowsShowInfo(currentStatus); - } - - #endregion - - #region 卸载MtProto - //******"检测系统是否已经安装MtProto......"******03 - SetUpProgressBarProcessing(61); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_TestExistSoft").ToString() + "MtProto......"; - MainWindowsShowInfo(currentStatus); - - //sshShellCommand = @"find / -name mtg"; - //currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //if (currentShellCommandResult.Contains("/usr/local/bin/mtg") == true) - functionResult = FileCheckExists(client, @"/usr/local/bin/mtg"); - if (functionResult == true) - { - //******"检测到MtProto,开始卸载MtProto......"****** - SetUpProgressBarProcessing(63); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_DiscoverProxySoft").ToString() - + "MtProto!" - + Application.Current.FindResource("DisplayInstallInfo_StartRemoveProxy").ToString() - + "MtProto......"; - MainWindowsShowInfo(currentStatus); - - sshShellCommand = @"systemctl stop mtg"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"systemctl disable mtg"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"rm -rf /etc/systemd/system/mtg.service"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"rm -rf /usr/local/bin/mtg"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"rm -rf /usr/local/etc/mtg_info.json"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"rm -rf /usr/local/etc/mtg.sh"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //sshShellCommand = @"find / -name mtg"; - //currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //if (currentShellCommandResult.Contains("/usr/local/bin/mtg") == true) - functionResult = FileCheckExists(client, @"/usr/local/bin/mtg"); - if (functionResult == true) - { - //******"MtProto卸载失败!请向开发者问询!"****** - currentStatus = "MtProto" + Application.Current.FindResource("DisplayInstallInfo_RemoveProxySoftFailed").ToString(); - MainWindowsShowInfo(currentStatus); - } - else - { - //******"MtProto卸载成功!"****** - SetUpProgressBarProcessing(65); - currentStatus = "MtProto" + Application.Current.FindResource("DisplayInstallInfo_RemoveProxySoftSuccess").ToString(); - MainWindowsShowInfo(currentStatus); - } - - } - else - { - //******"检测结果:未安装MtProto!"******04 - SetUpProgressBarProcessing(65); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_NoInstalledSoft").ToString() + "MtProto!"; - MainWindowsShowInfo(currentStatus); - } - #endregion - - #region 卸载Xay - - //******"检测系统是否已经安装Xray......"******03 - SetUpProgressBarProcessing(66); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_TestExistSoft").ToString() + "Xray......"; - MainWindowsShowInfo(currentStatus); - - //sshShellCommand = @"find / -name v2ray"; - //currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - functionResult = FileCheckExists(client, @"/usr/local/bin/xray"); - if (functionResult == true) - { - //******"检测到已安装V2Ray!开始卸载Xray......"****** - SetUpProgressBarProcessing(68); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_DiscoverProxySoft").ToString() - + "Xray!" - + Application.Current.FindResource("DisplayInstallInfo_StartRemoveProxy").ToString() - + "Xray......"; - MainWindowsShowInfo(currentStatus); - - sshShellCommand = @"systemctl stop xray"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - saveShellScriptFileName = GenerateRandomScriptFileName(GenerateRandomStr(10)); - - sshShellCommand = $"curl -o {saveShellScriptFileName} https://raw.githubusercontent.com/XTLS/Xray-install/main/install-release.sh"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - functionResult = FileCheckExists(client, $"{saveShellScriptFileName}"); - if (functionResult == false) - { - //***文件下载失败!*** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_DownloadScriptFailed").ToString(); - MainWindowsShowInfo(currentStatus); - return; - } - - sshShellCommand = $"bash {saveShellScriptFileName} --remove"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"systemctl disable xray"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"rm -rf /usr/local/etc/xray /var/log/xray"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = $"rm -f {saveShellScriptFileName}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - functionResult = FileCheckExists(client, @"/usr/local/bin/xray"); - if (functionResult == true) - //if (currentShellCommandResult.Contains("/usr/local/bin/v2ray") == true) - { - //******"V2Ray卸载失败!请向开发者问询!"****** - currentStatus = "Xray" + Application.Current.FindResource("DisplayInstallInfo_RemoveProxySoftFailed").ToString(); - MainWindowsShowInfo(currentStatus); - } - else - { - //******"V2Ray卸载成功!"****** - SetUpProgressBarProcessing(70); - currentStatus = "Xray" + Application.Current.FindResource("DisplayInstallInfo_RemoveProxySoftSuccess").ToString(); - MainWindowsShowInfo(currentStatus); - } - - } - else - { - //******"检测结果:未安装Xray!"******04 - SetUpProgressBarProcessing(70); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_NoInstalledSoft").ToString() + "Xray!"; - MainWindowsShowInfo(currentStatus); - } - - #endregion - - //如果是纯ipv6主机,则需要删除前面设置的Nat64网关 - if (onlyIpv6 == true) - { - SetUpNat64(client, false); - //sshShellCommand = $"{sshCmdUpdate}"; - //currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - } - - - //******"卸载成功!"******04 - SetUpProgressBarProcessing(100); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_RemoveProxySoftSuccess").ToString(); - MainWindowsShowInfo(currentStatus); - client.Disconnect(); - - MessageBox.Show(Application.Current.FindResource("DisplayInstallInfo_RemoveProxySoftSuccess").ToString()); - - return; - } - } - catch (Exception ex1)//例外处理 - #region 例外处理 - { - ProcessException(ex1.Message); - - //****** "主机登录失败!" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_LoginFailed").ToString(); - MainWindowsShowInfo(currentStatus); - } - #endregion - - } - - #region 启用Root密码登录 - private void ButtonEnableRootPassWord_Click(object sender, RoutedEventArgs e) - { - //******"本功能需要当前登录的账户具有sudo权限,是否为远程主机启用root账户并设置密码?"****** - string messageShow = Application.Current.FindResource("MessageBoxShow_EnableRootPassword").ToString(); - MessageBoxResult messageBoxResult = MessageBox.Show(messageShow, "", MessageBoxButton.YesNo, MessageBoxImage.Question); - if (messageBoxResult == MessageBoxResult.Yes) - { - ConnectionInfo connectionInfo = GenerateConnectionInfo(); - if (connectionInfo == null) - { - //****** "远程主机连接信息有误,请检查!" ****** - MessageBox.Show(Application.Current.FindResource("MessageBoxShow_ErrorHostConnection").ToString()); - return; - } - - ReceiveConfigurationParameters[4] = PreTrim(TextBoxHost.Text); ;//传递主机地址 - ReceiveConfigurationParameters[2] = PasswordBoxHostPassword.Password;//传递当前账户密码 - - installationDegree = 0; - TextBoxMonitorCommandResults.Text = ""; - Thread thread = new Thread(() => EnableRootPassWord(connectionInfo)); - thread.SetApartmentState(ApartmentState.STA); - thread.Start(); - } - } - //启用Root密码登录进程 - private void EnableRootPassWord(ConnectionInfo connectionInfo) - { - functionResult = true; - getApt = false; - getDnf = false; - getYum = false; - onlyIpv6 = false; - - //******"正在登录远程主机......"****** - SetUpProgressBarProcessing(1); - string currentStatus = Application.Current.FindResource("DisplayInstallInfo_Login").ToString(); - MainWindowsShowInfo(currentStatus); - - try - { - #region 主机指纹,暂未启用 - //byte[] expectedFingerPrint = new byte[] { - // 0x66, 0x31, 0xaf, 0x00, 0x54, 0xb9, 0x87, 0x31, - // 0xff, 0x58, 0x1c, 0x31, 0xb1, 0xa2, 0x4c, 0x6b - // }; - #endregion - using (var client = new SshClient(connectionInfo)) - - { - #region ssh登录验证主机指纹代码块,暂未启用 - // client.HostKeyReceived += (sender, e) => - // { - // if (expectedFingerPrint.Length == e.FingerPrint.Length) - // { - // for (var i = 0; i < expectedFingerPrint.Length; i++) - // { - // if (expectedFingerPrint[i] != e.FingerPrint[i]) - // { - // e.CanTrust = false; - // break; - // } - // } - // } - // else - // { - // e.CanTrust = false; - // } - // }; - #endregion - - client.Connect(); - if (client.IsConnected == true) - { - //******"主机登录成功"****** - SetUpProgressBarProcessing(5); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_LoginSuccessful").ToString(); - MainWindowsShowInfo(currentStatus); - } - - //检测root权限 5--7 - //******"检测是否运行在root权限下..."******01 - SetUpProgressBarProcessing(5); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_DetectionRootPermission").ToString(); - MainWindowsShowInfo(currentStatus); - - sshShellCommand = @"id -u"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - if (currentShellCommandResult.TrimEnd('\r', '\n').Equals("0") == true) - { - //******"当前账户已经具有root权限,无需再设置!"****** - currentStatus = Application.Current.FindResource("MessageBoxShow_AlreadyRoot").ToString(); - MainWindowsShowInfo(currentStatus); - MessageBox.Show(currentStatus); - client.Disconnect(); - return; - } - - SetUpProgressBarProcessing(10); - string hostPassword = "'" + ReceiveConfigurationParameters[2] + "'"; - //MessageBox.Show(hostPassword); - sshShellCommand = $"echo {hostPassword} | sudo -S id -u"; - //MessageBox.Show(sshShellCommand); - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - if (currentShellCommandResult.TrimEnd('\r', '\n').Equals("0") == false) - { - //******"当前账户无法获取sudo权限,设置失败!"****** - currentStatus = Application.Current.FindResource("MessageBoxShow_NoSudoToAccount").ToString(); - MainWindowsShowInfo(currentStatus); - MessageBox.Show(currentStatus); - client.Disconnect(); - return; - } - - SetUpProgressBarProcessing(20); - string cmdPre = $"echo {hostPassword} | sudo -S id -u" + ';'; - sshShellCommand = cmdPre + @"sudo sed -i 's/PermitRootLogin /#PermitRootLogin /g' /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = cmdPre + @"sudo sed -i 's/PasswordAuthentication /#PasswordAuthentication /g' /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - SetUpProgressBarProcessing(30); - sshShellCommand = cmdPre + @"sudo sed -i 's/PermitEmptyPasswords /#PermitEmptyPasswords /g' /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = cmdPre + @"echo 'PermitRootLogin yes' | sudo tee -a /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - SetUpProgressBarProcessing(40); - sshShellCommand = cmdPre + @"echo 'PasswordAuthentication yes' | sudo tee -a /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = cmdPre + @"echo 'PermitEmptyPasswords no' | sudo tee -a /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - SetUpProgressBarProcessing(60); - sshShellCommand = cmdPre + @"sudo systemctl restart sshd"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //******"生成20位随机密码!"****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_GenerateRandomPassword").ToString(); - MainWindowsShowInfo(currentStatus); - - sshShellCommand = @"cat /dev/urandom | tr -dc '_A-Z#\-+=a-z(0-9%^>)]{<|' | head -c 20 ; echo ''"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - SetUpProgressBarProcessing(80); - string setPassword = currentShellCommandResult.TrimEnd('\r', '\n') + '\n'; - - sshShellCommand = cmdPre + $"echo -e \"{setPassword}{setPassword}\" | sudo passwd root"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - client.Disconnect(); - - //***保存密码信息*** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_EnableRootPasswordSavePasswordInfo").ToString(); - MainWindowsShowInfo(currentStatus); - - string filePath = ReceiveConfigurationParameters[4].Replace(':', '_'); - CheckDir(filePath); - using (StreamWriter sw = new StreamWriter($"{filePath}\\host_password_info.txt")) - { - sw.WriteLine(ReceiveConfigurationParameters[4]); - sw.WriteLine("root"); - sw.WriteLine(setPassword); - } - - SetUpProgressBarProcessing(100); - //***远程主机Root账户密码登录已启用,密码保存在随后打开的文件夹中!*** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_EnableRootPasswordSuccess").ToString(); - MainWindowsShowInfo(currentStatus); - MessageBox.Show(currentStatus); - System.Diagnostics.Process.Start("explorer.exe", filePath); - return; - } - } - catch (Exception ex1)//例外处理 - #region 例外处理 - { - ProcessException(ex1.Message); - - //****** "主机登录失败!" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_LoginFailed").ToString(); - MainWindowsShowInfo(currentStatus); - } - #endregion - - } - - #endregion - - #region 启用Root证书密钥登录 - private void ButtonEnableRootCert_Click(object sender, RoutedEventArgs e) - { - //******"本功能需要当前登录的账户具有root或者sudo权限,是否为远程主机启用root证书密钥登录?"****** - string messageShow = Application.Current.FindResource("MessageBoxShow_ButtonEnableRootCert").ToString(); - MessageBoxResult messageBoxResult = MessageBox.Show(messageShow, "", MessageBoxButton.YesNo, MessageBoxImage.Question); - if (messageBoxResult == MessageBoxResult.Yes) - { - ConnectionInfo connectionInfo = GenerateConnectionInfo(); - if (connectionInfo == null) - { - //****** "远程主机连接信息有误,请检查!" ****** - MessageBox.Show(Application.Current.FindResource("MessageBoxShow_ErrorHostConnection").ToString()); - return; - } - - ReceiveConfigurationParameters[4] = PreTrim(TextBoxHost.Text);//传递主机地址 - ReceiveConfigurationParameters[2] = PasswordBoxHostPassword.Password; - - installationDegree = 0; - TextBoxMonitorCommandResults.Text = ""; - Thread thread = new Thread(() => EnableRootCert(connectionInfo)); - thread.SetApartmentState(ApartmentState.STA); - thread.Start(); - } - } - - //启用Root证书密钥登录进程 - private void EnableRootCert(ConnectionInfo connectionInfo) - { - functionResult = true; - getApt = false; - getDnf = false; - getYum = false; - onlyIpv6 = false; - - string filePath = String.Empty; - - //******"正在登录远程主机......"****** - SetUpProgressBarProcessing(1); - string currentStatus = Application.Current.FindResource("DisplayInstallInfo_Login").ToString(); - MainWindowsShowInfo(currentStatus); - - try - { - #region 主机指纹,暂未启用 - //byte[] expectedFingerPrint = new byte[] { - // 0x66, 0x31, 0xaf, 0x00, 0x54, 0xb9, 0x87, 0x31, - // 0xff, 0x58, 0x1c, 0x31, 0xb1, 0xa2, 0x4c, 0x6b - // }; - #endregion - using (var client = new SshClient(connectionInfo)) - - { - #region ssh登录验证主机指纹代码块,暂未启用 - // client.HostKeyReceived += (sender, e) => - // { - // if (expectedFingerPrint.Length == e.FingerPrint.Length) - // { - // for (var i = 0; i < expectedFingerPrint.Length; i++) - // { - // if (expectedFingerPrint[i] != e.FingerPrint[i]) - // { - // e.CanTrust = false; - // break; - // } - // } - // } - // else - // { - // e.CanTrust = false; - // } - // }; - #endregion - - client.Connect(); - if (client.IsConnected == true) - { - //******"主机登录成功"****** - SetUpProgressBarProcessing(5); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_LoginSuccessful").ToString(); - MainWindowsShowInfo(currentStatus); - } - - //检测root权限 5--7 - //******"检测是否运行在root权限下..."******01 - SetUpProgressBarProcessing(5); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_DetectionRootPermission").ToString(); - MainWindowsShowInfo(currentStatus); - - sshShellCommand = @"id -u"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - if (currentShellCommandResult.TrimEnd('\r', '\n').Equals("0") == true) - { - SetUpProgressBarProcessing(20); - - //***正在生成密钥......*** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_EnableRootCertGenerateCert").ToString(); - MainWindowsShowInfo(currentStatus); - - sshShellCommand = @"rm -rf /tmp/rootuser.key /tmp/rootuser.key.pub"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"yes | ssh-keygen -b 2048 -t rsa -f /tmp/rootuser.key -q -N ''"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"yes | ssh-keygen -p -P '' -N '' -m PEM -f /tmp/rootuser.key"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"mkdir -p /root/.ssh"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"cat /tmp/rootuser.key.pub | tee -a /root/.ssh/authorized_keys"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"chmod 777 /tmp/rootuser.key"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - SetUpProgressBarProcessing(30); - //***正在下载密钥......*** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_EnableRootCertDownloadCert").ToString(); - MainWindowsShowInfo(currentStatus); - - filePath = CreateConfigSaveDir(@"root_cert", ReceiveConfigurationParameters[4].Replace(':', '_')); - string localConfigSavePathAndFileName = $"{filePath}\\rootuser.key"; - string remoteConfigPathAndFileName = @"/tmp/rootuser.key"; - DownloadConfig(connectionInfo, localConfigSavePathAndFileName, remoteConfigPathAndFileName); - - localConfigSavePathAndFileName = $"{filePath}\\rootuser.key.pub"; - remoteConfigPathAndFileName = @"/tmp/rootuser.key.pub"; - DownloadConfig(connectionInfo, localConfigSavePathAndFileName, remoteConfigPathAndFileName); - - sshShellCommand = @"rm -rf /tmp/rootuser.key /tmp/rootuser.key.pub"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - SetUpProgressBarProcessing(50); - //***远程主机启用密钥登录......*** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_EnableRootCertSetCertEnable").ToString(); - MainWindowsShowInfo(currentStatus); - - sshShellCommand = @"sed -i 's/PermitRootLogin /#PermitRootLogin /g' /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"sed -i 's/StrictModes /#StrictModes /g' /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - SetUpProgressBarProcessing(70); - sshShellCommand = @"sed -i 's/PubkeyAuthentication /#PubkeyAuthentication /g' /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"sed -i 's/#AuthorizedKeysFile /AuthorizedKeysFile /g' /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - SetUpProgressBarProcessing(80); - sshShellCommand = @"sed -i 's/#RSAAuthentication /RSAAuthentication /g' /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"echo 'PermitRootLogin yes' | tee -a /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - SetUpProgressBarProcessing(90); - sshShellCommand = @"echo 'StrictModes no' | tee -a /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"echo 'PubkeyAuthentication yes' | tee -a /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"systemctl restart sshd"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - } - else - { - SetUpProgressBarProcessing(10); - string hostPassword = "'" + ReceiveConfigurationParameters[2] + "'"; - //MessageBox.Show(hostPassword); - sshShellCommand = $"echo {hostPassword} | sudo -S id -u"; - //MessageBox.Show(sshShellCommand); - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - //MessageBox.Show(currentShellCommandResult); - if (currentShellCommandResult.TrimEnd('\r', '\n').Equals("0") == false) - { - //******"当前账户无法获取sudo权限,设置失败!"****** - currentStatus = Application.Current.FindResource("MessageBoxShow_NoSudoToAccount").ToString(); - MainWindowsShowInfo(currentStatus); - MessageBox.Show(currentStatus); - client.Disconnect(); - return; - } - - SetUpProgressBarProcessing(20); - string cmdPre = $"echo {hostPassword} | sudo -S id -u" + ';'; - //***正在生成密钥......*** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_EnableRootCertGenerateCert").ToString(); - MainWindowsShowInfo(currentStatus); - - sshShellCommand = cmdPre + @"sudo rm -rf /tmp/rootuser.key /tmp/rootuser.key.pub"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = cmdPre + @"yes | sudo ssh-keygen -b 2048 -t rsa -f /tmp/rootuser.key -q -N ''"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = cmdPre + @"yes | sudo ssh-keygen -p -P '' -N '' -m PEM -f /tmp/rootuser.key"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = cmdPre + @"sudo mkdir -p /root/.ssh"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = cmdPre + @"cat /tmp/rootuser.key.pub | sudo tee -a /root/.ssh/authorized_keys"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = cmdPre + @"sudo chmod 777 /tmp/rootuser.key"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - SetUpProgressBarProcessing(30); - //***正在下载密钥......*** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_EnableRootCertDownloadCert").ToString(); - MainWindowsShowInfo(currentStatus); - - filePath = CreateConfigSaveDir(@"root_cert", ReceiveConfigurationParameters[4].Replace(':', '_')); - string localConfigSavePathAndFileName = $"{filePath}\\rootuser.key"; - string remoteConfigPathAndFileName = @"/tmp/rootuser.key"; - DownloadConfig(connectionInfo, localConfigSavePathAndFileName, remoteConfigPathAndFileName); - - localConfigSavePathAndFileName = $"{filePath}\\rootuser.key.pub"; - remoteConfigPathAndFileName = @"/tmp/rootuser.key.pub"; - DownloadConfig(connectionInfo, localConfigSavePathAndFileName, remoteConfigPathAndFileName); - - sshShellCommand = cmdPre + @"sudo rm -rf /tmp/rootuser.key /tmp/rootuser.key.pub"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - SetUpProgressBarProcessing(50); - //***远程主机启用密钥登录......*** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_EnableRootCertSetCertEnable").ToString(); - MainWindowsShowInfo(currentStatus); - - //string cmdPre = $"echo {hostPassword} | sudo -S id -u" + ';'; - sshShellCommand = cmdPre + @"sudo sed -i 's/PermitRootLogin /#PermitRootLogin /g' /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = cmdPre + @"sudo sed -i 's/StrictModes /#StrictModes /g' /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - SetUpProgressBarProcessing(70); - sshShellCommand = cmdPre + @"sudo sed -i 's/PubkeyAuthentication /#PubkeyAuthentication /g' /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = cmdPre + @"sudo sed -i 's/#AuthorizedKeysFile /AuthorizedKeysFile /g' /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - SetUpProgressBarProcessing(80); - sshShellCommand = cmdPre + @"sudo sed -i 's/#RSAAuthentication /RSAAuthentication /g' /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = cmdPre + @"echo 'PermitRootLogin yes' | sudo tee -a /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - SetUpProgressBarProcessing(90); - sshShellCommand = cmdPre + @"echo 'StrictModes no' | sudo tee -a /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = cmdPre + @"echo 'PubkeyAuthentication yes' | sudo tee -a /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = cmdPre + @"sudo systemctl restart sshd"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - } - client.Disconnect(); - - SetUpProgressBarProcessing(100); - //******"远程主机root账户证书密钥登录已启用,密钥文件rootuser.key保存在随后打开的文件夹中!"****** - currentStatus = Application.Current.FindResource("MessageBoxShow_ButtonEnableRootCertSuccess").ToString(); - MainWindowsShowInfo(currentStatus); - MessageBox.Show(currentStatus); - System.Diagnostics.Process.Start("explorer.exe", filePath); - - return; - } - } - catch (Exception ex1)//例外处理 - #region 例外处理 - { - ProcessException(ex1.Message); - - //****** "主机登录失败!" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_LoginFailed").ToString(); - MainWindowsShowInfo(currentStatus); - } - #endregion - - } - - - #endregion - - #region 禁止root账户密码登录 - //root禁止密码登录 - private void ButtonRootProhibitsPasswordLogin_Click(object sender, RoutedEventArgs e) - { - //******"本功能需要远程主机已经开启了其他登录方式,如密钥方式等,否则将可能造成远程主机无法连接,是否禁止远程主机的root账户密码登录方式?"****** - string messageShow = Application.Current.FindResource("MessageBoxShow_ButtonRootProhibitsPasswordLogin").ToString(); - MessageBoxResult messageBoxResult = MessageBox.Show(messageShow, "", MessageBoxButton.YesNo, MessageBoxImage.Question); - if (messageBoxResult == MessageBoxResult.Yes) - { - ConnectionInfo connectionInfo = GenerateConnectionInfo(); - if (connectionInfo == null) - { - //****** "远程主机连接信息有误,请检查!" ****** - MessageBox.Show(Application.Current.FindResource("MessageBoxShow_ErrorHostConnection").ToString()); - return; - } - - ReceiveConfigurationParameters[4] = PreTrim(TextBoxHost.Text);//传递主机地址 - ReceiveConfigurationParameters[2] = PasswordBoxHostPassword.Password;//传递主机密码 - - installationDegree = 0; - TextBoxMonitorCommandResults.Text = ""; - Thread thread = new Thread(() => RootProhibitsPasswordLogin(connectionInfo)); - thread.SetApartmentState(ApartmentState.STA); - thread.Start(); - } - } - - //禁止root密码登录进程 - private void RootProhibitsPasswordLogin(ConnectionInfo connectionInfo) - { - functionResult = true; - getApt = false; - getDnf = false; - getYum = false; - onlyIpv6 = false; - - string filePath = String.Empty; - - //******"正在登录远程主机......"****** - SetUpProgressBarProcessing(1); - string currentStatus = Application.Current.FindResource("DisplayInstallInfo_Login").ToString(); - MainWindowsShowInfo(currentStatus); - - try - { - #region 主机指纹,暂未启用 - //byte[] expectedFingerPrint = new byte[] { - // 0x66, 0x31, 0xaf, 0x00, 0x54, 0xb9, 0x87, 0x31, - // 0xff, 0x58, 0x1c, 0x31, 0xb1, 0xa2, 0x4c, 0x6b - // }; - #endregion - using (var client = new SshClient(connectionInfo)) - - { - #region ssh登录验证主机指纹代码块,暂未启用 - // client.HostKeyReceived += (sender, e) => - // { - // if (expectedFingerPrint.Length == e.FingerPrint.Length) - // { - // for (var i = 0; i < expectedFingerPrint.Length; i++) - // { - // if (expectedFingerPrint[i] != e.FingerPrint[i]) - // { - // e.CanTrust = false; - // break; - // } - // } - // } - // else - // { - // e.CanTrust = false; - // } - // }; - #endregion - - client.Connect(); - if (client.IsConnected == true) - { - //******"主机登录成功"****** - SetUpProgressBarProcessing(5); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_LoginSuccessful").ToString(); - MainWindowsShowInfo(currentStatus); - } - - //检测root权限 5--7 - //******"检测是否运行在root权限下..."******01 - SetUpProgressBarProcessing(5); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_DetectionRootPermission").ToString(); - MainWindowsShowInfo(currentStatus); - - sshShellCommand = @"id -u"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - if (currentShellCommandResult.TrimEnd('\r', '\n').Equals("0") == true) - { - SetUpProgressBarProcessing(20); - - //***正在关闭root账户密码登录方式......*** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_SetRootProhibitsPasswordLogin").ToString(); - MainWindowsShowInfo(currentStatus); - - sshShellCommand = @"sed -i 's/PasswordAuthentication /#PasswordAuthentication /g' /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"sed -i 's/PermitEmptyPasswords /#PermitEmptyPasswords /g' /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"echo 'PasswordAuthentication no' | tee -a /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"echo 'PermitEmptyPasswords no' | tee -a /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"systemctl restart sshd"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - } - else - { - SetUpProgressBarProcessing(10); - string hostPassword = "'" + ReceiveConfigurationParameters[2] + "'"; - //MessageBox.Show(hostPassword); - sshShellCommand = $"echo {hostPassword} | sudo -S id -u"; - //MessageBox.Show(sshShellCommand); - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - //MessageBox.Show(currentShellCommandResult); - if (currentShellCommandResult.TrimEnd('\r', '\n').Equals("0") == false) - { - //******"当前账户无法获取sudo权限,设置失败!"****** - currentStatus = Application.Current.FindResource("MessageBoxShow_NoSudoToAccount").ToString(); - MainWindowsShowInfo(currentStatus); - MessageBox.Show(currentStatus); - client.Disconnect(); - return; - } - - SetUpProgressBarProcessing(20); - string cmdPre = $"echo {hostPassword} | sudo -S id -u" + ';'; - - //***正在关闭root账户密码登录方式......*** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_SetRootProhibitsPasswordLogin").ToString(); - MainWindowsShowInfo(currentStatus); - - sshShellCommand = cmdPre + @"sudo sed -i 's/PasswordAuthentication /#PasswordAuthentication /g' /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = cmdPre + @"sudo sed -i 's/PermitEmptyPasswords /#PermitEmptyPasswords /g' /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = cmdPre + @"echo 'PasswordAuthentication no' | sudo tee -a /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = cmdPre + @"echo 'PermitEmptyPasswords no' | sudo tee -a /etc/ssh/sshd_config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = cmdPre + @"sudo systemctl restart sshd"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - } - client.Disconnect(); - - SetUpProgressBarProcessing(100); - //******"远程主机root账户密码登录方式已关闭!"****** - currentStatus = Application.Current.FindResource("MessageBoxShow_RootProhibitsPasswordLoginOK").ToString(); - MainWindowsShowInfo(currentStatus); - MessageBox.Show(currentStatus); - - return; - } - } - catch (Exception ex1)//例外处理 - #region 例外处理 - { - ProcessException(ex1.Message); - - //****** "主机登录失败!" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_LoginFailed").ToString(); - MainWindowsShowInfo(currentStatus); - } - #endregion - } - #endregion - - //安装日志另存为... - private void ButtonSaveInstalledLog_Click(object sender, RoutedEventArgs e) - { - string logSaveName = ChooseSaveFile("Log Save as...", $"{pwdir}"); - if (String.IsNullOrEmpty(logSaveName) == false) - { - using (StreamWriter sw = new StreamWriter($"{logSaveName}")) - { - sw.WriteLine($"{TextBoxMonitorCommandResults.Text}"); - } - } - } - private string ChooseSaveFile(string title, string initFolder) - { - SaveFileDialog dlg = new SaveFileDialog(); - dlg.Title = title; - string localTime = DateTime.Now.ToLocalTime().ToString().Replace(' ', '-').Replace(':', '-').Replace('/', '-').Replace('\\', '-'); - dlg.FileName = $"{PreTrim(TextBoxHost.Text).Replace(':', '_')}_{localTime}.txt"; // Default file name - dlg.DefaultExt = ".txt"; // Default file extension - dlg.Filter = "Text documents|*.txt"; // Filter files by extension - dlg.InitialDirectory = initFolder; - - // Process save file dialog box results - if (dlg.ShowDialog() == true) - { - return dlg.FileName; - } - else - { - return null; - } - } - - #endregion - - #region 标签页控制 - - private void ButtonWebBrowserHomePage_Click(object sender, RoutedEventArgs e) - { - try - { - WebBrowserResourcesAndTools.Source = new Uri("https://github.com/proxysu/windows/wiki/ResourcesAndTools"); - } - catch (Exception ex) - { - MessageBox.Show(ex.Message); - } - } - private void ButtonWebBrowserBack_Click(object sender, RoutedEventArgs e) - { - try - { - WebBrowserResourcesAndTools.GoBack(); - } - catch (Exception ex) - { - MessageBox.Show(ex.Message); - } - } - - private void ButtonWebBrowserForward_Click(object sender, RoutedEventArgs e) - { - try - { - WebBrowserResourcesAndTools.GoForward(); - } - catch (Exception ex) - { - MessageBox.Show(ex.Message); - } - } - - - - #region 免翻网址资源标签 - private void ButtonWebBrowserHomePageFreeWallURL_Click(object sender, RoutedEventArgs e) - { - try - { - WebBrowserResourcesAndToolsFreeWallURL.Source = new Uri("https://github.com/proxysu/windows/wiki/FreeWallURL"); - } - catch (Exception ex) - { - MessageBox.Show(ex.Message); - } - } - - private void ButtonWebBrowserBackFreeWallURL_Click(object sender, RoutedEventArgs e) - { - try - { - WebBrowserResourcesAndToolsFreeWallURL.GoBack(); - } - catch (Exception ex) - { - MessageBox.Show(ex.Message); - } - } - - private void ButtonWebBrowserForwardFreeWallURL_Click(object sender, RoutedEventArgs e) - { - try - { - WebBrowserResourcesAndToolsFreeWallURL.GoForward(); - } - catch (Exception ex) - { - MessageBox.Show(ex.Message); - } - } - - #endregion - - #region 常见问题标签 - private void ButtonWebBrowserHomePageCommonError_Click(object sender, RoutedEventArgs e) - { - try - { - WebBrowserCommonError.Source = new Uri("https://github.com/proxysu/windows/wiki/CommonError"); - } - catch (Exception ex) - { - MessageBox.Show(ex.Message); - } - } - - private void ButtonWebBrowserBackCommonError_Click(object sender, RoutedEventArgs e) - { - try - { - WebBrowserCommonError.GoBack(); - } - catch (Exception ex) - { - MessageBox.Show(ex.Message); - } - } - - private void ButtonWebBrowserForwardCommonError_Click(object sender, RoutedEventArgs e) - { - try - { - WebBrowserCommonError.GoForward(); - } - catch (Exception ex) - { - MessageBox.Show(ex.Message); - } - } - - - #endregion - #endregion - - #region 测试用代码 - private void Button_Click(object sender, RoutedEventArgs e) - { - //string host = ClassModel.DisguiseURLprocessing("www.google.com/accout/"); - //MessageBox.Show(host); - //saveShellScriptFileName = GenerateRandomScriptFileName(GenerateRandomStr(10)); - //saveShellScriptFileName = "tmp." + saveShellScriptFileName + ".sh"; - //MessageBox.Show(saveShellScriptFileName); - //var rand = System.Security.Cryptography.RandomNumberGenerator.Create(); - //byte[] bytes = new byte[8]; - //rand.GetBytes(bytes); - //string randStr = Convert.ToBase64String(bytes); - //randStr = randStr.Replace("+","").Replace("/", "").Replace("=",""); - //MessageBox.Show(randStr); - proxyType = "V2Ray"; - ResultClientInformation resultClientInformation = new ResultClientInformation(); - resultClientInformation.ShowDialog(); - //return; - //string pwdir = AppDomain.CurrentDomain.BaseDirectory; - //MessageBox.Show(pwdir); - //ConnectionInfo connectionInfo = GenerateConnectionInfo(); - //if (connectionInfo == null) - //{ - // //****** "远程主机连接信息有误,请检查!" ****** - // MessageBox.Show(Application.Current.FindResource("MessageBoxShow_ErrorHostConnection").ToString()); - // return; - //} - //using (var client = new SshClient(connectionInfo)) - //{ - // client.Connect(); - // if (client.IsConnected == true) - // { - // //******"主机登录成功"****** - // SetUpProgressBarProcessing(3); - // currentStatus = Application.Current.FindResource("DisplayInstallInfo_LoginSuccessful").ToString(); - // MainWindowsShowInfo(currentStatus); - - // } - // string fileProxy = @"/usr/local/bin/v2ray"; - // sshShellCommand = $"if [[ -f {fileProxy} ]];then echo '1';else echo '0'; fi"; - // //sshShellCommand = @"if [[ -f /usr/local/bin/v2ray ]];then echo '1';else echo '0'; fi"; - // currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - // if (currentShellCommandResult.Trim().Equals("0") == true) - // { - // MessageBox.Show("0"); - // } - // else - // { - // MessageBox.Show("1"); - // } - // // SetUpNat64(client, true); - // //FilterFastestIP(client); - // //string cmdErr = client.RunCommand(@"aaa ee").Error; - // //MessageBox.Show(cmdErr); - // //SshCommand cmdResult = client.RunCommand(@"pwd"); - // //string result = cmdResult.Result; - // //MessageBox.Show("result:" + result); - // //string error = cmdResult.Error; - // //MessageBox.Show("err:" + error); - - // //int cmdExitStatus = cmdResult.ExitStatus; - // //MessageBox.Show("cmdExitStatus:" + cmdExitStatus.ToString()); - - // //SshCommand cmdResultCat = client.RunCommand(@"cat tt.t"); - // //string resultCat = cmdResultCat.Result; - // //MessageBox.Show("resultCat:" + resultCat); - // //string errorCat = cmdResultCat.Error; - // //MessageBox.Show("errCat:" + errorCat); - - // //cmdExitStatus = cmdResultCat.ExitStatus; - // //MessageBox.Show("cmdExitStatus:" + cmdExitStatus.ToString()); - - // //SoftInstalledSuccessOrFail(client, "v2ray", @"/usr/local/bin/v2ray"); - // //CaddyInstall(client); - // //if (client.IsConnected == true) - // //{ - // // MessageBox.Show("Connected"); - // //} - // //if (client.IsConnected == false) - // //{ - // // MessageBox.Show("disConnected"); - // //} - //} - } - - private string CaddyInstallTest(SshClient client) - { - - if (client.IsConnected == true) - { - //******"主机登录成功"****** - SetUpProgressBarProcessing(3); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_LoginSuccessful").ToString(); - MainWindowsShowInfo(currentStatus); - - sshShellCommand = @"id -u"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - client.Disconnect(); - } - return ""; - } - #endregion - - #region 布署代理所用到的步骤函数 - - //检测主机是否为纯ipv6的主机 - private bool OnlyIpv6HostDetect(SshClient client) - { - //****** "正在检测是否为纯ipv6主机......." ******11 - //SetUpProgressBarProcessing(34); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_OnlyIpv6HostDetect").ToString(); - MainWindowsShowInfo(currentStatus); - - //再次初始化相关变量 - ipv4 = String.Empty; - ipv6 = String.Empty; - - //sshShellCommand = @"curl -4 ip.sb"; - sshShellCommand = @"curl -s https://api.ip.sb/ip --ipv4 --max-time 8"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - ipv4 = currentShellCommandResult.TrimEnd('\r', '\n'); - - sshShellCommand = @"curl -s https://api.ip.sb/ip --ipv6 --max-time 8"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - ipv6 = currentShellCommandResult.TrimEnd('\r', '\n'); - - if (String.IsNullOrEmpty(ipv4) == false) - { - return false; - } - else - { - if (String.IsNullOrEmpty(ipv6) == false) - { - - return true; - } - else - { - //FunctionResultErr(); - client.Disconnect(); - //****未检测到有效的IP地址......*** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_NoIpDetect").ToString(); - MainWindowsShowInfo(currentStatus); - MessageBox.Show(currentStatus); - return false; - } - } - - } - - //设置Nat64与删除设置Nat64 - private bool SetUpNat64(SshClient client, bool set) - { - if (set == true) - { - //****** "正在查找最快的Nat64网关......" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_FindFastestSetUpNat64").ToString(); - MainWindowsShowInfo(currentStatus); - //string[] dns64 = new string[2]; - var dns64 = FilterFastestIP(client); - - if (functionResult == false) - { - //****** "未能找到有效的Nat64网关......" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_FindFastestSetUpNat64Failed").ToString(); - MainWindowsShowInfo(currentStatus); - MessageBox.Show(currentStatus); - //FunctionResultErr(); - client.Disconnect(); - return false; - } - - //****** "正在设置Nat64网关......" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_SetUpNat64").ToString(); - MainWindowsShowInfo(currentStatus); - - functionResult = FileCheckExists(client, @"/etc/resolv.conf.proxysu"); - if (functionResult == false) - { - sshShellCommand = @"mv /etc/resolv.conf /etc/resolv.conf.proxysu"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - } - - - foreach (string gateip in dns64) - { - sshShellCommand = $"echo \"nameserver {gateip}\" > /etc/resolv.conf"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"curl -fsSL https://api.github.com/repos/proxysu/windows/releases/latest"; - //currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - SshCommand currentShellCommand = client.RunCommand(sshShellCommand); - int cmdExitStatus = currentShellCommand.ExitStatus; - if (cmdExitStatus == 0) - { - return true; - } - - } - - } - else - { - //****** "正在删除Nat64网关......" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_DeleteSetUpNat64").ToString(); - MainWindowsShowInfo(currentStatus); - sshShellCommand = @"rm /etc/resolv.conf"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - sshShellCommand = @"mv /etc/resolv.conf.proxysu /etc/resolv.conf"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - } - - return true; - } - - //筛选最优的NAT64地址 - private string[] FilterFastestIP(SshClient client) - { - string[] gateNat64 = { - "2a01:4f9:c010:3f02::1", - "2001:67c:2b0::4", - "2001:67c:2b0::6", - "2a09:11c0:f1:bbf0::70", - "2a01:4f8:c2c:123f::1", - "2001:67c:27e4:15::6411", - "2001:67c:27e4::64", - "2001:67c:27e4:15::64", - "2001:67c:27e4::60", - "2a00:1098:2b::1", - "2a03:7900:2:0:31:3:104:161", - "2a00:1098:2c::1", - "2a09:11c0:100::53", - }; - - List NatDns64s = new List(); - foreach (string gateip in gateNat64) - { - sshShellCommand = $"ping6 -c4 {gateip} | grep avg | awk '{{print $4}}'|cut -d/ -f2"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - if (String.IsNullOrEmpty(currentShellCommandResult) != true) - { - if (float.TryParse(currentShellCommandResult, out float delay) == true) - { - - int delayInt = (int)(delay * 1000); - NatDns64 ipaddr = new NatDns64($"{gateip}", delayInt); - NatDns64s.Add(ipaddr); - } - } - - } - NatDns64s = NatDns64s.OrderBy(o => o.Avg).ToList(); - int listCount = NatDns64s.Count; - currentStatus = listCount.ToString() + " NAT64 gateways are valid"; - MainWindowsShowInfo(currentStatus); - if (listCount < 1) - { - functionResult = false; - } - else - { - functionResult = true; - } - string[] returnstr = new string[listCount]; - for (int i = 0; i < listCount; i++) - { - returnstr[i] = NatDns64s[i].IpAddr; - } - //returnstr[0] = NatDns64s[0].IpAddr; - //returnstr[1] = NatDns64s[1].IpAddr; - return returnstr; - } - - //纯ipv6主机安装脚本处理 - //private void Ipv6ScriptEdit(SshClient client,string scriptFile) - //{ - // sshShellCommand = $"sed -i 's/api.github.com/{apiGithubCom}/g' {scriptFile}"; - // currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - // sshShellCommand = $"sed -i 's/raw.githubusercontent.com/raw.githubusercontent.com/g' {scriptFile}"; - // currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - // sshShellCommand = $"sed -i 's/https:\\/\\/github.com/https:\\/\\/{githubCom}/g' {scriptFile}"; - // currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - //} - - - #region 安装过程提示信息 - - //安装过程提示信息 - // MainWindowsShowInfo(currentStatus); - // currentShellCommandResult = MainWindowsShowCmd(client,sshShellCommand); - private string MainWindowsShowInfo(string currentStatus) - { - TextBlockSetUpProcessing.Dispatcher.BeginInvoke(updateAction, TextBlockSetUpProcessing, ProgressBarSetUpProcessing, currentStatus); - string currentShellCommandResult = currentStatus; - TextBoxMonitorCommandResults.Dispatcher.BeginInvoke(updateMonitorAction, TextBoxMonitorCommandResults, currentShellCommandResult);//显示命令执行的结果在监视窗口 - - return currentShellCommandResult; - } - - //安装过程所运行的命令与相应结果 - private string MainWindowsShowCmd(SshClient client, string sshShellCommand, bool stopIfError = true) - { - TextBoxMonitorCommandResults.Dispatcher.BeginInvoke(updateMonitorAction, TextBoxMonitorCommandResults, sshShellCommand);//显示执行的命令 - SshCommand cmdResult = client.RunCommand(sshShellCommand); - string currentShellCommandResult = cmdResult.Result; //命令执行成功的结果 - string currentShellCommandError = cmdResult.Error; //命令执行出错的提示 - int cmdExitStatus = cmdResult.ExitStatus; - //if (String.IsNullOrEmpty(currentShellCommandResult) == true) - if (cmdExitStatus == 1) - { - if (stopIfError) { } - //currentShellCommandResult = currentShellCommandError; - TextBoxMonitorCommandResults.Dispatcher.BeginInvoke(updateMonitorAction, TextBoxMonitorCommandResults, currentShellCommandError);//显示命令执行错误的提示 - } - TextBoxMonitorCommandResults.Dispatcher.BeginInvoke(updateMonitorAction, TextBoxMonitorCommandResults, currentShellCommandResult);//显示命令执行的结果 - - return currentShellCommandResult; - } - - //调用的函数返回false后的提示 - private string FunctionResultErr() - { - //*****"发生错误,安装中断......"***** - string currentStatus = Application.Current.FindResource("DisplayInstallInfo_FunctionResultErr").ToString(); - MainWindowsShowInfo(currentStatus); - return ""; - } - - //判断某个文件是否存在 - //functionResult = FileCheckExists(client, @"/usr/local/bin/mtg"); - private bool FileCheckExists(SshClient client, string pathFile) - { - sshShellCommand = $"if [[ -f {pathFile} ]];then echo '1';else echo '0'; fi"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - if (currentShellCommandResult.Trim().Equals("1") == true) - { - return true; - } - else - { - return false; - } - - } - #endregion - - //检测root权限 5--7 - //functionResult = RootAuthorityDetect(client); - //if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - private bool RootAuthorityDetect(SshClient client) - { - sshShellCommand = @"uname -a"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - //禁止一些可能产生的干扰信息 - sshShellCommand = @"sed -i 's/echo/#echo/g' ~/.bashrc"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"sed -i 's/echo/#echo/g' ~/.profile"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //******"检测是否运行在root权限下..."******01 - SetUpProgressBarProcessing(5); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_DetectionRootPermission").ToString(); - MainWindowsShowInfo(currentStatus); - - sshShellCommand = @"id -u"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //string testRootAuthority = currentShellCommandResult; - if (currentShellCommandResult.Equals("0\n") == false) - { - //******"请使用具有root权限的账户登录主机!!"****** - MessageBox.Show(Application.Current.FindResource("MessageBoxShow_ErrorRootPermission").ToString()); - //client.Disconnect(); - return false; - } - else - { - //******"检测结果:OK!"******02 - SetUpProgressBarProcessing(7); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_DetectionRootOK").ToString(); - MainWindowsShowInfo(currentStatus); - //return true; - } - return true; - } - - //检测是否已安装代理 8--10 - //soft--要检测的程序 - //condition---已安装的条件 - //functionResult = SoftInstalledIsNoYes(client, "v2ray", @"/usr/local/bin/v2ray"); - //if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - private bool SoftInstalledIsNoYes(SshClient client, string soft, string condition) - { - //******"检测系统是否已经安装......"******03 - SetUpProgressBarProcessing(8); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_TestExistSoft").ToString() + $"{soft}......"; - MainWindowsShowInfo(currentStatus); - - - //sshShellCommand = $"find / -name {soft}"; - //currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //string resultCmdTestV2rayInstalled = currentShellCommandResult; - //if (currentShellCommandResult.Contains($"{condition}") == true) - functionResult = FileCheckExists(client, condition); - if (functionResult == true) - { - //******"远程主机已安装V2ray,是否强制重新安装?"****** - string messageShow = Application.Current.FindResource("MessageBoxShow_ExistedSoft").ToString() + - $"{soft}" + - Application.Current.FindResource("MessageBoxShow_ForceInstallSoft").ToString(); - MessageBoxResult messageBoxResult = MessageBox.Show(messageShow, "", MessageBoxButton.YesNo, MessageBoxImage.Question); - if (messageBoxResult == MessageBoxResult.No) - { - //******"安装取消,退出"****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_InstallationCanceledExit").ToString(); - MainWindowsShowInfo(currentStatus); - //client.Disconnect(); - return false; - } - else - { - //******"已选择强制安装!"******04 - SetUpProgressBarProcessing(10); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_ForceInstallSoft").ToString() + $"{soft}"; - MainWindowsShowInfo(currentStatus); - - } - } - else - { - //******"检测结果:未安装"******04 - SetUpProgressBarProcessing(10); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_NoInstalledSoft").ToString() + $"{soft}"; - MainWindowsShowInfo(currentStatus); - } - return true; - } - - //检测关闭Selinux及系统组件是否齐全(apt-get/yum/dnf/systemctl)11--30 - //安装依赖软件,检测端口,防火墙开启端口,检测是否为纯ipv6主机,若是则设置Nat64网关 - //functionResult = ShutDownSelinuxAndSysComponentsDetect(client); - //if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - private bool ShutDownSelinuxAndSysComponentsDetect(SshClient client) - { - - //检测系统是否支持yum 或 apt-get或zypper,且支持Systemd - //如果不存在组件,则命令结果为空,String.IsNullOrEmpty值为真 - //取反则getApt,getDnf,getYum,getSystem,getGetenforce为假 - //不存在组件,则为假 - - //******"检测系统是否符合安装要求......"****** - SetUpProgressBarProcessing(11); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_CheckSystemRequirements").ToString(); - MainWindowsShowInfo(currentStatus); - - sshShellCommand = @"command -v apt-get"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - getApt = !String.IsNullOrEmpty(currentShellCommandResult); - - sshShellCommand = @"command -v dnf"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - getDnf = !String.IsNullOrEmpty(currentShellCommandResult); - - sshShellCommand = @"command -v yum"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - getYum = !String.IsNullOrEmpty(currentShellCommandResult); - - SetUpProgressBarProcessing(13); - - //sshShellCommand = @"command -v zypper"; - //currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - //bool getZypper = ! String.IsNullOrEmpty(currentShellCommandResult); - - sshShellCommand = @"command -v systemctl"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - bool getSystemd = !String.IsNullOrEmpty(currentShellCommandResult); - - sshShellCommand = @"command -v getenforce"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - bool getGetenforce = !String.IsNullOrEmpty(currentShellCommandResult); - - - //没有安装apt-get,也没有安装dnf\yum,也没有安装zypper,或者没有安装systemd的,不满足安装条件 - //也就是apt-get ,dnf\yum, zypper必须安装其中之一,且必须安装Systemd的系统才能安装。 - if ((getApt == false && getDnf == false && getYum == false) || getSystemd == false) - { - //******"系统缺乏必要的安装组件如:apt-get||dnf||yum||zypper||Syetemd,主机系统推荐使用:CentOS 7/8,Debian 8/9/10,Ubuntu 16.04及以上版本"****** - MessageBox.Show(Application.Current.FindResource("MessageBoxShow_MissingSystemComponents").ToString()); - - //******"系统环境不满足要求,安装失败!!"****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_MissingSystemComponents").ToString(); - MainWindowsShowInfo(currentStatus); - - return false; - } - else - { - //******"检测结果:OK!"******06 - SetUpProgressBarProcessing(16); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_SystemRequirementsOK").ToString(); - MainWindowsShowInfo(currentStatus); - } - - //检测是否安装dig - if (string.IsNullOrEmpty(client.RunCommand("command -v dig").Result) == true) - { - //设置安装软件所用的命令格式 - if (getApt == true) - { - sshCmdUpdate = @"apt-get update"; - sshCmdInstall = @"apt-get -y install dnsutils"; - } - else if (getDnf == true) - { - sshCmdUpdate = @"dnf makecache"; - sshCmdInstall = @"dnf -y install bind-utils"; - } - else if (getYum == true) - { - sshCmdUpdate = @"yum makecache"; - sshCmdInstall = @"yum -y install bind-utils"; - } - sshShellCommand = sshCmdUpdate; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = sshCmdInstall; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - } - - //设置安装软件所用的命令格式 - if (getApt == true) - { - sshCmdUpdate = @"apt-get update"; - sshCmdInstall = @"apt-get -y install "; - } - else if (getDnf == true) - { - sshCmdUpdate = @"dnf clean all;dnf makecache"; - sshCmdInstall = @"dnf -y install "; - } - else if (getYum == true) - { - sshCmdUpdate = @"yum clean all; yum makecache"; - sshCmdInstall = @"yum -y install "; - } - //else if (getZypper == true) - //{ - // sshCmdUpdate = @"zypper ref"; - // sshCmdInstall = @"zypper -y install "; - //} - - //判断是否启用了SELinux,如果启用了,并且工作在Enforcing模式下,则改为Permissive模式 - if (getGetenforce == true) - { - sshShellCommand = @"getenforce"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - //string testSELinux = currentShellCommandResult; - - if (currentShellCommandResult.Contains("Enforcing") == true) - { - //******"检测到系统启用SELinux,且工作在严格模式下,需改为宽松模式!修改中......"******07 - SetUpProgressBarProcessing(18); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_EnableSELinux").ToString(); - MainWindowsShowInfo(currentStatus); - - sshShellCommand = @"setenforce 0"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"sed -i 's/SELINUX=enforcing/SELINUX=permissive/' /etc/selinux/config"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //******"修改完毕!"******08 - SetUpProgressBarProcessing(20); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_SELinuxModifyOK").ToString(); - MainWindowsShowInfo(currentStatus); - } - - } - - sshShellCommand = $"{sshCmdUpdate}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //在相应系统内安装curl(如果没有安装curl)--此为依赖软件 - if (string.IsNullOrEmpty(client.RunCommand("command -v curl").Result) == true) - { - sshShellCommand = $"{sshCmdInstall}curl"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - } - // 在相应系统内安装wget(如果没有安装wget)--此为依赖软件 - if (string.IsNullOrEmpty(client.RunCommand("command -v wget").Result) == true) - { - sshShellCommand = $"{sshCmdInstall}wget"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - } - // 在相应系统内安装unzip(如果没有安装unzip)--此为依赖软件 - if (string.IsNullOrEmpty(client.RunCommand("command -v unzip").Result) == true) - { - sshShellCommand = $"{sshCmdInstall}unzip"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - } - //处理极其少见的xz-utils未安装的情况 - - if (getApt == true) - { - sshShellCommand = $"{sshCmdInstall}xz-utils"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - } - else if (getDnf == true || getYum == true) - { - sshShellCommand = $"{sshCmdInstall}xz-devel"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - } - - //检测是否安装lsof - if (string.IsNullOrEmpty(client.RunCommand("command -v lsof").Result) == true) - { - sshShellCommand = $"{sshCmdInstall}lsof"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - } - - //检测主机是否为纯ipv6的主机 - onlyIpv6 = OnlyIpv6HostDetect(client); - - //如果未检测到有效的ip,连接就会被断开 - if (client.IsConnected == false) - { - return false; - } - if (onlyIpv6 == true) - { - functionResult = SetUpNat64(client, true); - if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return false; } - //sshShellCommand = $"{sshCmdUpdate}"; - //currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - } - - //****** "检测端口占用情况......" ****** - SetUpProgressBarProcessing(22); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_TestPortUsed").ToString(); - MainWindowsShowInfo(currentStatus); - - if (String.Equals(ReceiveConfigurationParameters[1], "80") == true || String.Equals(ReceiveConfigurationParameters[1], "443") == true) - { - string testPort80 = string.Empty; - string testPort443 = string.Empty; - - sshShellCommand = @"lsof -n -P -i :80 | grep LISTEN"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - testPort80 = currentShellCommandResult; - - sshShellCommand = @"lsof -n -P -i :443 | grep LISTEN"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - testPort443 = currentShellCommandResult; - - - if (String.IsNullOrEmpty(testPort80) == false || String.IsNullOrEmpty(testPort443) == false) - { - //****** "80/443端口之一,或全部被占用,将强制停止占用80/443端口的程序?" ****** - MessageBoxResult dialogResult = MessageBox.Show(Application.Current.FindResource("MessageBoxShow_ErrorPortUsed").ToString(), "Stop application", MessageBoxButton.YesNo); - if (dialogResult == MessageBoxResult.No) - { - //****** "端口被占用,安装失败......" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_ErrorPortUsedFail").ToString(); - MainWindowsShowInfo(currentStatus); - //client.Disconnect(); - return false; - } - - //****** "正在释放80/443端口......" ****** - SetUpProgressBarProcessing(24); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_ReleasePort").ToString(); - MainWindowsShowInfo(currentStatus); - - if (String.IsNullOrEmpty(testPort443) == false) - { - string[] cmdResultArry443 = testPort443.Split(' '); - - sshShellCommand = $"systemctl stop {cmdResultArry443[0]}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = $"systemctl disable {cmdResultArry443[0]}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = $"pkill {cmdResultArry443[0]}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - } - - if (String.IsNullOrEmpty(testPort80) == false) - { - string[] cmdResultArry80 = testPort80.Split(' '); - - sshShellCommand = $"systemctl stop {cmdResultArry80[0]}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = $"systemctl disable {cmdResultArry80[0]}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = $"pkill {cmdResultArry80[0]}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - } - testPort80 = string.Empty; - testPort443 = string.Empty; - - sshShellCommand = @"lsof -n -P -i :80 | grep LISTEN"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - testPort80 = currentShellCommandResult; - - sshShellCommand = @"lsof -n -P -i :443 | grep LISTEN"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - testPort443 = currentShellCommandResult; - - - if (String.IsNullOrEmpty(testPort80) == false || String.IsNullOrEmpty(testPort443) == false) - { - //****** "端口被占用,安装失败......" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_ErrorPortUsedFail").ToString(); - MainWindowsShowInfo(currentStatus); - //client.Disconnect(); - return false; - } - //****** "80/443端口释放完毕!" ****** - SetUpProgressBarProcessing(26); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_ReleasePortOK").ToString(); - MainWindowsShowInfo(currentStatus); - } - else - { - //****** "检测结果:未被占用!" ****** - SetUpProgressBarProcessing(26); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_PortNotUsed").ToString(); - MainWindowsShowInfo(currentStatus); - } - } - else - { - string testPort = string.Empty; - - sshShellCommand = $"lsof -n -P -i :{ReceiveConfigurationParameters[1]} | grep LISTEN"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - testPort = currentShellCommandResult; - - if (String.IsNullOrEmpty(testPort) == false) - { - //****** "端口被占用,将强制停止占用此端口的程序?" ****** - MessageBoxResult dialogResult = MessageBox.Show(ReceiveConfigurationParameters[1] + Application.Current.FindResource("MessageBoxShow_ErrorPortUsedOther").ToString(), "Stop application", MessageBoxButton.YesNo); - if (dialogResult == MessageBoxResult.No) - { - //****** "端口被占用,安装失败......" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_ErrorPortUsedFail").ToString(); - MainWindowsShowInfo(currentStatus); - //client.Disconnect(); - return false; - } - - //****** "正在释放端口......" ****** - SetUpProgressBarProcessing(24); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_ReleasePortOther").ToString(); - MainWindowsShowInfo(currentStatus); - - string[] cmdResultArry = testPort.Split(' '); - - sshShellCommand = $"systemctl stop {cmdResultArry[0]}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = $"systemctl disable {cmdResultArry[0]}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = $"pkill {cmdResultArry[0]}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - testPort = string.Empty; - - sshShellCommand = $"lsof -n -P -i :{ReceiveConfigurationParameters[1]} | grep LISTEN"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - testPort = currentShellCommandResult; - - if (String.IsNullOrEmpty(testPort) == false) - { - //****** "端口被占用,安装失败......" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_ErrorPortUsedFail").ToString(); - MainWindowsShowInfo(currentStatus); - //client.Disconnect(); - return false; - } - - //****** "端口释放完毕!" ****** - SetUpProgressBarProcessing(26); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_ReleasePortOKOther").ToString(); - MainWindowsShowInfo(currentStatus); - - } - else - { - //****** "检测结果:未被占用!" ****** - SetUpProgressBarProcessing(26); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_PortNotUsed").ToString(); - MainWindowsShowInfo(currentStatus); - } - } - //****** "开启防火墙相应端口......" ****** - SetUpProgressBarProcessing(27); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_OpenFireWallPort").ToString(); - MainWindowsShowInfo(currentStatus); - string openFireWallPort = ReceiveConfigurationParameters[1]; - if (String.IsNullOrEmpty(client.RunCommand("command -v firewall-cmd").Result) == false) - { - //有很奇怪的vps主机,在firewalld未运行时,端口是关闭的,无法访问。所以要先启动firewalld - //用于保证acme.sh申请证书成功 - sshShellCommand = @"firewall-cmd --state"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - if (String.Equals(currentShellCommandResult.Trim(), "running") == false) - { - sshShellCommand = @"systemctl restart firewalld"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - } - - - if (String.Equals(openFireWallPort, "443")) - { - sshShellCommand = @"firewall-cmd --zone=public --add-port=80/tcp --permanent"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"firewall-cmd --zone=public --add-port=80/udp --permanent"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"firewall-cmd --zone=public --add-port=443/tcp --permanent"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"firewall-cmd --zone=public --add-port=443/udp --permanent"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"yes | firewall-cmd --reload"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - } - else - { - sshShellCommand = $"firewall-cmd --zone=public --add-port={openFireWallPort}/tcp --permanent"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = $"firewall-cmd --zone=public --add-port={openFireWallPort}/udp --permanent"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"yes | firewall-cmd --reload"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - } - } - else if (String.IsNullOrEmpty(client.RunCommand("command -v ufw").Result) == false) - { - if (String.Equals(openFireWallPort, "443")) - { - sshShellCommand = @"ufw allow 80/tcp"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"ufw allow 80/udp"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"ufw allow 443/tcp"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"ufw allow 443/udp"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"yes | ufw reload"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - } - else - { - sshShellCommand = $"ufw allow {openFireWallPort}/tcp"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = $"ufw allow {openFireWallPort}/udp"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"yes | ufw reload"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - } - } - - SetUpProgressBarProcessing(30); - return true; - } - - //检测校对时间 31--33 - //functionResult = CheckProofreadingTime(client); - //if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - private bool CheckProofreadingTime(SshClient client) - { - //******"校对时间......"******09 - SetUpProgressBarProcessing(31); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_ProofreadingTime").ToString(); - MainWindowsShowInfo(currentStatus); - - //获取远程主机的时间戳 - long timeStampVPS = Convert.ToInt64(client.RunCommand("date +%s").Result.ToString()); - - //获取本地时间戳 - TimeSpan ts = DateTime.Now.ToUniversalTime() - new DateTime(1970, 1, 1, 0, 0, 0, 0); - long timeStampLocal = Convert.ToInt64(ts.TotalSeconds); - if (Math.Abs(timeStampLocal - timeStampVPS) >= 90) - { - //******"本地时间与远程主机时间相差超过限制(90秒),请先用 '系统工具-->时间校对' 校对时间后再设置"****** - MessageBox.Show(Application.Current.FindResource("MessageBoxShow_TimeError").ToString()); - //"时间较对失败......" - currentStatus = Application.Current.FindResource("DisplayInstallInfo_TimeError").ToString(); - MainWindowsShowInfo(currentStatus); - - //client.Disconnect(); - return false; - } - //******"时间差符合要求,OK!"******10 - SetUpProgressBarProcessing(33); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_TimeOK").ToString(); - MainWindowsShowInfo(currentStatus); - return true; - } - - - //检测域名是否解析到当前IP上 34---36 - //functionResult = DomainResolutionCurrentIPDetect(client); - //if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - private bool DomainResolutionCurrentIPDetect(SshClient client) - { - //****** "正在检测域名是否解析到当前VPS的IP上......" ******11 - SetUpProgressBarProcessing(34); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_TestDomainResolve").ToString(); - MainWindowsShowInfo(currentStatus); - - //再次初始化相关变量 - //ipv4 = String.Empty; - //ipv6 = String.Empty; - //onlyIpv6 = false; - - //sshShellCommand = @"curl -4 ip.sb"; - //sshShellCommand = @"curl -s https://api.ip.sb/ip --ipv4 --max-time 8"; - //currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - //ipv4 = currentShellCommandResult.TrimEnd('\r', '\n'); - - //sshShellCommand = @"curl -s https://api.ip.sb/ip --ipv6 --max-time 8"; - //currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - //ipv6 = currentShellCommandResult.TrimEnd('\r', '\n'); - - if (onlyIpv6 == false) - { - string nativeIp = ipv4; - - //string cmdFilter = ""; - string cmdFilter = @"| grep -oE '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | head -n 1"; - sshShellCommand = $"dig @resolver1.opendns.com A {ReceiveConfigurationParameters[4]} +short -4 {cmdFilter}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - string resultTestDomainCmd = currentShellCommandResult.TrimEnd('\r', '\n'); - if (String.Equals(nativeIp, resultTestDomainCmd) == true) - { - //****** "解析正确!OK!" ******12 - SetUpProgressBarProcessing(36); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_DomainResolveOK").ToString(); - MainWindowsShowInfo(currentStatus); - //onlyIpv6 = false; - return true; - } - - } - else - { - string nativeIp = ipv6; - - //string cmdFilter = ""; - string cmdFilter = @"| grep -oE '(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))' | head -n 1"; - sshShellCommand = $"dig @resolver1.opendns.com AAAA {ReceiveConfigurationParameters[4]} +short -6 {cmdFilter}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - string resultTestDomainCmd = currentShellCommandResult.TrimEnd('\r', '\n'); - if (String.Equals(nativeIp, resultTestDomainCmd) == true) - { - //****** "解析正确!OK!" ******12 - SetUpProgressBarProcessing(36); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_DomainResolveOK").ToString(); - MainWindowsShowInfo(currentStatus); - //onlyIpv6 = true; - - return true; - } - - } - //****** "域名未能正确解析到当前VPS的IP上!安装失败!" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_ErrorDomainResolve").ToString(); - MainWindowsShowInfo(currentStatus); - - //****** "域名未能正确解析到当前VPS的IP上,请检查!若解析设置正确,请等待生效后再重试安装。如果域名使用了CDN,请先关闭!" ****** - MessageBox.Show(Application.Current.FindResource("MessageBoxShow_ErrorDomainResolve").ToString()); - //client.Disconnect(); - return false; - - } - - - //安装代理程序 37--40 - //functionResult = ProxySoftInstall(client,@"",@""); - //if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - private bool ProxySoftInstall(SshClient client, string proxyName, string downloadUrl) - { - //****** "系统环境检测完毕,符合安装要求,开始布署......" ****** - SetUpProgressBarProcessing(37); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_StartInstalling").ToString(); - MainWindowsShowInfo(currentStatus); - - //****** "正在安装{proxyName}......" ****** - SetUpProgressBarProcessing(38); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_StartInstallSoft").ToString() + $"{proxyName}......"; - MainWindowsShowInfo(currentStatus); - - saveShellScriptFileName = GenerateRandomScriptFileName(GenerateRandomStr(10)); - - sshShellCommand = $"curl -o {saveShellScriptFileName} {downloadUrl}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - functionResult = FileCheckExists(client, $"{saveShellScriptFileName}"); - if (functionResult == false) - { - //***文件下载失败!*** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_DownloadScriptFailed").ToString(); - MainWindowsShowInfo(currentStatus); - return false; - - } - sshShellCommand = $"yes | bash {saveShellScriptFileName}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = $"rm -f {saveShellScriptFileName}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - SetUpProgressBarProcessing(40); - return true; - } - - //程序是否安装成功检测并设置开机启动 41--43 - //soft--要检测的程序 - //condition---成功安装的条件 - //functionResult = SoftInstalledSuccessOrFail(client,"v2ray",@"/usr/local/bin/v2ray"); - //if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - private bool SoftInstalledSuccessOrFail(SshClient client, string soft, string condition) - { - SetUpProgressBarProcessing(41); - //sshShellCommand = $"find / -name {soft}"; - //sshShellCommand = $"if [[ -f {condition} ]];then echo '1';else echo '0'; fi"; - //currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - bool functionResult = FileCheckExists(client, condition); - - //if (!currentShellCommandResult.Contains($"{condition}")) - if (functionResult == false) - { - //****** "安装失败,官方脚本运行出错!" ****** - MessageBox.Show(Application.Current.FindResource("MessageBoxShow_ErrorInstallSoftFail").ToString()); - //****** "安装失败,官方脚本运行出错!" ****** - currentStatus = Application.Current.FindResource("MessageBoxShow_ErrorInstallSoftFail").ToString(); - MainWindowsShowInfo(currentStatus); - - //client.Disconnect(); - return false; - } - else - { - //****** "安装成功!" ******20 - SetUpProgressBarProcessing(43); - currentStatus = $"{soft}" + Application.Current.FindResource("DisplayInstallInfo_SoftInstallSuccess").ToString(); - MainWindowsShowInfo(currentStatus); - - //开机启动 - sshShellCommand = $"systemctl enable {soft}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - } - return true; - } - - - //生成服务端配置 44--46 - //functionResult = GenerateServerConfiguration(client); - //if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - - - //上传服务配置 47--50 - private bool GenerateServerConfigurations(SshClient client) { return true; } - - //acme.sh安装与申请证书 51--57 - //functionResult = AcmeShInstall(client); - //if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - private bool AcmeShInstall(SshClient client) - { - //****** "正在安装acme.sh......" ******22 - SetUpProgressBarProcessing(51); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_StartInstallAcmeSh").ToString(); - MainWindowsShowInfo(currentStatus); - - //安装所依赖的软件 - sshShellCommand = $"{sshCmdUpdate}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = $"{sshCmdInstall}socat"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //解决搬瓦工CentOS缺少问题 - sshShellCommand = $"{sshCmdInstall}automake autoconf libtool"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //sshShellCommand = $"curl https://raw.githubusercontent.com/acmesh-official/acme.sh/master/acme.sh | INSTALLONLINE=1 sh"; - sshShellCommand = $"curl https://raw.githubusercontent.com/acmesh-official/acme.sh/master/acme.sh | sh -s -- --install-online -m {acmeEmail}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - if (currentShellCommandResult.Contains("Install success") == true) - { - //****** "acme.sh安装成功!" ******23 - SetUpProgressBarProcessing(54); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_AcmeShInstallSuccess").ToString(); - MainWindowsShowInfo(currentStatus); - } - else - { - //****** "acme.sh安装失败!原因未知,请向开发者提问!" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_ErrorAcmeShInstallFail").ToString(); - MainWindowsShowInfo(currentStatus); - return false; - } - - sshShellCommand = @"cd ~/.acme.sh/"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"alias acme.sh=~/.acme.sh/acme.sh"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //****** "申请域名证书......" ******24 - SetUpProgressBarProcessing(55); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_StartApplyCert").ToString(); - MainWindowsShowInfo(currentStatus); - - if (onlyIpv6 == true) - { - sshShellCommand = $"/root/.acme.sh/acme.sh --force --debug --issue --standalone -d {ReceiveConfigurationParameters[4]} --listen-v6"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - } - else - { - sshShellCommand = $"/root/.acme.sh/acme.sh --force --debug --issue --standalone -d {ReceiveConfigurationParameters[4]}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - } - - if (currentShellCommandResult.Contains("Cert success") == true) - { - //****** "证书申请成功!" ******25 - SetUpProgressBarProcessing(57); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_ApplyCertSuccess").ToString(); - MainWindowsShowInfo(currentStatus); - } - else - { - //****** "证书申请失败!原因未知,请向开发者提问!" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_ApplyCertFail").ToString(); - MainWindowsShowInfo(currentStatus); - return false; - } - return true; - - } - - - - //安装证书到代理程序 58--60 - private bool CertInstallProxy(SshClient client) - { - return true; - } - - - //Caddy安装与检测安装是否成功 61--66 - //functionResult = CaddyInstall(client); - //if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - private bool CaddyInstall(SshClient client) - { - //****** "安装Caddy......" ******28 - SetUpProgressBarProcessing(61); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_StartInstallCaddy").ToString(); - MainWindowsShowInfo(currentStatus); - - //为真则表示系统有相应的组件。 - if (getApt == true) - { - - sshShellCommand = @"echo ""deb [trusted=yes] https://apt.fury.io/caddy/ /"" | tee -a /etc/apt/sources.list.d/caddy-fury.list"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"apt-get install -y apt-transport-https"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"apt-get update"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"apt-get -y install caddy"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - } - else if (getDnf == true) - { - - sshShellCommand = @"dnf install 'dnf-command(copr)' -y"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"dnf copr enable @caddy/caddy -y"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //sshShellCommand = @"dnf makecache"; - //currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"dnf -y install caddy"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - } - else if (getYum == true) - { - - sshShellCommand = @"yum install yum-plugin-copr -y"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"yum copr enable @caddy/caddy -y"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //sshShellCommand = @"yum makecache"; - //currentShellCommandResult = MainWindowsShowCmd(client,sshShellCommand); - - sshShellCommand = @"yum -y install caddy"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - } - - string caddyService = @"/lib/systemd/system/caddy.service"; - functionResult = FileCheckExists(client, $"{caddyService}"); - if (functionResult == false) - { - caddyService = @"/usr/lib/systemd/system/caddy.service"; - } - sshShellCommand = $"sed -i 's/AmbientCapabilities/#AmbientCapabilities/g' {caddyService}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = $"sed -i 's/=caddy/=root/g' {caddyService}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = $"sed -i 's/LimitNPROC/#LimitNPROC/g' {caddyService}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = $"sed -i 's/LimitNOFILE/#LimitNOFILE/g' {caddyService}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"systemctl daemon-reload"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - - functionResult = FileCheckExists(client, @"/usr/bin/caddy"); - if (functionResult == true) - { - //****** "Caddy安装成功!" ******29 - SetUpProgressBarProcessing(66); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_InstalledCaddyOK").ToString(); - MainWindowsShowInfo(currentStatus); - - - sshShellCommand = @"systemctl enable caddy"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - return true; - - } - functionResult = ProxySoftInstall(client, @"Caddy", @"https://raw.githubusercontent.com/proxysu/shellscript/master/Caddy-Naive/caddy-naive-install.sh"); - //if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return false; } - - functionResult = FileCheckExists(client, @"/usr/bin/caddy"); - if (functionResult == true) - { - //****** "Caddy安装成功!" ******29 - SetUpProgressBarProcessing(66); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_InstalledCaddyOK").ToString(); - MainWindowsShowInfo(currentStatus); - - - sshShellCommand = @"systemctl enable caddy"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - return true; - } - - //****** "安装Caddy失败!" ****** - MessageBox.Show(Application.Current.FindResource("DisplayInstallInfo_ErrorInstallCaddyFail").ToString()); - //****** "安装Caddy失败!" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_ErrorInstallCaddyFail").ToString(); - MainWindowsShowInfo(currentStatus); - - //client.Disconnect(); - return false; - } - - - //上传Caddy配置文件67--70 - private bool UpConfigCaddy(SshClient client) - { - return true; - } - - //设置Caddy配置文件 - //functionResult = SetCaddyfile(client, @"/etc/caddy/Caddyfile"); - //if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - private bool SetCaddyfile(SshClient client, string upLoadPath) - { - - //设置Caddyfile文件中的tls 邮箱,在caddy2中已经不需要设置。 - - //设置Caddy监听的随机端口 - string randomCaddyListenPortStr = randomCaddyListenPort.ToString(); - - sshShellCommand = $"sed -i 's/8800/{randomCaddyListenPortStr}/' {upLoadPath}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //设置域名 - ReceiveConfigurationParameters[4] = ReceiveConfigurationParameters[4].TrimEnd(' '); - sshShellCommand = $"sed -i 's/##domain##/{ReceiveConfigurationParameters[4]}/g' {upLoadPath}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //设置Path - sshShellCommand = $"sed -i 's/##path##/\\{ReceiveConfigurationParameters[6]}/' {upLoadPath}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //设置伪装网站/纯ipv6主机暂不设置 - // && onlyIpv6 == false - if (String.IsNullOrEmpty(ReceiveConfigurationParameters[7]) == false) - { - sshShellCommand = $"sed -i 's/##reverse_Proxy1##/reverse_proxy http:\\/\\/{ReceiveConfigurationParameters[7]} {{/ ' {upLoadPath}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = $"sed -i 's/##reverse_Proxy2##/header_up Host {ReceiveConfigurationParameters[7]}/' {upLoadPath}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = $"sed -i 's/##reverse_Proxy3##/}}/' {upLoadPath}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - } - return true; - } - - //程序启动检测 - //soft--要检测的程序 - //condition---成功启动的条件 - //functionResult = SoftStartDetect(client, "v2ray", @"/usr/local/bin/v2ray"); - //if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - private bool SoftStartDetect(SshClient client, string soft, string condition) - { - //****** "正在启动......" ******33 - //SetUpProgressBarProcessing(87); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_StartSoft").ToString() + $"{soft}......"; - MainWindowsShowInfo(currentStatus); - - //启动服务 - sshShellCommand = $"systemctl restart {soft}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - Thread.Sleep(3000); - - sshShellCommand = $"ps aux | grep {soft}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - if (currentShellCommandResult.Contains($"{condition}") == true) - { - //****** "启动成功!" ******34 - //SetUpProgressBarProcessing(88); - currentStatus = $"{soft}" + Application.Current.FindResource("DisplayInstallInfo_StartSoftOK").ToString(); - MainWindowsShowInfo(currentStatus); - - } - else - { - //****** "启动失败!" ****** - currentStatus = $"{soft}" + Application.Current.FindResource("DisplayInstallInfo_StartSoftFail").ToString(); - MainWindowsShowInfo(currentStatus); - - Thread.Sleep(1000); - - //****** "正在启动(第二次尝试)!" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_StartSoftSecond").ToString() + $"{soft}"; - MainWindowsShowInfo(currentStatus); - - Thread.Sleep(3000); - sshShellCommand = $"systemctl restart {soft}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - Thread.Sleep(3000); - - sshShellCommand = $"ps aux | grep {soft}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - if (currentShellCommandResult.Contains($"{condition}") == true) - { - //****** "启动成功!" ****** - currentStatus = $"{soft}" + Application.Current.FindResource("DisplayInstallInfo_StartSoftOK").ToString(); - MainWindowsShowInfo(currentStatus); - - } - else - { - //****** "启动失败(第二次)!退出安装!" ****** - currentStatus = $"{soft}" + Application.Current.FindResource("DisplayInstallInfo_StartSoftSecondFail").ToString(); - MainWindowsShowInfo(currentStatus); - - //显示启动失败原因 - sshShellCommand = $"journalctl -n50 --no-pager --boot -u {soft}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - //****** "启动失败,原因如上!请排查原因!" ****** - currentStatus = $"{soft}" + Application.Current.FindResource("DisplayInstallInfo_StartSoftFailedExit").ToString(); - MainWindowsShowInfo(currentStatus); - - //****** "启动失败,原因如上!请排查原因!" ****** - MessageBox.Show($"{soft}" + Application.Current.FindResource("DisplayInstallInfo_StartSoftFailedExit").ToString()); - return false; - } - } - return true; - } - - //检测BBR,满足条件并启动 90--95 - //functionResult = DetectBBRandEnable(client); - //if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; } - private bool DetectBBRandEnable(SshClient client) - { - //测试BBR条件,若满足提示是否启用 - //****** "BBR测试......" ******37 - SetUpProgressBarProcessing(90); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_TestBBR").ToString(); - MainWindowsShowInfo(currentStatus); - - sshShellCommand = @"uname -r"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - string[] linuxKernelVerStrBBR = currentShellCommandResult.Split('-'); - - bool detectResultBBR = DetectKernelVersionBBR(linuxKernelVerStrBBR[0]); - - sshShellCommand = @"sysctl net.ipv4.tcp_congestion_control | grep bbr"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - string resultCmdTestBBR = currentShellCommandResult; - //如果内核满足大于等于4.9,且还未启用BBR,则启用BBR - if (detectResultBBR == true && resultCmdTestBBR.Contains("bbr") == false) - { - //****** "正在启用BBR......" ******38 - SetUpProgressBarProcessing(93); - currentStatus = Application.Current.FindResource("DisplayInstallInfo_EnableBBR").ToString(); - MainWindowsShowInfo(currentStatus); - - sshShellCommand = @"bash -c 'echo ""net.core.default_qdisc=fq"" >> /etc/sysctl.conf'"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"bash -c 'echo ""net.ipv4.tcp_congestion_control=bbr"" >> /etc/sysctl.conf'"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"sysctl -p"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - sshShellCommand = @"sysctl net.ipv4.tcp_congestion_control | grep bbr"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - - if (currentShellCommandResult.Contains("bbr") == true) - { - //****** "BBR启用成功!" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_BBREnabledSuccess").ToString(); - MainWindowsShowInfo(currentStatus); - } - else - { - //****** "系统不满足启用BBR的条件,启用失败!" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_BBRFailed").ToString(); - MainWindowsShowInfo(currentStatus); - //return false; - } - } - else if (resultCmdTestBBR.Contains("bbr") == true) - { - //****** "BBR已经启用了!" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_BBRisEnabled").ToString(); - MainWindowsShowInfo(currentStatus); - } - else - { - //****** "系统不满足启用BBR的条件,启用失败!" ****** - currentStatus = Application.Current.FindResource("DisplayInstallInfo_BBRFailed").ToString(); - MainWindowsShowInfo(currentStatus); - //return false; - } - - //如果是纯ipv6主机,则需要删除前面设置的Nat64网关 - if (onlyIpv6 == true) - { - SetUpNat64(client, false); - sshShellCommand = $"{sshCmdUpdate}"; - currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand); - } - - SetUpProgressBarProcessing(95); - return true; - } - - - - - - //生成客户端配置 96--98 - - - #endregion - - - } - -} diff --git a/ProxySU/ProofreadTimeWindow.xaml b/ProxySU/ProofreadTimeWindow.xaml deleted file mode 100644 index 01d9842..0000000 --- a/ProxySU/ProofreadTimeWindow.xaml +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ProxySU/ProofreadTimeWindow.xaml.cs b/ProxySU/ProofreadTimeWindow.xaml.cs deleted file mode 100644 index 0499216..0000000 --- a/ProxySU/ProofreadTimeWindow.xaml.cs +++ /dev/null @@ -1,258 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; -using System.Text.RegularExpressions; -using System.Threading; -using System.Threading.Tasks; -using System.IO; -using Renci.SshNet; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using Newtonsoft.Json.Serialization; -using System.Drawing; -using QRCoder; -using System.Net; -using System.Net.Sockets; -using System.Net.NetworkInformation; -using System.Runtime.InteropServices; -using System.Runtime; -using System.Globalization; - -namespace ProxySU -{ - /// - /// ProofreadTimeWindow.xaml 的交互逻辑 - /// - public partial class ProofreadTimeWindow : Window - { - public static ConnectionInfo ProfreadTimeReceiveConnectionInfo { get; set; } - //ProfreadTimeReceiveParameters - - public ProofreadTimeWindow() - { - InitializeComponent(); - - } - - private void ButtonTestTime_Click(object sender, RoutedEventArgs e) - { - using (var client = new SshClient(ProfreadTimeReceiveConnectionInfo)) - { - client.Connect(); - client.RunCommand("rm -f /etc/localtime"); - client.RunCommand("ln -s /usr/share/zoneinfo/UTC /etc/localtime"); - //获取远程主机的时间戳 - long timeStampVPS = Convert.ToInt64(client.RunCommand("date +%s").Result.ToString()); - - //获取本地时间戳 - TimeSpan ts = DateTime.Now.ToUniversalTime() - new DateTime(1970, 1, 1, 0, 0, 0, 0); - long timeStampLocal = Convert.ToInt64(ts.TotalSeconds); - client.Disconnect(); - if (Math.Abs(timeStampLocal - timeStampVPS) >= 90) - { - - MessageBox.Show("本地时间与远程主机时间相差超过限制(90秒),V2ray无法建立连接"); - - return; - } - else - { - MessageBox.Show("误差为:" + Math.Abs(timeStampLocal - timeStampVPS).ToString()+" 可以连接"); - } - } - } - - private void ButtonProofreading_Click(object sender, RoutedEventArgs e) - { - if (RadioButtonUpDateLocalTime.IsChecked == true) - { - //将本机电脑与网络时间同步 - DateTime netUTCtime = NetTime.GetUTCTime(); - if (!DateTime.Equals(netUTCtime, new DateTime(1970, 1, 1, 0, 0, 0, 0))) - { - DateTime localTime = netUTCtime.ToLocalTime(); - bool setD = UpdateTime.SetDate(localTime); - if (setD == true) - { - MessageBox.Show("本机时间已经更新为网络时间(国家授时中心获取)"); - } - else - { - MessageBox.Show("更新失败,请重试。"); - } - } - return; - } - using (var client = new SshClient(ProfreadTimeReceiveConnectionInfo)) - { - client.Connect(); - //设置vps为UTC时区 - client.RunCommand("rm -f /etc/localtime"); - client.RunCommand("ln -s /usr/share/zoneinfo/UTC /etc/localtime"); - - if (RadioButtonLocalTime.IsChecked == true) - { - //以本地时间为准,校正远程主机时间 - //获取本地时间戳 - TimeSpan ts = DateTime.Now.ToUniversalTime() - new DateTime(1970, 1, 1, 0, 0, 0, 0); - long timeStampLocal = Convert.ToInt64(ts.TotalSeconds); - - string sshCmd = $"date --set=\"$(date \"+%Y-%m-%d %H:%M:%S\" -d @{timeStampLocal.ToString()})\""; - - client.RunCommand(sshCmd); - MessageBox.Show("同步本地时间校时完毕"); - - - } - else - { - //以网络时间为准,校正远程主机时间 - TimeSpan utcTS = NetTime.GetUTCTime() - new DateTime(1970, 1, 1, 0, 0, 0, 0); - long timeStampVPS = Convert.ToInt64(utcTS.TotalSeconds); - if (timeStampVPS!=0) - { - - string sshCmd = $"date --set=\"$(date \"+%Y-%m-%d %H:%M:%S\" -d @{timeStampVPS.ToString()})\""; - - client.RunCommand(sshCmd); - MessageBox.Show("同步网络时间校时完毕"); - } - - } - client.Disconnect(); - } - - } - - private void TextBlock_MouseDown(object sender, MouseButtonEventArgs e) - { - RadioButtonNetworkTime.IsChecked = true; - } - - private void TextBlock_MouseDown_1(object sender, MouseButtonEventArgs e) - { - RadioButtonLocalTime.IsChecked = true; - } - - private void TextBlock_MouseDown_2(object sender, MouseButtonEventArgs e) - { - RadioButtonUpDateLocalTime.IsChecked = true; - } - - //private void ButtonTEST_Click(object sender, RoutedEventArgs e) - //{ - // //NetTime netTime = new NetTime(); - // string netDatetime = NetTime.GetUTCTime().ToString(); - // MessageBox.Show(netDatetime); - // //NetTime netTime = new NetTime(); - // //UpdateTime updateTime = new UpdateTime(); - // //DateTime netDateTime = netTime.GetBeijingTime(); - // //MessageBox.Show(netDateTime.ToString()); - //} - - } - - /// - /// 网络时间 代码从网上复制,原网址:https://www.codeleading.com/article/23791981303/ - /// - public class NetTime - { - /// - /// 从国家授时中心获取标准GMT时间,读取https://www.tsa.cn - /// GMT时间与UTC时间没有差别,可以UTC=GMT - /// - /// 返回网络时间 - public static DateTime GetUTCTime() - { - DateTime time; - ////Thread.Sleep(5000); - try - { - HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://www.tsa.cn"); - request.Method = "HEAD"; - request.AllowAutoRedirect = false; - HttpWebResponse reponse = (HttpWebResponse)request.GetResponse(); - string cc = reponse.GetResponseHeader("date"); - reponse.Close(); - - bool s = GMTStrParse(cc, out time); - return time; - } - catch (Exception ex1) - { - if (ex1.ToString().Contains("403")) - { - MessageBox.Show("校时操作太频繁,请稍等片刻再操作!"); - } - else - { - MessageBox.Show(ex1.Message); - } - return time = new DateTime(1970, 1, 1, 0, 0, 0, 0); - } - - //return time.AddHours(8); //GMT要加8个小时才是北京时间 - } - public static bool GMTStrParse(string gmtStr, out DateTime gmtTime) //抓取的date是GMT格式的字符串,这里转成datetime - { - CultureInfo enUS = new CultureInfo("en-US"); - bool s = DateTime.TryParseExact(gmtStr, "r", enUS, DateTimeStyles.None, out gmtTime); - return s; - } - - } - - /// - /// 更新系统时间,代码从网上复制,原网址:https://www.open-open.com/code/view/1430552965599 - /// - public class UpdateTime - { - //设置系统时间的API函数 - [DllImport("kernel32.dll")] - private static extern bool SetLocalTime(ref SYSTEMTIME time); - - [StructLayout(LayoutKind.Sequential)] - private struct SYSTEMTIME - { - public short year; - public short month; - public short dayOfWeek; - public short day; - public short hour; - public short minute; - public short second; - public short milliseconds; - } - - /// - /// 设置系统时间 - /// - /// 需要设置的时间 - /// 返回系统时间设置状态,true为成功,false为失败 - public static bool SetDate(DateTime dt) - { - SYSTEMTIME st; - - st.year = (short)dt.Year; - st.month = (short)dt.Month; - st.dayOfWeek = (short)dt.DayOfWeek; - st.day = (short)dt.Day; - st.hour = (short)dt.Hour; - st.minute = (short)dt.Minute; - st.second = (short)dt.Second; - st.milliseconds = (short)dt.Millisecond; - bool rt = SetLocalTime(ref st); - return rt; - } - } - -} diff --git a/ProxySU/Properties/AssemblyInfo.cs b/ProxySU/Properties/AssemblyInfo.cs deleted file mode 100644 index 75b945d..0000000 --- a/ProxySU/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System.Reflection; -using System.Resources; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Windows; - -// 有关程序集的一般信息由以下 -// 控制。更改这些特性值可修改 -// 与程序集关联的信息。 -[assembly: AssemblyTitle("ProxySU")] -[assembly: AssemblyDescription("V2ray,Trojan,NaiveProxy,Trojan-Go等一键安装工具")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("ProxySU")] -[assembly: AssemblyProduct("ProxySU")] -[assembly: AssemblyCopyright("Copyright © 2020")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// 将 ComVisible 设置为 false 会使此程序集中的类型 -//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 -//请将此类型的 ComVisible 特性设置为 true。 -[assembly: ComVisible(false)] - -//若要开始生成可本地化的应用程序,请设置 -//.csproj 文件中的 CultureYouAreCodingWith -//例如,如果您在源文件中使用的是美国英语, -//使用的是美国英语,请将 设置为 en-US。 然后取消 -//对以下 NeutralResourceLanguage 特性的注释。 更新 -//以下行中的“en-US”以匹配项目文件中的 UICulture 设置。 - -//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] - - -[assembly: ThemeInfo( - ResourceDictionaryLocation.None, //主题特定资源词典所处位置 - //(未在页面中找到资源时使用, - //或应用程序资源字典中找到时使用) - ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置 - //(未在页面中找到资源时使用, - //、应用程序或任何主题专用资源字典中找到时使用) -)] - - -// 程序集的版本信息由下列四个值组成: -// -// 主版本 -// 次版本 -// 生成号 -// 修订号 -// -// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号 -// 方法是按如下所示使用“*”: : -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.5.6.0")] -[assembly: AssemblyFileVersion("2.5.6.0")] diff --git a/ProxySU/Properties/Resources.Designer.cs b/ProxySU/Properties/Resources.Designer.cs deleted file mode 100644 index 50e1154..0000000 --- a/ProxySU/Properties/Resources.Designer.cs +++ /dev/null @@ -1,71 +0,0 @@ -//------------------------------------------------------------------------------ -// -// 此代码由工具生成。 -// 运行时版本: 4.0.30319.42000 -// -// 对此文件的更改可能导致不正确的行为,如果 -// 重新生成代码,则所做更改将丢失。 -// -//------------------------------------------------------------------------------ - -namespace ProxySU.Properties -{ - - - /// - /// 强类型资源类,用于查找本地化字符串等。 - /// - // 此类是由 StronglyTypedResourceBuilder - // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 - // 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen - // (以 /str 作为命令选项),或重新生成 VS 项目。 - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources - { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() - { - } - - /// - /// 返回此类使用的缓存 ResourceManager 实例。 - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager - { - get - { - if ((resourceMan == null)) - { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ProxySU.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// 覆盖当前线程的 CurrentUICulture 属性 - /// 使用此强类型的资源类的资源查找。 - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture - { - get - { - return resourceCulture; - } - set - { - resourceCulture = value; - } - } - } -} diff --git a/ProxySU/Properties/Resources.resx b/ProxySU/Properties/Resources.resx deleted file mode 100644 index af7dbeb..0000000 --- a/ProxySU/Properties/Resources.resx +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/ProxySU/Properties/Settings.Designer.cs b/ProxySU/Properties/Settings.Designer.cs deleted file mode 100644 index 654607b..0000000 --- a/ProxySU/Properties/Settings.Designer.cs +++ /dev/null @@ -1,30 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace ProxySU.Properties -{ - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase - { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default - { - get - { - return defaultInstance; - } - } - } -} diff --git a/ProxySU/Properties/Settings.settings b/ProxySU/Properties/Settings.settings deleted file mode 100644 index 033d7a5..0000000 --- a/ProxySU/Properties/Settings.settings +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/ProxySU/ProxySU.csproj b/ProxySU/ProxySU.csproj deleted file mode 100644 index 9ae9d06..0000000 --- a/ProxySU/ProxySU.csproj +++ /dev/null @@ -1,213 +0,0 @@ - - - - - Debug - AnyCPU - {DD5505BC-E7F1-4D03-ABC7-B636E893FC09} - WinExe - ProxySU - ProxySU - v4.0 - 512 - {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 4 - true - false - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 1 - 1.0.0.%2a - false - true - true - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - ProxySU.ico - - - 01AFC64B121E781F77B42A6E9F1B587DDBAD475A - - - ProxySU_TemporaryKey.pfx - - - true - - - true - - - - ..\json.net\net40\Newtonsoft.Json.dll - - - ..\qrcoder\net40\QRCoder.dll - - - ..\packages\SSH.NET.2020.0.1\lib\net40\Renci.SshNet.dll - - - - - - - - - - - - 4.0 - - - - - - - - MSBuild:Compile - Designer - - - - ProofreadTimeWindow.xaml - - - ResultClientInformation.xaml - - - SSpluginWindow.xaml - - - XayTemplateWindow.xaml - - - V2RayTemplateWindow.xaml - - - TrojanGoTemplateWindow.xaml - - - MSBuild:Compile - Designer - - - App.xaml - Code - - - MainWindow.xaml - Code - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - MSBuild:Compile - Designer - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - - - Code - - - True - True - Resources.resx - - - True - Settings.settings - True - - - ResXFileCodeGenerator - Resources.Designer.cs - - - .editorconfig - - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - - - False - .NET Framework 3.5 SP1 - false - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/ProxySU/ProxySU.csproj.user b/ProxySU/ProxySU.csproj.user deleted file mode 100644 index 0871ddf..0000000 --- a/ProxySU/ProxySU.csproj.user +++ /dev/null @@ -1,17 +0,0 @@ - - - - publish\ - - - - - - zh-CN - false - ProjectFiles - - - false - - \ No newline at end of file diff --git a/ProxySU/ProxySU.ico b/ProxySU/ProxySU.ico deleted file mode 100644 index 9d7a128..0000000 Binary files a/ProxySU/ProxySU.ico and /dev/null differ diff --git a/ProxySU/ResultClientInformation.xaml b/ProxySU/ResultClientInformation.xaml deleted file mode 100644 index eede1c4..0000000 --- a/ProxySU/ResultClientInformation.xaml +++ /dev/null @@ -1,570 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ProxySU/ResultClientInformation.xaml.cs b/ProxySU/ResultClientInformation.xaml.cs deleted file mode 100644 index 719ece9..0000000 --- a/ProxySU/ResultClientInformation.xaml.cs +++ /dev/null @@ -1,4942 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Web; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; -using System.IO; -using Renci.SshNet; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using Newtonsoft.Json.Serialization; -using System.Drawing; -using QRCoder; -using System.Runtime.InteropServices; - - -namespace ProxySU -{ - /// - /// ResultClientInformation.xaml 的交互逻辑 - /// - public partial class ResultClientInformation : Window - { - private static string saveFileFolder = ""; - private static string configDomainSavePath = ""; - private static string server = MainWindow.ReceiveConfigurationParameters[4]; - - private static string TextBoxURLDefault; - private static string TextBoxURLVlessTcp; - private static string TextBoxURLVlessWs; - private static string TextBoxURLVmessTcp; - private static string TextBoxURLVmessWs; - private static string TextBoxURLTrojanTcp; - - private static BitmapSource ImageShareQRcodeDefault; - private static BitmapSource ImageShareQRcodeVlessTcp; - private static BitmapSource ImageShareQRcodeVlessWs; - private static BitmapSource ImageShareQRcodeVmessTcp; - private static BitmapSource ImageShareQRcodeVmessWs; - private static BitmapSource ImageShareQRcodeTrojanTcp; - - - [DllImport("user32.dll")] - private static extern int MessageBoxTimeoutA(IntPtr hWnd, string msg, string Caps, int type, int Id, int time); //引用DLL - - public ResultClientInformation() - { - InitializeComponent(); - - if (String.Equals(MainWindow.proxyType, "V2Ray")) - { - //显示V2Ray参数,隐藏其他 - GroupBoxClientMTProto.Visibility = Visibility.Collapsed; - GroupBoxClientQRandURL.Visibility = Visibility.Visible; - GroupBoxClientSSpc.Visibility = Visibility.Collapsed; - GroupBoxV2rayClient.Visibility = Visibility.Visible; - GroupBoxXrayClient.Visibility = Visibility.Collapsed; - GroupBoxTrojanGoClient.Visibility = Visibility.Collapsed; - GroupBoxTrojanClient.Visibility = Visibility.Collapsed; - GroupBoxNaiveProxyClient.Visibility = Visibility.Collapsed; - GroupBoxSSRClient.Visibility = Visibility.Collapsed; - GroupBoxClientSS.Visibility = Visibility.Collapsed; - - //主机地址 - TextBoxHostAddress.Text = MainWindow.ReceiveConfigurationParameters[4]; - //主机端口 - TextBoxPort.Text = MainWindow.ReceiveConfigurationParameters[1]; - //用户ID(uuid)/Trojan密码 - TextBoxUUID.Text = MainWindow.ReceiveConfigurationParameters[2]; - //额外ID - TextBoxUUIDextra.Text = "0"; - //加密方式,一般都为auto - TextBoxEncryption.Text = "auto"; - - //传输协议 - TextBoxTransmission.Text = ""; - //伪装类型 - TextBoxCamouflageType.Text = MainWindow.ReceiveConfigurationParameters[5]; - - //TLS的Host /Quic 加密方式 - TextBoxHostQuicEncryption.Text = ""; - - //QUIC密钥/mKCP Seed/路径Path - TextBoxQuicKeyMkcpSeedPath.Text = MainWindow.ReceiveConfigurationParameters[6]; - - //TLS设置 - TextBoxTLS.Text = "none"; - - //初始化时,隐藏多方案客户端选择面板 - GroupBoxSelectVlessVmessXtlsTcpWs.Visibility = Visibility.Collapsed; - //显示非Trojan的所有参数 - GridNotTrojanParameters.Visibility = Visibility.Visible; - - if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "VlessVmessXtlsTcpWebSocketWeb") == false) - { - #region 单模式方案 - if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "TCP") == true) - { - TextBoxTransmission.Text = "tcp"; - TextBoxCamouflageType.Text = "none"; - TextBoxTLS.Text = "none"; - ShowHostName(); - ShowPathV2ray(); - - } - else if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "TCPhttp") == true) - { - TextBoxTransmission.Text = "tcp"; - TextBoxCamouflageType.Text = "http"; - TextBoxTLS.Text = "none"; - ShowHostName(); - ShowPathV2ray(); - } - else if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "tcpTLS") == true) - { - TextBoxEncryption.Text = "none"; - TextBoxTransmission.Text = "tcp"; - TextBoxCamouflageType.Text = "none"; - //TLS的Host /Quic 加密方式 - TextBoxHostQuicEncryption.Text = MainWindow.ReceiveConfigurationParameters[4]; - TextBoxTLS.Text = "tls"; - ShowHostName(); - ShowPathV2ray(); - } - else if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "tcpTLSselfSigned") == true) - { - TextBoxTransmission.Text = "tcp"; - TextBoxCamouflageType.Text = "none"; - //TLS的Host /Quic 加密方式 - TextBoxHostQuicEncryption.Text = MainWindow.ReceiveConfigurationParameters[4]; - TextBoxTLS.Text = "tls"; - ShowHostName(); - ShowPathV2ray(); - } - else if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "VlessXtlsTcp") == true) - { - TextBlockVmessOrVless.Text = Application.Current.FindResource("TabItemHeaderV2RayVlessProtocol").ToString(); - - TextBoxTransmission.Text = "tcp"; - TextBoxCamouflageType.Text = "none"; - //TLS的Host /Quic 加密方式 - TextBoxHostQuicEncryption.Text = MainWindow.ReceiveConfigurationParameters[4]; - TextBoxEncryption.Text = "none"; - TextBoxTLS.Text = "xtls"; - HideAlterId(); - ShowHostName(); - ShowPathV2ray(); - HideGroupBoxClientQRandURL(); - } - else if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "VlessTcpTlsWeb") == true) - { - TextBlockVmessOrVless.Text = Application.Current.FindResource("TabItemHeaderV2RayVlessProtocol").ToString(); - - TextBoxTransmission.Text = "tcp"; - TextBoxCamouflageType.Text = "none"; - //TLS的Host /Quic 加密方式 - TextBoxHostQuicEncryption.Text = MainWindow.ReceiveConfigurationParameters[4]; - TextBoxEncryption.Text = "none"; - TextBoxTLS.Text = "tls"; - HideAlterId(); - ShowHostName(); - ShowPathV2ray(); - HideGroupBoxClientQRandURL(); - } - else if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "VlessWebSocketTlsWeb") == true) - { - TextBlockVmessOrVless.Text = Application.Current.FindResource("TabItemHeaderV2RayVlessProtocol").ToString(); - - TextBoxTransmission.Text = "ws"; - TextBoxCamouflageType.Text = "none"; - //TLS的Host /Quic 加密方式 - TextBoxHostQuicEncryption.Text = MainWindow.ReceiveConfigurationParameters[4]; - TextBoxEncryption.Text = "none"; - TextBoxTLS.Text = "tls"; - HideAlterId(); - ShowHostName(); - ShowPathV2ray(); - HideGroupBoxClientQRandURL(); - } - else if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "VlessHttp2Web") == true) - { - TextBlockVmessOrVless.Text = Application.Current.FindResource("TabItemHeaderV2RayVlessProtocol").ToString(); - - TextBoxTransmission.Text = "h2"; - TextBoxCamouflageType.Text = "none"; - //TLS的Host /Quic 加密方式 - TextBoxHostQuicEncryption.Text = MainWindow.ReceiveConfigurationParameters[4]; - TextBoxEncryption.Text = "none"; - TextBoxTLS.Text = "tls"; - HideAlterId(); - ShowHostName(); - ShowPathV2ray(); - HideGroupBoxClientQRandURL(); - } - else if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "webSocket") == true) - { - TextBoxTransmission.Text = "ws"; - TextBoxCamouflageType.Text = "none"; - TextBoxTLS.Text = "none"; - ShowHostName(); - ShowPathV2ray(); - } - else if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "WebSocketTLS") == true) - { - TextBoxEncryption.Text = "none"; - TextBoxTransmission.Text = "ws"; - TextBoxCamouflageType.Text = "none"; - //TLS的Host /Quic 加密方式 - TextBoxHostQuicEncryption.Text = MainWindow.ReceiveConfigurationParameters[4]; - TextBoxTLS.Text = "tls"; - ShowHostName(); - ShowPathV2ray(); - } - else if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "WebSocketTLS2Web") == true) - { - TextBoxEncryption.Text = "none"; - TextBoxTransmission.Text = "ws"; - TextBoxCamouflageType.Text = "none"; - //TLS的Host /Quic 加密方式 - TextBoxHostQuicEncryption.Text = MainWindow.ReceiveConfigurationParameters[4]; - TextBoxTLS.Text = "tls"; - ShowHostName(); - ShowPathV2ray(); - } - else if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "WebSocketTLSselfSigned") == true) - { - TextBoxTransmission.Text = "ws"; - TextBoxCamouflageType.Text = "none"; - //TLS的Host /Quic 加密方式 - TextBoxHostQuicEncryption.Text = MainWindow.ReceiveConfigurationParameters[4]; - TextBoxTLS.Text = "tls"; - ShowHostName(); - ShowPathV2ray(); - } - else if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "Http2") == true) - { - TextBoxEncryption.Text = "none"; - TextBoxTransmission.Text = "h2"; - TextBoxCamouflageType.Text = "none"; - //TLS的Host /Quic 加密方式 - TextBoxHostQuicEncryption.Text = MainWindow.ReceiveConfigurationParameters[4]; - TextBoxTLS.Text = "tls"; - ShowHostName(); - ShowPathV2ray(); - } - else if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "http2Web") == true) - { - TextBoxEncryption.Text = "none"; - TextBoxTransmission.Text = "h2"; - TextBoxCamouflageType.Text = "none"; - TextBoxHostQuicEncryption.Text = MainWindow.ReceiveConfigurationParameters[4];//获取Host - TextBoxTLS.Text = "tls"; - ShowHostName(); - ShowPathV2ray(); - } - else if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "http2selfSigned") == true) - { - TextBoxTransmission.Text = "h2"; - TextBoxCamouflageType.Text = "none"; - //TLS的Host /Quic 加密方式 - TextBoxHostQuicEncryption.Text = MainWindow.ReceiveConfigurationParameters[4]; - TextBoxTLS.Text = "tls"; - ShowHostName(); - ShowPathV2ray(); - } - else if (MainWindow.ReceiveConfigurationParameters[0].Contains("mKCP") == true) - { - if(MainWindow.mKCPvlessIsSet == true) - { - TextBlockVmessOrVless.Text = Application.Current.FindResource("TabItemHeaderV2RayVlessProtocol").ToString(); - TextBoxEncryption.Text = "none"; - HideAlterId(); - HideGroupBoxClientQRandURL(); - } - if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "mKCPNone") == true) - { - TextBoxCamouflageType.Text = "none"; - } - else if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "mKCP2SRTP") == true) - { - TextBoxCamouflageType.Text = "srtp"; - } - else if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "mKCPuTP") == true) - { - TextBoxCamouflageType.Text = "utp"; - } - else if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "mKCP2WechatVideo") == true) - { - TextBoxCamouflageType.Text = "wechat-video"; - } - else if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "mKCP2DTLS") == true) - { - TextBoxCamouflageType.Text = "dtls"; - } - else if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "mKCP2WireGuard") == true) - { - TextBoxCamouflageType.Text = "wireguard"; - } - - TextBoxTransmission.Text = "kcp"; - TextBoxQuicKeyMkcpSeedPath.Text = MainWindow.ReceiveConfigurationParameters[6];//获取mkcp Seed - TextBoxTLS.Text = "none"; - ShowHostName(); - ShowMkcpSeed(); - } - else if (MainWindow.ReceiveConfigurationParameters[0].Contains("Quic") == true) - { - if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "QuicNone") == true) - { - TextBoxCamouflageType.Text = "none"; - - } - else if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "QuicSRTP") == true) - { - TextBoxCamouflageType.Text = "srtp"; - } - else if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "Quic2uTP") == true) - { - TextBoxCamouflageType.Text = "utp"; - } - else if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "QuicWechatVideo") == true) - { - TextBoxCamouflageType.Text = "wechat-video"; - } - else if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "QuicDTLS") == true) - { - TextBoxCamouflageType.Text = "dtls"; - } - else if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "QuicWireGuard") == true) - { - TextBoxCamouflageType.Text = "wireguard"; - } - - TextBoxTransmission.Text = "quic"; - TextBoxHostQuicEncryption.Text = MainWindow.ReceiveConfigurationParameters[3];//获取Quic加密方式 - TextBoxQuicKeyMkcpSeedPath.Text = MainWindow.ReceiveConfigurationParameters[6];//获取Quic加密密钥 - TextBoxTLS.Text = "none"; - ShowQuicEncryption(); - ShowQuicKey(); - } - - else - { - TextBoxTransmission.Text = "tcp"; - TextBoxCamouflageType.Text = "none"; - TextBoxTLS.Text = "none"; - ShowHostName(); - ShowPathV2ray(); - } - CheckDir("v2ray_config"); - - GenerateV2rayShareQRcodeAndBase64Url(); - #endregion - } - else - { - //显示多方案客户端选择面板 - GroupBoxSelectVlessVmessXtlsTcpWs.Visibility = Visibility.Visible; - - string proxyfolder = CheckDir("v2ray_config"); - configDomainSavePath = CreateConfigSaveDir(proxyfolder, TextBoxHostAddress.Text); - - V2raySetVlessTcpXtls(); - //GenerateV2rayVlessTcpXtlsShareQRcodeAndBase64Url(); - - V2raySetVlessTcpTls(); - GenerateV2rayVlessTcpTlsShareQRcodeAndBase64Url(); - - V2raySetVlessWsTls(); - GenerateV2rayVlessWsTlsShareQRcodeAndBase64Url(); - - V2raySetVmessTcpTls(); - GenerateV2rayVmessTcpTlsShareQRcodeAndBase64Url(); - - V2raySetVmessWsTls(); - GenerateV2rayVmessWsTlsShareQRcodeAndBase64Url(); - - GenerateV2rayTrojanShareQRcodeAndBase64Url(); - RadioButtonVlessTcpTls.IsChecked = true; - } - - } - else if (String.Equals(MainWindow.proxyType, "Xray")) - { - //显示Xray参数,隐藏其他 - GroupBoxClientMTProto.Visibility = Visibility.Collapsed; - GroupBoxClientQRandURL.Visibility = Visibility.Visible; - GroupBoxClientSSpc.Visibility = Visibility.Collapsed; - GroupBoxV2rayClient.Visibility = Visibility.Collapsed; - GroupBoxXrayClient.Visibility = Visibility.Visible; - GroupBoxTrojanGoClient.Visibility = Visibility.Collapsed; - GroupBoxTrojanClient.Visibility = Visibility.Collapsed; - GroupBoxNaiveProxyClient.Visibility = Visibility.Collapsed; - GroupBoxSSRClient.Visibility = Visibility.Collapsed; - GroupBoxClientSS.Visibility = Visibility.Collapsed; - - //主机地址 - TextBoxHostAddressXray.Text = MainWindow.ReceiveConfigurationParameters[4]; - //主机端口 - TextBoxPortXray.Text = MainWindow.ReceiveConfigurationParameters[1]; - //用户ID(uuid)/Trojan密码 - TextBoxUUIDXray.Text = MainWindow.ReceiveConfigurationParameters[2]; - //额外ID - TextBoxUUIDextraXray.Text = "0"; - //加密方式,一般都为auto - TextBoxEncryptionXray.Text = "auto"; - - //传输协议 - TextBoxTransmissionXray.Text = ""; - //伪装类型 - TextBoxCamouflageTypeXray.Text = MainWindow.ReceiveConfigurationParameters[5]; - - //TLS的Host /Quic 加密方式 - TextBoxHostQuicEncryptionXray.Text = ""; - - //QUIC密钥/mKCP Seed/路径Path - TextBoxQuicKeyMkcpSeedPathXray.Text = MainWindow.ReceiveConfigurationParameters[6]; - - //TLS设置 - TextBoxTLSXray.Text = "none"; - - //初始化时,隐藏多方案客户端选择面板 - GroupBoxSelectVlessVmessXtlsTcpWsXray.Visibility = Visibility.Collapsed; - //显示非Trojan的所有参数 - GridNotTrojanParametersXray.Visibility = Visibility.Visible; - - if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "VlessVmessXtlsTcpWebSocketWeb") == false) - { - #region 单模式方案 - if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "TCP") == true) - { - TextBoxTransmissionXray.Text = "tcp"; - TextBoxCamouflageTypeXray.Text = "none"; - TextBoxTLSXray.Text = "none"; - ShowHostNameXray(); - ShowPathXray(); - - } - else if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "TCPhttp") == true) - { - TextBoxTransmissionXray.Text = "tcp"; - TextBoxCamouflageTypeXray.Text = "http"; - TextBoxTLSXray.Text = "none"; - ShowHostNameXray(); - ShowPathXray(); - } - else if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "tcpTLS") == true) - { - TextBoxEncryptionXray.Text = "none"; - TextBoxTransmissionXray.Text = "tcp"; - TextBoxCamouflageTypeXray.Text = "none"; - //TLS的Host /Quic 加密方式 - TextBoxHostQuicEncryptionXray.Text = MainWindow.ReceiveConfigurationParameters[4]; - TextBoxTLSXray.Text = "tls"; - ShowHostNameXray(); - ShowPathXray(); - } - else if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "tcpTLSselfSigned") == true) - { - TextBoxTransmissionXray.Text = "tcp"; - TextBoxCamouflageTypeXray.Text = "none"; - //TLS的Host /Quic 加密方式 - TextBoxHostQuicEncryptionXray.Text = MainWindow.ReceiveConfigurationParameters[4]; - TextBoxTLSXray.Text = "tls"; - ShowHostNameXray(); - ShowPathXray(); - } - else if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "VlessXtlsTcp") == true) - { - TextBlockVmessOrVlessXray.Text = Application.Current.FindResource("TabItemHeaderV2RayVlessProtocol").ToString(); - - TextBoxTransmissionXray.Text = "tcp"; - TextBoxCamouflageTypeXray.Text = "none"; - //TLS的Host /Quic 加密方式 - TextBoxHostQuicEncryptionXray.Text = MainWindow.ReceiveConfigurationParameters[4]; - TextBoxEncryptionXray.Text = "none"; - TextBoxTLSXray.Text = "xtls"; - HideAlterIdXray(); - ShowHostNameXray(); - ShowPathXray(); - HideGroupBoxClientQRandURL(); - } - else if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "VlessTcpTlsWeb") == true) - { - TextBlockVmessOrVlessXray.Text = Application.Current.FindResource("TabItemHeaderV2RayVlessProtocol").ToString(); - - TextBoxTransmissionXray.Text = "tcp"; - TextBoxCamouflageTypeXray.Text = "none"; - //TLS的Host /Quic 加密方式 - TextBoxHostQuicEncryptionXray.Text = MainWindow.ReceiveConfigurationParameters[4]; - TextBoxEncryptionXray.Text = "none"; - TextBoxTLSXray.Text = "tls"; - HideAlterIdXray(); - ShowHostNameXray(); - ShowPathXray(); - HideGroupBoxClientQRandURL(); - } - else if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "VlessWebSocketTlsWeb") == true) - { - TextBlockVmessOrVlessXray.Text = Application.Current.FindResource("TabItemHeaderV2RayVlessProtocol").ToString(); - - TextBoxTransmissionXray.Text = "ws"; - TextBoxCamouflageTypeXray.Text = "none"; - //TLS的Host /Quic 加密方式 - TextBoxHostQuicEncryptionXray.Text = MainWindow.ReceiveConfigurationParameters[4]; - TextBoxEncryptionXray.Text = "none"; - TextBoxTLSXray.Text = "tls"; - HideAlterIdXray(); - ShowHostNameXray(); - ShowPathXray(); - HideGroupBoxClientQRandURL(); - } - else if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "VlessHttp2Web") == true) - { - TextBlockVmessOrVlessXray.Text = Application.Current.FindResource("TabItemHeaderV2RayVlessProtocol").ToString(); - - TextBoxTransmissionXray.Text = "h2"; - TextBoxCamouflageTypeXray.Text = "none"; - //TLS的Host /Quic 加密方式 - TextBoxHostQuicEncryptionXray.Text = MainWindow.ReceiveConfigurationParameters[4]; - TextBoxEncryptionXray.Text = "none"; - TextBoxTLSXray.Text = "tls"; - HideAlterIdXray(); - ShowHostNameXray(); - ShowPathXray(); - HideGroupBoxClientQRandURL(); - } - else if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "webSocket") == true) - { - TextBoxTransmissionXray.Text = "ws"; - TextBoxCamouflageTypeXray.Text = "none"; - TextBoxTLSXray.Text = "none"; - ShowHostNameXray(); - ShowPathXray(); - } - else if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "WebSocketTLS") == true) - { - TextBoxEncryptionXray.Text = "none"; - TextBoxTransmissionXray.Text = "ws"; - TextBoxCamouflageType.Text = "none"; - //TLS的Host /Quic 加密方式 - TextBoxHostQuicEncryptionXray.Text = MainWindow.ReceiveConfigurationParameters[4]; - TextBoxTLSXray.Text = "tls"; - ShowHostNameXray(); - ShowPathXray(); - } - else if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "WebSocketTLS2Web") == true) - { - TextBoxEncryptionXray.Text = "none"; - TextBoxTransmissionXray.Text = "ws"; - TextBoxCamouflageTypeXray.Text = "none"; - //TLS的Host /Quic 加密方式 - TextBoxHostQuicEncryptionXray.Text = MainWindow.ReceiveConfigurationParameters[4]; - TextBoxTLSXray.Text = "tls"; - ShowHostNameXray(); - ShowPathXray(); - } - else if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "WebSocketTLSselfSigned") == true) - { - TextBoxTransmissionXray.Text = "ws"; - TextBoxCamouflageTypeXray.Text = "none"; - //TLS的Host /Quic 加密方式 - TextBoxHostQuicEncryptionXray.Text = MainWindow.ReceiveConfigurationParameters[4]; - TextBoxTLSXray.Text = "tls"; - ShowHostNameXray(); - ShowPathXray(); - } - else if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "Http2") == true) - { - TextBoxEncryptionXray.Text = "none"; - TextBoxTransmissionXray.Text = "h2"; - TextBoxCamouflageTypeXray.Text = "none"; - //TLS的Host /Quic 加密方式 - TextBoxHostQuicEncryptionXray.Text = MainWindow.ReceiveConfigurationParameters[4]; - TextBoxTLSXray.Text = "tls"; - ShowHostNameXray(); - ShowPathXray(); - } - else if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "http2Web") == true) - { - TextBoxEncryptionXray.Text = "none"; - TextBoxTransmissionXray.Text = "h2"; - TextBoxCamouflageTypeXray.Text = "none"; - TextBoxHostQuicEncryptionXray.Text = MainWindow.ReceiveConfigurationParameters[4];//获取Host - TextBoxTLSXray.Text = "tls"; - ShowHostNameXray(); - ShowPathXray(); - } - else if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "http2selfSigned") == true) - { - TextBoxTransmissionXray.Text = "h2"; - TextBoxCamouflageTypeXray.Text = "none"; - //TLS的Host /Quic 加密方式 - TextBoxHostQuicEncryptionXray.Text = MainWindow.ReceiveConfigurationParameters[4]; - TextBoxTLSXray.Text = "tls"; - ShowHostNameXray(); - ShowPathXray(); - } - else if (MainWindow.ReceiveConfigurationParameters[0].Contains("mKCP") == true) - { - if (MainWindow.mKCPvlessIsSet == true) - { - TextBlockVmessOrVlessXray.Text = Application.Current.FindResource("TabItemHeaderV2RayVlessProtocol").ToString(); - TextBoxEncryptionXray.Text = "none"; - HideAlterIdXray(); - HideGroupBoxClientQRandURL(); - } - if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "mKCPNone") == true) - { - TextBoxCamouflageTypeXray.Text = "none"; - } - else if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "mKCP2SRTP") == true) - { - TextBoxCamouflageTypeXray.Text = "srtp"; - } - else if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "mKCPuTP") == true) - { - TextBoxCamouflageTypeXray.Text = "utp"; - } - else if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "mKCP2WechatVideo") == true) - { - TextBoxCamouflageTypeXray.Text = "wechat-video"; - } - else if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "mKCP2DTLS") == true) - { - TextBoxCamouflageTypeXray.Text = "dtls"; - } - else if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "mKCP2WireGuard") == true) - { - TextBoxCamouflageTypeXray.Text = "wireguard"; - } - - TextBoxTransmissionXray.Text = "kcp"; - TextBoxQuicKeyMkcpSeedPathXray.Text = MainWindow.ReceiveConfigurationParameters[6];//获取mkcp Seed - TextBoxTLSXray.Text = "none"; - ShowHostNameXray(); - ShowMkcpSeedXray(); - } - else if (MainWindow.ReceiveConfigurationParameters[0].Contains("Quic") == true) - { - if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "QuicNone") == true) - { - TextBoxCamouflageTypeXray.Text = "none"; - - } - else if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "QuicSRTP") == true) - { - TextBoxCamouflageTypeXray.Text = "srtp"; - } - else if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "Quic2uTP") == true) - { - TextBoxCamouflageTypeXray.Text = "utp"; - } - else if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "QuicWechatVideo") == true) - { - TextBoxCamouflageTypeXray.Text = "wechat-video"; - } - else if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "QuicDTLS") == true) - { - TextBoxCamouflageTypeXray.Text = "dtls"; - } - else if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "QuicWireGuard") == true) - { - TextBoxCamouflageTypeXray.Text = "wireguard"; - } - - TextBoxTransmissionXray.Text = "quic"; - TextBoxHostQuicEncryptionXray.Text = MainWindow.ReceiveConfigurationParameters[3];//获取Quic加密方式 - TextBoxQuicKeyMkcpSeedPathXray.Text = MainWindow.ReceiveConfigurationParameters[6];//获取Quic加密密钥 - TextBoxTLSXray.Text = "none"; - ShowQuicEncryptionXray(); - ShowQuicKeyXray(); - } - - else - { - TextBoxTransmissionXray.Text = "tcp"; - TextBoxCamouflageTypeXray.Text = "none"; - TextBoxTLSXray.Text = "none"; - ShowHostNameXray(); - ShowPathXray(); - } - CheckDir("xray_config"); - - GenerateXrayShareQRcodeAndBase64Url(); - #endregion - } - else - { - //显示多方案客户端选择面板 - GroupBoxSelectVlessVmessXtlsTcpWsXray.Visibility = Visibility.Visible; - - string proxyfolder = CheckDir("xray_config"); - configDomainSavePath = CreateConfigSaveDir(proxyfolder, TextBoxHostAddressXray.Text); - - XraySetVlessTcpXtls(); - GenerateXrayVlessTcpXtlsShareQRcodeAndBase64Url(); - - XraySetVlessTcpTls(); - GenerateXrayVlessTcpTlsShareQRcodeAndBase64Url(); - - XraySetVlessWsTls(); - GenerateXrayVlessWsTlsShareQRcodeAndBase64Url(); - - XraySetVmessTcpTls(); - GenerateXrayVmessTcpTlsShareQRcodeAndBase64Url(); - - XraySetVmessWsTls(); - GenerateXrayVmessWsTlsShareQRcodeAndBase64Url(); - - GenerateXrayTrojanShareQRcodeAndBase64Url(); - RadioButtonVlessTcpXtlsXray.IsChecked = true; - } - - } - else if (String.Equals(MainWindow.proxyType, "TrojanGo")) - { - //GroupBoxTrojanClient.Header = "Trojan-go 客户端配置参数"; - GroupBoxClientMTProto.Visibility = Visibility.Collapsed; - GroupBoxClientQRandURL.Visibility = Visibility.Visible; - GroupBoxClientSSpc.Visibility = Visibility.Collapsed; - GroupBoxV2rayClient.Visibility = Visibility.Collapsed; - GroupBoxXrayClient.Visibility = Visibility.Collapsed; - GroupBoxTrojanGoClient.Visibility = Visibility.Visible; - GroupBoxTrojanClient.Visibility = Visibility.Collapsed; - GroupBoxNaiveProxyClient.Visibility = Visibility.Collapsed; - GroupBoxSSRClient.Visibility = Visibility.Collapsed; - GroupBoxClientSS.Visibility = Visibility.Collapsed; - - TextBlockTrojanGoHost.Visibility = Visibility.Hidden; - TextBoxTrojanGoHost.Visibility = Visibility.Hidden; - TextBoxTrojanGoWSPath.Visibility = Visibility.Hidden; - TextBlockTrojanGoWebSocketPath.Visibility = Visibility.Hidden; - TextBlockTrojanGoCaption.Visibility = Visibility.Hidden; - - TextBlockMuxSelect.Visibility = Visibility.Hidden; - GridMuxSelect.Visibility = Visibility.Hidden; - TextBlockExplainCheckBoxMuxSelectResult.Visibility = Visibility.Hidden; - - //******"可用于ShadowRocket (ios)、igniter(Android)、Qv2ray (windows) 扫码和导入url。注意:有的客户端可能不支持WebSocket模式。" ****** - TextBlockQrURLexplain.Text = Application.Current.FindResource("TextBlockQrURLexplainTrojan-go").ToString(); - - //主机地址 - TextBoxTrojanGoServerHost.Text = MainWindow.ReceiveConfigurationParameters[4]; - //主机端口 - TextBoxTrojanGoServerPort.Text = "443"; - //密钥(uuid) - TextBoxTrojanGoServerPassword.Text = MainWindow.ReceiveConfigurationParameters[2]; - //SNI - TextBoxTrojanGoSNI.Text = MainWindow.ReceiveConfigurationParameters[4]; - //TrojanGo 使用类型 - TextBoxTrojanGoType.Text = "original"; - - //WebSocket设置 - if (MainWindow.ReceiveConfigurationParameters[0].Equals("TrojanGoWebSocketTLS2Web")) - { - TextBoxTrojanGoType.Text = "ws"; - //Host - TextBoxTrojanGoHost.Text = MainWindow.ReceiveConfigurationParameters[4]; - TextBlockTrojanGoHost.Visibility = Visibility.Visible; - TextBoxTrojanGoHost.Visibility = Visibility.Visible; - //Path - TextBoxTrojanGoWSPath.Text = MainWindow.ReceiveConfigurationParameters[6]; - TextBoxTrojanGoWSPath.Visibility = Visibility.Visible; - TextBlockTrojanGoWebSocketPath.Visibility = Visibility.Visible; - TextBlockTrojanGoCaption.Visibility = Visibility.Visible; - - } - if(String.Equals(MainWindow.ReceiveConfigurationParameters[9],"true") == true) - { - TextBoxConcurrency.Text = MainWindow.ReceiveConfigurationParameters[3]; - TextBoxIdle_timeout.Text = MainWindow.ReceiveConfigurationParameters[5]; - TextBlockMuxSelect.Visibility = Visibility.Visible; - GridMuxSelect.Visibility = Visibility.Visible; - TextBlockExplainCheckBoxMuxSelectResult.Visibility = Visibility.Visible; - } - CheckDir("trojan-go_config"); - GenerateTrojanGoShareQRcodeAndBase64Url(); - } - else if (String.Equals(MainWindow.proxyType, "Trojan")) - { - GroupBoxClientMTProto.Visibility = Visibility.Collapsed; - GroupBoxClientQRandURL.Visibility = Visibility.Visible; - GroupBoxClientSSpc.Visibility = Visibility.Collapsed; - GroupBoxV2rayClient.Visibility = Visibility.Collapsed; - GroupBoxXrayClient.Visibility = Visibility.Collapsed; - GroupBoxTrojanGoClient.Visibility = Visibility.Collapsed; - GroupBoxTrojanClient.Visibility = Visibility.Visible; - GroupBoxNaiveProxyClient.Visibility = Visibility.Collapsed; - GroupBoxSSRClient.Visibility = Visibility.Collapsed; - GroupBoxClientSS.Visibility = Visibility.Collapsed; - - TextBlockQrURLexplain.Text = Application.Current.FindResource("TextBlockQrURLexplainTrojan").ToString(); - - //主机地址 - TextBoxTrojanServerHost.Text = MainWindow.ReceiveConfigurationParameters[4]; - //主机端口 - TextBoxTrojanServerPort.Text = "443"; - //密钥(uuid) - TextBoxTrojanServerPassword.Text = MainWindow.ReceiveConfigurationParameters[2]; - - CheckDir("trojan_config"); - GenerateTrojanShareQRcodeAndBase64Url(); - } - else if (String.Equals(MainWindow.proxyType, "NaiveProxy")) - { - GroupBoxClientMTProto.Visibility = Visibility.Collapsed; - GroupBoxClientQRandURL.Visibility = Visibility.Visible; - GroupBoxClientSSpc.Visibility = Visibility.Collapsed; - GroupBoxV2rayClient.Visibility = Visibility.Collapsed; - GroupBoxXrayClient.Visibility = Visibility.Collapsed; - GroupBoxTrojanGoClient.Visibility = Visibility.Collapsed; - GroupBoxTrojanClient.Visibility = Visibility.Collapsed; - GroupBoxNaiveProxyClient.Visibility = Visibility.Visible; - GroupBoxSSRClient.Visibility = Visibility.Collapsed; - GroupBoxClientSS.Visibility = Visibility.Collapsed; - - TextBlockQrURLexplain.Text = Application.Current.FindResource("TextBlockQrURLexplainNaiveProxy").ToString(); - - TextBoxNaiveServerHost.Text = MainWindow.ReceiveConfigurationParameters[4]; - TextBoxNaiveUser.Text = MainWindow.ReceiveConfigurationParameters[3]; - TextBoxNaivePassword.Text = MainWindow.ReceiveConfigurationParameters[2]; - GenerateNaivePrxoyShareQRcodeAndBase64Url(); - } - else if (String.Equals(MainWindow.proxyType, "SSR")) - { - GroupBoxClientMTProto.Visibility = Visibility.Collapsed; - GroupBoxClientQRandURL.Visibility = Visibility.Visible; - GroupBoxClientSSpc.Visibility = Visibility.Collapsed; - GroupBoxV2rayClient.Visibility = Visibility.Collapsed; - GroupBoxXrayClient.Visibility = Visibility.Collapsed; - GroupBoxTrojanGoClient.Visibility = Visibility.Collapsed; - GroupBoxTrojanClient.Visibility = Visibility.Collapsed; - GroupBoxNaiveProxyClient.Visibility = Visibility.Collapsed; - GroupBoxSSRClient.Visibility = Visibility.Visible; - GroupBoxClientSS.Visibility = Visibility.Collapsed; - - TextBlockQrURLexplain.Text = Application.Current.FindResource("TextBlockQrURLexplainSSR").ToString(); - - //主机地址 - TextBoxSSRHostAddress.Text = MainWindow.ReceiveConfigurationParameters[4]; - //主机端口 - TextBoxSSRPort.Text = "443"; - //密码(uuid) - TextBoxSSRUUID.Text = MainWindow.ReceiveConfigurationParameters[2]; - //加密方式 - TextBoxSSREncryption.Text = "none"; - //传输协议 - TextBoxSSRTransmission.Text = "auth_chain_a"; - //混淆 - TextBoxSSRCamouflageType.Text = "tls1.2_ticket_auth"; - - //CheckDir("ssr_config"); - GenerateSSRShareQRcodeAndBase64Url(); - } - else if (String.Equals(MainWindow.proxyType, "SS")) - { - GroupBoxClientMTProto.Visibility = Visibility.Collapsed; - GroupBoxClientQRandURL.Visibility = Visibility.Visible; - GroupBoxClientSSpc.Visibility = Visibility.Collapsed; - GroupBoxV2rayClient.Visibility = Visibility.Collapsed; - GroupBoxXrayClient.Visibility = Visibility.Collapsed; - GroupBoxTrojanGoClient.Visibility = Visibility.Collapsed; - GroupBoxTrojanClient.Visibility = Visibility.Collapsed; - GroupBoxNaiveProxyClient.Visibility = Visibility.Collapsed; - GroupBoxSSRClient.Visibility = Visibility.Collapsed; - GroupBoxClientSS.Visibility = Visibility.Visible; - - //主机地址 - TextBoxHostAddressSS.Text = MainWindow.ReceiveConfigurationParameters[4]; - //主机端口 - TextBoxPortSS.Text = MainWindow.ReceiveConfigurationParameters[1]; - //密码(uuid) - TextBoxPasswordSS.Text = MainWindow.ReceiveConfigurationParameters[2]; - //加密方式 - TextBoxEncryptionSS.Text = MainWindow.ReceiveConfigurationParameters[3]; - //插件程序 - TextBoxPluginNameExplainSS.Text = MainWindow.ReceiveConfigurationParameters[5]; - //插件选项 - TextBoxPluginOptionExplainSS.Text = MainWindow.ReceiveConfigurationParameters[9]; - //创建ss配置文件总文件夹 - CheckDir("ss_config"); - - if (String.IsNullOrEmpty(TextBoxPluginNameExplainSS.Text) == true) - { - TextBlockPluginNameExplainSS.Visibility = Visibility.Collapsed; - TextBoxPluginNameExplainSS.Visibility = Visibility.Collapsed; - - //TextBoxPluginNameExplainSSpc.Visibility = Visibility.Collapsed; - TextBlockPluginOptionExplainSS.Visibility = Visibility.Collapsed; - TextBoxPluginOptionExplainSS.Visibility = Visibility.Collapsed; - - TextBlockClientPromptSS.Visibility = Visibility.Collapsed; - RadioButtonMobile.Visibility = Visibility.Collapsed; - RadioButtonPC.Visibility = Visibility.Collapsed; - TextBlockQrURLexplain.Text = Application.Current.FindResource("TextBlockQrURLexplainSS").ToString(); - } - else - { - //显示插件程序与插件选项 - TextBlockPluginNameExplainSS.Visibility = Visibility.Visible; - TextBoxPluginNameExplainSS.Visibility = Visibility.Visible; - - TextBlockPluginOptionExplainSS.Visibility = Visibility.Visible; - TextBoxPluginOptionExplainSS.Visibility = Visibility.Visible; - - TextBlockClientPromptSS.Visibility = Visibility.Visible; - RadioButtonMobile.Visibility = Visibility.Visible; - RadioButtonPC.Visibility = Visibility.Visible; - - TextBlockQrURLexplain.Text = Application.Current.FindResource("TextBlockQrURLexplainSSmobile").ToString(); - TextBlockQrURLexplainSSpc.Text = Application.Current.FindResource("TextBlockQrURLexplainSSpc").ToString(); - - //转换成PC版plugin格式 - if (String.Equals(TextBoxPluginNameExplainSS.Text, "obfs-local")) - { - TextBoxPluginNameExplainSSpc.Text = @"plugins\obfs-local.exe"; - } - else if (String.Equals(TextBoxPluginNameExplainSS.Text, "v2ray-plugin")) - { - TextBoxPluginNameExplainSSpc.Text = @"plugins\v2ray-plugin.exe"; - } - else if (String.Equals(TextBoxPluginNameExplainSS.Text, "kcptun")) - { - TextBoxPluginNameExplainSSpc.Text = @"plugins\kcptun-client.exe"; - } - else if (String.Equals(TextBoxPluginNameExplainSS.Text, "goquiet")) - { - TextBoxPluginNameExplainSSpc.Text = @"plugins\goquiet-client.exe"; - } - else if (String.Equals(TextBoxPluginNameExplainSS.Text, "cloak")) - { - TextBoxPluginNameExplainSSpc.Text = @"plugins\cloak-client.exe"; - } - } - - GenerateShareQRcodeAndBase64UrlSS(); - //选择手机端做为默认显示 - if (String.IsNullOrEmpty(TextBoxPluginNameExplainSS.Text) == false) - { - RadioButtonMobile.IsChecked = true; - if (String.Equals(TextBoxPluginNameExplainSS.Text, "goquiet")) - { - RadioButtonPC.IsChecked = true; - RadioButtonMobile.Visibility = Visibility.Collapsed; - TextBlockClientPromptSS.Visibility = Visibility.Collapsed; - //File.Delete($"ss_config\\{saveFileFolder}\\QR.bmp"); - //File.Delete($"ss_config\\{saveFileFolder}\\url.txt"); - } - else if (String.Equals(TextBoxPluginNameExplainSS.Text, "cloak")) - { - RadioButtonPC.IsChecked = true; - RadioButtonMobile.Visibility = Visibility.Collapsed; - TextBlockClientPromptSS.Visibility = Visibility.Collapsed; - //File.Delete($"ss_config\\{saveFileFolder}\\QR.bmp"); - //File.Delete($"ss_config\\{saveFileFolder}\\url.txt"); - } - - } - - } - else if (String.Equals(MainWindow.proxyType, "MTProto")) - { - //显示MTProto参数,隐藏其他 - GroupBoxClientMTProto.Visibility = Visibility.Visible; - GroupBoxClientQRandURL.Visibility = Visibility.Collapsed; - GroupBoxClientSSpc.Visibility = Visibility.Collapsed; - GroupBoxV2rayClient.Visibility = Visibility.Collapsed; - GroupBoxXrayClient.Visibility = Visibility.Collapsed; - GroupBoxTrojanGoClient.Visibility = Visibility.Collapsed; - GroupBoxTrojanClient.Visibility = Visibility.Collapsed; - GroupBoxNaiveProxyClient.Visibility = Visibility.Collapsed; - GroupBoxSSRClient.Visibility = Visibility.Collapsed; - GroupBoxClientSS.Visibility = Visibility.Collapsed; - - string proxyfolder = CheckDir("mtproto_config"); - configDomainSavePath = CreateConfigSaveDir(proxyfolder, MainWindow.ReceiveConfigurationParameters[4]); - string configSavePath = configDomainSavePath; - - RadioButtonMtgIpv4.IsChecked = true; - - JObject jObjectJson = JObject.Parse(MainWindow.ReceiveConfigurationParameters[9]); - - if (jObjectJson["ipv6"]["tg_url"].ToString().Contains("nil") == false) - { - RadioButtonMtgIpv6.Visibility = Visibility.Visible; - TextBoxURLMtgTgIpv6.Text = jObjectJson["ipv6"]["tg_url"].ToString(); - ImageShareQRcodeMtgTgIpv6.Source = CreateQRCode(TextBoxURLMtgTgIpv6.Text, $"{configSavePath}\\QRIpv6Tg.bmp"); - using (StreamWriter sw = new StreamWriter($"{configSavePath}\\urlIpv6Tg.txt")) - { - sw.WriteLine(TextBoxURLMtgTgIpv6.Text); - } - - TextBoxURLMtgTmeIpv6.Text = jObjectJson["ipv6"]["tme_url"].ToString(); - ImageShareQRcodeMtgTmeIpv6.Source = CreateQRCode(TextBoxURLMtgTmeIpv6.Text, $"{configSavePath}\\QRIpv6Tme.bmp"); - using (StreamWriter sw = new StreamWriter($"{configSavePath}\\urlIpv6Tme.txt")) - { - sw.WriteLine(TextBoxURLMtgTmeIpv6.Text); - } - RadioButtonMtgIpv6.IsChecked = true; - } - else - { - RadioButtonMtgIpv6.Visibility = Visibility.Collapsed; - } - - if (jObjectJson["ipv4"]["tg_url"].ToString().Contains("nil") == false) - { - RadioButtonMtgIpv4.Visibility = Visibility.Visible; - TextBoxURLMtgTgIpv4.Text = jObjectJson["ipv4"]["tg_url"].ToString(); - ImageShareQRcodeMtgTgIpv4.Source = CreateQRCode(TextBoxURLMtgTgIpv4.Text, $"{configSavePath}\\QRIpv4Tg.bmp"); - using (StreamWriter sw = new StreamWriter($"{configSavePath}\\urlIpv4Tg.txt")) - { - sw.WriteLine(TextBoxURLMtgTgIpv4.Text); - } - - TextBoxURLMtgTmeIpv4.Text = jObjectJson["ipv4"]["tme_url"].ToString(); - ImageShareQRcodeMtgTmeIpv4.Source = CreateQRCode(TextBoxURLMtgTmeIpv4.Text, $"{configSavePath}\\QRIpv4Tme.bmp"); - using (StreamWriter sw = new StreamWriter($"{configSavePath}\\urlIpv4Tme.txt")) - { - sw.WriteLine(TextBoxURLMtgTmeIpv4.Text); - } - RadioButtonMtgIpv4.IsChecked = true; - } - else - { - RadioButtonMtgIpv4.Visibility = Visibility.Collapsed; - } - - using (StreamWriter sw = new StreamWriter($"{configSavePath}\\mtproto_info.json")) - { - sw.Write(MainWindow.ReceiveConfigurationParameters[9].ToString()); - } - - } - } - - #region V2Ray 相关 - - #region V2ray参数设置函数 - - //设置VLESS over TCP with XTLS - private void V2raySetVlessTcpXtls() - { - GridNotTrojanParameters.Visibility = Visibility.Visible; - TextBlockVmessOrVless.Text = Application.Current.FindResource("TabItemHeaderV2RayVlessProtocol").ToString(); - TextBlockVmessOrVless.Visibility = Visibility.Visible; - //隐藏下面的二维码显示 - HideGroupBoxClientQRandURL(); - //ImageShareQRcode.Source = ImageShareQRcodeDefault; - //TextBoxURL.Text = TextBoxURLDefault; - - TextBoxEncryption.Text = "none"; - TextBoxTransmission.Text = "tcp"; - TextBoxCamouflageType.Text = "none"; - //TLS的Host /Quic 加密方式 - TextBoxHostQuicEncryption.Text = MainWindow.ReceiveConfigurationParameters[4]; - TextBoxTLS.Text = "xtls"; - HideAlterId(); - ShowHostName(); - ShowPathV2ray(); - TextBoxQuicKeyMkcpSeedPath.Text = ""; - - - } - - //设置VLESS over TCP with TLS - private void V2raySetVlessTcpTls() - { - GridNotTrojanParameters.Visibility = Visibility.Visible; - TextBlockVmessOrVless.Text = Application.Current.FindResource("TabItemHeaderV2RayVlessProtocol").ToString(); - TextBlockVmessOrVless.Visibility = Visibility.Visible; - //隐藏下面的二维码显示 - HideGroupBoxClientQRandURL(); - //TextBoxURL.Text = TextBoxURLVlessTcp; - //ImageShareQRcode.Source = ImageShareQRcodeVlessTcp; - - TextBoxEncryption.Text = "none"; - TextBoxTransmission.Text = "tcp"; - TextBoxCamouflageType.Text = "none"; - //TLS的Host /Quic 加密方式 - TextBoxHostQuicEncryption.Text = MainWindow.ReceiveConfigurationParameters[4]; - TextBoxTLS.Text = "tls"; - HideAlterId(); - ShowHostName(); - ShowPathV2ray(); - TextBoxQuicKeyMkcpSeedPath.Text = ""; - } - - //设置VLESS over WS with TLS - private void V2raySetVlessWsTls() - { - GridNotTrojanParameters.Visibility = Visibility.Visible; - TextBlockVmessOrVless.Text = Application.Current.FindResource("TabItemHeaderV2RayVlessProtocol").ToString(); - TextBlockVmessOrVless.Visibility = Visibility.Visible; - //隐藏下面的二维码显示 - HideGroupBoxClientQRandURL(); - //TextBoxURL.Text = TextBoxURLVlessWs; - //ImageShareQRcode.Source = ImageShareQRcodeVlessWs; - - TextBoxEncryption.Text = "none"; - TextBoxTransmission.Text = "ws"; - TextBoxCamouflageType.Text = "none"; - //TLS的Host /Quic 加密方式 - TextBoxHostQuicEncryption.Text = MainWindow.ReceiveConfigurationParameters[4]; - TextBoxTLS.Text = "tls"; - HideAlterId(); - ShowHostName(); - ShowPathV2ray(); - TextBoxQuicKeyMkcpSeedPath.Text = MainWindow.ReceiveConfigurationParameters[3]; - - } - - //设置VMess over TCP with TLS - private void V2raySetVmessTcpTls() - { - GridNotTrojanParameters.Visibility = Visibility.Visible; - TextBoxEncryption.Text = "none"; - TextBoxTransmission.Text = "tcp"; - TextBoxCamouflageType.Text = "http"; - //TLS的Host /Quic 加密方式 - TextBoxHostQuicEncryption.Text = MainWindow.ReceiveConfigurationParameters[4]; - TextBoxTLS.Text = "tls"; - ShowAlterId(); - ShowHostName(); - ShowPathV2ray(); - TextBoxQuicKeyMkcpSeedPath.Text = MainWindow.ReceiveConfigurationParameters[9]; - TextBlockVmessOrVless.Visibility = Visibility.Collapsed; - //显示下面的二维码显示。 - //HideGroupBoxClientQRandURL(); - ShowGroupBoxClientQRandURL(); - TextBoxURL.Text = TextBoxURLVmessTcp; - ImageShareQRcode.Source = ImageShareQRcodeVmessTcp; - } - - //设置VMess over WS with TLS - private void V2raySetVmessWsTls() - { - GridNotTrojanParameters.Visibility = Visibility.Visible; - TextBoxEncryption.Text = "none"; - TextBoxTransmission.Text = "ws"; - TextBoxCamouflageType.Text = "none"; - //TLS的Host /Quic 加密方式 - TextBoxHostQuicEncryption.Text = MainWindow.ReceiveConfigurationParameters[4]; - TextBoxTLS.Text = "tls"; - ShowAlterId(); - ShowHostName(); - ShowPathV2ray(); - TextBoxQuicKeyMkcpSeedPath.Text = MainWindow.ReceiveConfigurationParameters[6]; - TextBlockVmessOrVless.Visibility = Visibility.Collapsed; - ShowGroupBoxClientQRandURL(); - TextBoxURL.Text = TextBoxURLVmessWs; - ImageShareQRcode.Source = ImageShareQRcodeVmessWs; - } - - //设置Trojan over TCP with TLS - private void V2raySetTrojanTcpTls() - { - //隐藏所有不是Trojan的参数 - GridNotTrojanParameters.Visibility = Visibility.Collapsed; - //显示下面的二维码与分享链接 - ShowGroupBoxClientQRandURL(); - TextBoxURL.Text = TextBoxURLTrojanTcp; - ImageShareQRcode.Source = ImageShareQRcodeTrojanTcp; - } - #endregion - - #region 界面控制相关 - - //显示Quic 加密方式 - private void ShowQuicEncryption() - { - TextBlockQuicEncryption.Visibility = Visibility.Visible; - TextBlockHost.Visibility = Visibility.Collapsed; - } - - //显示Host隐藏Quic加密方式 - private void ShowHostName() - { - TextBlockHost.Visibility = Visibility.Visible; - TextBlockQuicEncryption.Visibility = Visibility.Collapsed; - } - - //显示路径Path,隐藏mKCP/Quic Key/复制按钮 - private void ShowPathV2ray() - { - TextBlockPath.Visibility = Visibility.Visible; - TextBlockMkcpSeed.Visibility = Visibility.Collapsed; - TextBlockQuicKey.Visibility = Visibility.Collapsed; - } - - //显示mKCP Seed/复制按钮,隐藏Path/Quic Key - private void ShowMkcpSeed() - { - TextBlockPath.Visibility = Visibility.Collapsed; - TextBlockMkcpSeed.Visibility = Visibility.Visible; - TextBlockQuicKey.Visibility = Visibility.Collapsed; - } - - //显示Quic Key/复制按钮 隐藏Path/mKcp Seed - private void ShowQuicKey() - { - TextBlockPath.Visibility = Visibility.Collapsed; - TextBlockMkcpSeed.Visibility = Visibility.Collapsed; - TextBlockQuicKey.Visibility = Visibility.Visible; - } - - //显示额外ID - private void ShowAlterId() - { - TextBlockUUIDextra.Visibility = Visibility.Visible; - TextBoxUUIDextra.Visibility = Visibility.Visible; - TextBlockUUIDextraExplanation.Visibility = Visibility.Visible; - - } - - //隐藏额外ID - private void HideAlterId() - { - TextBlockUUIDextra.Visibility = Visibility.Collapsed; - TextBoxUUIDextra.Visibility = Visibility.Collapsed; - TextBlockUUIDextraExplanation.Visibility = Visibility.Collapsed; - - } - - //显示加密方式 - private void ShowEncryption() - { - TextBlockEncryption.Visibility = Visibility.Visible; - TextBoxEncryption.Visibility = Visibility.Visible; - } - //隐藏加密方式 - private void HideEncryption() - { - TextBlockEncryption.Visibility = Visibility.Collapsed; - TextBoxEncryption.Visibility = Visibility.Collapsed; - } - - //显示传输协议 - private void ShowTransferProtocol() - { - TextBlockTransferProtocol.Visibility = Visibility.Visible; - TextBoxTransmission.Visibility = Visibility.Visible; - } - //隐藏传输协议 - private void HideTransferProtocol() - { - TextBlockTransferProtocol.Visibility = Visibility.Collapsed; - TextBoxTransmission.Visibility = Visibility.Collapsed; - } - //显示伪装类型 - private void ShowTextBlockCamouflageType() - { - TextBlockCamouflageType.Visibility = Visibility.Visible; - TextBoxCamouflageType.Visibility = Visibility.Visible; - } - //隐藏伪装类型 - private void HideTextBlockCamouflageType() - { - TextBlockCamouflageType.Visibility = Visibility.Collapsed; - TextBoxCamouflageType.Visibility = Visibility.Collapsed; - } - - //显示二维码与链接分享 - private void ShowGroupBoxClientQRandURL() - { - GroupBoxClientQRandURL.Visibility = Visibility.Visible; - } - //隐藏二维码与链接分享 - private void HideGroupBoxClientQRandURL() - { - GroupBoxClientQRandURL.Visibility = Visibility.Hidden; - } - - //以下几个为对RadioButton按钮的选中后,界面变化与参数显示 - private void RadioButtonVlessTcpXtls_Checked(object sender, RoutedEventArgs e) - { - V2raySetVlessTcpXtls(); - } - - private void RadioButtonVlessTcpTls_Checked(object sender, RoutedEventArgs e) - { - V2raySetVlessTcpTls(); - } - - private void RadioButtonVlessWsTls_Checked(object sender, RoutedEventArgs e) - { - V2raySetVlessWsTls(); - } - - private void RadioButtonVmessTcpTls_Checked(object sender, RoutedEventArgs e) - { - V2raySetVmessTcpTls(); - } - - private void RadioButtonVmessWsTls_Checked(object sender, RoutedEventArgs e) - { - V2raySetVmessWsTls(); - } - - private void RadioButtonTrojanTcpTls_Checked(object sender, RoutedEventArgs e) - { - V2raySetTrojanTcpTls(); - } - #endregion - - #region 复制参数到剪贴板中 - - //复制内容到剪贴板函数 - private void CopyToClipboard(string content) - { - if (content != "") - { - Clipboard.SetDataObject(content); - //MessageBox.Show(Application.Current.FindResource("MessageBoxShow_V2RayUUIDcopyedToClip").ToString()); - string message = Application.Current.FindResource("MessageBoxShow_V2RayUUIDcopyedToClip").ToString(); - MessageBoxTimeoutA((IntPtr)0, message, "", 0, 0, 600); // 直接调用 0.6秒后自动关闭 - } - else - { - //MessageBox.Show(Application.Current.FindResource("MessageBoxShow_V2RayEmptyToClip").ToString()); - string message = Application.Current.FindResource("MessageBoxShow_V2RayEmptyToClip").ToString(); - MessageBoxTimeoutA((IntPtr)0, message, "", 0, 0, 600); // 直接调用 0.6秒后自动关闭 - } - } - - //复制服务器地址到剪贴板 - private void TextBoxHostAddress_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxHostAddress.Text); - } - - - //复制服务器端口到剪贴板 - private void TextBoxPort_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxPort.Text); - } - - //复制UUID到剪贴板 - private void TextBoxUUID_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxUUID.Text); - } - - //复制额外ID到剪贴板 - private void TextBoxUUIDextra_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxUUIDextra.Text); - } - - //复制加密方式到剪贴板 - private void TextBoxEncryption_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxEncryption.Text); - } - - //复制传输协议到剪贴板 - private void TextBoxTransmission_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxTransmission.Text); - } - - //复制伪装方式到剪贴板 - private void TextBoxCamouflageType_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxCamouflageType.Text); - } - - //复制Host/Quic加密方法到剪贴板 - private void TextBoxHostQuicEncryption_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxHostQuicEncryption.Text); - } - - //复制Quic Key/mKCP Seed/路径Path 到剪贴板中 - private void TextBoxQuicKeyMkcpSeedPath_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxQuicKeyMkcpSeedPath.Text); - } - - //复制TLS 到剪贴板中 - private void TextBoxTLS_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxTLS.Text); - } - - //复制URL链接到剪贴板中 - private void TextBoxURL_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxURL.Text); - } - - #endregion - - #region V2Ray客户端生成 - //生成单方案v2rayN客户端导入文件 - private void GenerateV2rayShareQRcodeAndBase64Url() - { - //生成v2rayN的json文件 - string v2rayNjsonFile = @" -{ - ""v"": """", - ""ps"": """", - ""add"": """", - ""port"": """", - ""id"": """", - ""aid"": """", - ""net"": """", - ""type"": """", - ""host"": """", - ""path"": """", - ""tls"": """" -}"; - //MessageBox.Show(v2rayNjsonFile); - JObject v2rayNjsonObject = JObject.Parse(v2rayNjsonFile); - v2rayNjsonObject["v"] = "2"; - v2rayNjsonObject["add"] = TextBoxHostAddress.Text; //设置域名 - v2rayNjsonObject["port"] = TextBoxPort.Text; //设置端口 - v2rayNjsonObject["id"] = TextBoxUUID.Text; //设置uuid - v2rayNjsonObject["aid"] = TextBoxUUIDextra.Text; //设置额外ID - v2rayNjsonObject["net"] = TextBoxTransmission.Text; //设置传输模式 - v2rayNjsonObject["type"] = TextBoxCamouflageType.Text; //设置伪装类型 - - if (TextBoxTransmission.Text.Contains("kcp") == true) - { - v2rayNjsonObject["path"] = TextBoxQuicKeyMkcpSeedPath.Text;//设置mKCP Seed - v2rayNjsonObject["host"] = "";//设置Host - } - else if (TextBoxTransmission.Text.Contains("quic")==true) - { - v2rayNjsonObject["path"] = TextBoxQuicKeyMkcpSeedPath.Text;//设置quic密钥 - v2rayNjsonObject["host"] = TextBoxHostQuicEncryption.Text;//Quic加密方式 - } - else - { - v2rayNjsonObject["path"] = TextBoxQuicKeyMkcpSeedPath.Text; //设置路径 - v2rayNjsonObject["host"] = TextBoxHostQuicEncryption.Text;//设置TLS的Host - } - - v2rayNjsonObject["tls"] = TextBoxTLS.Text; //设置是否启用TLS - v2rayNjsonObject["ps"] = v2rayNjsonObject["add"]; //设置备注 - //MessageBox.Show(v2rayNjsonObject["v"].ToString()); - //MessageBox.Show("step1"); - string proxyfolder = CheckDir("v2ray_config"); - //MessageBox.Show("step2"); - configDomainSavePath = CreateConfigSaveDir(proxyfolder, TextBoxHostAddress.Text); - //MessageBox.Show("step3"); - string configSavePath = configDomainSavePath; - - //生成二维码与URL,跳过VlessTcpTlsWeb暂时未有URL标准 - string vmessUrl = "vmess://" + ToBase64Encode(v2rayNjsonObject.ToString()); - TextBoxURL.Text = vmessUrl; - if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "VlessXtlsTcp") == false - && String.Equals(MainWindow.ReceiveConfigurationParameters[0], "VlessTcpTlsWeb") == false - && String.Equals(MainWindow.ReceiveConfigurationParameters[0], "VlessWebSocketTlsWeb") == false - && String.Equals(MainWindow.ReceiveConfigurationParameters[0], "VlessHttp2Web") == false - && MainWindow.mKCPvlessIsSet == false) - { - using (StreamWriter sw = new StreamWriter($"{configSavePath}\\url.txt")) - { - sw.WriteLine(vmessUrl); - } - ImageShareQRcode.Source = CreateQRCode(vmessUrl, $"{configSavePath}\\QR.bmp"); - } - - if (File.Exists(@"v2ray_config\config.json")) - { - File.Move(@"v2ray_config\config.json", $"{configSavePath}\\config.json"); - //File.Delete(@"config\config.json");//删除该文件 - } - - using (StreamWriter sw = new StreamWriter($"{configSavePath}\\readme.txt")) - { - ReadmeTxtWriteGenerate(sw); - //sw.WriteLine("config.json"); - ////****** "此文件为v2ray官方程序所使用的客户端配置文件,配置为全局模式,socks5地址:127.0.0.1:1080,http代理地址:127.0.0.1:1081" ****** - //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine01").ToString()); - - ////****** "v2ray官方网站:https://www.v2ray.com/" ****** - //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine02").ToString()); - - ////****** "v2ray官方程序下载地址:https://github.com/v2ray/v2ray-core/releases" ****** - //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine03").ToString()); - - ////****** "下载相应版本,Windows选择v2ray-windows-64.zip或者v2ray-windows-32.zip,解压后提取v2ctl.exe和v2ray.exe。与config.json放在同一目录,运行v2ray.exe即可。" ****** - //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine04").ToString()); - - //sw.WriteLine("-----------------------------------------"); - //sw.WriteLine("QR.bmp"); - - ////****** "此文件为v2rayN(windows)、Qv2ray(windows)、v2rayNG(Android)、Shadowrocket(ios)扫码导入节点" ****** - //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine05").ToString()); - - ////****** "v2rayN下载网址:https://github.com/2dust/v2rayN/releases" ****** - //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine06").ToString()); - - ////****** "Qv2ray下载网址:https://github.com/Qv2ray/Qv2ray/releases" ****** - //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine07").ToString()); - - ////****** "v2rayNG(Android)下载网址:https://github.com/2dust/v2rayNG/releases" ****** - //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine08").ToString()); - - ////****** "v2rayNG(Android)在Google Play下载网址:https://play.google.com/store/apps/details?id=com.v2ray.ang" ****** - //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine09").ToString()); - - ////****** "Shadowrocket(ios)下载,需要使用国外区的AppleID。请自行谷歌方法。" ****** - //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine10").ToString()); - - //sw.WriteLine("-----------------------------------------"); - //sw.WriteLine("url.txt"); - - ////****** "此文件为v2rayN、Qv2ray、v2rayNG(Android)、Shadowrocket(ios)复制粘贴导入节点的vmess网址" ****** - //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine11").ToString()); - - ////写入通用配置参数 - //TxtWriteGeneralParameters(sw); - } - } - - #region VLESS VMESS XTLS WS共存方案生成链接与说明文件 - - //生成VLESS Vmess Tcp Xtls Ws 配置保存(暂未有分享链接与二维码) - private void GenerateV2rayVlessVmessTcpXtlsWsShareQRcodeAndBase64Url(string plainSavePath) - { - #region 暂时不用内容 - // //生成v2rayN的json文件 - // string v2rayNjsonFile = @" - //{ - // ""v"": """", - // ""ps"": """", - // ""add"": """", - // ""port"": """", - // ""id"": """", - // ""aid"": """", - // ""net"": """", - // ""type"": """", - // ""host"": """", - // ""path"": """", - // ""tls"": """" - //}"; - // //MessageBox.Show(v2rayNjsonFile); - // JObject v2rayNjsonObject = JObject.Parse(v2rayNjsonFile); - // v2rayNjsonObject["v"] = "2"; - // v2rayNjsonObject["add"] = TextBoxHostAddress.Text; //设置域名 - // v2rayNjsonObject["port"] = TextBoxPort.Text; //设置端口 - // v2rayNjsonObject["id"] = TextBoxUUID.Text; //设置uuid - // v2rayNjsonObject["aid"] = TextBoxUUIDextra.Text; //设置额外ID - // v2rayNjsonObject["net"] = TextBoxTransmission.Text; //设置传输模式 - // v2rayNjsonObject["type"] = TextBoxCamouflageType.Text; //设置伪装类型 - - // if (TextBoxTransmission.Text.Contains("kcp") == true) - // { - // v2rayNjsonObject["path"] = TextBoxQuicKeyMkcpSeedPath.Text;//设置mKCP Seed - // } - // else if (TextBoxTransmission.Text.Contains("quic") == true) - // { - // v2rayNjsonObject["path"] = TextBoxQuicKeyMkcpSeedPath.Text;//设置quic密钥 - // v2rayNjsonObject["host"] = TextBoxHostQuicEncryption.Text;//Quic加密方式 - // } - // else - // { - // v2rayNjsonObject["path"] = TextBoxQuicKeyMkcpSeedPath.Text; //设置路径 - // v2rayNjsonObject["host"] = TextBoxHostQuicEncryption.Text;//设置TLS的Host - // } - - // v2rayNjsonObject["tls"] = TextBoxTLS.Text; //设置是否启用TLS - // v2rayNjsonObject["ps"] = v2rayNjsonObject["add"]; //设置备注 - // //MessageBox.Show(v2rayNjsonObject["v"].ToString()); - - //string saveFileFolderFirst = TextBoxHostAddress.Text; - //int num = 1; - //saveFileFolder = saveFileFolderFirst; - //CheckDir(@"v2ray_config"); - //while (Directory.Exists(@"v2ray_config\" + saveFileFolder)) - //{ - // saveFileFolder = saveFileFolderFirst + "_copy_" + num.ToString(); - // num++; - //} - //CheckDir(@"v2ray_config\" + saveFileFolder); - - #endregion - - //创建保存目录 - //string plainSavePath = @""; - - //v2ray_config\${域名IP}\vless_tcp_xtls_client_config - string configSavePath = CheckDir($"{configDomainSavePath}\\{plainSavePath}"); - - - //生成二维码与URL,跳过VlessTcpTlsWeb暂时未有URL标准 - //string vmessUrl = "vmess://" + ToBase64Encode(v2rayNjsonObject.ToString()); - //TextBoxURL.Text = vmessUrl; - //using (StreamWriter sw = new StreamWriter($"{configSavePath}\\url.txt")) - //{ - // if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "VlessTcpTlsWeb") == false) - // { - // sw.WriteLine(vmessUrl); - // } - //} - //if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "VlessTcpTlsWeb") == false) - //{ - // ImageShareQRcode.Source = CreateQRCode(vmessUrl, $"v2ray_config\\{saveFileFolder}\\QR.bmp"); - //} - - - if (File.Exists($"v2ray_config\\{plainSavePath}\\config.json")) - { - File.Move($"v2ray_config\\{plainSavePath}\\config.json", $"{configSavePath}\\config.json"); - Directory.Delete($"v2ray_config\\{plainSavePath}"); - } - - using (StreamWriter sw = new StreamWriter($"{configSavePath}\\readme.txt")) - { - sw.WriteLine("config.json"); - //****** "此文件为v2ray官方程序所使用的客户端配置文件,配置为全局模式,socks5地址:127.0.0.1:1080,http代理地址:127.0.0.1:1081" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine01").ToString()); - - //****** "v2ray官方网站:https://www.v2ray.com/" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine02").ToString()); - - //****** "v2ray官方程序下载地址:https://github.com/v2ray/v2ray-core/releases" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine03").ToString()); - - //****** "下载相应版本,Windows选择v2ray-windows-64.zip或者v2ray-windows-32.zip,解压后提取v2ctl.exe和v2ray.exe。与config.json放在同一目录,运行v2ray.exe即可。" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine04").ToString()); - - sw.WriteLine("-----------------------------------------"); - //sw.WriteLine("QR.bmp"); - - //****** "此文件为v2rayN、Qv2ray、v2rayNG(Android)、Shadowrocket(ios)扫码导入节点" ****** - //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine05").ToString()); - - //****** "v2rayN下载网址:https://github.com/2dust/v2rayN/releases" ****** - //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine06").ToString()); - - //****** "Qv2ray:https://github.com/Qv2ray/Qv2ray/releases" ****** - //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine07").ToString()); - - //****** "v2rayNG(Android)下载网址:https://github.com/2dust/v2rayNG/releases" ****** - //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine08").ToString()); - - //****** "v2rayNG(Android)在Google Play下载网址:https://play.google.com/store/apps/details?id=com.v2ray.ang" ****** - //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine09").ToString()); - - //****** "Shadowrocket(ios)下载,需要使用国外区的AppleID。请自行谷歌方法。" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine10").ToString()); - - //sw.WriteLine("-----------------------------------------"); - //sw.WriteLine("url.txt"); - - //****** "此文件为v2rayN、Qv2ray、v2rayNG(Android)、Shadowrocket(ios)复制粘贴导入节点的vmess网址" ****** - //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine11").ToString()); - - //写入通用配置参数 - TxtWriteGeneralParameters(sw); - } - } - - - //生成VLESS over TCP with XTLS的配置保存(暂未有分享链接与二维码) - private void GenerateV2rayVlessTcpXtlsShareQRcodeAndBase64Url() - { - #region 暂时不用内容 - // //生成v2rayN的json文件 - // string v2rayNjsonFile = @" - //{ - // ""v"": """", - // ""ps"": """", - // ""add"": """", - // ""port"": """", - // ""id"": """", - // ""aid"": """", - // ""net"": """", - // ""type"": """", - // ""host"": """", - // ""path"": """", - // ""tls"": """" - //}"; - // //MessageBox.Show(v2rayNjsonFile); - // JObject v2rayNjsonObject = JObject.Parse(v2rayNjsonFile); - // v2rayNjsonObject["v"] = "2"; - // v2rayNjsonObject["add"] = TextBoxHostAddress.Text; //设置域名 - // v2rayNjsonObject["port"] = TextBoxPort.Text; //设置端口 - // v2rayNjsonObject["id"] = TextBoxUUID.Text; //设置uuid - // v2rayNjsonObject["aid"] = TextBoxUUIDextra.Text; //设置额外ID - // v2rayNjsonObject["net"] = TextBoxTransmission.Text; //设置传输模式 - // v2rayNjsonObject["type"] = TextBoxCamouflageType.Text; //设置伪装类型 - - // if (TextBoxTransmission.Text.Contains("kcp") == true) - // { - // v2rayNjsonObject["path"] = TextBoxQuicKeyMkcpSeedPath.Text;//设置mKCP Seed - // } - // else if (TextBoxTransmission.Text.Contains("quic") == true) - // { - // v2rayNjsonObject["path"] = TextBoxQuicKeyMkcpSeedPath.Text;//设置quic密钥 - // v2rayNjsonObject["host"] = TextBoxHostQuicEncryption.Text;//Quic加密方式 - // } - // else - // { - // v2rayNjsonObject["path"] = TextBoxQuicKeyMkcpSeedPath.Text; //设置路径 - // v2rayNjsonObject["host"] = TextBoxHostQuicEncryption.Text;//设置TLS的Host - // } - - // v2rayNjsonObject["tls"] = TextBoxTLS.Text; //设置是否启用TLS - // v2rayNjsonObject["ps"] = v2rayNjsonObject["add"]; //设置备注 - // //MessageBox.Show(v2rayNjsonObject["v"].ToString()); - - //string saveFileFolderFirst = TextBoxHostAddress.Text; - //int num = 1; - //saveFileFolder = saveFileFolderFirst; - //CheckDir(@"v2ray_config"); - //while (Directory.Exists(@"v2ray_config\" + saveFileFolder)) - //{ - // saveFileFolder = saveFileFolderFirst + "_copy_" + num.ToString(); - // num++; - //} - //CheckDir(@"v2ray_config\" + saveFileFolder); - - #endregion - - //创建保存目录 - string plainSavePath = @"vless_tcp_xtls_client_config"; - - //v2ray_config\${域名IP}\vless_tcp_xtls_client_config - string configSavePath = CheckDir($"{configDomainSavePath}\\{plainSavePath}"); - - - //生成二维码与URL,跳过VlessTcpTlsWeb暂时未有URL标准 - //TextBoxURLDefault = "vmess://" + ToBase64Encode(v2rayNjsonObject.ToString()); - //TextBoxURL.Text = TextBoxURLDefault; - //using (StreamWriter sw = new StreamWriter($"{configSavePath}\\url.txt")) - //{ - - // sw.WriteLine(TextBoxURLDefault); - - //} - - // ImageShareQRcodeDefault = CreateQRCode(TextBoxURLDefault, $"v2ray_config\\{saveFileFolder}\\QR.bmp"); - // ImageShareQRcode.Source = ImageShareQRcodeDefault; - - - if (File.Exists($"v2ray_config\\{plainSavePath}\\config.json")) - { - File.Move($"v2ray_config\\{plainSavePath}\\config.json", $"{configSavePath}\\config.json"); - Directory.Delete($"v2ray_config\\{plainSavePath}"); - } - - using (StreamWriter sw = new StreamWriter($"{configSavePath}\\readme.txt")) - { - sw.WriteLine("config.json"); - //****** "此文件为v2ray官方程序所使用的客户端配置文件,配置为全局模式,socks5地址:127.0.0.1:1080,http代理地址:127.0.0.1:1081" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine01").ToString()); - - //****** "v2ray官方网站:https://www.v2ray.com/" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine02").ToString()); - - //****** "v2ray官方程序下载地址:https://github.com/v2ray/v2ray-core/releases" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine03").ToString()); - - //****** "下载相应版本,Windows选择v2ray-windows-64.zip或者v2ray-windows-32.zip,解压后提取v2ctl.exe和v2ray.exe。与config.json放在同一目录,运行v2ray.exe即可。" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine04").ToString()); - - //sw.WriteLine("-----------------------------------------"); - //sw.WriteLine("QR.bmp"); - - //****** "此文件为v2rayN、Qv2ray、v2rayNG(Android)、Shadowrocket(ios)扫码导入节点" ****** - //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine05").ToString()); - - //****** "v2rayN下载网址:https://github.com/2dust/v2rayN/releases" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine06").ToString()); - - //****** "Qv2ray:https://github.com/Qv2ray/Qv2ray/releases" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine07").ToString()); - - //****** "v2rayNG(Android)下载网址:https://github.com/2dust/v2rayNG/releases" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine08").ToString()); - - //****** "v2rayNG(Android)在Google Play下载网址:https://play.google.com/store/apps/details?id=com.v2ray.ang" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine09").ToString()); - - //****** "Shadowrocket(ios)下载,需要使用国外区的AppleID。请自行谷歌方法。" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine10").ToString()); - - //sw.WriteLine("-----------------------------------------"); - //sw.WriteLine("url.txt"); - - //****** "此文件为v2rayN、Qv2ray、v2rayNG(Android)、Shadowrocket(ios)复制粘贴导入节点的vmess网址" ****** - //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine11").ToString()); - - //写入通用配置参数-- - TxtWriteGeneralParameters(sw,false); - - } - } - - //生成VLESS over TCP with TLS的配置保存(暂未有分享链接与二维码) - private void GenerateV2rayVlessTcpTlsShareQRcodeAndBase64Url() - { - #region 暂时不用内容 - // //生成v2rayN的json文件 - // string v2rayNjsonFile = @" - //{ - // ""v"": """", - // ""ps"": """", - // ""add"": """", - // ""port"": """", - // ""id"": """", - // ""aid"": """", - // ""net"": """", - // ""type"": """", - // ""host"": """", - // ""path"": """", - // ""tls"": """" - //}"; - // //MessageBox.Show(v2rayNjsonFile); - // JObject v2rayNjsonObject = JObject.Parse(v2rayNjsonFile); - // v2rayNjsonObject["v"] = "2"; - // v2rayNjsonObject["add"] = TextBoxHostAddress.Text; //设置域名 - // v2rayNjsonObject["port"] = TextBoxPort.Text; //设置端口 - // v2rayNjsonObject["id"] = TextBoxUUID.Text; //设置uuid - // v2rayNjsonObject["aid"] = TextBoxUUIDextra.Text; //设置额外ID - // v2rayNjsonObject["net"] = TextBoxTransmission.Text; //设置传输模式 - // v2rayNjsonObject["type"] = TextBoxCamouflageType.Text; //设置伪装类型 - - // if (TextBoxTransmission.Text.Contains("kcp") == true) - // { - // v2rayNjsonObject["path"] = TextBoxQuicKeyMkcpSeedPath.Text;//设置mKCP Seed - // } - // else if (TextBoxTransmission.Text.Contains("quic") == true) - // { - // v2rayNjsonObject["path"] = TextBoxQuicKeyMkcpSeedPath.Text;//设置quic密钥 - // v2rayNjsonObject["host"] = TextBoxHostQuicEncryption.Text;//Quic加密方式 - // } - // else - // { - // v2rayNjsonObject["path"] = TextBoxQuicKeyMkcpSeedPath.Text; //设置路径 - // v2rayNjsonObject["host"] = TextBoxHostQuicEncryption.Text;//设置TLS的Host - // } - - // v2rayNjsonObject["tls"] = TextBoxTLS.Text; //设置是否启用TLS - // v2rayNjsonObject["ps"] = v2rayNjsonObject["add"]; //设置备注 - // //MessageBox.Show(v2rayNjsonObject["v"].ToString()); - - //string saveFileFolderFirst = TextBoxHostAddress.Text; - //int num = 1; - //saveFileFolder = saveFileFolderFirst; - //CheckDir(@"v2ray_config"); - //while (Directory.Exists(@"v2ray_config\" + saveFileFolder)) - //{ - // saveFileFolder = saveFileFolderFirst + "_copy_" + num.ToString(); - // num++; - //} - //CheckDir(@"v2ray_config\" + saveFileFolder); - - #endregion - - //创建保存目录 - string plainSavePath = @"vless_tcp_tls_client_config"; - //v2ray_config\${域名IP} - //string configDomainSavePath = CreateConfigSaveDir(@"v2ray_config", TextBoxHostAddressSS.Text); - //v2ray_config\${域名IP}\vless_tcp_xtls_client_config - string configSavePath = CheckDir($"{configDomainSavePath}\\{plainSavePath}"); - - - //生成二维码与URL,跳过VlessTcpTlsWeb暂时未有URL标准 - //TextBoxURLVlessTcp = "vmess://" + ToBase64Encode(v2rayNjsonObject.ToString()); - //TextBoxURL.Text = TextBoxURLVlessTcp; - //using (StreamWriter sw = new StreamWriter($"{configSavePath}\\url.txt")) - //{ - - // sw.WriteLine(TextBoxURLVlessTcp); - - //} - - // ImageShareQRcodeVlessTcp = CreateQRCode(TextBoxURLVlessTcp, $"v2ray_config\\{saveFileFolder}\\QR.bmp"); - // ImageShareQRcode.Source = ImageShareQRcodeVlessTcp; - - - if (File.Exists($"v2ray_config\\{plainSavePath}\\config.json")) - { - File.Move($"v2ray_config\\{plainSavePath}\\config.json", $"{configSavePath}\\config.json"); - Directory.Delete($"v2ray_config\\{plainSavePath}"); - } - - using (StreamWriter sw = new StreamWriter($"{configSavePath}\\readme.txt")) - { - sw.WriteLine("config.json"); - //****** "此文件为v2ray官方程序所使用的客户端配置文件,配置为全局模式,socks5地址:127.0.0.1:1080,http代理地址:127.0.0.1:1081" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine01").ToString()); - - //****** "v2ray官方网站:https://www.v2ray.com/" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine02").ToString()); - - //****** "v2ray官方程序下载地址:https://github.com/v2ray/v2ray-core/releases" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine03").ToString()); - - //****** "下载相应版本,Windows选择v2ray-windows-64.zip或者v2ray-windows-32.zip,解压后提取v2ctl.exe和v2ray.exe。与config.json放在同一目录,运行v2ray.exe即可。" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine04").ToString()); - - //sw.WriteLine("-----------------------------------------"); - //sw.WriteLine("QR.bmp"); - - //****** "此文件为v2rayN、Qv2ray、v2rayNG(Android)、Shadowrocket(ios)扫码导入节点" ****** - //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine05").ToString()); - - //****** "v2rayN下载网址:https://github.com/2dust/v2rayN/releases" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine06").ToString()); - - //****** "Qv2ray:https://github.com/Qv2ray/Qv2ray/releases" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine07").ToString()); - - //****** "v2rayNG(Android)下载网址:https://github.com/2dust/v2rayNG/releases" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine08").ToString()); - - //****** "v2rayNG(Android)在Google Play下载网址:https://play.google.com/store/apps/details?id=com.v2ray.ang" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine09").ToString()); - - //****** "Shadowrocket(ios)下载,需要使用国外区的AppleID。请自行谷歌方法。" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine10").ToString()); - - //sw.WriteLine("-----------------------------------------"); - //sw.WriteLine("url.txt"); - - //****** "此文件为v2rayN、Qv2ray、v2rayNG(Android)、Shadowrocket(ios)复制粘贴导入节点的vmess网址" ****** - //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine11").ToString()); - - //写入通用配置参数-- - TxtWriteGeneralParameters(sw,false); - - } - } - - //生成VLESS over WS with TLS的配置保存(暂未有分享链接与二维码) - private void GenerateV2rayVlessWsTlsShareQRcodeAndBase64Url() - { - #region 暂时不用内容 - // //生成v2rayN的json文件 - // string v2rayNjsonFile = @" - //{ - // ""v"": """", - // ""ps"": """", - // ""add"": """", - // ""port"": """", - // ""id"": """", - // ""aid"": """", - // ""net"": """", - // ""type"": """", - // ""host"": """", - // ""path"": """", - // ""tls"": """" - //}"; - // //MessageBox.Show(v2rayNjsonFile); - // JObject v2rayNjsonObject = JObject.Parse(v2rayNjsonFile); - // v2rayNjsonObject["v"] = "2"; - // v2rayNjsonObject["add"] = TextBoxHostAddress.Text; //设置域名 - // v2rayNjsonObject["port"] = TextBoxPort.Text; //设置端口 - // v2rayNjsonObject["id"] = TextBoxUUID.Text; //设置uuid - // v2rayNjsonObject["aid"] = TextBoxUUIDextra.Text; //设置额外ID - // v2rayNjsonObject["net"] = TextBoxTransmission.Text; //设置传输模式 - // v2rayNjsonObject["type"] = TextBoxCamouflageType.Text; //设置伪装类型 - - // if (TextBoxTransmission.Text.Contains("kcp") == true) - // { - // v2rayNjsonObject["path"] = TextBoxQuicKeyMkcpSeedPath.Text;//设置mKCP Seed - // } - // else if (TextBoxTransmission.Text.Contains("quic") == true) - // { - // v2rayNjsonObject["path"] = TextBoxQuicKeyMkcpSeedPath.Text;//设置quic密钥 - // v2rayNjsonObject["host"] = TextBoxHostQuicEncryption.Text;//Quic加密方式 - // } - // else - // { - // v2rayNjsonObject["path"] = TextBoxQuicKeyMkcpSeedPath.Text; //设置路径 - // v2rayNjsonObject["host"] = TextBoxHostQuicEncryption.Text;//设置TLS的Host - // } - - // v2rayNjsonObject["tls"] = TextBoxTLS.Text; //设置是否启用TLS - // v2rayNjsonObject["ps"] = v2rayNjsonObject["add"]; //设置备注 - // //MessageBox.Show(v2rayNjsonObject["v"].ToString()); - - //string saveFileFolderFirst = TextBoxHostAddress.Text; - //int num = 1; - //saveFileFolder = saveFileFolderFirst; - //CheckDir(@"v2ray_config"); - //while (Directory.Exists(@"v2ray_config\" + saveFileFolder)) - //{ - // saveFileFolder = saveFileFolderFirst + "_copy_" + num.ToString(); - // num++; - //} - //CheckDir(@"v2ray_config\" + saveFileFolder); - - #endregion - - //创建保存目录 - string plainSavePath = @"vless_ws_tls_client_config"; - //v2ray_config\${域名IP} - //string configDomainSavePath = CreateConfigSaveDir(@"v2ray_config", TextBoxHostAddressSS.Text); - //v2ray_config\${域名IP}\vless_tcp_xtls_client_config - string configSavePath = CheckDir($"{configDomainSavePath}\\{plainSavePath}"); - - - //生成二维码与URL,跳过VlessTcpTlsWeb暂时未有URL标准 - //TextBoxURLVlessWs = "vmess://" + ToBase64Encode(v2rayNjsonObject.ToString()); - //TextBoxURL.Text = TextBoxURLVlessWs; - //using (StreamWriter sw = new StreamWriter($"{configSavePath}\\url.txt")) - //{ - - // sw.WriteLine(TextBoxURLVlessWs); - - //} - - // ImageShareQRcodeVlessWs = CreateQRCode(TextBoxURLVlessWs, $"v2ray_config\\{saveFileFolder}\\QR.bmp"); - //ImageShareQRcode.Source = ImageShareQRcodeVlessWs; - - - if (File.Exists($"v2ray_config\\{plainSavePath}\\config.json")) - { - File.Move($"v2ray_config\\{plainSavePath}\\config.json", $"{configSavePath}\\config.json"); - Directory.Delete($"v2ray_config\\{plainSavePath}"); - } - - using (StreamWriter sw = new StreamWriter($"{configSavePath}\\readme.txt")) - { - sw.WriteLine("config.json"); - //****** "此文件为v2ray官方程序所使用的客户端配置文件,配置为全局模式,socks5地址:127.0.0.1:1080,http代理地址:127.0.0.1:1081" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine01").ToString()); - - //****** "v2ray官方网站:https://www.v2ray.com/" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine02").ToString()); - - //****** "v2ray官方程序下载地址:https://github.com/v2ray/v2ray-core/releases" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine03").ToString()); - - //****** "下载相应版本,Windows选择v2ray-windows-64.zip或者v2ray-windows-32.zip,解压后提取v2ctl.exe和v2ray.exe。与config.json放在同一目录,运行v2ray.exe即可。" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine04").ToString()); - - //sw.WriteLine("-----------------------------------------"); - //sw.WriteLine("QR.bmp"); - - //****** "此文件为v2rayN、Qv2ray、v2rayNG(Android)、Shadowrocket(ios)扫码导入节点" ****** - //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine05").ToString()); - - //****** "v2rayN下载网址:https://github.com/2dust/v2rayN/releases" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine06").ToString()); - - //****** "Qv2ray:https://github.com/Qv2ray/Qv2ray/releases" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine07").ToString()); - - //****** "v2rayNG(Android)下载网址:https://github.com/2dust/v2rayNG/releases" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine08").ToString()); - - //****** "v2rayNG(Android)在Google Play下载网址:https://play.google.com/store/apps/details?id=com.v2ray.ang" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine09").ToString()); - - //****** "Shadowrocket(ios)下载,需要使用国外区的AppleID。请自行谷歌方法。" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine10").ToString()); - - //sw.WriteLine("-----------------------------------------"); - //sw.WriteLine("url.txt"); - - //****** "此文件为v2rayN、Qv2ray、v2rayNG(Android)、Shadowrocket(ios)复制粘贴导入节点的vmess网址" ****** - //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine11").ToString()); - - //写入通用配置参数-- - TxtWriteGeneralParameters(sw,false); - - } - } - - //生成VMess over TCP with TLS的配置保存 - private void GenerateV2rayVmessTcpTlsShareQRcodeAndBase64Url() - { - #region 暂时不用内容 - //生成v2rayN的json文件 - string v2rayNjsonFile = @" -{ - ""v"": """", - ""ps"": """", - ""add"": """", - ""port"": """", - ""id"": """", - ""aid"": """", - ""net"": """", - ""type"": """", - ""host"": """", - ""path"": """", - ""tls"": """" -}"; - //MessageBox.Show(v2rayNjsonFile); - JObject v2rayNjsonObject = JObject.Parse(v2rayNjsonFile); - v2rayNjsonObject["v"] = "2"; - v2rayNjsonObject["add"] = TextBoxHostAddress.Text; //设置域名 - v2rayNjsonObject["port"] = TextBoxPort.Text; //设置端口 - v2rayNjsonObject["id"] = TextBoxUUID.Text; //设置uuid - v2rayNjsonObject["aid"] = TextBoxUUIDextra.Text; //设置额外ID - v2rayNjsonObject["net"] = TextBoxTransmission.Text; //设置传输模式 - v2rayNjsonObject["type"] = TextBoxCamouflageType.Text; //设置伪装类型 - - if (TextBoxTransmission.Text.Contains("kcp") == true) - { - v2rayNjsonObject["path"] = TextBoxQuicKeyMkcpSeedPath.Text;//设置mKCP Seed - v2rayNjsonObject["host"] = "";//设置Host - } - else if (TextBoxTransmission.Text.Contains("quic") == true) - { - v2rayNjsonObject["path"] = TextBoxQuicKeyMkcpSeedPath.Text;//设置quic密钥 - v2rayNjsonObject["host"] = TextBoxHostQuicEncryption.Text;//Quic加密方式 - } - else - { - v2rayNjsonObject["path"] = TextBoxQuicKeyMkcpSeedPath.Text; //设置路径 - v2rayNjsonObject["host"] = TextBoxHostQuicEncryption.Text;//设置TLS的Host - } - - v2rayNjsonObject["tls"] = TextBoxTLS.Text; //设置是否启用TLS - v2rayNjsonObject["ps"] = v2rayNjsonObject["add"]; //设置备注 - - - #endregion - - //创建保存目录 - string plainSavePath = @"vmess_tcp_tls_client_config"; - //v2ray_config\${域名IP} - //string configDomainSavePath = CreateConfigSaveDir(@"v2ray_config", TextBoxHostAddressSS.Text); - //v2ray_config\${域名IP}\vless_tcp_xtls_client_config - string configSavePath = CheckDir($"{configDomainSavePath}\\{plainSavePath}"); - - - //生成二维码与URL,跳过VlessTcpTlsWeb暂时未有URL标准 - TextBoxURLVmessTcp = "vmess://" + ToBase64Encode(v2rayNjsonObject.ToString()); - //TextBoxURL.Text = TextBoxURLVmessTcp; - using (StreamWriter sw = new StreamWriter($"{configSavePath}\\url.txt")) - { - sw.WriteLine(TextBoxURLVmessTcp); - } - - ImageShareQRcodeVmessTcp = CreateQRCode(TextBoxURLVmessTcp, $"{configSavePath}\\QR.bmp"); - //ImageShareQRcode.Source = ImageShareQRcodeVmessTcp; - - - if (File.Exists($"v2ray_config\\{plainSavePath}\\config.json")) - { - File.Move($"v2ray_config\\{plainSavePath}\\config.json", $"{configSavePath}\\config.json"); - Directory.Delete($"v2ray_config\\{plainSavePath}"); - } - - using (StreamWriter sw = new StreamWriter($"{configSavePath}\\readme.txt")) - { - ReadmeTxtWriteGenerate(sw); - - } - } - - //生成VMess over WS with TLS的配置保存 - private void GenerateV2rayVmessWsTlsShareQRcodeAndBase64Url() - { - #region 暂时不用内容 - //生成v2rayN的json文件 - string v2rayNjsonFile = @" -{ - ""v"": """", - ""ps"": """", - ""add"": """", - ""port"": """", - ""id"": """", - ""aid"": """", - ""net"": """", - ""type"": """", - ""host"": """", - ""path"": """", - ""tls"": """" -}"; - //MessageBox.Show(v2rayNjsonFile); - JObject v2rayNjsonObject = JObject.Parse(v2rayNjsonFile); - v2rayNjsonObject["v"] = "2"; - v2rayNjsonObject["add"] = TextBoxHostAddress.Text; //设置域名 - v2rayNjsonObject["port"] = TextBoxPort.Text; //设置端口 - v2rayNjsonObject["id"] = TextBoxUUID.Text; //设置uuid - v2rayNjsonObject["aid"] = TextBoxUUIDextra.Text; //设置额外ID - v2rayNjsonObject["net"] = TextBoxTransmission.Text; //设置传输模式 - v2rayNjsonObject["type"] = TextBoxCamouflageType.Text; //设置伪装类型 - - if (TextBoxTransmission.Text.Contains("kcp") == true) - { - v2rayNjsonObject["path"] = TextBoxQuicKeyMkcpSeedPath.Text;//设置mKCP Seed - } - else if (TextBoxTransmission.Text.Contains("quic") == true) - { - v2rayNjsonObject["path"] = TextBoxQuicKeyMkcpSeedPath.Text;//设置quic密钥 - v2rayNjsonObject["host"] = TextBoxHostQuicEncryption.Text;//Quic加密方式 - } - else - { - v2rayNjsonObject["path"] = TextBoxQuicKeyMkcpSeedPath.Text; //设置路径 - v2rayNjsonObject["host"] = TextBoxHostQuicEncryption.Text;//设置TLS的Host - } - - v2rayNjsonObject["tls"] = "tls"; //设置是否启用TLS - v2rayNjsonObject["ps"] = v2rayNjsonObject["add"]; //设置备注 - - #endregion - - //创建保存目录 - string plainSavePath = @"vmess_ws_tls_client_config"; - //v2ray_config\${域名IP} - //string configDomainSavePath = CreateConfigSaveDir(@"v2ray_config", TextBoxHostAddressSS.Text); - //v2ray_config\${域名IP}\vless_tcp_xtls_client_config - string configSavePath = CheckDir($"{configDomainSavePath}\\{plainSavePath}"); - - - //生成二维码与URL,跳过VlessTcpTlsWeb暂时未有URL标准 - TextBoxURLVmessWs = "vmess://" + ToBase64Encode(v2rayNjsonObject.ToString()); - //TextBoxURL.Text = TextBoxURLVmessWs; - using (StreamWriter sw = new StreamWriter($"{configSavePath}\\url.txt")) - { - - sw.WriteLine(TextBoxURLVmessWs); - - } - - ImageShareQRcodeVmessWs = CreateQRCode(TextBoxURLVmessWs, $"{configSavePath}\\QR.bmp"); - //ImageShareQRcode.Source = ImageShareQRcodeVmessWs; - - if (File.Exists($"v2ray_config\\{plainSavePath}\\config.json")) - { - File.Move($"v2ray_config\\{plainSavePath}\\config.json", $"{configSavePath}\\config.json"); - Directory.Delete($"v2ray_config\\{plainSavePath}"); - } - - using (StreamWriter sw = new StreamWriter($"{configSavePath}\\readme.txt")) - { - ReadmeTxtWriteGenerate(sw); - - } - } - - //生成Trojan over TCP with TLS的配置保存 - private void GenerateV2rayTrojanShareQRcodeAndBase64Url() - { - //创建保存目录 - string plainSavePath = @"trojan_tcp_tls_client_config"; - string configSavePath = CheckDir($"{configDomainSavePath}\\{plainSavePath}"); - - TextBoxURLTrojanTcp = $"trojan://{TextBoxUUID.Text}@{TextBoxHostAddress.Text}:{TextBoxPort.Text}#{TextBoxHostAddress.Text}"; - - //TextBoxURL.Text = TextBoxURLTrojanTcp; - using (StreamWriter sw = new StreamWriter($"{configSavePath}\\url.txt")) - { - sw.WriteLine(TextBoxURLTrojanTcp); - - } - //ImageShareQRcode.Source = CreateQRCode(TextBoxURLTrojanTcp, $"{configSavePath}\\QR.bmp"); - ImageShareQRcodeTrojanTcp = CreateQRCode(TextBoxURLTrojanTcp, $"{configSavePath}\\QR.bmp"); - //ImageShareQRcode.Source = ImageShareQRcodeTrojanTcp; - //移动官方程序配置文件到相应目录 - if (File.Exists($"v2ray_config\\{plainSavePath}\\config.json")) - { - File.Move($"v2ray_config\\{plainSavePath}\\config.json", $"{configSavePath}\\config.json"); - Directory.Delete($"v2ray_config\\{plainSavePath}"); - } - - using (StreamWriter sw = new StreamWriter($"{configSavePath}\\readme.txt")) - { - //ReadmeTxtWriteGenerate(sw); - sw.WriteLine("config.json"); - //****** "此文件为v2ray官方程序所使用的客户端配置文件,配置为全局模式,socks5地址:127.0.0.1:1080,http代理地址:127.0.0.1:1081" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine01").ToString()); - - //****** "v2ray官方网站:https://www.v2ray.com/" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine02").ToString()); - - //****** "v2ray官方程序下载地址:https://github.com/v2ray/v2ray-core/releases" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine03").ToString()); - - //****** "下载相应版本,Windows选择v2ray-windows-64.zip或者v2ray-windows-32.zip,解压后提取v2ctl.exe和v2ray.exe。与config.json放在同一目录,运行v2ray.exe即可。" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine04").ToString()); - - sw.WriteLine("-----------------------------------------"); - sw.WriteLine("QR.bmp"); - - //****** "此文件为v2rayN(windows)、Qv2ray(windows)、v2rayNG(Android)、Shadowrocket(ios)扫码导入节点" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine05").ToString()); - - //****** "v2rayN下载网址:https://github.com/2dust/v2rayN/releases" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine06").ToString()); - - //****** "Qv2ray下载网址:https://github.com/Qv2ray/Qv2ray/releases" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine07").ToString()); - - //****** "v2rayNG(Android)下载网址:https://github.com/2dust/v2rayNG/releases" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine08").ToString()); - - //****** "v2rayNG(Android)在Google Play下载网址:https://play.google.com/store/apps/details?id=com.v2ray.ang" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine09").ToString()); - - //****** "Shadowrocket(ios)下载,需要使用国外区的AppleID。请自行谷歌方法。" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine10").ToString()); - - sw.WriteLine("-----------------------------------------"); - sw.WriteLine("url.txt"); - - //****** "此文件为v2rayN、Qv2ray、v2rayNG(Android)、Shadowrocket(ios)复制粘贴导入节点的vmess网址" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine11").ToString()); - - sw.WriteLine("-----------------------------------------\n"); - - string strApplicat = ""; - string strParam = ""; - int strLenth = 20; - //****** "服务器通用连接配置参数:" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine12").ToString()); - sw.WriteLine(""); - - strApplicat = "TextBlockServerAddress"; - strParam = TextBoxHostAddress.Text; - sw.WriteLine(AlignmentStrFunc(Application.Current.FindResource($"{strApplicat}").ToString(), strLenth) + strParam); - - strApplicat = "TextBlockServerPort"; - strParam = TextBoxPort.Text; - sw.WriteLine(AlignmentStrFunc(Application.Current.FindResource($"{strApplicat}").ToString(), strLenth) + strParam); - - strApplicat = "TextBlockUserUUID"; - strParam = TextBoxUUID.Text; - sw.WriteLine(AlignmentStrFunc(Application.Current.FindResource($"{strApplicat}").ToString(), strLenth) + strParam); - - } - - } - - //写入VMESS的readme.txt文件 - private void ReadmeTxtWriteGenerate(StreamWriter sw) - { - sw.WriteLine("config.json"); - //****** "此文件为v2ray官方程序所使用的客户端配置文件,配置为全局模式,socks5地址:127.0.0.1:1080,http代理地址:127.0.0.1:1081" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine01").ToString()); - - //****** "v2ray官方网站:https://www.v2ray.com/" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine02").ToString()); - - //****** "v2ray官方程序下载地址:https://github.com/v2ray/v2ray-core/releases" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine03").ToString()); - - //****** "下载相应版本,Windows选择v2ray-windows-64.zip或者v2ray-windows-32.zip,解压后提取v2ctl.exe和v2ray.exe。与config.json放在同一目录,运行v2ray.exe即可。" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine04").ToString()); - - sw.WriteLine("-----------------------------------------"); - sw.WriteLine("QR.bmp"); - - //****** "此文件为v2rayN(windows)、Qv2ray(windows)、v2rayNG(Android)、Shadowrocket(ios)扫码导入节点" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine05").ToString()); - - //****** "v2rayN下载网址:https://github.com/2dust/v2rayN/releases" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine06").ToString()); - - //****** "Qv2ray下载网址:https://github.com/Qv2ray/Qv2ray/releases" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine07").ToString()); - - //****** "v2rayNG(Android)下载网址:https://github.com/2dust/v2rayNG/releases" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine08").ToString()); - - //****** "v2rayNG(Android)在Google Play下载网址:https://play.google.com/store/apps/details?id=com.v2ray.ang" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine09").ToString()); - - //****** "Shadowrocket(ios)下载,需要使用国外区的AppleID。请自行谷歌方法。" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine10").ToString()); - - sw.WriteLine("-----------------------------------------"); - sw.WriteLine("url.txt"); - - //****** "此文件为v2rayN、Qv2ray、v2rayNG(Android)、Shadowrocket(ios)复制粘贴导入节点的vmess网址" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine11").ToString()); - - //写入通用配置参数 - TxtWriteGeneralParameters(sw); - } - //TXT文件中写入通用配置参数--- - private void TxtWriteGeneralParameters(StreamWriter sw,bool alterId = true) - { - sw.WriteLine("-----------------------------------------\n"); - - string strApplicat = ""; - string strParam = ""; - int strLenth = 20; - //****** "服务器通用连接配置参数:" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine12").ToString()); - sw.WriteLine(""); - - strApplicat = "TextBlockServerAddress"; - strParam = TextBoxHostAddress.Text; - sw.WriteLine(AlignmentStrFunc(Application.Current.FindResource($"{strApplicat}").ToString(), strLenth) + strParam); - - strApplicat = "TextBlockServerPort"; - strParam = TextBoxPort.Text; - sw.WriteLine(AlignmentStrFunc(Application.Current.FindResource($"{strApplicat}").ToString(), strLenth) + strParam); - - strApplicat = "TextBlockUserUUID"; - strParam = TextBoxUUID.Text; - sw.WriteLine(AlignmentStrFunc(Application.Current.FindResource($"{strApplicat}").ToString(), strLenth) + strParam); - - if (alterId == true) - { - strApplicat = "TextBlockV2RayAlterId"; - strParam = TextBoxUUIDextra.Text; - sw.WriteLine(AlignmentStrFunc(Application.Current.FindResource($"{strApplicat}").ToString(), strLenth) + strParam); - } - - strApplicat = "TextBlockEncryption"; - strParam = TextBoxEncryption.Text; - sw.WriteLine(AlignmentStrFunc(Application.Current.FindResource($"{strApplicat}").ToString(), strLenth) + strParam); - - strApplicat = "TextBlockTransferProtocol"; - strParam = TextBoxTransmission.Text; - sw.WriteLine(AlignmentStrFunc(Application.Current.FindResource($"{strApplicat}").ToString(), strLenth) + strParam); - - strApplicat = "TextBlockCamouflageType"; - strParam = TextBoxCamouflageType.Text; - sw.WriteLine(AlignmentStrFunc(Application.Current.FindResource($"{strApplicat}").ToString(), strLenth) + strParam); - - strApplicat = "TextBlockIsOrNotTLS"; - strParam = TextBoxTLS.Text; - sw.WriteLine(AlignmentStrFunc(Application.Current.FindResource($"{strApplicat}").ToString(), strLenth) + strParam); - - if (MainWindow.ReceiveConfigurationParameters[0].Contains("Quic") == true) - { - strParam = TextBoxHostQuicEncryption.Text; - sw.WriteLine(AlignmentStrFunc(TextBlockQuicEncryption.Text, strLenth) + strParam); - - strParam = TextBoxQuicKeyMkcpSeedPath.Text; - sw.WriteLine(AlignmentStrFunc(TextBlockQuicKey.Text, strLenth) + strParam); - - } - else if (MainWindow.ReceiveConfigurationParameters[0].Contains("mKCP") == true) - { - strParam = TextBoxHostQuicEncryption.Text; - sw.WriteLine(AlignmentStrFunc("host:", strLenth) + strParam); - - strParam = TextBoxQuicKeyMkcpSeedPath.Text; - sw.WriteLine(AlignmentStrFunc(TextBlockMkcpSeed.Text, strLenth) + strParam); - - } - else - { - strParam = TextBoxHostQuicEncryption.Text; - sw.WriteLine(AlignmentStrFunc("host:", strLenth) + strParam); - - strParam = TextBoxQuicKeyMkcpSeedPath.Text; - sw.WriteLine(AlignmentStrFunc(TextBlockPath.Text, strLenth) + strParam); - } - } - #endregion - - #endregion - - #endregion - - #region Xray 相关 - - #region Xray参数设置函数 - - //设置VLESS over TCP with XTLS - private void XraySetVlessTcpXtls() - { - GridNotTrojanParametersXray.Visibility = Visibility.Visible; - TextBlockVmessOrVlessXray.Text = Application.Current.FindResource("TabItemHeaderV2RayVlessProtocol").ToString(); - TextBlockVmessOrVlessXray.Visibility = Visibility.Visible; - //隐藏下面的二维码显示 - HideGroupBoxClientQRandURL(); - - TextBoxEncryptionXray.Text = "none"; - TextBoxTransmissionXray.Text = "tcp"; - TextBoxCamouflageTypeXray.Text = "none"; - //TLS的Host /Quic 加密方式 - TextBoxHostQuicEncryptionXray.Text = MainWindow.ReceiveConfigurationParameters[4]; - TextBoxTLSXray.Text = "xtls"; - HideAlterIdXray(); - ShowHostNameXray(); - ShowPathXray(); - TextBoxQuicKeyMkcpSeedPathXray.Text = ""; - - - } - - //设置VLESS over TCP with TLS - private void XraySetVlessTcpTls() - { - GridNotTrojanParametersXray.Visibility = Visibility.Visible; - TextBlockVmessOrVlessXray.Text = Application.Current.FindResource("TabItemHeaderV2RayVlessProtocol").ToString(); - TextBlockVmessOrVlessXray.Visibility = Visibility.Visible; - //隐藏下面的二维码显示 - HideGroupBoxClientQRandURL(); - - TextBoxEncryptionXray.Text = "none"; - TextBoxTransmissionXray.Text = "tcp"; - TextBoxCamouflageTypeXray.Text = "none"; - //TLS的Host /Quic 加密方式 - TextBoxHostQuicEncryptionXray.Text = MainWindow.ReceiveConfigurationParameters[4]; - TextBoxTLSXray.Text = "tls"; - HideAlterIdXray(); - ShowHostNameXray(); - ShowPathXray(); - TextBoxQuicKeyMkcpSeedPathXray.Text = ""; - } - - //设置VLESS over WS with TLS - private void XraySetVlessWsTls() - { - GridNotTrojanParametersXray.Visibility = Visibility.Visible; - TextBlockVmessOrVlessXray.Text = Application.Current.FindResource("TabItemHeaderV2RayVlessProtocol").ToString(); - TextBlockVmessOrVlessXray.Visibility = Visibility.Visible; - //隐藏下面的二维码显示 - HideGroupBoxClientQRandURL(); - - TextBoxEncryptionXray.Text = "none"; - TextBoxTransmissionXray.Text = "ws"; - TextBoxCamouflageTypeXray.Text = "none"; - //TLS的Host /Quic 加密方式 - TextBoxHostQuicEncryptionXray.Text = MainWindow.ReceiveConfigurationParameters[4]; - TextBoxTLSXray.Text = "tls"; - HideAlterIdXray(); - ShowHostNameXray(); - ShowPathXray(); - TextBoxQuicKeyMkcpSeedPathXray.Text = MainWindow.ReceiveConfigurationParameters[3]; - - } - - //设置VMess over TCP with TLS - private void XraySetVmessTcpTls() - { - GridNotTrojanParametersXray.Visibility = Visibility.Visible; - TextBoxEncryptionXray.Text = "none"; - TextBoxTransmissionXray.Text = "tcp"; - TextBoxCamouflageTypeXray.Text = "http"; - //TLS的Host /Quic 加密方式 - TextBoxHostQuicEncryptionXray.Text = MainWindow.ReceiveConfigurationParameters[4]; - TextBoxTLSXray.Text = "tls"; - ShowAlterIdXray(); - ShowHostNameXray(); - ShowPathXray(); - TextBoxQuicKeyMkcpSeedPathXray.Text = MainWindow.ReceiveConfigurationParameters[9]; - TextBlockVmessOrVlessXray.Visibility = Visibility.Collapsed; - //显示下面的二维码显示。 - //HideGroupBoxClientQRandURL(); - ShowGroupBoxClientQRandURL(); - TextBoxURL.Text = TextBoxURLVmessTcp; - ImageShareQRcode.Source = ImageShareQRcodeVmessTcp; - } - - //设置VMess over WS with TLS - private void XraySetVmessWsTls() - { - GridNotTrojanParametersXray.Visibility = Visibility.Visible; - TextBoxEncryptionXray.Text = "none"; - TextBoxTransmissionXray.Text = "ws"; - TextBoxCamouflageTypeXray.Text = "none"; - //TLS的Host /Quic 加密方式 - TextBoxHostQuicEncryptionXray.Text = MainWindow.ReceiveConfigurationParameters[4]; - TextBoxTLSXray.Text = "tls"; - ShowAlterIdXray(); - ShowHostNameXray(); - ShowPathXray(); - TextBoxQuicKeyMkcpSeedPathXray.Text = MainWindow.ReceiveConfigurationParameters[6]; - TextBlockVmessOrVlessXray.Visibility = Visibility.Collapsed; - //显示下面的二维码与分享链接 - ShowGroupBoxClientQRandURL(); - TextBoxURL.Text = TextBoxURLVmessWs; - ImageShareQRcode.Source = ImageShareQRcodeVmessWs; - } - - //设置Trojan over TCP with TLS - private void XraySetTrojanTcpTls() - { - //隐藏所有不是Trojan的参数 - GridNotTrojanParametersXray.Visibility = Visibility.Collapsed; - //显示下面的二维码与分享链接 - ShowGroupBoxClientQRandURL(); - TextBoxURL.Text = TextBoxURLTrojanTcp; - ImageShareQRcode.Source = ImageShareQRcodeTrojanTcp; - } - #endregion - - #region 界面控制相关 - - //显示Quic 加密方式 - private void ShowQuicEncryptionXray() - { - TextBlockQuicEncryptionXray.Visibility = Visibility.Visible; - TextBlockHostXray.Visibility = Visibility.Collapsed; - } - - //显示Host隐藏Quic加密方式 - private void ShowHostNameXray() - { - TextBlockHostXray.Visibility = Visibility.Visible; - TextBlockQuicEncryptionXray.Visibility = Visibility.Collapsed; - } - - //显示路径Path,隐藏mKCP/Quic Key/复制按钮 - private void ShowPathXray() - { - TextBlockPathXray.Visibility = Visibility.Visible; - TextBlockMkcpSeedXray.Visibility = Visibility.Collapsed; - TextBlockQuicKeyXray.Visibility = Visibility.Collapsed; - } - - //显示mKCP Seed/复制按钮,隐藏Path/Quic Key - private void ShowMkcpSeedXray() - { - TextBlockPathXray.Visibility = Visibility.Collapsed; - TextBlockMkcpSeedXray.Visibility = Visibility.Visible; - TextBlockQuicKeyXray.Visibility = Visibility.Collapsed; - } - - //显示Quic Key/复制按钮 隐藏Path/mKcp Seed - private void ShowQuicKeyXray() - { - TextBlockPathXray.Visibility = Visibility.Collapsed; - TextBlockMkcpSeedXray.Visibility = Visibility.Collapsed; - TextBlockQuicKeyXray.Visibility = Visibility.Visible; - } - - //显示额外ID - private void ShowAlterIdXray() - { - TextBlockUUIDextraXray.Visibility = Visibility.Visible; - TextBoxUUIDextraXray.Visibility = Visibility.Visible; - TextBlockUUIDextraExplanationXray.Visibility = Visibility.Visible; - - } - - //隐藏额外ID - private void HideAlterIdXray() - { - TextBlockUUIDextraXray.Visibility = Visibility.Collapsed; - TextBoxUUIDextraXray.Visibility = Visibility.Collapsed; - TextBlockUUIDextraExplanationXray.Visibility = Visibility.Collapsed; - - } - - //显示加密方式 - private void ShowEncryptionXray() - { - TextBlockEncryptionXray.Visibility = Visibility.Visible; - TextBoxEncryptionXray.Visibility = Visibility.Visible; - } - //隐藏加密方式 - private void HideEncryptionXray() - { - TextBlockEncryptionXray.Visibility = Visibility.Collapsed; - TextBoxEncryptionXray.Visibility = Visibility.Collapsed; - } - - //显示传输协议 - private void ShowTransferProtocolXray() - { - TextBlockTransferProtocolXray.Visibility = Visibility.Visible; - TextBoxTransmissionXray.Visibility = Visibility.Visible; - } - //隐藏传输协议 - private void HideTransferProtocolXray() - { - TextBlockTransferProtocolXray.Visibility = Visibility.Collapsed; - TextBoxTransmissionXray.Visibility = Visibility.Collapsed; - } - //显示伪装类型 - private void ShowTextBlockCamouflageTypeXray() - { - TextBlockCamouflageTypeXray.Visibility = Visibility.Visible; - TextBoxCamouflageTypeXray.Visibility = Visibility.Visible; - } - //隐藏伪装类型 - private void HideTextBlockCamouflageTypeXray() - { - TextBlockCamouflageTypeXray.Visibility = Visibility.Collapsed; - TextBoxCamouflageTypeXray.Visibility = Visibility.Collapsed; - } - - - //以下几个为对RadioButton按钮的选中后,界面变化与参数显示 - private void RadioButtonVlessTcpXtlsXray_Checked(object sender, RoutedEventArgs e) - { - XraySetVlessTcpXtls(); - } - - private void RadioButtonVlessTcpTlsXray_Checked(object sender, RoutedEventArgs e) - { - XraySetVlessTcpTls(); - } - - private void RadioButtonVlessWsTlsXray_Checked(object sender, RoutedEventArgs e) - { - XraySetVlessWsTls(); - } - - private void RadioButtonVmessTcpTlsXray_Checked(object sender, RoutedEventArgs e) - { - XraySetVmessTcpTls(); - } - - private void RadioButtonVmessWsTlsXray_Checked(object sender, RoutedEventArgs e) - { - XraySetVmessWsTls(); - } - - private void RadioButtonTrojanTcpTlsXray_Checked(object sender, RoutedEventArgs e) - { - XraySetTrojanTcpTls(); - } - #endregion - - #region 复制参数到剪贴板中 - - - - //复制服务器地址到剪贴板 - private void TextBoxHostAddressXray_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxHostAddressXray.Text); - } - - - //复制服务器端口到剪贴板 - private void TextBoxPortXray_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxPortXray.Text); - } - - //复制UUID到剪贴板 - private void TextBoxUUIDXray_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxUUIDXray.Text); - } - - //复制额外ID到剪贴板 - private void TextBoxUUIDextraXray_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxUUIDextraXray.Text); - } - - //复制加密方式到剪贴板 - private void TextBoxEncryptionXray_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxEncryptionXray.Text); - } - - //复制传输协议到剪贴板 - private void TextBoxTransmissionXray_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxTransmissionXray.Text); - } - - //复制伪装方式到剪贴板 - private void TextBoxCamouflageTypeXray_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxCamouflageTypeXray.Text); - } - - //复制Host/Quic加密方法到剪贴板 - private void TextBoxHostQuicEncryptionXray_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxHostQuicEncryptionXray.Text); - } - - //复制Quic Key/mKCP Seed/路径Path 到剪贴板中 - private void TextBoxQuicKeyMkcpSeedPathXray_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxQuicKeyMkcpSeedPathXray.Text); - } - - //复制TLS 到剪贴板中 - private void TextBoxTLSXray_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxTLSXray.Text); - } - - #endregion - - #region Xray客户端生成 - //生成单方案v2rayN客户端导入文件 - private void GenerateXrayShareQRcodeAndBase64Url() - { - //生成v2rayN的json文件 - string v2rayNjsonFile = @" -{ - ""v"": """", - ""ps"": """", - ""add"": """", - ""port"": """", - ""id"": """", - ""aid"": """", - ""net"": """", - ""type"": """", - ""host"": """", - ""path"": """", - ""tls"": """" -}"; - //MessageBox.Show(v2rayNjsonFile); - JObject v2rayNjsonObject = JObject.Parse(v2rayNjsonFile); - v2rayNjsonObject["v"] = "2"; - v2rayNjsonObject["add"] = TextBoxHostAddressXray.Text; //设置域名 - v2rayNjsonObject["port"] = TextBoxPortXray.Text; //设置端口 - v2rayNjsonObject["id"] = TextBoxUUIDXray.Text; //设置uuid - v2rayNjsonObject["aid"] = TextBoxUUIDextraXray.Text; //设置额外ID - v2rayNjsonObject["net"] = TextBoxTransmissionXray.Text; //设置传输模式 - v2rayNjsonObject["type"] = TextBoxCamouflageTypeXray.Text; //设置伪装类型 - - if (TextBoxTransmissionXray.Text.Contains("kcp") == true) - { - v2rayNjsonObject["path"] = TextBoxQuicKeyMkcpSeedPathXray.Text;//设置mKCP Seed - v2rayNjsonObject["host"] = "";//设置Host - } - else if (TextBoxTransmissionXray.Text.Contains("quic") == true) - { - v2rayNjsonObject["path"] = TextBoxQuicKeyMkcpSeedPathXray.Text;//设置quic密钥 - v2rayNjsonObject["host"] = TextBoxHostQuicEncryptionXray.Text;//Quic加密方式 - } - else - { - v2rayNjsonObject["path"] = TextBoxQuicKeyMkcpSeedPathXray.Text; //设置路径 - v2rayNjsonObject["host"] = TextBoxHostQuicEncryptionXray.Text;//设置TLS的Host - } - - v2rayNjsonObject["tls"] = TextBoxTLSXray.Text; //设置是否启用TLS - v2rayNjsonObject["ps"] = v2rayNjsonObject["add"]; //设置备注 - //MessageBox.Show(v2rayNjsonObject["v"].ToString()); - //MessageBox.Show("step1"); - string proxyfolder = CheckDir("xray_config"); - //MessageBox.Show("step2"); - configDomainSavePath = CreateConfigSaveDir(proxyfolder, TextBoxHostAddressXray.Text); - //MessageBox.Show("step3"); - string configSavePath = configDomainSavePath; - - //生成二维码与URL,跳过VlessTcpTlsWeb暂时未有URL标准 - string vmessUrl = "vmess://" + ToBase64Encode(v2rayNjsonObject.ToString()); - TextBoxURL.Text = vmessUrl; - if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "VlessXtlsTcp") == false - && String.Equals(MainWindow.ReceiveConfigurationParameters[0], "VlessTcpTlsWeb") == false - && String.Equals(MainWindow.ReceiveConfigurationParameters[0], "VlessWebSocketTlsWeb") == false - && String.Equals(MainWindow.ReceiveConfigurationParameters[0], "VlessHttp2Web") == false - && MainWindow.mKCPvlessIsSet == false) - { - using (StreamWriter sw = new StreamWriter($"{configSavePath}\\url.txt")) - { - sw.WriteLine(vmessUrl); - } - ImageShareQRcode.Source = CreateQRCode(vmessUrl, $"{configSavePath}\\QR.bmp"); - } - - if (File.Exists(@"xray_config\config.json")) - { - File.Move(@"xray_config\config.json", $"{configSavePath}\\config.json"); - //File.Delete(@"config\config.json");//删除该文件 - } - - using (StreamWriter sw = new StreamWriter($"{configSavePath}\\readme.txt")) - { - ReadmeTxtWriteGenerateXray(sw); - - } - } - - #region VLESS VMESS XTLS WS共存方案生成链接与说明文件 - - //生成VLESS Vmess Tcp Xtls Ws 配置保存(暂未有分享链接与二维码) - private void GenerateXrayVlessVmessTcpXtlsWsShareQRcodeAndBase64Url(string plainSavePath) - { - #region 暂时不用内容 - // //生成v2rayN的json文件 - // string v2rayNjsonFile = @" - //{ - // ""v"": """", - // ""ps"": """", - // ""add"": """", - // ""port"": """", - // ""id"": """", - // ""aid"": """", - // ""net"": """", - // ""type"": """", - // ""host"": """", - // ""path"": """", - // ""tls"": """" - //}"; - // //MessageBox.Show(v2rayNjsonFile); - // JObject v2rayNjsonObject = JObject.Parse(v2rayNjsonFile); - // v2rayNjsonObject["v"] = "2"; - // v2rayNjsonObject["add"] = TextBoxHostAddress.Text; //设置域名 - // v2rayNjsonObject["port"] = TextBoxPort.Text; //设置端口 - // v2rayNjsonObject["id"] = TextBoxUUID.Text; //设置uuid - // v2rayNjsonObject["aid"] = TextBoxUUIDextra.Text; //设置额外ID - // v2rayNjsonObject["net"] = TextBoxTransmission.Text; //设置传输模式 - // v2rayNjsonObject["type"] = TextBoxCamouflageType.Text; //设置伪装类型 - - // if (TextBoxTransmission.Text.Contains("kcp") == true) - // { - // v2rayNjsonObject["path"] = TextBoxQuicKeyMkcpSeedPath.Text;//设置mKCP Seed - // } - // else if (TextBoxTransmission.Text.Contains("quic") == true) - // { - // v2rayNjsonObject["path"] = TextBoxQuicKeyMkcpSeedPath.Text;//设置quic密钥 - // v2rayNjsonObject["host"] = TextBoxHostQuicEncryption.Text;//Quic加密方式 - // } - // else - // { - // v2rayNjsonObject["path"] = TextBoxQuicKeyMkcpSeedPath.Text; //设置路径 - // v2rayNjsonObject["host"] = TextBoxHostQuicEncryption.Text;//设置TLS的Host - // } - - // v2rayNjsonObject["tls"] = TextBoxTLS.Text; //设置是否启用TLS - // v2rayNjsonObject["ps"] = v2rayNjsonObject["add"]; //设置备注 - // //MessageBox.Show(v2rayNjsonObject["v"].ToString()); - - //string saveFileFolderFirst = TextBoxHostAddress.Text; - //int num = 1; - //saveFileFolder = saveFileFolderFirst; - //CheckDir(@"v2ray_config"); - //while (Directory.Exists(@"v2ray_config\" + saveFileFolder)) - //{ - // saveFileFolder = saveFileFolderFirst + "_copy_" + num.ToString(); - // num++; - //} - //CheckDir(@"v2ray_config\" + saveFileFolder); - - #endregion - - //创建保存目录 - //string plainSavePath = @""; - - //v2ray_config\${域名IP}\vless_tcp_xtls_client_config - string configSavePath = CheckDir($"{configDomainSavePath}\\{plainSavePath}"); - - - //生成二维码与URL,跳过VlessTcpTlsWeb暂时未有URL标准 - //string vmessUrl = "vmess://" + ToBase64Encode(v2rayNjsonObject.ToString()); - //TextBoxURL.Text = vmessUrl; - //using (StreamWriter sw = new StreamWriter($"{configSavePath}\\url.txt")) - //{ - // if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "VlessTcpTlsWeb") == false) - // { - // sw.WriteLine(vmessUrl); - // } - //} - //if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "VlessTcpTlsWeb") == false) - //{ - // ImageShareQRcode.Source = CreateQRCode(vmessUrl, $"v2ray_config\\{saveFileFolder}\\QR.bmp"); - //} - - - if (File.Exists($"xray_config\\{plainSavePath}\\config.json")) - { - File.Move($"xray_config\\{plainSavePath}\\config.json", $"{configSavePath}\\config.json"); - Directory.Delete($"xray_config\\{plainSavePath}"); - } - - using (StreamWriter sw = new StreamWriter($"{configSavePath}\\readme.txt")) - { - sw.WriteLine("config.json"); - //****** "此文件为v2ray官方程序所使用的客户端配置文件,配置为全局模式,socks5地址:127.0.0.1:1080,http代理地址:127.0.0.1:1081" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtXrayExplainLine01").ToString()); - - //****** "v2ray官方网站:https://www.v2ray.com/" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtXrayExplainLine02").ToString()); - - //****** "v2ray官方程序下载地址:https://github.com/v2ray/v2ray-core/releases" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtXrayExplainLine03").ToString()); - - //****** "下载相应版本,Windows选择v2ray-windows-64.zip或者v2ray-windows-32.zip,解压后提取v2ctl.exe和v2ray.exe。与config.json放在同一目录,运行v2ray.exe即可。" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtXrayExplainLine04").ToString()); - - sw.WriteLine("-----------------------------------------"); - //sw.WriteLine("QR.bmp"); - - //****** "此文件为v2rayN、Qv2ray、v2rayNG(Android)、Shadowrocket(ios)扫码导入节点" ****** - //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine05").ToString()); - - //****** "v2rayN下载网址:https://github.com/2dust/v2rayN/releases" ****** - //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine06").ToString()); - - //****** "Qv2ray:https://github.com/Qv2ray/Qv2ray/releases" ****** - //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine07").ToString()); - - //****** "v2rayNG(Android)下载网址:https://github.com/2dust/v2rayNG/releases" ****** - //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine08").ToString()); - - //****** "v2rayNG(Android)在Google Play下载网址:https://play.google.com/store/apps/details?id=com.v2ray.ang" ****** - //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine09").ToString()); - - //****** "Shadowrocket(ios)下载,需要使用国外区的AppleID。请自行谷歌方法。" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine10").ToString()); - - //sw.WriteLine("-----------------------------------------"); - //sw.WriteLine("url.txt"); - - //****** "此文件为v2rayN、Qv2ray、v2rayNG(Android)、Shadowrocket(ios)复制粘贴导入节点的vmess网址" ****** - //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine11").ToString()); - - //写入通用配置参数 - TxtWriteGeneralParametersXray(sw); - } - } - - - //生成VLESS over TCP with XTLS的配置保存(暂未有分享链接与二维码) - private void GenerateXrayVlessTcpXtlsShareQRcodeAndBase64Url() - { - #region 暂时不用内容 - // //生成v2rayN的json文件 - // string v2rayNjsonFile = @" - //{ - // ""v"": """", - // ""ps"": """", - // ""add"": """", - // ""port"": """", - // ""id"": """", - // ""aid"": """", - // ""net"": """", - // ""type"": """", - // ""host"": """", - // ""path"": """", - // ""tls"": """" - //}"; - // //MessageBox.Show(v2rayNjsonFile); - // JObject v2rayNjsonObject = JObject.Parse(v2rayNjsonFile); - // v2rayNjsonObject["v"] = "2"; - // v2rayNjsonObject["add"] = TextBoxHostAddress.Text; //设置域名 - // v2rayNjsonObject["port"] = TextBoxPort.Text; //设置端口 - // v2rayNjsonObject["id"] = TextBoxUUID.Text; //设置uuid - // v2rayNjsonObject["aid"] = TextBoxUUIDextra.Text; //设置额外ID - // v2rayNjsonObject["net"] = TextBoxTransmission.Text; //设置传输模式 - // v2rayNjsonObject["type"] = TextBoxCamouflageType.Text; //设置伪装类型 - - // if (TextBoxTransmission.Text.Contains("kcp") == true) - // { - // v2rayNjsonObject["path"] = TextBoxQuicKeyMkcpSeedPath.Text;//设置mKCP Seed - // } - // else if (TextBoxTransmission.Text.Contains("quic") == true) - // { - // v2rayNjsonObject["path"] = TextBoxQuicKeyMkcpSeedPath.Text;//设置quic密钥 - // v2rayNjsonObject["host"] = TextBoxHostQuicEncryption.Text;//Quic加密方式 - // } - // else - // { - // v2rayNjsonObject["path"] = TextBoxQuicKeyMkcpSeedPath.Text; //设置路径 - // v2rayNjsonObject["host"] = TextBoxHostQuicEncryption.Text;//设置TLS的Host - // } - - // v2rayNjsonObject["tls"] = TextBoxTLS.Text; //设置是否启用TLS - // v2rayNjsonObject["ps"] = v2rayNjsonObject["add"]; //设置备注 - // //MessageBox.Show(v2rayNjsonObject["v"].ToString()); - - //string saveFileFolderFirst = TextBoxHostAddress.Text; - //int num = 1; - //saveFileFolder = saveFileFolderFirst; - //CheckDir(@"v2ray_config"); - //while (Directory.Exists(@"v2ray_config\" + saveFileFolder)) - //{ - // saveFileFolder = saveFileFolderFirst + "_copy_" + num.ToString(); - // num++; - //} - //CheckDir(@"v2ray_config\" + saveFileFolder); - - #endregion - - //创建保存目录 - string plainSavePath = @"vless_tcp_xtls_client_config"; - - //v2ray_config\${域名IP}\vless_tcp_xtls_client_config - string configSavePath = CheckDir($"{configDomainSavePath}\\{plainSavePath}"); - - - //生成二维码与URL,跳过VlessTcpTlsWeb暂时未有URL标准 - //TextBoxURLDefault = "vmess://" + ToBase64Encode(v2rayNjsonObject.ToString()); - //TextBoxURL.Text = TextBoxURLDefault; - //using (StreamWriter sw = new StreamWriter($"{configSavePath}\\url.txt")) - //{ - - // sw.WriteLine(TextBoxURLDefault); - - //} - - // ImageShareQRcodeDefault = CreateQRCode(TextBoxURLDefault, $"v2ray_config\\{saveFileFolder}\\QR.bmp"); - // ImageShareQRcode.Source = ImageShareQRcodeDefault; - - - if (File.Exists($"xray_config\\{plainSavePath}\\config.json")) - { - File.Move($"xray_config\\{plainSavePath}\\config.json", $"{configSavePath}\\config.json"); - Directory.Delete($"xray_config\\{plainSavePath}"); - } - - using (StreamWriter sw = new StreamWriter($"{configSavePath}\\readme.txt")) - { - sw.WriteLine("config.json"); - //****** "此文件为Xray官方程序所使用的客户端配置文件,配置为全局模式,socks5地址:127.0.0.1:1080,http代理地址:127.0.0.1:1081" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtXrayExplainLine01").ToString()); - - //****** "Xray官方网站:https://github.com/XTLS/Xray-core" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtXrayExplainLine02").ToString()); - - //****** "Xray官方程序下载地址:https://github.com/XTLS/Xray-core/releases" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtXrayExplainLine03").ToString()); - - //****** "下载相应版本,Windows选择xray-windows-64.zip或者xray-windows-32.zip,解压后提取xray.exe。与config.json放在同一目录,运行xray.exe即可。" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtXrayExplainLine04").ToString()); - - //sw.WriteLine("-----------------------------------------"); - //sw.WriteLine("QR.bmp"); - - //****** "此文件为v2rayN(windows)、Qv2ray(windows)、v2rayNG(Android)、Shadowrocket(ios)扫码导入节点" ****** - //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine05").ToString()); - - //****** "v2rayN下载网址:https://github.com/2dust/v2rayN/releases" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine06").ToString()); - - //****** "Qv2ray下载网址:https://github.com/Qv2ray/Qv2ray/releases" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine07").ToString()); - - //****** "v2rayNG(Android)下载网址:https://github.com/2dust/v2rayNG/releases" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine08").ToString()); - - //****** "v2rayNG(Android)在Google Play下载网址:https://play.google.com/store/apps/details?id=com.v2ray.ang" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine09").ToString()); - - //****** "Shadowrocket(ios)下载,需要使用国外区的AppleID。请自行谷歌方法。" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine10").ToString()); - - //sw.WriteLine("-----------------------------------------"); - //sw.WriteLine("url.txt"); - - //****** "此文件为v2rayN、Qv2ray、v2rayNG(Android)、Shadowrocket(ios)复制粘贴导入节点的vmess网址" ****** - //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine11").ToString()); - - //写入通用配置参数-- - TxtWriteGeneralParametersXray(sw, false); - - } - } - - //生成VLESS over TCP with TLS的配置保存(暂未有分享链接与二维码) - private void GenerateXrayVlessTcpTlsShareQRcodeAndBase64Url() - { - #region 暂时不用内容 - // //生成v2rayN的json文件 - // string v2rayNjsonFile = @" - //{ - // ""v"": """", - // ""ps"": """", - // ""add"": """", - // ""port"": """", - // ""id"": """", - // ""aid"": """", - // ""net"": """", - // ""type"": """", - // ""host"": """", - // ""path"": """", - // ""tls"": """" - //}"; - // //MessageBox.Show(v2rayNjsonFile); - // JObject v2rayNjsonObject = JObject.Parse(v2rayNjsonFile); - // v2rayNjsonObject["v"] = "2"; - // v2rayNjsonObject["add"] = TextBoxHostAddress.Text; //设置域名 - // v2rayNjsonObject["port"] = TextBoxPort.Text; //设置端口 - // v2rayNjsonObject["id"] = TextBoxUUID.Text; //设置uuid - // v2rayNjsonObject["aid"] = TextBoxUUIDextra.Text; //设置额外ID - // v2rayNjsonObject["net"] = TextBoxTransmission.Text; //设置传输模式 - // v2rayNjsonObject["type"] = TextBoxCamouflageType.Text; //设置伪装类型 - - // if (TextBoxTransmission.Text.Contains("kcp") == true) - // { - // v2rayNjsonObject["path"] = TextBoxQuicKeyMkcpSeedPath.Text;//设置mKCP Seed - // } - // else if (TextBoxTransmission.Text.Contains("quic") == true) - // { - // v2rayNjsonObject["path"] = TextBoxQuicKeyMkcpSeedPath.Text;//设置quic密钥 - // v2rayNjsonObject["host"] = TextBoxHostQuicEncryption.Text;//Quic加密方式 - // } - // else - // { - // v2rayNjsonObject["path"] = TextBoxQuicKeyMkcpSeedPath.Text; //设置路径 - // v2rayNjsonObject["host"] = TextBoxHostQuicEncryption.Text;//设置TLS的Host - // } - - // v2rayNjsonObject["tls"] = TextBoxTLS.Text; //设置是否启用TLS - // v2rayNjsonObject["ps"] = v2rayNjsonObject["add"]; //设置备注 - // //MessageBox.Show(v2rayNjsonObject["v"].ToString()); - - //string saveFileFolderFirst = TextBoxHostAddress.Text; - //int num = 1; - //saveFileFolder = saveFileFolderFirst; - //CheckDir(@"v2ray_config"); - //while (Directory.Exists(@"v2ray_config\" + saveFileFolder)) - //{ - // saveFileFolder = saveFileFolderFirst + "_copy_" + num.ToString(); - // num++; - //} - //CheckDir(@"v2ray_config\" + saveFileFolder); - - #endregion - - //创建保存目录 - string plainSavePath = @"vless_tcp_tls_client_config"; - //v2ray_config\${域名IP} - //string configDomainSavePath = CreateConfigSaveDir(@"v2ray_config", TextBoxHostAddressSS.Text); - //v2ray_config\${域名IP}\vless_tcp_xtls_client_config - string configSavePath = CheckDir($"{configDomainSavePath}\\{plainSavePath}"); - - - //生成二维码与URL,跳过VlessTcpTlsWeb暂时未有URL标准 - //TextBoxURLVlessTcp = "vmess://" + ToBase64Encode(v2rayNjsonObject.ToString()); - //TextBoxURL.Text = TextBoxURLVlessTcp; - //using (StreamWriter sw = new StreamWriter($"{configSavePath}\\url.txt")) - //{ - - // sw.WriteLine(TextBoxURLVlessTcp); - - //} - - // ImageShareQRcodeVlessTcp = CreateQRCode(TextBoxURLVlessTcp, $"v2ray_config\\{saveFileFolder}\\QR.bmp"); - // ImageShareQRcode.Source = ImageShareQRcodeVlessTcp; - - - if (File.Exists($"xray_config\\{plainSavePath}\\config.json")) - { - File.Move($"xray_config\\{plainSavePath}\\config.json", $"{configSavePath}\\config.json"); - Directory.Delete($"xray_config\\{plainSavePath}"); - } - - using (StreamWriter sw = new StreamWriter($"{configSavePath}\\readme.txt")) - { - sw.WriteLine("config.json"); - //****** "此文件为Xray官方程序所使用的客户端配置文件,配置为全局模式,socks5地址:127.0.0.1:1080,http代理地址:127.0.0.1:1081" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtXrayExplainLine01").ToString()); - - //****** "Xray官方网站:https://github.com/XTLS/Xray-core" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtXrayExplainLine02").ToString()); - - //****** "Xray官方程序下载地址:https://github.com/XTLS/Xray-core/releases" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtXrayExplainLine03").ToString()); - - //****** "下载相应版本,Windows选择xray-windows-64.zip或者xray-windows-32.zip,解压后提取v2ray.exe。与config.json放在同一目录,运行xray.exe即可。" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtXrayExplainLine04").ToString()); - - //sw.WriteLine("-----------------------------------------"); - //sw.WriteLine("QR.bmp"); - - //****** "此文件为v2rayN(windows)、Qv2ray(windows)、v2rayNG(Android)、Shadowrocket(ios)扫码导入节点" ****** - //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine05").ToString()); - - //****** "v2rayN下载网址:https://github.com/2dust/v2rayN/releases" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine06").ToString()); - - //****** "Qv2ray下载网址:https://github.com/Qv2ray/Qv2ray/releases" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine07").ToString()); - - //****** "v2rayNG(Android)下载网址:https://github.com/2dust/v2rayNG/releases" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine08").ToString()); - - //****** "v2rayNG(Android)在Google Play下载网址:https://play.google.com/store/apps/details?id=com.v2ray.ang" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine09").ToString()); - - //****** "Shadowrocket(ios)下载,需要使用国外区的AppleID。请自行谷歌方法。" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine10").ToString()); - - //sw.WriteLine("-----------------------------------------"); - //sw.WriteLine("url.txt"); - - //****** "此文件为v2rayN、Qv2ray、v2rayNG(Android)、Shadowrocket(ios)复制粘贴导入节点的vmess网址" ****** - //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine11").ToString()); - - //写入通用配置参数-- - TxtWriteGeneralParametersXray(sw, false); - - } - } - - //生成VLESS over WS with TLS的配置保存(暂未有分享链接与二维码) - private void GenerateXrayVlessWsTlsShareQRcodeAndBase64Url() - { - #region 暂时不用内容 - // //生成v2rayN的json文件 - // string v2rayNjsonFile = @" - //{ - // ""v"": """", - // ""ps"": """", - // ""add"": """", - // ""port"": """", - // ""id"": """", - // ""aid"": """", - // ""net"": """", - // ""type"": """", - // ""host"": """", - // ""path"": """", - // ""tls"": """" - //}"; - // //MessageBox.Show(v2rayNjsonFile); - // JObject v2rayNjsonObject = JObject.Parse(v2rayNjsonFile); - // v2rayNjsonObject["v"] = "2"; - // v2rayNjsonObject["add"] = TextBoxHostAddress.Text; //设置域名 - // v2rayNjsonObject["port"] = TextBoxPort.Text; //设置端口 - // v2rayNjsonObject["id"] = TextBoxUUID.Text; //设置uuid - // v2rayNjsonObject["aid"] = TextBoxUUIDextra.Text; //设置额外ID - // v2rayNjsonObject["net"] = TextBoxTransmission.Text; //设置传输模式 - // v2rayNjsonObject["type"] = TextBoxCamouflageType.Text; //设置伪装类型 - - // if (TextBoxTransmission.Text.Contains("kcp") == true) - // { - // v2rayNjsonObject["path"] = TextBoxQuicKeyMkcpSeedPath.Text;//设置mKCP Seed - // } - // else if (TextBoxTransmission.Text.Contains("quic") == true) - // { - // v2rayNjsonObject["path"] = TextBoxQuicKeyMkcpSeedPath.Text;//设置quic密钥 - // v2rayNjsonObject["host"] = TextBoxHostQuicEncryption.Text;//Quic加密方式 - // } - // else - // { - // v2rayNjsonObject["path"] = TextBoxQuicKeyMkcpSeedPath.Text; //设置路径 - // v2rayNjsonObject["host"] = TextBoxHostQuicEncryption.Text;//设置TLS的Host - // } - - // v2rayNjsonObject["tls"] = TextBoxTLS.Text; //设置是否启用TLS - // v2rayNjsonObject["ps"] = v2rayNjsonObject["add"]; //设置备注 - // //MessageBox.Show(v2rayNjsonObject["v"].ToString()); - - //string saveFileFolderFirst = TextBoxHostAddress.Text; - //int num = 1; - //saveFileFolder = saveFileFolderFirst; - //CheckDir(@"v2ray_config"); - //while (Directory.Exists(@"v2ray_config\" + saveFileFolder)) - //{ - // saveFileFolder = saveFileFolderFirst + "_copy_" + num.ToString(); - // num++; - //} - //CheckDir(@"v2ray_config\" + saveFileFolder); - - #endregion - - //创建保存目录 - string plainSavePath = @"vless_ws_tls_client_config"; - //v2ray_config\${域名IP} - //string configDomainSavePath = CreateConfigSaveDir(@"v2ray_config", TextBoxHostAddressSS.Text); - //v2ray_config\${域名IP}\vless_tcp_xtls_client_config - string configSavePath = CheckDir($"{configDomainSavePath}\\{plainSavePath}"); - - - //生成二维码与URL,跳过VlessTcpTlsWeb暂时未有URL标准 - //TextBoxURLVlessWs = "vmess://" + ToBase64Encode(v2rayNjsonObject.ToString()); - //TextBoxURL.Text = TextBoxURLVlessWs; - //using (StreamWriter sw = new StreamWriter($"{configSavePath}\\url.txt")) - //{ - - // sw.WriteLine(TextBoxURLVlessWs); - - //} - - // ImageShareQRcodeVlessWs = CreateQRCode(TextBoxURLVlessWs, $"v2ray_config\\{saveFileFolder}\\QR.bmp"); - //ImageShareQRcode.Source = ImageShareQRcodeVlessWs; - - - if (File.Exists($"xray_config\\{plainSavePath}\\config.json")) - { - File.Move($"xray_config\\{plainSavePath}\\config.json", $"{configSavePath}\\config.json"); - Directory.Delete($"xray_config\\{plainSavePath}"); - } - - using (StreamWriter sw = new StreamWriter($"{configSavePath}\\readme.txt")) - { - sw.WriteLine("config.json"); - //****** "此文件为Xray官方程序所使用的客户端配置文件,配置为全局模式,socks5地址:127.0.0.1:1080,http代理地址:127.0.0.1:1081" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtXrayExplainLine01").ToString()); - - //****** "Xray官方网站:https://github.com/XTLS/Xray-core" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtXrayExplainLine02").ToString()); - - //****** "Xray官方程序下载地址:https://github.com/XTLS/Xray-core/releases" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtXrayExplainLine03").ToString()); - - //****** "下载相应版本,Windows选择xray-windows-64.zip或者xray-windows-32.zip,解压后提取v2ray.exe。与config.json放在同一目录,运行xray.exe即可。" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtXrayExplainLine04").ToString()); - - //sw.WriteLine("-----------------------------------------"); - //sw.WriteLine("QR.bmp"); - - //****** "此文件为v2rayN(windows)、Qv2ray(windows)、v2rayNG(Android)、Shadowrocket(ios)扫码导入节点" ****** - //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine05").ToString()); - - //****** "v2rayN下载网址:https://github.com/2dust/v2rayN/releases" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine06").ToString()); - - //****** "Qv2ray下载网址:https://github.com/Qv2ray/Qv2ray/releases" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine07").ToString()); - - //****** "v2rayNG(Android)下载网址:https://github.com/2dust/v2rayNG/releases" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine08").ToString()); - - //****** "v2rayNG(Android)在Google Play下载网址:https://play.google.com/store/apps/details?id=com.v2ray.ang" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine09").ToString()); - - //****** "Shadowrocket(ios)下载,需要使用国外区的AppleID。请自行谷歌方法。" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine10").ToString()); - - //sw.WriteLine("-----------------------------------------"); - //sw.WriteLine("url.txt"); - - //****** "此文件为v2rayN、Qv2ray、v2rayNG(Android)、Shadowrocket(ios)复制粘贴导入节点的vmess网址" ****** - //sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine11").ToString()); - - //写入通用配置参数-- - TxtWriteGeneralParametersXray(sw, false); - - } - } - - //生成VMess over TCP with TLS的配置保存 - private void GenerateXrayVmessTcpTlsShareQRcodeAndBase64Url() - { - #region 暂时不用内容 - //生成v2rayN的json文件 - string v2rayNjsonFile = @" -{ - ""v"": """", - ""ps"": """", - ""add"": """", - ""port"": """", - ""id"": """", - ""aid"": """", - ""net"": """", - ""type"": """", - ""host"": """", - ""path"": """", - ""tls"": """" -}"; - //MessageBox.Show(v2rayNjsonFile); - JObject v2rayNjsonObject = JObject.Parse(v2rayNjsonFile); - v2rayNjsonObject["v"] = "2"; - v2rayNjsonObject["add"] = TextBoxHostAddressXray.Text; //设置域名 - v2rayNjsonObject["port"] = TextBoxPortXray.Text; //设置端口 - v2rayNjsonObject["id"] = TextBoxUUIDXray.Text; //设置uuid - v2rayNjsonObject["aid"] = TextBoxUUIDextraXray.Text; //设置额外ID - v2rayNjsonObject["net"] = TextBoxTransmissionXray.Text; //设置传输模式 - v2rayNjsonObject["type"] = TextBoxCamouflageTypeXray.Text; //设置伪装类型 - - if (TextBoxTransmissionXray.Text.Contains("kcp") == true) - { - v2rayNjsonObject["path"] = TextBoxQuicKeyMkcpSeedPathXray.Text;//设置mKCP Seed - v2rayNjsonObject["host"] = "";//设置Host - } - else if (TextBoxTransmissionXray.Text.Contains("quic") == true) - { - v2rayNjsonObject["path"] = TextBoxQuicKeyMkcpSeedPathXray.Text;//设置quic密钥 - v2rayNjsonObject["host"] = TextBoxHostQuicEncryptionXray.Text;//Quic加密方式 - } - else - { - v2rayNjsonObject["path"] = TextBoxQuicKeyMkcpSeedPathXray.Text; //设置路径 - v2rayNjsonObject["host"] = TextBoxHostQuicEncryptionXray.Text;//设置TLS的Host - } - - v2rayNjsonObject["tls"] = TextBoxTLSXray.Text; //设置是否启用TLS - v2rayNjsonObject["ps"] = v2rayNjsonObject["add"]; //设置备注 - - - #endregion - - //创建保存目录 - string plainSavePath = @"vmess_tcp_tls_client_config"; - //v2ray_config\${域名IP} - //string configDomainSavePath = CreateConfigSaveDir(@"v2ray_config", TextBoxHostAddressSS.Text); - //v2ray_config\${域名IP}\vless_tcp_xtls_client_config - string configSavePath = CheckDir($"{configDomainSavePath}\\{plainSavePath}"); - - - //生成二维码与URL,跳过VlessTcpTlsWeb暂时未有URL标准 - TextBoxURLVmessTcp = "vmess://" + ToBase64Encode(v2rayNjsonObject.ToString()); - //TextBoxURL.Text = TextBoxURLVmessTcp; - using (StreamWriter sw = new StreamWriter($"{configSavePath}\\url.txt")) - { - sw.WriteLine(TextBoxURLVmessTcp); - } - - ImageShareQRcodeVmessTcp = CreateQRCode(TextBoxURLVmessTcp, $"{configSavePath}\\QR.bmp"); - //ImageShareQRcode.Source = ImageShareQRcodeVmessTcp; - - - if (File.Exists($"xray_config\\{plainSavePath}\\config.json")) - { - File.Move($"xray_config\\{plainSavePath}\\config.json", $"{configSavePath}\\config.json"); - Directory.Delete($"xray_config\\{plainSavePath}"); - } - - using (StreamWriter sw = new StreamWriter($"{configSavePath}\\readme.txt")) - { - ReadmeTxtWriteGenerateXray(sw); - - } - } - - //生成VMess over WS with TLS的配置保存 - private void GenerateXrayVmessWsTlsShareQRcodeAndBase64Url() - { - #region 暂时不用内容 - //生成v2rayN的json文件 - string v2rayNjsonFile = @" -{ - ""v"": """", - ""ps"": """", - ""add"": """", - ""port"": """", - ""id"": """", - ""aid"": """", - ""net"": """", - ""type"": """", - ""host"": """", - ""path"": """", - ""tls"": """" -}"; - //MessageBox.Show(v2rayNjsonFile); - JObject v2rayNjsonObject = JObject.Parse(v2rayNjsonFile); - v2rayNjsonObject["v"] = "2"; - v2rayNjsonObject["add"] = TextBoxHostAddressXray.Text; //设置域名 - v2rayNjsonObject["port"] = TextBoxPortXray.Text; //设置端口 - v2rayNjsonObject["id"] = TextBoxUUIDXray.Text; //设置uuid - v2rayNjsonObject["aid"] = TextBoxUUIDextraXray.Text; //设置额外ID - v2rayNjsonObject["net"] = TextBoxTransmissionXray.Text; //设置传输模式 - v2rayNjsonObject["type"] = TextBoxCamouflageTypeXray.Text; //设置伪装类型 - - if (TextBoxTransmissionXray.Text.Contains("kcp") == true) - { - v2rayNjsonObject["path"] = TextBoxQuicKeyMkcpSeedPathXray.Text;//设置mKCP Seed - } - else if (TextBoxTransmissionXray.Text.Contains("quic") == true) - { - v2rayNjsonObject["path"] = TextBoxQuicKeyMkcpSeedPathXray.Text;//设置quic密钥 - v2rayNjsonObject["host"] = TextBoxHostQuicEncryptionXray.Text;//Quic加密方式 - } - else - { - v2rayNjsonObject["path"] = TextBoxQuicKeyMkcpSeedPathXray.Text; //设置路径 - v2rayNjsonObject["host"] = TextBoxHostQuicEncryptionXray.Text;//设置TLS的Host - } - - v2rayNjsonObject["tls"] = "tls"; //设置是否启用TLS - v2rayNjsonObject["ps"] = v2rayNjsonObject["add"]; //设置备注 - - #endregion - - //创建保存目录 - string plainSavePath = @"vmess_ws_tls_client_config"; - //v2ray_config\${域名IP} - //string configDomainSavePath = CreateConfigSaveDir(@"v2ray_config", TextBoxHostAddressSS.Text); - //v2ray_config\${域名IP}\vless_tcp_xtls_client_config - string configSavePath = CheckDir($"{configDomainSavePath}\\{plainSavePath}"); - - - //生成二维码与URL - TextBoxURLVmessWs = "vmess://" + ToBase64Encode(v2rayNjsonObject.ToString()); - //TextBoxURL.Text = TextBoxURLVmessWs; - using (StreamWriter sw = new StreamWriter($"{configSavePath}\\url.txt")) - { - sw.WriteLine(TextBoxURLVmessWs); - } - - ImageShareQRcodeVmessWs = CreateQRCode(TextBoxURLVmessWs, $"{configSavePath}\\QR.bmp"); - //ImageShareQRcode.Source = ImageShareQRcodeVmessWs; - - if (File.Exists($"xray_config\\{plainSavePath}\\config.json")) - { - File.Move($"xray_config\\{plainSavePath}\\config.json", $"{configSavePath}\\config.json"); - Directory.Delete($"xray_config\\{plainSavePath}"); - } - - using (StreamWriter sw = new StreamWriter($"{configSavePath}\\readme.txt")) - { - ReadmeTxtWriteGenerateXray(sw); - - } - } - - //生成Trojan over TCP with TLS的配置保存 - private void GenerateXrayTrojanShareQRcodeAndBase64Url() - { - //创建保存目录 - string plainSavePath = @"trojan_tcp_tls_client_config"; - string configSavePath = CheckDir($"{configDomainSavePath}\\{plainSavePath}"); - - TextBoxURLTrojanTcp = $"trojan://{TextBoxUUIDXray.Text}@{TextBoxHostAddressXray.Text}:{TextBoxPortXray.Text}#{TextBoxHostAddressXray.Text}"; - - //TextBoxURL.Text = TextBoxURLTrojanTcp; - using (StreamWriter sw = new StreamWriter($"{configSavePath}\\url.txt")) - { - sw.WriteLine(TextBoxURLTrojanTcp); - - } - //ImageShareQRcode.Source = CreateQRCode(TextBoxURLTrojanTcp, $"{configSavePath}\\QR.bmp"); - ImageShareQRcodeTrojanTcp = CreateQRCode(TextBoxURLTrojanTcp, $"{configSavePath}\\QR.bmp"); - //ImageShareQRcode.Source = ImageShareQRcodeTrojanTcp; - //移动官方程序配置文件到相应目录 - if (File.Exists($"xray_config\\{plainSavePath}\\config.json")) - { - File.Move($"xray_config\\{plainSavePath}\\config.json", $"{configSavePath}\\config.json"); - Directory.Delete($"xray_config\\{plainSavePath}"); - } - - using (StreamWriter sw = new StreamWriter($"{configSavePath}\\readme.txt")) - { - //ReadmeTxtWriteGenerate(sw); - sw.WriteLine("config.json"); - //****** "此文件为Xray官方程序所使用的客户端配置文件,配置为全局模式,socks5地址:127.0.0.1:1080,http代理地址:127.0.0.1:1081" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtXrayExplainLine01").ToString()); - - //****** "Xray官方网站:https://github.com/XTLS/Xray-core" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtXrayExplainLine02").ToString()); - - //****** "Xray官方程序下载地址:https://github.com/XTLS/Xray-core/releases" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtXrayExplainLine03").ToString()); - - //****** "下载相应版本,Windows选择Xray-windows-64.zip或者Xray-windows-32.zip,解压后提取v2ctl.exe和v2ray.exe。与config.json放在同一目录,运行v2ray.exe即可。" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtXrayExplainLine04").ToString()); - - sw.WriteLine("-----------------------------------------"); - sw.WriteLine("QR.bmp"); - - //****** "此文件为v2rayN(windows)、Qv2ray(windows)、v2rayNG(Android)、Shadowrocket(ios)扫码导入节点" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine05").ToString()); - - //****** "v2rayN下载网址:https://github.com/2dust/v2rayN/releases" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine06").ToString()); - - //****** "Qv2ray下载网址:https://github.com/Qv2ray/Qv2ray/releases" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine07").ToString()); - - //****** "v2rayNG(Android)下载网址:https://github.com/2dust/v2rayNG/releases" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine08").ToString()); - - //****** "v2rayNG(Android)在Google Play下载网址:https://play.google.com/store/apps/details?id=com.v2ray.ang" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine09").ToString()); - - //****** "Shadowrocket(ios)下载,需要使用国外区的AppleID。请自行谷歌方法。" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine10").ToString()); - - sw.WriteLine("-----------------------------------------"); - sw.WriteLine("url.txt"); - - //****** "此文件为v2rayN、Qv2ray、v2rayNG(Android)、Shadowrocket(ios)复制粘贴导入节点的vmess网址" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine11").ToString()); - - sw.WriteLine("-----------------------------------------\n"); - - string strApplicat = ""; - string strParam = ""; - int strLenth = 20; - //****** "服务器通用连接配置参数:" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine12").ToString()); - sw.WriteLine(""); - - strApplicat = "TextBlockServerAddress"; - strParam = TextBoxHostAddressXray.Text; - sw.WriteLine(AlignmentStrFunc(Application.Current.FindResource($"{strApplicat}").ToString(), strLenth) + strParam); - - strApplicat = "TextBlockServerPort"; - strParam = TextBoxPortXray.Text; - sw.WriteLine(AlignmentStrFunc(Application.Current.FindResource($"{strApplicat}").ToString(), strLenth) + strParam); - - strApplicat = "TextBlockUserUUID"; - strParam = TextBoxUUIDXray.Text; - sw.WriteLine(AlignmentStrFunc(Application.Current.FindResource($"{strApplicat}").ToString(), strLenth) + strParam); - - } - - } - - //写入VMESS的readme.txt文件 - private void ReadmeTxtWriteGenerateXray(StreamWriter sw) - { - sw.WriteLine("config.json"); - //****** "此文件为Xray官方程序所使用的客户端配置文件,配置为全局模式,socks5地址:127.0.0.1:1080,http代理地址:127.0.0.1:1081" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtXrayExplainLine01").ToString()); - - //****** "Xray官方网站:https://github.com/XTLS/Xray-core" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtXrayExplainLine02").ToString()); - - //****** "Xray官方程序下载地址:https://github.com/XTLS/Xray-core/releases" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtXrayExplainLine03").ToString()); - - //****** "下载相应版本,Windows选择xray-windows-64.zip或者xray-windows-32.zip,解压后提取xray.exe。与config.json放在同一目录,运行xray.exe即可。" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtXrayExplainLine04").ToString()); - - sw.WriteLine("-----------------------------------------"); - sw.WriteLine("QR.bmp"); - - //****** "此文件为v2rayN(windows)、Qv2ray(windows)、v2rayNG(Android)、Shadowrocket(ios)扫码导入节点" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine05").ToString()); - - //****** "v2rayN下载网址:https://github.com/2dust/v2rayN/releases" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine06").ToString()); - - //****** "Qv2ray下载网址:https://github.com/Qv2ray/Qv2ray/releases" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine07").ToString()); - - //****** "v2rayNG(Android)下载网址:https://github.com/2dust/v2rayNG/releases" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine08").ToString()); - - //****** "v2rayNG(Android)在Google Play下载网址:https://play.google.com/store/apps/details?id=com.v2ray.ang" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine09").ToString()); - - //****** "Shadowrocket(ios)下载,需要使用国外区的AppleID。请自行谷歌方法。" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine10").ToString()); - - sw.WriteLine("-----------------------------------------"); - sw.WriteLine("url.txt"); - - //****** "此文件为v2rayN、Qv2ray、v2rayNG(Android)、Shadowrocket(ios)复制粘贴导入节点的vmess网址" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine11").ToString()); - - //写入通用配置参数 - TxtWriteGeneralParametersXray(sw); - } - //TXT文件中写入通用配置参数--- - private void TxtWriteGeneralParametersXray(StreamWriter sw, bool alterId = true) - { - sw.WriteLine("-----------------------------------------\n"); - - string strApplicat = ""; - string strParam = ""; - int strLenth = 20; - //****** "服务器通用连接配置参数:" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtV2RayExplainLine12").ToString()); - sw.WriteLine(""); - - strApplicat = "TextBlockServerAddress"; - strParam = TextBoxHostAddressXray.Text; - sw.WriteLine(AlignmentStrFunc(Application.Current.FindResource($"{strApplicat}").ToString(), strLenth) + strParam); - - strApplicat = "TextBlockServerPort"; - strParam = TextBoxPortXray.Text; - sw.WriteLine(AlignmentStrFunc(Application.Current.FindResource($"{strApplicat}").ToString(), strLenth) + strParam); - - strApplicat = "TextBlockUserUUID"; - strParam = TextBoxUUIDXray.Text; - sw.WriteLine(AlignmentStrFunc(Application.Current.FindResource($"{strApplicat}").ToString(), strLenth) + strParam); - - if (alterId == true) - { - strApplicat = "TextBlockV2RayAlterId"; - strParam = TextBoxUUIDextraXray.Text; - sw.WriteLine(AlignmentStrFunc(Application.Current.FindResource($"{strApplicat}").ToString(), strLenth) + strParam); - } - - strApplicat = "TextBlockEncryption"; - strParam = TextBoxEncryptionXray.Text; - sw.WriteLine(AlignmentStrFunc(Application.Current.FindResource($"{strApplicat}").ToString(), strLenth) + strParam); - - strApplicat = "TextBlockTransferProtocol"; - strParam = TextBoxTransmissionXray.Text; - sw.WriteLine(AlignmentStrFunc(Application.Current.FindResource($"{strApplicat}").ToString(), strLenth) + strParam); - - strApplicat = "TextBlockCamouflageType"; - strParam = TextBoxCamouflageTypeXray.Text; - sw.WriteLine(AlignmentStrFunc(Application.Current.FindResource($"{strApplicat}").ToString(), strLenth) + strParam); - - strApplicat = "TextBlockIsOrNotTLS"; - strParam = TextBoxTLSXray.Text; - sw.WriteLine(AlignmentStrFunc(Application.Current.FindResource($"{strApplicat}").ToString(), strLenth) + strParam); - - if (MainWindow.ReceiveConfigurationParameters[0].Contains("Quic") == true) - { - strParam = TextBoxHostQuicEncryptionXray.Text; - sw.WriteLine(AlignmentStrFunc(TextBlockQuicEncryptionXray.Text, strLenth) + strParam); - - strParam = TextBoxQuicKeyMkcpSeedPathXray.Text; - sw.WriteLine(AlignmentStrFunc(TextBlockQuicKeyXray.Text, strLenth) + strParam); - - } - else if (MainWindow.ReceiveConfigurationParameters[0].Contains("mKCP") == true) - { - strParam = TextBoxHostQuicEncryptionXray.Text; - sw.WriteLine(AlignmentStrFunc("host:", strLenth) + strParam); - - strParam = TextBoxQuicKeyMkcpSeedPathXray.Text; - sw.WriteLine(AlignmentStrFunc(TextBlockMkcpSeedXray.Text, strLenth) + strParam); - - } - else - { - strParam = TextBoxHostQuicEncryptionXray.Text; - sw.WriteLine(AlignmentStrFunc("host:", strLenth) + strParam); - - strParam = TextBoxQuicKeyMkcpSeedPathXray.Text; - sw.WriteLine(AlignmentStrFunc(TextBlockPathXray.Text, strLenth) + strParam); - } - } - #endregion - - #endregion - - #endregion - - #region TrojanGo 相关 - //生成TrojanGo客户端资料 - private void GenerateTrojanGoShareQRcodeAndBase64Url() - { - string proxyfolder = CheckDir("trojan-go_config"); - configDomainSavePath = CreateConfigSaveDir(proxyfolder, TextBoxTrojanGoServerHost.Text); - string configSavePath = configDomainSavePath; - - string trojanGoUrl = GetTrojanGoUrl(); - - TextBoxURL.Text = trojanGoUrl; - using (StreamWriter sw = new StreamWriter($"{configSavePath}\\url.txt")) - { - sw.WriteLine(trojanGoUrl); - - } - ImageShareQRcode.Source = CreateQRCode(trojanGoUrl, $"{configSavePath}\\QR.bmp"); - - //移动Trojan官方程序配置文件到相应目录 - if (File.Exists(@"trojan-go_config\config.json")) - { - File.Move(@"trojan-go_config\config.json", $"{configSavePath}\\config.json"); - //File.Delete(@"config\config.json");//删除该文件 - } - - using (StreamWriter sw = new StreamWriter($"{configSavePath}\\readme.txt")) - { - sw.WriteLine("config.json"); - - //****** "此文件为Trojan-go官方程序所使用的客户端配置文件,配置为全局模式,http与socks5地址:127.0.0.1:1080" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtTrojan-goExplainLine01").ToString()); - - //****** "Trojan-go官方网站:https://github.com/p4gefau1t/trojan-go" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtTrojan-goExplainLine02").ToString()); - - //sw.WriteLine("Trojan-go官方程序下载地址:https://github.com/p4gefau1t/trojan-go/releases"); - sw.WriteLine(Application.Current.FindResource("readmeTxtTrojan-goExplainLine03").ToString()); - - //sw.WriteLine("下载相应版本,Windows选择Trojan-go-x.xx-win.zip,解压后提取trojan-go.exe。与config.json放在同一目录,运行trojan-go.exe即可。"); - sw.WriteLine(Application.Current.FindResource("readmeTxtTrojan-goExplainLine04").ToString()); - - sw.WriteLine("-----------------------------------------\n"); - sw.WriteLine("QR.bmp"); - - //sw.WriteLine("此文件为Qv2ray (windows)、igniter(Android)扫码导入节点"); - sw.WriteLine(Application.Current.FindResource("readmeTxtTrojan-goExplainLine05").ToString()); - - //sw.WriteLine("Qv2ray (windows)下载网址:https://github.com/Qv2ray/Qv2ray/releases"); - sw.WriteLine(Application.Current.FindResource("readmeTxtTrojan-goExplainLine06").ToString()); - - //sw.WriteLine("igniter(Android)下载网址:https://github.com/trojan-gfw/igniter/releases"); - sw.WriteLine(Application.Current.FindResource("readmeTxtTrojan-goExplainLine07").ToString()); - - //sw.WriteLine("Shadowrocket(ios)下载,需要使用国外区的AppleID。请自行谷歌方法。"); - // sw.WriteLine(Application.Current.FindResource("readmeTxtTrojan-goExplainLine08").ToString()); - sw.WriteLine("-----------------------------------------\n"); - sw.WriteLine("url.txt"); - - //sw.WriteLine("此文件为Qv2ray (windows)、igniter(Android)复制粘贴导入节点的网址"); - sw.WriteLine(Application.Current.FindResource("readmeTxtTrojan-goExplainLine09").ToString()); - sw.WriteLine("-----------------------------------------\n"); - - string strApplicat = ""; - string strParam = ""; - int strLenth = 20; - - //sw.WriteLine("服务器通用连接配置参数"); - sw.WriteLine(Application.Current.FindResource("readmeTxtTrojan-goExplainLine10").ToString()); - sw.WriteLine(""); - - //****** 服务器地址(address): ****** - //sw.WriteLine(Application.Current.FindResource("TextBlockServerAddress").ToString() + $"{TextBoxTrojanGoServerHost.Text}"); - strApplicat = "TextBlockServerAddress"; - strParam = TextBoxTrojanGoServerHost.Text; - sw.WriteLine(AlignmentStrFunc(Application.Current.FindResource($"{strApplicat}").ToString(), strLenth) + strParam); - - //****** 端口(port): ****** - //sw.WriteLine(Application.Current.FindResource("TextBlockServerPort").ToString() + $"{TextBoxTrojanGoServerPort.Text}"); - strApplicat = "TextBlockServerPort"; - strParam = TextBoxTrojanGoServerPort.Text; - sw.WriteLine(AlignmentStrFunc(Application.Current.FindResource($"{strApplicat}").ToString(), strLenth) + strParam); - - //****** 密码: ****** - //sw.WriteLine(Application.Current.FindResource("TextBlockTrojanGoPassword").ToString() + $"{TextBoxTrojanGoServerPassword.Text}"); - strApplicat = "TextBlockTrojanGoPassword"; - strParam = TextBoxTrojanGoServerPassword.Text; - sw.WriteLine(AlignmentStrFunc(Application.Current.FindResource($"{strApplicat}").ToString(), strLenth) + strParam); - - //****** Type: ****** - //sw.WriteLine(Application.Current.FindResource("TextBlockTrojanGoPassword").ToString() + $"{TextBoxTrojanGoServerPassword.Text}"); - //strApplicat = "TextBlockTrojanGoPassword"; - strParam = TextBoxTrojanGoType.Text; - sw.WriteLine(AlignmentStrFunc("Type:", strLenth) + strParam); - //sw.WriteLine(AlignmentStrFunc(Application.Current.FindResource($"{strApplicat}").ToString(), strLenth) + strParam); - - //****** WebSocket路径: ****** - //sw.WriteLine(Application.Current.FindResource("TextBlockTrojanGoWebSocketPath").ToString() + $"{TextBoxTrojanGoWSPath.Text}"); - strApplicat = "TextBlockTrojanGoWebSocketPath"; - strParam = TextBoxTrojanGoWSPath.Text; - sw.WriteLine(AlignmentStrFunc(Application.Current.FindResource($"{strApplicat}").ToString(), strLenth) + strParam); - - //****** Mux多路复用 ****** - //sw.WriteLine(Application.Current.FindResource("TextBlockTrojanGoWebSocketPath").ToString() + $"{TextBoxTrojanGoWSPath.Text}"); - strApplicat = "CheckBoxMuxSelect"; - strParam = ":"; - sw.WriteLine(AlignmentStrFunc(Application.Current.FindResource($"{strApplicat}").ToString(), strLenth) + strParam); - - //****** concurrency: ****** - //sw.WriteLine(Application.Current.FindResource("TextBlockTrojanGoWebSocketPath").ToString() + $"{TextBoxTrojanGoWSPath.Text}"); - strApplicat = "concurrency:"; - strParam = TextBoxConcurrency.Text; - sw.WriteLine(AlignmentStrFunc(strApplicat, strLenth) + strParam); - - //****** idle_timeout: ****** - //sw.WriteLine(Application.Current.FindResource("TextBlockTrojanGoWebSocketPath").ToString() + $"{TextBoxTrojanGoWSPath.Text}"); - strApplicat = "idle_timeout:"; - strParam = TextBoxIdle_timeout.Text; - sw.WriteLine(AlignmentStrFunc(strApplicat, strLenth) + strParam); - - } - - } - - #region TrojanGo内容双击复制到剪贴板 - private void TextBoxTrojanGoServerHost_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxTrojanGoServerHost.Text); - } - - private void TextBoxTrojanGoServerPort_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxTrojanGoServerPort.Text); - } - - private void TextBoxTrojanGoServerPassword_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxTrojanGoServerPassword.Text); - } - private void TextBoxTrojanGoSNI_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxTrojanGoSNI.Text); - } - private void TextBoxTrojanGoType_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxTrojanGoType.Text); - } - private void TextBoxTrojanGoHost_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxTrojanGoHost.Text); - } - private void TextBoxTrojanGoWSPath_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxTrojanGoWSPath.Text); - } - private void TextBoxConcurrency_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxConcurrency.Text); - } - - private void TextBoxIdle_timeout_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxIdle_timeout.Text); - } - #endregion - - //生成TrojanGo的分享链接 - private string GetTrojanGoUrl() - { - string trojanGoPassword = EncodeURIComponent(TextBoxTrojanGoServerPassword.Text); - string trojanGoHost = TextBoxTrojanGoServerHost.Text; - string trojanGoPort = TextBoxTrojanGoServerPort.Text; - - string trojanGoSni = EncodeURIComponent(TextBoxTrojanGoSNI.Text); - string trojanGoType= EncodeURIComponent(TextBoxTrojanGoType.Text); - string trojanGohostName = EncodeURIComponent(TextBoxTrojanGoHost.Text); - - string trojanGoPath = EncodeURIComponent(TextBoxTrojanGoWSPath.Text); - string trojanGoEncryption = EncodeURIComponent(""); - string trojanGoPlugin = EncodeURIComponent(""); - - string trojanGoRemarks = EncodeURIComponent(trojanGoHost); - - //分享链接规范:https://github.com/p4gefau1t/trojan-go/issues/132 - //trojan-go://$(trojan-password)@trojan-host:port/?sni=$(update.microsoft.com)&type=$(original|ws|h2|h2+ws)&host=$(update-01.microsoft.com)&path=$(/update/whatever)&encryption=$(ss;aes-256-gcm:ss-password)&plugin=$(...)#$(descriptive-text) - //string trojanGoUrl = $"trojan-go://{trojanGoPassword}@{trojanGoHost}:{trojanGoPort}/?sni={trojanGoSni}&type={trojanGoType}&host={trojanGohostName}&path={trojanGoPath}&encryption={trojanGoEncryption}&plugin={trojanGoPlugin}#{trojanGoRemarks}"; - - //&path={trojanGoPath} - //&encryption={trojanGoEncryption} - //&plugin={trojanGoPlugin} - //#{trojanGoRemarks} - string trojanGoUrl = $"trojan-go://{trojanGoPassword}@{trojanGoHost}:{trojanGoPort}/?sni={trojanGoSni}&type={trojanGoType}"; - - if (String.IsNullOrEmpty(trojanGohostName) == false) - { - trojanGoUrl += $"&host={trojanGohostName}"; - } - if (String.IsNullOrEmpty(trojanGoPath) == false) - { - trojanGoUrl += $"&path={trojanGoPath}"; - } - if (String.IsNullOrEmpty(trojanGoEncryption) == false) - { - trojanGoUrl += $"&encryption={trojanGoEncryption}"; - } - if (String.IsNullOrEmpty(trojanGoPlugin) == false) - { - trojanGoUrl += $"&plugin={trojanGoPlugin}"; - } - - trojanGoUrl += $"#{trojanGoRemarks}"; - return trojanGoUrl; - } - private string EncodeURIComponent(string initialUri) - { - return Uri.EscapeDataString(initialUri); - } - - //生成Trojan客户端资料 - private void GenerateTrojanShareQRcodeAndBase64Url() - { - string proxyfolder = CheckDir("trojan_config"); - configDomainSavePath = CreateConfigSaveDir(proxyfolder, TextBoxTrojanServerHost.Text); - string configSavePath = configDomainSavePath; - - //string saveFileFolderFirst = TextBoxTrojanServerHost.Text; - //int num = 1; - //saveFileFolder = saveFileFolderFirst; - //CheckDir("trojan_config"); - //while (Directory.Exists(@"trojan_config\" + saveFileFolder)) - //{ - // saveFileFolder = saveFileFolderFirst + "_copy_" + num.ToString(); - // num++; - //} - //CheckDir(@"trojan_config\" + saveFileFolder); - string trojanUrl = $"trojan://{TextBoxTrojanServerPassword.Text}@{TextBoxTrojanServerHost.Text}:{TextBoxTrojanServerPort.Text}#{TextBoxTrojanServerHost.Text}"; - //MessageBox.Show(v2rayNjsonObject.ToString()); - //string trojanUrl = "trojan://" + ToBase64Encode(v2rayNjsonObject.ToString()); - TextBoxURL.Text = trojanUrl; - using (StreamWriter sw = new StreamWriter($"{configSavePath}\\url.txt")) - { - sw.WriteLine(trojanUrl); - - } - ImageShareQRcode.Source = CreateQRCode(trojanUrl, $"{configSavePath}\\QR.bmp"); - - //移动Trojan官方程序配置文件到相应目录 - if (File.Exists(@"trojan_config\config.json")) - { - File.Move(@"trojan_config\config.json", $"{configSavePath}\\config.json"); - //File.Delete(@"config\config.json");//删除该文件 - } - - using (StreamWriter sw = new StreamWriter($"{configSavePath}\\readme.txt")) - { - sw.WriteLine("config.json"); - - //****** "此文件为Trojan官方程序所使用的客户端配置文件,配置为全局模式,http与socks5地址:127.0.0.1:1080" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtTrojanExplainLine01").ToString()); - - //****** "Trojan官方网站:https://trojan-gfw.github.io/trojan/" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtTrojanExplainLine02").ToString()); - - //sw.WriteLine("Trojan官方程序下载地址:https://github.com/trojan-gfw/trojan/releases"); - sw.WriteLine(Application.Current.FindResource("readmeTxtTrojanExplainLine03").ToString()); - - //sw.WriteLine("下载相应版本,Windows选择Trojan-x.xx-win.zip,解压后提取trojan.exe。与config.json放在同一目录,运行trojan.exe即可。"); - sw.WriteLine(Application.Current.FindResource("readmeTxtTrojanExplainLine04").ToString()); - - sw.WriteLine("-----------------------------------------\n"); - sw.WriteLine("QR.bmp"); - - //sw.WriteLine("此文件为Qv2ray (windows)、igniter(Android)、Shadowrocket(ios)扫码导入节点"); - sw.WriteLine(Application.Current.FindResource("readmeTxtTrojanExplainLine05").ToString()); - - //sw.WriteLine("Qv2ray (windows)下载网址:https://github.com/Qv2ray/Qv2ray/releases"); - sw.WriteLine(Application.Current.FindResource("readmeTxtTrojanExplainLine06").ToString()); - - //sw.WriteLine("igniter(Android)下载网址:https://github.com/trojan-gfw/igniter/releases"); - sw.WriteLine(Application.Current.FindResource("readmeTxtTrojanExplainLine07").ToString()); - - //sw.WriteLine("Shadowrocket(ios)下载,需要使用国外区的AppleID。请自行谷歌方法。"); - sw.WriteLine(Application.Current.FindResource("readmeTxtTrojanExplainLine08").ToString()); - sw.WriteLine("-----------------------------------------\n"); - sw.WriteLine("url.txt"); - - //sw.WriteLine("此文件为Qv2ray (windows)、igniter(Android)、Shadowrocket(ios)复制粘贴导入节点的网址"); - sw.WriteLine(Application.Current.FindResource("readmeTxtTrojanExplainLine09").ToString()); - sw.WriteLine("-----------------------------------------\n"); - - string strApplicat = ""; - string strParam = ""; - int strLenth = 20; - - //sw.WriteLine("服务器通用连接配置参数"); - sw.WriteLine(Application.Current.FindResource("readmeTxtTrojanExplainLine10").ToString()); - sw.WriteLine(""); - - //****** 服务器地址(address): ****** - //sw.WriteLine(Application.Current.FindResource("TextBlockServerAddress").ToString() + $"{TextBoxTrojanGoServerHost.Text}"); - strApplicat = "TextBlockServerAddress"; - strParam = TextBoxTrojanServerHost.Text; - sw.WriteLine(AlignmentStrFunc(Application.Current.FindResource($"{strApplicat}").ToString(), strLenth) + strParam); - - //****** 端口(port): ****** - //sw.WriteLine(Application.Current.FindResource("TextBlockServerPort").ToString() + $"{TextBoxTrojanGoServerPort.Text}"); - strApplicat = "TextBlockServerPort"; - strParam = TextBoxTrojanServerPort.Text; - sw.WriteLine(AlignmentStrFunc(Application.Current.FindResource($"{strApplicat}").ToString(), strLenth) + strParam); - - //****** 密码: ****** - //sw.WriteLine(Application.Current.FindResource("TextBlockTrojanGoPassword").ToString() + $"{TextBoxTrojanGoServerPassword.Text}"); - //sw.WriteLine(Application.Current.FindResource("TextBlockTrojanGoWebSocketPath").ToString() + $"{TextBoxTrojanGoWSPath.Text}"); - strApplicat = "TextBlockTrojanGoPassword"; - strParam = TextBoxTrojanServerPassword.Text; - sw.WriteLine(AlignmentStrFunc(Application.Current.FindResource($"{strApplicat}").ToString(), strLenth) + strParam); - - - } - - } - - #region Trojan内容双击复制到剪贴板 - - private void TextBoxTrojanServerHost_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxTrojanServerHost.Text); - } - - private void TextBoxTrojanServerPort_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxTrojanServerPort.Text); - } - - private void TextBoxTrojanServerPassword_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxTrojanServerPassword.Text); - } - - #endregion - - #endregion - - #region NaiveProxy 相关 - //生成NaiveProxy客户端资料 - private void GenerateNaivePrxoyShareQRcodeAndBase64Url() - { - string proxyfolder = CheckDir("naive_config"); - configDomainSavePath = CreateConfigSaveDir(proxyfolder, TextBoxNaiveServerHost.Text); - string configSavePath = configDomainSavePath; - - string naiveUrl = $"naive+https://{TextBoxNaiveUser.Text}:{TextBoxNaivePassword.Text}@{TextBoxNaiveServerHost.Text}:443?padding=true#{TextBoxNaiveServerHost.Text}"; - - TextBoxURL.Text = naiveUrl; - using (StreamWriter sw = new StreamWriter($"{configSavePath}\\url.txt")) - { - sw.WriteLine(naiveUrl); - - } - ImageShareQRcode.Source = CreateQRCode(naiveUrl, $"{configSavePath}\\QR.bmp"); - - //移动NaiveProxy官方程序配置文件到相应目录 - if (File.Exists(@"naive_config\config.json")) - { - File.Move(@"naive_config\config.json", $"{configSavePath}\\config.json"); - //File.Delete(@"config\config.json");//删除该文件 - } - - using (StreamWriter sw = new StreamWriter($"{configSavePath}\\readme.txt")) - { - sw.WriteLine("config.json"); - - //****** "此文件为NaiveProxy官方程序所使用的客户端配置文件,配置为全局模式,socks5地址:127.0.0.1:1080" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtNaiveProxyExplainLine01").ToString()); - - //****** "NaiveProxy官方网站:https://github.com/klzgrad/naiveproxy" ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtNaiveProxyExplainLine02").ToString()); - - //sw.WriteLine("NaiveProxy官方程序下载地址:https://github.com/klzgrad/naiveproxy/releases"); - sw.WriteLine(Application.Current.FindResource("readmeTxtNaiveProxyExplainLine03").ToString()); - - //sw.WriteLine("下载相应版本,Windows选择naiveproxy-x.xx-win.zip,解压后提取naive.exe。与config.json放在同一目录,运行naive.exe即可。"); - sw.WriteLine(Application.Current.FindResource("readmeTxtNaiveProxyExplainLine04").ToString()); - - sw.WriteLine("-----------------------------------------"); - sw.WriteLine("QR.bmp"); - - //sw.WriteLine("此文件为NaiveSharp(windows)复制粘贴导入节点的网址"); - sw.WriteLine(Application.Current.FindResource("readmeTxtNaiveProxyExplainLine05").ToString()); - - //sw.WriteLine("NaiveSharp(windows)下载网址:https://github.com/KevinZonda/NaiveSharp/releases"); - sw.WriteLine(Application.Current.FindResource("readmeTxtNaiveProxyExplainLine06").ToString()); - - sw.WriteLine("-----------------------------------------\n"); - - sw.WriteLine("url.txt"); - - //sw.WriteLine("此文件为NaiveSharp(windows)复制粘贴导入节点的网址"); - sw.WriteLine(Application.Current.FindResource("readmeTxtNaiveProxyExplainLine05").ToString()); - - //sw.WriteLine("NaiveSharp(windows)下载网址:https://github.com/KevinZonda/NaiveSharp/releases"); - sw.WriteLine(Application.Current.FindResource("readmeTxtNaiveProxyExplainLine06").ToString()); - - sw.WriteLine("-----------------------------------------\n"); - - string strApplicat = ""; - string strParam = ""; - int strLenth = 20; - - //sw.WriteLine("服务器通用连接配置参数"); - sw.WriteLine(Application.Current.FindResource("readmeTxtNaiveProxyExplainLine07").ToString()); - sw.WriteLine(""); - - //****** 服务器地址(address): ****** - //sw.WriteLine(Application.Current.FindResource("TextBlockServerAddress").ToString() + $"{TextBoxNaiveServerHost.Text}"); - strApplicat = "TextBlockServerAddress"; - strParam = TextBoxNaiveServerHost.Text; - sw.WriteLine(AlignmentStrFunc(Application.Current.FindResource($"{strApplicat}").ToString(), strLenth) + strParam); - - //****** 用户名:****** - //sw.WriteLine(Application.Current.FindResource("TextBlockHostUser").ToString() + $"{TextBoxNaiveUser.Text}"); - strApplicat = "TextBlockHostUser"; - strParam = TextBoxNaiveUser.Text; - sw.WriteLine(AlignmentStrFunc(Application.Current.FindResource($"{strApplicat}").ToString(), strLenth) + strParam); - - //****** 密码: ****** - //sw.WriteLine(Application.Current.FindResource("TextBlockTrojanGoPassword").ToString() + $"{TextBoxNaivePassword.Text}"); - strApplicat = "TextBlockTrojanGoPassword"; - strParam = TextBoxNaivePassword.Text; - sw.WriteLine(AlignmentStrFunc(Application.Current.FindResource($"{strApplicat}").ToString(), strLenth) + strParam); - - } - - } - - #region NaiveProxy内容双击复制到剪贴板 - private void TextBoxNaiveServerHost_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxNaiveServerHost.Text); - } - - private void TextBoxNaivePort_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxNaivePort.Text); - } - - private void TextBoxNaiveUser_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxNaiveUser.Text); - } - - private void TextBoxNaivePassword_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxNaivePassword.Text); - } - - - - #endregion - - #endregion - - #region SSR 相关 - //生成SSR客户端资料 - private void GenerateSSRShareQRcodeAndBase64Url() - { - string proxyfolder = CheckDir("ssr_config"); - configDomainSavePath = CreateConfigSaveDir(proxyfolder, TextBoxSSRHostAddress.Text); - string configSavePath = configDomainSavePath; - //string saveFileFolderFirst = TextBoxSSRHostAddress.Text; - //int num = 1; - //saveFileFolder = saveFileFolderFirst; - //CheckDir("ssr_config"); - //while (Directory.Exists(@"ssr_config\" + saveFileFolder)) - //{ - // saveFileFolder = saveFileFolderFirst + "_copy_" + num.ToString(); - // num++; - //} - //CheckDir(@"ssr_config\" + saveFileFolder); - - string ssrUrl = GetSSRLinkForServer(); - TextBoxURL.Text = ssrUrl; - using (StreamWriter sw = new StreamWriter($"{configSavePath}\\url.txt")) - { - sw.WriteLine(ssrUrl); - } - ImageShareQRcode.Source = CreateQRCode(ssrUrl, $"{configSavePath}\\QR.bmp"); - - using (StreamWriter sw = new StreamWriter($"{configSavePath}\\readme.txt")) - { - //sw.WriteLine("-----------------------------------------\n"); - sw.WriteLine("QR.bmp"); - - //***"此文件为ShadowsocksR (windows)、SSRR(Android)、Shadowrocket(ios)扫码导入节点"*** - sw.WriteLine(Application.Current.FindResource("readmeTxtSSRExplainLine05").ToString()); - - //***"ShadowsocksR (windows)下载网址:https://github.com/shadowsocksrr/shadowsocksr-csharp/releases"*** - sw.WriteLine(Application.Current.FindResource("readmeTxtSSRExplainLine06").ToString()); - - //***"SSRR(Android)下载网址:https://github.com/shadowsocksrr/shadowsocksr-android/releases"*** - sw.WriteLine(Application.Current.FindResource("readmeTxtSSRExplainLine07").ToString()); - - //***"Shadowrocket(ios)下载,需要使用国外区的AppleID。请自行谷歌方法。"*** - sw.WriteLine(Application.Current.FindResource("readmeTxtSSRExplainLine08").ToString()); - sw.WriteLine("-----------------------------------------\n"); - sw.WriteLine("url.txt"); - - //***"此文件为ShadowsocksR (windows)、SSRR(Android)、Shadowrocket(ios)复制粘贴导入节点的网址"*** - sw.WriteLine(Application.Current.FindResource("readmeTxtSSRExplainLine09").ToString()); - sw.WriteLine("-----------------------------------------\n"); - - string strApplicat = ""; - string strParam = ""; - int strLenth = 20; - - //***"服务器通用连接配置参数"*** - sw.WriteLine(Application.Current.FindResource("readmeTxtTrojanExplainLine10").ToString()); - sw.WriteLine(""); - - //****** 服务器地址(address): ****** - //sw.WriteLine(Application.Current.FindResource("TextBlockServerAddress").ToString() + $"{ TextBoxSSRHostAddress.Text}"); - strApplicat = "TextBlockServerAddress"; - strParam = TextBoxSSRHostAddress.Text; - sw.WriteLine(AlignmentStrFunc(Application.Current.FindResource($"{strApplicat}").ToString(), strLenth) + strParam); - - //****** 端口(port): ****** - //sw.WriteLine(Application.Current.FindResource("TextBlockServerPort").ToString() + $"{TextBoxSSRPort.Text}"); - strApplicat = "TextBlockServerPort"; - strParam = TextBoxSSRPort.Text; - sw.WriteLine(AlignmentStrFunc(Application.Current.FindResource($"{strApplicat}").ToString(), strLenth) + strParam); - - //****** 密码: ****** - //sw.WriteLine(Application.Current.FindResource("TextBlockTrojanGoPassword").ToString() + $"{TextBoxSSRUUID.Text}"); - strApplicat = "TextBlockTrojanGoPassword"; - strParam = TextBoxSSRUUID.Text; - sw.WriteLine(AlignmentStrFunc(Application.Current.FindResource($"{strApplicat}").ToString(), strLenth) + strParam); - - //****** 加密方式: ****** - //sw.WriteLine(Application.Current.FindResource("TextBlockEncryption").ToString() + $"{TextBoxSSREncryption.Text}"); - strApplicat = "TextBlockEncryption"; - strParam = TextBoxSSREncryption.Text; - sw.WriteLine(AlignmentStrFunc(Application.Current.FindResource($"{strApplicat}").ToString(), strLenth) + strParam); - - //****** 传输协议: ****** - //sw.WriteLine(Application.Current.FindResource("TextBlockTransferProtocol").ToString() + $"{TextBoxSSRTransmission.Text}"); - strApplicat = "TextBlockTransferProtocol"; - strParam = TextBoxSSRTransmission.Text; - sw.WriteLine(AlignmentStrFunc(Application.Current.FindResource($"{strApplicat}").ToString(), strLenth) + strParam); - - //****** 混淆: ****** - //sw.WriteLine(Application.Current.FindResource("TextBlockCamouflageType").ToString() + $"{TextBoxSSRCamouflageType.Text}"); - strApplicat = "TextBlockCamouflageType"; - strParam = TextBoxSSRCamouflageType.Text; - sw.WriteLine(AlignmentStrFunc(Application.Current.FindResource($"{strApplicat}").ToString(), strLenth) + strParam); - - } - } - - #region SSR内容双击复制到剪贴板 - - private void TextBoxSSRHostAddress_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxSSRHostAddress.Text); - } - - private void TextBoxSSRPort_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxSSRPort.Text); - } - - private void TextBoxSSRUUID_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxSSRUUID.Text); - } - - private void TextBoxSSREncryption_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxSSREncryption.Text); - } - - private void TextBoxSSRTransmission_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxSSRTransmission.Text); - } - - private void TextBoxSSRCamouflageType_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxSSRCamouflageType.Text); - } - #endregion - - //生成SS客户端资料 - private void GenerateShareQRcodeAndBase64UrlSS() - { - //创建保存目录 - string proxyfolder = CheckDir("ss_config"); - configDomainSavePath = CreateConfigSaveDir(proxyfolder, TextBoxHostAddressSS.Text); - string configSavePath = configDomainSavePath; - //string configSavePath = CreateConfigSaveDir(@"ss_config", TextBoxHostAddressSS.Text); - string ssUrl; - - //生成手机端的URL(无插件时,为电脑手机通用) - if (String.Equals(TextBoxPluginNameExplainSS.Text, "goquiet")==false && String.Equals(TextBoxPluginNameExplainSS.Text, "cloak") == false) - { - ssUrl = GetSStoURL(TextBoxPluginNameExplainSS.Text); - TextBoxURL.Text = ssUrl; - using (StreamWriter sw = new StreamWriter($"{configSavePath}\\url.txt")) - { - sw.WriteLine(ssUrl); - } - ImageShareQRcode.Source = CreateQRCode(ssUrl, $"{configSavePath}\\QR.bmp"); - } - - if (String.IsNullOrEmpty(TextBoxPluginNameExplainSS.Text) == false) - { - //生成电脑端 - ssUrl = GetSStoURL(TextBoxPluginNameExplainSSpc.Text); - TextBoxURLpcSS.Text = ssUrl; - using (StreamWriter sw = new StreamWriter($"{configSavePath}\\url_pc.txt")) - { - sw.WriteLine(ssUrl); - } - ImageShareQRcodeSSpc.Source = CreateQRCode(ssUrl, $"{configSavePath}\\QR_pc.bmp"); - } - using (StreamWriter sw = new StreamWriter($"{configSavePath}\\readme.txt")) - { - if (String.Equals(TextBoxPluginNameExplainSS.Text, "goquiet") == false && String.Equals(TextBoxPluginNameExplainSS.Text, "cloak") == false) - { - //sw.WriteLine("-----------------------------------------\n"); - sw.WriteLine("QR.bmp"); - if (String.IsNullOrEmpty(TextBoxPluginNameExplainSS.Text) == true) - { - //***"此文件为Shadowsocks (windows)、shadowsocks(Android)、Shadowrocket(ios)扫码导入节点"*** - sw.WriteLine(Application.Current.FindResource("readmeTxtExplainLineSS05").ToString()); - - } - else - { - //***"此文件为shadowsocks(Android)、Shadowrocket(ios)扫码导入节点"*** - sw.WriteLine(Application.Current.FindResource("readmeTxtExplainLineSS05").ToString()); - } - - sw.WriteLine("-----------------------------------------\n"); - sw.WriteLine("url.txt"); - if (String.IsNullOrEmpty(TextBoxPluginNameExplainSS.Text) == true) - { - //***"此文件为Shadowsocks (windows)、shadowsocks(Android)、Shadowrocket(ios)复制粘贴导入节点的网址"*** - sw.WriteLine(Application.Current.FindResource("readmeTxtExplainLineSS09").ToString()); - } - else - { - //***"此文件为shadowsocks(Android)、Shadowrocket(ios)复制粘贴导入节点的网址"*** - sw.WriteLine(Application.Current.FindResource("readmeTxtExplainLineSS09").ToString()); - } - sw.WriteLine(""); - //***"shadowsocks(Android)下载网址:https://github.com/shadowsocks/shadowsocks-android/releases"*** - sw.WriteLine(Application.Current.FindResource("readmeTxtExplainLineSS07").ToString()); - - //***"Shadowrocket(ios)下载,需要使用国外区的AppleID。请自行谷歌方法。"*** - sw.WriteLine(Application.Current.FindResource("readmeTxtExplainLineSS08").ToString()); - } - if (String.IsNullOrEmpty(TextBoxPluginNameExplainSS.Text) == false) - { - sw.WriteLine(""); - sw.WriteLine("-----------------------------------------\n"); - sw.WriteLine("QR_pc.bmp"); - - //***"此文件为Shadowsocks (windows)扫码导入节点"*** - sw.WriteLine(Application.Current.FindResource("readmeTxtExplainLineSS01").ToString()); - sw.WriteLine("-----------------------------------------\n"); - sw.WriteLine("url_pc.txt"); - - //***"此文件为Shadowsocks (windows)复制粘贴导入节点的网址"*** - sw.WriteLine(Application.Current.FindResource("readmeTxtExplainLineSS02").ToString()); - sw.WriteLine(""); - - } - //***"Shadowsocks(windows)下载网址:https://github.com/shadowsocks/shadowsocks-windows/releases"*** - sw.WriteLine(Application.Current.FindResource("readmeTxtExplainLineSS06").ToString()); - sw.WriteLine("-----------------------------------------\n"); - - string strApplicat = ""; - string strParam = ""; - int strLenth = 20; - - //***"服务器通用连接配置参数"*** - sw.WriteLine(Application.Current.FindResource("readmeTxtTrojanExplainLine10").ToString()); - sw.WriteLine(""); - - //****** 服务器地址(address): ****** - //sw.WriteLine(Application.Current.FindResource("TextBlockServerAddress").ToString() + $"{TextBoxHostAddressSS.Text}"); - strApplicat = "TextBlockServerAddress"; - strParam = TextBoxHostAddressSS.Text; - sw.WriteLine(AlignmentStrFunc(Application.Current.FindResource($"{strApplicat}").ToString(), strLenth) + strParam); - - //****** 端口(port): ****** - //sw.WriteLine(Application.Current.FindResource("TextBlockServerPort").ToString() + $"{TextBoxPortSS.Text}"); - strApplicat = "TextBlockServerPort"; - strParam = TextBoxPortSS.Text; - sw.WriteLine(AlignmentStrFunc(Application.Current.FindResource($"{strApplicat}").ToString(), strLenth) + strParam); - - //****** 密码: ****** - //sw.WriteLine(Application.Current.FindResource("TextBlockTrojanGoPassword").ToString() + $"{TextBoxPasswordSS.Text}"); - strApplicat = "TextBlockTrojanGoPassword"; - strParam = TextBoxPasswordSS.Text; - sw.WriteLine(AlignmentStrFunc(Application.Current.FindResource($"{strApplicat}").ToString(), strLenth) + strParam); - - //****** 加密方式: ****** - //sw.WriteLine(Application.Current.FindResource("TextBlockEncryption").ToString() + $"{TextBoxEncryptionSS.Text}"); - strApplicat = "TextBlockEncryption"; - strParam = TextBoxEncryptionSS.Text; - sw.WriteLine(AlignmentStrFunc(Application.Current.FindResource($"{strApplicat}").ToString(), strLenth) + strParam); - - - if (String.IsNullOrEmpty(TextBoxPluginNameExplainSS.Text) == false) - { - //****** 插件程序:: ****** - //sw.WriteLine(Application.Current.FindResource("TextBlockPluginNameExplainSS").ToString() + $"{TextBoxPluginNameExplainSS.Text}"); - strApplicat = "TextBlockPluginNameExplainSS"; - strParam = TextBoxPluginNameExplainSS.Text; - sw.WriteLine(AlignmentStrFunc(Application.Current.FindResource($"{strApplicat}").ToString(), strLenth) + strParam); - - //****** 插件选项: ****** - //sw.WriteLine(Application.Current.FindResource("TextBlockPluginOptionExplainSS").ToString() + $"{TextBoxPluginOptionExplainSS.Text}"); - strApplicat = "TextBlockPluginOptionExplainSS"; - strParam = TextBoxPluginOptionExplainSS.Text; - sw.WriteLine(AlignmentStrFunc(Application.Current.FindResource($"{strApplicat}").ToString(), strLenth) + strParam); - - sw.WriteLine("-----------------------------------------\n"); - //****** 插件使用说明 ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtPluginExplainSS").ToString()); - - //****** ProxySU默认所有插件,在Shadowsocks (windows)运行文件所在文件夹的子文件夹plugins下。 ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtPluginExplainSS01").ToString()); - - //****** 电脑端手动安装插件说明 ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtPluginExplainSS02").ToString()); - - //****** 先下载插件,各个插件Windows客户端下载地址为: ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtPluginExplainSS03").ToString()); - - //****** Simple-obfs: https://github.com/shadowsocks/simple-obfs/releases 只下载 obfs-local.zip ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtPluginExplainSS04").ToString()); - - //****** V2ray-plugin: https://github.com/shadowsocks/v2ray-plugin/releases 64位系统选择:v2ray-plugin-windows-amd64-vx.x.x.tar.gz,32位系统选择:v2ray-plugin-windows-386-vx.x.x.tar.gz (x为数字,是版本号)****** - sw.WriteLine(Application.Current.FindResource("readmeTxtPluginExplainSS05").ToString()); - - //****** Kcptun-plugin: https://github.com/shadowsocks/kcptun/releases 64位系统选择:kcptun-windows-amd64-xxxxxx.tar.gz,32位系统选择:kcptun-plugin-windows-386-xxxxxx.tar.gz (x为数字,是版本号)****** - sw.WriteLine(Application.Current.FindResource("readmeTxtPluginExplainSS06").ToString()); - - ////****** GoQuiet-plugin: https://github.com/cbeuw/GoQuiet/releases 64位系统选择:gq-client-windows-amd64-x.x.x.exe,32位系统选择:gq-client-windows-386-x.x.x.exe(x为数字,是版本号)****** - //sw.WriteLine(Application.Current.FindResource("readmeTxtPluginExplainSS07").ToString()); - - ////****** Cloak-plugin: https://github.com/cbeuw/Cloak/releases 64位系统选择:ck-client-windows-amd64-x.x.x.exe,32位系统选择:ck-client-windows-386-x.x.x.exe(x为数字,是版本号) ****** - //sw.WriteLine(Application.Current.FindResource("readmeTxtPluginExplainSS08").ToString()); - - //****** 在Shadowsocks (windows)运行文件所在文件夹中,新建文件夹plugins,将obfs-local.zip解压出的文件(两个)全部复到plugins中, - //v2ray -plugin下载得到的文件,解压出的文件,复制到plugins中,并重命名为:v2ray-plugin.exe。 - //Kcptun -plugin下载得到的文件,解压出两个文件,将其中的client_windows开头的文件,复制到plugins中,并重命名为:kcptun-client.exe。 - //GoQuiet-plugin下载得到的文件,直接复制到plugin中,并重命名为:goquiet-client.exe。 - //Cloak-plugin下载得到的文件,直接复制到plugin中,并重命名为:cloak-client.exe - //****** - sw.WriteLine(Application.Current.FindResource("readmeTxtPluginExplainSS09").ToString()); - //******安装完毕 ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtPluginExplainSS10").ToString()); - - sw.WriteLine("-----------------------------------------\n"); - - //******手机安卓客户端插件安装说明 ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtPluginExplainSSandroid02").ToString()); - - //****** 先下载插件,各个插件安卓客户端下载地址为: ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtPluginExplainSSandroid03").ToString()); - - //****** Simple-obfs: https://github.com/shadowsocks/simple-obfs-android/releases 只下载 obfs-local-nightly-x.x.x.apk(x为数字,是版本号) ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtPluginExplainSSandroid04").ToString()); - - //****** V2ray-plugin: https://github.com/shadowsocks/v2ray-plugin-android/releases 一般选择v2ray--universal-x.x.x.apk(x为数字,是版本号)****** - sw.WriteLine(Application.Current.FindResource("readmeTxtPluginExplainSSandroid05").ToString()); - - //****** Kcptun-plugin: https://github.com/shadowsocks/kcptun-android/releases 一般选择kcptun--universal-x.x.x.apk(x为数字,是版本号)****** - sw.WriteLine(Application.Current.FindResource("readmeTxtPluginExplainSSandroid06").ToString()); - //******将上述apk文件传到手机,安装即可! ****** - sw.WriteLine(Application.Current.FindResource("readmeTxtPluginExplainSSandroid07").ToString()); - - } - - } - - } - - #region SS内容双击复制到剪贴板 - private void TextBoxHostAddressSS_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxHostAddressSS.Text); - } - - private void TextBoxPortSS_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxPortSS.Text); - } - - private void TextBoxPasswordSS_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxPasswordSS.Text); - } - - private void TextBoxEncryptionSS_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxEncryptionSS.Text); - } - - private void TextBoxPluginNameExplainSS_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxPluginNameExplainSS.Text); - } - private void TextBoxPluginNameExplainSSpc_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxPluginNameExplainSSpc.Text); - } - - private void TextBoxPluginOptionExplainSS_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxPluginOptionExplainSS.Text); - } - - private void TextBoxURLpcSS_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxURLpcSS.Text); - } - - #endregion - - #endregion - - #region MTProto 界面控制 - private void RadioButtonMtgIpv4_Checked(object sender, RoutedEventArgs e) - { - GridMtgIpv4.Visibility = Visibility.Visible; - GridMtgIpv6.Visibility = Visibility.Collapsed; - } - - private void RadioButtonMtgIpv6_Checked(object sender, RoutedEventArgs e) - { - GridMtgIpv4.Visibility = Visibility.Collapsed; - GridMtgIpv6.Visibility = Visibility.Visible; - } - private void TextBoxURLMtgTgIpv4_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxURLMtgTgIpv4.Text); - } - - private void TextBoxURLMtgTmeIpv4_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxURLMtgTmeIpv4.Text); - } - - private void TextBoxURLMtgTgIpv6_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxURLMtgTgIpv6.Text); - } - - private void TextBoxURLMtgTmeIpv6_MouseDoubleClick(object sender, MouseButtonEventArgs e) - { - CopyToClipboard(TextBoxURLMtgTmeIpv6.Text); - } - - #endregion - - //生成base64 - private string ToBase64Encode(string text) - { - if (String.IsNullOrEmpty(text)) - { - return text; - } - - byte[] textBytes = Encoding.UTF8.GetBytes(text); - return Convert.ToBase64String(textBytes); - } - - //生成QRcoder图片,并按给出的路径与名称保存,返回窗口显示的图片源 - private BitmapSource CreateQRCode(string varBase64,string configPath) - { - QRCodeGenerator qrGenerator = new QRCodeGenerator(); - QRCodeData qrCodeData = qrGenerator.CreateQrCode(varBase64, QRCodeGenerator.ECCLevel.Q); - QRCode qrCode = new QRCode(qrCodeData); - Bitmap qrCodeImage = qrCode.GetGraphic(20); - IntPtr myImagePtr = qrCodeImage.GetHbitmap(); - BitmapSource imgsource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(myImagePtr, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); - //ImageShareQRcode.Source = imgsource; - //DeleteObject(myImagePtr); - qrCodeImage.Save(configPath); - return imgsource; - - } - - //判断目录是否存在,不存在则创建 - private string CheckDir(string folder) - { - try - { - if (!Directory.Exists(folder))//如果不存在就创建file文件夹 - Directory.CreateDirectory(folder);//创建该文件夹   - return folder; - } - catch (Exception) - { - return ""; - } - } - - //目录已存在则生成序号递增,并返回所创建的目录路径。 - private string CreateConfigSaveDir(string upperDir,string configDir) - { - try - { - //string saveFileFolderFirst = configDir; - int num = 1; - //saveFileFolder = EncodeURIComponent(configDir); - saveFileFolder = configDir.Replace(":","_"); - CheckDir(upperDir); - while (Directory.Exists(upperDir + @"\" + saveFileFolder) == true) - { - saveFileFolder = configDir + "_copy_" + num.ToString(); - num++; - } - CheckDir(upperDir + @"\" + saveFileFolder); - return upperDir + @"\" + saveFileFolder; - } - catch (Exception) - { - saveFileFolder = ""; - return upperDir + @"\" + saveFileFolder; - } - - } - - //打开文件夹 - private void ButtonOpenSaveDir_Click(object sender, RoutedEventArgs e) - { - string openFolderPath = configDomainSavePath; - System.Diagnostics.Process.Start("explorer.exe", openFolderPath); - this.Close(); - - } - - //SSR生成URL链接 - private string GetSSRLinkForServer() - { - string server = TextBoxSSRHostAddress.Text; - string server_port = TextBoxSSRPort.Text; - string password = TextBoxSSRUUID.Text; - string protocol = TextBoxSSRTransmission.Text; - string method = TextBoxSSREncryption.Text; - string obfs = TextBoxSSRCamouflageType.Text; - - string obfsparam=""; - string protocolparam = ""; - string remarks = TextBoxSSRHostAddress.Text; - string group = TextBoxSSRHostAddress.Text; - bool udp_over_tcp = true; - int server_udp_port = 0; - - string main_part = server + ":" + server_port + ":" + protocol + ":" + method + ":" + obfs + ":" + EncodeUrlSafeBase64(password); - string param_str = "obfsparam=" + EncodeUrlSafeBase64(obfsparam ?? ""); - if (!string.IsNullOrEmpty(protocolparam)) - { - param_str += "&protoparam=" + EncodeUrlSafeBase64(protocolparam); - } - if (!string.IsNullOrEmpty(remarks)) - { - param_str += "&remarks=" + EncodeUrlSafeBase64(remarks); - } - if (!string.IsNullOrEmpty(group)) - { - param_str += "&group=" + EncodeUrlSafeBase64(group); - } - if (udp_over_tcp) - { - param_str += "&uot=" + "1"; - } - if (server_udp_port > 0) - { - param_str += "&udpport=" + server_udp_port.ToString(); - } - string base64 = EncodeUrlSafeBase64(main_part + "/?" + param_str); - return "ssr://" + base64; - } - - //SS生成URL链接,需要给出plugin的内容,用于生成手机端或电脑端的URL - public string GetSStoURL(string plugin,bool legacyUrl = true) - { - string tag = string.Empty; - string url = string.Empty; - - server = TextBoxHostAddressSS.Text; - string server_port = TextBoxPortSS.Text; - - string password = TextBoxPasswordSS.Text; - string method = TextBoxEncryptionSS.Text; - - // plugin = TextBoxPluginNameExplainSS.Text; - string plugin_opts = TextBoxPluginOptionExplainSS.Text; - - string remarks = server; - - if (legacyUrl && string.IsNullOrWhiteSpace(plugin)) - { - // For backwards compatiblity, if no plugin, use old url format - string parts = $"{method}:{password}@{server}:{server_port}"; - string base64 = Convert.ToBase64String(Encoding.UTF8.GetBytes(parts)); - url = base64; - } - else - { - // SIP002 - string parts = $"{method}:{password}"; - string base64 = Convert.ToBase64String(Encoding.UTF8.GetBytes(parts)); - string websafeBase64 = base64.Replace('+', '-').Replace('/', '_').TrimEnd('='); - - url = string.Format( - "{0}@{1}:{2}/", - websafeBase64, - FormalHostName, - server_port - ); - - if (!String.IsNullOrWhiteSpace(plugin)) - { - - string pluginPart = plugin; - if (!String.IsNullOrWhiteSpace(plugin_opts)) - { - pluginPart += ";" + plugin_opts; - } - string pluginQuery = "?plugin=" + HttpUtility.UrlEncode(pluginPart, Encoding.UTF8); - url += pluginQuery; - } - } - - if (!String.IsNullOrEmpty(remarks)) - { - tag = $"#{HttpUtility.UrlEncode(remarks, Encoding.UTF8)}"; - } - return $"ss://{url}{tag}"; - } - - //格式化主机名称 - private string FormalHostName - { - get - { - // CheckHostName() won't do a real DNS lookup - switch (Uri.CheckHostName(server)) - { - case UriHostNameType.IPv6: // Add square bracket when IPv6 (RFC3986) - return $"[{server}]"; - default: // IPv4 or domain name - return server; - } - } - } - //编码安全Base64 - private string EncodeUrlSafeBase64(byte[] val, bool trim) - { - if (trim) - return Convert.ToBase64String(val).Replace('+', '-').Replace('/', '_').TrimEnd('='); - else - return Convert.ToBase64String(val).Replace('+', '-').Replace('/', '_'); - } - //编码安全Base64重载 - private string EncodeUrlSafeBase64(string val, bool trim = true) - { - return EncodeUrlSafeBase64(Encoding.UTF8.GetBytes(val), trim); - } - - private void RadioButtonMobile_Checked(object sender, RoutedEventArgs e) - { - TextBoxPluginNameExplainSS.Visibility = Visibility.Visible; - GroupBoxClientQRandURL.Visibility = Visibility.Visible; - - TextBoxPluginNameExplainSSpc.Visibility = Visibility.Collapsed; - GroupBoxClientSSpc.Visibility = Visibility.Collapsed; - - } - - private void RadioButtonPC_Checked(object sender, RoutedEventArgs e) - { - TextBoxPluginNameExplainSS.Visibility = Visibility.Collapsed; - GroupBoxClientQRandURL.Visibility = Visibility.Collapsed; - - TextBoxPluginNameExplainSSpc.Visibility = Visibility.Visible; - GroupBoxClientSSpc.Visibility = Visibility.Visible; - } - - /// - ///生成固定长度的空格字符串 - /// - /// - /// - - private string SpaceStrFunc(int length) - { - string strReturn = string.Empty; - if (length > 0) - { - for (int i = 0; i < length; i++) - { - strReturn += " "; - } - } - return strReturn; - } - - /// - ///将字符串生转化为固定长度左对齐,右补空格 - /// - ///需要补齐的字符串 - ///补齐后的长度 - /// - - private string AlignmentStrFunc(string strTemp, int length) - { - byte[] byteStr = System.Text.Encoding.Default.GetBytes(strTemp.Trim()); - int iLength = byteStr.Length; - int iNeed = length - iLength; - - byte[] spaceLen = Encoding.Default.GetBytes(" "); //一个空格的长度 - iNeed = iNeed / spaceLen.Length; - - string spaceString = SpaceStrFunc(iNeed); - //return strTemp + spaceString; - return spaceString + strTemp; - } - - - } - - -} diff --git a/ProxySU/SSpluginWindow.xaml b/ProxySU/SSpluginWindow.xaml deleted file mode 100644 index a3af977..0000000 --- a/ProxySU/SSpluginWindow.xaml +++ /dev/null @@ -1,279 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ProxySU/SSpluginWindow.xaml.cs b/ProxySU/SSpluginWindow.xaml.cs deleted file mode 100644 index f1f508b..0000000 --- a/ProxySU/SSpluginWindow.xaml.cs +++ /dev/null @@ -1,394 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; - -namespace ProxySU -{ - /// - /// SSpluginWindow.xaml 的交互逻辑 - /// - public partial class SSpluginWindow : Window - { - //SS加密方法设定 - public class EncryptionMethodInfo - { - public string Name { get; set; } - public string Value { get; set; } - } - public SSpluginWindow() - { - InitializeComponent(); - - #region 加密方法选择 初始设置为chacha20-ietf-poly1305 - List methodList = new List(); - - methodList.Add(new EncryptionMethodInfo { Name = "chacha20-ietf-poly1305", Value = "chacha20-ietf-poly1305" }); - methodList.Add(new EncryptionMethodInfo { Name = "xchacha20-ietf-poly1305", Value = "xchacha20-ietf-poly1305" }); - methodList.Add(new EncryptionMethodInfo { Name = "aes-256-gcm", Value = "aes-256-gcm" }); - methodList.Add(new EncryptionMethodInfo { Name = "aes-192-gcm", Value = "aes-192-gcm" }); - methodList.Add(new EncryptionMethodInfo { Name = "aes-128-gcm", Value = "aes-128-gcm" }); - - ComboBoxEncryptionMethodInfo.ItemsSource = methodList; - - ComboBoxEncryptionMethodInfo.DisplayMemberPath = "Name";//显示出来的值 - ComboBoxEncryptionMethodInfo.SelectedValuePath = "Value";//实际选中后获取的结果的值 - ComboBoxEncryptionMethodInfo.SelectedIndex = 0; - - DataContext = this; - #endregion - } - - - - //取消不在当前活动选项卡中的其他所有选项卡中的所有RadioBuuton的选中状态 - //代码参考网址:https://blog.csdn.net/weixin_42583999/article/details/103468857 - //调用:UncheckLayouts((TabItem)TabControlTemplate.SelectedItem); - private void UncheckLayouts(TabItem activePage) - { - foreach (TabItem tabPage in TabControlTemplate.Items) - { - if (tabPage == activePage) continue; - Grid grid = (Grid)tabPage.Content; - foreach (UIElement element in grid.Children) - { - if (element is RadioButton) - { - RadioButton radiobutton = (element as RadioButton); - radiobutton.IsChecked = false; - } - - } - } - } - - - //伪装网站处理 - //private string DisguiseURLprocessing(string fakeUrl) - //{ - //var uri = new Uri(fakeUrl); - //return uri.Host; - //处理伪装网站域名中的前缀 - //if (fakeUrl.Length >= 7) - //{ - // string testDomainMask = fakeUrl.Substring(0, 7); - // if (String.Equals(testDomainMask, "https:/") || String.Equals(testDomainMask, "http://")) - // { - // string[] tmpUrl = fakeUrl.Split('/'); - // fakeUrl = tmpUrl[2]; - // } - - //} - //return fakeUrl; - // } - - private void ButtondDecide_Click(object sender, RoutedEventArgs e) - { - bool preDomainMask = ClassModel.PreDomainMask(TextBoxMaskSites.Text); - bool domainNotEmpty = true; - //UncheckLayouts(TabControlTemplate); - //SS 经典模式被选中 - if (RadioButtonNonePluginSS.IsChecked == true) - { - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "NonePluginSS"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonNonePluginSS.Content.ToString(); - - } - //SS+obfs+http+web伪装模式被选中 - else if (RadioButtonObfsPluginHttpWebSS.IsChecked == true) - { - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "ObfsPluginHttpWebSS"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonObfsPluginHttpWebSS.Content.ToString(); - - } - //SS+obfs+TLS+web模式被选中 - else if (RadioButtonObfsPluginHttpsWebSS.IsChecked == true) - { - - domainNotEmpty = ClassModel.TestDomainIsEmpty(TextBoxDomainSS.Text); - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "ObfsPluginHttpsWebSS"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonObfsPluginHttpsWebSS.Content.ToString(); - //传递域名 - MainWindow.ReceiveConfigurationParameters[4] = PreTrim(TextBoxDomainSS.Text); - //传递伪装网站 - MainWindow.ReceiveConfigurationParameters[7] = ClassModel.DisguiseURLprocessing(PreTrim(TextBoxMaskSites.Text)); - - } - - //V2Ray-Plugin SS+WebSocket 无TLS模式被选中 - else if (RadioButtonWebSocketSS.IsChecked == true) - { - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "WebSocketSS"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonWebSocketSS.Content.ToString(); - //传递路径 - MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxWebSocketPathSS.Text); - } - - //V2Ray-Plugin SS+WebSocket+TLS+Web模式被选中 - else if (RadioButtonWebSocketTLSWebFrontSS.IsChecked == true || RadioButtonWebSocketTLSWebFrontSSHot.IsChecked == true) - { - domainNotEmpty = ClassModel.TestDomainIsEmpty(TextBoxDomainSS.Text); - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "WebSocketTLSWebFrontSS"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonWebSocketTLSWebFrontSS.Content.ToString(); - - //传递路径 - MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxWebSocketPathSS.Text); - //传递域名 - MainWindow.ReceiveConfigurationParameters[4] = PreTrim(TextBoxDomainSS.Text); - //传递伪装网站 - MainWindow.ReceiveConfigurationParameters[7] = ClassModel.DisguiseURLprocessing(PreTrim(TextBoxMaskSites.Text)); - - } - //V2Ray-Plugin SS+QUIC模式被选中 - else if (RadioButtonQuicSS.IsChecked == true) - { - domainNotEmpty = ClassModel.TestDomainIsEmpty(TextBoxDomainSS.Text); - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "QuicSS"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonQuicSS.Content.ToString(); - - //传递域名 - MainWindow.ReceiveConfigurationParameters[4] = PreTrim(TextBoxDomainSS.Text); - - } - //SS+kcptun-plugin模式被选中 - else if (RadioButtonKcptunPluginSS.IsChecked == true) - { - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "KcptunPluginSS"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonKcptunPluginSS.Content.ToString(); - - } - //SS+GoQuiet-Plugin模式被选中 - else if (RadioButtonGoQuietPluginSS.IsChecked == true) - { - domainNotEmpty = ClassModel.TestDomainIsEmpty(TextBoxDomainSS.Text); - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "GoQuietPluginSS"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonGoQuietPluginSS.Content.ToString(); - //传递域名 - MainWindow.ReceiveConfigurationParameters[4] = PreTrim(TextBoxDomainSS.Text); - - } - //SS+Cloak-Plugin模式被选中 - else if (RadioButtonCloakPluginSS.IsChecked == true) - { - domainNotEmpty = ClassModel.TestDomainIsEmpty(TextBoxDomainSS.Text); - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "CloakPluginSS"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonCloakPluginSS.Content.ToString(); - //传递域名 - MainWindow.ReceiveConfigurationParameters[4] = PreTrim(TextBoxDomainSS.Text); - - } - - //传递服务端口 - MainWindow.ReceiveConfigurationParameters[1] = PreTrim(TextBoxServerListenPortSS.Text); - //传递uuid密码 - MainWindow.ReceiveConfigurationParameters[2] = PreTrim(TextBoxNewUUIDSS.Text); - //传递加密方式 - MainWindow.ReceiveConfigurationParameters[3] = GetEncryptionMethodSS(); - - if (domainNotEmpty == true && preDomainMask == true) - { - this.Close(); - } - - } - - private void ButtondCancel_Click(object sender, RoutedEventArgs e) => Close(); - - - #region 其他设置中的界面控制 - - //无插件的界面 - private void RadioButtonNonePluginSS_Checked(object sender, RoutedEventArgs e) - { - //隐藏Websocket Path - TextBlockWebSocketPathSS.Visibility = Visibility.Collapsed; - TextBoxWebSocketPathSS.Visibility = Visibility.Collapsed; - ButtonWebSocketPathSS.Visibility = Visibility.Collapsed; - - //隐藏域名 - TextBlockDomainSS.Visibility = Visibility.Collapsed; - TextBoxDomainSS.Visibility = Visibility.Collapsed; - //检测域名按钮 - ButtonDomain.Visibility = Visibility.Collapsed; - //隐藏伪装网站 - TextBlockMaskSites.Visibility = Visibility.Collapsed; - TextBoxMaskSites.Visibility = Visibility.Collapsed; - - //初始化密码 - TextBoxNewUUIDSS.Text = GenerateRandomUUID(); - //初始化端口 - - TextBoxServerListenPortSS.Text = GenerateRandomPort().ToString(); - //清除其他选项卡中的选项 - UncheckLayouts((TabItem)TabControlTemplate.SelectedItem); - } - //使用域名,启用TLS 无Websocket的界面 - private void RadioButtonUseDomainTls_Checked(object sender, RoutedEventArgs e) - { - - TextBoxServerListenPortSS.Text = "443"; - //隐藏Websocket Path - TextBlockWebSocketPathSS.Visibility = Visibility.Collapsed; - TextBoxWebSocketPathSS.Visibility = Visibility.Collapsed; - ButtonWebSocketPathSS.Visibility = Visibility.Collapsed; - - //显示域名 - TextBlockDomainSS.Visibility = Visibility.Visible; - TextBoxDomainSS.Visibility = Visibility.Visible; - //检测域名按钮 - ButtonDomain.Visibility = Visibility.Collapsed; - //显示伪装网站 - TextBlockMaskSites.Visibility = Visibility.Visible; - TextBoxMaskSites.Visibility = Visibility.Visible; - - //初始化密码 - TextBoxNewUUIDSS.Text = GenerateRandomUUID(); - //初始化端口 - //TextBoxServerListenPortSS.Text = GenerateRandomPort().ToString(); - //清除其他选项卡中的选项 - UncheckLayouts((TabItem)TabControlTemplate.SelectedItem); - } - - //使用V2ray-plugin 的Websocket over https (TLS) - private void RadioButtonUseDomainWebsocketTls_Checked(object sender, RoutedEventArgs e) - { - - TextBoxServerListenPortSS.Text = "443"; - //显示Websocket Path - TextBlockWebSocketPathSS.Visibility = Visibility.Visible; - TextBoxWebSocketPathSS.Visibility = Visibility.Visible; - ButtonWebSocketPathSS.Visibility = Visibility.Visible; - - //显示域名 - TextBlockDomainSS.Visibility = Visibility.Visible; - TextBoxDomainSS.Visibility = Visibility.Visible; - //检测域名按钮 - ButtonDomain.Visibility = Visibility.Collapsed; - //显示伪装网站 - TextBlockMaskSites.Visibility = Visibility.Visible; - TextBoxMaskSites.Visibility = Visibility.Visible; - - //初始化密码 - TextBoxNewUUIDSS.Text = GenerateRandomUUID(); - - //初始化端口 - - //TextBoxServerListenPortSS.Text = GenerateRandomPort().ToString(); - - //初始化Websocket Path - TextBoxWebSocketPathSS.Text = GenerateRandomPath(); - //清除其他选项卡中的选项 - UncheckLayouts((TabItem)TabControlTemplate.SelectedItem); - } - - #endregion - - //加密方法更改后的动作 - private void ComboBoxEncryptionMethodInfo_SelectionChanged(object sender, SelectionChangedEventArgs e) - { - //传递加密方式 - MainWindow.ReceiveConfigurationParameters[3] = GetEncryptionMethodSS(); - - } - - //产生随机的uuid - private void ButtonNewUUID_Click(object sender, RoutedEventArgs e) - { - TextBoxNewUUIDSS.Text = GenerateRandomUUID(); - } - - //产生随机服务端口 - private void ButtonServerListenPort_Click(object sender, RoutedEventArgs e) - { - TextBoxServerListenPortSS.Text = GenerateRandomPort().ToString(); - } - //产生随机的Path - private void ButtonPath_Click(object sender, RoutedEventArgs e) - { - TextBoxWebSocketPathSS.Text = GenerateRandomPath(); - } - - #region 相关参数生成函数 - //产生随机的UUID - private string GenerateRandomUUID() - { - Guid uuid = Guid.NewGuid(); - return uuid.ToString(); - } - //产生随机端口 - private int GenerateRandomPort() - { - Random random = new Random(); - return random.Next(30001, 50000); - } - //读取加密方式 - private string GetEncryptionMethodSS() - { - //string methodName; - //object methodSelected; - //methodSelected = ComboBoxEncryptionMethodInfo.SelectedValue; - //methodName = methodSelected.ToString(); - //return methodName; - return ComboBoxEncryptionMethodInfo.SelectedValue.ToString(); - } - //产生随机的Path - private string GenerateRandomPath() - { - Random random = new Random(); - int randomSerialNum = random.Next(0, 4); - Guid uuid = Guid.NewGuid(); - string[] pathArray = uuid.ToString().Split('-'); - string path = pathArray[randomSerialNum]; - return $"/{path}"; - } - - #endregion - - //TextBox输入内容做预处理 - private string PreTrim(string preString) - { - return preString.Trim(); - } - - //域名检测是否为空 - //private bool TestDomainIsEmpty() - //{ - // if (string.IsNullOrEmpty(PreTrim(TextBoxDomainSS.Text)) == true) - // { - // //****** "域名不能为空,请检查相关参数设置!" ****** - // MessageBox.Show(Application.Current.FindResource("MessageBoxShow_DomainNotEmpty").ToString()); - // return false; - // } - // else - // { - // return true; - // } - //} - } -} diff --git a/ProxySU/Translations/ProxySU.en-US.xaml b/ProxySU/Translations/ProxySU.en-US.xaml deleted file mode 100644 index a7ff3f0..0000000 --- a/ProxySU/Translations/ProxySU.en-US.xaml +++ /dev/null @@ -1,619 +0,0 @@ - - - The new version has been released! - Downloading...Wait Prompt... - The download of the latest version failed, please try again later! - Download the latest version successfully, the file has been saved in the same directory of the current ProxySU.exe - Update - 界面語言: - Deployment - Resources - Free Wall URL - Common Error - Host: - IP or Domain (Not empty) - Port: - User: - Password: - Key: - Key file Path (Not Empty) - Open... - Password Login - Key Login - No Proxy - Not Login - Requires Login - Proxy Addr: - Email - Acme.sh SSL must an available email address. - Save Installation Log... - Waiting for installation and deployment - System Tools - - Xray template library - Xray one-click installation - Upgrade Xay - - V2Ray Templates - V2ray install - Upgrade V2Ray - Cancel - Trojan-Go Templates - Trojan-Go install - Upgrade Trojan-Go - Cancel - Currently selected plan: - No plan selected - - Parameter settings - Mode: Trojan+TLS+Caddy - Domain: - Port: 443 - Domain Not Empty - Password: - Change - Trojan install - Upgrade Trojan - Cancel - - Mode: NaiveProxy+TLS+Caddy - Random - NaiveProxy install - Cancel - - Mode: SSR+TLS+Caddy - SSR install - - - Mode: MTProto+TLS - MTProto install - Making domain name: - Recommended https ports 443, 2053, 2083, 2087, 2096, 8443 - The secret key will be randomly generated by the server. - - - SS install - SS plug-in library - Classic mode - Tip: This mode, long time, large traffic use, easy to be blocked and interfered, is not recommended! - SS Classic - SS classic use mode, no domain name is required, data is encrypted with high strength, and the data is recognized as unknown data. At present, the traffic is easy to be identified, and it is easy to be interfered and blocked. Use it with caution! Putting here is just a feeling and tribute! - Simple-obfs plug-in - Tip: This is a traffic obfuscation scheme used in the early days of SS. The plug-in has not been updated for a long time and is not recommended! - SS+obfs+http+Web - Does not require a domain name, the data is highly encrypted, the traffic is confused as http (not the real http), and the use of Web site camouflage can enhance the anti-recognition to a certain extent! CDN is not supported. - SS+obfs+TLS(https)+Web - requires a domain name, the use of a domain name will greatly enhance the anti-identification, high-strength data encryption, traffic confusion as https (not real https), the use of Web site camouflage, further enhance the anti-identification! CDN is not supported. - V2Ray plug-in - Reminder: ShadowRocket(ios) does not support SS+Quic mode - SS+WebSocket+TLS+Caddy (Web post) - SS+WebSocket+TLS+Caddy (Web front) - Tip: In the above scheme, there is no difference in the use effect between Web front and Web post. In the Web post scheme, the TLS certificate is applied for by acme.sh. After the certificate expires, acme.sh will automatically renew, but you need to manually restart SS to load the new certificate. The certificate in the web front-end solution is automatically applied for and loaded by Caddy without restarting SS. - SS+QUIC - V2Ray-Plugin uses QUIC protocol for transmission, and TLS encryption is mandatory. Encrypted data transmission, identified as udp traffic, was originally initiated by Google, advantages: reduced delay, multiplexing, connection migration, domain name is required, - - kcptun Plugin - Reminder: Shadowrocket(ios) does not support GoQuiet-plugin. shadowsocks (Android) does not support GoQuiet-plugin and Cloak-plugin plug-ins - KCP is a fast and reliable protocol. It can waste 10%-20% of bandwidth than TCP in exchange for a 30%-40% reduction in average latency and a three-fold reduction in maximum latency The transmission effect. Use UDP protocol for transmission, high-strength data encryption, transmission of the same content, kcp generally consumes more traffic than TCP, and will greatly increase the network speed under lines with high packet loss rates, and may be restricted by QOS at individual operators . - The basic principle is to simulate TLS traffic while disguising the server as a normal web server. This confusion is not the first: simple-obfs and ShadowsocksR’s tls1.2_ticket_auth mode proves this. It works. This plug-in improves the existing methods, and its goal is to make large-scale blockade of HTTPS servers (even IP segments) the only effective way to block SS - Use encryption to confuse proxy traffic into legitimate HTTPS traffic, and disguise the proxy server as a normal Web server to avoid Internet censorship. It can be seen as an upgraded version of GoQuiet above, optimizing the network connection speed, and not confusing https but real https traffic. - Plugin program: - Plugin options: - Use the compilation method, it will take a little longer, please be patient... - - - Proofreading Time - Release 80/443 - Enable BBR - Uninstall Proxy - Enable root password login - root prohibits password login - Enable root certificate key login - Only the proxy software installed by ProxySU and related configurations are supported. Please make sure that important configurations have been backed up. Uninstalling agents installed using other methods or scripts is not supported. Are you sure you want to uninstall the agent software on the remote host? - This function requires that the currently logged-in account has sudo permissions. Is the root account enabled and password set for the remote host? - This function requires that the currently logged-in account has root or sudo authority. Is root certificate key login enabled for the remote host? - This function requires that the remote host has enabled other login methods, such as key mode, etc., otherwise the remote host may not be able to connect. Is the root account password login method of the remote host prohibited? - is closing the root account password login method..... - The remote host root account password login method is closed! - The root account certificate key login of the remote host has been enabled, and the key file rootuser.key is saved in the subsequent opened folder! - The current account already has root privileges, no need to set it up! - The current account cannot obtain sudo permission, the setting failed! - Generate a 20-digit random password! - Save password information! - Generating a key... - The key is being downloaded... - The remote host enables key login....... - The remote host Root account password login is enabled, and the password is saved in the folder opened afterwards! - Start uninstall...... - Detected installed - Uninstallation failed! Please ask the developer! - Uninstall successfully! - - Home - Forward - Back - Due to well-known reasons, loading is slow at certain times, please be patient - - Trojan-go template library - http/2 transmission, Caddy2 camouflage website, anti-recognition, CDN of CloudFlare is not currently supported - Use WebSocket transmission, Caddy2 camouflage website, anti-identification, support CloudFlare CDN - Parameter settings - Domain name: - Port: 443 - Password: - Use the existing password and paste it directly into the box - WebSocket Path: - Mux multiplexing - The settings here are only valid for the official client configuration file config.json, other clients need to be set manually, and the server automatically adapts. - This field does not appear in the QR code and sharing URL. The client needs to set it by itself, and the server enables automatic adaptation by default. - OK - Cancel - - V2Ray Templates - Recommend - EarlyPlan - VLESS - VLESS is a lightweight transmission protocol. Unlike VMess, VLESS don't depend on the system time. The authentication method is also UUID, but alterId is not required. Currently VLESS does not have its own encryption, please use it for reliable channels, such as TLS. Advantages: It can effectively reduce host resource consumption. Currently VLESS does not support sharing. Please ensure that both the client and server v2ray-core are the latest version. - XTLS works well on devices with low performance or without AES hard-decoding. For example, XTLS is used on hard routers, and the network speed can be doubled when the CPU is full, or the same The CPU occupancy rate is halved at Internet speed, and for mobile devices, the reduction in the amount of calculation means power saving.Version requires 4.29+ (Domain required) Not support CDN. - Lightweight protocol VLESS, occupies less host resources, data TLS encrypted transmission, and Caddy2 is used as a disguised website on the node. Suitable for VPS with low configuration, or shared nodes by multiple people, the server client version requires 4.27+ (Domain required) Notsupport CDN. - VLESS protocol, this type of solution with VMESS is more lightweight. Stability is strong, Caddy2 is front-facing, hidden proxy features, it is recognized as https traffic visiting the website, the strongest anti-blocking recognition, (Domain required) CDN is supported - VLESS protocol, this type of solution with VMESS is more lightweight. Based on HTTP/2 transmission. Completely implemented in accordance with the HTTP/2 standard, with Caddy2 as the front, hidden proxy features, H2C protocol forwarding to V2Ray, (Domain required) CloudFlare CDN is not supported - TCP - WebSocket - Http/2 - mKCP - QUIC - Parameter settings - Server port: - Random - If TLS encryption is used, please keep the default port 443 - Use the existing UUID and paste it directly into the box - QUIC Key: - mKCP Seed: - Enable the mKCP Seed key to enhance anti-recognition, leave it blank to disable it. Version 4.24.2+ - Path: - VLESS ws path: - VMESS tcp path: - VMESS ws path: - QUIC Encryption: - Domain name: - Trojan password is the same as V2ray UUID. - Mask a website: - Set this option to increase proxy concealment (can be empty) - Enter only the domain name, excluding "http" and "/" etc. - Only forbid root account to log in with password, please make sure that other login methods of root account have taken effect - The root account will be enabled and set to password login - will enable or set the root account as the key certificate login - The input format of the fake URL is wrong! please enter again! - Strong stability, Caddy2 as the front, hidden proxy feature, recognized as https traffic to the website, the strongest anti-blocking recognition, domain name is required, CDN support - based on HTTP/2 transmission. Completely implemented in accordance with the HTTP/2 standard, with Caddy2 as the front, hidden proxy features, H2C protocol forwarding to V2Ray, domain name is required, and CloudFlare CDN is not currently supported - Currently Xray is a superset of V2Ray, and it will have a different development direction from V2Ray in the future. - VLESS over TCP with XTLS + fallback and shunt to WHATEVER (ultimate configuration), configured and recommended by rprx boss (author of xtls), configure the following six solutions at the same time on the server side, sharing the same domain name and port 443, WS can pass through CDN. - VLESS over TCP with XTLS + fallback and shunt to WHATEVER (ultimate configuration), configured and recommended by rprx boss (author of xtls), configure the following five solutions at the same time on the server side, sharing the same domain name and port 443, WS can pass through CDN.(If you want to add XTLS scheme, please use Xray configuration) - Encrypted data transmission will be recognized as unknown tcp traffic - TCP+Http camouflage - Encrypted data transmission and HTTP disguise will be recognized as http traffic, but not real http access - Data encrypted transmission, the transmission protocol uses TLS, it will be recognized as TLS traffic, not equivalent to https traffic characteristics (domain name required) - TCP+TLS (self-signed certificate) - Data encrypted transmission, the transmission protocol uses TLS, it will be recognized as TLS traffic, not equivalent to https traffic characteristics (no domain name required) - Shadowrocket (ios) needs to manually open the "Allow Unsafe" option - Data encrypted transmission, the transmission protocol uses WebSocket, if TLS is not enabled, it will be recognized as WebSocket traffic. - Data encrypted transmission, the transmission protocol uses WebSocket, and TLS is enabled, it will be recognized as TLS traffic. (Domain name required),Support CDN. - WebSocket+TLS (self-signed certificate) - Data encrypted transmission, the transmission protocol uses WebSocket, and TLS is enabled, and it will be recognized as TLS traffic. (No domain name required) - The transmission method based on HTTP/2. It is fully implemented in accordance with the HTTP/2 standard and requires a domain name - HTTP2 (self-signed certificate) - The transmission method based on HTTP/2. It is fully implemented in accordance with the HTTP/2 standard, uses a self-signed certificate, and does not require a domain name - mKCP (no camouflage) - Encrypted data transmission to increase bandwidth usage and reduce delay, udp protocol, no camouflage, will be recognized as udp traffic - Same as mKCP (without camouflage), add disguised as SRTP packet, it will be recognized as video call data (such as FaceTime) - Same as mKCP (without camouflage), adding a uTP packet disguised as a uTP data packet will be recognized as BT download data - Same as mKCP (no camouflage), adding data packets disguised as WeChat video calls - Same as mKCP (without camouflage), add disguised as DTLS 1.2 data packet - Same as mKCP (without camouflage), with the addition of disguised as WireGuard packets. (Not the real WireGuard protocol) - Reminder: Shadowrocket currently does not support QUIC transmission mode. - QUIC (no camouflage) - Encrypted data transmission, no pretense will be recognized as udp traffic, originally created by Google, advantages: reduced delay, multiplexing, connection migration - Same as QUIC (no camouflage), adding a packet disguised as SRTP, it will be recognized as video call data (such as FaceTime) - Same as QUIC (without camouflage), add disguised as uTP data packet, it will be recognized as BT download data - Same as QUIC (no camouflage), adding data packets disguised as WeChat video calls - Same as QUIC (without camouflage), add disguised as DTLS 1.2 packet - Same as QUIC (without camouflage), adding a pretend to be a WireGuard packet. (Not the real WireGuard protocol) - - Sync Network Time - Correct the remote host time to the network time. Note: The time of the local computer must also be synchronized with the network time, otherwise the local computer V2ray may have a connection error Recommendation: First use this method to proofread time - Sync local time - Synchronize the remote host’s time to the local time. Note: The local computer’s time must be accurate and synchronized with the network time, otherwise there may be connection errors in other clients Use this method when you can’t check the time when using the network - Update the local time - Synchronize the local computer time with the network time. Note: To use this function, you must run this program as an administrator - Detection Time - Proofread - - Client configuration parameters - Server address: - Port: - User ID(uuid)/Password: - Copy - Copied to the clipboard! - Empty content! - alterId: - The default is 16, and you can fill in a value not exceeding 64. If the client does not have this option, leave it blank - Encryption method: - Transfer Protocol: - Camouflage type(Confuse): - TLS Set: - Tip: Double-click the above content window to copy it to the clipboard. - Path: - mKCP Seed/QUIC key: - default auto - QR/URL - The above parameters can be entered into the client manually or by scanning. The configuration and related files used for the official client have been stored in the directory. Click the OK button to open - QR code and URL link can be used v2rayN(windows) Qv2ray(windows) Qv2ray(windows) Shadowrocket(ios) v2rayNG(Android) Import v2ray node Note: The Vless protocol requires manual input of configuration parameters, and the QR code and URL are invalid - " can be used for ShadowRocket (ios), ignore (Android), Qv2ray (windows) to scan codes and import URLs. Note: some clients may not support WebSocket mode ." - "Can be used for ShadowRocket (ios), ignore (Android), Qv2ray (windows) to scan codes and import URLs. Note: Some clients may not support WebSocket mode." - URL import link for NaiveSharp (windows) - Used to scan codes and import URL import links for ShadowsocksR (windows), SSRR (android), Shadowrocket (ios) - For mobile phone client shadowsocks(android), Shadowrocket(ios) scan code and URL import link - For the computer client Shadowsocks (windows) scan code and URL import link - Scan code and URL import link for Shadowsocks (windows), shadowsocks(android), Shadowrocket(ios) - Reminder: The import format of the computer client Shadowsocks (windows) and the mobile client shadowsocks (android) and Shadowrocket (ios) are not compatible. Please select the corresponding format. - Mobile phone - Computer side - TG format QR - TG format URL (double-click to copy to the clipboard) - T.ME format QR - T.ME format URL (double-click to copy to the clipboard) - - Host address, host port, and user name are required and cannot be empty!! - The connection port contains non-numeric characters! - The login password is required and cannot be empty!! - The key file is required and cannot be empty!! - If a proxy is selected, the proxy address and port cannot be empty! - If the proxy needs to log in, the user name and password for proxy login cannot be empty! - The remote host connection information is wrong, please check! - Please select a configuration template first! - An error occurred, the installation was interrupted... - Logging in to the remote host... - The host login is successful! - Detect whether it is running under root permissions... - Please use an account with root permissions to log in to the host! ! - Detection result: OK! - Check whether the system has been installed - The remote host has been installed - , it is recommended to uninstall first, or reinstall the system, if the forced installation may fail. Do you force a reinstallation? - installation canceled, exit - Selected mandatory installation - Test result: not installed - Check whether the system meets the installation requirements... - The current system kernel version is - , V2ray requires the kernel to be 2.6.23 and above. Please upgrade the kernel and install again! - The system kernel version does not meet the requirements, and the installation failed! ! - The system lacks necessary installation components such as: apt||dnf||yum||zypper||Syetemd, the host system is recommended to use: CentOS 7/8, Debian 8/9/10 ,Ubuntu 16.04 and above - The system environment does not meet the requirements, and the installation fails! ! - Test result: OK! - It is detected that the system has SELinux enabled and it is working in strict mode. It needs to be changed to relaxed mode! Modifying... - The modification is complete! - Proofreading time... - The difference between the local time and the remote host’s time exceeds the limit (90 seconds), please use'System Tools-->Time Correction' to verify the time before setting - Time comparison failed... - The time difference meets the requirements, OK! - is checking whether the domain name is resolved to the IP of the current VPS... - is detecting whether it is a pure ipv6 host... - A valid IP address was not detected... - Finding the fastest Nat64 gateway... - Failed to find a valid Nat64 gateway... - The fastest Nat64 gateway of the current host is: - Nat64 gateway is being set up...... - Nat64 gateway is being deleted... - The resolution is correct! OK! - detects that the current host is a pure ipv6 host, it is not currently supported! - The domain name could not be correctly resolved to the IP of the current VPS! Installation failed! - The domain name cannot be correctly resolved to the IP of the current VPS, please check! If the resolution setting is correct, please wait for it to take effect before retrying the installation. If the domain name uses CDN, please close it first! - Detect port occupancy... - If one or all of the 80/443 ports are occupied, will the program occupying 80/443 ports be forcibly stopped? - The port is occupied and the installation failed... - is releasing port 80/443... - The release of port 80/443 is complete! - The port is occupied, will the program occupying this port be forcibly stopped? - Release the port... - The port is released! - Test result: Not occupied! - The system environment has been tested and the installation requirements are met, and the deployment begins... - Open the corresponding port of the firewall... - Installing - File download failed! - Compiling, please wait patiently............. - The installation failed, the script runs incorrectly! - The installation is successful! - After installation, upload the configuration file...... - Installing acme.sh...... - acme.sh is installed successfully! - acme.sh installation failed! The reason is unknown, please ask the developer! - Apply for domain name certificate... - The certificate application is successful! - Certificate application failed! The reason is unknown, please ask the developer! - Install the certificate to - The certificate is successfully installed to - The certificate is installed to - failed, the reason is unknown, you can ask the developer! - Install Caddy... - Test result: Caddy is not installed! - The installation of Caddy failed! - Caddy installed successfully! - is upgrading the Caddy v2.2.0 beta version for Http2Web mode! - Upload Caddy configuration file... - Caddy configuration file upload failed! - The Caddy configuration file is uploaded successfully, OK! - Starting Caddy... - Caddy started successfully! - Caddy failed to start! - Starting Caddy (second attempt)! - Caddy failed to start (second time)! Exit the installation! - Caddy failed to start, the reason is unknown! Please ask the developer! - Starting - Startup is successful! - Startup failed! - is trying to start the second time - failed to start (second time)! Exit the installation! - Startup failed, the reason is as above! Please troubleshoot the reason! - BBR test... - Enable BBR... - BBR has been enabled! - The system does not meet the conditions for enabling BBR, and the enabling failed! - BBR is successfully activated! - Generate client configuration... - Failed to obtain client configuration! - The installation is successful, Enjoy it!! - Installation Failed! - An error occurred! - Wrong password or wrong username! - Please check whether the host address and port are correct, if it passes the proxy, please check whether the proxy is working properly - The selected key file is wrong or the format is wrong! - Login using the key, the key file is wrong or the user name is wrong! - The host address is wrong. If a proxy is used, it may also be the wrong port to connect to the proxy! - Exit! Reason: The remote host is not installed - V2Ray using the old installation script is detected... - The V2Ray using the old installation script is detected. Do you want to uninstall the old version and reinstall it with the new installation script? - Uninstalling the old version... - Uninstall the old version, OK! - Install the new version... - Migrate the original configuration file. - has been updated to the latest version. - The current version of the remote host is: v - The latest version is: - Is it upgraded to the latest version? - Upgrading to the latest version - The upgrade is successful! It is currently the latest version! - The upgrade failed. The reason is unknown. Please ask the developer! - Upgrade is cancelled, exit! - The remote host is currently the latest version: - No need to upgrade! drop out! - The domain name cannot be empty, please check the relevant parameter settings! - Please install in x86_64 system - Back up the Trojan configuration file... - Restore the Trojan configuration file... - "Caddy has been installed on the remote host, but I’m not sure whether it supports forward proxy. Do I force a reinstallation?" - Please uninstall Caddy or reinstall the VPS system first! - Installing dependent software...... - The installation is complete! OK! - Installing Caddy..... - The server is being upgraded for NaiveProxy - The upgrade is complete, OK! - Optimizing network parameters... - Optimize network parameters, OK! - - This file is the client configuration file used by the official Xay program. It is configured in global mode, socks5 address: 127.0.0.1:1080, http proxy address: 127.0.0.1:1081 - Xray official website: https://github.com/XTLS/Xray-core - Xray official program download address: https://github.com/XTLS/Xray-core/releases - Download the corresponding version, select xray-windows-64.zip or xray-windows-32.zip for Windows, extract xray.exe after decompression. Put it in the same directory as config.json, just run xray.exe. - - This file is the client configuration file used by the official V2Ray program. It is configured in global mode, socks5 address: 127.0.0.1:1080, http proxy address: 127.0.0.1:1081 - v2ray official website: https://www.v2ray.com/ - v2ray official program download address: https://github.com/v2ray/v2ray-core/releases - download the corresponding version, Windows select v2ray-windows-64.zip or v2ray-windows-32.zip, extract v2ctl.exe and v2ray.exe after decompression. Put it in the same directory as config.json, just run v2ray.exe. - This file is v2rayN, Qv2ray, v2rayNG(Android), Shadowrocket(ios) scan code import node - v2rayN download URL: https://github.com/2dust/v2rayN/releases - Qv2ray download URL: https://github.com/Qv2ray/Qv2ray/releases - v2rayNG(Android) download URL: https://github.com/2dust/v2rayNG/releases - v2rayNG (Android) download URL on Google Play: https://play.google.com/store/apps/details?id=com.v2ray.ang - Shadowrocket(ios) download, you need to use the AppleID of the foreign region. Please Google method yourself. - This file is v2rayN, Qv2ray, v2rayNG(Android), Shadowrocket(ios) copy and paste the vmess URL of the imported node - Server general connection configuration parameters - - This file is the client configuration file used by the official Trojan-go program, configured in global mode, http and socks5 address: 127.0.0.1:1080 - Trojan-go official website: https://github.com/p4gefau1t/trojan-go - Trojan-go official program download address: https://github.com/p4gefau1t/trojan-go/releases - Download the corresponding version, select Trojan-go-x.xx-win.zip for Windows, extract trojan-go.exe after decompression. Put it in the same directory as config.json, just run trojan-go.exe. - This file is for Qv2ray (windows), ignore (Android) scan code import node - Qv2ray (windows) download URL: https://github.com/Qv2ray/Qv2ray/releases - igniter (Android) download URL: https://github.com/trojan-gfw/igniter/releases - Shadowrocket(ios) download, you need to use the AppleID of the foreign region. Please Google method yourself. - This file is Qv2ray (windows), ignore (Android)copy and paste the URL of the imported node - Server general connection configuration parameters - - This file is the client configuration file used by the official Trojan program. It is configured in global mode, http and socks5 address: 127.0.0.1:1080 - Trojan official website: https://trojan-gfw.github.io/trojan/ - Trojan official program download address: https://github.com/trojan-gfw/trojan/releases - Download the corresponding version, select Trojan-x.xx-win.zip for Windows, extract trojan.exe after decompression. Put it in the same directory as config.json, just run trojan.exe. - This file is Qv2ray (windows), ignore (Android), Shadowrocket (ios) scan code import node - Qv2ray (windows) download URL: https://github.com/Qv2ray/Qv2ray/releases - igniter (Android) download URL: https://github.com/trojan-gfw/igniter/releases - Shadowrocket(ios) download, you need to use the AppleID of the foreign region. Please Google method yourself. - This file is Qv2ray (windows), ignore (Android), Shadowrocket (ios) copy and paste the URL of the imported node - Server general connection configuration parameters - - This file is the client configuration file used by the official NaiveProxy program, configured in global mode, socks5 address: 127.0.0.1:1080 - NaiveProxy official website: https://github.com/klzgrad/naiveproxy - NaiveProxy official program download address: https://github.com/klzgrad/naiveproxy/releases - download the corresponding version, select naiveproxy-x.xx-win.zip for Windows, extract naive.exe after decompression. Put it in the same directory as config.json, just run naive.exe. - This file is NaiveSharp (windows) copy and paste the URL of the imported node - NaiveSharp(windows) download URL: https://github.com/KevinZonda/NaiveSharp/releases - Server general connection configuration parameters - - This file is for ShadowsocksR (windows), SSRR (Android), Shadowrocket (ios) scan code import node - ShadowsocksR (windows) download URL: https://github.com/shadowsocksrr/shadowsocksr-csharp/releases - SSRR (Android) download URL: https://github.com/shadowsocksrr/shadowsocksr-android/releases - Shadowrocket(ios) download, you need to use the AppleID of the foreign region. Please Google method yourself. - This file is ShadowsocksR (windows), SSRR (Android), Shadowrocket (ios) copy and paste the URL of the imported node - Server general connection configuration parameters - - This file is a Shadowsocks (windows) scan code import node - This file is Shadowsocks (windows) copy and paste the URL of the imported node - This file is for shadowsocks (Android), Shadowrocket (ios) scan code to import nodes - Shadowsocks (windows) download URL: https://github.com/shadowsocks/shadowsocks-windows/releases - shadowsocks (Android) download URL: https://github.com/shadowsocks/shadowsocks-android/releases - Shadowrocket(ios) download, you need to use the AppleID of the foreign region. Please Google method yourself. - This file is shadowsocks (Android), Shadowrocket (ios) copy and paste the URL of the imported node - Server general connection configuration parameters - plug-in instructions - ProxySU defaults all plug-ins, under the subfolder plugins of the folder where the Shadowsocks (windows) run file is located. - Instructions for manually installing the plug-in on the computer - First download the plug-in, the download address of each plug-in Windows client is: - Simple-obfs: https://github.com/shadowsocks/simple-obfs/releases only download obfs-local.zip - V2ray-plugin: https://github.com/shadowsocks/v2ray-plugin/releases 64-bit system selection: v2ray-plugin-windows-amd64-vx.xxtar.gz , 32-bit system selection: v2ray-plugin-windows-386-vx.xxtar.gz (x is a number, is the version number) - Kcptun-plugin: https://github.com/shadowsocks/kcptun/releases 64-bit system selection: kcptun-windows-amd64-xxxxxx.tar.gz, 32-bit system selection :Kcptun-plugin-windows-386-xxxxxx.tar.gz (x is a number, is the version number) - GoQuiet-plugin: https://github.com/cbeuw/GoQuiet/releases 64-bit system selection: gq-client-windows-amd64-xxxexe, 32-bit system selection: gq-client-windows-386-xxxexe (x is a number, is the version number) - Cloak-plugin: https://github.com/cbeuw/Cloak/releases 64-bit system selection: ck-client-windows-amd64-xxxexe, 32-bit system selection: ck-client-windows-386-xxxexe (x is a number, is the version number) - In the folder where the Shadowsocks (windows) run file is located, create a new folder plugins, and copy all the files (two) extracted from obfs-local.zip to plugins, v2ray -plugin download the file, unzip the file, copy it to plugins, and rename it to: v2ray-plugin.exe. Kcptun-plugin downloads the file, unzip the two files, copy the file starting with client_windows into the plugins, and rename it to: kcptun-client.exe. The file downloaded by GoQuiet-plugin is directly copied to the plugin and renamed to: goquiet-client.exe. The file downloaded by Cloak-plugin is directly copied to the plugin and renamed to: cloak-client.exe - installation completed - Mobile Android client plug-in installation instructions - first download the plug-in, the download address of each plug-in Android client is: - Simple-obfs: https://github.com/shadowsocks/simple-obfs-android/releases only download obfs-local-nightly-xxxapk (x is a number, is the version Number) - V2ray-plugin: https://github.com/shadowsocks/v2ray-plugin-android/releases Generally choose v2ray--universal-xxxapk (x is a number, is the version number ) - Kcptun-plugin: https://github.com/shadowsocks/kcptun-android/releases Generally choose kcptun--universal-xxxapk (x is a number, is the version number) - Transfer the above apk file to the phone and install it! - - - - - - \ No newline at end of file diff --git a/ProxySU/Translations/ProxySU.zh-CN.xaml b/ProxySU/Translations/ProxySU.zh-CN.xaml deleted file mode 100644 index 1db4354..0000000 --- a/ProxySU/Translations/ProxySU.zh-CN.xaml +++ /dev/null @@ -1,507 +0,0 @@ - - - 最新版本已发布了,快去更新一下吧! - 正在下载最新版,请等待完成提示.... - 最新版下载失败,请稍后重试! - 下载最新版成功,文件已存入当前ProxySU.exe同一目录 - 下载更新 - Languages: - 应用布署 - 资源工具 - 免翻网址资源 - 常见问题 - 主机: - IP或域名(不可为空) - 端口: - 用户: - 密码: - 密钥: - 密钥文件存放路径(不可为空) - 浏览... - 密码登录 - 密钥登录 - 无代理 - 不需登录 - 需要登录 - 代理地址: - Email - 申请SSL证书需要一个可用的Email地址 - 安装日志另存为... - 等待安装布署 - 系统工具 - - Xray模板库 - Xray一键安装 - 升级Xay - - V2Ray模板库 - V2ray一键安装 - 升级V2ray - 取消 - - Trojan-Go参数设置 - Trojan-Go一键安装 - 升级Trojan-Go - 取消 - 当前所选方案: - 未选择方案 - - 参数设置 - 模式:Trojan+TLS+Caddy - 服务器地址(域名): - 端口:443 - 域名不可为空 - 密码: - 更新 - Trojan一键安装 - 升级Trojan - 取消 - - 模式:NaiveProxy+TLS+Caddy - 随机 - NaiveProxy一键安装 - 取消 - - 模式:SSR+TLS+Caddy - SSR一键安装 - - - 模式:MTProto+TLS - MTProto一键安装 - 伪装域名: - 推荐用常见https端口443、2053、2083、2087、2096、8443 - 密钥将由服务端随机生成,这里无需设置。 - - - SS 一键安装 - SS 插件库 - 经典模式 - 提示:这种模式,长时间,大流量使用,容易被阻断和干扰,不推荐使用! - SS 经典 - SS经典使用模式,无需域名,数据高强度加密,数据被识别为未知数据。目前流量容易被识别,极易被干扰与阻断,慎重使用!放在这里仅仅只是一种情怀与致敬! - Simple-obfs 插件 - 提示:这是SS早期使用的流量混淆方案,插件已经长时间不再更新,不推荐使用! - SS+obfs+http+Web - 无需域名,数据高强度加密,流量混淆为http(并非真正的http),使用Web网站伪装,可在一定程度上增强抗识别!不支持CDN。 - SS+obfs+TLS(https)+Web - 需要域名,使用域名将很大增强抗识别,数据高强度加密,流量混淆为https(并非真正的https),使用Web网站伪装,进一步增强抗识别!不支持CDN。 - V2Ray 插件 - 提醒:ShadowRocket(ios)不支持SS+Quic模式 - SS+WebSocket+TLS+Caddy(Web后置) - SS+WebSocket+TLS+Caddy(Web前置) - 提示:上面方案中的Web前置与Web后置,使用效果上没有差别,Web后置方案,TLS证书由acme.sh申请,证书到期后,acme.sh会自动续期,但是需要手动重启SS加载新证书。而Web前置方案中的证书由Caddy自动申请并加载,不需要重启SS。 - SS+QUIC - 通过V2Ray-Plugin使用QUIC协议传输,强制使用TLS加密。数据加密传输,被识别为udp流量,最初由谷歌创始,优点:减少延迟、多路复用、连接迁移,需要域名, - - kcptun 插件 - 提醒:Shadowrocket(ios)不支持GoQuiet-plugin插件。shadowsocks(Android)不支持GoQuiet-plugin与Cloak-plugin插件 - KCP是一个快速可靠协议,能以比 TCP浪费10%-20%的带宽的代价,换取平均延迟降低 30%-40%,且最大延迟降低三倍的传输效果。使用UDP协议传输,数据高强度加密,传输同样的内容,kcp 一般比 TCP 消耗更多的流量,在丢包率高的线路下将极大提高网速,在个别运营商处可能会被QOS限制。 - 基本原理为模拟TLS的流量同时将服务器伪装成一个正常的网站服务器,这个混淆思路并非首创:simple-obfs和ShadowsocksR的tls1.2_ticket_auth模式证明这条道是行得通的。此插件对现有的方法进行了改善,其目标为让大规模封锁HTTPS服务器(甚至IP段)成为封锁SS的唯一有效手段 - 通过加密方式将代理流量混淆为合法的HTTPS流量,并将代理服务器伪装成普通的Web服务器以规避互联网审查。可以看成是上面GoQuiet升级版,优化网络连接速度,并且不是混淆https而是真正的https流量。 - 插件程序: - 插件选项: - 使用编译方式,时间稍长,请耐心等待...... - - - 校对时间 - 释放80/443端口 - 启用BBR - 卸载代理 - 启用root密码登录 - 启用root证书密钥登录 - root禁止密码登录 - 仅支持卸载由ProxySU安装的代理软件及相关配置,请确保重要配置已备份。不支持卸载使用其他方法或脚本安装的代理。确定要卸载远程主机上的代理软件吗? - 本功能需要当前登录的账户具有sudo权限,是否为远程主机启用root账户并设置密码? - 本功能需要当前登录的账户具有root或者sudo权限,是否为远程主机启用root证书密钥登录? - 本功能需要远程主机已经开启了其他登录方式,如密钥方式等,否则将可能造成远程主机无法连接,是否禁止远程主机的root账户密码登录方式? - 正在关闭root账户密码登录方式..... - 远程主机root账户密码登录方式已关闭! - 远程主机root账户证书密钥登录已启用,密钥文件rootuser.key保存在随后打开的文件夹中! - 当前账户已经具有root权限,无需再设置! - 当前账户无法获取sudo权限,设置失败! - 生成20位随机密码! - 保存密码信息! - 正在生成密钥...... - 正在下载密钥...... - 远程主机启用密钥登录....... - 远程主机Root账户密码登录已启用,密码保存在随后打开的文件夹中! - 开始卸载 - 检测到已安装 - 卸载失败!请向开发者问询! - 卸载成功! - - - 主页 - 前进 - 后退 - 由于众所周知的原因,在某些时候,加载缓慢,请耐心等待一下 - - Trojan-go 模板库 - http/2传输,Caddy2伪装网站,抗识别,暂不支持CloudFlare的CDN - 使用WebSocket传输,Caddy2伪装网站,抗识别,支持CloudFlare的CDN - 参数设置 - 域名: - 端口: 443 - 密码: - 使用已有密码,直接粘贴到框中 - WebSocket路径: - Mux多路复用 - 此处设置只对官方客户端配置文件config.json有效,其他客户端需手动设置,服务端自动适配。 - 此字段不出现在QR码及分享URL中,客户端需自行设置,服务端默认启用自动适配。 - 确定 - 取消 - - V2Ray 模板库 - 推荐方案 - 尝鲜方案 - VLESS协议 - VLESS 是一个无状态的轻量传输协议,与 VMess 不同,VLESS 不依赖于系统时间,认证方式同样为 UUID,但不需要 alterId。目前 VLESS 没有自带加密,请用于可靠信道,如 TLS。优点:可以有效的降低主机资源消耗。目前 VLESS 不支持分享。VLESS 处于公测阶段,测试期间请确保客户端与服务端的 v2ray-core 均为最新版本。 - XTLS 在低性能或没有 AES 硬解的设备上效果出众,如在硬路由上换用 XTLS,同样跑满 CPU 时实现网速 翻倍,或是相同网速时 CPU 占用率减半,而对于移动设备,计算量减少意味着省电。服务端客户端版本要求4.29+ (需域名)不支持CDN。 - 轻量协议VLESS,占用更少主机资源,数据TLS加密传输,用Caddy2在节点上做伪装网站。适合配置低的VPS,或多人共用节点,服务端客户端版本要求4.27+ (需域名)不支持CDN。 - 使用VLESS协议,与VMESS的此类型方案,更轻量。稳定性强,Caddy2做前置,隐藏代理特征,被识别为访问网站的https流量,抗封锁识别最强,需要域名,支持CDN - 使用VLESS协议,与VMESS的此类型方案,更轻量。基于 HTTP/2 传输。完整按 HTTP/2 标准实现,Caddy2做前置,隐藏代理特征,H2C协议转发到V2Ray,需要域名,暂不支持CloudFlare的CDN - - TCP传输协议 - WebSocket传输协议 - Http/2传输协议 - mKCP传输协议 - QUIC传输协议 - 参数设置 - 服务器端口: - 随机选择 - 若使用TLS加密,请保持默认的443端口 - 使用已有UUID,直接粘贴到框中 - QUIC密钥: - mKCP Seed: - 启用mKCP Seed密钥,可增强抗识别,留空则禁用,要求版本4.24.2+ - 路径: - VLESS ws路径: - VMESS tcp路径: - VMESS ws路径: - - QUIC加密方式: - 域名: - Trojan密码与UUID相同。 - 伪装网站: - 设置此项可增加代理的隐蔽(可为空) - 仅仅输入域名,不包括"http"及"/"等 - 仅仅禁止root账户使用密码登录,请确保root账户其他登录方式已生效 - 将启用root账户,并设置为密码登录 - 将启用或设置root账户为密钥证书登录 - 伪装网址输入格式错误!请重新输入! - 稳定性强,Caddy2做前置,隐藏代理特征,被识别为访问网站的https流量,抗封锁识别最强,需要域名,支持CDN - 基于 HTTP/2 传输。完整按 HTTP/2 标准实现,Caddy2做前置,隐藏代理特征,H2C协议转发到V2Ray,需要域名,暂不支持CloudFlare的CDN - 当前Xray是V2Ray的超集,未来与V2Ray会有不同的发展方向。 - VLESS over TCP with XTLS + 回落 and 分流 to WHATEVER(终极配置),由rprx大佬 (xtls作者) 配置并推荐,在服务端同时配置以下六种方案,共用同一域名与443端口,其中 WS 都可以通过 CDN。 - VLESS over TCP with XTLS + 回落 and 分流 to WHATEVER(终极配置),由rprx大佬 (xtls作者) 配置并推荐,在服务端同时配置以下五种方案,共用同一域名与443端口,其中 WS 都可以通过 CDN。(想增加XTLS方案请使用Xray配置) - TCP+Http伪装 - 数据加密传输,会被识别为未知的tcp流量 - 数据加密传输,并做http伪装,会被识别为http流量,但并不是真正的http访问 - 数据加密传输,传输协议使用TLS,会被识别为TLS流量,不等同于https流量特征 (需域名) - TCP+TLS(自签证书) - 数据加密传输,传输协议使用TLS,会被识别为TLS流量,不等同于https流量特征 (无需域名) - Shadowrocket (ios)需要手动打开“允许不安全”选项 - 数据加密传输,传输协议使用WebSocket,未启用TLS,将被识别为WebSocket流量。 - 数据加密传输,传输协议使用WebSocket,启用TLS,将被识别为TLS流量。(需要域名)支持CDN。 - WebSocket+TLS(自签证书) - 数据加密传输,传输协议使用WebSocket,启用TLS,将被识别为TLS流量。(无需域名) - 基于 HTTP/2 的传输方式。它完整按照 HTTP/2 标准实现,需要域名 - HTTP2(自签证书) - 基于 HTTP/2 的传输方式。它完整按照 HTTP/2 标准实现,使用自签名证书,不需要域名 - mKCP(无伪装) - 数据加密传输,以增加带宽占用,减少延迟,udp协议,无伪装,会被识别为udp流量 - 同mKCP(无伪装),增加伪装成 SRTP 数据包,会被识别为视频通话数据(如 FaceTime) - 同mKCP(无伪装),增加伪装成 uTP 数据包,会被识别为 BT 下载数据 - 同mKCP(无伪装),增加伪装成微信视频通话的数据包 - 同mKCP(无伪装),增加伪装成 DTLS 1.2 数据包 - 同mKCP(无伪装),增加伪装成 WireGuard 数据包。(并不是真正的 WireGuard 协议) - 提醒:Shadowrocket目前暂不支持QUIC的传输模式。 - QUIC(无伪装) - 数据加密传输,无伪装会被识别为udp流量,最初由谷歌创始,优点:减少延迟、多路复用、连接迁移 - 同QUIC(无伪装),增加伪装成 SRTP 数据包,会被识别为视频通话数据(如 FaceTime) - 同QUIC(无伪装),增加伪装成 uTP 数据包,会被识别为 BT 下载数据 - 同QUIC(无伪装),增加伪装成微信视频通话的数据包 - 同QUIC(无伪装),增加伪装成 DTLS 1.2 数据包 - 同QUIC(无伪装),增加伪装成 WireGuard 数据包。(并不是真正的 WireGuard 协议) - - 同步网络时间 - 将远程主机时间校正为网络时间,注意:本机电脑的时间必须也是与网络时间同步的,否则本机电脑V2ray有可能连接出错 推荐:优先使用此方法校对时间 - 同步本机时间 - 将远程主机时间同步为本地时间,注意:本机电脑的时间必须是准确的,与网络时间同步的,否则其他客户端中,有可能连接出错 使用网络校时无法校对时间时,使用此种方法 - 更新本机时间 - 将本机电脑时间与网络时间同步。 注意:使用此项功能,必须以管理员身份运行本程序 - 检测时间误差 - 校对时间 - - 客户端配置参数 - 服务器地址(address): - 端口(port): - 用户ID(uuid)/密码: - 复制 - 已复制到剪贴板中! - 空内容! - 额外ID: - 不超过64,客户端没此项可不填 - 加密方式: - 传输协议: - 伪装类型(混淆): - TLS设置: - 提示:双击以上内容窗,即可复制到剪贴板中。 - 路径(Path): - QUIC密钥: - mKCP Seed: - 默认auto - 二维码/URL - 以上参数可以手动或扫描输入客户端,用于官方客户端的配置和相关文件已经存放入目录下,点击 确定 按扭可打开 - 二维码和URL链接可用于 v2rayN(windows) Qv2ray(windows) Qv2ray(windows) Shadowrocket(ios) v2rayNG(Android) 导入v2ray节点 注意:Vless协议需要手动输入配置参数,二维码和URL无效 - "可用于ShadowRocket (ios)、igniter(Android)、Qv2ray (windows) 扫码和导入url。注意:有的客户端可能不支持WebSocket模式。" - "可用于ShadowRocket (ios)、igniter(Android)、Qv2ray (windows) 扫码和导入url。注意:有的客户端可能不支持WebSocket模式。" - 用于NaiveSharp(windows)的URL导入链接 - 用于ShadowsocksR(windows)、SSRR(android)、Shadowrocket(ios)的扫码和URL导入链接 - 用于手机客户端shadowsocks(android)、Shadowrocket(ios)的扫码和URL导入链接 - 用于电脑客户端Shadowsocks (windows)的扫码和URL导入链接 - 用于Shadowsocks (windows)、shadowsocks(android)、Shadowrocket(ios)的扫码和URL导入链接 - 提醒: 电脑客户端Shadowsocks (windows)与手机客户端shadowsocks(android)、Shadowrocket(ios)的导入格式不兼容,请选择相应格式。 - 手机端 - 电脑端 - TG格式QR - TG格式URL(双击复制到剪切板中) - T.ME格式QR - T.ME格式URL(双击复制到剪切板中) - - - 主机地址、主机端口、用户名为必填项,不能为空!! - 连接端口含有非数字字符! - 登录密码为必填项,不能为空!! - 密钥文件为必填项,不能为空!! - 如果选择了代理,则代理地址与端口不能为空! - 如果代理需要登录,则代理登录的用户名与密码不能为空! - 远程主机连接信息有误,请检查! - 请先选择配置模板! - 发生错误,安装中断...... - 正在登录远程主机...... - 主机登录成功! - 检测是否运行在root权限下... - 请使用具有root权限的账户登录主机!! - 检测结果:OK! - 检测系统是否已经安装 - 远程主机已安装 - ,建议先执行卸载,或者重装系统,若强制安装有一定机率失败。是否强制重新安装? - 安装取消,退出 - 已选择强制安装 - 检测结果:未安装 - 检测系统是否符合安装要求...... - 当前系统内核版本为 - ,V2ray要求内核为2.6.23及以上。请升级内核再安装! - 系统内核版本不符合要求,安装失败!! - 系统缺乏必要的安装组件如:apt||dnf||yum||zypper||Syetemd,主机系统推荐使用:CentOS 7/8,Debian 8/9/10,Ubuntu 16.04及以上版本 - 系统环境不满足要求,安装失败!! - 检测结果:OK! - 检测到系统启用SELinux,且工作在严格模式下,需改为宽松模式!修改中...... - 修改完毕! - 校对时间...... - 本地时间与远程主机时间相差超过限制(90秒),请先用 '系统工具-->时间校对' 校对时间后再设置 - 时间较对失败...... - 时间差符合要求,OK! - 正在检测域名是否解析到当前VPS的IP上...... - 正在检测是否为纯ipv6主机...... - 未检测到有效的IP地址...... - 正在查找最快的Nat64网关...... - 未能找到有效的Nat64网关...... - 当前主机最快的Nat64网关为: - 正在设置Nat64网关...... - 正在删除Nat64网关...... - 解析正确!OK! - 检测当前主机为纯ipv6主机,目前暂不支持! - 域名未能正确解析到当前VPS的IP上!安装失败! - 域名未能正确解析到当前VPS的IP上,请检查!若解析设置正确,请等待生效后再重试安装。如果域名使用了CDN,请先关闭! - 检测端口占用情况...... - 80/443端口之一,或全部被占用,将强制停止占用80/443端口的程序? - 端口被占用,安装失败...... - 正在释放80/443端口...... - 80/443端口释放完毕! - 端口被占用,将强制停止占用此端口的程序? - 正在释放端口...... - 端口释放完毕! - 检测结果:未被占用! - 系统环境检测完毕,符合安装要求,开始布署...... - 开启防火墙相应端口...... - 正在安装 - 文件下载失败! - 编译中,请耐心等待............. - 安装失败,脚本运行出错! - 安装成功! - 安装完毕,上传配置文件...... - 正在安装acme.sh...... - acme.sh安装成功! - acme.sh安装失败!原因未知,请向开发者提问! - 申请域名证书...... - 证书申请成功! - 证书申请失败!原因未知,请向开发者提问! - 安装证书到 - 证书成功安装到 - 证书安装到 - 失败,原因未知,可以向开发者提问! - 安装Caddy...... - 检测结果:未安装Caddy! - 安装Caddy失败! - Caddy安装成功! - 正在为Http2Web模式升级Caddy v2.2.0测试版! - 上传Caddy配置文件...... - Caddy配置文件上传失败! - Caddy配置文件上传成功,OK! - 正在启动Caddy...... - Caddy启动成功! - Caddy启动失败! - 正在启动Caddy(第二次尝试)! - Caddy启动失败(第二次)!退出安装! - Caddy启动失败,原因未知!请向开发者问询! - 正在启动 - 启动成功! - 启动失败! - 正在第二次尝试启动 - 启动失败(第二次)!退出安装! - 启动失败,原因如上!请排查原因! - BBR测试...... - 正在启用BBR...... - BBR已经启用了! - 系统不满足启用BBR的条件,启用失败! - BBR 启用成功! - 生成客户端配置...... - 客户端配置获取失败! - 安装成功,祝你玩的愉快!! - 安装失败! - 发生错误! - 密码错误或用户名错误! - 请检查主机地址及端口是否正确,如果通过代理,请检查代理是否正常工作 - 所选密钥文件错误或者格式不对! - 使用密钥登录,密钥文件错误或用户名错误! - 主机地址错误,如果使用了代理,也可能是连接代理的端口错误! - 退出!原因:远程主机未安装 - 检测到使用旧安装脚本的V2Ray...... - 检测到使用旧安装脚本的V2Ray,是否卸载旧版本并使用新安装脚本重新安装? - 正在卸载旧版本...... - 卸载旧版本,OK! - 安装新版本...... - 迁移原配置文件。 - 已更新到最新版本。 - 远程主机当前版本为:v - 最新版本为: - 是否升级为最新版本? - 正在升级到最新版本 - 升级成功!当前已是最新版本! - 升级失败,原因未知,请向开发者提问! - 升级取消,退出! - 远程主机当前已是最新版本: - 无需升级!退出! - 域名不能为空,请检查相关参数设置! - 请在x86_64系统中安装 - 备份Trojan配置文件...... - 恢复Trojan配置文件...... - "远程主机已安装Caddy,但不确定是否支持forward proxy,是否强制重新安装?" - 请先行卸载Caddy或重装VPS系统! - 正在安装依赖的软件...... - 安装完毕!OK! - 正在安装Caddy..... - 正在为NaiveProxy升级服务端 - 升级完毕,OK! - 正在优化网络参数...... - 优化网络参数,OK! - - 此文件为Xay官方程序所使用的客户端配置文件,配置为全局模式,socks5地址:127.0.0.1:1080,http代理地址:127.0.0.1:1081 - Xray官方网站:https://github.com/XTLS/Xray-core - Xray官方程序下载地址:https://github.com/XTLS/Xray-core/releases - 下载相应版本,Windows选择xray-windows-64.zip或者xray-windows-32.zip,解压后提取xray.exe。与config.json放在同一目录,运行xray.exe即可。 - - - 此文件为V2Ray官方程序所使用的客户端配置文件,配置为全局模式,socks5地址:127.0.0.1:1080,http代理地址:127.0.0.1:1081 - v2ray官方网站:https://www.v2ray.com/ - v2ray官方程序下载地址:https://github.com/v2ray/v2ray-core/releases - 下载相应版本,Windows选择v2ray-windows-64.zip或者v2ray-windows-32.zip,解压后提取v2ctl.exe和v2ray.exe。与config.json放在同一目录,运行v2ray.exe即可。 - - 此文件为v2rayN(windows)、Qv2ray(windows)、v2rayNG(Android)、Shadowrocket(ios)扫码导入节点 - v2rayN下载网址:https://github.com/2dust/v2rayN/releases - Qv2ray下载网址:https://github.com/Qv2ray/Qv2ray/releases - v2rayNG(Android)下载网址:https://github.com/2dust/v2rayNG/releases - v2rayNG(Android)在Google Play下载网址:https://play.google.com/store/apps/details?id=com.v2ray.ang - Shadowrocket(ios)下载,需要使用国外区的AppleID。请自行谷歌方法。 - 此文件为v2rayN、Qv2ray、v2rayNG(Android)、Shadowrocket(ios)复制粘贴导入节点的vmess网址 - 服务器通用连接配置参数: - - 此文件为Trojan-go官方程序所使用的客户端配置文件,配置为全局模式,http与socks5地址:127.0.0.1:1080 - Trojan-go官方网站:https://github.com/p4gefau1t/trojan-go - Trojan-go官方程序下载地址:https://github.com/p4gefau1t/trojan-go/releases - 下载相应版本,Windows选择Trojan-go-x.xx-win.zip,解压后提取trojan-go.exe。与config.json放在同一目录,运行trojan-go.exe即可。 - 此文件为Qv2ray (windows)、igniter(Android)扫码导入节点 - Qv2ray (windows)下载网址:https://github.com/Qv2ray/Qv2ray/releases - igniter(Android)下载网址:https://github.com/trojan-gfw/igniter/releases - Shadowrocket(ios)下载,需要使用国外区的AppleID。请自行谷歌方法。 - 此文件为Qv2ray (windows)、igniter(Android)复制粘贴导入节点的网址 - 服务器通用连接配置参数 - - 此文件为Trojan官方程序所使用的客户端配置文件,配置为全局模式,http与socks5地址:127.0.0.1:1080 - Trojan官方网站:https://trojan-gfw.github.io/trojan/ - Trojan官方程序下载地址:https://github.com/trojan-gfw/trojan/releases - 下载相应版本,Windows选择Trojan-x.xx-win.zip,解压后提取trojan.exe。与config.json放在同一目录,运行trojan.exe即可。 - 此文件为Qv2ray (windows)、igniter(Android)、Shadowrocket(ios)扫码导入节点 - Qv2ray (windows)下载网址:https://github.com/Qv2ray/Qv2ray/releases - igniter(Android)下载网址:https://github.com/trojan-gfw/igniter/releases - Shadowrocket(ios)下载,需要使用国外区的AppleID。请自行谷歌方法。 - 此文件为Qv2ray (windows)、igniter(Android)、Shadowrocket(ios)复制粘贴导入节点的网址 - 服务器通用连接配置参数 - - 此文件为NaiveProxy官方程序所使用的客户端配置文件,配置为全局模式,socks5地址:127.0.0.1:1080 - NaiveProxy官方网站:https://github.com/klzgrad/naiveproxy - NaiveProxy官方程序下载地址:https://github.com/klzgrad/naiveproxy/releases - 下载相应版本,Windows选择naiveproxy-x.xx-win.zip,解压后提取naive.exe。与config.json放在同一目录,运行naive.exe即可。 - 此文件为NaiveSharp(windows)复制粘贴导入节点的网址 - NaiveSharp(windows)下载网址:https://github.com/KevinZonda/NaiveSharp/releases - 服务器通用连接配置参数 - - 此文件为ShadowsocksR (windows)、SSRR(Android)、Shadowrocket(ios)扫码导入节点 - ShadowsocksR (windows)下载网址:https://github.com/shadowsocksrr/shadowsocksr-csharp/releases - SSRR(Android)下载网址:https://github.com/shadowsocksrr/shadowsocksr-android/releases - Shadowrocket(ios)下载,需要使用国外区的AppleID。请自行谷歌方法。 - 此文件为ShadowsocksR (windows)、SSRR(Android)、Shadowrocket(ios)复制粘贴导入节点的网址 - 服务器通用连接配置参数 - - 此文件为Shadowsocks (windows)扫码导入节点 - 此文件为Shadowsocks (windows)复制粘贴导入节点的网址 - 此文件为shadowsocks(Android)、Shadowrocket(ios)扫码导入节点 - Shadowsocks (windows)下载网址:https://github.com/shadowsocks/shadowsocks-windows/releases - shadowsocks(Android)下载网址:https://github.com/shadowsocks/shadowsocks-android/releases - Shadowrocket(ios)下载,需要使用国外区的AppleID。请自行谷歌方法。 - 此文件为shadowsocks(Android)、Shadowrocket(ios)复制粘贴导入节点的网址 - 服务器通用连接配置参数 - 插件使用说明 - ProxySU默认所有插件,在Shadowsocks (windows)运行文件所在文件夹的子文件夹plugins下。 - 电脑端手动安装插件说明 - 先下载插件,各个插件Windows客户端下载地址为: - Simple-obfs: https://github.com/shadowsocks/simple-obfs/releases 只下载 obfs-local.zip - V2ray-plugin: https://github.com/shadowsocks/v2ray-plugin/releases 64位系统选择:v2ray-plugin-windows-amd64-vx.x.x.tar.gz,32位系统选择:v2ray-plugin-windows-386-vx.x.x.tar.gz (x为数字,是版本号) - Kcptun-plugin: https://github.com/shadowsocks/kcptun/releases 64位系统选择:kcptun-windows-amd64-xxxxxx.tar.gz,32位系统选择:kcptun-plugin-windows-386-xxxxxx.tar.gz (x为数字,是版本号) - GoQuiet-plugin: https://github.com/cbeuw/GoQuiet/releases 64位系统选择:gq-client-windows-amd64-x.x.x.exe,32位系统选择:gq-client-windows-386-x.x.x.exe(x为数字,是版本号) - Cloak-plugin: https://github.com/cbeuw/Cloak/releases 64位系统选择:ck-client-windows-amd64-x.x.x.exe,32位系统选择:ck-client-windows-386-x.x.x.exe(x为数字,是版本号) - 在Shadowsocks (windows)运行文件所在文件夹中,新建文件夹plugins,将obfs-local.zip解压出的文件(两个)全部复制到plugins中,v2ray -plugin下载得到的文件,解压出的文件,复制到plugins中,并重命名为:v2ray-plugin.exe。Kcptun -plugin下载得到的文件,解压出两个文件,将其中的client_windows开头的文件,复制到plugins中,并重命名为:kcptun-client.exe。GoQuiet-plugin下载得到的文件,直接复制到plugin中,并重命名为:goquiet-client.exe。Cloak-plugin下载得到的文件,直接复制到plugin中,并重命名为:cloak-client.exe - 安装完毕 - 手机安卓客户端插件安装说明 - 先下载插件,各个插件安卓客户端下载地址为: - Simple-obfs: https://github.com/shadowsocks/simple-obfs-android/releases 只下载 obfs-local-nightly-x.x.x.apk(x为数字,是版本号) - V2ray-plugin: https://github.com/shadowsocks/v2ray-plugin-android/releases 一般选择v2ray--universal-x.x.x.apk(x为数字,是版本号) - Kcptun-plugin: https://github.com/shadowsocks/kcptun-android/releases 一般选择kcptun--universal-x.x.x.apk(x为数字,是版本号) - 将上述apk文件传到手机,安装即可! - - - - \ No newline at end of file diff --git a/ProxySU/Translations/ProxySU.zh-TW.xaml b/ProxySU/Translations/ProxySU.zh-TW.xaml deleted file mode 100644 index 3b98e2e..0000000 --- a/ProxySU/Translations/ProxySU.zh-TW.xaml +++ /dev/null @@ -1,488 +0,0 @@ - - - 最新版本已發布了,快去更新一下吧! - 正在下載最新版,請等待完成提示.... - 最新版下載失敗,請稍後重試! - 下載最新版成功,文件已存入當前ProxySU.exe同一目錄 - 下載更新 - Languages: - 應用佈署 - 資源工具 - 免翻網址資源 - 常見問題 - 主機: - IP或域名(不可為空) - 端口: - 用戶: - 密碼: - 密鑰:: - 密鑰文件存放路徑(不可為空) - 瀏覽... - 密碼登錄 - 密鑰登錄 - 無代理 - 不需登錄 - 需要登錄 - 代理地址: - Email - 申請SSL證書需要一個可用的Email地址 - 安裝日誌另存為... - 等待安裝佈署 - 系統工具 - - Xray模板庫 - Xray一鍵安裝 - 升級Xay - - V2Ray模板庫 - V2ray一鍵安裝 - 升級V2Ray - 取消 - Trojan-Go參數設置 - Trojan-Go一鍵安裝 - 升級Trojan-Go - 取消 - 當前所選方案: - 未選擇方案 - - 參數設置 - 模式:Trojan+TLS+Caddy - 服務器地址(域名): - 端口:443 - 域名不可為空 - 密碼: - 更新 - Trojan一鍵安裝 - 升級Trojan - 取消 - - 模式:NaiveProxy+TLS+Caddy - 隨機 - NaiveProxy一鍵安裝 - 取消 - - 模式:SSR+TLS+Caddy - SSR一鍵安裝 - - - 模式:MTProto+TLS - MTProto一鍵安裝 - 偽裝域名: - 推薦用常見https端口443、2053、2083、2087、2096、8443 - 密鑰將由服務端隨機生成,這裡無需設置。 - - - SS 一鍵安裝 - SS 插件庫 - 經典模式 - 提示:這種模式,長時間,大流量使用,容易被阻斷和乾擾,不推薦使用! - SS 經典 - SS經典使用模式,無需域名,數據高強度加密,數據被識別為未知數據。目前流量容易被識別,極易被干擾與阻斷,慎重使用!放在這裡僅僅只是一種情懷與致敬! - Simple-obfs 插件 - 提示:這是SS早期使用的流量混淆方案,插件已經長時間不再更新,不推薦使用! - SS+obfs+http+Web - 無需域名,數據高強度加密,流量混淆為http(並非真正的http),使用Web網站偽裝,可在一定程度上增強抗識別!不支持CDN。 - SS+obfs+TLS(https)+Web - 需要域名,使用域名將很大增強抗識別,數據高強度加密,流量混淆為https(並非真正的https),​​使用Web網站偽裝,進一步增強抗識別!不支持CDN。 - V2Ray 插件 - 提醒:ShadowRocket(ios)不支持SS+Quic模式 - SS+WebSocket+TLS+Caddy(Web後置) - SS+WebSocket+TLS+Caddy(Web前置) - 提示:上面方案中的Web前置與Web後置,使用效果上沒有差別,Web後置方案,TLS證書由acme.sh申請,證書到期後, acme.sh會自動續期,但是需要手動重啟SS加載新證書。而Web前置方案中的證書由Caddy自動申請並加載,不需要重啟SS。 - SS+QUIC - 通過V2Ray-Plugin使用QUIC協議傳輸,強制使用TLS加密。數據加密傳輸,被識別為udp流量,最初由谷歌創始,優點:減少延遲、多路復用、連接遷移,需要域名, - - kcptun 插件 - 提醒:Shadowrocket(ios)不支持GoQuiet-plugin插件。 shadowsocks(Android)不支持GoQuiet-plugin與Cloak-plugin插件 - KCP是一個快速可靠協議,能以比TCP浪費10%-20%的帶寬的代價,換取平均延遲降低30%-40%,且最大延遲降低三倍的傳輸效果。使用UDP協議傳輸,數據高強度加密,傳輸同樣的內容,kcp 一般比TCP 消耗更多的流量,在丟包率高的線路下將極大提高網速,在個別運營商處可能會被QOS限制。 - 基本原理為模擬TLS的流量同時將服務器偽裝成一個正常的網站服務器,這個混淆思路並非首創:simple-obfs和ShadowsocksR的tls1.2_ticket_auth模式證明這條道是行得通的。此插件對現有的方法進行了改善,其目標為讓大規模封鎖HTTPS服務器(甚至IP段)成為封鎖SS的唯一有效手段 - 通過加密方式將代理流量混淆為合法的HTTPS流量,並將代理服務器偽裝成普通的Web服務器以規避互聯網審查。可以看成是上面GoQuiet升級版,優化網絡連接速度,並且不是混淆https而是真正的https流量。 - 插件程序: - 插件選項: - 使用編譯方式,時間稍長,請耐心等待...... - - - 校對時間 - 釋放80/443端口 - 啟用BBR - 卸載代理 - 啟用root密碼登錄 - root禁止密碼登錄 - 啟用root證書密鑰登錄 - 僅支持卸載由ProxySU安裝的代理軟件及相關配置,請確保重要配置已備份。不支持卸載使用其他方法或腳本安裝的代理。確定要卸載遠程主機上的代理軟件嗎? - 本功能需要當前登錄的賬戶具有sudo權限,是否為遠程主機啟用root賬戶並設置密碼? - 本功能需要當前登錄的賬戶具有root或者sudo權限,是否為遠程主機啟用root證書密鑰登錄? - 本功能需要遠程主機已經開啟了其他登錄方式,如密鑰方式等,否則將可能造成遠程主機無法連接,是否禁止遠程主機的root賬戶密碼登錄方式? - 正在關閉root賬戶密碼登錄方式..... - 遠程主機root賬戶密碼登錄方式已關閉! - 遠程主機root賬戶證書密鑰登錄已啟用,密鑰文件rootuser.key保存在隨後打開的文件夾中! - 當前賬戶已經具有root權限,無需再設置! - 當前賬戶無法獲取sudo權限,設置失敗! - 生成20位隨機密碼! - 保存密碼信息! - 正在生成密鑰...... - 正在下載密鑰...... - 遠程主機啟用密鑰登錄....... - 遠程主機Root賬戶密碼登錄已啟用,密碼保存在隨後打開的文件夾中! - 開始卸載...... - 檢測到已安裝 - 卸載失敗!請向開發者問詢! - 卸載成功! - - 主頁 - 前進 - 後退 - 由於眾所周知的原因,在某些時候,加載緩慢,請耐心等待一下 - - Trojan-go 模板庫 - http/2傳輸,Caddy2偽裝網站,抗識別,暫不支持CloudFlare的CDN - 使用WebSocket傳輸,Caddy2偽裝網站,抗識別,支持CloudFlare的CDN - 參數設置 - 域名: - 端口: 443 - 密碼: - 使用已有密碼,直接粘貼到框中 - WebSocket路徑: - Mux多路復用 - 此處設置只對官方客戶端配置文件config.json有效,其他客戶端需手動設置,服務端自動適配。 - 此字段不出現在QR碼及分享URL中,客戶端需自行設置,服務端默認啟用自動適配。 - 確定 - 取消 - - V2Ray 模板庫 - 推薦方案 - 嚐鮮方案 - VLESS協議 - VLESS 是一個無狀態的輕量傳輸協議,與 VMess 不同,VLESS 不依賴於系統時間,認證方式同樣為 UUID,但不需要 alterId。目前 VLESS 沒有自帶加密,請用於可靠信道,如 TLS。優點:可以有效的降低主機資源消耗。目前 VLESS 不支持分享。 VLESS 處於公測階段,測試期間請確保客戶端與服務端的 v2ray-core 均為最新版本。 - XTLS 在低性能或沒有AES 硬解的設備上效果出眾,如在硬路由上換用XTLS,同樣跑滿CPU 時實現網速翻倍,或是相同網速時CPU 佔用率減半,而對於移動設備,計算量減少意味著省電。服務端客戶端版本要求4.29+ (需域名)不支持CDN。 - 輕量協議VLESS,佔用更少主機資源,數據TLS加密傳輸,用Caddy2在節點上做偽裝網站。適合配置低的VPS,或多人共用節點,服務端客戶端版本要求4.27+ (需域名)不支持CDN。 - 使用VLESS協議,與VMESS的此類型方案,更輕量。穩定性強,Caddy2做前置,隱藏代理特徵,被識別為訪問網站的https流量,抗封鎖識別最強,需要域名,支持CDN - 使用VLESS協議,與VMESS的此類型方案,更輕量。基於 HTTP/2 傳輸。完整按 HTTP/2 標準實現,Caddy2做前置,隱藏代理特徵,H2C協議轉發到V2Ray,需要域名,暫不支持CloudFlare的CDN - TCP傳輸協議 - WebSocket傳輸協議 - Http/2傳輸協議 - mKCP傳輸協議 - QUIC傳輸協議 - 參數設置 - 服務器端口: - 隨機選擇 - 若使用TLS加密,請保持默認的443端口 - 使用已有UUID,直接粘貼到框中 - QUIC密鑰: - mKCP Seed: - 啟用mKCP Seed密鑰,可增強抗識別,留空則禁用,要求版本4.24.2+ - 路徑: - VLESS ws路徑: - VMESS tcp路徑: - VMESS ws路徑: - QUIC加密方式: - 域名: - Trojan密碼與V2ray的UUID相同。 - 偽裝網站: - 設置此項可增加代理的隱蔽(可為空) - 僅僅輸入域名,不包括"http"及"/"等 - 僅僅禁止root賬戶使用密碼登錄,請確保root賬戶其他登錄方式已生效 - 將啟用root賬戶,並設置為密碼登錄 - 將啟用或設置root賬戶為密鑰證書登錄 - 偽裝網址輸入格式錯誤!請重新輸入! - 穩定性強,Caddy2做前置,隱藏代理特徵,被識別為訪問網站的https流量,抗封鎖識別最強,需要域名,支持CDN - 基於 HTTP/2 傳輸。完整按 HTTP/2 標準實現,Caddy2做前置,隱藏代理特徵,H2C協議轉發到V2Ray,需要域名,暫不支持CloudFlare的CDN - 當前Xray是V2Ray的超集,未來與V2Ray會有不同的發展方向。 - VLESS over TCP with XTLS + 回落and 分流to WHATEVER(終極配置),由rprx大佬(xtls作者)配置並推薦,在服務端同時配置以下六種方案,共用同一域名與443端口,其中 WS 都可以通過 CDN。 - VLESS over TCP with XTLS + 回落and 分流to WHATEVER(終極配置),由rprx大佬(xtls作者)配置並推薦,在服務端同時配置以下五種方案,共用同一域名與443端口,其中 WS 都可以通過 CDN。(想增加XTLS方案請使用Xray配置) - 數據加密傳輸,會被識別為未知的tcp流量 - TCP+Http偽裝 - 數據加密傳輸,並做http偽裝,會被識別為http流量,但並不是真正的http訪問 - 數據加密傳輸,傳輸協議使用TLS,會被識別為TLS流量,不等同於https流量特徵 (需域名) - TCP+TLS(自簽證書) - 數據加密傳輸,傳輸協議使用TLS,會被識別為TLS流量,不等同於https流量特徵 (無需域名) - Shadowrocket (ios)需要手動打開“允許不安全”選項 - 數據加密傳輸,傳輸協議使用WebSocket,未啟用TLS,將被識別為WebSocket流量。 - 數據加密傳輸,傳輸協議使用WebSocket,啟用TLS,將被識別為TLS流量。 (需要域名)支持CDN。 - WebSocket+TLS(自簽證書) - 數據加密傳輸,傳輸協議使用WebSocket,啟用TLS,將被識別為TLS流量。 (無需域名) - 基於 HTTP/2 的傳輸方式。它完整​​按照 HTTP/2 標準實現,需要域名 - HTTP2(自簽證書) - 基於 HTTP/2 的傳輸方式。它完整​​按照 HTTP/2 標準實現,使用自簽名證書,不需要域名 - mKCP(無偽裝) - 數據加密傳輸,以增加帶寬佔用,減少延遲,udp協議,無偽裝,會被識別為udp流量 - 同mKCP(無偽裝),增加偽裝成 SRTP 數據包,會被識別為視頻通話數據(如 FaceTime) - 同mKCP(無偽裝),增加偽裝成 uTP 數據包,會被識別為 BT 下載數據 - 同mKCP(無偽裝),增加偽裝成微信視頻通話的數據包 - 同mKCP(無偽裝),增加偽裝成 DTLS 1.2 數據包 - 同mKCP(無偽裝),增加偽裝成 WireGuard 數據包。 (並不是真正的 WireGuard 協議) - 提醒:Shadowrocket目前暫不支持QUIC的傳輸模式。 - QUIC(無偽裝) - 數據加密傳輸,無偽裝會被識別為udp流量,最初由谷歌創始,優點:減少延遲、多路復用、連接遷移 - 同QUIC(無偽裝),增加偽裝成 SRTP 數據包,會被識別為視頻通話數據(如 FaceTime) - 同QUIC(無偽裝),增加偽裝成 uTP 數據包,會被識別為 BT 下載數據 - 同QUIC(無偽裝),增加偽裝成微信視頻通話的數據包 - 同QUIC(無偽裝),增加偽裝成 DTLS 1.2 數據包 - 同QUIC(無偽裝),增加偽裝成 WireGuard 數據包。 (並不是真正的 WireGuard 協議) - - 同步網絡時間 - 將遠程主機時間校正為網絡時間,注意:本機電腦的時間必須也是與網絡時間同步的,否則本機電腦V2ray有可能連接出錯 推薦:優先使用此方法校對時間 - 同步本機時間 - 將遠程主機時間同步為本地時間,注意:本機電腦的時間必須是準確的,與網絡時間同步的,否則其他客戶端中,有可能連接出錯 使用網絡校時無法校對時間時,使用此種方法 - 更新本機時間 - 將本機電腦時間與網絡時間同步。 注意:使用此項功能,必須以管理員身份運行本程序 - 檢測時間誤差 - 校對時間 - - 客戶端配置參數 - 服務器地址(address): - 端口(port): - 用戶ID(uuid)/密碼: - 複製 - 已復製到剪貼板中! - 空內容! - 額外ID: - 不超過64,客戶端沒此項可不填 - 加密方式: - 傳輸協議: - 偽裝類型(混淆): - TLS設置: - 提示:雙擊以上內容窗,即可複製到剪貼板中。 - 路徑(Path): - mKCP Seed/QUIC密鑰: - 默認auto - 二維碼/URL - 以上參數可以手動或掃描輸入客戶端,用於官方客戶端的配置和相關文件已經存放入目錄下,點擊 確定 按扭可打開 - 二維碼和URL鏈接可用於 v2rayN(windows) Qv2ray(windows) Qv2ray(windows) Shadowrocket(ios) v2rayNG(Android) 導入v2ray節點 注意:Vless協議需要手動輸入配置參數,二維碼和URL無效 - "可用於ShadowRocket (ios)、igniter(Android)、Qv2ray (windows) 掃碼和導入url。注意:有的客戶端可能不支持WebSocket模式。" - "可用於ShadowRocket (ios)、igniter(Android)、Qv2ray (windows) 掃碼和導入url。注意:有的客戶端可能不支持WebSocket模式。" - 用於NaiveSharp(windows)的URL導入鏈接 - 用於ShadowsocksR(windows)、SSRR(android)、Shadowrocket(ios)的掃碼和導入URL導入鏈接 - 用於手機客戶端shadowsocks(android)、Shadowrocket(ios)的掃碼和URL導入鏈接 - 用於電腦客戶端Shadowsocks (windows)的掃碼和URL導入鏈接 - 用於Shadowsocks (windows)、shadowsocks(android)、Shadowrocket(ios)的掃碼和URL導入鏈接 - 提醒: 電腦客戶端Shadowsocks (windows)與手機客戶端shadowsocks(android)、Shadowrocket(ios)的導入格式不兼容,請選擇相應格式。 - 手機端 - 電腦端 - TG格式QR - TG格式URL(雙擊複製到剪切板中) - T.ME格式QR - T.ME格式URL(雙擊複製到剪切板中) - - 主機地址、主機端口、用戶名為必填項,不能為空!! - 連接端口含有非數字字符! - 登錄密碼為必填項,不能為空!! - 密鑰文件為必填項,不能為空!! - 如果選擇了代理,則代理地址與端口不能為空! - 如果代理需要登錄,則代理登錄的用戶名與密碼不能為空! - 遠程主機連接信息有誤,請檢查! - 請先選擇配置模板! - 發生錯誤,安裝中斷...... - 正在登錄遠程主機...... - 主機登錄成功! - 檢測是否運行在root權限下... - 請使用具有root權限的賬戶登錄主機! ! - 檢測結果:OK! - 檢測系統是否已經安裝 - 遠程主機已安裝 - ,建議先執行卸載,或者重裝系統,若強制安裝有一定機率失敗。是否強制重新安裝? - 安裝取消,退出 - 已選擇強制安裝 - 檢測結果:未安裝 - 檢測系統是否符合安裝要求...... - 當前系統內核版本為 - ,V2ray要求內核為2.6.23及以上。請升級內核再安裝! - 系統內核版本不符合要求,安裝失敗! ! - 系統缺乏必要的安裝組件如:apt||dnf||yum||zypper||Syetemd,主機系統推薦使用:CentOS 7/8,Debian 8/9/10 ,Ubuntu 16.04及以上版本 - 系統環境不滿足要求,安裝失敗! ! - 檢測結果:OK! - 檢測到系統啟用SELinux,且工作在嚴格模式下,需改為寬鬆模式!修改中...... - 修改完畢! - 校對時間...... - 本地時間與遠程主機時間相差超過限制(90秒),請先用 '系統工具-->時間校對' 校對時間後再設置 - 時間較對失敗...... - 時間差符合要求,OK! - 正在檢測域名是否解析到當前VPS的IP上...... - 正在檢測是否為純ipv6主機...... - 未檢測到有效的IP地址...... - 正在查找最快的Nat64網關...... - 未能找到有效的Nat64網關...... - 當前主機最快的Nat64網關為: - 正在設置Nat64網關...... - 正在刪除Nat64網關...... - 解析正確! OK! - 檢測當前主機為純ipv6主機,目前暫不支持! - 域名未能正確解析到當前VPS的IP上!安裝失敗! - 域名未能正確解析到當前VPS的IP上,請檢查!若解析設置正確,請等待生效後再重試安裝。如果域名使用了CDN,請先關閉! - 檢測端口占用情況...... - 80/443端口之一,或全部被佔用,將強制停止佔用80/443端口的程序? - 端口被佔用,安裝失敗...... - 正在釋放80/443端口...... - 80/443端口釋放完畢! - 端口被佔用,將強制停止佔用此端口的程序? - 正在釋放端口...... - 端口釋放完畢! - 檢測結果:未被佔用! - 系統環境檢測完畢,符合安裝要求,開始佈署...... - 開啟防火牆相應端口...... - 正在安裝 - 文件下載失敗! - 編譯中,請耐心等待............. - 安裝失敗,腳本運行出錯! - 安裝成功! - 安裝完畢,上傳配置文件...... - 正在安裝acme.sh...... - acme.sh安裝成功! - acme.sh安裝失敗!原因未知,請向開發者提問! - 申請域名證書...... - 證書申請成功! - 證書申請失敗!原因未知,請向開發者提問! - 安裝證書到 - 證書成功安裝到 - 證書安裝到 - 失敗,原因未知,可以向開發者提問! - 安裝Caddy...... - 檢測結果:未安裝Caddy! - 安裝Caddy失敗! - Caddy安裝成功! - 正在為Http2Web模式升級Caddy v2.2.0測試版! - 上傳Caddy配置文件...... - Caddy配置文件上傳失敗! - Caddy配置文件上傳成功,OK! - 正在啟動Caddy...... - Caddy啟動成功! - Caddy啟動失敗! - 正在啟動Caddy(第二次嘗試)! - Caddy啟動失敗(第二次)!退出安裝! - Caddy啟動失敗,原因未知!請向開發者問詢! - 正在啟動 - 啟動成功! - 啟動失敗! - 正在第二次嘗試啟動 - 啟動失敗(第二次)!退出安裝! - 啟動失敗,原因如上!請排查原因! - BBR測試...... - 正在啟用BBR...... - BBR已經啟用了! - 系統不滿足啟用BBR的條件,啟用失敗! - BBR 啟用成功! - 生成客戶端配置...... - 客戶端配置獲取失敗! - 安裝成功,祝你玩的愉快! ! - 安裝失敗! - 發生錯誤! - 密碼錯誤或用戶名錯誤! - 請檢查主機地址及端口是否正確,如果通過代理,請檢查代理是否正常工作 - 所選密鑰文件錯誤或者格式不對! - 使用密鑰登錄,密鑰文件錯誤或用戶名錯誤! - 主機地址錯誤,如果使用了代理,也可能是連接代理的端口錯誤! - 退出!原因:遠程主機未安裝 - 檢測到使用舊安裝腳本的V2Ray...... - 檢測到使用舊安裝腳本的V2Ray,是否卸載舊版本並使用新安裝腳本重新安裝? - 正在卸載舊版本...... - 卸載舊版本,OK! - 安裝新版本...... - 遷移原配置文件。 - 已更新到最新版本。 - 遠程主機當前版本為:v - 最新版本為: - 是否升級為最新版本? - 正在升級到最新版本 - 升級成功!當前已是最新版本! - 升級失敗,原因未知,請向開發者提問! - 升級取消,退出! - 遠程主機當前已是最新版本: - 無需升級!退出! - 域名不能為空,請檢查相關參數設置! - 請在x86_64系統中安裝 - 備份Trojan配置文件...... - 恢復Trojan配置文件...... - "遠程主機已安裝Caddy,但不確定是否支持forward proxy,是否強制重新安裝?" - 請先行卸載Caddy或重裝VPS系統! - 正在安裝依賴的軟件...... - 安裝完畢! OK! - 正在安裝Caddy..... - 正在為NaiveProxy升級服務端 - 升級完畢,OK! - 正在優化網絡參數...... - 優化網絡參數,OK! - - 此文件為Xay官方程序所使用的客戶端配置文件,配置為全局模式,socks5地址:127.0.0.1:1080,http代理地址:127.0.0.1:1081 - Xray官方網站:https://github.com/XTLS/Xray-core - Xray官方程序下載地址:https://github.com/XTLS/Xray-core/releases - 下載相應版本,Windows選擇xray-windows-64.zip或者xray-windows-32.zip,解壓後提取xray.exe。與config.json放在同一目錄,運行xray.exe即可。 - - 此文件為V2Ray官方程序所使用的客戶端配置文件,配置為全局模式,socks5地址:127.0.0.1:1080,http代理地址:127.0.0.1:1081 - v2ray官方網站:https://www.v2ray.com/ - v2ray官方程序下載地址:https://github.com/v2ray/v2ray-core/releases - 下載相應版本,Windows選擇v2ray-windows-64.zip或者v2ray-windows-32.zip,解壓後提取v2ctl.exe和v2ray.exe。與config.json放在同一目錄,運行v2ray.exe即可。 - 此文件為v2rayN、Qv2ray、v2rayNG(Android)、Shadowrocket(ios)掃碼導入節點 - v2rayN下載網址:https://github.com/2dust/v2rayN/releases - Qv2ray下載網址:https://github.com/Qv2ray/Qv2ray/releases - v2rayNG(Android)下載網址:https://github.com/2dust/v2rayNG/releases - v2rayNG(Android)在Google Play下載網址:https://play.google.com/store/apps/details?id=com.v2ray.ang - Shadowrocket(ios)下載,需要使用國外區的AppleID。請自行谷歌方法。 - 此文件為v2rayN、Qv2ray、v2rayNG(Android)、Shadowrocket(ios)複製粘貼導入節點的vmess網址 - 服務器通用連接配置參數 - - 此文件為Trojan-go官方程序所使用的客戶端配置文件,配置為全局模式,http與socks5地址:127.0.0.1:1080 - Trojan-go官方網站:https://github.com/p4gefau1t/trojan-go - Trojan-go官方程序下載地址:https://github.com/p4gefau1t/trojan-go/releases - 下載相應版本,Windows選擇Trojan-go-x.xx-win.zip,解壓後提取trojan-go.exe。與config.json放在同一目錄,運行trojan-go.exe即可。 - 此文件為Qv2ray (windows)、igniter(Android)掃碼導入節點 - Qv2ray (windows)下載網址:https://github.com/Qv2ray/Qv2ray/releases - igniter(Android)下載網址:https://github.com/trojan-gfw/igniter/releases - Shadowrocket(ios)下載,需要使用國外區的AppleID。請自行谷歌方法。 - 此文件為Qv2ray (windows)、igniter(Android)複製粘貼導入節點的網址 - 服務器通用連接配置參數 - - 此文件為Trojan官方程序所使用的客戶端配置文件,配置為全局模式,http與socks5地址:127.0.0.1:1080 - Trojan官方網站:https://trojan-gfw.github.io/trojan/ - Trojan官方程序下載地址:https://github.com/trojan-gfw/trojan/releases - 下載相應版本,Windows選擇Trojan-x.xx-win.zip,解壓後提取trojan.exe。與config.json放在同一目錄,運行trojan.exe即可。 - 此文件為Qv2ray (windows)、igniter(Android)、Shadowrocket(ios)掃碼導入節點 - Qv2ray (windows)下載網址:https://github.com/Qv2ray/Qv2ray/releases - igniter(Android)下載網址:https://github.com/trojan-gfw/igniter/releases - Shadowrocket(ios)下載,需要使用國外區的AppleID。請自行谷歌方法。 - 此文件為Qv2ray (windows)、igniter(Android)、Shadowrocket(ios)複製粘貼導入節點的網址 - 服務器通用連接配置參數 - - 此文件為NaiveProxy官方程序所使用的客戶端配置文件,配置為全局模式,socks5地址:127.0.0.1:1080 - NaiveProxy官方網站:https://github.com/klzgrad/naiveproxy - NaiveProxy官方程序下載地址:https://github.com/klzgrad/naiveproxy/releases - 下載相應版本,Windows選擇naiveproxy-x.xx-win.zip,解壓後提取naive.exe。與config.json放在同一目錄,運行naive.exe即可。 - 此文件為NaiveSharp(windows)複製粘貼導入節點的網址 - NaiveSharp(windows)下載網址:https://github.com/KevinZonda/NaiveSharp/releases - 服務器通用連接配置參數 - - 此文件為ShadowsocksR (windows)、SSRR(Android)、Shadowrocket(ios)掃碼導入節點 - ShadowsocksR (windows)下載網址:https://github.com/shadowsocksrr/shadowsocksr-csharp/releases - SSRR(Android)下載網址:https://github.com/shadowsocksrr/shadowsocksr-android/releases - Shadowrocket(ios)下載,需要使用國外區的AppleID。請自行谷歌方法。 - 此文件為ShadowsocksR (windows)、SSRR(Android)、Shadowrocket(ios)複製粘貼導入節點的網址 - 服務器通用連接配置參數 - - 此文件為Shadowsocks (windows)掃碼導入節點 - 此文件為Shadowsocks (windows)複製粘貼導入節點的網址 - 此文件為shadowsocks(Android)、Shadowrocket(ios)掃碼導入節點 - Shadowsocks (windows)下載網址:https://github.com/shadowsocks/shadowsocks-windows/releases - shadowsocks(Android)下載網址:https://github.com/shadowsocks/shadowsocks-android/releases - Shadowrocket(ios)下載,需要使用國外區的AppleID。請自行谷歌方法。 - 此文件為shadowsocks(Android)、Shadowrocket(ios)複製粘貼導入節點的網址 - 服務器通用連接配置參數 - 插件使用說明 - ProxySU默認所有插件,在Shadowsocks (windows)運行文件所在文件夾的子文件夾plugins下。 - 電腦端手動安裝插件說明 - 先下載插件,各個插件Windows客戶端下載地址為: - Simple-obfs: https://github.com/shadowsocks/simple-obfs/releases 只下載 obfs-local.zip - V2ray-plugin: https://github.com/shadowsocks/v2ray-plugin/releases 64位系統選擇:v2ray-plugin-windows-amd64-vx.xxtar.gz ,32位系統選擇:v2ray-plugin-windows-386-vx.xxtar.gz (x為數字,是版本號) - Kcptun-plugin: https://github.com/shadowsocks/kcptun/releases 64位系統選擇:kcptun-windows-amd64-xxxxxx.tar.gz,32位系統選擇:kcptun-plugin-windows-386-xxxxxx.tar.gz (x為數字,是版本號) - GoQuiet-plugin: https://github.com/cbeuw/GoQuiet/releases 64位系統選擇:gq-client-windows-amd64-xxxexe,32位系統選擇: gq-client-windows-386-xxxexe(x為數字,是版本號) - Cloak-plugin: https://github.com/cbeuw/Cloak/releases 64位系統選擇:ck-client-windows-amd64-xxxexe,32位系統選擇: ck-client-windows-386-xxxexe(x為數字,是版本號) - 在Shadowsocks (windows)運行文件所在文件夾中,新建文件夾plugins,將obfs-local.zip解壓出的文件(兩個)全部複製到plugins中,v2ray -plugin下載得到的文件,解壓出的文件,複製到plugins中,並重命名為:v2ray-plugin.exe。 Kcptun -plugin下載得到的文件,解壓出兩個文件,將其中的client_windows開頭的文件,複製到plugins中,並重命名為:kcptun-client.exe。 GoQuiet-plugin下載得到的文件,直接複製到plugin中,並重命名為:goquiet-client.exe。 Cloak-plugin下載得到的文件,直接複製到plugin中,並重命名為:cloak-client.exe - 安裝完畢 - 手機安卓客戶端插件安裝說明 - 先下載插件,各個插件安卓客戶端下載地址為: - Simple-obfs: https://github.com/shadowsocks/simple-obfs-android/releases 只下載obfs-local-nightly-xxxapk(x為數字,是版本號) - V2ray-plugin: https://github.com/shadowsocks/v2ray-plugin-android/releases 一般選擇v2ray--universal-xxxapk(x為數字,是版本號) - Kcptun-plugin: https://github.com/shadowsocks/kcptun-android/releases 一般選擇kcptun--universal-xxxapk(x為數字,是版本號) - 將上述apk文件傳到手機,安裝即可! - \ No newline at end of file diff --git a/ProxySU/TrojanGoTemplateWindow.xaml b/ProxySU/TrojanGoTemplateWindow.xaml deleted file mode 100644 index 1c59fa4..0000000 --- a/ProxySU/TrojanGoTemplateWindow.xaml +++ /dev/null @@ -1,131 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ProxySU/TrojanGoTemplateWindow.xaml.cs b/ProxySU/TrojanGoTemplateWindow.xaml.cs deleted file mode 100644 index 59816c7..0000000 --- a/ProxySU/TrojanGoTemplateWindow.xaml.cs +++ /dev/null @@ -1,194 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; - -namespace ProxySU -{ - /// - /// TrojanGoTemplateWindow.xaml 的交互逻辑 - /// - public partial class TrojanGoTemplateWindow : Window - { - public TrojanGoTemplateWindow() - { - InitializeComponent(); - RadioButtonTrojanGoTLS2Web.IsChecked = true; - CheckBoxMuxSelect.IsChecked = false; - GridTrojanGoMuxSelected.Visibility = Visibility.Collapsed; - TextBlockExplainCheckBoxMuxSelect.Visibility = Visibility.Collapsed; - } - private void ButtondDecide_Click(object sender, RoutedEventArgs e) - { - bool preDomainMask = ClassModel.PreDomainMask(TextBoxMaskSites.Text); - bool domainNotEmpty = ClassModel.TestDomainIsEmpty(TextBoxDomain.Text); - - //if (string.IsNullOrEmpty(PreTrim(TextBoxDomain.Text)) == true) - //{ - // //****** "域名不能为空,请检查相关参数设置!" ****** - // MessageBox.Show(Application.Current.FindResource("MessageBoxShow_DomainNotEmpty").ToString()); - // return; - //} - //传递域名 - MainWindow.ReceiveConfigurationParameters[4] = PreTrim(TextBoxDomain.Text); - //传递伪装网站 - MainWindow.ReceiveConfigurationParameters[7] = ClassModel.DisguiseURLprocessing(PreTrim(TextBoxMaskSites.Text)); - - //传递服务端口 - MainWindow.ReceiveConfigurationParameters[1] = "443"; - //传递密码(uuid) - MainWindow.ReceiveConfigurationParameters[2] = PreTrim(TextBoxNewUUID.Text); - if (RadioButtonTrojanGoTLS2Web.IsChecked == true) - { - //传递模板类型 - 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[6] = PreTrim(TextBoxPath.Text); - } - //传递Mux的concurrency与idle_timeout - if (CheckBoxMuxSelect.IsChecked == true) - { - MainWindow.ReceiveConfigurationParameters[9] = "true"; - MainWindow.ReceiveConfigurationParameters[3] = PreTrim(TextBoxConcurrency.Text); - MainWindow.ReceiveConfigurationParameters[5] = PreTrim(TextBoxIdle_timeout.Text); - } - if (domainNotEmpty == true && preDomainMask == true) - { - this.Close(); - } - - } - //更新密码 - private void ButtonNewUUID_Click(object sender, RoutedEventArgs e) - { - //Guid uuid = Guid.NewGuid(); - TextBoxNewUUID.Text = GenerateRandomUUID(); - } - //更新路径 - private void ButtonPath_Click(object sender, RoutedEventArgs e) - { - string path = GenerateRandomPath(); - TextBoxPath.Text = $"/{path}"; - //MessageBox.Show(path); - } - //private void ButtonServerListenPort_Click(object sender, RoutedEventArgs e) - //{ - // TextBoxServerListenPort.Text = GetRandomPort(); - //} - private void ButtondCancel_Click(object sender, RoutedEventArgs e) => Close(); - - private void RadioButtonTrojanTLS2Web_Checked(object sender, RoutedEventArgs e) - { - Guid uuid = Guid.NewGuid(); - TextBoxNewUUID.Text = uuid.ToString(); - TextBlockPath.Visibility = Visibility.Collapsed; - TextBoxPath.Visibility = Visibility.Collapsed; - ButtonPath.Visibility = Visibility.Collapsed; - //Random random = new Random(); - //int randomServerPort = random.Next(10000, 50000); - //TextBoxServerListenPort.Text = "443"; - } - private void RadioButtonTrojanGoWebSocketTLS2Web_Checked(object sender, RoutedEventArgs e) - { - Guid uuid = Guid.NewGuid(); - TextBoxNewUUID.Text = uuid.ToString(); - TextBlockPath.Visibility = Visibility.Visible; - TextBoxPath.Visibility = Visibility.Visible; - ButtonPath.Visibility = Visibility.Visible; - TextBoxPath.Text = "/trojan"; - } - - //生成随机UUID - private string GenerateRandomUUID() - { - Guid uuid = Guid.NewGuid(); - return uuid.ToString(); - } - - //生成随机端口 - private int GetRandomPort() - { - Random random = new Random(); - return random.Next(10001, 60000); - } - //生成随机Path - private string GenerateRandomPath() - { - Random random = new Random(); - int randomSerialNum = random.Next(0, 4); - //Guid uuid = Guid.NewGuid(); - string uuid = GenerateRandomUUID(); - string[] pathArray = uuid.Split('-'); - string path = pathArray[randomSerialNum]; - return path; - } - //域名检测是否为空 - //private bool TestDomainIsEmpty() - //{ - // if (string.IsNullOrEmpty(PreTrim(TextBoxDomain.Text)) == true) - // { - // //****** "域名不能为空,请检查相关参数设置!" ****** - // MessageBox.Show(Application.Current.FindResource("MessageBoxShow_DomainNotEmpty").ToString()); - // return false; - // } - // else - // { - // return true; - // } - //} - - private void CheckBoxMuxSelect_Checked(object sender, RoutedEventArgs e) - { - GridTrojanGoMuxSelected.Visibility = Visibility.Visible; - TextBlockExplainCheckBoxMuxSelect.Visibility = Visibility.Visible; - } - - private void CheckBoxMuxSelect_Unchecked(object sender, RoutedEventArgs e) - { - GridTrojanGoMuxSelected.Visibility = Visibility.Collapsed; - TextBlockExplainCheckBoxMuxSelect.Visibility = Visibility.Collapsed; - } - - //TextBox输入内容做预处理 - private string PreTrim(string preString) - { - return preString.Trim(); - } - - //处理伪装网站域名中的前缀 - //private string DisguiseURLprocessing(string fakeUrl) - //{ - //var uri = new Uri(fakeUrl); - //return uri.Host; - //if (fakeUrl.Length >= 7) - //{ - // string testDomainMask = fakeUrl.Substring(0, 7); - // if (String.Equals(testDomainMask, "https:/") || String.Equals(testDomainMask, "http://")) - // { - // string[] tmpUrl = fakeUrl.Split('/'); - // fakeUrl = tmpUrl[2]; - // } - - //} - //return fakeUrl; - // } - } -} diff --git a/ProxySU/V2RayTemplateWindow.xaml b/ProxySU/V2RayTemplateWindow.xaml deleted file mode 100644 index a3e0577..0000000 --- a/ProxySU/V2RayTemplateWindow.xaml +++ /dev/null @@ -1,390 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ProxySU/V2RayTemplateWindow.xaml.cs b/ProxySU/V2RayTemplateWindow.xaml.cs deleted file mode 100644 index 0b171a6..0000000 --- a/ProxySU/V2RayTemplateWindow.xaml.cs +++ /dev/null @@ -1,1146 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; -//using System.Windows.Forms; - -namespace ProxySU -{ - /// - /// WindowTemplateConfiguration.xaml 的交互逻辑 - /// - public partial class WindowTemplateConfiguration : Window - { - //QUIC 加密方法 - public class EncryptionMethodInfo - { - public string Name { get; set; } - public string Value { get; set; } - } - - public WindowTemplateConfiguration() - { - InitializeComponent(); - - #region 加密方法选择 初始设置为chacha20-poly1305 - List methodList = new List(); - - methodList.Add(new EncryptionMethodInfo { Name = "chacha20-poly1305", Value = "chacha20-poly1305" }); - methodList.Add(new EncryptionMethodInfo { Name = "aes-128-gcm", Value = "aes-128-gcm" }); - methodList.Add(new EncryptionMethodInfo { Name = "none", Value = "none" }); - - ComboBoxEncryptionMethodInfo.ItemsSource = methodList; - - ComboBoxEncryptionMethodInfo.DisplayMemberPath = "Name";//显示出来的值 - ComboBoxEncryptionMethodInfo.SelectedValuePath = "Value";//实际选中后获取的结果的值 - ComboBoxEncryptionMethodInfo.SelectedIndex = 0; - - DataContext = this; - #endregion - - //隐藏QUIC密钥 - FirstQuicHideEncryption(); - RadioButtonVMESSmKCP.IsChecked = true; - } - //取消不在当前活动选项卡中的其他所有选项卡中的所有RadioBuuton的选中状态 - //代码参考网址:https://blog.csdn.net/weixin_42583999/article/details/103468857 - //调用:UncheckLayouts((TabItem)TabControlTemplate.SelectedItem); - private void UncheckLayouts(TabItem activePage) - { - foreach (TabItem tabPage in TabControlTemplate.Items) - { - if (tabPage == activePage) continue; - Grid grid = (Grid)tabPage.Content; - foreach (UIElement element in grid.Children) - { - if (element is RadioButton) - { - RadioButton radiobutton = (element as RadioButton); - radiobutton.IsChecked = false; - } - - } - } - } - - //传递所选择的参数与模板方案 - private void ButtondDecide_Click(object sender, RoutedEventArgs e) - { - bool preDomainMask = ClassModel.PreDomainMask(TextBoxMaskSites.Text); - bool domainNotEmpty = true; - - #region TCP 传输协议(VMESS) - - //TCP模式被选中 - if (RadioButtonTCP.IsChecked == true) - { - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "TCP"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonTCP.Content.ToString(); - - } - - //TCP+http伪装模式被选中 - else if (RadioButtonTCPhttp.IsChecked == true) - { - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "TCPhttp"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonTCPhttp.Content.ToString(); - //伪装类型 - MainWindow.ReceiveConfigurationParameters[5] = "http"; - - } - - //TCP+TLS模式被选中 - else if (RadioButtonTCP2TLS.IsChecked == true) - { - domainNotEmpty = ClassModel.TestDomainIsEmpty(TextBoxDomain.Text); - - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "tcpTLS"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonTCP2TLS.Content.ToString(); - - //传递域名 - MainWindow.ReceiveConfigurationParameters[4] = PreTrim(TextBoxDomain.Text); - - } - - //tcp+TLS(自签证书)模式被选中 - else if (RadioButtonTcpTLS2SelfSigned.IsChecked == true) - { - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "tcpTLSselfSigned"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonTcpTLS2SelfSigned.Content.ToString(); - - //传递域名 - // MainWindow.ReceiveConfigurationParameters[4] = PreTrim(TextBoxDomain.Text); - - } - - #endregion - - #region VLESS协议 - - //VLESS+TCP+XTLS+Web模式选中 - else if (RadioButtonVlessXtlsTcp.IsChecked == true) - { - domainNotEmpty = ClassModel.TestDomainIsEmpty(TextBoxDomain.Text); - - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "VlessXtlsTcp"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonVlessXtlsTcp.Content.ToString(); - - //传递域名 - MainWindow.ReceiveConfigurationParameters[4] = PreTrim(TextBoxDomain.Text); - //传递伪装网站 - MainWindow.ReceiveConfigurationParameters[7] = ClassModel.DisguiseURLprocessing(PreTrim(TextBoxMaskSites.Text)); - - } - - //VLESS+TCP+TLS+Web模式选中 - else if (RadioButtonVlessTcpTlsWeb.IsChecked == true) - { - domainNotEmpty = ClassModel.TestDomainIsEmpty(TextBoxDomain.Text); - - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "VlessTcpTlsWeb"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonVlessTcpTlsWeb.Content.ToString(); - - //传递域名 - MainWindow.ReceiveConfigurationParameters[4] = PreTrim(TextBoxDomain.Text); - //传递伪装网站 - MainWindow.ReceiveConfigurationParameters[7] = ClassModel.DisguiseURLprocessing(PreTrim(TextBoxMaskSites.Text)); - - } - - //VLESS+WebSocket+TLS+Web模式选中 - else if (RadioButtonVlessWebSocketTlsWeb.IsChecked == true) - { - domainNotEmpty = ClassModel.TestDomainIsEmpty(TextBoxDomain.Text); - - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "VlessWebSocketTlsWeb"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonVlessWebSocketTlsWeb.Content.ToString(); - - //传递路径 - MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxPath.Text); - //传递域名 - MainWindow.ReceiveConfigurationParameters[4] = PreTrim(TextBoxDomain.Text); - //传递伪装网站 - MainWindow.ReceiveConfigurationParameters[7] = ClassModel.DisguiseURLprocessing(PreTrim(TextBoxMaskSites.Text)); - } - - //VLESS+http2+TLS+Web模式选中 - else if (RadioButtonVlessHttp2Web.IsChecked == true) - { - domainNotEmpty = ClassModel.TestDomainIsEmpty(TextBoxDomain.Text); - - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "VlessHttp2Web"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonVlessHttp2Web.Content.ToString(); - - //传递路径 - MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxPath.Text); - //传递域名 - MainWindow.ReceiveConfigurationParameters[4] = PreTrim(TextBoxDomain.Text); - //传递伪装网站 - MainWindow.ReceiveConfigurationParameters[7] = ClassModel.DisguiseURLprocessing(PreTrim(TextBoxMaskSites.Text)); - } - - //VLESS+VMESS+Trojan+XTLS+TCP+WebSocket+Web模式被选中 - else if (RadioButtonVlessVmessXtlsTcpWebSocketHot.IsChecked == true) - { - domainNotEmpty = ClassModel.TestDomainIsEmpty(TextBoxDomain.Text); - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "VlessVmessXtlsTcpWebSocketWeb"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonVlessVmessXtlsTcpWebSocketHot.Content.ToString(); - //传递路径 - MainWindow.ReceiveConfigurationParameters[3] = PreTrim(TextBoxPathVlessWS.Text);//VLESS ws Path - MainWindow.ReceiveConfigurationParameters[9] = PreTrim(TextBoxPathVmessTcp.Text);//VMESS tcp Path - MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxPathVmessWS.Text);//VMESS ws Path - - //传递域名 - MainWindow.ReceiveConfigurationParameters[4] = PreTrim(TextBoxDomain.Text); - //传递混淆方式(VMESS TCP Path方式所用) - MainWindow.ReceiveConfigurationParameters[5] = "http"; - //传递伪装网站 - MainWindow.ReceiveConfigurationParameters[7] = ClassModel.DisguiseURLprocessing(PreTrim(TextBoxMaskSites.Text)); - - } - - #endregion - - #region WebSocket传输协议(VMESS) - - //webSocket模式被选中 - else if (RadioButtonWebSocket.IsChecked == true) - { - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "webSocket"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonWebSocket.Content.ToString(); - - } - - //WebSocket+TLS模式被选中 - else if (RadioButtonWebSocketTLS.IsChecked == true) - { - domainNotEmpty = ClassModel.TestDomainIsEmpty(TextBoxDomain.Text); - - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "WebSocketTLS"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonWebSocketTLS.Content.ToString(); - //传递路径 - MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxPath.Text); - //传递域名 - MainWindow.ReceiveConfigurationParameters[4] = PreTrim(TextBoxDomain.Text); - - } - - //WebSocket+TLS+Web模式被选中 - else if (RadioButtonWebSocketTLS2Web.IsChecked == true|| RadioButtonWebSocketTLS2WebHot.IsChecked==true) - { - domainNotEmpty = ClassModel.TestDomainIsEmpty(TextBoxDomain.Text); - - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "WebSocketTLS2Web"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonWebSocketTLS2Web.Content.ToString(); - - //传递路径 - MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxPath.Text); - //传递域名 - MainWindow.ReceiveConfigurationParameters[4] = PreTrim(TextBoxDomain.Text); - //传递伪装网站 - MainWindow.ReceiveConfigurationParameters[7] = ClassModel.DisguiseURLprocessing(PreTrim(TextBoxMaskSites.Text)); - - } - - //WebSocket+TLS(自签证书)模式被选中 - else if (RadioButtonWebSocketTLSselfSigned.IsChecked == true) - { - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "WebSocketTLSselfSigned"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonWebSocketTLSselfSigned.Content.ToString(); - - //传递路径 - MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxPath.Text); - //传递域名 - //MainWindow.ReceiveConfigurationParameters[4] = PreTrim(TextBoxDomain.Text); - - } - - #endregion - - #region http2传输协议(VMESS) - - //http2模式被选中 - else if (RadioButtonHTTP2.IsChecked == true) - { - domainNotEmpty = ClassModel.TestDomainIsEmpty(TextBoxDomain.Text); - - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "Http2"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonHTTP2.Content.ToString(); - - //传递路径 - MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxPath.Text); - //传递域名 - MainWindow.ReceiveConfigurationParameters[4] = PreTrim(TextBoxDomain.Text); - - } - - //http2+TLS+Web模式被选中 - else if (RadioButtonHTTP2Web.IsChecked == true || RadioButtonHTTP2WebHot.IsChecked == true) - { - domainNotEmpty = ClassModel.TestDomainIsEmpty(TextBoxDomain.Text); - - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "http2Web"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonHTTP2Web.Content.ToString(); - - //传递路径 - MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxPath.Text); - //传递域名 - MainWindow.ReceiveConfigurationParameters[4] = PreTrim(TextBoxDomain.Text); - //传递伪装网站 - MainWindow.ReceiveConfigurationParameters[7] = ClassModel.DisguiseURLprocessing(PreTrim(TextBoxMaskSites.Text)); - - } - - //http2(自签证书)模式被选中 - else if (RadioButtonHTTP2selfSigned.IsChecked == true) - { - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "http2selfSigned"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonHTTP2selfSigned.Content.ToString(); - - //传递路径 - MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxPath.Text); - //传递域名 - //MainWindow.ReceiveConfigurationParameters[4] = PreTrim(TextBoxDomain.Text); - - } - - #endregion - - #region mKCP 传输协议 (VMESS) - - //mKCP无伪装模式被选中 - else if (RadioButtonMkcpNone.IsChecked == true) - { - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "mKCPNone"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonMkcpNone.Content.ToString(); - //传递伪装类型 - MainWindow.ReceiveConfigurationParameters[5] = "none"; - //传递mKCP Seed - if (String.IsNullOrEmpty(PreTrim(TextBoxQuicAndMkcpSeedUUID.Text)) ==false) - { - MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxQuicAndMkcpSeedUUID.Text); - } - } - - //mKCP+srtp伪装模式被选中 - else if (RadioButton2mKCP2SRTP.IsChecked == true) - { - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "mKCP2SRTP"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButton2mKCP2SRTP.Content.ToString(); - //传递伪装类型 - MainWindow.ReceiveConfigurationParameters[5] = "srtp"; - //传递mKCP Seed - if (String.IsNullOrEmpty(PreTrim(TextBoxQuicAndMkcpSeedUUID.Text)) == false) - { - MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxQuicAndMkcpSeedUUID.Text); - } - } - - //mKCP+utp伪装模式被选中 - else if (RadioButton2mKCPuTP.IsChecked == true) - { - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "mKCPuTP"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButton2mKCPuTP.Content.ToString(); - //传递伪装类型 - MainWindow.ReceiveConfigurationParameters[5] = "utp"; - //传递mKCP Seed - if (String.IsNullOrEmpty(PreTrim(TextBoxQuicAndMkcpSeedUUID.Text)) == false) - { - MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxQuicAndMkcpSeedUUID.Text); - } - } - - //mKCP+wechat-video伪装模式被选中 - else if (RadioButton2mKCP2WechatVideo.IsChecked == true) - { - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "mKCP2WechatVideo"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButton2mKCP2WechatVideo.Content.ToString(); - //传递伪装类型 - MainWindow.ReceiveConfigurationParameters[5] = "wechat-video"; - //传递mKCP Seed - if (String.IsNullOrEmpty(PreTrim(TextBoxQuicAndMkcpSeedUUID.Text)) == false) - { - MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxQuicAndMkcpSeedUUID.Text); - } - } - - //mKCP+dtls伪装模式被选中 - else if (RadioButton2mKCP2DTLS.IsChecked == true) - { - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "mKCP2DTLS"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButton2mKCP2DTLS.Content.ToString(); - //传递伪装类型 - MainWindow.ReceiveConfigurationParameters[5] = "dtls"; - //传递mKCP Seed - if (String.IsNullOrEmpty(PreTrim(TextBoxQuicAndMkcpSeedUUID.Text)) == false) - { - MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxQuicAndMkcpSeedUUID.Text); - } - } - - //mKCP+wireguard伪装模式被选中 - else if (RadioButton2mKCP2WireGuard.IsChecked == true) - { - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "mKCP2WireGuard"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButton2mKCP2WireGuard.Content.ToString(); - //传递伪装类型 - MainWindow.ReceiveConfigurationParameters[5] = "wireguard"; - //传递mKCP Seed - if (String.IsNullOrEmpty(PreTrim(TextBoxQuicAndMkcpSeedUUID.Text)) == false) - { - MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxQuicAndMkcpSeedUUID.Text); - } - } - - #endregion - - #region QUIC传输协议(VMESS) - - //QUIC无伪装模式被选中 - else if (RadioButtonQuicNone.IsChecked == true) - { - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "QuicNone"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonQuicNone.Content.ToString(); - //传递伪装类型 - MainWindow.ReceiveConfigurationParameters[5] = "none"; - //QUIC 密钥 - MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxQuicAndMkcpSeedUUID.Text); - //QUIC加密方法 - MainWindow.ReceiveConfigurationParameters[3] = GetEncryptionMethodSS(); - } - - //QUIC+srtp伪装模式被选中 - else if (RadioButtonQuicSRTP.IsChecked == true) - { - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "QuicSRTP"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonQuicSRTP.Content.ToString(); - //传递伪装类型 - MainWindow.ReceiveConfigurationParameters[5] = "srtp"; - //QUIC 密钥 - MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxQuicAndMkcpSeedUUID.Text); - //QUIC加密方法 - MainWindow.ReceiveConfigurationParameters[3] = GetEncryptionMethodSS(); - } - - //QUIC+utp伪装模式被选中 - else if (RadioButtonQuic2uTP.IsChecked == true) - { - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "Quic2uTP"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonQuic2uTP.Content.ToString(); - //传递伪装类型 - MainWindow.ReceiveConfigurationParameters[5] = "utp"; - //QUIC 密钥 - MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxQuicAndMkcpSeedUUID.Text); - //QUIC加密方法 - MainWindow.ReceiveConfigurationParameters[3] = GetEncryptionMethodSS(); - } - - //QUIC+wechat-video伪装模式被选中 - else if (RadioButtonQuicWechatVideo.IsChecked == true) - { - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "QuicWechatVideo"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonQuicWechatVideo.Content.ToString(); - //传递伪装类型 - MainWindow.ReceiveConfigurationParameters[5] = "wechat-video"; - //QUIC 密钥 - MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxQuicAndMkcpSeedUUID.Text); - //QUIC加密方法 - MainWindow.ReceiveConfigurationParameters[3] = GetEncryptionMethodSS(); - } - - //QUIC+dtls伪装模式被选中 - else if (RadioButtonQuicDTLS.IsChecked == true) - { - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "QuicDTLS"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonQuicDTLS.Content.ToString(); - //传递伪装类型 - MainWindow.ReceiveConfigurationParameters[5] = "dtls"; - //QUIC 密钥 - MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxQuicAndMkcpSeedUUID.Text); - //QUIC加密方法 - MainWindow.ReceiveConfigurationParameters[3] = GetEncryptionMethodSS(); - } - - //QUIC+wireguard伪装模式被选中 - else if (RadioButtonQuicWireGuard.IsChecked == true) - { - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "QuicWireGuard"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonQuicWireGuard.Content.ToString(); - //传递伪装类型 - MainWindow.ReceiveConfigurationParameters[5] = "wireguard"; - //QUIC 密钥 - MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxQuicAndMkcpSeedUUID.Text); - //QUIC加密方法 - MainWindow.ReceiveConfigurationParameters[3] = GetEncryptionMethodSS(); - } - - #endregion - - //传递服务端口 - MainWindow.ReceiveConfigurationParameters[1] = PreTrim(TextBoxServerListenPort.Text); - //传递uuid - MainWindow.ReceiveConfigurationParameters[2] = PreTrim(TextBoxNewUUID.Text); - - if (RadioButtonVLESSmKCP.IsChecked == true) - { - MainWindow.mKCPvlessIsSet = true; - } - else - { - MainWindow.mKCPvlessIsSet = false; - } - - if (domainNotEmpty == true && preDomainMask == true) - { - this.Close(); - } - - } - - //取消选择返回主窗口 - private void ButtondCancel_Click(object sender, RoutedEventArgs e) => Close(); - - - //伪装网站处理 - //DisguiseURLprocessing(string fakeUrl); - // private string DisguiseURLprocessing(string fakeUrl) - //{ - //var uri = new Uri(fakeUrl); - //return uri.Host; - //Console.WriteLine(uri.Host); - - ////处理伪装网站域名中的前缀 - //if (fakeUrl.Length >= 7) - //{ - // string testDomainMask = fakeUrl.Substring(0, 7); - // if (String.Equals(testDomainMask, "https:/") || String.Equals(testDomainMask, "http://")) - // { - // string[] tmpUrl = fakeUrl.Split('/'); - // fakeUrl = tmpUrl[2]; - // } - - //} - - //} - - #region 其他设置中的界面控制 - - private void RadioButtonTCP_Checked(object sender, RoutedEventArgs e) - { - //隐藏mKCP项 - HideMkcpSeed(); - - //隐藏QUIC密钥 - HideQuic(); - - //隐藏Path - HidePath(); - HideVlessVmessMultiplePath(); - - //隐藏域名 - HideDomain(); - - //隐藏伪装网站 - HideMaskSites(); - - - //Guid uuid = Guid.NewGuid(); - TextBoxNewUUID.Text = GenerateRandomUUID(); - //Random random = new Random(); - int randomServerPort = GetRandomPort(); - TextBoxServerListenPort.Text = randomServerPort.ToString(); - //清除其他选项卡中的选项 - UncheckLayouts((TabItem)TabControlTemplate.SelectedItem); - } - private void RadioButtonTCPhttp_Checked(object sender, RoutedEventArgs e) - { - TextBoxServerListenPort.Text = "80"; - - //隐藏mKCP项 - HideMkcpSeed(); - - //隐藏QUIC密钥 - HideQuic(); - - //隐藏Path - HidePath(); - HideVlessVmessMultiplePath(); - - //隐藏域名 - HideDomain(); - - //隐藏伪装网站 - HideMaskSites(); - - //Guid uuid = Guid.NewGuid(); - TextBoxNewUUID.Text = GenerateRandomUUID(); - //清除其他选项卡中的选项 - UncheckLayouts((TabItem)TabControlTemplate.SelectedItem); - } - private void RadioButtonTCP2TLS_Checked(object sender, RoutedEventArgs e) - { - TextBoxServerListenPort.Text = "443"; - - //隐藏mKCP项 - HideMkcpSeed(); - - //隐藏QUIC密钥 - HideQuic(); - - //隐藏Path - HidePath(); - HideVlessVmessMultiplePath(); - - //显示域名 - ShowDomain(); - - //隐藏伪装网站 - HideMaskSites(); - - //Guid uuid = Guid.NewGuid(); - TextBoxNewUUID.Text = GenerateRandomUUID(); - //清除其他选项卡中的选项 - UncheckLayouts((TabItem)TabControlTemplate.SelectedItem); - } - private void RadioButtonVlessTcpTlsWeb_Checked(object sender, RoutedEventArgs e) - { - TextBoxServerListenPort.Text = "443"; - - //隐藏mKCP项 - HideMkcpSeed(); - - //隐藏QUIC密钥 - HideQuic(); - - //隐藏Path - HidePath(); - HideVlessVmessMultiplePath(); - - //显示域名 - ShowDomain(); - - //显示伪装网站 - ShowMaskSites(); - - //Guid uuid = Guid.NewGuid(); - TextBoxNewUUID.Text = GenerateRandomUUID(); - //清除其他选项卡中的选项 - UncheckLayouts((TabItem)TabControlTemplate.SelectedItem); - } - private void RadioButtonVlessVmessXtlsTcpWebSocketHot_Checked(object sender, RoutedEventArgs e) - { - TextBoxServerListenPort.Text = "443"; - - //隐藏mKCP项 - HideMkcpSeed(); - - //隐藏QUIC密钥 - HideQuic(); - - //显示复合路径 - ShowVlessVmessMultiplePath(); - - //显示域名 - ShowDomain(); - - //显示伪装网站 - ShowMaskSites(); - - //生成UUID - TextBoxNewUUID.Text = GenerateRandomUUID(); - - //清除其他选项卡中的选项 - UncheckLayouts((TabItem)TabControlTemplate.SelectedItem); - } - //单击TextBlockVlessVmessXtlsTcpWebSocket标签则选中RadioButtonVlessVmessXtlsTcpWebSocketHot - private void TextBlockVlessVmessXtlsTcpWebSocket_MouseDown(object sender, MouseButtonEventArgs e) - { - RadioButtonVlessVmessXtlsTcpWebSocketHot.IsChecked = true; - } - private void RadioButtonTCP2TLSnoDomain_Checked(object sender, RoutedEventArgs e) - { - TextBoxServerListenPort.Text = "443"; - - //隐藏mKCP项 - HideMkcpSeed(); - - //隐藏QUIC密钥 - HideQuic(); - - //隐藏Path - HidePath(); - HideVlessVmessMultiplePath(); - - //隐藏域名 - HideDomain(); - - //隐藏伪装网站 - HideMaskSites(); - - //Guid uuid = Guid.NewGuid(); - TextBoxNewUUID.Text = GenerateRandomUUID(); - //清除其他选项卡中的选项 - UncheckLayouts((TabItem)TabControlTemplate.SelectedItem); - } - private void RadioButtonWebSocketTLS2Web_Checked(object sender, RoutedEventArgs e) - { - TextBoxServerListenPort.Text = "443"; - - //隐藏mKCP项 - HideMkcpSeed(); - - //隐藏QUIC密钥 - HideQuic(); - - //显示Path - ShowPath(); - - //显示域名 - ShowDomain(); - - //显示伪装网站 - ShowMaskSites(); - - //Guid uuid = Guid.NewGuid(); - TextBoxNewUUID.Text = GenerateRandomUUID(); - //清除其他选项卡中的选项 - UncheckLayouts((TabItem)TabControlTemplate.SelectedItem); - } - private void RadioButtonWebSocketTLSselfSigned_Checked(object sender, RoutedEventArgs e) - { - TextBoxServerListenPort.Text = "443"; - - //隐藏mKCP项 - HideMkcpSeed(); - - //隐藏QUIC密钥 - HideQuic(); - - //显示Path - ShowPath(); - - //隐藏域名 - HideDomain(); - - //隐藏伪装网站 - HideMaskSites(); - - //Guid uuid = Guid.NewGuid(); - TextBoxNewUUID.Text = GenerateRandomUUID(); - //清除其他选项卡中的选项 - UncheckLayouts((TabItem)TabControlTemplate.SelectedItem); - } - private void RadioButtonHTTP2_Checked(object sender, RoutedEventArgs e) - { - TextBoxServerListenPort.Text = "443"; - - //隐藏mKCP项 - HideMkcpSeed(); - - //隐藏QUIC密钥 - HideQuic(); - - //显示Path - ShowPath(); - - //显示域名 - ShowDomain(); - - //隐藏伪装网站 - HideMaskSites(); - - //Guid uuid = Guid.NewGuid(); - TextBoxNewUUID.Text = GenerateRandomUUID(); - //清除其他选项卡中的选项 - UncheckLayouts((TabItem)TabControlTemplate.SelectedItem); - } - - //mKCP显示界面 - private void RadioButtonMkcp_Checked(object sender, RoutedEventArgs e) - { - //隐藏QUIC密钥 - HideQuic(); - - //显示mKCP Seed - ShowMkcpSeed(); - - //隐藏Path - HidePath(); - HideVlessVmessMultiplePath(); - - //隐藏域名 - HideDomain(); - - //隐藏伪装网站 - HideMaskSites(); - - //Guid uuid = Guid.NewGuid(); - TextBoxNewUUID.Text = GenerateRandomUUID(); - - //uuid = Guid.NewGuid(); - TextBoxQuicAndMkcpSeedUUID.Text = GenerateRandomUUID(); - - //Random random = new Random(); - int randomServerPort = GetRandomPort(); - TextBoxServerListenPort.Text = randomServerPort.ToString(); - //清除其他选项卡中的选项 - UncheckLayouts((TabItem)TabControlTemplate.SelectedItem); - } - - //QUIC显示界面 - private void RadioButtonQuicNone_Checked(object sender, RoutedEventArgs e) - { - //隐藏mKCP项 - HideMkcpSeed(); - - //显示QUIC密钥 - ShowQuic(); - - //隐藏Path - HidePath(); - HideVlessVmessMultiplePath(); - - //隐藏域名 - HideDomain(); - - //隐藏伪装网站 - HideMaskSites(); - - //Guid uuid = Guid.NewGuid(); - TextBoxNewUUID.Text = GenerateRandomUUID(); - - //uuid = Guid.NewGuid(); - TextBoxQuicAndMkcpSeedUUID.Text = GenerateRandomUUID(); - - //Random random = new Random(); - int randomServerPort = GetRandomPort(); - TextBoxServerListenPort.Text = randomServerPort.ToString(); - //清除其他选项卡中的选项 - UncheckLayouts((TabItem)TabControlTemplate.SelectedItem); - } - - - //隐藏QUIC相关项 - private void HideQuic() - { - TextBlockQuicUUID.Visibility = Visibility.Collapsed; - TextBoxQuicAndMkcpSeedUUID.Visibility = Visibility.Collapsed; - ButtonQuicAndmKcpSeedUUID.Visibility = Visibility.Collapsed; - TextBlockQuicEncryption.Visibility = Visibility.Collapsed; - ComboBoxEncryptionMethodInfo.Visibility = Visibility.Collapsed; - //TextBlockMkcpUUID.Visibility = Visibility.Collapsed; - } - //如果加密方法选择none,则隐藏只QUIC密钥 - private void NoneEncryptionHideQuicKey() - { - TextBlockQuicUUID.Visibility = Visibility.Collapsed; - TextBoxQuicAndMkcpSeedUUID.Visibility = Visibility.Collapsed; - ButtonQuicAndmKcpSeedUUID.Visibility = Visibility.Collapsed; - } - //窗口初始化时,需要做一次隐藏QUIC加密方法 - private void FirstQuicHideEncryption() - { - TextBlockQuicEncryption.Visibility = Visibility.Collapsed; - ComboBoxEncryptionMethodInfo.Visibility = Visibility.Collapsed; - } - //显示QUIC相关项 - private void ShowQuic() - { - TextBlockQuicUUID.Visibility = Visibility.Visible; - TextBoxQuicAndMkcpSeedUUID.Visibility = Visibility.Visible; - ButtonQuicAndmKcpSeedUUID.Visibility = Visibility.Visible; - TextBlockQuicEncryption.Visibility = Visibility.Visible; - ComboBoxEncryptionMethodInfo.Visibility = Visibility.Visible; - - //隐藏mKCP相关项 - TextBlockMkcpSeedUUID.Visibility = Visibility.Collapsed; - TextBlockMkcpUUID.Visibility = Visibility.Collapsed; - } - //隐藏mKCP Seed相关项 - private void HideMkcpSeed() - { - TextBlockMkcpSeedUUID.Visibility = Visibility.Collapsed; - TextBoxQuicAndMkcpSeedUUID.Visibility = Visibility.Collapsed; - ButtonQuicAndmKcpSeedUUID.Visibility = Visibility.Collapsed; - TextBlockMkcpUUID.Visibility = Visibility.Collapsed; - - } - //显示mKCP Seed相关项 - private void ShowMkcpSeed() - { - TextBlockMkcpSeedUUID.Visibility = Visibility.Visible; - TextBoxQuicAndMkcpSeedUUID.Visibility = Visibility.Visible; - ButtonQuicAndmKcpSeedUUID.Visibility = Visibility.Visible; - TextBlockMkcpUUID.Visibility = Visibility.Visible; - //隐藏QUIC标示 - TextBlockQuicUUID.Visibility = Visibility.Collapsed; - } - //隐藏路径相关项 - private void HidePath() - { - //隐藏Path - TextBlockPath.Visibility = Visibility.Collapsed; - TextBoxPath.Visibility = Visibility.Collapsed; - ButtonPath.Visibility = Visibility.Collapsed; - } - //显示路径相关项 - private void ShowPath() - { - HideVlessVmessMultiplePath();//隐藏VLESS VMESS多种方案的路径Path - //显示Path - TextBlockPath.Visibility = Visibility.Visible; - TextBoxPath.Visibility = Visibility.Visible; - TextBoxPath.Text = "/ray"; - ButtonPath.Visibility = Visibility.Visible; - } - //隐藏VLESS VMESS复合方案路径 - private void HideVlessVmessMultiplePath() - { - TextBlockPathVlessWs.Visibility = Visibility.Collapsed; - TextBoxPathVlessWS.Visibility = Visibility.Collapsed; - TextBlockPathVmessTcp.Visibility = Visibility.Collapsed; - TextBoxPathVmessTcp.Visibility = Visibility.Collapsed; - TextBlockPathVmessWs.Visibility = Visibility.Collapsed; - TextBoxPathVmessWS.Visibility = Visibility.Collapsed; - ButtonVlessVmessPath.Visibility = Visibility.Collapsed; - TextBlockTrojanPassword.Visibility = Visibility.Collapsed; - - } - //显示VLESS VMESS复合方案路径 - private void ShowVlessVmessMultiplePath() - { - HidePath();//隐藏普通路径Path - TextBlockPathVlessWs.Visibility = Visibility.Visible; - TextBoxPathVlessWS.Visibility = Visibility.Visible; - TextBoxPathVlessWS.Text = "/vlessws"; - - TextBlockPathVmessTcp.Visibility = Visibility.Visible; - TextBoxPathVmessTcp.Visibility = Visibility.Visible; - TextBoxPathVmessTcp.Text = "/vmesstcp"; - - TextBlockPathVmessWs.Visibility = Visibility.Visible; - TextBoxPathVmessWS.Visibility = Visibility.Visible; - TextBoxPathVmessWS.Text = "/vmessws"; - - ButtonVlessVmessPath.Visibility = Visibility.Visible; - TextBlockTrojanPassword.Visibility = Visibility.Visible; - } - //隐藏域名相关项 - private void HideDomain() - { - //隐藏域名 - TextBlockDomain.Visibility = Visibility.Collapsed; - TextBoxDomain.Visibility = Visibility.Collapsed; - ButtonDomain.Visibility = Visibility.Collapsed; - } - //显示域名相关项 - private void ShowDomain() - { - //显示域名 - TextBlockDomain.Visibility = Visibility.Visible; - TextBoxDomain.Visibility = Visibility.Visible; - //ButtonDomain.Visibility = Visibility.Visible; - } - //隐藏伪装网站 - private void HideMaskSites() - { - TextBlockMaskSites.Visibility = Visibility.Collapsed; - TextBoxMaskSites.Visibility = Visibility.Collapsed; - } - //显示伪装网站 - private void ShowMaskSites() - { - TextBlockMaskSites.Visibility = Visibility.Visible; - TextBoxMaskSites.Visibility = Visibility.Visible; - } - #endregion - - //产生随机的uuid - private void ButtonNewUUID_Click(object sender, RoutedEventArgs e) - { - TextBoxNewUUID.Text = GenerateRandomUUID(); - } - - //产生QUIC密钥/mKCP Seed所用的UUID - private void ButtonQuicAndMkcpSeedUUID_Click(object sender, RoutedEventArgs e) - { - TextBoxQuicAndMkcpSeedUUID.Text = GenerateRandomUUID(); - } - - //更新随机服务端口 - private void ButtonServerListenPort_Click(object sender, RoutedEventArgs e) - { - int randomServerPort = GetRandomPort(); - TextBoxServerListenPort.Text = randomServerPort.ToString(); - } - - //更新单方案随机的Path - private void ButtonPath_Click(object sender, RoutedEventArgs e) - { - string path = GenerateRandomPath(); - TextBoxPath.Text = $"/{path}"; - } - - //更新多方案共存的Path - private void ButtonVlessVmessPath_Click(object sender, RoutedEventArgs e) - { - string path = GenerateRandomPath(); - TextBoxPathVlessWS.Text = $"/{path}"; - - path = GenerateRandomPath(); - TextBoxPathVmessTcp.Text = $"/{path}"; - - path = GenerateRandomPath(); - TextBoxPathVmessWS.Text = $"/{path}"; - } - //TextBox输入内容做预处理 - private string PreTrim(string preString) - { - return preString.Trim(); - } - //生成随机端口 - private int GetRandomPort() - { - Random random = new Random(); - return random.Next(10001, 60000); - } - - //生成随机UUID - private string GenerateRandomUUID() - { - Guid uuid = Guid.NewGuid(); - return uuid.ToString(); - } - - //生成随机Path - private string GenerateRandomPath() - { - Random random = new Random(); - int randomSerialNum = random.Next(0, 4); - //Guid uuid = Guid.NewGuid(); - string uuid = GenerateRandomUUID(); - string[] pathArray = uuid.Split('-'); - string path = pathArray[randomSerialNum]; - return path; - } - //域名检测是否为空 - //private bool TestDomainIsEmpty() - //{ - // if (string.IsNullOrEmpty(PreTrim(TextBoxDomain.Text)) == true) - // { - // //****** "域名不能为空,请检查相关参数设置!" ****** - // MessageBox.Show(Application.Current.FindResource("MessageBoxShow_DomainNotEmpty").ToString()); - // return false; - // } - // else - // { - // return true; - // } - //} - - //加密方法更改后的动作 - private void ComboBoxEncryptionMethodInfo_SelectionChanged(object sender, SelectionChangedEventArgs e) - { - string getMethond = GetEncryptionMethodSS(); - //传递加密方式 - MainWindow.ReceiveConfigurationParameters[3] = getMethond; - if (String.Equals(getMethond,"none")) - { - NoneEncryptionHideQuicKey(); - } - else - { - ShowQuic(); - } - - } - - //读取加密方式 - private string GetEncryptionMethodSS() - { - return ComboBoxEncryptionMethodInfo.SelectedValue.ToString(); - } - private void ButtonDomain_Click(object sender, RoutedEventArgs e) - { - - } - - - - - - - - - - //private void ButtonTestChecked_Click(object sender, RoutedEventArgs e) - //{ - // UncheckLayouts((TabItem)TabControlTemplate.SelectedItem); - - //} - } -} diff --git a/ProxySU/XayTemplateWindow.xaml b/ProxySU/XayTemplateWindow.xaml deleted file mode 100644 index 0daad4e..0000000 --- a/ProxySU/XayTemplateWindow.xaml +++ /dev/null @@ -1,390 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ProxySU/XayTemplateWindow.xaml.cs b/ProxySU/XayTemplateWindow.xaml.cs deleted file mode 100644 index 1079966..0000000 --- a/ProxySU/XayTemplateWindow.xaml.cs +++ /dev/null @@ -1,1146 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; -//using System.Windows.Forms; - -namespace ProxySU -{ - /// - /// WindowTemplateConfiguration.xaml 的交互逻辑 - /// - public partial class XrayWindowTemplateConfiguration : Window - { - //QUIC 加密方法 - public class EncryptionMethodInfo - { - public string Name { get; set; } - public string Value { get; set; } - } - - public XrayWindowTemplateConfiguration() - { - InitializeComponent(); - - #region 加密方法选择 初始设置为chacha20-poly1305 - List methodList = new List(); - - methodList.Add(new EncryptionMethodInfo { Name = "chacha20-poly1305", Value = "chacha20-poly1305" }); - methodList.Add(new EncryptionMethodInfo { Name = "aes-128-gcm", Value = "aes-128-gcm" }); - methodList.Add(new EncryptionMethodInfo { Name = "none", Value = "none" }); - - ComboBoxEncryptionMethodInfo.ItemsSource = methodList; - - ComboBoxEncryptionMethodInfo.DisplayMemberPath = "Name";//显示出来的值 - ComboBoxEncryptionMethodInfo.SelectedValuePath = "Value";//实际选中后获取的结果的值 - ComboBoxEncryptionMethodInfo.SelectedIndex = 0; - - DataContext = this; - #endregion - - //隐藏QUIC密钥 - FirstQuicHideEncryption(); - RadioButtonVMESSmKCP.IsChecked = true; - } - //取消不在当前活动选项卡中的其他所有选项卡中的所有RadioBuuton的选中状态 - //代码参考网址:https://blog.csdn.net/weixin_42583999/article/details/103468857 - //调用:UncheckLayouts((TabItem)TabControlTemplate.SelectedItem); - private void UncheckLayouts(TabItem activePage) - { - foreach (TabItem tabPage in TabControlTemplate.Items) - { - if (tabPage == activePage) continue; - Grid grid = (Grid)tabPage.Content; - foreach (UIElement element in grid.Children) - { - if (element is RadioButton) - { - RadioButton radiobutton = (element as RadioButton); - radiobutton.IsChecked = false; - } - - } - } - } - - //传递所选择的参数与模板方案 - private void ButtondDecide_Click(object sender, RoutedEventArgs e) - { - bool preDomainMask = ClassModel.PreDomainMask(TextBoxMaskSites.Text); - bool domainNotEmpty = true; - - #region TCP 传输协议(VMESS) - - //TCP模式被选中 - if (RadioButtonTCP.IsChecked == true) - { - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "TCP"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonTCP.Content.ToString(); - - } - - //TCP+http伪装模式被选中 - else if (RadioButtonTCPhttp.IsChecked == true) - { - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "TCPhttp"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonTCPhttp.Content.ToString(); - //伪装类型 - MainWindow.ReceiveConfigurationParameters[5] = "http"; - - } - - //TCP+TLS模式被选中 - else if (RadioButtonTCP2TLS.IsChecked == true) - { - domainNotEmpty = ClassModel.TestDomainIsEmpty(TextBoxDomain.Text); - - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "tcpTLS"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonTCP2TLS.Content.ToString(); - - //传递域名 - MainWindow.ReceiveConfigurationParameters[4] = PreTrim(TextBoxDomain.Text); - - } - - //tcp+TLS(自签证书)模式被选中 - else if (RadioButtonTcpTLS2SelfSigned.IsChecked == true) - { - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "tcpTLSselfSigned"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonTcpTLS2SelfSigned.Content.ToString(); - - //传递域名 - // MainWindow.ReceiveConfigurationParameters[4] = PreTrim(TextBoxDomain.Text); - - } - - #endregion - - #region VLESS协议 - - //VLESS+TCP+XTLS+Web模式选中 - else if (RadioButtonVlessXtlsTcp.IsChecked == true) - { - domainNotEmpty = ClassModel.TestDomainIsEmpty(TextBoxDomain.Text); - - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "VlessXtlsTcp"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonVlessXtlsTcp.Content.ToString(); - - //传递域名 - MainWindow.ReceiveConfigurationParameters[4] = PreTrim(TextBoxDomain.Text); - //传递伪装网站 - MainWindow.ReceiveConfigurationParameters[7] = ClassModel.DisguiseURLprocessing(PreTrim(TextBoxMaskSites.Text)); - - } - - //VLESS+TCP+TLS+Web模式选中 - else if (RadioButtonVlessTcpTlsWeb.IsChecked == true) - { - domainNotEmpty = ClassModel.TestDomainIsEmpty(TextBoxDomain.Text); - - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "VlessTcpTlsWeb"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonVlessTcpTlsWeb.Content.ToString(); - - //传递域名 - MainWindow.ReceiveConfigurationParameters[4] = PreTrim(TextBoxDomain.Text); - //传递伪装网站 - MainWindow.ReceiveConfigurationParameters[7] = ClassModel.DisguiseURLprocessing(PreTrim(TextBoxMaskSites.Text)); - - } - - //VLESS+WebSocket+TLS+Web模式选中 - else if (RadioButtonVlessWebSocketTlsWeb.IsChecked == true) - { - domainNotEmpty = ClassModel.TestDomainIsEmpty(TextBoxDomain.Text); - - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "VlessWebSocketTlsWeb"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonVlessWebSocketTlsWeb.Content.ToString(); - - //传递路径 - MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxPath.Text); - //传递域名 - MainWindow.ReceiveConfigurationParameters[4] = PreTrim(TextBoxDomain.Text); - //传递伪装网站 - MainWindow.ReceiveConfigurationParameters[7] = ClassModel.DisguiseURLprocessing(PreTrim(TextBoxMaskSites.Text)); - } - - //VLESS+http2+TLS+Web模式选中 - else if (RadioButtonVlessHttp2Web.IsChecked == true) - { - domainNotEmpty = ClassModel.TestDomainIsEmpty(TextBoxDomain.Text); - - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "VlessHttp2Web"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonVlessHttp2Web.Content.ToString(); - - //传递路径 - MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxPath.Text); - //传递域名 - MainWindow.ReceiveConfigurationParameters[4] = PreTrim(TextBoxDomain.Text); - //传递伪装网站 - MainWindow.ReceiveConfigurationParameters[7] = ClassModel.DisguiseURLprocessing(PreTrim(TextBoxMaskSites.Text)); - } - - //VLESS+VMESS+Trojan+XTLS+TCP+WebSocket+Web模式被选中 - else if (RadioButtonVlessVmessXtlsTcpWebSocketHot.IsChecked == true) - { - domainNotEmpty = ClassModel.TestDomainIsEmpty(TextBoxDomain.Text); - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "VlessVmessXtlsTcpWebSocketWeb"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonVlessVmessXtlsTcpWebSocketHot.Content.ToString(); - //传递路径 - MainWindow.ReceiveConfigurationParameters[3] = PreTrim(TextBoxPathVlessWS.Text);//VLESS ws Path - MainWindow.ReceiveConfigurationParameters[9] = PreTrim(TextBoxPathVmessTcp.Text);//VMESS tcp Path - MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxPathVmessWS.Text);//VMESS ws Path - - //传递域名 - MainWindow.ReceiveConfigurationParameters[4] = PreTrim(TextBoxDomain.Text); - //传递混淆方式(VMESS TCP Path方式所用) - MainWindow.ReceiveConfigurationParameters[5] = "http"; - //传递伪装网站 - MainWindow.ReceiveConfigurationParameters[7] = ClassModel.DisguiseURLprocessing(PreTrim(TextBoxMaskSites.Text)); - - } - - #endregion - - #region WebSocket传输协议(VMESS) - - //webSocket模式被选中 - else if (RadioButtonWebSocket.IsChecked == true) - { - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "webSocket"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonWebSocket.Content.ToString(); - - } - - //WebSocket+TLS模式被选中 - else if (RadioButtonWebSocketTLS.IsChecked == true) - { - domainNotEmpty = ClassModel.TestDomainIsEmpty(TextBoxDomain.Text); - - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "WebSocketTLS"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonWebSocketTLS.Content.ToString(); - //传递路径 - MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxPath.Text); - //传递域名 - MainWindow.ReceiveConfigurationParameters[4] = PreTrim(TextBoxDomain.Text); - - } - - //WebSocket+TLS+Web模式被选中 - else if (RadioButtonWebSocketTLS2Web.IsChecked == true|| RadioButtonWebSocketTLS2WebHot.IsChecked==true) - { - domainNotEmpty = ClassModel.TestDomainIsEmpty(TextBoxDomain.Text); - - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "WebSocketTLS2Web"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonWebSocketTLS2Web.Content.ToString(); - - //传递路径 - MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxPath.Text); - //传递域名 - MainWindow.ReceiveConfigurationParameters[4] = PreTrim(TextBoxDomain.Text); - //传递伪装网站 - MainWindow.ReceiveConfigurationParameters[7] = ClassModel.DisguiseURLprocessing(PreTrim(TextBoxMaskSites.Text)); - - } - - //WebSocket+TLS(自签证书)模式被选中 - else if (RadioButtonWebSocketTLSselfSigned.IsChecked == true) - { - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "WebSocketTLSselfSigned"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonWebSocketTLSselfSigned.Content.ToString(); - - //传递路径 - MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxPath.Text); - //传递域名 - //MainWindow.ReceiveConfigurationParameters[4] = PreTrim(TextBoxDomain.Text); - - } - - #endregion - - #region http2传输协议(VMESS) - - //http2模式被选中 - else if (RadioButtonHTTP2.IsChecked == true) - { - domainNotEmpty = ClassModel.TestDomainIsEmpty(TextBoxDomain.Text); - - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "Http2"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonHTTP2.Content.ToString(); - - //传递路径 - MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxPath.Text); - //传递域名 - MainWindow.ReceiveConfigurationParameters[4] = PreTrim(TextBoxDomain.Text); - - } - - //http2+TLS+Web模式被选中 - else if (RadioButtonHTTP2Web.IsChecked == true || RadioButtonHTTP2WebHot.IsChecked == true) - { - domainNotEmpty = ClassModel.TestDomainIsEmpty(TextBoxDomain.Text); - - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "http2Web"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonHTTP2Web.Content.ToString(); - - //传递路径 - MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxPath.Text); - //传递域名 - MainWindow.ReceiveConfigurationParameters[4] = PreTrim(TextBoxDomain.Text); - //传递伪装网站 - MainWindow.ReceiveConfigurationParameters[7] = ClassModel.DisguiseURLprocessing(PreTrim(TextBoxMaskSites.Text)); - - } - - //http2(自签证书)模式被选中 - else if (RadioButtonHTTP2selfSigned.IsChecked == true) - { - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "http2selfSigned"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonHTTP2selfSigned.Content.ToString(); - - //传递路径 - MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxPath.Text); - //传递域名 - //MainWindow.ReceiveConfigurationParameters[4] = PreTrim(TextBoxDomain.Text); - - } - - #endregion - - #region mKCP 传输协议 (VMESS) - - //mKCP无伪装模式被选中 - else if (RadioButtonMkcpNone.IsChecked == true) - { - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "mKCPNone"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonMkcpNone.Content.ToString(); - //传递伪装类型 - MainWindow.ReceiveConfigurationParameters[5] = "none"; - //传递mKCP Seed - if (String.IsNullOrEmpty(PreTrim(TextBoxQuicAndMkcpSeedUUID.Text)) ==false) - { - MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxQuicAndMkcpSeedUUID.Text); - } - } - - //mKCP+srtp伪装模式被选中 - else if (RadioButton2mKCP2SRTP.IsChecked == true) - { - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "mKCP2SRTP"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButton2mKCP2SRTP.Content.ToString(); - //传递伪装类型 - MainWindow.ReceiveConfigurationParameters[5] = "srtp"; - //传递mKCP Seed - if (String.IsNullOrEmpty(PreTrim(TextBoxQuicAndMkcpSeedUUID.Text)) == false) - { - MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxQuicAndMkcpSeedUUID.Text); - } - } - - //mKCP+utp伪装模式被选中 - else if (RadioButton2mKCPuTP.IsChecked == true) - { - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "mKCPuTP"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButton2mKCPuTP.Content.ToString(); - //传递伪装类型 - MainWindow.ReceiveConfigurationParameters[5] = "utp"; - //传递mKCP Seed - if (String.IsNullOrEmpty(PreTrim(TextBoxQuicAndMkcpSeedUUID.Text)) == false) - { - MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxQuicAndMkcpSeedUUID.Text); - } - } - - //mKCP+wechat-video伪装模式被选中 - else if (RadioButton2mKCP2WechatVideo.IsChecked == true) - { - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "mKCP2WechatVideo"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButton2mKCP2WechatVideo.Content.ToString(); - //传递伪装类型 - MainWindow.ReceiveConfigurationParameters[5] = "wechat-video"; - //传递mKCP Seed - if (String.IsNullOrEmpty(PreTrim(TextBoxQuicAndMkcpSeedUUID.Text)) == false) - { - MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxQuicAndMkcpSeedUUID.Text); - } - } - - //mKCP+dtls伪装模式被选中 - else if (RadioButton2mKCP2DTLS.IsChecked == true) - { - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "mKCP2DTLS"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButton2mKCP2DTLS.Content.ToString(); - //传递伪装类型 - MainWindow.ReceiveConfigurationParameters[5] = "dtls"; - //传递mKCP Seed - if (String.IsNullOrEmpty(PreTrim(TextBoxQuicAndMkcpSeedUUID.Text)) == false) - { - MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxQuicAndMkcpSeedUUID.Text); - } - } - - //mKCP+wireguard伪装模式被选中 - else if (RadioButton2mKCP2WireGuard.IsChecked == true) - { - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "mKCP2WireGuard"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButton2mKCP2WireGuard.Content.ToString(); - //传递伪装类型 - MainWindow.ReceiveConfigurationParameters[5] = "wireguard"; - //传递mKCP Seed - if (String.IsNullOrEmpty(PreTrim(TextBoxQuicAndMkcpSeedUUID.Text)) == false) - { - MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxQuicAndMkcpSeedUUID.Text); - } - } - - #endregion - - #region QUIC传输协议(VMESS) - - //QUIC无伪装模式被选中 - else if (RadioButtonQuicNone.IsChecked == true) - { - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "QuicNone"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonQuicNone.Content.ToString(); - //传递伪装类型 - MainWindow.ReceiveConfigurationParameters[5] = "none"; - //QUIC 密钥 - MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxQuicAndMkcpSeedUUID.Text); - //QUIC加密方法 - MainWindow.ReceiveConfigurationParameters[3] = GetEncryptionMethodSS(); - } - - //QUIC+srtp伪装模式被选中 - else if (RadioButtonQuicSRTP.IsChecked == true) - { - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "QuicSRTP"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonQuicSRTP.Content.ToString(); - //传递伪装类型 - MainWindow.ReceiveConfigurationParameters[5] = "srtp"; - //QUIC 密钥 - MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxQuicAndMkcpSeedUUID.Text); - //QUIC加密方法 - MainWindow.ReceiveConfigurationParameters[3] = GetEncryptionMethodSS(); - } - - //QUIC+utp伪装模式被选中 - else if (RadioButtonQuic2uTP.IsChecked == true) - { - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "Quic2uTP"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonQuic2uTP.Content.ToString(); - //传递伪装类型 - MainWindow.ReceiveConfigurationParameters[5] = "utp"; - //QUIC 密钥 - MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxQuicAndMkcpSeedUUID.Text); - //QUIC加密方法 - MainWindow.ReceiveConfigurationParameters[3] = GetEncryptionMethodSS(); - } - - //QUIC+wechat-video伪装模式被选中 - else if (RadioButtonQuicWechatVideo.IsChecked == true) - { - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "QuicWechatVideo"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonQuicWechatVideo.Content.ToString(); - //传递伪装类型 - MainWindow.ReceiveConfigurationParameters[5] = "wechat-video"; - //QUIC 密钥 - MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxQuicAndMkcpSeedUUID.Text); - //QUIC加密方法 - MainWindow.ReceiveConfigurationParameters[3] = GetEncryptionMethodSS(); - } - - //QUIC+dtls伪装模式被选中 - else if (RadioButtonQuicDTLS.IsChecked == true) - { - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "QuicDTLS"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonQuicDTLS.Content.ToString(); - //传递伪装类型 - MainWindow.ReceiveConfigurationParameters[5] = "dtls"; - //QUIC 密钥 - MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxQuicAndMkcpSeedUUID.Text); - //QUIC加密方法 - MainWindow.ReceiveConfigurationParameters[3] = GetEncryptionMethodSS(); - } - - //QUIC+wireguard伪装模式被选中 - else if (RadioButtonQuicWireGuard.IsChecked == true) - { - //传递模板类型 - MainWindow.ReceiveConfigurationParameters[0] = "QuicWireGuard"; - //传递方案名称 - MainWindow.ReceiveConfigurationParameters[8] = RadioButtonQuicWireGuard.Content.ToString(); - //传递伪装类型 - MainWindow.ReceiveConfigurationParameters[5] = "wireguard"; - //QUIC 密钥 - MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxQuicAndMkcpSeedUUID.Text); - //QUIC加密方法 - MainWindow.ReceiveConfigurationParameters[3] = GetEncryptionMethodSS(); - } - - #endregion - - //传递服务端口 - MainWindow.ReceiveConfigurationParameters[1] = PreTrim(TextBoxServerListenPort.Text); - //传递uuid - MainWindow.ReceiveConfigurationParameters[2] = PreTrim(TextBoxNewUUID.Text); - - if (RadioButtonVLESSmKCP.IsChecked == true) - { - MainWindow.mKCPvlessIsSet = true; - } - else - { - MainWindow.mKCPvlessIsSet = false; - } - - if (domainNotEmpty == true && preDomainMask == true) - { - this.Close(); - } - - } - - //取消选择返回主窗口 - private void ButtondCancel_Click(object sender, RoutedEventArgs e) => Close(); - - - //伪装网站处理 - //DisguiseURLprocessing(string fakeUrl); - // private string DisguiseURLprocessing(string fakeUrl) - //{ - //var uri = new Uri(fakeUrl); - //return uri.Host; - //Console.WriteLine(uri.Host); - - ////处理伪装网站域名中的前缀 - //if (fakeUrl.Length >= 7) - //{ - // string testDomainMask = fakeUrl.Substring(0, 7); - // if (String.Equals(testDomainMask, "https:/") || String.Equals(testDomainMask, "http://")) - // { - // string[] tmpUrl = fakeUrl.Split('/'); - // fakeUrl = tmpUrl[2]; - // } - - //} - - //} - - #region 其他设置中的界面控制 - - private void RadioButtonTCP_Checked(object sender, RoutedEventArgs e) - { - //隐藏mKCP项 - HideMkcpSeed(); - - //隐藏QUIC密钥 - HideQuic(); - - //隐藏Path - HidePath(); - HideVlessVmessMultiplePath(); - - //隐藏域名 - HideDomain(); - - //隐藏伪装网站 - HideMaskSites(); - - - //Guid uuid = Guid.NewGuid(); - TextBoxNewUUID.Text = GenerateRandomUUID(); - //Random random = new Random(); - int randomServerPort = GetRandomPort(); - TextBoxServerListenPort.Text = randomServerPort.ToString(); - //清除其他选项卡中的选项 - UncheckLayouts((TabItem)TabControlTemplate.SelectedItem); - } - private void RadioButtonTCPhttp_Checked(object sender, RoutedEventArgs e) - { - TextBoxServerListenPort.Text = "80"; - - //隐藏mKCP项 - HideMkcpSeed(); - - //隐藏QUIC密钥 - HideQuic(); - - //隐藏Path - HidePath(); - HideVlessVmessMultiplePath(); - - //隐藏域名 - HideDomain(); - - //隐藏伪装网站 - HideMaskSites(); - - //Guid uuid = Guid.NewGuid(); - TextBoxNewUUID.Text = GenerateRandomUUID(); - //清除其他选项卡中的选项 - UncheckLayouts((TabItem)TabControlTemplate.SelectedItem); - } - private void RadioButtonTCP2TLS_Checked(object sender, RoutedEventArgs e) - { - TextBoxServerListenPort.Text = "443"; - - //隐藏mKCP项 - HideMkcpSeed(); - - //隐藏QUIC密钥 - HideQuic(); - - //隐藏Path - HidePath(); - HideVlessVmessMultiplePath(); - - //显示域名 - ShowDomain(); - - //隐藏伪装网站 - HideMaskSites(); - - //Guid uuid = Guid.NewGuid(); - TextBoxNewUUID.Text = GenerateRandomUUID(); - //清除其他选项卡中的选项 - UncheckLayouts((TabItem)TabControlTemplate.SelectedItem); - } - private void RadioButtonVlessTcpTlsWeb_Checked(object sender, RoutedEventArgs e) - { - TextBoxServerListenPort.Text = "443"; - - //隐藏mKCP项 - HideMkcpSeed(); - - //隐藏QUIC密钥 - HideQuic(); - - //隐藏Path - HidePath(); - HideVlessVmessMultiplePath(); - - //显示域名 - ShowDomain(); - - //显示伪装网站 - ShowMaskSites(); - - //Guid uuid = Guid.NewGuid(); - TextBoxNewUUID.Text = GenerateRandomUUID(); - //清除其他选项卡中的选项 - UncheckLayouts((TabItem)TabControlTemplate.SelectedItem); - } - private void RadioButtonVlessVmessXtlsTcpWebSocketHot_Checked(object sender, RoutedEventArgs e) - { - TextBoxServerListenPort.Text = "443"; - - //隐藏mKCP项 - HideMkcpSeed(); - - //隐藏QUIC密钥 - HideQuic(); - - //显示复合路径 - ShowVlessVmessMultiplePath(); - - //显示域名 - ShowDomain(); - - //显示伪装网站 - ShowMaskSites(); - - //生成UUID - TextBoxNewUUID.Text = GenerateRandomUUID(); - - //清除其他选项卡中的选项 - UncheckLayouts((TabItem)TabControlTemplate.SelectedItem); - } - //单击TextBlockVlessVmessXtlsTcpWebSocket标签则选中RadioButtonVlessVmessXtlsTcpWebSocketHot - private void TextBlockVlessVmessXtlsTcpWebSocket_MouseDown(object sender, MouseButtonEventArgs e) - { - RadioButtonVlessVmessXtlsTcpWebSocketHot.IsChecked = true; - } - private void RadioButtonTCP2TLSnoDomain_Checked(object sender, RoutedEventArgs e) - { - TextBoxServerListenPort.Text = "443"; - - //隐藏mKCP项 - HideMkcpSeed(); - - //隐藏QUIC密钥 - HideQuic(); - - //隐藏Path - HidePath(); - HideVlessVmessMultiplePath(); - - //隐藏域名 - HideDomain(); - - //隐藏伪装网站 - HideMaskSites(); - - //Guid uuid = Guid.NewGuid(); - TextBoxNewUUID.Text = GenerateRandomUUID(); - //清除其他选项卡中的选项 - UncheckLayouts((TabItem)TabControlTemplate.SelectedItem); - } - private void RadioButtonWebSocketTLS2Web_Checked(object sender, RoutedEventArgs e) - { - TextBoxServerListenPort.Text = "443"; - - //隐藏mKCP项 - HideMkcpSeed(); - - //隐藏QUIC密钥 - HideQuic(); - - //显示Path - ShowPath(); - - //显示域名 - ShowDomain(); - - //显示伪装网站 - ShowMaskSites(); - - //Guid uuid = Guid.NewGuid(); - TextBoxNewUUID.Text = GenerateRandomUUID(); - //清除其他选项卡中的选项 - UncheckLayouts((TabItem)TabControlTemplate.SelectedItem); - } - private void RadioButtonWebSocketTLSselfSigned_Checked(object sender, RoutedEventArgs e) - { - TextBoxServerListenPort.Text = "443"; - - //隐藏mKCP项 - HideMkcpSeed(); - - //隐藏QUIC密钥 - HideQuic(); - - //显示Path - ShowPath(); - - //隐藏域名 - HideDomain(); - - //隐藏伪装网站 - HideMaskSites(); - - //Guid uuid = Guid.NewGuid(); - TextBoxNewUUID.Text = GenerateRandomUUID(); - //清除其他选项卡中的选项 - UncheckLayouts((TabItem)TabControlTemplate.SelectedItem); - } - private void RadioButtonHTTP2_Checked(object sender, RoutedEventArgs e) - { - TextBoxServerListenPort.Text = "443"; - - //隐藏mKCP项 - HideMkcpSeed(); - - //隐藏QUIC密钥 - HideQuic(); - - //显示Path - ShowPath(); - - //显示域名 - ShowDomain(); - - //隐藏伪装网站 - HideMaskSites(); - - //Guid uuid = Guid.NewGuid(); - TextBoxNewUUID.Text = GenerateRandomUUID(); - //清除其他选项卡中的选项 - UncheckLayouts((TabItem)TabControlTemplate.SelectedItem); - } - - //mKCP显示界面 - private void RadioButtonMkcp_Checked(object sender, RoutedEventArgs e) - { - //隐藏QUIC密钥 - HideQuic(); - - //显示mKCP Seed - ShowMkcpSeed(); - - //隐藏Path - HidePath(); - HideVlessVmessMultiplePath(); - - //隐藏域名 - HideDomain(); - - //隐藏伪装网站 - HideMaskSites(); - - //Guid uuid = Guid.NewGuid(); - TextBoxNewUUID.Text = GenerateRandomUUID(); - - //uuid = Guid.NewGuid(); - TextBoxQuicAndMkcpSeedUUID.Text = GenerateRandomUUID(); - - //Random random = new Random(); - int randomServerPort = GetRandomPort(); - TextBoxServerListenPort.Text = randomServerPort.ToString(); - //清除其他选项卡中的选项 - UncheckLayouts((TabItem)TabControlTemplate.SelectedItem); - } - - //QUIC显示界面 - private void RadioButtonQuicNone_Checked(object sender, RoutedEventArgs e) - { - //隐藏mKCP项 - HideMkcpSeed(); - - //显示QUIC密钥 - ShowQuic(); - - //隐藏Path - HidePath(); - HideVlessVmessMultiplePath(); - - //隐藏域名 - HideDomain(); - - //隐藏伪装网站 - HideMaskSites(); - - //Guid uuid = Guid.NewGuid(); - TextBoxNewUUID.Text = GenerateRandomUUID(); - - //uuid = Guid.NewGuid(); - TextBoxQuicAndMkcpSeedUUID.Text = GenerateRandomUUID(); - - //Random random = new Random(); - int randomServerPort = GetRandomPort(); - TextBoxServerListenPort.Text = randomServerPort.ToString(); - //清除其他选项卡中的选项 - UncheckLayouts((TabItem)TabControlTemplate.SelectedItem); - } - - - //隐藏QUIC相关项 - private void HideQuic() - { - TextBlockQuicUUID.Visibility = Visibility.Collapsed; - TextBoxQuicAndMkcpSeedUUID.Visibility = Visibility.Collapsed; - ButtonQuicAndmKcpSeedUUID.Visibility = Visibility.Collapsed; - TextBlockQuicEncryption.Visibility = Visibility.Collapsed; - ComboBoxEncryptionMethodInfo.Visibility = Visibility.Collapsed; - //TextBlockMkcpUUID.Visibility = Visibility.Collapsed; - } - //如果加密方法选择none,则隐藏只QUIC密钥 - private void NoneEncryptionHideQuicKey() - { - TextBlockQuicUUID.Visibility = Visibility.Collapsed; - TextBoxQuicAndMkcpSeedUUID.Visibility = Visibility.Collapsed; - ButtonQuicAndmKcpSeedUUID.Visibility = Visibility.Collapsed; - } - //窗口初始化时,需要做一次隐藏QUIC加密方法 - private void FirstQuicHideEncryption() - { - TextBlockQuicEncryption.Visibility = Visibility.Collapsed; - ComboBoxEncryptionMethodInfo.Visibility = Visibility.Collapsed; - } - //显示QUIC相关项 - private void ShowQuic() - { - TextBlockQuicUUID.Visibility = Visibility.Visible; - TextBoxQuicAndMkcpSeedUUID.Visibility = Visibility.Visible; - ButtonQuicAndmKcpSeedUUID.Visibility = Visibility.Visible; - TextBlockQuicEncryption.Visibility = Visibility.Visible; - ComboBoxEncryptionMethodInfo.Visibility = Visibility.Visible; - - //隐藏mKCP相关项 - TextBlockMkcpSeedUUID.Visibility = Visibility.Collapsed; - TextBlockMkcpUUID.Visibility = Visibility.Collapsed; - } - //隐藏mKCP Seed相关项 - private void HideMkcpSeed() - { - TextBlockMkcpSeedUUID.Visibility = Visibility.Collapsed; - TextBoxQuicAndMkcpSeedUUID.Visibility = Visibility.Collapsed; - ButtonQuicAndmKcpSeedUUID.Visibility = Visibility.Collapsed; - TextBlockMkcpUUID.Visibility = Visibility.Collapsed; - - } - //显示mKCP Seed相关项 - private void ShowMkcpSeed() - { - TextBlockMkcpSeedUUID.Visibility = Visibility.Visible; - TextBoxQuicAndMkcpSeedUUID.Visibility = Visibility.Visible; - ButtonQuicAndmKcpSeedUUID.Visibility = Visibility.Visible; - TextBlockMkcpUUID.Visibility = Visibility.Visible; - //隐藏QUIC标示 - TextBlockQuicUUID.Visibility = Visibility.Collapsed; - } - //隐藏路径相关项 - private void HidePath() - { - //隐藏Path - TextBlockPath.Visibility = Visibility.Collapsed; - TextBoxPath.Visibility = Visibility.Collapsed; - ButtonPath.Visibility = Visibility.Collapsed; - } - //显示路径相关项 - private void ShowPath() - { - HideVlessVmessMultiplePath();//隐藏VLESS VMESS多种方案的路径Path - //显示Path - TextBlockPath.Visibility = Visibility.Visible; - TextBoxPath.Visibility = Visibility.Visible; - TextBoxPath.Text = "/ray"; - ButtonPath.Visibility = Visibility.Visible; - } - //隐藏VLESS VMESS复合方案路径 - private void HideVlessVmessMultiplePath() - { - TextBlockPathVlessWs.Visibility = Visibility.Collapsed; - TextBoxPathVlessWS.Visibility = Visibility.Collapsed; - TextBlockPathVmessTcp.Visibility = Visibility.Collapsed; - TextBoxPathVmessTcp.Visibility = Visibility.Collapsed; - TextBlockPathVmessWs.Visibility = Visibility.Collapsed; - TextBoxPathVmessWS.Visibility = Visibility.Collapsed; - ButtonVlessVmessPath.Visibility = Visibility.Collapsed; - TextBlockTrojanPassword.Visibility = Visibility.Collapsed; - - } - //显示VLESS VMESS复合方案路径 - private void ShowVlessVmessMultiplePath() - { - HidePath();//隐藏普通路径Path - TextBlockPathVlessWs.Visibility = Visibility.Visible; - TextBoxPathVlessWS.Visibility = Visibility.Visible; - TextBoxPathVlessWS.Text = "/vlessws"; - - TextBlockPathVmessTcp.Visibility = Visibility.Visible; - TextBoxPathVmessTcp.Visibility = Visibility.Visible; - TextBoxPathVmessTcp.Text = "/vmesstcp"; - - TextBlockPathVmessWs.Visibility = Visibility.Visible; - TextBoxPathVmessWS.Visibility = Visibility.Visible; - TextBoxPathVmessWS.Text = "/vmessws"; - - ButtonVlessVmessPath.Visibility = Visibility.Visible; - TextBlockTrojanPassword.Visibility = Visibility.Visible; - } - //隐藏域名相关项 - private void HideDomain() - { - //隐藏域名 - TextBlockDomain.Visibility = Visibility.Collapsed; - TextBoxDomain.Visibility = Visibility.Collapsed; - ButtonDomain.Visibility = Visibility.Collapsed; - } - //显示域名相关项 - private void ShowDomain() - { - //显示域名 - TextBlockDomain.Visibility = Visibility.Visible; - TextBoxDomain.Visibility = Visibility.Visible; - //ButtonDomain.Visibility = Visibility.Visible; - } - //隐藏伪装网站 - private void HideMaskSites() - { - TextBlockMaskSites.Visibility = Visibility.Collapsed; - TextBoxMaskSites.Visibility = Visibility.Collapsed; - } - //显示伪装网站 - private void ShowMaskSites() - { - TextBlockMaskSites.Visibility = Visibility.Visible; - TextBoxMaskSites.Visibility = Visibility.Visible; - } - #endregion - - //产生随机的uuid - private void ButtonNewUUID_Click(object sender, RoutedEventArgs e) - { - TextBoxNewUUID.Text = GenerateRandomUUID(); - } - - //产生QUIC密钥/mKCP Seed所用的UUID - private void ButtonQuicAndMkcpSeedUUID_Click(object sender, RoutedEventArgs e) - { - TextBoxQuicAndMkcpSeedUUID.Text = GenerateRandomUUID(); - } - - //更新随机服务端口 - private void ButtonServerListenPort_Click(object sender, RoutedEventArgs e) - { - int randomServerPort = GetRandomPort(); - TextBoxServerListenPort.Text = randomServerPort.ToString(); - } - - //更新单方案随机的Path - private void ButtonPath_Click(object sender, RoutedEventArgs e) - { - string path = GenerateRandomPath(); - TextBoxPath.Text = $"/{path}"; - } - - //更新多方案共存的Path - private void ButtonVlessVmessPath_Click(object sender, RoutedEventArgs e) - { - string path = GenerateRandomPath(); - TextBoxPathVlessWS.Text = $"/{path}"; - - path = GenerateRandomPath(); - TextBoxPathVmessTcp.Text = $"/{path}"; - - path = GenerateRandomPath(); - TextBoxPathVmessWS.Text = $"/{path}"; - } - //TextBox输入内容做预处理 - private string PreTrim(string preString) - { - return preString.Trim(); - } - //生成随机端口 - private int GetRandomPort() - { - Random random = new Random(); - return random.Next(10001, 60000); - } - - //生成随机UUID - private string GenerateRandomUUID() - { - Guid uuid = Guid.NewGuid(); - return uuid.ToString(); - } - - //生成随机Path - private string GenerateRandomPath() - { - Random random = new Random(); - int randomSerialNum = random.Next(0, 4); - //Guid uuid = Guid.NewGuid(); - string uuid = GenerateRandomUUID(); - string[] pathArray = uuid.Split('-'); - string path = pathArray[randomSerialNum]; - return path; - } - //域名检测是否为空 - //private bool TestDomainIsEmpty() - //{ - // if (string.IsNullOrEmpty(PreTrim(TextBoxDomain.Text)) == true) - // { - // //****** "域名不能为空,请检查相关参数设置!" ****** - // MessageBox.Show(Application.Current.FindResource("MessageBoxShow_DomainNotEmpty").ToString()); - // return false; - // } - // else - // { - // return true; - // } - //} - - //加密方法更改后的动作 - private void ComboBoxEncryptionMethodInfo_SelectionChanged(object sender, SelectionChangedEventArgs e) - { - string getMethond = GetEncryptionMethodSS(); - //传递加密方式 - MainWindow.ReceiveConfigurationParameters[3] = getMethond; - if (String.Equals(getMethond,"none")) - { - NoneEncryptionHideQuicKey(); - } - else - { - ShowQuic(); - } - - } - - //读取加密方式 - private string GetEncryptionMethodSS() - { - return ComboBoxEncryptionMethodInfo.SelectedValue.ToString(); - } - private void ButtonDomain_Click(object sender, RoutedEventArgs e) - { - - } - - - - - - - - - - //private void ButtonTestChecked_Click(object sender, RoutedEventArgs e) - //{ - // UncheckLayouts((TabItem)TabControlTemplate.SelectedItem); - - //} - } -} diff --git a/ProxySU/bin/Beta/Beta.zip b/ProxySU/bin/Beta/Beta.zip deleted file mode 100644 index 500116a..0000000 Binary files a/ProxySU/bin/Beta/Beta.zip and /dev/null differ diff --git a/ProxySU/packages.config b/ProxySU/packages.config deleted file mode 100644 index cd7f780..0000000 --- a/ProxySU/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/ProxySU_Core/App.config b/ProxySU_Core/App.config deleted file mode 100644 index 824190f..0000000 --- a/ProxySU_Core/App.config +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - diff --git a/ProxySU_Core/App.xaml b/ProxySU_Core/App.xaml deleted file mode 100644 index d59fcda..0000000 --- a/ProxySU_Core/App.xaml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ProxySU_Core/App.xaml.cs b/ProxySU_Core/App.xaml.cs deleted file mode 100644 index 2ccb782..0000000 --- a/ProxySU_Core/App.xaml.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Configuration; -using System.Data; -using System.Linq; -using System.Threading.Tasks; -using System.Windows; - -namespace ProxySU_Core -{ - /// - /// Interaction logic for App.xaml - /// - public partial class App : Application - { - } -} diff --git a/ProxySU_Core/AssemblyInfo.cs b/ProxySU_Core/AssemblyInfo.cs deleted file mode 100644 index 8b5504e..0000000 --- a/ProxySU_Core/AssemblyInfo.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Windows; - -[assembly: ThemeInfo( - ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located - //(used if a resource is not found in the page, - // or application resource dictionaries) - ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located - //(used if a resource is not found in the page, - // app, or any theme specific resource dictionaries) -)] diff --git a/ProxySU_Core/Common/Base64.cs b/ProxySU_Core/Common/Base64.cs deleted file mode 100644 index 0a61841..0000000 --- a/ProxySU_Core/Common/Base64.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ProxySU_Core.Common -{ - public class Base64 - { - public static string Encode(string plainText) - { - var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(plainText); - return System.Convert.ToBase64String(plainTextBytes); - } - - public static string Decode(string base64EncodedData) - { - var base64EncodedBytes = System.Convert.FromBase64String(base64EncodedData); - return System.Text.Encoding.UTF8.GetString(base64EncodedBytes); - } - } -} diff --git a/ProxySU_Core/Converters/LoginSecretTypeConverter.cs b/ProxySU_Core/Converters/LoginSecretTypeConverter.cs deleted file mode 100644 index be26ed8..0000000 --- a/ProxySU_Core/Converters/LoginSecretTypeConverter.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Text; -using System.Windows.Data; - -namespace ProxySU_Core.Converters -{ - public class LoginSecretTypeConverter : IValueConverter - { - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) - { - return value != null && value.Equals(parameter); - } - - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) - { - if (value == null) - { - return Binding.DoNothing; - } - - if (!value.Equals(true)) - { - return Binding.DoNothing; - } - - return parameter; - - } - } -} diff --git a/ProxySU_Core/Converters/ProxyTypeConverter.cs b/ProxySU_Core/Converters/ProxyTypeConverter.cs deleted file mode 100644 index 771cb62..0000000 --- a/ProxySU_Core/Converters/ProxyTypeConverter.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Text; -using System.Windows.Data; - -namespace ProxySU_Core.Converters -{ - public class ProxyTypeConverter : IValueConverter - { - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) - { - return value != null && value.Equals(parameter); - } - - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) - { - if (value == null) - { - return Binding.DoNothing; - } - - if (!value.Equals(true)) - { - return Binding.DoNothing; - } - - return parameter; - } - } -} diff --git a/ProxySU_Core/Converters/VisibleConverter.cs b/ProxySU_Core/Converters/VisibleConverter.cs deleted file mode 100644 index f52a08d..0000000 --- a/ProxySU_Core/Converters/VisibleConverter.cs +++ /dev/null @@ -1,34 +0,0 @@ -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/AppSettings.cs b/ProxySU_Core/Models/AppSettings.cs deleted file mode 100644 index 0b42488..0000000 --- a/ProxySU_Core/Models/AppSettings.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ProxySU_Core.Models -{ - public class AppSettings - { - public string Language { get; set; } - } -} diff --git a/ProxySU_Core/Models/Developers/IParameters.cs b/ProxySU_Core/Models/Developers/IParameters.cs deleted file mode 100644 index f80f33a..0000000 --- a/ProxySU_Core/Models/Developers/IParameters.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace ProxySU_Core.Models.Developers -{ - public interface IParameters - { - int Port { get; set; } - - string Domain { get; set; } - - List FreePorts { get; } - } -} diff --git a/ProxySU_Core/Models/Developers/Project.cs b/ProxySU_Core/Models/Developers/Project.cs deleted file mode 100644 index 5aaa233..0000000 --- a/ProxySU_Core/Models/Developers/Project.cs +++ /dev/null @@ -1,740 +0,0 @@ -using ProxySU_Core.Tools; -using ProxySU_Core.ViewModels; -using Renci.SshNet; -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; - -namespace ProxySU_Core.Models.Developers -{ - public enum CmdType - { - None, - Apt, - Dnf, - Yum - } - - public abstract class Project : BaseViewModel where TParameters : IParameters - { - private SshClient _sshClient; - - protected Action WriteOutput; - - protected CmdType CmdType { get; set; } - - protected bool IsSELinux { get; set; } - - protected bool OnlyIpv6 { get; set; } - - protected string IPv4 { get; set; } - - protected string IPv6 { get; set; } - - protected TParameters Parameters { get; set; } - - public Project(SshClient sshClient, TParameters parameters, Action writeOutput) - { - _sshClient = sshClient; - WriteOutput = writeOutput; - Parameters = parameters; - } - - protected string RunCmd(string cmdStr) - { - var cmd = _sshClient.CreateCommand(cmdStr); - WriteOutput(cmdStr); - - var result = cmd.Execute(); - WriteOutput(result); - return result; - } - - /// - /// 执行安装命令 - /// - public abstract void Install(); - - /// - /// 配置系统基础环境 - /// - protected void EnsureSystemEnv() - { - string cmd; - - // 确认安装命令 - if (CmdType == CmdType.None) - { - cmd = RunCmd("command -v apt-get"); - if (!string.IsNullOrEmpty(cmd)) - { - CmdType = CmdType.Apt; - } - } - - if (CmdType == CmdType.None) - { - cmd = RunCmd("command -v dnf"); - if (!string.IsNullOrEmpty(cmd)) - { - CmdType = CmdType.Dnf; - } - } - - if (CmdType == CmdType.None) - { - cmd = RunCmd("command -v yum"); - if (!string.IsNullOrEmpty(cmd)) - { - CmdType = CmdType.Yum; - } - } - - // systemctl - cmd = RunCmd("command -v systemctl"); - var hasSystemCtl = !string.IsNullOrEmpty(cmd); - - // SELinux - cmd = RunCmd("command -v getenforce"); - IsSELinux = !string.IsNullOrEmpty(cmd); - - if (CmdType == CmdType.None || !hasSystemCtl) - { - throw new Exception("系统缺乏必要的安装组件如:apt-get||dnf||yum||Syetemd,主机系统推荐使用:CentOS 7/8,Debian 8/9/10,Ubuntu 16.04及以上版本"); - } - - - // 判断是否启用了SELinux,如果启用了,并且工作在Enforcing模式下,则改为Permissive模式 - if (IsSELinux) - { - cmd = RunCmd("getenforce"); - - // 检测到系统启用SELinux,且工作在严格模式下,需改为宽松模式 - if (cmd.Contains("Enforcing")) - { - RunCmd("setenforce 0"); - RunCmd(@"sed -i 's/SELINUX=enforcing/SELINUX=permissive/' /etc/selinux/config"); - } - } - } - - /// - /// 确保Root账户登陆 - /// - protected void EnsureRootAuth() - { - // 禁止一些可能产生的干扰信息 - RunCmd(@"sed -i 's/echo/#echo/g' ~/.bashrc"); - RunCmd(@"sed -i 's/echo/#echo/g' ~/.profile"); - - - // 检测是否运行在Root权限下 - var cmd = RunCmd("id -u"); - if (!cmd.Equals("0\n")) - { - throw new Exception("请使用Root账户登陆主机"); - } - } - - /// - /// 配置IPV6环境 - /// - protected void ConfigureIPv6() - { - if (IsOnlyIpv6()) - { - SetNat64(); - } - } - - /// - /// 配置必要的软件 - /// - protected void ConfigureSoftware() - { - string cmd = RunCmd("command -v sudo"); - if (string.IsNullOrEmpty(cmd)) - { - RunCmd(GetInstallCmd("sudo")); - } - - // 安装curl,wget,unzip - cmd = RunCmd("command -v curl"); - if (string.IsNullOrEmpty(cmd)) - { - RunCmd(GetInstallCmd("curl")); - } - - cmd = RunCmd("command -v wget"); - if (string.IsNullOrEmpty(cmd)) - { - RunCmd(GetInstallCmd("wget")); - } - - cmd = RunCmd("command -v unzip"); - if (string.IsNullOrEmpty(cmd)) - { - RunCmd(GetInstallCmd("unzip")); - } - - // 安装dig - cmd = RunCmd("command -v dig"); - if (string.IsNullOrEmpty(cmd)) - { - if (CmdType == CmdType.Apt) - { - RunCmd(GetUpdateCmd()); - RunCmd(GetInstallCmd("dnsutils")); - } - else if (CmdType == CmdType.Dnf) - { - RunCmd(GetUpdateCmd()); - RunCmd(GetInstallCmd("bind-utils")); - } - else if (CmdType == CmdType.Yum) - { - RunCmd(GetUpdateCmd()); - RunCmd(GetInstallCmd("bind-utils")); - } - } - - - // 处理极其少见的xz-utils未安装的情况 - if (CmdType == CmdType.Apt) - { - RunCmd(GetInstallCmd("xz-utils")); - } - else - { - RunCmd(GetInstallCmd("xz-devel")); - } - - // 检测是否安装lsof - cmd = RunCmd("command -v lsof"); - if (string.IsNullOrEmpty(cmd)) - { - RunCmd(GetInstallCmd("lsof")); - } - } - - protected void ClosePort(params int[] portList) - { - string cmd; - - cmd = RunCmd("command -v firewall-cmd"); - if (!string.IsNullOrEmpty(cmd)) - { - //有很奇怪的vps主机,在firewalld未运行时,端口是关闭的,无法访问。所以要先启动firewalld - //用于保证acme.sh申请证书成功 - cmd = RunCmd("firewall-cmd --state"); - if (cmd.Trim() != "running") - { - RunCmd("systemctl restart firewalld"); - } - - foreach (var port in portList) - { - RunCmd($"firewall-cmd --zone=public --remove-port={port}/tcp --permanent"); - RunCmd($"firewall-cmd --zone=public --remove-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 delete allow {port}/tcp"); - RunCmd($"ufw delete allow {port}/udp"); - } - RunCmd("yes | ufw reload"); - } - } - } - - protected void OpenPort(params int[] portList) - { - - string cmd; - - cmd = RunCmd("command -v firewall-cmd"); - if (!string.IsNullOrEmpty(cmd)) - { - //有很奇怪的vps主机,在firewalld未运行时,端口是关闭的,无法访问。所以要先启动firewalld - //用于保证acme.sh申请证书成功 - cmd = RunCmd("firewall-cmd --state"); - if (cmd.Trim() != "running") - { - RunCmd("systemctl restart firewalld"); - } - - foreach (var port in portList) - { - 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); - portList.AddRange(Parameters.FreePorts); - - OpenPort(portList.ToArray()); - } - - /// - /// 配置同步时间差 - /// - protected void SyncTimeDiff() - { - RunCmd("rm -f /etc/localtime"); - RunCmd("ln -s /usr/share/zoneinfo/UTC /etc/localtime"); - - var result = RunCmd("date +%s"); - var vpsSeconds = Convert.ToInt64(result); - var localSeconds = (int)(DateTime.Now.ToUniversalTime() - DateTime.Parse("1970-01-01")).TotalSeconds; - - if (Math.Abs(vpsSeconds - localSeconds) >= 90) - { - // 同步本地时间 - var netUtcTime = DateTimeUtils.GetUTCTime(); - DateTimeUtils.SetDate(netUtcTime.ToLocalTime()); - - // 同步VPS时间 - var utcTS = DateTimeUtils.GetUTCTime() - new DateTime(1970, 1, 1, 0, 0, 0, 0); - long timeStampVPS = Convert.ToInt64(utcTS.TotalSeconds); - RunCmd($"date --set=\"$(date \"+%Y-%m-%d %H:%M:%S\" -d @{timeStampVPS.ToString()})\""); - } - } - - /// - /// 验证域名是否绑定了主机 - /// - protected void ValidateDomain() - { - if (OnlyIpv6) - { - string cmdFilter = @"| grep -oE '(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))' | head -n 1"; - var cmd = $"dig @resolver1.opendns.com AAAA {Parameters.Domain} +short -6 {cmdFilter}"; - var result = RunCmd(cmd).TrimEnd('\r', '\n'); - - if (result == IPv6) return; - } - - else - { - string cmdFilter = @"| grep -oE '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | head -n 1"; - var cmd = $"dig @resolver1.opendns.com A {Parameters.Domain} +short -4 {cmdFilter}"; - var result = RunCmd(cmd).TrimEnd('\r', '\n'); - - if (result == IPv4) return; - - } - - - var btnResult = MessageBox.Show( - $"{Parameters.Domain}未能正常解析到服务器的IP,如果您使用了CDN请忽略,是否继续安装?", "提示", MessageBoxButton.YesNo); - - if (btnResult == MessageBoxResult.No) - { - throw new Exception($"域名解析失败,安装停止!"); - } - - } - - /// - /// 判断是否安装某个软件 - /// - /// - /// - protected bool FileExists(string path) - { - var cmdStr = $"if [[ -f {path} ]];then echo '1';else echo '0'; fi"; - var cmd = RunCmd(cmdStr); - return cmd.Trim() == "1"; - } - - /// - /// 安装 Caddy - /// - protected void InstallCaddy() - { - RunCmd("rm -rf caddy_install.sh"); - RunCmd("curl -o caddy_install.sh https://raw.githubusercontent.com/proxysu/shellscript/master/Caddy-Naive/caddy-naive-install.sh"); - RunCmd("yes | bash caddy_install.sh"); - RunCmd("rm -rf caddy_install.sh"); - RunCmd("systemctl enable caddy.service"); - } - - /// - /// 卸载 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"); - } - - - #region 检测系统环境 - - private bool IsOnlyIpv6() - { - string cmd; - - cmd = RunCmd(@"curl -s https://api.ip.sb/ip --ipv4 --max-time 8"); - IPv4 = cmd.TrimEnd('\r', '\n'); - - if (!string.IsNullOrEmpty(IPv4)) - { - OnlyIpv6 = false; - return false; - } - - cmd = RunCmd(@"curl -s https://api.ip.sb/ip --ipv6 --max-time 8"); - IPv6 = cmd.TrimEnd('\r', '\n'); - - if (string.IsNullOrEmpty(IPv6)) - { - throw new Exception("未检测可用的的IP地址"); - } - - OnlyIpv6 = true; - return OnlyIpv6; - } - - private bool SetPortFree(int port, bool force = true) - { - string result = RunCmd($"lsof -n -P -i :{port} | grep LISTEN"); - - if (!string.IsNullOrEmpty(result)) - { - if (force) - { - var btnResult = MessageBox.Show($"{port}端口被占用,将强制停止占用{port}端口的程序?", "提示", MessageBoxButton.YesNo); - if (btnResult == MessageBoxResult.No) - { - throw new Exception($"{port}端口被占用,安装停止!"); - } - - string[] process = result.Split(' '); - RunCmd($"systemctl stop {process[0]}"); - RunCmd($"systemctl disable {process[0]}"); - RunCmd($"pkill {process[0]}"); - return SetPortFree(port, force: false); - } - else - { - return false; - } - } - - return true; - } - - public void ConfigurePort() - { - if (Parameters.Port == 80 || Parameters.Port == 443) - { - SetPortFree(80); - SetPortFree(443); - } - else - { - SetPortFree(80); - SetPortFree(443); - SetPortFree(Parameters.Port); - - Parameters.FreePorts.ForEach(port => - { - SetPortFree(port); - }); - } - } - - protected void SetNat64() - { - var dns64List = FilterFastestIP(); - if (dns64List.Count == 0) - { - throw new Exception("未找到有效的Nat64网关"); - } - - var exists = FileExists("/etc/resolv.conf.proxysu"); - if (!exists) - { - var cmdStr = @"mv /etc/resolv.conf /etc/resolv.conf.proxysu"; - RunCmd(cmdStr); - } - - foreach (var gateip in dns64List) - { - RunCmd($"echo \"nameserver {gateip}\" > /etc/resolv.conf"); - } - } - - protected void RemoveNat64() - { - RunCmd("rm /etc/resolv.conf"); - RunCmd("mv /etc/resolv.conf.proxysu /etc/resolv.conf"); - } - - private List FilterFastestIP() - { - string[] gateNat64 = { - "2a01:4f9:c010:3f02::1", - "2001:67c:2b0::4", - "2001:67c:2b0::6", - "2a09:11c0:f1:bbf0::70", - "2a01:4f8:c2c:123f::1", - "2001:67c:27e4:15::6411", - "2001:67c:27e4::64", - "2001:67c:27e4:15::64", - "2001:67c:27e4::60", - "2a00:1098:2b::1", - "2a03:7900:2:0:31:3:104:161", - "2a00:1098:2c::1", - "2a09:11c0:100::53", - }; - - Dictionary dns64List = new Dictionary(); - foreach (var gateip in gateNat64) - { - var cmdStr = $"ping6 -c4 {gateip} | grep avg | awk '{{print $4}}'|cut -d/ -f2"; - var cmd = RunCmd(cmdStr); - if (!string.IsNullOrEmpty(cmd)) - { - if (float.TryParse(cmd, out float delay)) - { - dns64List.Add(gateip, delay); - } - } - } - - return dns64List.Keys.ToList(); - } - - #endregion - - - #region BBR - private bool CheckKernelVersionBBR(string kernelVer) - { - string[] linuxKernelCompared = kernelVer.Split('.'); - if (int.Parse(linuxKernelCompared[0]) > 4) - { - return true; - } - else if (int.Parse(linuxKernelCompared[0]) < 4) - { - return false; - } - else if (int.Parse(linuxKernelCompared[0]) == 4) - { - if (int.Parse(linuxKernelCompared[1]) >= 9) - { - return true; - } - else if (int.Parse(linuxKernelCompared[1]) < 9) - { - return false; - } - - } - return false; - - } - - protected void EnableBBR() - { - var osVersion = RunCmd("uname -r"); - var canInstallBBR = CheckKernelVersionBBR(osVersion.Split('-')[0]); - - var bbrInfo = RunCmd("sysctl net.ipv4.tcp_congestion_control | grep bbr"); - var installed = bbrInfo.Contains("bbr"); - if (canInstallBBR && !installed) - { - RunCmd(@"bash -c 'echo ""net.core.default_qdisc=fq"" >> /etc/sysctl.conf'"); - RunCmd(@"bash -c 'echo ""net.ipv4.tcp_congestion_control=bbr"" >> /etc/sysctl.conf'"); - RunCmd(@"sysctl -p"); - - if (OnlyIpv6) - { - RemoveNat64(); - } - WriteOutput("BBR启动成功"); - } - - if (!canInstallBBR) - { - WriteOutput("****** 系统不满足启用BBR条件,启动失败。 ******"); - } - - } - #endregion - - /// - /// 安装证书 - /// - /// - /// - protected void InstallCert(string dirPath, string certName, string keyName) - { - string certPath = Path.Combine(dirPath, certName); - string keyPath = Path.Combine(dirPath, keyName); - - // 安装依赖 - RunCmd(GetInstallCmd("socat")); - - // 解决搬瓦工CentOS缺少问题 - RunCmd(GetInstallCmd("automake autoconf libtool")); - - // 安装Acme - var result = RunCmd($"curl https://get.acme.sh yes | sh"); - if (result.Contains("Install success")) - { - WriteOutput("安装 acme.sh 成功"); - } - else - { - WriteOutput("安装 acme.sh 失败,请联系开发者!"); - throw new Exception("安装 acme.sh 失败,请联系开发者!"); - } - - RunCmd("cd ~/.acme.sh/"); - RunCmd("alias acme.sh=~/.acme.sh/acme.sh"); - - // 申请证书 - if (OnlyIpv6) - { - var cmd = $"/root/.acme.sh/acme.sh --force --debug --issue --standalone -d {Parameters.Domain} --listen-v6"; - result = RunCmd(cmd); - } - else - { - var cmd = $"/root/.acme.sh/acme.sh --force --debug --issue --standalone -d {Parameters.Domain}"; - result = RunCmd(cmd); - } - - if (result.Contains("success")) - { - WriteOutput("申请证书成功"); - } - else - { - WriteOutput("申请证书失败,如果申请次数过多请更换二级域名,或联系开发者!"); - throw new Exception("申请证书失败,如果申请次数过多请更换二级域名,或联系开发者!"); - } - - // 安装证书 - RunCmd($"mkdir -p {dirPath}"); - RunCmd($"/root/.acme.sh/acme.sh --installcert -d {Parameters.Domain} --certpath {certPath} --keypath {keyPath} --capath {certPath}"); - - result = RunCmd($@"if [ ! -f ""{keyPath}"" ]; then echo ""0""; else echo ""1""; fi | head -n 1"); - - if (result.Contains("1")) - { - WriteOutput("安装证书成功"); - } - else - { - WriteOutput("安装证书失败,请联系开发者!"); - throw new Exception("安装证书失败,请联系开发者!"); - } - - RunCmd($"chmod 755 {dirPath}"); - } - - /// - /// 上传文件 - /// - /// - /// - protected void UploadFile(Stream stream, string path) - { - using (var sftp = new SftpClient(_sshClient.ConnectionInfo)) - { - sftp.Connect(); - sftp.UploadFile(stream, path, true); - sftp.Disconnect(); - } - } - - /// - /// 根据系统环境匹配更新命令 - /// - /// - protected string GetUpdateCmd() - { - if (CmdType == CmdType.Apt) - { - return "apt-get update"; - } - else if (CmdType == CmdType.Dnf) - { - return "dnf clean all;dnf makecache"; - } - else if (CmdType == CmdType.Yum) - { - return "yum clean all;yum makecache"; - } - - throw new Exception("未识别的系统"); - } - - /// - /// 根据系统匹配安装命令 - /// - /// - /// - protected string GetInstallCmd(string soft) - { - if (CmdType == CmdType.Apt) - { - return "echo y | apt-get install " + soft; - } - else if (CmdType == CmdType.Dnf) - { - return "echo y | dnf -y install " + soft; - } - else if (CmdType == CmdType.Yum) - { - return "echo y | yum -y install " + soft; - } - - throw new Exception("未识别的系统"); - } - - } -} diff --git a/ProxySU_Core/Models/Developers/TrojanGoConfigBuilder.cs b/ProxySU_Core/Models/Developers/TrojanGoConfigBuilder.cs deleted file mode 100644 index c02a9d0..0000000 --- a/ProxySU_Core/Models/Developers/TrojanGoConfigBuilder.cs +++ /dev/null @@ -1,63 +0,0 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ProxySU_Core.Models.Developers -{ - public class TrojanGoConfigBuilder - { - public static readonly int WebPort = 8088; - - public static readonly string TrojanGoSettingPath = @"Templates\trojan-go\trojan-go.json"; - - public static readonly string CaddyFilePath = @"Templates\trojan-go\base.caddyfile"; - - public static string BuildTrojanGoConfig(TrojanGoSettings parameters) - { - var jsonStr = File.ReadAllText(TrojanGoSettingPath); - var settings = JToken.FromObject(JsonConvert.DeserializeObject(jsonStr)); - - settings["remote_port"] = WebPort; - settings["password"][0] = parameters.Password; - settings["ssl"]["sni"] = parameters.Domain; - - return JsonConvert.SerializeObject(settings, Formatting.Indented, new JsonSerializerSettings() - { - NullValueHandling = NullValueHandling.Ignore - }); - } - - public static string BuildCaddyConfig(TrojanGoSettings parameters, bool useCustomWeb = false) - { - var caddyStr = File.ReadAllText(CaddyFilePath); - caddyStr.Replace("##domain##", parameters.Domain); - caddyStr.Replace("##port##", WebPort.ToString()); - - if (!useCustomWeb && !string.IsNullOrEmpty(parameters.MaskDomain)) - { - var prefix = "http://"; - if (parameters.MaskDomain.StartsWith("https://")) - { - prefix = "https://"; - } - var domain = parameters.MaskDomain - .TrimStart("http://".ToCharArray()) - .TrimStart("https://".ToCharArray()); - - caddyStr = caddyStr.Replace("##reverse_proxy##", $"reverse_proxy {prefix}{domain} {{ \n header_up Host {domain} \n }}"); - } - else - { - caddyStr = caddyStr.Replace("##reverse_proxy##", ""); - } - - return caddyStr; - } - } - -} diff --git a/ProxySU_Core/Models/Developers/TrojanGoProject.cs b/ProxySU_Core/Models/Developers/TrojanGoProject.cs deleted file mode 100644 index bf6cf19..0000000 --- a/ProxySU_Core/Models/Developers/TrojanGoProject.cs +++ /dev/null @@ -1,135 +0,0 @@ -using Renci.SshNet; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; - -namespace ProxySU_Core.Models.Developers -{ - public class TrojanGoProject : Project - { - public TrojanGoProject(SshClient sshClient, TrojanGoSettings parameters, Action writeOutput) : base(sshClient, parameters, writeOutput) - { - } - - public override void Install() - { - try - { - EnsureRootAuth(); - - if (FileExists("/usr/local/bin/xray")) - { - var btnResult = MessageBox.Show("已经安装Xray,是否需要重装?", "提示", MessageBoxButton.YesNo); - if (btnResult == MessageBoxResult.No) - { - MessageBox.Show("安装终止", "提示"); - return; - } - } - - WriteOutput("检测安装系统环境..."); - EnsureSystemEnv(); - WriteOutput("检测安装系统环境完成"); - - WriteOutput("配置服务器端口..."); - ConfigurePort(); - WriteOutput("端口配置完成"); - - WriteOutput("安装必要的系统工具..."); - ConfigureSoftware(); - WriteOutput("系统工具安装完成"); - - WriteOutput("检测IP6..."); - ConfigureIPv6(); - WriteOutput("检测IP6完成"); - - WriteOutput("配置防火墙..."); - ConfigureFirewall(); - WriteOutput("防火墙配置完成"); - - WriteOutput("同步系统和本地时间..."); - SyncTimeDiff(); - WriteOutput("时间同步完成"); - - WriteOutput("检测域名是否绑定本机IP..."); - ValidateDomain(); - WriteOutput("域名检测完成"); - - WriteOutput("安装Trojan-Go..."); - InstallTrojanGo(); - WriteOutput("Trojan-Go安装完成"); - - WriteOutput("安装Caddy..."); - InstallCaddy(); - WriteOutput("Caddy安装完成"); - - WriteOutput("启动BBR"); - EnableBBR(); - - UploadCaddyFile(); - WriteOutput("************"); - WriteOutput("安装完成,尽情享用吧......"); - WriteOutput("************"); - } - catch (Exception ex) - { - var errorLog = "安装终止," + ex.Message; - WriteOutput(errorLog); - MessageBox.Show(errorLog); - } - } - - private void InstallTrojanGo() - { - WriteOutput("安装Trojan-Go"); - RunCmd(@"curl https://raw.githubusercontent.com/proxysu/shellscript/master/trojan-go.sh yes | bash"); - var success = FileExists("/usr/local/etc/trojan-go"); - if (success == false) - { - throw new Exception("trojan-go 安装失败,请联系开发者!"); - } - - RunCmd($"sed -i 's/User=nobody/User=root/g' /etc/systemd/system/xray.service"); - RunCmd($"sed -i 's/CapabilityBoundingSet=/#CapabilityBoundingSet=/g' /etc/systemd/system/xray.service"); - RunCmd($"sed -i 's/AmbientCapabilities=/#AmbientCapabilities=/g' /etc/systemd/system/xray.service"); - RunCmd($"systemctl daemon-reload"); - - RunCmd("systemctl enable trojan-go"); - RunCmd("systemctl start trojan-go"); - WriteOutput("Trojan-Go 安装完成"); - - InstallCert( - dirPath: "/usr/local/etc/trojan-go", - certName: "trojan-go.crt", - keyName: "trojan-go.key"); - - if (FileExists("/usr/local/etc/trojan-go/config.json")) - { - RunCmd("mv /usr/local/etc/trojan-go/config.json config.json.old"); - } - - // 上传配置 - var settings = TrojanGoConfigBuilder.BuildTrojanGoConfig(Parameters); - var stream = new MemoryStream(Encoding.UTF8.GetBytes(settings)); - UploadFile(stream, "/usr/local/etc/trojan-go/config.json"); - RunCmd("systemctl restart trojan-go"); - } - - private void UploadCaddyFile(bool useCustomWeb = false) - { - var config = TrojanGoConfigBuilder.BuildCaddyConfig(Parameters, useCustomWeb); - var stream = new MemoryStream(Encoding.UTF8.GetBytes(config)); - if (FileExists("/etc/caddy/Caddyfile")) - { - RunCmd("mv /etc/caddy/Caddyfile /etc/caddy/Caddyfile.back"); - } - UploadFile(stream, "/etc/caddy/Caddyfile"); - RunCmd("systemctl restart caddy"); - } - } - -} diff --git a/ProxySU_Core/Models/Developers/TrojanGoSettings.cs b/ProxySU_Core/Models/Developers/TrojanGoSettings.cs deleted file mode 100644 index 6dd2102..0000000 --- a/ProxySU_Core/Models/Developers/TrojanGoSettings.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ProxySU_Core.Models.Developers -{ - public class TrojanGoSettings : IParameters - { - public int Port { get; set; } - - public List FreePorts - { - get - { - return new List(); - } - } - - public string Domain { get; set; } - - public List Types { get; set; } - - public string Password { get; set; } - - public string MaskDomain { get; set; } - } -} diff --git a/ProxySU_Core/Models/Developers/XrayConfigBuilder.cs b/ProxySU_Core/Models/Developers/XrayConfigBuilder.cs deleted file mode 100644 index d7eb4be..0000000 --- a/ProxySU_Core/Models/Developers/XrayConfigBuilder.cs +++ /dev/null @@ -1,232 +0,0 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using ProxySU_Core.Models; -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; - -namespace ProxySU_Core.Models.Developers -{ - public class XrayConfigBuilder - { - private const string ServerLogDir = @"Templates\xray\server\00_log"; - private const string ServerApiDir = @"Templates\xray\server\01_api"; - private const string ServerDnsDir = @"Templates\xray\server\02_dns"; - private const string ServerRoutingDir = @"Templates\xray\server\03_routing"; - private const string ServerPolicyDir = @"Templates\xray\server\04_policy"; - private const string ServerInboundsDir = @"Templates\xray\server\05_inbounds"; - private const string ServerOutboundsDir = @"Templates\xray\server\06_outbounds"; - private const string ServerTransportDir = @"Templates\xray\server\07_transport"; - private const string ServerStatsDir = @"Templates\xray\server\08_stats"; - private const string ServerReverseDir = @"Templates\xray\server\09_reverse"; - private const string CaddyFileDir = @"Templates\xray\caddy"; - - public static int VLESS_TCP_Port = 1110; - public static int VLESS_WS_Port = 1111; - public static int VLESS_H2_Port = 1112; - public static int VLESS_mKCP_Port = 1113; - - public static int VMESS_TCP_Port = 1210; - public static int VMESS_WS_Port = 1211; - public static int VMESS_H2_Port = 1212; - - public static int Trojan_TCP_Port = 1310; - public static int Trojan_WS_Port = 1311; - - public static int FullbackPort = 8080; - - - - public static dynamic LoadXrayConfig() - { - dynamic logObj = LoadJsonObj(Path.Combine(ServerLogDir, "00_log.json")); - dynamic apiObj = LoadJsonObj(Path.Combine(ServerApiDir, "01_api.json")); - dynamic dnsObj = LoadJsonObj(Path.Combine(ServerDnsDir, "02_dns.json")); - dynamic routingObj = LoadJsonObj(Path.Combine(ServerRoutingDir, "03_routing.json")); - dynamic policyObj = LoadJsonObj(Path.Combine(ServerPolicyDir, "04_policy.json")); - dynamic inboundsObj = LoadJsonObj(Path.Combine(ServerInboundsDir, "05_inbounds.json")); - dynamic outboundsObj = LoadJsonObj(Path.Combine(ServerOutboundsDir, "06_outbounds.json")); - dynamic transportObj = LoadJsonObj(Path.Combine(ServerTransportDir, "07_transport.json")); - dynamic statsObj = LoadJsonObj(Path.Combine(ServerStatsDir, "08_stats.json")); - dynamic reverseObj = LoadJsonObj(Path.Combine(ServerReverseDir, "09_reverse.json")); - - return new - { - log = logObj["log"], - //api = apiObj["api"], api不能为空 - dns = dnsObj["dns"], - routing = routingObj["routing"], - policy = policyObj["policy"], - inbounds = inboundsObj["inbounds"], - outbounds = outboundsObj["outbounds"], - transport = transportObj["transport"], - stats = statsObj["stats"], - reverse = reverseObj["reverse"] - }; - } - - public static string BuildCaddyConfig(XraySettings parameters, bool useCustomWeb = false) - { - var caddyStr = File.ReadAllText(Path.Combine(CaddyFileDir, "base.caddyfile")); - caddyStr = caddyStr.Replace("##domain##", parameters.Domain); - caddyStr = caddyStr.Replace("##port##", FullbackPort.ToString()); - - if (!useCustomWeb && !string.IsNullOrEmpty(parameters.MaskDomain)) - { - var prefix = "http://"; - if (parameters.MaskDomain.StartsWith("https://")) - { - prefix = "https://"; - } - var domain = parameters.MaskDomain - .TrimStart("http://".ToCharArray()) - .TrimStart("https://".ToCharArray()); - - caddyStr = caddyStr.Replace("##reverse_proxy##", $"reverse_proxy {prefix}{domain} {{ \n header_up Host {domain} \n }}"); - } - else - { - caddyStr = caddyStr.Replace("##reverse_proxy##", ""); - } - - return caddyStr; - } - - public static string BuildXrayConfig(XraySettings parameters) - { - var xrayConfig = LoadXrayConfig(); - var baseBound = GetBound("VLESS_TCP_XTLS.json"); - baseBound.port = parameters.Port; - baseBound.settings.fallbacks.Add(JToken.FromObject(new - { - dest = FullbackPort - })); - xrayConfig.inbounds.Add(baseBound); - baseBound.settings.clients[0].id = parameters.UUID; - - if (parameters.Types.Contains(XrayType.VLESS_WS)) - { - 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, - xver = 1, - })); - xrayConfig.inbounds.Add(JToken.FromObject(wsInbound)); - } - - if (parameters.Types.Contains(XrayType.VLESS_gRPC)) - { - var gRPCInBound = GetBound("VLESS_gRPC.json"); - gRPCInBound.port = parameters.VLESS_gRPC_Port; - gRPCInBound.settings.clients[0].id = parameters.UUID; - gRPCInBound.streamSettings.grpcSettings.serviceName = parameters.VLESS_gRPC_ServiceName; - xrayConfig.inbounds.Add(JToken.FromObject(gRPCInBound)); - } - - if (parameters.Types.Contains(XrayType.VLESS_KCP)) - { - var kcpBound = GetBound("VLESS_KCP.json"); - kcpBound.port = parameters.VLESS_KCP_Port; - kcpBound.settings.clients[0].id = parameters.UUID; - kcpBound.streamSettings.kcpSettings.header.type = parameters.VLESS_KCP_Type; - kcpBound.streamSettings.kcpSettings.seed = parameters.VLESS_KCP_Seed; - xrayConfig.inbounds.Add(JToken.FromObject(kcpBound)); - } - - if (parameters.Types.Contains(XrayType.VMESS_TCP)) - { - 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; - baseBound.settings.fallbacks.Add(JToken.FromObject(new - { - dest = VMESS_TCP_Port, - path = parameters.VMESS_TCP_Path, - xver = 1, - })); - xrayConfig.inbounds.Add(JToken.FromObject(mtcpBound)); - } - - if (parameters.Types.Contains(XrayType.VMESS_WS)) - { - 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; - baseBound.settings.fallbacks.Add(JToken.FromObject(new - { - dest = VMESS_WS_Port, - path = parameters.VMESS_WS_Path, - xver = 1, - })); - xrayConfig.inbounds.Add(JToken.FromObject(mwsBound)); - } - - if (parameters.Types.Contains(XrayType.VMESS_KCP)) - { - var kcpBound = GetBound("VMESS_KCP.json"); - kcpBound.port = parameters.VMESS_KCP_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.Trojan_TCP)) - { - var trojanTcpBound = GetBound("Trojan_TCP.json"); - trojanTcpBound.port = Trojan_TCP_Port; - trojanTcpBound.settings.clients[0].password = parameters.TrojanPassword; - trojanTcpBound.settings.fallbacks[0].dest = FullbackPort; - baseBound.settings.fallbacks[0] = JToken.FromObject(new - { - dest = Trojan_TCP_Port, - xver = 1, - }); - xrayConfig.inbounds.Add(JToken.FromObject(trojanTcpBound)); - } - - - if (parameters.Types.Contains(XrayType.ShadowsocksAEAD)) - { - var ssBound = GetBound("Shadowsocks-AEAD.json"); - ssBound.port = parameters.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, - Formatting.Indented, - new JsonSerializerSettings() - { - NullValueHandling = NullValueHandling.Ignore - }); - } - - private static dynamic GetBound(string name) - { - return LoadJsonObj(Path.Combine(ServerInboundsDir, name)); - } - - private static dynamic LoadJsonObj(string path) - { - if (File.Exists(path)) - { - var jsonStr = File.ReadAllText(path, Encoding.UTF8); - return JToken.FromObject(JsonConvert.DeserializeObject(jsonStr)); - } - return null; - } - - } - -} diff --git a/ProxySU_Core/Models/Developers/XrayProject.cs b/ProxySU_Core/Models/Developers/XrayProject.cs deleted file mode 100644 index f0678af..0000000 --- a/ProxySU_Core/Models/Developers/XrayProject.cs +++ /dev/null @@ -1,321 +0,0 @@ -using Renci.SshNet; -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; -using System.Windows; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using ProxySU_Core.Models; - -namespace ProxySU_Core.Models.Developers -{ - public class XrayProject : Project - { - - private const string ServerLogDir = @"Templates\xray\server\00_log"; - private const string ServerApiDir = @"Templates\xray\server\01_api"; - private const string ServerDnsDir = @"Templates\xray\server\02_dns"; - private const string ServerRoutingDir = @"Templates\xray\server\03_routing"; - private const string ServerPolicyDir = @"Templates\xray\server\04_policy"; - private const string ServerInboundsDir = @"Templates\xray\server\05_inbounds"; - private const string ServerOutboundsDir = @"Templates\xray\server\06_outbounds"; - private const string ServerTransportDir = @"Templates\xray\server\07_transport"; - private const string ServerStatsDir = @"Templates\xray\server\08_stats"; - private const string ServerReverseDir = @"Templates\xray\server\09_reverse"; - private const string CaddyFileDir = @"Templates\xray\caddy"; - - public XrayProject(SshClient sshClient, XraySettings parameters, Action writeOutput) : base(sshClient, parameters, writeOutput) - { - } - - - /// - /// 安装Xray - /// - public override void Install() - { - try - { - EnsureRootAuth(); - - if (FileExists("/usr/local/bin/xray")) - { - var btnResult = MessageBox.Show("已经安装Xray,是否需要重装?", "提示", MessageBoxButton.YesNo); - if (btnResult == MessageBoxResult.No) - { - MessageBox.Show("安装终止", "提示"); - return; - } - } - - WriteOutput("检测安装系统环境..."); - EnsureSystemEnv(); - WriteOutput("检测安装系统环境完成"); - - WriteOutput("配置服务器端口..."); - ConfigurePort(); - WriteOutput("端口配置完成"); - - WriteOutput("安装必要的系统工具..."); - ConfigureSoftware(); - WriteOutput("系统工具安装完成"); - - WriteOutput("检测IP6..."); - ConfigureIPv6(); - WriteOutput("检测IP6完成"); - - WriteOutput("配置防火墙..."); - ConfigureFirewall(); - WriteOutput("防火墙配置完成"); - - WriteOutput("同步系统和本地时间..."); - SyncTimeDiff(); - WriteOutput("时间同步完成"); - - WriteOutput("检测域名是否绑定本机IP..."); - ValidateDomain(); - WriteOutput("域名检测完成"); - - WriteOutput("安装Xray-Core..."); - InstallXrayWithCert(); - WriteOutput("Xray-Core安装完成"); - - WriteOutput("安装Caddy..."); - InstallCaddy(); - WriteOutput("Caddy安装完成"); - - WriteOutput("启动BBR"); - EnableBBR(); - - UploadCaddyFile(); - WriteOutput("************"); - WriteOutput("安装完成,尽情享用吧......"); - WriteOutput("************"); - } - catch (Exception ex) - { - var errorLog = "安装终止," + ex.Message; - WriteOutput(errorLog); - MessageBox.Show(errorLog); - } - } - - public void UninstallProxy() - { - EnsureRootAuth(); - WriteOutput("卸载Caddy"); - UninstallCaddy(); - WriteOutput("卸载Xray"); - UninstallXray(); - WriteOutput("卸载证书"); - UninstallAcme(); - WriteOutput("关闭端口"); - ClosePort(Parameters.ShadowSocksPort, Parameters.VMESS_KCP_Port); - - WriteOutput("************ 卸载完成 ************"); - } - - /// - /// 更新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(); - ConfigureFirewall(); - var configJson = XrayConfigBuilder.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"); - ConfigurePort(); - UploadCaddyFile(string.IsNullOrEmpty(Parameters.MaskDomain)); - RunCmd("systemctl restart xray"); - WriteOutput("************ 更新Xray配置成功,更新配置不包含域名,如果域名更换请重新安装。 ************"); - } - - /// - /// 重装Caddy - /// - public void DoUninstallCaddy() - { - EnsureRootAuth(); - UninstallCaddy(); - WriteOutput("************ 卸载Caddy完成 ************"); - } - - /// - /// 安装证书 - /// - public void InstallCertToXray() - { - EnsureRootAuth(); - EnsureSystemEnv(); - InstallCert( - dirPath: "/usr/local/etc/xray/ssl", - certName: "xray_ssl.crt", - keyName: "xray_ssl.key"); - - 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 = XrayConfigBuilder.BuildCaddyConfig(Parameters, useCustomWeb); - var stream = new MemoryStream(Encoding.UTF8.GetBytes(configJson)); - if (FileExists("/etc/caddy/Caddyfile")) - { - RunCmd("mv /etc/caddy/Caddyfile /etc/caddy/Caddyfile.back"); - } - UploadFile(stream, "/etc/caddy/Caddyfile"); - RunCmd("systemctl restart caddy"); - } - - - - 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安装失败,请联系开发者"); - } - - RunCmd($"sed -i 's/User=nobody/User=root/g' /etc/systemd/system/xray.service"); - RunCmd($"sed -i 's/CapabilityBoundingSet=/#CapabilityBoundingSet=/g' /etc/systemd/system/xray.service"); - RunCmd($"sed -i 's/AmbientCapabilities=/#AmbientCapabilities=/g' /etc/systemd/system/xray.service"); - RunCmd($"systemctl daemon-reload"); - - if (FileExists("/usr/local/etc/xray/config.json")) - { - RunCmd(@"mv /usr/local/etc/xray/config.json /usr/local/etc/xray/config.json.1"); - } - - WriteOutput("安装TLS证书"); - InstallCertToXray(); - WriteOutput("TLS证书安装完成"); - - - var configJson = XrayConfigBuilder.BuildXrayConfig(Parameters); - var stream = new MemoryStream(Encoding.UTF8.GetBytes(configJson)); - UploadFile(stream, "/usr/local/etc/xray/config.json"); - RunCmd("systemctl restart xray"); - } - - private int GetRandomPort() - { - var random = new Random(); - return random.Next(10001, 60000); - } - - private dynamic LoadJsonObj(string path) - { - if (File.Exists(path)) - { - var jsonStr = File.ReadAllText(path, Encoding.UTF8); - return JsonConvert.DeserializeObject(jsonStr); - } - return null; - } - - } -} diff --git a/ProxySU_Core/Models/Developers/XraySettings.cs b/ProxySU_Core/Models/Developers/XraySettings.cs deleted file mode 100644 index 0b6e274..0000000 --- a/ProxySU_Core/Models/Developers/XraySettings.cs +++ /dev/null @@ -1,220 +0,0 @@ -using Newtonsoft.Json; -using ProxySU_Core.Common; -using ProxySU_Core.Models.Developers; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Web; - -namespace ProxySU_Core.Models -{ - public class XraySettings : IParameters - { - - public XraySettings() - { - var guid = Guid.NewGuid().ToString(); - Port = 443; - VLESS_KCP_Port = 2001; - VLESS_gRPC_Port = 2002; - VMESS_KCP_Port = 3001; - ShadowSocksPort = 4001; - - UUID = guid; - Types = new List(); - - VLESS_WS_Path = "/vlessws"; - VLESS_H2_Path = "/vlessh2"; - VLESS_KCP_Type = "none"; - VLESS_KCP_Seed = guid; - VLESS_gRPC_ServiceName = "xray_gRPC"; - - 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"; - } - - /// - /// 访问端口 - /// - public int Port { get; set; } - - - /// - /// UUID - /// - public string UUID { get; set; } - - #region vless - - - /// - /// vless ws路径 - /// - public string VLESS_WS_Path { get; set; } - - /// - /// vless http2 path - /// - public string VLESS_H2_Path { get; set; } - - /// - /// vless kcp seed - /// - public string VLESS_KCP_Seed { get; set; } - - /// - /// vless kcp type - /// - public string VLESS_KCP_Type { get; set; } - - /// - /// vless kcp端口 - /// - public int VLESS_KCP_Port { get; set; } - - /// - /// grpc service name - /// - public string VLESS_gRPC_ServiceName { get; set; } - - /// - /// grpc port - /// - public int VLESS_gRPC_Port { get; set; } - - #endregion - - #region vmess - /// - /// vmess ws路径 - /// - public string VMESS_WS_Path { get; set; } - - /// - /// vmess tcp路径 - /// - public string VMESS_TCP_Path { get; set; } - - /// - /// vmess http2 path - /// - public string VMESS_H2_Path { get; set; } - - /// - /// vmess kcp seed - /// - public string VMESS_KCP_Seed { get; set; } - - /// - /// vmess kcp type - /// - public string VMESS_KCP_Type { get; set; } - - /// - /// vmess kcp端口 - /// - public int VMESS_KCP_Port { get; set; } - #endregion - - #region Trojan - /// - /// trojan密码 - /// - public string TrojanPassword { get; set; } - - /// - /// 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; } - - /// - /// ss端口 - /// - public int ShadowSocksPort { get; set; } - #endregion - - - /// - /// 域名 - /// - public string Domain { get; set; } - - /// - /// 伪装域名 - /// - public string MaskDomain { get; set; } - - /// - /// 安装类型 - /// - public List Types { get; set; } - - public List FreePorts - { - get - { - return new List - { - VLESS_gRPC_Port, - VLESS_KCP_Port, - VMESS_KCP_Port, - ShadowSocksPort, - }; - } - } - - public string GetPath(XrayType type) - { - switch (type) - { - case XrayType.VLESS_WS: - return VLESS_WS_Path; - case XrayType.VLESS_H2: - return VLESS_H2_Path; - - case XrayType.VMESS_TCP: - return VMESS_TCP_Path; - case XrayType.VMESS_WS: - return VMESS_WS_Path; - case XrayType.Trojan_WS: - return Trojan_WS_Path; - - // no path - 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; - } - } - - } - - -} diff --git a/ProxySU_Core/Models/Host.cs b/ProxySU_Core/Models/Host.cs deleted file mode 100644 index c4d3fc8..0000000 --- a/ProxySU_Core/Models/Host.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ProxySU_Core.Models -{ - public class Host - { - - - public Host() - { - Proxy = new LocalProxy(); - } - - - public string Tag { get; set; } - - public string Address { get; set; } - - public string UserName { get; set; } - - public string Password { get; set; } - - public int Port { get; set; } = 22; - - public string PrivateKeyPath { get; set; } - - public LocalProxy Proxy { get; set; } - - public LoginSecretType SecretType { get; set; } - } -} diff --git a/ProxySU_Core/Models/LocalProxy.cs b/ProxySU_Core/Models/LocalProxy.cs deleted file mode 100644 index 7e71c8b..0000000 --- a/ProxySU_Core/Models/LocalProxy.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace ProxySU_Core.Models -{ - public class LocalProxy - { - public string Address { get; set; } = "127.0.0.1"; - - public int Port { get; set; } = 1080; - - public LocalProxyType Type { get; set; } - - public string UserName { get; set; } - - public string Password { get; set; } - - } -} diff --git a/ProxySU_Core/Models/LocalProxyType.cs b/ProxySU_Core/Models/LocalProxyType.cs deleted file mode 100644 index c74da49..0000000 --- a/ProxySU_Core/Models/LocalProxyType.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace ProxySU_Core.Models -{ - public enum LocalProxyType - { - None = 0, - // - // 摘要: - // A SOCKS4 proxy server. - Socks4 = 1, - // - // 摘要: - // A SOCKS5 proxy server. - Socks5 = 2, - // - // 摘要: - // A HTTP proxy server. - Http = 3 - } -} diff --git a/ProxySU_Core/Models/LoginSecretType.cs b/ProxySU_Core/Models/LoginSecretType.cs deleted file mode 100644 index 66c2602..0000000 --- a/ProxySU_Core/Models/LoginSecretType.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace ProxySU_Core.Models -{ - public enum LoginSecretType - { - Password = 0, - PrivateKey = 1 - } -} diff --git a/ProxySU_Core/Models/Record.cs b/ProxySU_Core/Models/Record.cs deleted file mode 100644 index 091ac2f..0000000 --- a/ProxySU_Core/Models/Record.cs +++ /dev/null @@ -1,24 +0,0 @@ -using ProxySU_Core.Models; -using System; -using System.Collections.Generic; -using System.Text; - -namespace ProxySU_Core.Models -{ - public class Record - { - public Record() - { - - } - - public Record(Host host) - { - this.Host = host; - } - - public Host Host { get; set; } = new Host(); - - public XraySettings Settings { get; set; } = new XraySettings(); - } -} diff --git a/ProxySU_Core/Models/ShareLink.cs b/ProxySU_Core/Models/ShareLink.cs deleted file mode 100644 index 8c606a4..0000000 --- a/ProxySU_Core/Models/ShareLink.cs +++ /dev/null @@ -1,196 +0,0 @@ -using Newtonsoft.Json; -using ProxySU_Core.Common; -using ProxySU_Core.Models.Developers; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Web; - -namespace ProxySU_Core.Models -{ - public class ShareLink - { - public static string Build(XrayType xrayType, XraySettings settings) - { - - switch (xrayType) - { - case XrayType.VLESS_TCP: - case XrayType.VLESS_TCP_XTLS: - case XrayType.VLESS_WS: - case XrayType.VLESS_KCP: - case XrayType.VLESS_gRPC: - case XrayType.Trojan_TCP: - return BuildVlessShareLink(xrayType, settings); - 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 = settings.ShadowSocksPort; - - var base64URL = Base64.Encode($"{_method}:{_password}@{_server}:{_port}"); - return "ss://" + base64URL + "#ShadowSocks"; - } - - private static string BuildVmessShareLink(XrayType xrayType, XraySettings settings) - { - var vmess = new Vmess - { - v = "2", - add = settings.Domain, - port = settings.Port.ToString(), - id = settings.UUID, - aid = "0", - net = "", - type = "none", - host = settings.Domain, - path = "", - tls = "tls", - ps = "", - }; - - switch (xrayType) - { - 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: - 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 = settings.VMESS_KCP_Port.ToString(); - vmess.net = "kcp"; - vmess.type = settings.VMESS_KCP_Type; - vmess.path = settings.VMESS_KCP_Seed; - vmess.tls = ""; - break; - default: - return string.Empty; - } - - var base64Url = Base64.Encode(JsonConvert.SerializeObject(vmess)); - return $"vmess://" + base64Url; - } - - private static string BuildVlessShareLink(XrayType xrayType, XraySettings settings) - { - var _protocol = string.Empty; - var _uuid = settings.UUID; - var _domain = settings.Domain; - var _port = settings.Port; - var _type = string.Empty; - var _encryption = "none"; - var _security = "tls"; - var _path = "/"; - var _host = settings.Domain; - var _descriptiveText = string.Empty; - var _headerType = "none"; - var _seed = string.Empty; - - switch (xrayType) - { - case XrayType.VLESS_TCP: - _protocol = "vless"; - _type = "tcp"; - _descriptiveText = "vless-tcp-tls"; - break; - case XrayType.VLESS_TCP_XTLS: - _protocol = "vless"; - _type = "tcp"; - _security = "xtls"; - _descriptiveText = "vless-tcp-xtls"; - break; - case XrayType.VLESS_WS: - _protocol = "vless"; - _type = "ws"; - _path = settings.VLESS_WS_Path; - _descriptiveText = "vless-ws-tls"; - break; - case XrayType.VLESS_KCP: - _protocol = "vless"; - _type = "kcp"; - _headerType = settings.VLESS_KCP_Type; - _seed = settings.VLESS_KCP_Seed; - _port = settings.VLESS_KCP_Port; - _security = "none"; - _descriptiveText = "vless-mKCP"; - break; - case XrayType.VLESS_gRPC: - _protocol = "vless"; - _type = "grpc"; - _path = settings.VLESS_gRPC_ServiceName; - _descriptiveText = "vless-gRPC"; - break; - case XrayType.Trojan_TCP: - _protocol = "trojan"; - _uuid = settings.TrojanPassword; - _descriptiveText = "trojan-tcp"; - break; - default: - throw new Exception("暂未实现的协议"); - } - - - string parametersURL = string.Empty; - if (xrayType != XrayType.Trojan_TCP) - { - // 4.3 传输层相关段 - parametersURL = $"?type={_type}&encryption={_encryption}&security={_security}&path={HttpUtility.UrlEncode(_path)}&headerType={_headerType}"; - - // kcp - if (xrayType == XrayType.VLESS_KCP) - { - parametersURL += $"&seed={_seed}"; - } - - // 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)}"; - } - - } - - - - class Vmess - { - public string v { get; set; } - public string ps { get; set; } - public string add { get; set; } - public string port { get; set; } - public string id { get; set; } - public string aid { get; set; } - public string net { get; set; } - public string type { get; set; } - public string host { get; set; } - public string path { get; set; } - public string tls { get; set; } - } -} diff --git a/ProxySU_Core/Models/XrayType.cs b/ProxySU_Core/Models/XrayType.cs deleted file mode 100644 index 6611113..0000000 --- a/ProxySU_Core/Models/XrayType.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ProxySU_Core.Models -{ - public enum XrayType - { - // 入口 - VLESS_TCP_XTLS = 100, - - // VLESS 101开头 - VLESS_TCP = 101, - VLESS_WS = 102, - VLESS_H2 = 103, - VLESS_KCP = 104, - VLESS_gRPC = 110, - - // VMESS 201开头 - VMESS_TCP = 201, - VMESS_WS = 202, - VMESS_H2 = 203, - VMESS_KCP = 204, - - // Trojan 301开头 - Trojan_TCP = 301, - Trojan_WS = 302, - - // SS - ShadowsocksAEAD = 401 - } -} diff --git a/ProxySU_Core/Properties/AssemblyInfo.cs b/ProxySU_Core/Properties/AssemblyInfo.cs deleted file mode 100644 index 2107e9b..0000000 --- a/ProxySU_Core/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System.Reflection; -using System.Resources; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Windows; - -// 有关程序集的一般信息由以下 -// 控制。更改这些特性值可修改 -// 与程序集关联的信息。 -[assembly: AssemblyTitle("ProxySU_Core")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("ProxySU_Core")] -[assembly: AssemblyCopyright("Copyright © 2021")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// 将 ComVisible 设置为 false 会使此程序集中的类型 -//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 -//请将此类型的 ComVisible 特性设置为 true。 -[assembly: ComVisible(false)] - -//若要开始生成可本地化的应用程序,请设置 -//.csproj 文件中的 CultureYouAreCodingWith -//例如,如果您在源文件中使用的是美国英语, -//使用的是美国英语,请将 设置为 en-US。 然后取消 -//对以下 NeutralResourceLanguage 特性的注释。 更新 -//以下行中的“en-US”以匹配项目文件中的 UICulture 设置。 - -//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] - - -[assembly: ThemeInfo( - ResourceDictionaryLocation.None, //主题特定资源词典所处位置 - //(未在页面中找到资源时使用, - //或应用程序资源字典中找到时使用) - ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置 - //(未在页面中找到资源时使用, - //、应用程序或任何主题专用资源字典中找到时使用) -)] - - -// 程序集的版本信息由下列四个值组成: -// -// 主版本 -// 次版本 -// 生成号 -// 修订号 -// -//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 -//通过使用 "*",如下所示: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("3.1.3.0")] -[assembly: AssemblyFileVersion("3.1.3.0")] diff --git a/ProxySU_Core/Properties/Resources.Designer.cs b/ProxySU_Core/Properties/Resources.Designer.cs deleted file mode 100644 index e7f1775..0000000 --- a/ProxySU_Core/Properties/Resources.Designer.cs +++ /dev/null @@ -1,63 +0,0 @@ -//------------------------------------------------------------------------------ -// -// 此代码由工具生成。 -// 运行时版本:4.0.30319.42000 -// -// 对此文件的更改可能会导致不正确的行为,并且如果 -// 重新生成代码,这些更改将会丢失。 -// -//------------------------------------------------------------------------------ - -namespace ProxySU_Core.Properties { - using System; - - - /// - /// 一个强类型的资源类,用于查找本地化的字符串等。 - /// - // 此类是由 StronglyTypedResourceBuilder - // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 - // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen - // (以 /str 作为命令选项),或重新生成 VS 项目。 - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() { - } - - /// - /// 返回此类使用的缓存的 ResourceManager 实例。 - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ProxySU_Core.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// 重写当前线程的 CurrentUICulture 属性,对 - /// 使用此强类型资源类的所有资源查找执行重写。 - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - } -} diff --git a/ProxySU_Core/Properties/Resources.resx b/ProxySU_Core/Properties/Resources.resx deleted file mode 100644 index af7dbeb..0000000 --- a/ProxySU_Core/Properties/Resources.resx +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/ProxySU_Core/Properties/Settings.Designer.cs b/ProxySU_Core/Properties/Settings.Designer.cs deleted file mode 100644 index a45c35e..0000000 --- a/ProxySU_Core/Properties/Settings.Designer.cs +++ /dev/null @@ -1,26 +0,0 @@ -//------------------------------------------------------------------------------ -// -// 此代码由工具生成。 -// 运行时版本:4.0.30319.42000 -// -// 对此文件的更改可能会导致不正确的行为,并且如果 -// 重新生成代码,这些更改将会丢失。 -// -//------------------------------------------------------------------------------ - -namespace ProxySU_Core.Properties { - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.8.1.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default { - get { - return defaultInstance; - } - } - } -} diff --git a/ProxySU_Core/Properties/Settings.settings b/ProxySU_Core/Properties/Settings.settings deleted file mode 100644 index 033d7a5..0000000 --- a/ProxySU_Core/Properties/Settings.settings +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/ProxySU_Core/ProxySU.ico b/ProxySU_Core/ProxySU.ico deleted file mode 100644 index 9d7a128..0000000 Binary files a/ProxySU_Core/ProxySU.ico and /dev/null differ diff --git a/ProxySU_Core/ProxySU_Core.csproj b/ProxySU_Core/ProxySU_Core.csproj deleted file mode 100644 index aeca57f..0000000 --- a/ProxySU_Core/ProxySU_Core.csproj +++ /dev/null @@ -1,463 +0,0 @@ - - - - - Debug - AnyCPU - {B066015C-D347-4493-92F1-6556D3863996} - WinExe - ProxySU_Core - ProxySU_Core - v4.7.2 - 512 - {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 4 - true - true - - - false - C:\Users\huife\Desktop\publish_new\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 1 - 1.0.0.%2a - false - true - true - - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - D529B8E43BC86188988D830C545B400612900BB3 - - - ProxySU_Core_TemporaryKey.pfx - - - true - - - false - - - ProxySU.ico - - - - ..\packages\ControlzEx.5.0.0\lib\net452\ControlzEx.dll - - - ..\packages\MahApps.Metro.2.4.5\lib\net46\MahApps.Metro.dll - - - ..\packages\MaterialDesignColors.2.0.1\lib\net452\MaterialDesignColors.dll - - - ..\packages\MaterialDesignThemes.MahApps.0.1.7\lib\net452\MaterialDesignThemes.MahApps.dll - - - ..\packages\MaterialDesignThemes.4.1.0\lib\net452\MaterialDesignThemes.Wpf.dll - - - ..\packages\Microsoft.Xaml.Behaviors.Wpf.1.1.31\lib\net45\Microsoft.Xaml.Behaviors.dll - - - ..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll - - - ..\packages\QRCoder.1.4.1\lib\net40\QRCoder.dll - - - ..\packages\SSH.NET.2020.0.1\lib\net40\Renci.SshNet.dll - - - - - - - - - - - - - - - - 4.0 - - - - - - - - MSBuild:Compile - Designer - - - App.xaml - Code - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ClientInfoWindow.xaml - - - ShadowSocksControl.xaml - - - Trojan_TCP_Control.xaml - - - VLESS_gRPC_Control.xaml - - - VLESS_KCP_Control.xaml - - - VLESS_TCP_TLS_Control.xaml - - - VLESS_WS_TLS_Control.xaml - - - VLESS_XTLS_Control.xaml - - - VMESS_KCP_Control.xaml - - - VMESS_TCP_TLS_Control.xaml - - - VMESS_WS_TLS_Control.xaml - - - MainWindow.xaml - - - RecordEditorWindow.xaml - - - ServerInfoControl.xaml - - - XrayEditorControl.xaml - - - TerminalWindow.xaml - - - TextBoxWindow.xaml - - - - - - Code - - - True - True - Resources.resx - - - True - Settings.settings - True - - - ResXFileCodeGenerator - Resources.Designer.cs - - - - 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 - - - - - - - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - MSBuild:Compile - Designer - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - MSBuild:Compile - Designer - - - Designer - MSBuild:Compile - - - - - - - - False - Microsoft .NET Framework 4.6.1 %28x86 和 x64%29 - true - - - False - .NET Framework 3.5 SP1 - false - - - - - - - - - - - - - - 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 - - - - \ No newline at end of file diff --git a/ProxySU_Core/Resources/Languages/en.xaml b/ProxySU_Core/Resources/Languages/en.xaml deleted file mode 100644 index dc9d5ab..0000000 --- a/ProxySU_Core/Resources/Languages/en.xaml +++ /dev/null @@ -1,122 +0,0 @@ - - Deployment - Readme - - Language(语言) - Chinese - English - Hosts - Add Host - Export Config - Export Sub - Random - - - - Selection - Remark - Host - Port - Proxy - Actions - Cnsole - Config - Edit - Delete - - - Actions - Connect - Edit - Edit Xray - Delete - Install - Save - Save as - Info - Warning - Error - - - - Server Editor - Connection - User - Password - Tag - Host - Port - Method - Password Login - KeyLogin - Key - Upload - Proxy - Method - None - Http - Socks5 - Host - Port - User - Password - Please enter host - Please enter port - Please enter proxy host - Please enter proxy port - - - VLESS over TCP With XTLS Preferred - VLESS over TCP with TLS XTLS is Preferred - VLESS over WS with TLS Support CDN - VLESS mKCP low delay - VMESS over WS with TLS Support CDN - VMESS mKCP low delay - ShadowSocks Support CDN - Trojan over TCP with TLS Trojan - - Address - GuiseHost - UUID - VLESS WS Path - VLESS KCP Seed - VLESS KCP Type - VLESS KCP Port - VMESS WS Path - VMESS KCP Seed - VMESS KCP Type - VMESS KCP Port - SS Pwd - SS Method - Trojan Pwd - xray Port - default port is 443 - - - Console - xray/settings - Install - UpdateSettings - UpdateXray - UninstallXray - - cert/web - UpdateCert - UploadSelfCert - UploadWebite - UninstallCaddy - - Install: Finally output "please enjoy" to indicate completion, go to [Configuration] or [Config] to view the node - Update Settings: After modifying the node configuration information, there is no need to reinstall, this function can update the configuration - Update Cert: The certificate is automatically updated by default, but it is not guaranteed to be updated successfully. If it fails, please use [Update Cert] to update manually - Upload website: Disguise the website, the correct static webpage must have an index.html file (please check), and then upload the website compressed package. - The following is a static web page connection provided by netizens, please check whether there is an index.html file by yourself - - - - - View Settings - - \ No newline at end of file diff --git a/ProxySU_Core/Resources/Languages/zh_cn.xaml b/ProxySU_Core/Resources/Languages/zh_cn.xaml deleted file mode 100644 index dc13120..0000000 --- a/ProxySU_Core/Resources/Languages/zh_cn.xaml +++ /dev/null @@ -1,120 +0,0 @@ - - 应用布署 - 说明文档 - - 语言(Language) - 中文 - 英文 - 主机列表 - 添加主机 - 导出配置 - 导出订阅 - 随机 - - - 选择 - 别名 - 主机 - 端口 - 代理 - 操作 - 控制台 - 查看配置 - 编辑 - 删除 - - - 连接 - 安装 - 编辑 - 编辑模板 - 删除 - 保存 - 另存为 - 消息 - 提示 - 错误 - - - 服务器管理 - 连接 - 用户名 - 密码 - 别名 - 主机 - 端口 - 登陆方式 - 密码登陆 - 密钥登陆 - 密钥 - 上传 - 代理 - 类型 - - Http - Socks5 - 代理地址 - 代理端口 - 用户名 - 密码 - 请输入主机 - 请输入端口号 - 请输入代理地址 - 请输入代理端口号 - - VLESS Over TCP With XTLS 性能数倍,首选方式。 - VLESS over TCP with TLS 仍推荐XTLS。 - VLESS over WS with TLS 推荐,支持CDN。 - VLESS mKCP 游戏推荐,延迟低。 - VMESS over WS with TLS 推荐,支持CDN。 - VMESS mKCP 游戏推荐,延迟低。 - ShadowSocks SS,支持udp。 - Trojan over TCP with TLS Trojan。 - - - 域名 - 伪装域名 - UUID - VLESS WS路径 - VLESS KCP Seed - VLESS KCP伪装 - VLESS KCP端口 - VMESS WS路径 - VMESS KCP Seed - VMESS KCP伪装 - VMESS KCP端口 - SS密码 - SS加密方式 - Trojan密码 - xray端口 - 默认端口443,不建议修改 - - - - - 控制台 - 内核/配置 - 一键安装 - 更新配置 - 更新xray内核 - 卸载代理 - - 证书/网站 - 续签证书 - 上传自有证书 - 上传网站 - 卸载Caddy - - 一键安装: 最后输出 “请尽情享用” 表示完成,到[查看配置]或[导出配置]查看节点 - 更新配置: 修改节点配置信息后,不需要重新安装,这个功能就可以更新配置了 - 续签证书: 证书默认是自动续签,但不保证都能续签成功,如果失败请用[续签证书]手动续签 - 上传网站: 伪装网站,正确的静态网页要有index.html文件(请检查),然后将网站压缩包上传。 - 如下是网友提供的静态网页连接,请自行检查是否有index.html文件 - - - - 查看配置信息 - - \ No newline at end of file diff --git a/ProxySU_Core/Resources/ProxySU.ico b/ProxySU_Core/Resources/ProxySU.ico deleted file mode 100644 index 9d7a128..0000000 Binary files a/ProxySU_Core/Resources/ProxySU.ico and /dev/null differ diff --git a/ProxySU_Core/Resources/Styles/MaterialDesignThemes.Overrides.xaml b/ProxySU_Core/Resources/Styles/MaterialDesignThemes.Overrides.xaml deleted file mode 100644 index 5909ff8..0000000 --- a/ProxySU_Core/Resources/Styles/MaterialDesignThemes.Overrides.xaml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/ProxySU_Core/Templates/trojan-go/base.caddyfile b/ProxySU_Core/Templates/trojan-go/base.caddyfile deleted file mode 100644 index 7975d73..0000000 --- a/ProxySU_Core/Templates/trojan-go/base.caddyfile +++ /dev/null @@ -1,9 +0,0 @@ -:##port## { - root * /usr/share/caddy - file_server - ##reverse_proxy## -} - -##domain##:80 { - redir https://##domain##{uri} -} \ No newline at end of file diff --git a/ProxySU_Core/Templates/trojan-go/trojan-go.json b/ProxySU_Core/Templates/trojan-go/trojan-go.json deleted file mode 100644 index acb0207..0000000 --- a/ProxySU_Core/Templates/trojan-go/trojan-go.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "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/ProxySU_Core/Templates/xray/base.json b/ProxySU_Core/Templates/xray/base.json deleted file mode 100644 index 84a9d1f..0000000 --- a/ProxySU_Core/Templates/xray/base.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "log": {}, - "api": {}, - "dns": {}, - "routing": {}, - "policy": {}, - "inbounds": [], - "outbounds": [], - "transport": {}, - "stats": {}, - "reverse": {} -} \ No newline at end of file diff --git a/ProxySU_Core/Templates/xray/caddy/base.caddyfile b/ProxySU_Core/Templates/xray/caddy/base.caddyfile deleted file mode 100644 index 7975d73..0000000 --- a/ProxySU_Core/Templates/xray/caddy/base.caddyfile +++ /dev/null @@ -1,9 +0,0 @@ -:##port## { - root * /usr/share/caddy - file_server - ##reverse_proxy## -} - -##domain##:80 { - redir https://##domain##{uri} -} \ No newline at end of file diff --git a/ProxySU_Core/Templates/xray/client/00_log/00_log.json b/ProxySU_Core/Templates/xray/client/00_log/00_log.json deleted file mode 100644 index 6a4cf00..0000000 --- a/ProxySU_Core/Templates/xray/client/00_log/00_log.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "log": { - "loglevel": "warning" - } -} \ No newline at end of file diff --git a/ProxySU_Core/Templates/xray/client/01_api/01_api.json b/ProxySU_Core/Templates/xray/client/01_api/01_api.json deleted file mode 100644 index aa1982b..0000000 --- a/ProxySU_Core/Templates/xray/client/01_api/01_api.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "api": null -} \ No newline at end of file diff --git a/ProxySU_Core/Templates/xray/client/02_dns/02_dns.json b/ProxySU_Core/Templates/xray/client/02_dns/02_dns.json deleted file mode 100644 index 63472d2..0000000 --- a/ProxySU_Core/Templates/xray/client/02_dns/02_dns.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "dns": {} -} \ No newline at end of file diff --git a/ProxySU_Core/Templates/xray/client/03_routing/03_routing.json b/ProxySU_Core/Templates/xray/client/03_routing/03_routing.json deleted file mode 100644 index a187d31..0000000 --- a/ProxySU_Core/Templates/xray/client/03_routing/03_routing.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "routing": {} -} \ No newline at end of file diff --git a/ProxySU_Core/Templates/xray/client/04_policy/04_policy.json b/ProxySU_Core/Templates/xray/client/04_policy/04_policy.json deleted file mode 100644 index 4beed61..0000000 --- a/ProxySU_Core/Templates/xray/client/04_policy/04_policy.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "policy": {} -} \ No newline at end of file diff --git a/ProxySU_Core/Templates/xray/client/05_inbounds/05_inbounds.json b/ProxySU_Core/Templates/xray/client/05_inbounds/05_inbounds.json deleted file mode 100644 index c402972..0000000 --- a/ProxySU_Core/Templates/xray/client/05_inbounds/05_inbounds.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "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/ProxySU_Core/Templates/xray/client/06_outbounds/06_outbounds.json b/ProxySU_Core/Templates/xray/client/06_outbounds/06_outbounds.json deleted file mode 100644 index 20e2beb..0000000 --- a/ProxySU_Core/Templates/xray/client/06_outbounds/06_outbounds.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "outbounds": [] -} \ No newline at end of file diff --git a/ProxySU_Core/Templates/xray/client/06_outbounds/VLESS_HTTP2_TLS.json b/ProxySU_Core/Templates/xray/client/06_outbounds/VLESS_HTTP2_TLS.json deleted file mode 100644 index 8718383..0000000 --- a/ProxySU_Core/Templates/xray/client/06_outbounds/VLESS_HTTP2_TLS.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "outbounds": [ - { - "protocol": "vless", - "settings": { - "vnext": [ - { - "address": "", - "port": 443, - "users": [ - { - "id": "", - "encryption": "none" - } - ] - } - ] - }, - "streamSettings": { - "network": "h2", - "security": "tls", - "httpSettings": { - "host": [ - "" - ], - "path": null - } - } - } - ] -} diff --git a/ProxySU_Core/Templates/xray/client/06_outbounds/VLESS_TCP_TLS_WS.json b/ProxySU_Core/Templates/xray/client/06_outbounds/VLESS_TCP_TLS_WS.json deleted file mode 100644 index 7a3c871..0000000 --- a/ProxySU_Core/Templates/xray/client/06_outbounds/VLESS_TCP_TLS_WS.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "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/ProxySU_Core/Templates/xray/client/07_transport/07_transport.json b/ProxySU_Core/Templates/xray/client/07_transport/07_transport.json deleted file mode 100644 index 6269103..0000000 --- a/ProxySU_Core/Templates/xray/client/07_transport/07_transport.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "transport": {} -} \ No newline at end of file diff --git a/ProxySU_Core/Templates/xray/client/08_stats/08_stats.json b/ProxySU_Core/Templates/xray/client/08_stats/08_stats.json deleted file mode 100644 index 02c9ed0..0000000 --- a/ProxySU_Core/Templates/xray/client/08_stats/08_stats.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "stats": null -} \ No newline at end of file diff --git a/ProxySU_Core/Templates/xray/client/09_reverse/09_reverse.json b/ProxySU_Core/Templates/xray/client/09_reverse/09_reverse.json deleted file mode 100644 index 6fa38a4..0000000 --- a/ProxySU_Core/Templates/xray/client/09_reverse/09_reverse.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "reverse": {} -} \ No newline at end of file diff --git a/ProxySU_Core/Templates/xray/server/00_log/00_log.json b/ProxySU_Core/Templates/xray/server/00_log/00_log.json deleted file mode 100644 index 40c2cd5..0000000 --- a/ProxySU_Core/Templates/xray/server/00_log/00_log.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "log": { - "access": "none", - "loglevel": "none" - } -} \ No newline at end of file diff --git a/ProxySU_Core/Templates/xray/server/01_api/01_api.json b/ProxySU_Core/Templates/xray/server/01_api/01_api.json deleted file mode 100644 index 34c6b17..0000000 --- a/ProxySU_Core/Templates/xray/server/01_api/01_api.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "api": {} -} \ No newline at end of file diff --git a/ProxySU_Core/Templates/xray/server/02_dns/02_dns.json b/ProxySU_Core/Templates/xray/server/02_dns/02_dns.json deleted file mode 100644 index 63472d2..0000000 --- a/ProxySU_Core/Templates/xray/server/02_dns/02_dns.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "dns": {} -} \ No newline at end of file diff --git a/ProxySU_Core/Templates/xray/server/03_routing/03_routing.json b/ProxySU_Core/Templates/xray/server/03_routing/03_routing.json deleted file mode 100644 index 0aa4964..0000000 --- a/ProxySU_Core/Templates/xray/server/03_routing/03_routing.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "routing": { - "domainStrategy": "AsIs", - "rules": [ - { - "type": "field", - "ip": [ - "geoip:private" - ], - "outboundTag": "block" - } - ] - } -} \ No newline at end of file diff --git a/ProxySU_Core/Templates/xray/server/04_policy/04_policy.json b/ProxySU_Core/Templates/xray/server/04_policy/04_policy.json deleted file mode 100644 index 4beed61..0000000 --- a/ProxySU_Core/Templates/xray/server/04_policy/04_policy.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "policy": {} -} \ No newline at end of file diff --git a/ProxySU_Core/Templates/xray/server/05_inbounds/05_inbounds.json b/ProxySU_Core/Templates/xray/server/05_inbounds/05_inbounds.json deleted file mode 100644 index 24465ae..0000000 --- a/ProxySU_Core/Templates/xray/server/05_inbounds/05_inbounds.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "inbounds": [] -} diff --git a/ProxySU_Core/Templates/xray/server/05_inbounds/Shadowsocks-AEAD.json b/ProxySU_Core/Templates/xray/server/05_inbounds/Shadowsocks-AEAD.json deleted file mode 100644 index e7179e5..0000000 --- a/ProxySU_Core/Templates/xray/server/05_inbounds/Shadowsocks-AEAD.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "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.json b/ProxySU_Core/Templates/xray/server/05_inbounds/Trojan_TCP.json deleted file mode 100644 index 8ea5ad9..0000000 --- a/ProxySU_Core/Templates/xray/server/05_inbounds/Trojan_TCP.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "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/ProxySU_Core/Templates/xray/server/05_inbounds/Trojan_WS.json b/ProxySU_Core/Templates/xray/server/05_inbounds/Trojan_WS.json deleted file mode 100644 index 51d725c..0000000 --- a/ProxySU_Core/Templates/xray/server/05_inbounds/Trojan_WS.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "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/ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_HTTP2.json b/ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_HTTP2.json deleted file mode 100644 index a99e848..0000000 --- a/ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_HTTP2.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "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/ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_KCP.json b/ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_KCP.json deleted file mode 100644 index a619549..0000000 --- a/ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_KCP.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "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/ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_TCP_XTLS.json b/ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_TCP_XTLS.json deleted file mode 100644 index eab8363..0000000 --- a/ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_TCP_XTLS.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "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/ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_WS.json b/ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_WS.json deleted file mode 100644 index 0abf2e8..0000000 --- a/ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_WS.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "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/ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_gRPC.json b/ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_gRPC.json deleted file mode 100644 index 319888d..0000000 --- a/ProxySU_Core/Templates/xray/server/05_inbounds/VLESS_gRPC.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "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/ProxySU_Core/Templates/xray/server/05_inbounds/VMESS_HTTP2.json b/ProxySU_Core/Templates/xray/server/05_inbounds/VMESS_HTTP2.json deleted file mode 100644 index 9957e76..0000000 --- a/ProxySU_Core/Templates/xray/server/05_inbounds/VMESS_HTTP2.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "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/ProxySU_Core/Templates/xray/server/05_inbounds/VMESS_KCP.json b/ProxySU_Core/Templates/xray/server/05_inbounds/VMESS_KCP.json deleted file mode 100644 index 0c3ea2b..0000000 --- a/ProxySU_Core/Templates/xray/server/05_inbounds/VMESS_KCP.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "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/ProxySU_Core/Templates/xray/server/05_inbounds/VMESS_TCP.json b/ProxySU_Core/Templates/xray/server/05_inbounds/VMESS_TCP.json deleted file mode 100644 index b14181e..0000000 --- a/ProxySU_Core/Templates/xray/server/05_inbounds/VMESS_TCP.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "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/ProxySU_Core/Templates/xray/server/05_inbounds/VMESS_WS.json b/ProxySU_Core/Templates/xray/server/05_inbounds/VMESS_WS.json deleted file mode 100644 index 2e863a4..0000000 --- a/ProxySU_Core/Templates/xray/server/05_inbounds/VMESS_WS.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "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/ProxySU_Core/Templates/xray/server/06_outbounds/06_outbounds.json b/ProxySU_Core/Templates/xray/server/06_outbounds/06_outbounds.json deleted file mode 100644 index 467a4e1..0000000 --- a/ProxySU_Core/Templates/xray/server/06_outbounds/06_outbounds.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "outbounds": [ - { - "protocol": "freedom", - "tag": "direct" - }, - { - "protocol": "blackhole", - "tag": "block" - } - ] -} \ No newline at end of file diff --git a/ProxySU_Core/Templates/xray/server/07_transport/07_transport.json b/ProxySU_Core/Templates/xray/server/07_transport/07_transport.json deleted file mode 100644 index 6269103..0000000 --- a/ProxySU_Core/Templates/xray/server/07_transport/07_transport.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "transport": {} -} \ No newline at end of file diff --git a/ProxySU_Core/Templates/xray/server/08_stats/08_stats.json b/ProxySU_Core/Templates/xray/server/08_stats/08_stats.json deleted file mode 100644 index b406e15..0000000 --- a/ProxySU_Core/Templates/xray/server/08_stats/08_stats.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "stats": {} -} \ No newline at end of file diff --git a/ProxySU_Core/Templates/xray/server/09_reverse/09_reverse.json b/ProxySU_Core/Templates/xray/server/09_reverse/09_reverse.json deleted file mode 100644 index 6fa38a4..0000000 --- a/ProxySU_Core/Templates/xray/server/09_reverse/09_reverse.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "reverse": {} -} \ No newline at end of file diff --git a/ProxySU_Core/Tools/DateTimeUtils.cs b/ProxySU_Core/Tools/DateTimeUtils.cs deleted file mode 100644 index 32cb7b5..0000000 --- a/ProxySU_Core/Tools/DateTimeUtils.cs +++ /dev/null @@ -1,83 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Net; -using System.Runtime.InteropServices; -using System.Text; - -namespace ProxySU_Core.Tools -{ - public static class DateTimeUtils - { - /// - /// 从国家授时中心获取标准GMT时间,读取https://www.tsa.cn - /// GMT时间与UTC时间没有差别,可以UTC=GMT - /// - /// 返回网络时间 - public static DateTime GetUTCTime() - { - DateTime time; - try - { - HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://www.tsa.cn"); - request.Method = "HEAD"; - request.AllowAutoRedirect = false; - HttpWebResponse reponse = (HttpWebResponse)request.GetResponse(); - string cc = reponse.GetResponseHeader("date"); - reponse.Close(); - - bool s = GMTStrParse(cc, out time); - return time; - } - catch - { - return new DateTime(1970, 1, 1, 0, 0, 0, 0); - } - } - - public static bool GMTStrParse(string gmtStr, out DateTime gmtTime) //抓取的date是GMT格式的字符串,这里转成datetime - { - CultureInfo enUS = new CultureInfo("en-US"); - bool s = DateTime.TryParseExact(gmtStr, "r", enUS, DateTimeStyles.None, out gmtTime); - return s; - } - - //设置系统时间的API函数 - [DllImport("kernel32.dll")] - private static extern bool SetLocalTime(ref SYSTEMTIME time); - - [StructLayout(LayoutKind.Sequential)] - private struct SYSTEMTIME - { - public short year; - public short month; - public short dayOfWeek; - public short day; - public short hour; - public short minute; - public short second; - public short milliseconds; - } - - /// - /// 设置系统时间 - /// - /// 需要设置的时间 - /// 返回系统时间设置状态,true为成功,false为失败 - public static bool SetDate(DateTime dt) - { - SYSTEMTIME st; - - st.year = (short)dt.Year; - st.month = (short)dt.Month; - st.dayOfWeek = (short)dt.DayOfWeek; - st.day = (short)dt.Day; - st.hour = (short)dt.Hour; - st.minute = (short)dt.Minute; - st.second = (short)dt.Second; - st.milliseconds = (short)dt.Millisecond; - bool rt = SetLocalTime(ref st); - return rt; - } - } -} diff --git a/ProxySU_Core/Tools/Extensions.cs b/ProxySU_Core/Tools/Extensions.cs deleted file mode 100644 index 1c4af48..0000000 --- a/ProxySU_Core/Tools/Extensions.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Runtime.Serialization.Formatters.Binary; -using System.Text; -using System.Threading.Tasks; - -namespace System -{ - public static class Extensions - { - // Deep clone - public static T DeepClone(this T obj) - { - if (obj == null) - throw new ArgumentNullException("Object cannot be null"); - return (T)Process(obj); - } - - static object Process(object obj) - { - if (obj == null) - return null; - Type type = obj.GetType(); - if (type.IsValueType || type == typeof(string)) - { - return obj; - } - else if (type.IsArray) - { - Type elementType = Type.GetType( - type.FullName.Replace("[]", string.Empty)); - var array = obj as Array; - Array copied = Array.CreateInstance(elementType, array.Length); - for (int i = 0; i < array.Length; i++) - { - copied.SetValue(Process(array.GetValue(i)), i); - } - return Convert.ChangeType(copied, obj.GetType()); - } - else if (type.IsClass) - { - object toret = Activator.CreateInstance(obj.GetType()); - FieldInfo[] fields = type.GetFields(BindingFlags.Public | - BindingFlags.NonPublic | BindingFlags.Instance); - foreach (FieldInfo field in fields) - { - object fieldValue = field.GetValue(obj); - if (fieldValue == null) - continue; - field.SetValue(toret, Process(fieldValue)); - } - return toret; - } - else - throw new ArgumentException("Unknown type"); - } - - } -} diff --git a/ProxySU_Core/ViewModels/BaseCommand.cs b/ProxySU_Core/ViewModels/BaseCommand.cs deleted file mode 100644 index 21860cd..0000000 --- a/ProxySU_Core/ViewModels/BaseCommand.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Windows.Input; - -namespace ProxySU_Core.ViewModels -{ - public class BaseCommand : ICommand - { - private readonly Action _execution; - private readonly Func _canExecute; - - public BaseCommand(Action execution, Func canExecute = null) - { - _execution = execution; - _canExecute = canExecute; - } - - - - public event EventHandler CanExecuteChanged; - - public bool CanExecute(object parameter) - { - if (_canExecute == null) - { - return true; - } - - return _canExecute(parameter); - } - - public void Execute(object parameter) - { - if (_execution != null && CanExecute(parameter)) - { - _execution.Invoke(parameter); - } - } - } -} diff --git a/ProxySU_Core/ViewModels/BaseModel.cs b/ProxySU_Core/ViewModels/BaseModel.cs deleted file mode 100644 index 5255ebb..0000000 --- a/ProxySU_Core/ViewModels/BaseModel.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ProxySU_Core.ViewModels -{ - public class BaseViewModel2 : INotifyPropertyChanged - { - - protected bool SetProperty(ref T backingStore, T value, - string propertyName = "", - Action onChanged = null) - { - if (EqualityComparer.Default.Equals(backingStore, value)) - return false; - - backingStore = value; - onChanged?.Invoke(); - OnPropertyChanged(propertyName); - return true; - } - - #region INotifyPropertyChanged - public event PropertyChangedEventHandler PropertyChanged; - protected void OnPropertyChanged(string propertyName = "") - { - var changed = PropertyChanged; - if (changed == null) - return; - - changed.Invoke(this, new PropertyChangedEventArgs(propertyName)); - } - #endregion - } -} diff --git a/ProxySU_Core/ViewModels/BaseViewModel.cs b/ProxySU_Core/ViewModels/BaseViewModel.cs deleted file mode 100644 index 1aa2f1c..0000000 --- a/ProxySU_Core/ViewModels/BaseViewModel.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Text; - -namespace ProxySU_Core.ViewModels -{ - public abstract class BaseViewModel : INotifyPropertyChanged - { - public event PropertyChangedEventHandler PropertyChanged; - - public void Notify(string propertyName) - { - if (PropertyChanged != null) - { - PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName)); - } - } - } -} diff --git a/ProxySU_Core/ViewModels/HostViewModel.cs b/ProxySU_Core/ViewModels/HostViewModel.cs deleted file mode 100644 index 04ceb62..0000000 --- a/ProxySU_Core/ViewModels/HostViewModel.cs +++ /dev/null @@ -1,144 +0,0 @@ -using Microsoft.Win32; -using Newtonsoft.Json; -using ProxySU_Core.Models; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Windows; -using System.Windows.Input; - -namespace ProxySU_Core.ViewModels -{ - public class HostViewModel : BaseViewModel - { - public Host host; - - private readonly ICommand _selectKeyCommand; - - - public HostViewModel(Host host) - { - _selectKeyCommand = new BaseCommand(obj => OpenFileDialog(obj)); - this.host = host; - } - - - public string Tag - { - get => host.Tag; - set - { - host.Tag = value; - Notify("Tag"); - } - } - - public string Address - { - get => host.Address; - set - { - host.Address = value; - Notify("Address"); - } - } - - public string UserName - { - get => host.UserName; - set => host.UserName = value; - } - - public string Password - { - get => host.Password; - set => host.Password = value; - } - - public int Port - { - get => host.Port; - set => host.Port = value; - } - - public string PrivateKeyPath - { - get => host.PrivateKeyPath; - set => host.PrivateKeyPath = value; - } - - public LocalProxy Proxy - { - get => host.Proxy; - set - { - host.Proxy = value; - Notify("Proxy"); - } - } - - public LoginSecretType SecretType - { - get => host.SecretType; - set - { - host.SecretType = value; - Notify("SecretType"); - Notify("KeyUploaderVisiblity"); - Notify("PasswordVisiblity"); - } - } - - [JsonIgnore] - public Visibility PasswordVisiblity - { - get - { - if (SecretType == LoginSecretType.Password) - { - return Visibility.Visible; - } - return Visibility.Collapsed; - } - } - - [JsonIgnore] - public Visibility KeyUploaderVisiblity - { - get - { - if (SecretType == LoginSecretType.PrivateKey) - { - return Visibility.Visible; - } - return Visibility.Collapsed; - } - } - - - [JsonIgnore] - public ICommand SelectKeyCommand - { - get - { - return _selectKeyCommand; - } - } - - - private void OpenFileDialog(object obj) - { - var fileDialog = new OpenFileDialog(); - fileDialog.FileOk += OnFileOk; - fileDialog.ShowDialog(); - } - - private void OnFileOk(object sender, CancelEventArgs e) - { - var file = sender as OpenFileDialog; - PrivateKeyPath = file.FileName; - } - } - - -} diff --git a/ProxySU_Core/ViewModels/IdValueViewModel.cs b/ProxySU_Core/ViewModels/IdValueViewModel.cs deleted file mode 100644 index d7b8fbf..0000000 --- a/ProxySU_Core/ViewModels/IdValueViewModel.cs +++ /dev/null @@ -1,21 +0,0 @@ -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/RecordViewModel.cs b/ProxySU_Core/ViewModels/RecordViewModel.cs deleted file mode 100644 index e2270be..0000000 --- a/ProxySU_Core/ViewModels/RecordViewModel.cs +++ /dev/null @@ -1,58 +0,0 @@ -using ProxySU_Core.Models; -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ProxySU_Core.ViewModels -{ - public class RecordViewModel : BaseViewModel - { - public Record record; - private bool _isChecked; - - public RecordViewModel(Record record) - { - this.record = record; - this._isChecked = false; - } - - public bool IsChecked - { - get => _isChecked; - set - { - _isChecked = value; - Notify("IsChecked"); - } - } - - public Host Host - { - get => record.Host; - set - { - record.Host = value; - Notify("Host"); - } - } - - public XraySettings Settings - { - get => record.Settings; - set - { - record.Settings = value; - Notify("Settings"); - } - } - - public void Notify() - { - Notify("Host"); - Notify("Settings"); - } - } -} diff --git a/ProxySU_Core/ViewModels/Terminal.cs b/ProxySU_Core/ViewModels/Terminal.cs deleted file mode 100644 index 1f2a92a..0000000 --- a/ProxySU_Core/ViewModels/Terminal.cs +++ /dev/null @@ -1,38 +0,0 @@ -using ProxySU_Core.Models; -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Text; - -namespace ProxySU_Core.ViewModels -{ - public class Terminal : BaseViewModel - { - private bool hasConnected; - - public Terminal(Host host) - { - Host = host; - HasConnected = false; - } - - public bool HasConnected - { - get - { - return hasConnected; - } - set - { - hasConnected = value; - Notify("HasConnected"); - } - } - - public Host Host { get; set; } - - public string CommandText { get; set; } - - public string OutputText { get; set; } - } -} diff --git a/ProxySU_Core/ViewModels/XraySettingsViewModel.cs b/ProxySU_Core/ViewModels/XraySettingsViewModel.cs deleted file mode 100644 index 78826a8..0000000 --- a/ProxySU_Core/ViewModels/XraySettingsViewModel.cs +++ /dev/null @@ -1,399 +0,0 @@ -using Newtonsoft.Json; -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; -using System.Windows.Input; - -namespace ProxySU_Core.ViewModels -{ - public partial class XraySettingsViewModel : BaseViewModel - { - public XraySettings settings; - private readonly ICommand _randomUuid; - - public XraySettingsViewModel(XraySettings parameters) - { - _randomUuid = new BaseCommand((obj) => GetUuid()); - this.settings = parameters; - Notify("VMESS_KCP_Type"); - } - - public ICommand RandomUuid - { - get - { - return _randomUuid; - } - } - - - public int Port - { - get => settings.Port; - set - { - settings.Port = value; - Notify("Port"); - } - } - - public int VLESS_KCP_Port - { - get => settings.VLESS_KCP_Port; - set - { - settings.VLESS_KCP_Port = value; - Notify("VLESS_KCP_Port"); - } - } - - public int VMESS_KCP_Port - { - get => settings.VMESS_KCP_Port; - set - { - settings.VMESS_KCP_Port = value; - Notify("VMESS_KCP_Port"); - } - } - - public int ShadowSocksPort - { - get => settings.ShadowSocksPort; - set - { - settings.VMESS_KCP_Port = value; - Notify("ShadowSocksPort"); - } - } - - - public string UUID - { - get => settings.UUID; - set - { - settings.UUID = value; - Notify("UUID"); - } - } - - public string Domain - { - get => settings.Domain; - set - { - settings.Domain = value; - Notify("Domain"); - } - } - - public string MaskDomain - { - get => settings.MaskDomain; - set - { - settings.MaskDomain = value; - Notify("MaskDomain"); - } - } - - public string TrojanPassword - { - get => settings.TrojanPassword; - set => settings.TrojanPassword = value; - } - public bool Checked_Trojan_TCP - { - get - { - return settings.Types.Contains(XrayType.Trojan_TCP); - } - set - { - if (value == true) - { - if (!settings.Types.Contains(XrayType.Trojan_TCP)) - settings.Types.Add(XrayType.Trojan_TCP); - } - else - { - settings.Types.Remove(XrayType.Trojan_TCP); - } - Notify("Checked_Trojan_TCP"); - } - } - 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); - } - } - - - - private void GetUuid() - { - UUID = Guid.NewGuid().ToString(); - Notify("UUID"); - } - - } - - /// - /// VMESS - /// - public partial class XraySettingsViewModel - { - // vmess tcp - public bool Checked_VMESS_TCP - { - get => settings.Types.Contains(XrayType.VMESS_TCP); - set - { - CheckBoxChanged(value, XrayType.VMESS_TCP); - Notify("Checked_VMESS_TCP"); - } - } - public string VMESS_TCP_Path - { - get => settings.VMESS_TCP_Path; - set => settings.VMESS_TCP_Path = value; - } - public string VMESS_TCP_ShareLink - { - 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; - } - - /// - /// VLESS - /// - 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_TCP_XTLS"); - } - } - public string VLESS_TCP_XTLS_ShareLink - { - get => ShareLink.Build(XrayType.VLESS_TCP_XTLS, settings); - } - - // vless tcp - public bool Checked_VLESS_TCP - { - get => settings.Types.Contains(XrayType.VLESS_TCP); - set - { - CheckBoxChanged(value, XrayType.VLESS_TCP); - Notify("Checked_VLESS_TCP"); - } - } - public string VLESS_TCP_ShareLink - { - get => ShareLink.Build(XrayType.VLESS_TCP, settings); - } - - - // vless ws - public string VLESS_WS_Path - { - get => settings.VLESS_WS_Path; - set => settings.VLESS_WS_Path = value; - } - public bool Checked_VLESS_WS - { - get - { - return settings.Types.Contains(XrayType.VLESS_WS); - } - set - { - CheckBoxChanged(value, XrayType.VLESS_WS); - Notify("Checked_VLESS_WS"); - } - } - public string VLESS_WS_ShareLink - { - get => ShareLink.Build(XrayType.VLESS_WS, settings); - } - - // vless kcp - public string VLESS_KCP_Seed - { - get => settings.VLESS_KCP_Seed; - set => settings.VLESS_KCP_Seed = value; - } - public string VLESS_KCP_Type - { - get => settings.VLESS_KCP_Type; - set - { - var namespaceStr = typeof(ComboBoxItem).FullName + ":"; - var trimValue = value.Replace(namespaceStr, ""); - trimValue = trimValue.Trim(); - settings.VLESS_KCP_Type = trimValue; - Notify("VLESS_KCP_Type"); - } - } - public bool Checked_VLESS_KCP - { - get => settings.Types.Contains(XrayType.VLESS_KCP); - set - { - CheckBoxChanged(value, XrayType.VLESS_KCP); - Notify("Checked_VLESS_KCP"); - } - } - public string VLESS_KCP_ShareLink - { - get => ShareLink.Build(XrayType.VLESS_KCP, settings); - } - - // vless grpc - public string VLESS_gRPC_ServiceName - { - get => settings.VLESS_gRPC_ServiceName; - set => settings.VLESS_gRPC_ServiceName = value; - } - public int VLESS_gRPC_Port - { - get => settings.VLESS_gRPC_Port; - set => settings.VLESS_gRPC_Port = value; - } - public bool Checked_VLESS_gRPC - { - get => settings.Types.Contains(XrayType.VLESS_gRPC); - set - { - CheckBoxChanged(value, XrayType.VLESS_gRPC); - Notify("Checked_VLESS_gRPC"); - } - } - public string VLESS_gRPC_ShareLink - { - get => ShareLink.Build(XrayType.VLESS_gRPC, settings); - } - } - -} diff --git a/ProxySU_Core/Views/ClientInfo/ClientInfoWindow.xaml b/ProxySU_Core/Views/ClientInfo/ClientInfoWindow.xaml deleted file mode 100644 index d95b8cb..0000000 --- a/ProxySU_Core/Views/ClientInfo/ClientInfoWindow.xaml +++ /dev/null @@ -1,114 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -