添加Trojan一键安装1
@ -106,8 +106,8 @@
|
|||||||
<!--<StatusBar x:Name="StatusBarStatusMonitoring" Grid.Column="0" Grid.Row="7" Grid.ColumnSpan="4"></StatusBar>-->
|
<!--<StatusBar x:Name="StatusBarStatusMonitoring" Grid.Column="0" Grid.Row="7" Grid.ColumnSpan="4"></StatusBar>-->
|
||||||
<TextBlock x:Name="TextBlockSetUpProcessing" Text="等待安装布署" Foreground="Blue" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="0" Grid.Row="7" Grid.ColumnSpan="4"></TextBlock>
|
<TextBlock x:Name="TextBlockSetUpProcessing" Text="等待安装布署" Foreground="Blue" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="0" Grid.Row="7" Grid.ColumnSpan="4"></TextBlock>
|
||||||
<ProgressBar x:Name="ProgressBarSetUpProcessing" Minimum="0" Maximum="100" Value="0" IsIndeterminate="False" Margin="7" Grid.Column="0" Grid.Row="8" Grid.ColumnSpan="4"></ProgressBar>
|
<ProgressBar x:Name="ProgressBarSetUpProcessing" Minimum="0" Maximum="100" Value="0" IsIndeterminate="False" Margin="7" Grid.Column="0" Grid.Row="8" Grid.ColumnSpan="4"></ProgressBar>
|
||||||
<TabControl Grid.Column="0" Grid.Row="9" Grid.ColumnSpan="4" Grid.RowSpan="2">
|
<TabControl Grid.Column="0" Grid.Row="9" Grid.ColumnSpan="4" Grid.RowSpan="3">
|
||||||
<TabItem Header="V2ray配置" Width="150" Height="30">
|
<TabItem Header="V2ray" Width="100" Height="30">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition></ColumnDefinition>
|
<ColumnDefinition></ColumnDefinition>
|
||||||
@ -118,7 +118,6 @@
|
|||||||
<RowDefinition></RowDefinition>
|
<RowDefinition></RowDefinition>
|
||||||
<RowDefinition></RowDefinition>
|
<RowDefinition></RowDefinition>
|
||||||
<RowDefinition></RowDefinition>
|
<RowDefinition></RowDefinition>
|
||||||
<RowDefinition></RowDefinition>
|
|
||||||
|
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<!--<Button x:Name="ButtonGuideConfiguration" Visibility="Visible" Content="启用向导" Grid.Column="0" Grid.Row="0" Click="ButtonGuideConfiguration_Click"></Button>
|
<!--<Button x:Name="ButtonGuideConfiguration" Visibility="Visible" Content="启用向导" Grid.Column="0" Grid.Row="0" Click="ButtonGuideConfiguration_Click"></Button>
|
||||||
@ -132,9 +131,33 @@
|
|||||||
<RadioButton x:Name="RadioButtonAdvancedConfiguration" Content="高级配置" Grid.Column="0" Grid.Row="2"></RadioButton>
|
<RadioButton x:Name="RadioButtonAdvancedConfiguration" Content="高级配置" Grid.Column="0" Grid.Row="2"></RadioButton>
|
||||||
<TextBox x:Name="TextBoxJsonPath" Margin="10" Grid.Column="1" Grid.Row="1"></TextBox>
|
<TextBox x:Name="TextBoxJsonPath" Margin="10" Grid.Column="1" Grid.Row="1"></TextBox>
|
||||||
<Button x:Name="ButtonSetConfiguration" Margin="6" Content="配置" Grid.Column="2" Grid.Row="2" Click="ButtonSetConfiguration_Click"></Button>-->
|
<Button x:Name="ButtonSetConfiguration" Margin="6" Content="配置" Grid.Column="2" Grid.Row="2" Click="ButtonSetConfiguration_Click"></Button>-->
|
||||||
|
<Button x:Name="Button_Login" Content="V2ray一键安装" Grid.ColumnSpan="1" Margin="10" Grid.Column="0" Grid.Row="2" Click="Button_Login_Click"></Button>
|
||||||
|
<Button x:Name="Button_canel" Content="取消" Grid.ColumnSpan="1" Margin="10" Grid.Column="2" Grid.Row="2" Click="Button_canel_Click"></Button>
|
||||||
</Grid>
|
</Grid>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem Header="系统工具" Width="150" Height="30">
|
<TabItem Header="Trojan" Width="100" Height="30">
|
||||||
|
<Grid>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition></ColumnDefinition>
|
||||||
|
<ColumnDefinition></ColumnDefinition>
|
||||||
|
<ColumnDefinition></ColumnDefinition>
|
||||||
|
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition></RowDefinition>
|
||||||
|
<RowDefinition></RowDefinition>
|
||||||
|
<RowDefinition></RowDefinition>
|
||||||
|
|
||||||
|
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Button x:Name="ButtonTrojanTemplate" Content="Trojan设置" Grid.Column="1" Grid.Row="0" Click="ButtonTrojanTemplate_Click"/>
|
||||||
|
<TextBlock Text="Trojan参数设置" Grid.Column="1" Grid.Row="1" Grid.RowSpan="2" HorizontalAlignment="Center"></TextBlock>
|
||||||
|
|
||||||
|
<Button x:Name="ButtonTrojanSetUp" Content="Trojan一键安装" Grid.ColumnSpan="1" Margin="10" Grid.Column="0" Grid.Row="2" Click="ButtonTrojanSetUp_Click"/>
|
||||||
|
<Button x:Name="ButtonTrojanCancel" Content="取消" Grid.ColumnSpan="1" Margin="10" Grid.Column="2" Grid.Row="2" Click="Button_canel_Click"></Button>
|
||||||
|
</Grid>
|
||||||
|
</TabItem>
|
||||||
|
<TabItem Header="系统工具" Width="100" Height="30">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition></ColumnDefinition>
|
<ColumnDefinition></ColumnDefinition>
|
||||||
@ -179,8 +202,7 @@
|
|||||||
</TabControl>
|
</TabControl>
|
||||||
|
|
||||||
|
|
||||||
<Button x:Name="Button_Login" Content="布署安装" Grid.ColumnSpan="2" Margin="10" Grid.Column="0" Grid.Row="11" Click="Button_Login_Click"></Button>
|
|
||||||
<Button x:Name="Button_canel" Content="取消" Grid.ColumnSpan="2" Margin="10" Grid.Column="2" Grid.Row="11" Click="Button_canel_Click"></Button>
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem Header="资源工具" Width="110" Height="30">
|
<TabItem Header="资源工具" Width="110" Height="30">
|
||||||
|
@ -169,7 +169,7 @@ namespace ProxySU
|
|||||||
//Action<ConnectionInfo, TextBlock> startSetUpAction = new Action<ConnectionInfo, TextBlock>(StartSetUpRemoteHost);
|
//Action<ConnectionInfo, TextBlock> startSetUpAction = new Action<ConnectionInfo, TextBlock>(StartSetUpRemoteHost);
|
||||||
//string serverConfig = TextBoxJsonPath.Text.ToString().Replace("\\","\\\\");
|
//string serverConfig = TextBoxJsonPath.Text.ToString().Replace("\\","\\\\");
|
||||||
//读取模板配置
|
//读取模板配置
|
||||||
//sed -i 's/PermitRootLogin no/PermitRootLogin yes/' /etc/v2ray/config.json
|
|
||||||
string serverConfig=""; //服务端配置文件
|
string serverConfig=""; //服务端配置文件
|
||||||
string clientConfig = ""; //生成的客户端配置文件
|
string clientConfig = ""; //生成的客户端配置文件
|
||||||
string upLoadPath = "/etc/v2ray/config.json"; //服务端文件位置
|
string upLoadPath = "/etc/v2ray/config.json"; //服务端文件位置
|
||||||
@ -254,7 +254,7 @@ namespace ProxySU
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Thread thread
|
//Thread thread
|
||||||
Thread thread = new Thread(() => StartSetUpRemoteHost(connectionInfo, TextBlockSetUpProcessing, ProgressBarSetUpProcessing, serverConfig, clientConfig, upLoadPath));
|
Thread thread = new Thread(() => StartSetUpV2ray(connectionInfo, TextBlockSetUpProcessing, ProgressBarSetUpProcessing, serverConfig, clientConfig, upLoadPath));
|
||||||
thread.SetApartmentState(ApartmentState.STA);
|
thread.SetApartmentState(ApartmentState.STA);
|
||||||
thread.Start();
|
thread.Start();
|
||||||
// Task task = new Task(() => StartSetUpRemoteHost(connectionInfo, TextBlockSetUpProcessing, ProgressBarSetUpProcessing, serverConfig, clientConfig, upLoadPath));
|
// Task task = new Task(() => StartSetUpRemoteHost(connectionInfo, TextBlockSetUpProcessing, ProgressBarSetUpProcessing, serverConfig, clientConfig, upLoadPath));
|
||||||
@ -408,8 +408,8 @@ namespace ProxySU
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
//登录远程主机布署程序
|
//登录远程主机布署V2ray程序
|
||||||
private void StartSetUpRemoteHost(ConnectionInfo connectionInfo,TextBlock textBlockName, ProgressBar progressBar, string serverConfig,string clientConfig,string upLoadPath)
|
private void StartSetUpV2ray(ConnectionInfo connectionInfo,TextBlock textBlockName, ProgressBar progressBar, string serverConfig,string clientConfig,string upLoadPath)
|
||||||
{
|
{
|
||||||
string currentStatus = "正在登录远程主机......";
|
string currentStatus = "正在登录远程主机......";
|
||||||
Action<TextBlock, ProgressBar, string> updateAction = new Action<TextBlock, ProgressBar, string>(UpdateTextBlock);
|
Action<TextBlock, ProgressBar, string> updateAction = new Action<TextBlock, ProgressBar, string>(UpdateTextBlock);
|
||||||
@ -800,7 +800,7 @@ namespace ProxySU
|
|||||||
//设置Caddyfile文件中的tls 邮箱
|
//设置Caddyfile文件中的tls 邮箱
|
||||||
//string sshCmdEmail = $"email={ReceiveConfigurationParameters[4]};email=${{email/./@}};echo $email";//结尾有回车符
|
//string sshCmdEmail = $"email={ReceiveConfigurationParameters[4]};email=${{email/./@}};echo $email";//结尾有回车符
|
||||||
//string email = client.RunCommand(sshCmdEmail).Result.Replace("\n", "");//删除结尾的回车符
|
//string email = client.RunCommand(sshCmdEmail).Result.Replace("\n", "");//删除结尾的回车符
|
||||||
string email = $"admin@{ReceiveConfigurationParameters[4]}";
|
string email = $"user@{ReceiveConfigurationParameters[4]}";
|
||||||
string sshCmd = $"sed -i 's/off/{email}/' {upLoadPath}";//设置Caddyfile中的邮箱
|
string sshCmd = $"sed -i 's/off/{email}/' {upLoadPath}";//设置Caddyfile中的邮箱
|
||||||
client.RunCommand(sshCmd);
|
client.RunCommand(sshCmd);
|
||||||
//设置Path
|
//设置Path
|
||||||
@ -883,9 +883,9 @@ namespace ProxySU
|
|||||||
currentStatus = "生成客户端配置......";
|
currentStatus = "生成客户端配置......";
|
||||||
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
Thread.Sleep(1000);
|
Thread.Sleep(1000);
|
||||||
if (!Directory.Exists("config"))//如果不存在就创建file文件夹
|
if (!Directory.Exists("v2ray_config"))//如果不存在就创建file文件夹
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory("config");//创建该文件夹
|
Directory.CreateDirectory("v2ray_config");//创建该文件夹
|
||||||
}
|
}
|
||||||
//string clientConfig = "TemplateConfg\\tcp_client_config.json";
|
//string clientConfig = "TemplateConfg\\tcp_client_config.json";
|
||||||
using (StreamReader reader = File.OpenText(clientConfig))
|
using (StreamReader reader = File.OpenText(clientConfig))
|
||||||
@ -918,7 +918,7 @@ namespace ProxySU
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
using (StreamWriter sw = new StreamWriter(@"config\config.json"))
|
using (StreamWriter sw = new StreamWriter(@"v2ray_config\config.json"))
|
||||||
{
|
{
|
||||||
sw.Write(clientJson.ToString());
|
sw.Write(clientJson.ToString());
|
||||||
}
|
}
|
||||||
@ -975,6 +975,7 @@ namespace ProxySU
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//上传配置文件
|
//上传配置文件
|
||||||
private void UploadConfig(ConnectionInfo connectionInfo,string uploadConfig,string upLoadPath)
|
private void UploadConfig(ConnectionInfo connectionInfo,string uploadConfig,string upLoadPath)
|
||||||
{
|
{
|
||||||
@ -999,6 +1000,7 @@ namespace ProxySU
|
|||||||
MessageBox.Show("sftp出现未知错误");
|
MessageBox.Show("sftp出现未知错误");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//下载配置文件
|
//下载配置文件
|
||||||
private void DownloadConfig(ConnectionInfo connectionInfo, string downloadConfig,string downloadPath)
|
private void DownloadConfig(ConnectionInfo connectionInfo, string downloadConfig,string downloadPath)
|
||||||
{
|
{
|
||||||
@ -1110,7 +1112,7 @@ namespace ProxySU
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//打开模板设置窗口
|
//打开v2ray模板设置窗口
|
||||||
private void ButtonTemplateConfiguration_Click(object sender, RoutedEventArgs e)
|
private void ButtonTemplateConfiguration_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
//清空初始化模板参数
|
//清空初始化模板参数
|
||||||
@ -1185,15 +1187,15 @@ namespace ProxySU
|
|||||||
MessageBox.Show(ex.Message);
|
MessageBox.Show(ex.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void ButtonGuideConfiguration_Click(object sender, RoutedEventArgs e)
|
//private void ButtonGuideConfiguration_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
//{
|
||||||
MessageBox.Show("尚未完善,敬请期待");
|
// MessageBox.Show("尚未完善,敬请期待");
|
||||||
}
|
//}
|
||||||
|
|
||||||
private void ButtonAdvancedConfiguration_Click(object sender, RoutedEventArgs e)
|
//private void ButtonAdvancedConfiguration_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
//{
|
||||||
MessageBox.Show("尚未完善,敬请期待");
|
// MessageBox.Show("尚未完善,敬请期待");
|
||||||
}
|
//}
|
||||||
|
|
||||||
private void ButtonWebBrowserBack_Click(object sender, RoutedEventArgs e)
|
private void ButtonWebBrowserBack_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
@ -1231,213 +1233,528 @@ namespace ProxySU
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//private void Button_Click(object sender, RoutedEventArgs e)
|
|
||||||
//{
|
|
||||||
// string[] testString = new string[6];
|
|
||||||
// for (int i = 0; i != testString.Length; i++)
|
|
||||||
|
|
||||||
// {
|
//打开Trojan参数设置界面
|
||||||
|
private void ButtonTrojanTemplate_Click(object sender, RoutedEventArgs e)
|
||||||
// testString[i] = i.ToString();
|
|
||||||
|
|
||||||
// }
|
|
||||||
// foreach (string str in testString)
|
|
||||||
// {
|
|
||||||
// MessageBox.Show(str);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
private void Button_Click_1(object sender, RoutedEventArgs e)
|
|
||||||
{
|
{
|
||||||
for (int i = 0; i != ReceiveConfigurationParameters.Length; i++)
|
for (int i = 0; i != ReceiveConfigurationParameters.Length; i++)
|
||||||
|
|
||||||
{
|
{
|
||||||
MessageBox.Show(ReceiveConfigurationParameters[i]);
|
ReceiveConfigurationParameters[i] = "";
|
||||||
|
}
|
||||||
|
TrojanTemplateWindow windowTrojanTemplateConfiguration = new TrojanTemplateWindow();
|
||||||
|
windowTrojanTemplateConfiguration.ShowDialog();
|
||||||
|
}
|
||||||
|
//Trojan一键安装
|
||||||
|
private void ButtonTrojanSetUp_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
ConnectionInfo connectionInfo = GenerateConnectionInfo();
|
||||||
|
if (connectionInfo == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("远程主机连接信息有误,请检查");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
string serverConfig = ""; //服务端配置文件
|
||||||
|
string clientConfig = ""; //生成的客户端配置文件
|
||||||
|
string upLoadPath = "/usr/local/etc/trojan/config.json"; //服务端文件位置
|
||||||
|
if (String.IsNullOrEmpty(ReceiveConfigurationParameters[4]) == true)
|
||||||
|
{
|
||||||
|
ReceiveConfigurationParameters[4] = TextBoxHost.Text.ToString();
|
||||||
|
}
|
||||||
|
if (String.IsNullOrEmpty(ReceiveConfigurationParameters[0]) == true)
|
||||||
|
{
|
||||||
|
MessageBox.Show("请先选择配置模板!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (String.Equals(ReceiveConfigurationParameters[0], "TrojanTLS2Web"))
|
||||||
|
{
|
||||||
|
serverConfig = "TemplateConfg\\trojan_server_config.json";
|
||||||
|
clientConfig = "TemplateConfg\\trojan_client_config.json";
|
||||||
|
}
|
||||||
|
Thread thread = new Thread(() => StartSetUpTrojan(connectionInfo, TextBlockSetUpProcessing, ProgressBarSetUpProcessing, serverConfig, clientConfig, upLoadPath));
|
||||||
|
thread.SetApartmentState(ApartmentState.STA);
|
||||||
|
thread.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
//登录远程主机布署Trojan程序
|
||||||
|
private void StartSetUpTrojan(ConnectionInfo connectionInfo, TextBlock textBlockName, ProgressBar progressBar, string serverConfig, string clientConfig, string upLoadPath)
|
||||||
|
{
|
||||||
|
string currentStatus = "正在登录远程主机......";
|
||||||
|
Action<TextBlock, ProgressBar, string> updateAction = new Action<TextBlock, ProgressBar, string>(UpdateTextBlock);
|
||||||
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, 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)
|
||||||
|
{
|
||||||
|
currentStatus = "主机登录成功";
|
||||||
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
}
|
||||||
|
//检测是否安装有Trojan
|
||||||
|
currentStatus = "检测系统是否已经安装V2ray......";
|
||||||
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
|
||||||
|
//string cmdTestTrojanInstalled = @"find / -name trojan";
|
||||||
|
string resultCmdTestTrojanInstalled = client.RunCommand(@"find / -name trojan").Result;
|
||||||
|
|
||||||
|
if (resultCmdTestTrojanInstalled.Contains("/usr/local/bin/trojan") == true)
|
||||||
|
{
|
||||||
|
MessageBoxResult messageBoxResult = MessageBox.Show("远程主机已安装Trojan,是否强制重新安装?", "", MessageBoxButton.YesNo, MessageBoxImage.Question);
|
||||||
|
if (messageBoxResult == MessageBoxResult.No)
|
||||||
|
{
|
||||||
|
currentStatus = "安装取消,退出";
|
||||||
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//private void TestresultClientInform_Click(object sender, RoutedEventArgs e)
|
//检测远程主机系统环境是否符合要求
|
||||||
//{
|
currentStatus = "检测系统是否符合安装要求......";
|
||||||
// ResultClientInformation resultClientInformation = new ResultClientInformation();
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
// resultClientInformation.ShowDialog();
|
Thread.Sleep(1000);
|
||||||
//}
|
|
||||||
|
|
||||||
//private void TestPortOccupy_Click(object sender, RoutedEventArgs e)
|
string resultCmd = client.RunCommand("uname -m").Result;
|
||||||
//{
|
//var result = client.RunCommand("cat /root/test.ver");
|
||||||
// MessageBoxResult dialogResult = MessageBox.Show("将强制停止占用80/443端口的程序?", "Stop application", MessageBoxButton.YesNo);
|
//string[] linuxKernelVerStr = resultCmd.Split('-');
|
||||||
// if (dialogResult == MessageBoxResult.No)
|
|
||||||
// {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// ConnectionInfo testconnect = GenerateConnectionInfo();
|
|
||||||
// using (var client = new SshClient(testconnect))
|
|
||||||
// {
|
|
||||||
// client.Connect();
|
|
||||||
// string cmdTestPort = @"lsof -n -P -i :443 | grep LISTEN";
|
|
||||||
// MessageBox.Show(cmdTestPort);
|
|
||||||
// string cmdResult = client.RunCommand(cmdTestPort).Result;
|
|
||||||
// client.Disconnect();
|
|
||||||
// MessageBox.Show(cmdResult);
|
|
||||||
// string[] cmdResultArry = cmdResult.Split(' ');
|
|
||||||
// //foreach(string arry in cmdResultArry)
|
|
||||||
// //{
|
|
||||||
// // MessageBox.Show(arry);
|
|
||||||
// //}
|
|
||||||
// MessageBox.Show(cmdResultArry[0]);//程序名字
|
|
||||||
// MessageBox.Show(cmdResultArry[3]);//程序PID
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
//private void TestInstalledV2ray_Click(object sender, RoutedEventArgs e)
|
//bool detectResult = DetectKernelVersion(linuxKernelVerStr[0]);
|
||||||
//{
|
|
||||||
// ConnectionInfo testconnect = GenerateConnectionInfo();
|
|
||||||
// using (var client = new SshClient(testconnect))
|
|
||||||
// {
|
|
||||||
// client.Connect();
|
|
||||||
// //string cmdTestPort = @"find / -name v2ray";
|
|
||||||
// //MessageBox.Show(cmdTestPort);
|
|
||||||
// //string cmdResult = client.RunCommand(cmdTestPort).Result;
|
|
||||||
// //设置Caddyfile文件中的tls 邮箱
|
|
||||||
// string upLoadPath = "/etc/caddy/Caddyfile.test";
|
|
||||||
// string emailAddress = ReceiveConfigurationParameters[4];
|
|
||||||
// string sshCmdEmail = $"email={emailAddress};email=${{email/./@}};echo $email";//结尾有回车符
|
|
||||||
// string email = client.RunCommand(sshCmdEmail).Result.Replace("\n","");
|
|
||||||
// MessageBox.Show(email);
|
|
||||||
// string sshCmd = $"sed -i 's/off/{email}/' {upLoadPath}";
|
|
||||||
|
|
||||||
// MessageBox.Show(sshCmd);
|
if (resultCmd.Contains("x86_64") == false)
|
||||||
// client.RunCommand(sshCmd);
|
{
|
||||||
// sshCmd = $"sed -i 's/##path##/\\{ReceiveConfigurationParameters[3]}/' {upLoadPath}";
|
MessageBox.Show($"请在x86_64系统中安装Trojan");
|
||||||
// MessageBox.Show(sshCmd);
|
currentStatus = "系统不符合要求,安装失败!!";
|
||||||
// client.RunCommand(sshCmd);
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
// //sshCmd = "sed -i 's/##path##/\\" + ReceiveConfigurationParameters[3] + "/' " + upLoadPath;
|
Thread.Sleep(1000);
|
||||||
// //MessageBox.Show(sshCmd);
|
}
|
||||||
// //client.RunCommand("sed -i 's/##path##/\\" + ReceiveConfigurationParameters[3] + "/' " + upLoadPath);
|
|
||||||
// sshCmd = $"sed -i 's/##domain##/{ReceiveConfigurationParameters[4]}/' {upLoadPath}";
|
|
||||||
// MessageBox.Show(sshCmd);
|
|
||||||
// client.RunCommand(sshCmd);
|
|
||||||
// //client.RunCommand("sed -i 's/##domain##/" + ReceiveConfigurationParameters[4] + "/' " + upLoadPath);
|
|
||||||
// if (String.IsNullOrEmpty(ReceiveConfigurationParameters[7]) == false)
|
|
||||||
// {
|
|
||||||
// sshCmd = $"sed -i 's/##sites##/proxy \\/ {ReceiveConfigurationParameters[7]}/' {upLoadPath}";
|
|
||||||
// //client.RunCommand("sed -i 's/##sites##/proxy \\/ " + ReceiveConfigurationParameters[7] + "/' " + upLoadPath);
|
|
||||||
// MessageBox.Show(sshCmd);
|
|
||||||
// client.RunCommand(sshCmd);
|
|
||||||
// }
|
|
||||||
// Thread.Sleep(2000);
|
|
||||||
|
|
||||||
// //生成安装服务命令中的邮箱
|
//检测系统是否支持yum 或 apt-get或zypper,且支持Systemd
|
||||||
// //string sshCmdEmail = $"email={emailAddress};email=${{email/./@}};echo $email";
|
//如果不存在组件,则命令结果为空,string.IsNullOrEmpty值为真,
|
||||||
// //string email = client.RunCommand(sshCmdEmail).Result.ToString();
|
bool getApt = String.IsNullOrEmpty(client.RunCommand("command -v apt-get").Result);
|
||||||
|
bool getYum = String.IsNullOrEmpty(client.RunCommand("command -v yum").Result);
|
||||||
|
bool getZypper = String.IsNullOrEmpty(client.RunCommand("command -v zypper").Result);
|
||||||
|
bool getSystemd = String.IsNullOrEmpty(client.RunCommand("command -v systemctl").Result);
|
||||||
|
bool getGetenforce = String.IsNullOrEmpty(client.RunCommand("command -v getenforce").Result);
|
||||||
|
|
||||||
// //MessageBox.Show(email);
|
//没有安装apt-get,也没有安装yum,也没有安装zypper,或者没有安装systemd的,不满足安装条件
|
||||||
|
//也就是apt-get ,yum, zypper必须安装其中之一,且必须安装Systemd的系统才能安装。
|
||||||
|
if ((getApt && getYum && getZypper) || getSystemd)
|
||||||
|
{
|
||||||
|
MessageBox.Show($"系统缺乏必要的安装组件如:apt-get||yum||zypper||Syetemd,主机系统推荐使用:CentOS 7/8,Debian 8/9/10,Ubuntu 16.04及以上版本");
|
||||||
|
currentStatus = "系统环境不满足要求,安装失败!!";
|
||||||
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//判断是否启用了SELinux,如果启用了,并且工作在Enforcing模式下,则改为Permissive模式
|
||||||
|
if (getGetenforce == false)
|
||||||
|
{
|
||||||
|
string testSELinux = client.RunCommand("getenforce").Result;
|
||||||
|
//MessageBox.Show(testSELinux);
|
||||||
|
if (testSELinux.Contains("Enforcing") == true)
|
||||||
|
{
|
||||||
|
//MessageBox.Show("Enforcing");
|
||||||
|
client.RunCommand("setenforce 0");//不重启改为Permissive模式
|
||||||
|
client.RunCommand("sed -i 's/SELINUX=enforcing/SELINUX=permissive/' /etc/selinux/config");//重启也工作在Permissive模式下
|
||||||
|
}
|
||||||
|
|
||||||
// //安装Caddy服务
|
}
|
||||||
// //sshCmd = "caddy -service install -agree -conf /etc/caddy/Caddyfile -email " + email;
|
|
||||||
// sshCmd = $"caddy -service install -agree -conf /etc/caddy/Caddyfile -email {email}";
|
//如果使用如果是WebSocket + TLS + Web/http2/Http2Web/tcp_TLS/WebSocket_TLS模式,需要检测域名解析是否正确
|
||||||
|
if (serverConfig.Contains("trojan_server") == true)
|
||||||
|
{
|
||||||
|
currentStatus = "正在检测域名是否解析到当前VPS的IP上......";
|
||||||
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
|
||||||
|
//在相应系统内安装curl(如果没有安装curl)
|
||||||
|
if (string.IsNullOrEmpty(client.RunCommand("command -v curl").Result) == true)
|
||||||
|
{
|
||||||
|
//为假则表示系统有相应的组件。
|
||||||
|
if (getApt == false)
|
||||||
|
{
|
||||||
|
client.RunCommand("apt-get -qq update");
|
||||||
|
client.RunCommand("apt-get -y -qq install curl");
|
||||||
|
}
|
||||||
|
if (getYum == false)
|
||||||
|
{
|
||||||
|
client.RunCommand("yum -q makecache");
|
||||||
|
client.RunCommand("yum -y -q install curl");
|
||||||
|
}
|
||||||
|
if (getZypper == false)
|
||||||
|
{
|
||||||
|
client.RunCommand("zypper ref");
|
||||||
|
client.RunCommand("zypper -y install curl");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
string nativeIp = client.RunCommand("curl -4 ip.sb").Result.ToString();
|
||||||
|
string testDomainCmd = "ping " + ReceiveConfigurationParameters[4] + " -c 1 | grep -oE -m1 \"([0-9]{1,3}\\.){3}[0-9]{1,3}\"";
|
||||||
|
string resultTestDomainCmd = client.RunCommand(testDomainCmd).Result.ToString();
|
||||||
|
|
||||||
|
if (String.Equals(nativeIp, resultCmd) == true)
|
||||||
|
{
|
||||||
|
currentStatus = "解析正确!";
|
||||||
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
currentStatus = "域名未能正确解析到当前VPS的IP上!安装失败!";
|
||||||
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
MessageBox.Show("域名未能正确解析到当前VPS的IP上,请检查!若解析设置正确,请等待生效后再重试安装。如果域名使用了CDN,请先关闭!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if (serverConfig.Contains("trojan_server") == true)
|
||||||
|
{
|
||||||
|
//检测是否安装lsof
|
||||||
|
if (string.IsNullOrEmpty(client.RunCommand("command -v lsof").Result) == true)
|
||||||
|
{
|
||||||
|
//为假则表示系统有相应的组件。
|
||||||
|
if (getApt == false)
|
||||||
|
{
|
||||||
|
client.RunCommand("apt-get -qq update");
|
||||||
|
client.RunCommand("apt-get -y -qq install lsof");
|
||||||
|
}
|
||||||
|
if (getYum == false)
|
||||||
|
{
|
||||||
|
client.RunCommand("yum -q makecache");
|
||||||
|
client.RunCommand("yum -y -q install lsof");
|
||||||
|
}
|
||||||
|
if (getZypper == false)
|
||||||
|
{
|
||||||
|
client.RunCommand("zypper ref");
|
||||||
|
client.RunCommand("zypper -y install lsof");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
currentStatus = "正在检测端口占用情况......";
|
||||||
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
//MessageBox.Show(@"lsof -n -P -i :80 | grep LISTEN");
|
||||||
|
//MessageBox.Show(client.RunCommand(@"lsof -n -P -i :80 | grep LISTEN").Result);
|
||||||
|
if (String.IsNullOrEmpty(client.RunCommand(@"lsof -n -P -i :80 | grep LISTEN").Result) == false || String.IsNullOrEmpty(client.RunCommand(@"lsof -n -P -i :443 | grep LISTEN").Result) == false)
|
||||||
|
{
|
||||||
|
MessageBox.Show("80/443端口之一,或全部被占用,请先用系统工具中的“释放80/443端口”工具,释放出,再重新安装");
|
||||||
|
currentStatus = "端口被占用,安装失败......";
|
||||||
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
currentStatus = "符合安装要求,布署中......";
|
||||||
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
|
||||||
|
//在相应系统内安装curl(如果没有安装curl)
|
||||||
|
if (string.IsNullOrEmpty(client.RunCommand("command -v curl").Result) == true)
|
||||||
|
{
|
||||||
|
//为假则表示系统有相应的组件。
|
||||||
|
if (getApt == false)
|
||||||
|
{
|
||||||
|
client.RunCommand("apt-get -qq update");
|
||||||
|
client.RunCommand("apt-get -y -qq install curl");
|
||||||
|
}
|
||||||
|
if (getYum == false)
|
||||||
|
{
|
||||||
|
client.RunCommand("yum -q makecache");
|
||||||
|
client.RunCommand("yum -y -q install curl");
|
||||||
|
}
|
||||||
|
if (getZypper == false)
|
||||||
|
{
|
||||||
|
client.RunCommand("zypper ref");
|
||||||
|
client.RunCommand("zypper -y install curl");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// client.Disconnect();
|
//下载官方安装脚本安装
|
||||||
// //MessageBox.Show(cmdResult);
|
|
||||||
// //if (cmdResult.Contains("/usr/bin/v2ray")==true)
|
|
||||||
// //{
|
|
||||||
// // MessageBox.Show("已安装");
|
|
||||||
// //}
|
|
||||||
// //else
|
|
||||||
// //{
|
|
||||||
// // MessageBox.Show("未安装");
|
|
||||||
// //}
|
|
||||||
// //string[] cmdResultArry = cmdResult.Split('\n');
|
|
||||||
// //foreach(string arry in cmdResultArry)
|
|
||||||
// //{
|
|
||||||
// // MessageBox.Show(arry);
|
|
||||||
// //}
|
|
||||||
// //MessageBox.Show(cmdResultArry[0]);//程序名字
|
|
||||||
// //MessageBox.Show(cmdResultArry[3]);//程序PID
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
//private void TestsshCmd_Click(object sender, RoutedEventArgs e)
|
client.RunCommand("bash -c \"$(curl - fsSL https://raw.githubusercontent.com/trojan-gfw/trojan-quickstart/master/trojan-quickstart.sh)\"");
|
||||||
//{
|
//client.RunCommand("bash /tmp/go.sh -f");
|
||||||
// ReceiveConfigurationParameters[3] = "https://tes.te.tt";
|
string installResult = client.RunCommand("find / -name trojan").Result.ToString();
|
||||||
// ReceiveConfigurationParameters[7] = "http://77.77.77";
|
|
||||||
// string upLoadPath = "/etc/caddy/Caddyfile";
|
if (!installResult.Contains("/usr/local/bin/trojan"))
|
||||||
// string sshCmd = $"sed -i 's/##path##/\\{ReceiveConfigurationParameters[3]}/' {upLoadPath}";
|
{
|
||||||
// //MessageBox.Show(sshCmd);
|
MessageBox.Show("安装Trojan失败(官方脚本运行出错!");
|
||||||
// //sshCmd = "sed -i 's/##path##/\\" + ReceiveConfigurationParameters[3] + "/' " + upLoadPath;
|
client.Disconnect();
|
||||||
// //MessageBox.Show(sshCmd);
|
currentStatus = "安装Trojan失败(官方脚本运行出错!";
|
||||||
// //sshCmd = $"sed -i 's/##path##/\\{ReceiveConfigurationParameters[3]}/' {upLoadPath}";
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
// //MessageBox.Show(sshCmd);
|
return;
|
||||||
// //sshCmd = "sed -i 's/##path##/\\" + ReceiveConfigurationParameters[3] + "/' " + upLoadPath;
|
}
|
||||||
// //MessageBox.Show(sshCmd);
|
client.RunCommand("mv /usr/local/etc/trojan/config.json /usr/local/etc/trojan/config.json.1");
|
||||||
// //client.RunCommand("sed -i 's/##path##/\\" + ReceiveConfigurationParameters[3] + "/' " + upLoadPath);
|
|
||||||
// sshCmd = $"sed -i 's/##domain##/{ReceiveConfigurationParameters[4]}/' {upLoadPath}";
|
//上传配置文件
|
||||||
// MessageBox.Show(sshCmd);
|
currentStatus = "Trojan程序安装完毕,配置文件上传中......";
|
||||||
// string testDomain = ReceiveConfigurationParameters[7].Substring(0,7);
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
// if (String.Equals(testDomain,"https:/")||String.Equals(testDomain,"http://"))
|
Thread.Sleep(1000);
|
||||||
// {
|
|
||||||
// MessageBox.Show(testDomain);
|
//生成服务端配置
|
||||||
// ReceiveConfigurationParameters[7]=ReceiveConfigurationParameters[7].Replace("/","\\/");
|
using (StreamReader reader = File.OpenText(serverConfig))
|
||||||
// }
|
{
|
||||||
// else
|
JObject serverJson = (JObject)JToken.ReadFrom(new JsonTextReader(reader));
|
||||||
// {
|
//设置密码
|
||||||
// ReceiveConfigurationParameters[7] = "http:\\/\\/" + ReceiveConfigurationParameters[7];
|
serverJson["password"][0] = ReceiveConfigurationParameters[2];
|
||||||
// }
|
//设置监听端口
|
||||||
// sshCmd = $"sed -i 's/##sites##/proxy \\/ {ReceiveConfigurationParameters[7]}/' {upLoadPath}";
|
//serverJson["inbounds"][0]["port"] = int.Parse(ReceiveConfigurationParameters[1]);
|
||||||
// MessageBox.Show(sshCmd);
|
|
||||||
//}
|
using (StreamWriter sw = new StreamWriter(@"config.json"))
|
||||||
|
{
|
||||||
|
sw.Write(serverJson.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
UploadConfig(connectionInfo, @"config.json", upLoadPath);
|
||||||
|
|
||||||
|
File.Delete(@"config.json");
|
||||||
|
|
||||||
|
//打开防火墙端口
|
||||||
|
string openFireWallPort = ReceiveConfigurationParameters[1];
|
||||||
|
if (String.IsNullOrEmpty(client.RunCommand("command -v firewall-cmd").Result) == false)
|
||||||
|
{
|
||||||
|
if (String.Equals(openFireWallPort, "443"))
|
||||||
|
{
|
||||||
|
client.RunCommand("firewall-cmd --zone=public --add-port=80/tcp --permanent");
|
||||||
|
client.RunCommand("firewall-cmd --zone=public --add-port=443/tcp --permanent");
|
||||||
|
client.RunCommand("firewall-cmd --reload");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
client.RunCommand($"firewall-cmd --zone=public --add-port={openFireWallPort}/tcp --permanent");
|
||||||
|
client.RunCommand($"firewall-cmd --zone=public --add-port={openFireWallPort}/udp --permanent");
|
||||||
|
client.RunCommand("firewall-cmd --reload");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (String.IsNullOrEmpty(client.RunCommand("command -v ufw").Result) == false)
|
||||||
|
{
|
||||||
|
if (String.Equals(openFireWallPort, "443"))
|
||||||
|
{
|
||||||
|
client.RunCommand("ufw allow 80");
|
||||||
|
client.RunCommand("ufw allow 443");
|
||||||
|
client.RunCommand("ufw reset");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
client.RunCommand($"ufw allow {openFireWallPort}/tcp");
|
||||||
|
client.RunCommand($"ufw allow {openFireWallPort}/udp");
|
||||||
|
client.RunCommand("ufw reset");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//安装nginx
|
||||||
|
if (serverConfig.Contains("trojan_server") == true)
|
||||||
|
{
|
||||||
|
currentStatus = "正在安装Caddy";
|
||||||
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
|
||||||
|
client.RunCommand("curl https://getcaddy.com -o getcaddy");
|
||||||
|
client.RunCommand("bash getcaddy personal hook.service");
|
||||||
|
client.RunCommand("mkdir -p /etc/caddy");
|
||||||
|
client.RunCommand("mkdir -p /var/www");
|
||||||
|
|
||||||
|
|
||||||
|
currentStatus = "上传Caddy配置文件......";
|
||||||
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
if (serverConfig.Contains("trojan_server") == true)
|
||||||
|
{
|
||||||
|
serverConfig = "TemplateConfg\\trojan_caddy_config.caddyfile";
|
||||||
|
}
|
||||||
|
|
||||||
//private void Button_Click(object sender, RoutedEventArgs e)
|
upLoadPath = "/etc/caddy/Caddyfile";
|
||||||
//{
|
UploadConfig(connectionInfo, serverConfig, upLoadPath);
|
||||||
// ConnectionInfo testconnect = GenerateConnectionInfo();
|
|
||||||
// using (var client = new SshClient(testconnect))
|
|
||||||
// {
|
|
||||||
// client.Connect();
|
|
||||||
// bool getGetenforce = String.IsNullOrEmpty(client.RunCommand("command -v getenforce").Result);
|
|
||||||
|
|
||||||
// if (getGetenforce == false)
|
//设置Caddyfile文件中的tls 邮箱
|
||||||
// {
|
//string sshCmdEmail = $"email={ReceiveConfigurationParameters[4]};email=${{email/./@}};echo $email";//结尾有回车符
|
||||||
// string testSELinux = client.RunCommand("getenforce").Result;
|
//string email = client.RunCommand(sshCmdEmail).Result.Replace("\n", "");//删除结尾的回车符
|
||||||
// MessageBox.Show(testSELinux);
|
string email = $"user@{ReceiveConfigurationParameters[4]}";
|
||||||
// if (testSELinux.Contains("Enforcing") == true)
|
string sshCmd;// = $"sed -i 's/off/{email}/' {upLoadPath}";//设置Caddyfile中的邮箱
|
||||||
// {
|
//client.RunCommand(sshCmd);
|
||||||
// MessageBox.Show("Enforcing");
|
//设置Path
|
||||||
// client.RunCommand("setenforce 0");//不重启改为Permissive模式
|
//sshCmd = $"sed -i 's/##path##/\\{ReceiveConfigurationParameters[3]}/' {upLoadPath}";
|
||||||
// client.RunCommand("sed -i 's/SELINUX=enforcing/SELINUX=permissive/' /etc/selinux/config");//重启也工作在Permissive模式下
|
//MessageBox.Show(sshCmd);
|
||||||
// }
|
//client.RunCommand(sshCmd);
|
||||||
// else
|
//设置域名
|
||||||
// {
|
sshCmd = $"sed -i 's/##domain##/{ReceiveConfigurationParameters[4]}/' {upLoadPath}";
|
||||||
// MessageBox.Show("非Enforcing");
|
//MessageBox.Show(sshCmd);
|
||||||
// }
|
client.RunCommand(sshCmd);
|
||||||
// }
|
//设置伪装网站
|
||||||
// client.Disconnect();
|
if (String.IsNullOrEmpty(ReceiveConfigurationParameters[7]) == false)
|
||||||
// }
|
{
|
||||||
//}
|
sshCmd = $"sed -i 's/##sites##/proxy \\/ {ReceiveConfigurationParameters[7]}/' {upLoadPath}";
|
||||||
//private void ButtonWebBrowserProxyGo_Click(object sender, RoutedEventArgs e)
|
//MessageBox.Show(sshCmd);
|
||||||
//{
|
client.RunCommand(sshCmd);
|
||||||
// try
|
}
|
||||||
// {
|
Thread.Sleep(2000);
|
||||||
// string urlStartchar = TextBoxWebBrowserProxyUrl.Text.Substring(0, 4);
|
|
||||||
// //MessageBox.Show(urlStartchar);
|
|
||||||
// if (String.Equals(urlStartchar,"http")==true)
|
|
||||||
// {
|
|
||||||
// WebBrowserResourcesAndTools.Source = new Uri(TextBoxWebBrowserProxyUrl.Text);
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// WebBrowserResourcesAndTools.Source = new Uri("http://" + TextBoxWebBrowserProxyUrl.Text);//如果没有前置代理,此处应为:"http://" + TextBoxWebBrowserProxyUrl.Text
|
|
||||||
// }
|
|
||||||
|
|
||||||
// }
|
//安装Caddy服务
|
||||||
// catch (Exception ex)
|
sshCmd = $"caddy -service install -agree -conf /etc/caddy/Caddyfile -email {email}";
|
||||||
// {
|
//MessageBox.Show(sshCmd);
|
||||||
// MessageBox.Show(ex.Message);
|
client.RunCommand(sshCmd);
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
|
//启动Caddy服务
|
||||||
|
client.RunCommand("caddy -service restart");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (serverConfig.Contains("trojan_server") == true)
|
||||||
|
{
|
||||||
|
currentStatus = "使用Trojan+TLS+Web模式,正在安装acme.sh......";
|
||||||
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
|
||||||
|
if (getApt == false)
|
||||||
|
{
|
||||||
|
//client.RunCommand("apt-get -qq update");
|
||||||
|
client.RunCommand("apt-get -y -qq install socat");
|
||||||
|
}
|
||||||
|
if (getYum == false)
|
||||||
|
{
|
||||||
|
//client.RunCommand("yum -q makecache");
|
||||||
|
client.RunCommand("yum -y -q install socat");
|
||||||
|
}
|
||||||
|
if (getZypper == false)
|
||||||
|
{
|
||||||
|
// client.RunCommand("zypper ref");
|
||||||
|
client.RunCommand("zypper -y install socat");
|
||||||
|
}
|
||||||
|
client.RunCommand("curl https://raw.githubusercontent.com/acmesh-official/acme.sh/master/acme.sh | INSTALLONLINE=1 sh");
|
||||||
|
client.RunCommand("cd ~/.acme.sh/");
|
||||||
|
client.RunCommand("alias acme.sh=~/.acme.sh/acme.sh");
|
||||||
|
|
||||||
|
currentStatus = "申请域名证书......";
|
||||||
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
|
||||||
|
//client.RunCommand("mkdir -p /etc/v2ray/ssl");
|
||||||
|
client.RunCommand($"/root/.acme.sh/acme.sh --issue --standalone -d {ReceiveConfigurationParameters[4]}");
|
||||||
|
|
||||||
|
currentStatus = "安装证书到V2ray......";
|
||||||
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
client.RunCommand($"/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\"");
|
||||||
|
}
|
||||||
|
|
||||||
|
currentStatus = "正在启动Trojan......";
|
||||||
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
//启动V2ray服务
|
||||||
|
client.RunCommand("systemctl restart trojan");
|
||||||
|
|
||||||
|
currentStatus = "Trojan启动成功!";
|
||||||
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
|
||||||
|
|
||||||
|
//生成客户端配置
|
||||||
|
currentStatus = "生成客户端配置......";
|
||||||
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
if (!Directory.Exists("trojan_config"))//如果不存在就创建file文件夹
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory("trojan_config");//创建该文件夹
|
||||||
|
}
|
||||||
|
//string clientConfig = "TemplateConfg\\tcp_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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
client.Disconnect();
|
||||||
|
|
||||||
|
currentStatus = "安装成功";
|
||||||
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
|
||||||
|
//显示服务端连接参数
|
||||||
|
//MessageBox.Show("用于V2ray官方客户端的配置文件已保存在config文件夹中");
|
||||||
|
TrojanResultClientInfoWindow resultClientInformation = new TrojanResultClientInfoWindow();
|
||||||
|
resultClientInformation.ShowDialog();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex1)//例外处理
|
||||||
|
#region 例外处理
|
||||||
|
{
|
||||||
|
//MessageBox.Show(ex1.Message);
|
||||||
|
if (ex1.Message.Contains("连接尝试失败") == true)
|
||||||
|
{
|
||||||
|
MessageBox.Show($"{ex1.Message}\n请检查主机地址及端口是否正确,如果通过代理,请检查代理是否正常工作");
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (ex1.Message.Contains("denied (password)") == true)
|
||||||
|
{
|
||||||
|
MessageBox.Show($"{ex1.Message}\n密码错误或用户名错误");
|
||||||
|
}
|
||||||
|
else if (ex1.Message.Contains("Invalid private key file") == true)
|
||||||
|
{
|
||||||
|
MessageBox.Show($"{ex1.Message}\n所选密钥文件错误或者格式不对");
|
||||||
|
}
|
||||||
|
else if (ex1.Message.Contains("denied (publickey)") == true)
|
||||||
|
{
|
||||||
|
MessageBox.Show($"{ex1.Message}\n使用密钥登录,密钥文件错误或用户名错误");
|
||||||
|
}
|
||||||
|
else if (ex1.Message.Contains("目标计算机积极拒绝") == true)
|
||||||
|
{
|
||||||
|
MessageBox.Show($"{ex1.Message}\n主机地址错误,如果使用了代理,也可能是连接代理的端口错误");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("发生错误");
|
||||||
|
MessageBox.Show(ex1.Message);
|
||||||
|
}
|
||||||
|
currentStatus = "主机登录失败";
|
||||||
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
|
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -90,6 +90,12 @@
|
|||||||
<Compile Include="TemplateConfiguration.xaml.cs">
|
<Compile Include="TemplateConfiguration.xaml.cs">
|
||||||
<DependentUpon>TemplateConfiguration.xaml</DependentUpon>
|
<DependentUpon>TemplateConfiguration.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="TrojanResultClientInfoWindow.xaml.cs">
|
||||||
|
<DependentUpon>TrojanResultClientInfoWindow.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="TrojanTemplateWindow.xaml.cs">
|
||||||
|
<DependentUpon>TrojanTemplateWindow.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Page Include="MainWindow.xaml">
|
<Page Include="MainWindow.xaml">
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
@ -114,6 +120,14 @@
|
|||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
|
<Page Include="TrojanResultClientInfoWindow.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
|
<Page Include="TrojanTemplateWindow.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Properties\AssemblyInfo.cs">
|
<Compile Include="Properties\AssemblyInfo.cs">
|
||||||
|
@ -250,7 +250,7 @@ namespace ProxySU
|
|||||||
HidePath();
|
HidePath();
|
||||||
HideQuicKey();
|
HideQuicKey();
|
||||||
}
|
}
|
||||||
CheckDir("config");
|
CheckDir("v2ray_config");
|
||||||
|
|
||||||
GenerateV2rayShareQRcodeAndBase64Url();
|
GenerateV2rayShareQRcodeAndBase64Url();
|
||||||
|
|
||||||
@ -329,29 +329,29 @@ namespace ProxySU
|
|||||||
string saveFileFolderFirst = v2rayNjsonObject["ps"].ToString();
|
string saveFileFolderFirst = v2rayNjsonObject["ps"].ToString();
|
||||||
int num = 1;
|
int num = 1;
|
||||||
saveFileFolder = saveFileFolderFirst;
|
saveFileFolder = saveFileFolderFirst;
|
||||||
while (Directory.Exists(@"config\" + saveFileFolder))
|
while (Directory.Exists(@"v2ray_config\" + saveFileFolder))
|
||||||
{
|
{
|
||||||
saveFileFolder = saveFileFolderFirst + "_copy_" + num.ToString();
|
saveFileFolder = saveFileFolderFirst + "_copy_" + num.ToString();
|
||||||
num++;
|
num++;
|
||||||
}
|
}
|
||||||
CheckDir(@"config\" + saveFileFolder);
|
CheckDir(@"v2ray_config\" + saveFileFolder);
|
||||||
//MessageBox.Show(v2rayNjsonObject.ToString());
|
//MessageBox.Show(v2rayNjsonObject.ToString());
|
||||||
string vmessUrl = "vmess://" + ToBase64Encode(v2rayNjsonObject.ToString());
|
string vmessUrl = "vmess://" + ToBase64Encode(v2rayNjsonObject.ToString());
|
||||||
TextBoxvVmessUrl.Text = vmessUrl;
|
TextBoxvVmessUrl.Text = vmessUrl;
|
||||||
using (StreamWriter sw = new StreamWriter($"config\\{saveFileFolder}\\url.txt"))
|
using (StreamWriter sw = new StreamWriter($"v2ray_config\\{saveFileFolder}\\url.txt"))
|
||||||
{
|
{
|
||||||
sw.WriteLine(vmessUrl);
|
sw.WriteLine(vmessUrl);
|
||||||
|
|
||||||
}
|
}
|
||||||
CreateQRCode(vmessUrl);
|
CreateQRCode(vmessUrl);
|
||||||
|
|
||||||
if (File.Exists(@"config\config.json"))
|
if (File.Exists(@"v2ray_config\config.json"))
|
||||||
{
|
{
|
||||||
File.Move(@"config\config.json", @"config\" + saveFileFolder + @"\config.json");
|
File.Move(@"v2ray_config\config.json", @"v2ray_config\" + saveFileFolder + @"\config.json");
|
||||||
//File.Delete(@"config\config.json");//删除该文件
|
//File.Delete(@"config\config.json");//删除该文件
|
||||||
}
|
}
|
||||||
|
|
||||||
using (StreamWriter sw = new StreamWriter($"config\\{saveFileFolder}\\说明.txt"))
|
using (StreamWriter sw = new StreamWriter($"v2ray_config\\{saveFileFolder}\\说明.txt"))
|
||||||
{
|
{
|
||||||
sw.WriteLine("config.json");
|
sw.WriteLine("config.json");
|
||||||
sw.WriteLine("此文件为v2ray官方程序所使用的客户端配置文件,配置为全局模式,socks5地址:127.0.0.1:1080,http代理地址:127.0.0.1:1081");
|
sw.WriteLine("此文件为v2ray官方程序所使用的客户端配置文件,配置为全局模式,socks5地址:127.0.0.1:1080,http代理地址:127.0.0.1:1081");
|
||||||
@ -410,7 +410,7 @@ namespace ProxySU
|
|||||||
BitmapSource imgsource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(myImagePtr, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
|
BitmapSource imgsource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(myImagePtr, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
|
||||||
ImageShareQRcode.Source = imgsource;
|
ImageShareQRcode.Source = imgsource;
|
||||||
//DeleteObject(myImagePtr);
|
//DeleteObject(myImagePtr);
|
||||||
qrCodeImage.Save($"config\\{saveFileFolder}\\QR.bmp");
|
qrCodeImage.Save($"v2ray_config\\{saveFileFolder}\\QR.bmp");
|
||||||
//ImageShareQRcode.Source = @"config\v2rayN.bmp";
|
//ImageShareQRcode.Source = @"config\v2rayN.bmp";
|
||||||
}
|
}
|
||||||
//判断目录是否存在,不存在则创建
|
//判断目录是否存在,不存在则创建
|
||||||
@ -430,7 +430,7 @@ namespace ProxySU
|
|||||||
|
|
||||||
private void ButtonOpenSaveDir_Click(object sender, RoutedEventArgs e)
|
private void ButtonOpenSaveDir_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
string openFolderPath = @"config\" + saveFileFolder;
|
string openFolderPath = @"v2ray_config\" + saveFileFolder;
|
||||||
System.Diagnostics.Process.Start("explorer.exe", openFolderPath);
|
System.Diagnostics.Process.Start("explorer.exe", openFolderPath);
|
||||||
this.Close();
|
this.Close();
|
||||||
}
|
}
|
||||||
|
26
ProxySU/TrojanResultClientInfoWindow.xaml
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<Window x:Class="ProxySU.TrojanResultClientInfoWindow"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:local="clr-namespace:ProxySU"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
Title="TrojanResultClientInfoWindow" Height="450" Width="400">
|
||||||
|
<Grid>
|
||||||
|
<Grid>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition></ColumnDefinition>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition></RowDefinition>
|
||||||
|
<RowDefinition></RowDefinition>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<GroupBox Header="服务器连接参数" Grid.Row="0">
|
||||||
|
|
||||||
|
</GroupBox>
|
||||||
|
<GroupBox Header="二维码/URL" Grid.Row="1">
|
||||||
|
|
||||||
|
</GroupBox>
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
26
ProxySU/TrojanResultClientInfoWindow.xaml.cs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// TrojanResultClientInfoWindow.xaml 的交互逻辑
|
||||||
|
/// </summary>
|
||||||
|
public partial class TrojanResultClientInfoWindow : Window
|
||||||
|
{
|
||||||
|
public TrojanResultClientInfoWindow()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
105
ProxySU/TrojanTemplateWindow.xaml
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
<Window x:Class="ProxySU.TrojanTemplateWindow"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:local="clr-namespace:ProxySU"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
Title="TrojanTemplateWindow" Height="400" Width="600">
|
||||||
|
<Window.Resources>
|
||||||
|
<Style BasedOn="{StaticResource {x:Type TextBox}}"
|
||||||
|
TargetType="TextBox"
|
||||||
|
x:Key="TitleText">
|
||||||
|
<Style.Triggers>
|
||||||
|
<MultiTrigger>
|
||||||
|
<MultiTrigger.Conditions>
|
||||||
|
<Condition Property="Text" Value=""/>
|
||||||
|
<Condition Property="TextBox.IsFocused" Value="false"/>
|
||||||
|
</MultiTrigger.Conditions>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate>
|
||||||
|
<Border BorderThickness="1" BorderBrush="Gray" Margin="0">
|
||||||
|
<TextBlock x:Name="MainTextBlock" Text="{TemplateBinding TextBox.Tag}" Width="{TemplateBinding TextBox.ActualWidth}" Foreground="Gray" VerticalAlignment="Center" HorizontalAlignment="Left"/>
|
||||||
|
</Border>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</MultiTrigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
</Window.Resources>
|
||||||
|
<Grid>
|
||||||
|
<Grid>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition></ColumnDefinition>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="0.7*"></RowDefinition>
|
||||||
|
<RowDefinition></RowDefinition>
|
||||||
|
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<GroupBox Header="模板库" Grid.Row="0">
|
||||||
|
<Grid>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="0.6*"></ColumnDefinition>
|
||||||
|
<ColumnDefinition></ColumnDefinition>
|
||||||
|
<ColumnDefinition Width="0.5*"></ColumnDefinition>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition></RowDefinition>
|
||||||
|
<RowDefinition></RowDefinition>
|
||||||
|
<RowDefinition></RowDefinition>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<RadioButton x:Name="RadioButtonTrojanTLS2Web" Content="Trojan+TLS+Web" Grid.Column="0" Grid.Row="1" Checked="RadioButtonTrojanTLS2Web_Checked"></RadioButton>
|
||||||
|
<TextBlock Text="说明" Grid.Column="1" Grid.Row="1"></TextBlock>
|
||||||
|
</Grid>
|
||||||
|
</GroupBox>
|
||||||
|
<GroupBox Header="其他设置" Grid.Row="1">
|
||||||
|
<Grid>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="0.3*"></ColumnDefinition>
|
||||||
|
<ColumnDefinition></ColumnDefinition>
|
||||||
|
<ColumnDefinition Width="0.4*"></ColumnDefinition>
|
||||||
|
<ColumnDefinition Width="0.4*"></ColumnDefinition>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition></RowDefinition>
|
||||||
|
<RowDefinition></RowDefinition>
|
||||||
|
<RowDefinition></RowDefinition>
|
||||||
|
<RowDefinition></RowDefinition>
|
||||||
|
<RowDefinition></RowDefinition>
|
||||||
|
<RowDefinition></RowDefinition>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<TextBlock x:Name="TextBlockDomain" Text="域名:" Grid.Column="0" Grid.Row="0" ></TextBlock>
|
||||||
|
<TextBox x:Name="TextBoxDomain" Style="{StaticResource TitleText}" Tag="不可为空" Grid.Column="1" Grid.Row="0" Margin="3"></TextBox>
|
||||||
|
<!--<Button x:Name="ButtonDomain" Content="检测" Visibility="Collapsed" Grid.Column="2" Grid.Row="0" Margin="2" Click="ButtonDomain_Click"></Button>-->
|
||||||
|
<TextBlock x:Name="TextBlockServerListenPort" Text="服务端口:" Grid.Column="0" Grid.Row="1"></TextBlock>
|
||||||
|
<TextBox x:Name="TextBoxServerListenPort" Grid.Column="1" Grid.Row="1" Margin="3"></TextBox>
|
||||||
|
<Button x:Name="ButtonServerListenPort" Content="随机选择" Grid.Column="2" Grid.Row="1" Margin="2" Click="ButtonServerListenPort_Click"></Button>
|
||||||
|
|
||||||
|
<TextBlock x:Name="TextBlockNewUUID" Text="密码:" Grid.Column="0" Grid.Row="2" ></TextBlock>
|
||||||
|
<TextBox x:Name="TextBoxNewUUID" Grid.Column="1" Grid.Row="2" Margin="3"></TextBox>
|
||||||
|
<Button x:Name="ButtonNewUUID" Content="更新" Grid.Column="2" Grid.Row="2" Margin="3" Click="ButtonNewUUID_Click"></Button>
|
||||||
|
<TextBlock Text="使用已有密码,直接粘贴到框中" TextWrapping="Wrap" Grid.Column="3" Grid.Row="2"></TextBlock>
|
||||||
|
<TextBlock x:Name="TextBlockMaskSites" Text="伪装网站:" Grid.Column="0" Grid.Row="3" Grid.ColumnSpan="2"></TextBlock>
|
||||||
|
<TextBox x:Name="TextBoxMaskSites" Style="{StaticResource TitleText}" Tag="设置此项可增加代理的隐蔽(可为空)" Grid.Column="1" Grid.Row="3" Margin="3"></TextBox>
|
||||||
|
<Grid Grid.Column="0" Grid.Row="5" Grid.ColumnSpan="4">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition></ColumnDefinition>
|
||||||
|
<ColumnDefinition></ColumnDefinition>
|
||||||
|
<ColumnDefinition></ColumnDefinition>
|
||||||
|
<ColumnDefinition></ColumnDefinition>
|
||||||
|
<ColumnDefinition></ColumnDefinition>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Button x:Name="ButtondDecide" Content="确定" Grid.Column="1" Grid.Row="6" Margin="3" Click="ButtondDecide_Click"></Button>
|
||||||
|
<Button x:Name="ButtondCancel" Content="取消" Grid.Column="3" Grid.Row="6" Margin="3" Click="ButtondCancel_Click"></Button>
|
||||||
|
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
</GroupBox>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
86
ProxySU/TrojanTemplateWindow.xaml.cs
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// TrojanTemplateWindow.xaml 的交互逻辑
|
||||||
|
/// </summary>
|
||||||
|
public partial class TrojanTemplateWindow : Window
|
||||||
|
{
|
||||||
|
public TrojanTemplateWindow()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
RadioButtonTrojanTLS2Web.IsChecked = true;
|
||||||
|
}
|
||||||
|
private void ButtondDecide_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (RadioButtonTrojanTLS2Web.IsChecked == true)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(TextBoxDomain.Text.ToString()) == true)
|
||||||
|
{
|
||||||
|
MessageBox.Show("域名不能为空!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//传递模板类型
|
||||||
|
MainWindow.ReceiveConfigurationParameters[0] = "TrojanTLS2Web";
|
||||||
|
|
||||||
|
//传递域名
|
||||||
|
MainWindow.ReceiveConfigurationParameters[4] = TextBoxDomain.Text.ToString();
|
||||||
|
//传递伪装网站
|
||||||
|
MainWindow.ReceiveConfigurationParameters[7] = TextBoxMaskSites.Text.ToString();
|
||||||
|
//处理伪装网站域名中的前缀
|
||||||
|
if (TextBoxMaskSites.Text.ToString().Length >= 7)
|
||||||
|
{
|
||||||
|
string testDomain = TextBoxMaskSites.Text.Substring(0, 7);
|
||||||
|
if (String.Equals(testDomain, "https:/") || String.Equals(testDomain, "http://"))
|
||||||
|
{
|
||||||
|
//MessageBox.Show(testDomain);
|
||||||
|
MainWindow.ReceiveConfigurationParameters[7] = TextBoxMaskSites.Text.Replace("/", "\\/");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MainWindow.ReceiveConfigurationParameters[7] = "http:\\/\\/" + TextBoxMaskSites.Text;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//传递服务端口
|
||||||
|
MainWindow.ReceiveConfigurationParameters[1] = TextBoxServerListenPort.Text.ToString();
|
||||||
|
//传递密码(uuid)
|
||||||
|
MainWindow.ReceiveConfigurationParameters[2] = TextBoxNewUUID.Text.ToString();
|
||||||
|
|
||||||
|
this.Close();
|
||||||
|
}
|
||||||
|
private void ButtonNewUUID_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
Guid uuid = Guid.NewGuid();
|
||||||
|
TextBoxNewUUID.Text = uuid.ToString();
|
||||||
|
}
|
||||||
|
private void ButtonServerListenPort_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
Random random = new Random();
|
||||||
|
int randomServerPort = random.Next(10000, 50000);
|
||||||
|
TextBoxServerListenPort.Text = randomServerPort.ToString();
|
||||||
|
}
|
||||||
|
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();
|
||||||
|
//Random random = new Random();
|
||||||
|
//int randomServerPort = random.Next(10000, 50000);
|
||||||
|
TextBoxServerListenPort.Text = "443";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
BIN
appPreview0.png
Before Width: | Height: | Size: 39 KiB |
BIN
appPreview1.png
Before Width: | Height: | Size: 94 KiB |
BIN
appPreview2.png
Before Width: | Height: | Size: 103 KiB |
BIN
appPreview3.png
Before Width: | Height: | Size: 84 KiB |
BIN
appPreview4.png
Before Width: | Height: | Size: 107 KiB |
BIN
appPreview5.png
Before Width: | Height: | Size: 111 KiB |
BIN
appPreview6.png
Before Width: | Height: | Size: 155 KiB |