diff --git a/ProxySU/MainWindow.xaml b/ProxySU/MainWindow.xaml
index 5486f5c..b63db44 100644
--- a/ProxySU/MainWindow.xaml
+++ b/ProxySU/MainWindow.xaml
@@ -115,6 +115,7 @@
+
diff --git a/ProxySU/MainWindow.xaml.cs b/ProxySU/MainWindow.xaml.cs
index 110b4a5..628b721 100644
--- a/ProxySU/MainWindow.xaml.cs
+++ b/ProxySU/MainWindow.xaml.cs
@@ -585,15 +585,46 @@ namespace ProxySU
currentStatus = "生成客户端配置......";
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
Thread.Sleep(1000);
- upLoadPath = "/tmp/config.json";
- UploadConfig(connectionInfo, clientConfig, upLoadPath);
+ if (!Directory.Exists("config"))//如果不存在就创建file文件夹
+ {
+ Directory.CreateDirectory("config");//创建该文件夹
+ }
+ //string clientConfig = "TemplateConfg\\tcp_client_config.json";
+ using (StreamReader reader = File.OpenText(clientConfig))
+ {
+ JObject clientJson = (JObject)JToken.ReadFrom(new JsonTextReader(reader));
+ // do stuff
+ //MessageBox.Show(clientJson.ToString());
+ clientJson["outbounds"][0]["settings"]["vnext"][0]["address"] = ReceiveConfigurationParameters[4];
+ clientJson["outbounds"][0]["settings"]["vnext"][0]["port"] = ReceiveConfigurationParameters[1];
+ clientJson["outbounds"][0]["settings"]["vnext"][0]["users"][0]["id"] = ReceiveConfigurationParameters[2];
+ if (clientJson.Property("path") != null)
+ {
+ //成员path存在
+ clientJson["outbounds"][0]["streamSettings"]["wsSettings"]["path"] = ReceiveConfigurationParameters[3];
- client.RunCommand("sed -i 's/##port##/" + ReceiveConfigurationParameters[1] + "/' " + upLoadPath);
- client.RunCommand("sed -i 's/##uuid##/" + ReceiveConfigurationParameters[2] + "/' " + upLoadPath);
- client.RunCommand("sed -i 's/##path##/\\" + ReceiveConfigurationParameters[3] + "/' " + upLoadPath);
- client.RunCommand("sed -i 's/##domain##/" + ReceiveConfigurationParameters[4] + "/' " + upLoadPath);
- client.RunCommand("sed -i 's/##mkcpHeaderType##/" + ReceiveConfigurationParameters[5] + "/' " + upLoadPath);
- DownloadConfig(connectionInfo, "config\\config.json", upLoadPath);
+ }
+ if (clientJson.Property("type") != null)
+ {
+ //成员type存在
+ clientJson["outbounds"][0]["streamSettings"]["kcpSettings"]["header"]["type"] = ReceiveConfigurationParameters[5];
+
+ }
+
+ using (StreamWriter sw = new StreamWriter(@"config\config.json"))
+ {
+ sw.Write(clientJson.ToString());
+ }
+ }
+ //upLoadPath = "/tmp/config.json";
+ //UploadConfig(connectionInfo, clientConfig, upLoadPath);
+
+ //client.RunCommand("sed -i 's/##port##/" + ReceiveConfigurationParameters[1] + "/' " + upLoadPath);
+ //client.RunCommand("sed -i 's/##uuid##/" + ReceiveConfigurationParameters[2] + "/' " + upLoadPath);
+ //client.RunCommand("sed -i 's/##path##/\\" + ReceiveConfigurationParameters[3] + "/' " + upLoadPath);
+ //client.RunCommand("sed -i 's/##domain##/" + ReceiveConfigurationParameters[4] + "/' " + upLoadPath);
+ //client.RunCommand("sed -i 's/##mkcpHeaderType##/" + ReceiveConfigurationParameters[5] + "/' " + upLoadPath);
+ //DownloadConfig(connectionInfo, "config.json", upLoadPath);
client.Disconnect();
@@ -870,6 +901,41 @@ namespace ProxySU
//MessageBox.Show(v2rayNjsonObject["v"].ToString());
}
+
+ private void Button_Click_4(object sender, RoutedEventArgs e)
+ {
+ if (!Directory.Exists("config"))//如果不存在就创建file文件夹
+ {
+ Directory.CreateDirectory("config");//创建该文件夹
+ }
+ string clientConfig= "TemplateConfg\\tcp_client_config.json";
+ using (StreamReader reader = File.OpenText(clientConfig))
+ {
+ JObject clientJson = (JObject)JToken.ReadFrom(new JsonTextReader(reader));
+ // do stuff
+ MessageBox.Show(clientJson.ToString());
+ clientJson["outbounds"][0]["settings"]["vnext"][0]["address"] = ReceiveConfigurationParameters[4];
+ clientJson["outbounds"][0]["settings"]["vnext"][0]["port"] = ReceiveConfigurationParameters[1];
+ clientJson["outbounds"][0]["settings"]["vnext"][0]["users"][0]["id"] = ReceiveConfigurationParameters[2];
+ if (clientJson.Property("path") != null)
+ {
+ //成员path存在
+ clientJson["outbounds"][0]["streamSettings"]["wsSettings"]["path"] = ReceiveConfigurationParameters[3];
+
+ }
+ if (clientJson.Property("type") != null)
+ {
+ //成员type存在
+ clientJson["outbounds"][0]["streamSettings"]["kcpSettings"]["header"]["type"] = ReceiveConfigurationParameters[5];
+
+ }
+
+ using (StreamWriter sw = new StreamWriter(@"config\config.json"))
+ {
+ sw.Write(clientJson.ToString());
+ }
+ }
+ }
}
}
diff --git a/ProxySU/ResultClientInformation.xaml b/ProxySU/ResultClientInformation.xaml
index 7277ee1..b0a914c 100644
--- a/ProxySU/ResultClientInformation.xaml
+++ b/ProxySU/ResultClientInformation.xaml
@@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:ProxySU"
mc:Ignorable="d"
- Title="ResultClientInformation" Height="400" Width="600">
+ Title="ResultClientInformation" Height="650" Width="600">
@@ -26,6 +26,13 @@
+
+
+
+
+
+
+
@@ -48,15 +55,27 @@
-
-
-
-
-
-
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ProxySU/ResultClientInformation.xaml.cs b/ProxySU/ResultClientInformation.xaml.cs
index 810d9b2..a7363d2 100644
--- a/ProxySU/ResultClientInformation.xaml.cs
+++ b/ProxySU/ResultClientInformation.xaml.cs
@@ -26,6 +26,7 @@ namespace ProxySU
///
public partial class ResultClientInformation : Window
{
+ private string saveFileFolder = "";
public ResultClientInformation()
{
InitializeComponent();
@@ -121,8 +122,12 @@ namespace ProxySU
TextBoxTLS.Text = "none";
HidePathAndTLS();
}
-
- GenerateV2rayNshareQRcodeAndBase64Url();
+ CheckDir("config");
+ //if (!Directory.Exists("config"))//如果不存在就创建file文件夹
+ //{
+ // Directory.CreateDirectory("config");//创建该文件夹
+ //}
+ GenerateV2rayShareQRcodeAndBase64Url();
}
private void HidePathAndTLS()
@@ -144,7 +149,7 @@ namespace ProxySU
//TextBlocTLSonOrNoExplain.Visibility = Visibility.Visible;
}
//生成v2rayN客户端导入文件
- private void GenerateV2rayNshareQRcodeAndBase64Url()
+ private void GenerateV2rayShareQRcodeAndBase64Url()
{
//生成v2rayN的json文件
string v2rayNjsonFile = @"
@@ -176,16 +181,45 @@ namespace ProxySU
v2rayNjsonObject["ps"] = v2rayNjsonObject["add"]; //设置备注
//MessageBox.Show(v2rayNjsonObject["v"].ToString());
-
- MessageBox.Show(v2rayNjsonObject.ToString());
+ saveFileFolder = v2rayNjsonObject["ps"].ToString();
+ CheckDir(@"config\" + saveFileFolder);
+ //MessageBox.Show(v2rayNjsonObject.ToString());
string vmessUrl = "vmess://" + ToBase64Encode(v2rayNjsonObject.ToString());
- using (StreamWriter sw = new StreamWriter(@"config\v2rayNvmessUrl.txt"))
+ TextBoxvVmessUrl.Text = vmessUrl;
+ using (StreamWriter sw = new StreamWriter($"config\\{saveFileFolder}\\url.txt"))
{
sw.WriteLine(vmessUrl);
}
CreateQRCode(vmessUrl);
+ if (File.Exists(@"config\config.json"))
+ {
+ File.Move(@"config\config.json", @"config\" + saveFileFolder + @"\config.json");
+ //File.Delete(@"config\config.json");//删除该文件
+ }
+
+ using (StreamWriter sw = new StreamWriter($"config\\{saveFileFolder}\\说明.txt"))
+ {
+ sw.WriteLine("config.json");
+ sw.WriteLine("此文件为v2ray官方程序所使用的客户端配置文件,配置为全局模式,socks5地址:127.0.0.1:1080,http代理地址:127.0.0.1:1081");
+ sw.WriteLine("v2ray官方网站:https://www.v2ray.com/");
+ sw.WriteLine("v2ray官方程序下载地址:https://github.com/v2ray/v2ray-core/releases");
+ sw.WriteLine("下载相应版本,Windows选择v2ray-windows-64.zip或者v2ray-windows-32.zip,解压后提取v2ctl.exe和v2ray.exe。与config.json放在同一目录,运行v2ray.exe即可。");
+ sw.WriteLine("-----------------------------------------");
+ sw.WriteLine("QR.bmp");
+ sw.WriteLine("此文件为v2rayN、v2rayNG(Android)、Shadowrocket(ios)扫码导入节点");
+ sw.WriteLine("v2rayN下载网址:https://github.com/2dust/v2rayN/releases");
+ sw.WriteLine("v2rayNG(Android)下载网址:https://github.com/2dust/v2rayNG/releases");
+ sw.WriteLine("v2rayNG(Android)在Google Play下载网址:https://play.google.com/store/apps/details?id=com.v2ray.ang");
+ sw.WriteLine("Shadowrocket(ios)下载,需要使用国外区的AppleID。请自行谷歌方法。");
+
+ sw.WriteLine("-----------------------------------------");
+ sw.WriteLine("url.txt");
+ sw.WriteLine("此文件为v2rayN、v2rayNG(Android)、Shadowrocket(ios)复制粘贴导入节点的vmess网址");
+ }
+
+
}
//生成base64
@@ -207,8 +241,28 @@ namespace ProxySU
QRCodeData qrCodeData = qrGenerator.CreateQrCode(varBase64, QRCodeGenerator.ECCLevel.Q);
QRCode qrCode = new QRCode(qrCodeData);
Bitmap qrCodeImage = qrCode.GetGraphic(20);
- qrCodeImage.Save(@"config\v2rayN.bmp");
+ 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($"config\\{saveFileFolder}\\QR.bmp");
+ //ImageShareQRcode.Source = @"config\v2rayN.bmp";
}
+ //判断目录是否存在,不存在则创建
+ public static bool CheckDir(string folder)
+ {
+ try
+ {
+ if (!Directory.Exists(folder))//如果不存在就创建file文件夹
+ Directory.CreateDirectory(folder);//创建该文件夹
+ return true;
+ }
+ catch (Exception ex)
+ {
+ return false;
+ }
+ }
+
private void Button_Click(object sender, RoutedEventArgs e)
{
string openFolderPath = @"config";
diff --git a/ProxySU/bin/Release/ProxySU.exe b/ProxySU/bin/Release/ProxySU.exe
index 0a1fd8e..8a7b5aa 100644
Binary files a/ProxySU/bin/Release/ProxySU.exe and b/ProxySU/bin/Release/ProxySU.exe differ
diff --git a/ProxySU/bin/Release/Release.zip b/ProxySU/bin/Release/Release.zip
index a2792be..8000aa7 100644
Binary files a/ProxySU/bin/Release/Release.zip and b/ProxySU/bin/Release/Release.zip differ