1
0
mirror of https://github.com/proxysu/ProxySU.git synced 2024-11-22 05:06:08 +03:00

添加模板库

This commit is contained in:
ProxySU 2020-03-17 14:50:22 +08:00
parent 4c6b19d10d
commit 919d5ab78a
5 changed files with 177 additions and 87 deletions

View File

@ -41,10 +41,22 @@
<Button x:Name="ButtonOpenFileDialog" Content="浏览..." Margin="8" Grid.Column="2" Grid.Row="2" Click="ButtonOpenFileDialog_Click"></Button>
<TextBox x:Name="TextBoxCertFilePath" Text="" Margin="10" Grid.Column="3" Grid.Row="2"></TextBox>
<!--代理设置-->
<RadioButton x:Name="RadioButtonNoProxy" GroupName="ProxyIsYesNo" Content="无代理" Grid.Column="0" Grid.Row="3" Height="30" VerticalAlignment="Top" Checked="RadioButtonNoProxy_Checked" Unchecked="RadioButtonNoProxy_Unchecked"/>
<RadioButton x:Name="RadioButtonHttp" GroupName="ProxyIsYesNo" Content="Http" Grid.Column="1" Grid.Row="3"/>
<RadioButton x:Name="RadioButtonSocks4" GroupName="ProxyIsYesNo" Content="Socks4" Grid.Column="2" Grid.Row="3" Grid.ColumnSpan="2" Height="30" Margin="0.333,0,226.333,0" VerticalAlignment="Bottom"/>
<RadioButton x:Name="RadioButtonSocks5" GroupName="ProxyIsYesNo" Content="Socks5" Grid.Column="3" Grid.Row="3"/>
<Grid Grid.Column="0" Grid.Row="3" Grid.ColumnSpan="4">
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<RadioButton x:Name="RadioButtonNoProxy" GroupName="ProxyIsYesNo" Content="无代理" Grid.Column="0" Grid.Row="0" Checked="RadioButtonNoProxy_Checked" Unchecked="RadioButtonNoProxy_Unchecked"/>
<RadioButton x:Name="RadioButtonHttp" GroupName="ProxyIsYesNo" Content="Http" Grid.Column="1" Grid.Row="0"/>
<RadioButton x:Name="RadioButtonSocks4" GroupName="ProxyIsYesNo" Content="Socks4" Grid.Column="2" Grid.Row="0" />
<RadioButton x:Name="RadioButtonSocks5" GroupName="ProxyIsYesNo" Content="Socks5" Grid.Column="3" Grid.Row="0"/>
</Grid>
<TextBlock x:Name="TextBlockProxyHost" IsEnabled="False" Text="代理地址" HorizontalAlignment="Left" Margin="5,10,0,5" Grid.Column="0" Grid.Row="4"/>
<TextBlock x:Name="TextBlockProxyPort" IsEnabled="False" Text="端口" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="5" Grid.Column="2" Grid.Row="4"></TextBlock>
<TextBox x:Name="TextBoxProxyHost" IsEnabled="False" Text="127.0.0.1" Margin="5" Grid.Column="1" Grid.Row="4"></TextBox>
@ -73,11 +85,17 @@
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<RadioButton x:Name="RadioButtonGuideConfiguration" Content="向导生成配置" Grid.Column="0" Grid.Row="0"></RadioButton>
<Button x:Name="ButtonGuideConfiguration" Content="启用向导" Grid.Column="0" Grid.Row="0"></Button>
<TextBlock Text="通过向导生成配置文件" Grid.Column="0" Grid.Row="1" Grid.RowSpan="2" HorizontalAlignment="Center"></TextBlock>
<Button x:Name="ButtonTemplateConfiguration" Content="打开模板库" Grid.Column="1" Grid.Row="0" Click="ButtonTemplateConfiguration_Click"></Button>
<TextBlock Text="模板库" Grid.Column="1" Grid.Row="1" Grid.RowSpan="2" HorizontalAlignment="Center"></TextBlock>
<Button x:Name="ButtonAdvancedConfiguration" Content="配置编辑器" Grid.Column="2" Grid.Row="0"></Button>
<TextBlock Text="配置文件高级生成器&#x0a;(有经验用户可以使用)" Grid.Column="2" Grid.Row="1" Grid.RowSpan="2" HorizontalAlignment="Center"></TextBlock>
<!--<RadioButton x:Name="RadioButtonGuideConfiguration" Content="向导生成配置" Grid.Column="0" Grid.Row="0"></RadioButton>
<RadioButton x:Name="RadioButtonTemplateConfiguration" Content="模板配置" Grid.Column="0" Grid.Row="1"></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>
<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>-->
</Grid>
</TabItem>
<TabItem Header="BBR设置" Width="150" Height="30"></TabItem>

View File

@ -31,7 +31,7 @@ namespace ProxySU
RadioButtonNoProxy.IsChecked = true;
RadioButtonProxyNoLogin.IsChecked = true;
//GuideConfiguration.IsChecked = true;
RadioButtonTemplateConfiguration.IsChecked = true;
//RadioButtonTemplateConfiguration.IsChecked = true;
}
//System.Diagnostics.Process exitProgram = System.Diagnostics.Process.GetProcessById(System.Diagnostics.Process.GetCurrentProcess().Id);
private void Button_Login_Click(object sender, RoutedEventArgs e)
@ -139,46 +139,10 @@ namespace ProxySU
//using (var client = new SshClient(sshHostName, sshPort, sshUser, sshPassword))
//Action<ConnectionInfo, TextBlock> startSetUpAction = new Action<ConnectionInfo, TextBlock>(StartSetUpRemoteHost);
string appConfig = TextBoxJsonPath.Text.ToString().Replace("\\","\\\\");
//string appConfig = TextBoxJsonPath.Text.ToString().Replace("\\","\\\\");
string appConfig = ("");
Task task = new Task(() => StartSetUpRemoteHost(connectionInfo, TextBlockSetUpProcessing, ProgressBarSetUpProcessing, appConfig));
task.Start();
//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("未知错误");
// }
// //TextBlockSetUpProcessing.Text = "主机登录失败";
// //ProgressBarSetUpProcessing.IsIndeterminate = false;
// //ProgressBarSetUpProcessing.Value = 0;
//}
#endregion
}
#region
@ -381,8 +345,7 @@ namespace ProxySU
var result = client.RunCommand("uname -r");
//var result = client.RunCommand("cat /root/test.ver");
string[] linuxKernelVerStr= result.Result.Split('-');
//MessageBox.Show(result.Result);
//MessageBox.Show(linuxKernelVerStr[0]);
bool detectResult = DetectKernelVersion(linuxKernelVerStr[0]);
if (detectResult == false)
{
@ -391,14 +354,14 @@ namespace ProxySU
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
Thread.Sleep(2000);
}
//detectResult = DetectReleaseVersion(string releaseVer);
//检测系统是否支持yum 或 apt-get或zypper且支持Systemd
//如果不存在组件则命令结果为空string.IsNullOrEmpty值为真
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 getPMT= string.IsNullOrEmpty(client.RunCommand("command -v apt-get").Result) && string.IsNullOrEmpty(client.RunCommand("command -v yum").Result) && string.IsNullOrEmpty(client.RunCommand("command -v zypper").Result);
bool getSystemd = string.IsNullOrEmpty(client.RunCommand("command -v systemctl").Result);
//没有安装apt-get也没有安装yum也没有安装zypper,或者没有安装systemd的不满足安装条件
//也就是apt-get yum, zypper必须安装其中之一且必须安装Systemd的系统才能安装。
if ((getApt && getYum && getZypper) || getSystemd)
@ -437,15 +400,14 @@ namespace ProxySU
}
//下载调用官方安装脚本安装
//下载官方安装脚本安装
client.RunCommand("curl -o /tmp/go.sh https://install.direct/go.sh");
client.RunCommand("bash /tmp/go.sh");
client.RunCommand("mv /etc/v2ray/config.json /etc/v2ray/config.json.1");
//client.RunCommand("echo 1111 >> test.json");
//上传配置文件
//string uploadConfig = "config\\http_server.json";
currentStatus = "程序安装完毕,配置文件上传中......";
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
Thread.Sleep(2000);
@ -455,10 +417,7 @@ namespace ProxySU
currentStatus = "安装成功";
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
Thread.Sleep(2000);
//MessageBox.Show("安装成功");
//MessageBox.Show("ssh信息"+client.ConnectionInfo.ServerVersion.ToString());
//MessageBox.Show(client);
client.Disconnect();
return;
}
@ -502,8 +461,6 @@ namespace ProxySU
//上传配置文件
private void UploadConfig(ConnectionInfo connectionInfo,string uploadConfig)
{
//v2rayConfig = "config\\http_server.json";
try
{
using (var sftpClient = new SftpClient(connectionInfo))
@ -511,8 +468,7 @@ namespace ProxySU
sftpClient.Connect();
//MessageBox.Show("sftp信息1" + sftpClient.ConnectionInfo.ServerVersion.ToString());
sftpClient.UploadFile(File.OpenRead(uploadConfig), "/etc/v2ray/config.json", true);
//sftpClient.DownloadFile("/root/id_rsa.pub", File.Create("config\\server_config.json"));
MessageBox.Show("sftp信息" + sftpClient.ConnectionInfo.ServerVersion.ToString());
//MessageBox.Show("sftp信息" + sftpClient.ConnectionInfo.ServerVersion.ToString());
sftpClient.Disconnect();
}
@ -526,17 +482,15 @@ namespace ProxySU
//下载配置文件
private void DownloadConfig(ConnectionInfo connectionInfo, string downloadConfig)
{
//v2rayConfig = "config\\http_server.json";
try
{
using (var sftpClient = new SftpClient(connectionInfo))
{
sftpClient.Connect();
//MessageBox.Show("sftp信息1" + sftpClient.ConnectionInfo.ServerVersion.ToString());
//sftpClient.UploadFile(File.OpenRead(v2rayConfig), "/etc/v2ray/config.json", true);
sftpClient.DownloadFile("/etc/v2ray/config.json", File.Create(downloadConfig));
MessageBox.Show("sftp信息" + sftpClient.ConnectionInfo.ServerVersion.ToString());
//MessageBox.Show("sftp信息" + sftpClient.ConnectionInfo.ServerVersion.ToString());
sftpClient.Disconnect();
}
@ -629,32 +583,41 @@ namespace ProxySU
}
private void ButtonSetConfiguration_Click(object sender, RoutedEventArgs e)
private void ButtonTemplateConfiguration_Click(object sender, RoutedEventArgs e)
{
if (RadioButtonGuideConfiguration.IsChecked == true)
{
MessageBox.Show("还未完善,敬请期待!");
}
else if (RadioButtonTemplateConfiguration.IsChecked == true)
{
var openFileDialog = new Microsoft.Win32.OpenFileDialog()
{
Filter = "Cert Files (*.json)|*.json"
};
var result = openFileDialog.ShowDialog();
if (result == true)
{
TextBoxJsonPath.Text = openFileDialog.FileName;
}
}
else
{
MessageBox.Show("还未完善,敬请期待!");
}
MessageBox.Show(TextBoxJsonPath.Text.ToString());
string appConfig = TextBoxJsonPath.Text.ToString().Replace("\\", "\\\\");
MessageBox.Show(appConfig);
WindowTemplateConfiguration windowTemplateConfiguration = new WindowTemplateConfiguration();
//windowTemplateConfiguration.Source = new Uri("Page1.xaml", UriKind.Relative);
windowTemplateConfiguration.ShowDialog();
}
//private void ButtonSetConfiguration_Click(object sender, RoutedEventArgs e)
//{
// if (RadioButtonGuideConfiguration.IsChecked == true)
// {
// MessageBox.Show("还未完善,敬请期待!");
// }
// else if (RadioButtonTemplateConfiguration.IsChecked == true)
// {
// var openFileDialog = new Microsoft.Win32.OpenFileDialog()
// {
// Filter = "Cert Files (*.json)|*.json"
// };
// var result = openFileDialog.ShowDialog();
// if (result == true)
// {
// TextBoxJsonPath.Text = openFileDialog.FileName;
// }
// }
// else
// {
// MessageBox.Show("还未完善,敬请期待!");
// }
// //MessageBox.Show(TextBoxJsonPath.Text.ToString());
// //string appConfig = TextBoxJsonPath.Text.ToString().Replace("\\", "\\\\");
// //MessageBox.Show(appConfig);
//}
}
}

View File

@ -74,6 +74,9 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="TemplateConfiguration.xaml.cs">
<DependentUpon>TemplateConfiguration.xaml</DependentUpon>
</Compile>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
@ -86,6 +89,10 @@
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Page Include="TemplateConfiguration.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">

View File

@ -0,0 +1,70 @@
<Window x:Name="TemplateConfiguration" x:Class="ProxySU.WindowTemplateConfiguration"
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="TemplateConfiguration" Height="650" Width="650">
<Grid>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<GroupBox Header="模板库" Grid.Row="0" Grid.RowSpan="2">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<RadioButton x:Name="RadioButtonTCP" Content="TCP" Grid.Column="0" Grid.Row="0"></RadioButton>
<TextBlock Text="TCP说明" Grid.Column="1" Grid.Row="0" Grid.ColumnSpan="2"></TextBlock>
<RadioButton x:Name="RadioButtonTCPhttp" Content="TCP+Http伪装" Grid.Column="0" Grid.Row="1"></RadioButton>
<TextBlock Text="TCP+Http伪装说明" Grid.Column="1" Grid.Row="1" Grid.ColumnSpan="2"></TextBlock>
<RadioButton x:Name="RadioButtonMkcpNoCamouflage" Content="mKCP(无伪装)" Grid.Column="0" Grid.Row="2"></RadioButton>
<TextBlock Text="mkcp协议,不进行伪装,发送的数据是没有特征的数据包。" Grid.Column="1" Grid.Row="2" Grid.ColumnSpan="2"></TextBlock>
<RadioButton x:Name="RadioButton2mKCP2SRTP" Content="mKCP+SRTP" Grid.Column="0" Grid.Row="3"></RadioButton>
<TextBlock Text="mkcp协议,伪装成 SRTP 数据包,会被识别为视频通话数据(如 FaceTime" Grid.Column="1" Grid.Row="3" Grid.ColumnSpan="2"></TextBlock>
<RadioButton x:Name="RadioButton2mKCPuTP" Content="mKCP+uTP" Grid.Column="0" Grid.Row="4"></RadioButton>
<TextBlock Text="伪装成 uTP 数据包,会被识别为 BT 下载数据" Grid.Column="1" Grid.Row="4" Grid.ColumnSpan="2"></TextBlock>
<RadioButton x:Name="RadioButton2mKCP2WechatVideo" Content="mKCP+WechatVideo" Grid.Column="0" Grid.Row="5"></RadioButton>
<TextBlock Text="伪装成微信视频通话的数据包" Grid.Column="1" Grid.Row="5" Grid.ColumnSpan="2"></TextBlock>
<RadioButton x:Name="RadioButton2mKCP2DTLS" Content="mKCP+DTLS 1.2" Grid.Column="0" Grid.Row="6"></RadioButton>
<TextBlock Text="伪装成 DTLS 1.2 数据包" Grid.Column="1" Grid.Row="6" Grid.ColumnSpan="2"></TextBlock>
<RadioButton x:Name="RadioButton2mKCP2WireGuard" Content="mKCP+WireGuard" Grid.Column="0" Grid.Row="7"></RadioButton>
<TextBlock Text="伪装成 WireGuard 数据包。(并不是真正的 WireGuard 协议)" Grid.Column="1" Grid.Row="7" Grid.ColumnSpan="2"></TextBlock>
<RadioButton x:Name="RadioButtonHTTP2" Content="HTTP/2" Grid.Column="0" Grid.Row="8"></RadioButton>
<TextBlock Text="基于 HTTP/2 的传输方式。它完整按照 HTTP/2 标准实现" Grid.Column="1" Grid.Row="8" Grid.ColumnSpan="2"></TextBlock>
<RadioButton x:Name="RadioButtonTLS" Content="TLS" Grid.Column="0" Grid.Row="9"></RadioButton>
<TextBlock Text="使用TLS加密数据流" Grid.Column="1" Grid.Row="9" Grid.ColumnSpan="2"></TextBlock>
<RadioButton x:Name="RadioButtonWebSocketTLS2Web" Content="WebSocket+TLS+Web" Grid.Column="0" Grid.Row="10"></RadioButton>
<TextBlock Text="目前是稳定性最好的使用Caddy做网站前置https数据流不易被识别出流量特征" Grid.Column="1" Grid.Row="10" Grid.ColumnSpan="2"></TextBlock>
<Button x:Name="ButtondDecide" Content="确定" Grid.Column="3" Grid.Row="11" Margin="4" Click="ButtondDecide_Click"></Button>
</Grid>
</GroupBox>
<GroupBox Header="自定义模板" Grid.Row="2">
<Grid>
</Grid>
</GroupBox>
</Grid>
</Window>

View File

@ -0,0 +1,32 @@
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>
/// Window1.xaml 的交互逻辑
/// </summary>
public partial class WindowTemplateConfiguration : Window
{
public WindowTemplateConfiguration()
{
InitializeComponent();
RadioButtonTCP.IsChecked = true;
}
private void ButtondDecide_Click(object sender, RoutedEventArgs e)
{
}
}
}