1
0
mirror of https://github.com/proxysu/ProxySU.git synced 2024-11-22 13:16:09 +03:00

修改模板

This commit is contained in:
ProxySU 2020-03-20 20:12:11 +08:00
parent c6f91bee1c
commit ff0b782da0
11 changed files with 224 additions and 40 deletions

View File

@ -30,12 +30,12 @@
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBlock Text="主机名" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="5" Grid.Column="0" Grid.Row="0"></TextBlock> <TextBlock Text="主机名" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="5" Grid.Column="0" Grid.Row="0"></TextBlock>
<TextBlock Text="端口" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="5" Grid.Column="2" Grid.Row="0"></TextBlock> <TextBlock Text="端口" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="5" Grid.Column="2" Grid.Row="0"></TextBlock>
<TextBox x:Name="TextBoxHost" Text="" Margin="5" Grid.Column="1" Grid.Row="0"></TextBox> <TextBox x:Name="TextBoxHost" Text="192.168.200.200" Margin="5" Grid.Column="1" Grid.Row="0"></TextBox>
<TextBox x:Name="TextBoxPort" CommandManager.PreviewExecuted="TextBoxPort_PreviewExecuted" Text="22" Margin="5" Grid.Column="3" Grid.Row="0" PreviewTextInput="TextBoxPort_PreviewTextInput"/> <TextBox x:Name="TextBoxPort" CommandManager.PreviewExecuted="TextBoxPort_PreviewExecuted" Text="22" Margin="5" Grid.Column="3" Grid.Row="0" PreviewTextInput="TextBoxPort_PreviewTextInput"/>
<TextBlock Text="用户名:" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="5" Grid.Column="0" Grid.Row="1"></TextBlock> <TextBlock Text="用户名:" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="5" Grid.Column="0" Grid.Row="1"></TextBlock>
<TextBlock x:Name="TextBlockPassword" Text="密码:" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="5" Grid.Column="2" Grid.Row="1"></TextBlock> <TextBlock x:Name="TextBlockPassword" Text="密码:" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="5" Grid.Column="2" Grid.Row="1"></TextBlock>
<TextBox x:Name="TextBoxUserName" Text="root" Margin="5" Grid.Column="1" Grid.Row="1"></TextBox> <TextBox x:Name="TextBoxUserName" Text="root" Margin="5" Grid.Column="1" Grid.Row="1"></TextBox>
<PasswordBox x:Name="PasswordBoxHostPassword" Password="" Margin="5" Grid.Column="3" Grid.Row="1"></PasswordBox> <PasswordBox x:Name="PasswordBoxHostPassword" Password="Tianlong71605" Margin="5" Grid.Column="3" Grid.Row="1"></PasswordBox>
<RadioButton x:Name="RadioButtonPasswordLogin" GroupName="CertIsYesNo" Content="密码登录" Grid.Column="0" Grid.Row="2" Checked="RadioButtonPasswordLogin_Checked"></RadioButton> <RadioButton x:Name="RadioButtonPasswordLogin" GroupName="CertIsYesNo" Content="密码登录" Grid.Column="0" Grid.Row="2" Checked="RadioButtonPasswordLogin_Checked"></RadioButton>
<RadioButton x:Name="RadioButtonCertLogin" GroupName="CertIsYesNo" Content="密钥登录" Grid.Column="1" Grid.Row="2" Checked="RadioButtonCertLogin_Checked"></RadioButton> <RadioButton x:Name="RadioButtonCertLogin" GroupName="CertIsYesNo" Content="密钥登录" Grid.Column="1" Grid.Row="2" Checked="RadioButtonCertLogin_Checked"></RadioButton>
<Button x:Name="ButtonOpenFileDialog" Content="浏览..." Margin="8" Grid.Column="2" Grid.Row="2" Click="ButtonOpenFileDialog_Click"></Button> <Button x:Name="ButtonOpenFileDialog" Content="浏览..." Margin="8" Grid.Column="2" Grid.Row="2" Click="ButtonOpenFileDialog_Click"></Button>
@ -52,9 +52,10 @@
<ColumnDefinition></ColumnDefinition> <ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<RadioButton x:Name="RadioButtonNoProxy" GroupName="ProxyIsYesNo" Content="无代理" Grid.Column="0" Grid.Row="0" Checked="RadioButtonNoProxy_Checked" Unchecked="RadioButtonNoProxy_Unchecked"/> <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="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"/> <RadioButton x:Name="RadioButtonSocks5" GroupName="ProxyIsYesNo" Content="Socks5代理" Grid.Column="2" Grid.Row="0"/>
<RadioButton x:Name="RadioButtonSocks4" GroupName="ProxyIsYesNo" Content="Socks4代理" Grid.Column="3" Grid.Row="0" />
</Grid> </Grid>
<TextBlock x:Name="TextBlockProxyHost" IsEnabled="False" Text="代理地址" HorizontalAlignment="Left" Margin="5,10,0,5" Grid.Column="0" Grid.Row="4"/> <TextBlock x:Name="TextBlockProxyHost" IsEnabled="False" Text="代理地址" HorizontalAlignment="Left" Margin="5,10,0,5" Grid.Column="0" Grid.Row="4"/>

View File

@ -25,14 +25,23 @@ namespace ProxySU
public partial class MainWindow : Window public partial class MainWindow : Window
{ {
public static string[] ReceiveConfigurationParameters { get; set; } public static string[] ReceiveConfigurationParameters { get; set; }
//ReceiveConfigurationParameters[0]----模板类型
//ReceiveConfigurationParameters[1]----服务端口
//ReceiveConfigurationParameters[2]----uuid
//ReceiveConfigurationParameters[3]----path
//ReceiveConfigurationParameters[4]----domain
//ReceiveConfigurationParameters[5]----mKCP伪装类型
public MainWindow() public MainWindow()
{ {
InitializeComponent(); InitializeComponent();
RadioButtonPasswordLogin.IsChecked = true; RadioButtonPasswordLogin.IsChecked = true;
RadioButtonNoProxy.IsChecked = true; RadioButtonNoProxy.IsChecked = true;
RadioButtonProxyNoLogin.IsChecked = true; RadioButtonProxyNoLogin.IsChecked = true;
ReceiveConfigurationParameters = new string[5]; RadioButtonSocks4.Visibility = Visibility.Collapsed;
ReceiveConfigurationParameters = new string[6];
} }
//开始布署安装
//System.Diagnostics.Process exitProgram = System.Diagnostics.Process.GetProcessById(System.Diagnostics.Process.GetCurrentProcess().Id); //System.Diagnostics.Process exitProgram = System.Diagnostics.Process.GetProcessById(System.Diagnostics.Process.GetCurrentProcess().Id);
private void Button_Login_Click(object sender, RoutedEventArgs e) private void Button_Login_Click(object sender, RoutedEventArgs e)
@ -140,7 +149,51 @@ namespace ProxySU
//using (var client = new SshClient(sshHostName, sshPort, sshUser, sshPassword)) //using (var client = new SshClient(sshHostName, sshPort, sshUser, sshPassword))
//Action<ConnectionInfo, TextBlock> startSetUpAction = new Action<ConnectionInfo, TextBlock>(StartSetUpRemoteHost); //Action<ConnectionInfo, TextBlock> startSetUpAction = new Action<ConnectionInfo, TextBlock>(StartSetUpRemoteHost);
//string appConfig = TextBoxJsonPath.Text.ToString().Replace("\\","\\\\"); //string appConfig = TextBoxJsonPath.Text.ToString().Replace("\\","\\\\");
string appConfig = (""); //读取模板配置
//sed -i 's/PermitRootLogin no/PermitRootLogin yes/' /etc/v2ray/config.json
string appConfig="";
if (String.IsNullOrEmpty(ReceiveConfigurationParameters[0]) == true)
{
MessageBox.Show("请先选择配置模板!");
return;
}
else if (String.Equals(ReceiveConfigurationParameters[0], "TCP"))
{
//File.Copy("TemplateConfg\\tcp_server_config.json", "ConfigUpload\\tcp_server_config.json", true);
appConfig = "TemplateConfg\\tcp_server_config.json";
}
else if (String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLS2Web"))
{
//File.Copy("TemplateConfg\\tcp_server_config.json", "ConfigUpload\\tcp_server_config.json", true);
appConfig = "TemplateConfg\\WebSocketTLSWeb_server_config.json";
}
else if (String.Equals(ReceiveConfigurationParameters[0], "TCPhttp"))
{
//File.Copy("TemplateConfg\\tcp_server_config.json", "ConfigUpload\\tcp_server_config.json", true);
appConfig = "TemplateConfg\\tcp_http_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"))
{
//File.Copy("TemplateConfg\\tcp_server_config.json", "ConfigUpload\\tcp_server_config.json", true);
appConfig = "TemplateConfg\\mkcp_server_config.json";
}
else if (String.Equals(ReceiveConfigurationParameters[0], "HTTP2"))
{
//File.Copy("TemplateConfg\\tcp_server_config.json", "ConfigUpload\\tcp_server_config.json", true);
appConfig = "TemplateConfg\\HTTP2_server_config.json";
}
else if (String.Equals(ReceiveConfigurationParameters[0], "TLS"))
{
//File.Copy("TemplateConfg\\tcp_server_config.json", "ConfigUpload\\tcp_server_config.json", true);
appConfig = "TemplateConfg\\TLS_server_config.json";
}
Task task = new Task(() => StartSetUpRemoteHost(connectionInfo, TextBlockSetUpProcessing, ProgressBarSetUpProcessing, appConfig)); Task task = new Task(() => StartSetUpRemoteHost(connectionInfo, TextBlockSetUpProcessing, ProgressBarSetUpProcessing, appConfig));
task.Start(); task.Start();
} }
@ -402,17 +455,21 @@ namespace ProxySU
//下载官方安装脚本安装 //下载官方安装脚本安装
client.RunCommand("curl -o /tmp/go.sh https://install.direct/go.sh"); //client.RunCommand("curl -o /tmp/go.sh https://install.direct/go.sh");
client.RunCommand("bash /tmp/go.sh"); //client.RunCommand("bash /tmp/go.sh");
client.RunCommand("mv /etc/v2ray/config.json /etc/v2ray/config.json.1"); //client.RunCommand("mv /etc/v2ray/config.json /etc/v2ray/config.json.1");
client.RunCommand("mkdir /etc/v2ray");
//上传配置文件 //上传配置文件
currentStatus = "程序安装完毕,配置文件上传中......"; currentStatus = "程序安装完毕,配置文件上传中......";
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
Thread.Sleep(2000); Thread.Sleep(2000);
UploadConfig(connectionInfo, appConfig); UploadConfig(connectionInfo, appConfig);
client.RunCommand("sed -i 's/##port##/" + ReceiveConfigurationParameters[1] + "/' /etc/v2ray/config.json");
client.RunCommand("sed -i 's/##uuid##/"+ ReceiveConfigurationParameters[2] + "/' /etc/v2ray/config.json");
client.RunCommand("sed -i 's/##path##/" + ReceiveConfigurationParameters[3] + "/' /etc/v2ray/config.json");
//client.RunCommand("sed -i 's/##domain##/" + ReceiveConfigurationParameters[4] + "/' /etc/v2ray/config.json");
client.RunCommand("sed -i 's/##mkcpHeaderType##/" + ReceiveConfigurationParameters[5] + "/' /etc/v2ray/config.json");
currentStatus = "安装成功"; currentStatus = "安装成功";
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
@ -467,6 +524,7 @@ namespace ProxySU
{ {
sftpClient.Connect(); sftpClient.Connect();
//MessageBox.Show("sftp信息1" + sftpClient.ConnectionInfo.ServerVersion.ToString()); //MessageBox.Show("sftp信息1" + sftpClient.ConnectionInfo.ServerVersion.ToString());
//sftpClient.UploadFile(File.OpenRead("TemplateConfg\tcp_server_config.json"), "/etc/v2ray/config.json", true);
sftpClient.UploadFile(File.OpenRead(uploadConfig), "/etc/v2ray/config.json", true); sftpClient.UploadFile(File.OpenRead(uploadConfig), "/etc/v2ray/config.json", true);
//MessageBox.Show("sftp信息" + sftpClient.ConnectionInfo.ServerVersion.ToString()); //MessageBox.Show("sftp信息" + sftpClient.ConnectionInfo.ServerVersion.ToString());
sftpClient.Disconnect(); sftpClient.Disconnect();
@ -600,32 +658,6 @@ namespace ProxySU
} }
} }
//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

@ -33,7 +33,6 @@
<RowDefinition></RowDefinition> <RowDefinition></RowDefinition>
<RowDefinition></RowDefinition> <RowDefinition></RowDefinition>
<RowDefinition></RowDefinition> <RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<RadioButton x:Name="RadioButtonTCP" Content="TCP" Grid.Column="0" Grid.Row="0" Checked="RadioButtonTCP_Checked"></RadioButton> <RadioButton x:Name="RadioButtonTCP" Content="TCP" Grid.Column="0" Grid.Row="0" Checked="RadioButtonTCP_Checked"></RadioButton>
<TextBlock Text="TCP说明" Grid.Column="1" Grid.Row="0" Grid.ColumnSpan="2"></TextBlock> <TextBlock Text="TCP说明" Grid.Column="1" Grid.Row="0" Grid.ColumnSpan="2"></TextBlock>

View File

@ -47,32 +47,38 @@ namespace ProxySU
else if (RadioButtonMkcpNoCamouflage.IsChecked == true) else if (RadioButtonMkcpNoCamouflage.IsChecked == true)
{ {
//传递模板类型 //传递模板类型
MainWindow.ReceiveConfigurationParameters[0] = "MkcpNoCamouflage"; MainWindow.ReceiveConfigurationParameters[0] = "MkcpNone";
MainWindow.ReceiveConfigurationParameters[5] = "none";
} }
else if (RadioButton2mKCP2SRTP.IsChecked == true) else if (RadioButton2mKCP2SRTP.IsChecked == true)
{ {
//传递模板类型 //传递模板类型
MainWindow.ReceiveConfigurationParameters[0] = "mKCP2SRTP"; MainWindow.ReceiveConfigurationParameters[0] = "mKCP2SRTP";
MainWindow.ReceiveConfigurationParameters[5] = "srtp";
} }
else if (RadioButton2mKCPuTP.IsChecked == true) else if (RadioButton2mKCPuTP.IsChecked == true)
{ {
//传递模板类型 //传递模板类型
MainWindow.ReceiveConfigurationParameters[0] = "mKCPuTP"; MainWindow.ReceiveConfigurationParameters[0] = "mKCPuTP";
MainWindow.ReceiveConfigurationParameters[5] = "utp";
} }
else if (RadioButton2mKCP2WechatVideo.IsChecked == true) else if (RadioButton2mKCP2WechatVideo.IsChecked == true)
{ {
//传递模板类型 //传递模板类型
MainWindow.ReceiveConfigurationParameters[0] = "mKCP2WechatVideo"; MainWindow.ReceiveConfigurationParameters[0] = "mKCP2WechatVideo";
MainWindow.ReceiveConfigurationParameters[5] = "wechat-video";
} }
else if (RadioButton2mKCP2DTLS.IsChecked == true) else if (RadioButton2mKCP2DTLS.IsChecked == true)
{ {
//传递模板类型 //传递模板类型
MainWindow.ReceiveConfigurationParameters[0] = "mKCP2DTLS"; MainWindow.ReceiveConfigurationParameters[0] = "mKCP2DTLS";
MainWindow.ReceiveConfigurationParameters[5] = "dtls";
} }
else if (RadioButton2mKCP2WireGuard.IsChecked == true) else if (RadioButton2mKCP2WireGuard.IsChecked == true)
{ {
//传递模板类型 //传递模板类型
MainWindow.ReceiveConfigurationParameters[0] = "mKCP2WireGuard"; MainWindow.ReceiveConfigurationParameters[0] = "mKCP2WireGuard";
MainWindow.ReceiveConfigurationParameters[5] = "wireguard";
} }
else if (RadioButtonHTTP2.IsChecked == true) else if (RadioButtonHTTP2.IsChecked == true)
{ {

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,9 @@
##domain## {
root /var/www
tls ##email##
proxy / ##sites##
proxy ##path## localhost:10000 {
websocket
header_upstream -Origin
}
}

View File

@ -0,0 +1,29 @@
{
"inbounds": [
{
"port": 10000,
"listen": "127.0.0.1",
"protocol": "vmess",
"settings": {
"clients": [
{
"id": "##uuid##",
"alterId": 64
}
]
},
"streamSettings": {
"network": "ws",
"wsSettings": {
"path": "##path##"
}
}
}
],
"outbounds": [
{
"protocol": "freedom",
"settings": {}
}
]
}

View File

@ -0,0 +1,33 @@
{
"inbounds": [
{
"port": ##port##,
"protocol": "vmess",
"settings": {
"clients": [
{
"id": "##uuid##",
"alterId": 64
}
]
},
"streamSettings": {
"network": "mkcp",
"kcpSettings": {
"uplinkCapacity": 100,
"downlinkCapacity": 100,
"congestion": true,
"header": {
"type": "##mkcpHeaderType##"
}
}
}
}
],
"outbounds": [
{
"protocol": "freedom",
"settings": {}
}
]
}

View File

@ -0,0 +1,50 @@
{
"inbounds": [
{
"port": 80,
"protocol": "vmess",
"settings": {
"clients": [
{
"id": "##uuid##",
"alterId": 64
}
]
},
"streamSettings": {
"network": "tcp",
"tcpSettings": {
"header": {
"type": "http",
"response": {
"version": "1.1",
"status": "200",
"reason": "OK",
"headers": {
"Content-Type": [
"application/octet-stream",
"application/x-msdownload",
"text/html",
"application/x-shockwave-flash"
],
"Transfer-Encoding": [
"chunked"
],
"Connection": [
"keep-alive"
],
"Pragma": "no-cache"
}
}
}
}
}
}
],
"outbounds": [
{
"protocol": "freedom",
"settings": {}
}
]
}

View File

@ -0,0 +1,25 @@
{
"inbounds": [
{
"port": ##port##,
"protocol": "vmess",
"settings": {
"clients": [
{
"id": "##uuid##",
"alterId": 64
}
]
}
}
}
],
"outbounds": [
{
"protocol": "freedom",
"settings": {}
}
]
}