1
0
Fork 0
mirror of https://github.com/proxysu/ProxySU.git synced 2025-04-04 06:13:37 +03:00

代码优化,潜在bug修复

This commit is contained in:
ProxySU 2020-10-30 11:25:41 +08:00
parent 3166814acf
commit a40776d5a9
9 changed files with 283 additions and 342 deletions

View file

@ -350,8 +350,8 @@
<TextBox x:Name="TextBoxTrojanPassword" Grid.Column="1" Grid.Row="2" Margin="3"></TextBox>
<Button x:Name="ButtonTrojanPassword" Content="{DynamicResource ButtonTrojanChangePassword}" Grid.Column="2" Grid.Row="2" Margin="2" Click="ButtonTrojanPassword_Click" ></Button>
<TextBlock Text="{DynamicResource TextBlockV2RayMaskSites}" Grid.Column="0" Grid.Row="3" Visibility="Collapsed"></TextBlock>
<TextBox x:Name="TextBoxTrojanSites" Style="{StaticResource TitleText}" Tag="{DynamicResource TextBoxV2RayMaskSitesTag}" Grid.Column="1" Grid.Row="3" Margin="3" Visibility="Collapsed"></TextBox>
<TextBlock Text="{DynamicResource TextBlockV2RayMaskSites}" Grid.Column="0" Grid.Row="3" HorizontalAlignment="Right" VerticalAlignment="Center" ></TextBlock>
<TextBox x:Name="TextBoxTrojanSites" Style="{StaticResource TitleText}" Tag="{DynamicResource TextBoxV2RayMaskSitesTag}" Grid.Column="1" Grid.Row="3" Margin="3"></TextBox>
</Grid>
</GroupBox>
@ -403,8 +403,8 @@
<TextBlock Text="{DynamicResource TextBlockTrojanHostPassword}" Grid.Column="0" Grid.Row="3" HorizontalAlignment="Right" VerticalAlignment="Center"></TextBlock>
<TextBox x:Name="TextBoxNaivePassword" Grid.Column="1" Grid.Row="3" Margin="3"></TextBox>
<Button x:Name="ButtonNaivePassword" Content="{DynamicResource ButtonTrojanChangePassword}" Grid.Column="2" Grid.Row="3" Margin="2" Click="ButtonNaivePassword_Click"></Button>
<TextBlock Text="{DynamicResource TextBlockV2RayMaskSites}" Grid.Column="0" Grid.Row="4" Visibility="Collapsed"></TextBlock>
<TextBox x:Name="TextBoxNaiveSites" Style="{StaticResource TitleText}" Tag="{DynamicResource TextBoxV2RayMaskSitesTag}" Grid.Column="1" Grid.Row="4" Margin="3" Visibility="Collapsed"></TextBox>
<TextBlock Text="{DynamicResource TextBlockV2RayMaskSites}" Grid.Column="0" Grid.Row="4" HorizontalAlignment="Right" VerticalAlignment="Center"></TextBlock>
<TextBox x:Name="TextBoxNaiveSites" Style="{StaticResource TitleText}" Tag="{DynamicResource TextBoxV2RayMaskSitesTag}" Grid.Column="1" Grid.Row="4" Margin="3"></TextBox>
</Grid>
</GroupBox>
@ -456,8 +456,8 @@
<TextBox x:Name="TextBoxSSRPassword" Grid.Column="1" Grid.Row="2" Margin="3"></TextBox>
<Button x:Name="ButtonSSRPassword" Content="{DynamicResource ButtonTrojanChangePassword}" Grid.Column="2" Grid.Row="2" Margin="2" Click="ButtonSSRPassword_Click" ></Button>
<TextBlock Text="{DynamicResource TextBlockV2RayMaskSites}" Grid.Column="0" Grid.Row="3" Visibility="Collapsed"></TextBlock>
<TextBox x:Name="TextBoxSSRSites" Style="{StaticResource TitleText}" Tag="{DynamicResource TextBoxV2RayMaskSitesTag}" Grid.Column="1" Grid.Row="3" Margin="3" Visibility="Collapsed"></TextBox>
<TextBlock Text="{DynamicResource TextBlockV2RayMaskSites}" Grid.Column="0" Grid.Row="3" HorizontalAlignment="Right" VerticalAlignment="Center"></TextBlock>
<TextBox x:Name="TextBoxSSRSites" Style="{StaticResource TitleText}" Tag="{DynamicResource TextBoxV2RayMaskSitesTag}" Grid.Column="1" Grid.Row="3" Margin="3"></TextBox>
</Grid>
</GroupBox>
@ -511,7 +511,7 @@
<TextBlock x:Name="TextBlockCurrentlySelectedPlanMethodSS" Grid.Column="1" Grid.Row="3" HorizontalAlignment="Left" VerticalAlignment="Center" Visibility="Visible"></TextBlock>
<TextBlock x:Name="TextBlockCurrentlySelectedPlanDomainSS" Grid.Column="1" Grid.Row="4" HorizontalAlignment="Left" VerticalAlignment="Center" Visibility="Visible"></TextBlock>
<TextBlock x:Name="TextBlockCurrentlySelectedPlanPathSS" Grid.Column="1" Grid.Row="5" HorizontalAlignment="Left" VerticalAlignment="Center" Visibility="Visible"></TextBlock>
<TextBlock x:Name="TextBlockCurrentlySelectedPlanFakeWebsiteSS" Grid.Column="1" Grid.Row="5" HorizontalAlignment="Left" VerticalAlignment="Center" Visibility="Hidden"></TextBlock>
<TextBlock x:Name="TextBlockCurrentlySelectedPlanFakeWebsiteSS" Grid.Column="1" Grid.Row="5" HorizontalAlignment="Left" VerticalAlignment="Center" Visibility="Visible"></TextBlock>
</Grid>
@ -552,7 +552,7 @@
</Grid.RowDefinitions>
<TextBlock Text="{DynamicResource TextBlockMtgTemplateExplanation}" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="3" HorizontalAlignment="Center" VerticalAlignment="Center"></TextBlock>
<TextBlock Text="{DynamicResource TextBlockHostPart}" Grid.Column="0" Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="5"></TextBlock>
<TextBox x:Name="TextBoxMtgHostDomain" Text="443" Grid.Column="1" Grid.Row="1" Margin="3"></TextBox>
<TextBox x:Name="TextBoxMtgHostPort" Text="443" Grid.Column="1" Grid.Row="1" Margin="3"></TextBox>
<TextBlock Text="{DynamicResource TextBlockMtgPortExplanation}" Grid.Column="2" Grid.Row="1" HorizontalAlignment="Left" VerticalAlignment="Center"></TextBlock>
<TextBlock Text="{DynamicResource TextBlockHostCert}" Grid.Column="0" Grid.Row="2" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="5"></TextBlock>
<TextBlock Grid.Column="1" Grid.Row="2" Grid.ColumnSpan="2" Text="{DynamicResource TextBlockMtgSecretExplanation}" VerticalAlignment="Center"></TextBlock>

View file

@ -571,19 +571,19 @@ namespace ProxySU
ConnectionInfo connectionInfo;
#region
if (string.IsNullOrEmpty(TextBoxHost.Text) == true || string.IsNullOrEmpty(TextBoxPort.Text) == true || string.IsNullOrEmpty(TextBoxUserName.Text) == true)
if (string.IsNullOrEmpty(PreTrim(TextBoxHost.Text)) == true || string.IsNullOrEmpty(PreTrim(TextBoxPort.Text)) == true || string.IsNullOrEmpty(PreTrim(TextBoxUserName.Text)) == true)
{
//******"主机地址、主机端口、用户名为必填项,不能为空"******
MessageBox.Show(Application.Current.FindResource("MessageBoxShow_ErrorHostPortUserNotEmpty").ToString());
return connectionInfo = null;
}
string sshHostName = TextBoxHost.Text.ToString();
string sshHostName = PreTrim(TextBoxHost.Text);
int sshPort = 22;
if (IsOnlyNumber(TextBoxPort.Text) == true)
if (IsOnlyNumber(PreTrim(TextBoxPort.Text)) == true)
{
TextBoxPort.Text = TextBoxPort.Text.Trim();
TextBoxPort.Text = PreTrim(TextBoxPort.Text);
sshPort = int.Parse(TextBoxPort.Text);
}
else
@ -593,7 +593,7 @@ namespace ProxySU
return connectionInfo = null;
}
string sshUser = TextBoxUserName.Text.ToString();
string sshUser = PreTrim(TextBoxUserName.Text);
if (RadioButtonPasswordLogin.IsChecked == true && string.IsNullOrEmpty(PasswordBoxHostPassword.Password) == true)
{
@ -630,18 +630,18 @@ namespace ProxySU
}
//MessageBox.Show(proxyTypes.ToString());
if (RadioButtonNoProxy.IsChecked == false && (string.IsNullOrEmpty(TextBoxProxyHost.Text) == true || string.IsNullOrEmpty(TextBoxProxyPort.Text) == true))
if (RadioButtonNoProxy.IsChecked == false && (string.IsNullOrEmpty(PreTrim(TextBoxProxyHost.Text)) == true || string.IsNullOrEmpty(PreTrim(TextBoxProxyPort.Text)) == true))
{
//****** "如果选择了代理,则代理地址与端口不能为空!" ******
MessageBox.Show(Application.Current.FindResource("MessageBoxShow_ErrorProxyAddressPortNotEmpty").ToString());
return connectionInfo = null;
}
string sshProxyHost = TextBoxProxyHost.Text.ToString();
string sshProxyHost = PreTrim(TextBoxProxyHost.Text);
int sshProxyPort = 1080;
if (IsOnlyNumber(TextBoxProxyPort.Text) == true)
if (IsOnlyNumber(PreTrim(TextBoxProxyPort.Text)) == true)
{
TextBoxProxyPort.Text = TextBoxProxyPort.Text.Trim();
TextBoxProxyPort.Text = PreTrim(TextBoxProxyPort.Text);
sshProxyPort = int.Parse(TextBoxProxyPort.Text);
}
else
@ -651,14 +651,14 @@ namespace ProxySU
return connectionInfo = null;
}
if (RadioButtonNoProxy.IsChecked==false && RadiobuttonProxyYesLogin.IsChecked == true && (string.IsNullOrEmpty(TextBoxProxyUserName.Text) == true || string.IsNullOrEmpty(PasswordBoxProxyPassword.Password) == true))
if (RadioButtonNoProxy.IsChecked==false && RadiobuttonProxyYesLogin.IsChecked == true && (string.IsNullOrEmpty(PreTrim(TextBoxProxyUserName.Text)) == true || string.IsNullOrEmpty(PasswordBoxProxyPassword.Password) == true))
{
//****** "如果代理需要登录,则代理登录的用户名与密码不能为空!" ******
MessageBox.Show(Application.Current.FindResource("MessageBoxShow_ErrorProxyUserPasswordNotEmpty").ToString());
return connectionInfo = null;
}
string sshProxyUser = TextBoxProxyUserName.Text.ToString();
string sshProxyPassword = PasswordBoxProxyPassword.Password.ToString();
string sshProxyUser = PreTrim(TextBoxProxyUserName.Text);
string sshProxyPassword = PasswordBoxProxyPassword.Password;
#endregion
@ -971,11 +971,11 @@ namespace ProxySU
TextBlockV2RayShowCurrentlySelectedPlanDomain.Visibility = Visibility.Hidden;
TextBlockCurrentlySelectedPlanDomain.Visibility = Visibility.Hidden;
}
//显示伪装网站(暂时不显示)
//显示伪装网站
private void ShowV2RayMaskSites()
{
TextBlockV2RayShowCurrentlySelectedPlanFakeWebsite.Visibility = Visibility.Hidden;
TextBlockCurrentlySelectedPlanFakeWebsite.Visibility = Visibility.Hidden;
TextBlockV2RayShowCurrentlySelectedPlanFakeWebsite.Visibility = Visibility.Visible;
TextBlockCurrentlySelectedPlanFakeWebsite.Visibility = Visibility.Visible;
}
//隐藏伪装网站
@ -1002,7 +1002,7 @@ namespace ProxySU
//生成客户端配置时连接的服务主机的IP或者域名
if (String.IsNullOrEmpty(ReceiveConfigurationParameters[4])==true)
{
ReceiveConfigurationParameters[4] = TextBoxHost.Text.ToString();
ReceiveConfigurationParameters[4] = PreTrim(TextBoxHost.Text);
testDomain = false;
}
//选择模板
@ -1217,28 +1217,10 @@ namespace ProxySU
client.RunCommand("mv /etc/caddy/Caddyfile /etc/caddy/Caddyfile.bak");
UploadConfig(connectionInfo, serverConfig, upLoadPath);
//设置Caddyfile文件中的tls 邮箱,在caddy2中已经不需要设置。
//设置Caddy配置文件
functionResult = SetCaddyfile(client, upLoadPath);
if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; }
//设置Caddy监听的随机端口
string randomCaddyListenPortStr = randomCaddyListenPort.ToString();
sshShellCommand = $"sed -i 's/8800/{randomCaddyListenPortStr}/' {upLoadPath}";
currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand);
//设置域名
sshShellCommand = $"sed -i 's/##domain##/{ReceiveConfigurationParameters[4]}/g' {upLoadPath}";
currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand);
//设置Path
sshShellCommand = $"sed -i 's/##path##/\\{ReceiveConfigurationParameters[6]}/' {upLoadPath}";
currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand);
//设置伪装网站
if (String.IsNullOrEmpty(ReceiveConfigurationParameters[7]) == false)
{
sshShellCommand = $"sed -i 's/##sites##/proxy \\/ {ReceiveConfigurationParameters[7]}/' {upLoadPath}";
currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand);
}
//****** "Caddy配置文件上传成功,OK!" ******32
SetUpProgressBarProcessing(70);
currentStatus = Application.Current.FindResource("DisplayInstallInfo_UploadCaddyConfigOK").ToString();
@ -2503,24 +2485,11 @@ namespace ProxySU
upLoadPath = "/etc/caddy/Caddyfile";
UploadConfig(connectionInfo, caddyConfig, upLoadPath);
//设置Caddyfile文件中的tls 邮箱
//设置Caddy配置文件
functionResult = SetCaddyfile(client, upLoadPath);
if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; }
//设置Caddy监听的随机端口
string randomCaddyListenPortStr = randomCaddyListenPort.ToString();
sshShellCommand = $"sed -i 's/8800/{randomCaddyListenPortStr}/' {upLoadPath}";
currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand);
//设置域名
sshShellCommand = $"sed -i 's/##domain##/{ReceiveConfigurationParameters[4]}/g' {upLoadPath}";
currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand);
//设置伪装网站
if (String.IsNullOrEmpty(ReceiveConfigurationParameters[7]) == false)
{
sshShellCommand = $"sed -i 's/##sites##/proxy \\/ {ReceiveConfigurationParameters[7]}/' {upLoadPath}";
currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand);
}
//****** "Caddy配置文件上传成功,OK!" ******
SetUpProgressBarProcessing(70);
currentStatus = Application.Current.FindResource("DisplayInstallInfo_UploadCaddyConfigOK").ToString();
@ -2939,7 +2908,7 @@ namespace ProxySU
{
ReceiveConfigurationParameters[i] = "";
}
if (string.IsNullOrEmpty(TextBoxTrojanHostDomain.Text.ToString()) == true)
if (string.IsNullOrEmpty(PreTrim(TextBoxTrojanHostDomain.Text)) == true)
{
//****** "域名不能为空,请检查相关参数设置!" ******
MessageBox.Show(Application.Current.FindResource("MessageBoxShow_DomainNotEmpty").ToString());
@ -2949,23 +2918,10 @@ namespace ProxySU
ReceiveConfigurationParameters[0] = "TrojanTLS2Web";
//传递域名
ReceiveConfigurationParameters[4] = TextBoxTrojanHostDomain.Text.ToString();
ReceiveConfigurationParameters[4] = PreTrim(TextBoxTrojanHostDomain.Text);
//传递伪装网站
ReceiveConfigurationParameters[7] = TextBoxTrojanSites.Text.ToString();
//处理伪装网站域名中的前缀
if (TextBoxTrojanSites.Text.ToString().Length >= 7)
{
string testDomain = TextBoxTrojanSites.Text.Substring(0, 7);
if (String.Equals(testDomain, "https:/") || String.Equals(testDomain, "http://"))
{
//MessageBox.Show(testDomain);
ReceiveConfigurationParameters[7] = TextBoxTrojanSites.Text.Replace("/", "\\/");
}
else
{
ReceiveConfigurationParameters[7] = "http:\\/\\/" + TextBoxTrojanSites.Text;
}
}
ReceiveConfigurationParameters[7] = DisguiseURLprocessing(PreTrim(TextBoxTrojanSites.Text));
//传递服务端口
ReceiveConfigurationParameters[1] = "443";
//传递密码(uuid)
@ -3171,23 +3127,10 @@ namespace ProxySU
UploadConfig(connectionInfo, caddyConfig, upLoadPath);
//设置Caddy监听的随机端口
string randomCaddyListenPortStr = randomCaddyListenPort.ToString();
//设置Caddy配置文件
functionResult = SetCaddyfile(client, upLoadPath);
if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; }
sshShellCommand = $"sed -i 's/8800/{randomCaddyListenPortStr}/' {upLoadPath}";
currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand);
//设置域名
sshShellCommand = $"sed -i 's/##domain##/{ReceiveConfigurationParameters[4]}/g' {upLoadPath}";
currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand);
//设置伪装网站
if (String.IsNullOrEmpty(ReceiveConfigurationParameters[7]) == false)
{
sshShellCommand = $"sed -i 's/##sites##/proxy \\/ {ReceiveConfigurationParameters[7]}/' {upLoadPath}";
currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand);
}
//****** "Caddy配置文件上传成功,OK!" ******
SetUpProgressBarProcessing(70);
currentStatus = Application.Current.FindResource("DisplayInstallInfo_UploadCaddyConfigOK").ToString();
@ -3507,7 +3450,7 @@ namespace ProxySU
//NaiveProxy一键安装开始传递参数
private void ButtonNavieSetUp_Click(object sender, RoutedEventArgs e)
{
if (string.IsNullOrEmpty(TextBoxNaiveHostDomain.Text) == true)
if (string.IsNullOrEmpty(PreTrim(TextBoxNaiveHostDomain.Text)) == true)
{
//****** "域名不能为空,请检查相关参数设置!" ******
MessageBox.Show(Application.Current.FindResource("MessageBoxShow_DomainNotEmpty").ToString());
@ -3523,24 +3466,12 @@ namespace ProxySU
}
//传递参数
ReceiveConfigurationParameters[4] = TextBoxNaiveHostDomain.Text;//传递域名
ReceiveConfigurationParameters[4] = PreTrim(TextBoxNaiveHostDomain.Text);//传递域名
ReceiveConfigurationParameters[1] = "443";//传递端口
ReceiveConfigurationParameters[3] = TextBoxNaiveUser.Text;//传递用户名
ReceiveConfigurationParameters[2] = TextBoxNaivePassword.Text;//传递密码
ReceiveConfigurationParameters[7] = TextBoxNaiveSites.Text;//传递伪装网站
if (TextBoxNaiveSites.Text.ToString().Length >= 7)
{
string testDomain = TextBoxNaiveSites.Text.Substring(0, 7);
if (String.Equals(testDomain, "https:/") || String.Equals(testDomain, "http://"))
{
//MessageBox.Show(testDomain);
ReceiveConfigurationParameters[7] = TextBoxNaiveSites.Text.Replace("/", "\\/");
}
else
{
ReceiveConfigurationParameters[7] = "http:\\/\\/" + TextBoxNaiveSites.Text;
}
}
ReceiveConfigurationParameters[7] = DisguiseURLprocessing(PreTrim(TextBoxNaiveSites.Text));//传递伪装网站
//启动布署进程
installationDegree = 0;
TextBoxMonitorCommandResults.Text = "";
@ -3673,12 +3604,17 @@ namespace ProxySU
UploadConfig(connectionInfo, caddyConfig, upLoadPath);
//$"sed -i 's/##domain##/{ReceiveConfigurationParameters[4]}/' {upLoadPath}"
//$"sed -i 's/##basicauth##/basicauth {ReceiveConfigurationParameters[3]} {ReceiveConfigurationParameters[2]}/' {upLoadPath}"
sshShellCommand = $"sed -i 's/##domain##/{ReceiveConfigurationParameters[4]}/' {upLoadPath}";
currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand);
//设置Caddy配置文件
functionResult = SetCaddyfile(client, upLoadPath);
if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; }
sshShellCommand = $"sed -i 's/##basicauth##/basic_auth {ReceiveConfigurationParameters[3]} {ReceiveConfigurationParameters[2]}/' {upLoadPath}";
currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand);
sshShellCommand = $"sed -i 's/file_server/#file_server/' {upLoadPath}";
currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand);
//string caddyConfig = $"{pwdir}" + @"TemplateConfg\naive\naive_server_config.json";
//using (StreamReader reader = File.OpenText(caddyConfig))
//{
@ -3901,7 +3837,7 @@ namespace ProxySU
{
ReceiveConfigurationParameters[i] = "";
}
if (string.IsNullOrEmpty(TextBoxSSRHostDomain.Text.ToString()) == true)
if (string.IsNullOrEmpty(PreTrim(TextBoxSSRHostDomain.Text)) == true)
{
//****** "域名不能为空,请检查相关参数设置!" ******
MessageBox.Show(Application.Current.FindResource("MessageBoxShow_DomainNotEmpty").ToString());
@ -3909,23 +3845,10 @@ namespace ProxySU
}
//传递域名
ReceiveConfigurationParameters[4] = TextBoxSSRHostDomain.Text.ToString();
ReceiveConfigurationParameters[4] = PreTrim(TextBoxSSRHostDomain.Text);
//传递伪装网站
ReceiveConfigurationParameters[7] = TextBoxSSRSites.Text.ToString();
//处理伪装网站域名中的前缀
if (TextBoxSSRSites.Text.ToString().Length >= 7)
{
string testDomain = TextBoxSSRSites.Text.Substring(0, 7);
if (String.Equals(testDomain, "https:/") || String.Equals(testDomain, "http://"))
{
//MessageBox.Show(testDomain);
ReceiveConfigurationParameters[7] = TextBoxSSRSites.Text.Replace("/", "\\/");
}
else
{
ReceiveConfigurationParameters[7] = "http:\\/\\/" + TextBoxSSRSites.Text;
}
}
ReceiveConfigurationParameters[7] = DisguiseURLprocessing(PreTrim(TextBoxSSRSites.Text));
//传递服务端口
ReceiveConfigurationParameters[1] = "443";
//传递密码(uuid)
@ -4072,21 +3995,9 @@ namespace ProxySU
UploadConfig(connectionInfo, caddyConfig, upLoadPath);
//设置Caddy监听的随机端口
string randomCaddyListenPortStr = randomCaddyListenPort.ToString();
sshShellCommand = $"sed -i 's/8800/{randomCaddyListenPortStr}/' {upLoadPath}";
currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand);
//设置域名
sshShellCommand = $"sed -i 's/##domain##/{ReceiveConfigurationParameters[4]}/g' {upLoadPath}";
currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand);
//设置伪装网站
if (String.IsNullOrEmpty(ReceiveConfigurationParameters[7]) == false)
{
sshShellCommand = $"sed -i 's/##sites##/proxy \\/ {ReceiveConfigurationParameters[7]}/' {upLoadPath}";
currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand);
}
functionResult = SetCaddyfile(client, @"/etc/caddy/Caddyfile");
if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; }
//****** "Caddy配置文件上传成功,OK!" ******
SetUpProgressBarProcessing(70);
currentStatus = Application.Current.FindResource("DisplayInstallInfo_UploadCaddyConfigOK").ToString();
@ -4249,9 +4160,9 @@ namespace ProxySU
//隐藏WebSocket路径
TextBlockShowPathSS.Visibility = Visibility.Hidden;
TextBlockCurrentlySelectedPlanPathSS.Visibility = Visibility.Hidden;
//隐藏伪装网站
TextBlockShowFakeWebsiteSS.Visibility = Visibility.Hidden;
TextBlockCurrentlySelectedPlanFakeWebsiteSS.Visibility = Visibility.Hidden;
//显示伪装网站
TextBlockShowFakeWebsiteSS.Visibility = Visibility.Visible;
TextBlockCurrentlySelectedPlanFakeWebsiteSS.Visibility = Visibility.Visible;
}
else if (String.Equals(ReceiveConfigurationParameters[0], "WebSocketTLSWebFrontSS"))
{
@ -4270,9 +4181,9 @@ namespace ProxySU
//隐藏WebSocket路径
TextBlockShowPathSS.Visibility = Visibility.Visible;
TextBlockCurrentlySelectedPlanPathSS.Visibility = Visibility.Visible;
//隐藏伪装网站
TextBlockShowFakeWebsiteSS.Visibility = Visibility.Hidden;
TextBlockCurrentlySelectedPlanFakeWebsiteSS.Visibility = Visibility.Hidden;
//显示伪装网站
TextBlockShowFakeWebsiteSS.Visibility = Visibility.Visible;
TextBlockCurrentlySelectedPlanFakeWebsiteSS.Visibility = Visibility.Visible;
}
}
@ -4294,7 +4205,7 @@ namespace ProxySU
//生成客户端配置时连接的服务主机的IP或者域名
if (String.IsNullOrEmpty(ReceiveConfigurationParameters[4]) == true)
{
ReceiveConfigurationParameters[4] = TextBoxHost.Text.ToString();
ReceiveConfigurationParameters[4] = PreTrim(TextBoxHost.Text);
testDomain = false;
}
//选择模板
@ -4734,28 +4645,10 @@ namespace ProxySU
UploadConfig(connectionInfo, serverConfig, upLoadPath);
//设置Caddyfile文件中的tls 邮箱,在caddy2中已经不需要设置。
//设置Caddy监听的随机端口
string randomCaddyListenPortStr = randomCaddyListenPort.ToString();
sshShellCommand = $"sed -i 's/8800/{randomCaddyListenPortStr}/' {upLoadPath}";
currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand);
//设置域名
sshShellCommand = $"sed -i 's/##domain##/{ReceiveConfigurationParameters[4]}/g' {upLoadPath}";
currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand);
//设置Path
sshShellCommand = $"sed -i 's/##path##/\\{ReceiveConfigurationParameters[3]}/' {upLoadPath}";
currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand);
//设置伪装网站
if (String.IsNullOrEmpty(ReceiveConfigurationParameters[7]) == false)
{
sshShellCommand = $"sed -i 's/##sites##/proxy \\/ {ReceiveConfigurationParameters[7]}/' {upLoadPath}";
currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand);
}
//设置Caddy配置文件
functionResult = SetCaddyfile(client, @"/etc/caddy/Caddyfile");
if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; }
//****** "Caddy配置文件上传成功,OK!" ******
SetUpProgressBarProcessing(70);
currentStatus = Application.Current.FindResource("DisplayInstallInfo_UploadCaddyConfigOK").ToString();
@ -4840,17 +4733,17 @@ namespace ProxySU
ReceiveConfigurationParameters[i] = "";
}
//传递服务器地址
ReceiveConfigurationParameters[4] = TextBoxHost.Text.ToString();
ReceiveConfigurationParameters[4] = PreTrim(TextBoxHost.Text); ;
//传递服务端口
ReceiveConfigurationParameters[1] = TextBoxMtgHostDomain.Text;
ReceiveConfigurationParameters[1] = PreTrim(TextBoxMtgHostPort.Text);
//传递伪装域名
if (String.IsNullOrEmpty(TextBoxMtgSites.Text) == true)
if (String.IsNullOrEmpty(PreTrim(TextBoxMtgSites.Text)) == true)
{
ReceiveConfigurationParameters[7] = "azure.microsoft.com";
}
else
{
ReceiveConfigurationParameters[7] = TextBoxMtgSites.Text;
ReceiveConfigurationParameters[7] = PreTrim(TextBoxMtgSites.Text);
}
installationDegree = 0;
TextBoxMonitorCommandResults.Text = "";
@ -5059,6 +4952,11 @@ namespace ProxySU
#endregion
#region
//TextBox输入内容做预处理
private string PreTrim(string preString)
{
return preString.Trim();
}
//产生随机端口
private int GetRandomPort()
{
@ -5157,6 +5055,25 @@ namespace ProxySU
}
}
//伪装网站处理
private string DisguiseURLprocessing(string fakeUrl)
{
//处理伪装网站域名中的前缀
if (fakeUrl.Length >= 7)
{
string testDomainMask = fakeUrl.Substring(0, 7);
if (String.Equals(testDomainMask, "https:/") || String.Equals(testDomainMask, "http://"))
{
//MessageBox.Show(testDomain);
string[] tmpUrl = fakeUrl.Split('/');
//MainWindow.ReceiveConfigurationParameters[7] = TextBoxMaskSites.Text.Replace("/", "\\/");
fakeUrl = tmpUrl[2];
}
}
return fakeUrl;
}
#region
//private static bool DetectKernelVersion(string kernelVer)
//{
@ -6165,7 +6082,7 @@ namespace ProxySU
return;
}
ReceiveConfigurationParameters[4] = TextBoxHost.Text;//传递主机地址
ReceiveConfigurationParameters[4] = PreTrim(TextBoxHost.Text); ;//传递主机地址
ReceiveConfigurationParameters[2] = PasswordBoxHostPassword.Password;//传递当前账户密码
installationDegree = 0;
@ -6358,7 +6275,7 @@ namespace ProxySU
return;
}
ReceiveConfigurationParameters[4] = TextBoxHost.Text;//传递主机地址
ReceiveConfigurationParameters[4] = PreTrim(TextBoxHost.Text);//传递主机地址
ReceiveConfigurationParameters[2] = PasswordBoxHostPassword.Password;
installationDegree = 0;
@ -6655,7 +6572,7 @@ namespace ProxySU
return;
}
ReceiveConfigurationParameters[4] = TextBoxHost.Text;//传递主机地址
ReceiveConfigurationParameters[4] = PreTrim(TextBoxHost.Text);//传递主机地址
ReceiveConfigurationParameters[2] = PasswordBoxHostPassword.Password;//传递主机密码
installationDegree = 0;
@ -6837,7 +6754,7 @@ namespace ProxySU
SaveFileDialog dlg = new SaveFileDialog();
dlg.Title = title;
string localTime = DateTime.Now.ToLocalTime().ToString().Replace(' ', '-').Replace(':', '-').Replace('/', '-').Replace('\\', '-');
dlg.FileName = $"{TextBoxHost.Text.Replace(':', '_')}_{localTime}.txt"; // Default file name
dlg.FileName = $"{PreTrim(TextBoxHost.Text).Replace(':', '_')}_{localTime}.txt"; // Default file name
dlg.DefaultExt = ".txt"; // Default file extension
dlg.Filter = "Text documents|*.txt"; // Filter files by extension
dlg.InitialDirectory = initFolder;
@ -7913,11 +7830,11 @@ namespace ProxySU
return false;
}
sshShellCommand = @"cd ~/.acme.sh/";
currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand);
//sshShellCommand = @"cd ~/.acme.sh/";
//currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand);
sshShellCommand = @"alias acme.sh=~/.acme.sh/acme.sh";
currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand);
//sshShellCommand = @"alias acme.sh=~/.acme.sh/acme.sh";
//currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand);
//****** "申请域名证书......" ******24
SetUpProgressBarProcessing(55);
@ -8064,6 +7981,45 @@ namespace ProxySU
return true;
}
//设置Caddy配置文件
//functionResult = SetCaddyfile(client, @"/etc/caddy/Caddyfile");
//if (functionResult == false) { FunctionResultErr(); client.Disconnect(); return; }
private bool SetCaddyfile(SshClient client,string upLoadPath)
{
//设置Caddyfile文件中的tls 邮箱,在caddy2中已经不需要设置。
//设置Caddy监听的随机端口
string randomCaddyListenPortStr = randomCaddyListenPort.ToString();
sshShellCommand = $"sed -i 's/8800/{randomCaddyListenPortStr}/' {upLoadPath}";
currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand);
//设置域名
ReceiveConfigurationParameters[4] = ReceiveConfigurationParameters[4].TrimEnd(' ');
sshShellCommand = $"sed -i 's/##domain##/{ReceiveConfigurationParameters[4]}/g' {upLoadPath}";
currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand);
//设置Path
sshShellCommand = $"sed -i 's/##path##/\\{ReceiveConfigurationParameters[6]}/' {upLoadPath}";
currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand);
//设置伪装网站
if (String.IsNullOrEmpty(ReceiveConfigurationParameters[7]) == false)
{
sshShellCommand = $"sed -i 's/##reverse_Proxy1##/reverse_proxy http:\\/\\/{ReceiveConfigurationParameters[7]} {{/ ' {upLoadPath}";
currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand);
sshShellCommand = $"sed -i 's/##reverse_Proxy2##/header_up Host {ReceiveConfigurationParameters[7]}/' {upLoadPath}";
currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand);
sshShellCommand = $"sed -i 's/##reverse_Proxy3##/}}/' {upLoadPath}";
currentShellCommandResult = MainWindowsShowCmd(client, sshShellCommand);
}
return true;
}
//程序启动检测
//soft--要检测的程序
//condition---成功启动的条件

View file

@ -265,8 +265,8 @@
<TextBox x:Name="TextBoxDomainSS" Style="{StaticResource TitleText}" Tag="{DynamicResource TextBoxDomainPrompt}" Grid.Column="1" Grid.Row="4" Grid.ColumnSpan="3" Margin="3"></TextBox>
<Button x:Name="ButtonDomain" Content="检测" Visibility="Collapsed" Grid.Column="4" Grid.Row="4" Margin="2" ></Button>
<TextBlock x:Name="TextBlockMaskSites" Text="{DynamicResource TextBlockV2RayMaskSites}" Grid.Column="0" Grid.Row="5" Grid.ColumnSpan="1" Visibility="Hidden"></TextBlock>
<TextBox x:Name="TextBoxMaskSites" Style="{StaticResource TitleText}" Tag="{DynamicResource TextBoxV2RayMaskSitesTag}" Grid.Column="1" Grid.Row="5" Grid.ColumnSpan="3" Margin="3" Visibility="Hidden"></TextBox>
<TextBlock x:Name="TextBlockMaskSites" Text="{DynamicResource TextBlockV2RayMaskSites}" Grid.Column="0" Grid.Row="5" Grid.ColumnSpan="1" VerticalAlignment="Center" HorizontalAlignment="Right"></TextBlock>
<TextBox x:Name="TextBoxMaskSites" Style="{StaticResource TitleText}" Tag="{DynamicResource TextBoxV2RayMaskSitesTag}" Grid.Column="1" Grid.Row="5" Grid.ColumnSpan="3" Margin="3"></TextBox>
<Button x:Name="ButtondDecide" Content="{DynamicResource ButtonTrojanGoTemplateOK}" Grid.Column="1" Grid.Row="6" Margin="0" Click="ButtondDecide_Click"></Button>

View file

@ -72,21 +72,20 @@ namespace ProxySU
//伪装网站处理
private void DisguiseURLprocessing()
private string DisguiseURLprocessing(string fakeUrl)
{
//处理伪装网站域名中的前缀
if (TextBoxMaskSites.Text.ToString().Length >= 7)
if (fakeUrl.Length >= 7)
{
string testDomain = TextBoxMaskSites.Text.Substring(0, 7);
if (String.Equals(testDomain, "https:/") || String.Equals(testDomain, "http://"))
string testDomainMask = fakeUrl.Substring(0, 7);
if (String.Equals(testDomainMask, "https:/") || String.Equals(testDomainMask, "http://"))
{
MainWindow.ReceiveConfigurationParameters[7] = TextBoxMaskSites.Text.Replace("/", "\\/");
}
else
{
MainWindow.ReceiveConfigurationParameters[7] = "http:\\/\\/" + TextBoxMaskSites.Text;
string[] tmpUrl = fakeUrl.Split('/');
fakeUrl = tmpUrl[2];
}
}
return fakeUrl;
}
private void ButtondDecide_Click(object sender, RoutedEventArgs e)
@ -114,19 +113,16 @@ namespace ProxySU
//SS+obfs+TLS+web模式被选中
else if (RadioButtonObfsPluginHttpsWebSS.IsChecked == true)
{
//if (string.IsNullOrEmpty(TextBoxDomainSS.Text.ToString()) == true)
//{
// //****** "域名不能为空,请检查相关参数设置!" ******
// MessageBox.Show(Application.Current.FindResource("MessageBoxShow_DomainNotEmpty").ToString());
// return;
//}
testDomain = TestDomainIsEmpty();
//传递模板类型
MainWindow.ReceiveConfigurationParameters[0] = "ObfsPluginHttpsWebSS";
//传递方案名称
MainWindow.ReceiveConfigurationParameters[8] = RadioButtonObfsPluginHttpsWebSS.Content.ToString();
//传递域名
MainWindow.ReceiveConfigurationParameters[4] = TextBoxDomainSS.Text.ToString();
MainWindow.ReceiveConfigurationParameters[4] = PreTrim(TextBoxDomainSS.Text);
//传递伪装网站
MainWindow.ReceiveConfigurationParameters[7] = DisguiseURLprocessing(PreTrim(TextBoxMaskSites.Text));
}
@ -138,7 +134,7 @@ namespace ProxySU
//传递方案名称
MainWindow.ReceiveConfigurationParameters[8] = RadioButtonWebSocketSS.Content.ToString();
//传递路径
MainWindow.ReceiveConfigurationParameters[6] = TextBoxWebSocketPathSS.Text.ToString();
MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxWebSocketPathSS.Text);
}
//V2Ray-Plugin SS+WebSocket+TLS+Web模式被选中
@ -151,26 +147,12 @@ namespace ProxySU
MainWindow.ReceiveConfigurationParameters[8] = RadioButtonWebSocketTLSWebFrontSS.Content.ToString();
//传递路径
MainWindow.ReceiveConfigurationParameters[6] = TextBoxWebSocketPathSS.Text.ToString();
MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxWebSocketPathSS.Text);
//传递域名
MainWindow.ReceiveConfigurationParameters[4] = TextBoxDomainSS.Text.ToString();
MainWindow.ReceiveConfigurationParameters[4] = PreTrim(TextBoxDomainSS.Text);
//传递伪装网站
//MainWindow.ReceiveConfigurationParameters[7] = TextBoxMaskSites.Text.ToString();
//处理伪装网站域名中的前缀
//DisguiseURLprocessing();
//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[7] = DisguiseURLprocessing(PreTrim(TextBoxMaskSites.Text));
}
//V2Ray-Plugin SS+QUIC模式被选中
else if (RadioButtonQuicSS.IsChecked == true)
@ -182,7 +164,7 @@ namespace ProxySU
MainWindow.ReceiveConfigurationParameters[8] = RadioButtonQuicSS.Content.ToString();
//传递域名
MainWindow.ReceiveConfigurationParameters[4] = TextBoxDomainSS.Text.ToString();
MainWindow.ReceiveConfigurationParameters[4] = PreTrim(TextBoxDomainSS.Text);
}
//SS+kcptun-plugin模式被选中
@ -203,7 +185,7 @@ namespace ProxySU
//传递方案名称
MainWindow.ReceiveConfigurationParameters[8] = RadioButtonGoQuietPluginSS.Content.ToString();
//传递域名
MainWindow.ReceiveConfigurationParameters[4] = TextBoxDomainSS.Text.ToString();
MainWindow.ReceiveConfigurationParameters[4] = PreTrim(TextBoxDomainSS.Text);
}
//SS+Cloak-Plugin模式被选中
@ -215,14 +197,14 @@ namespace ProxySU
//传递方案名称
MainWindow.ReceiveConfigurationParameters[8] = RadioButtonCloakPluginSS.Content.ToString();
//传递域名
MainWindow.ReceiveConfigurationParameters[4] = TextBoxDomainSS.Text.ToString();
MainWindow.ReceiveConfigurationParameters[4] = PreTrim(TextBoxDomainSS.Text);
}
//传递服务端口
MainWindow.ReceiveConfigurationParameters[1] = TextBoxServerListenPortSS.Text.ToString();
MainWindow.ReceiveConfigurationParameters[1] = PreTrim(TextBoxServerListenPortSS.Text);
//传递uuid密码
MainWindow.ReceiveConfigurationParameters[2] = TextBoxNewUUIDSS.Text.ToString();
MainWindow.ReceiveConfigurationParameters[2] = PreTrim(TextBoxNewUUIDSS.Text);
//传递加密方式
MainWindow.ReceiveConfigurationParameters[3] = GetEncryptionMethodSS();
@ -278,9 +260,9 @@ namespace ProxySU
TextBoxDomainSS.Visibility = Visibility.Visible;
//检测域名按钮
ButtonDomain.Visibility = Visibility.Collapsed;
//隐藏伪装网站
TextBlockMaskSites.Visibility = Visibility.Collapsed;
TextBoxMaskSites.Visibility = Visibility.Collapsed;
//显示伪装网站
TextBlockMaskSites.Visibility = Visibility.Visible;
TextBoxMaskSites.Visibility = Visibility.Visible;
//初始化密码
TextBoxNewUUIDSS.Text = GenerateRandomUUID();
@ -290,7 +272,6 @@ namespace ProxySU
UncheckLayouts((TabItem)TabControlTemplate.SelectedItem);
}
//使用V2ray-plugin 的Websocket over https (TLS)
private void RadioButtonUseDomainWebsocketTls_Checked(object sender, RoutedEventArgs e)
{
@ -306,9 +287,9 @@ namespace ProxySU
TextBoxDomainSS.Visibility = Visibility.Visible;
//检测域名按钮
ButtonDomain.Visibility = Visibility.Collapsed;
//隐藏伪装网站
TextBlockMaskSites.Visibility = Visibility.Collapsed;
TextBoxMaskSites.Visibility = Visibility.Collapsed;
//显示伪装网站
TextBlockMaskSites.Visibility = Visibility.Visible;
TextBoxMaskSites.Visibility = Visibility.Visible;
//初始化密码
TextBoxNewUUIDSS.Text = GenerateRandomUUID();
@ -386,10 +367,16 @@ namespace ProxySU
#endregion
//TextBox输入内容做预处理
private string PreTrim(string preString)
{
return preString.Trim();
}
//域名检测是否为空
private bool TestDomainIsEmpty()
{
if (string.IsNullOrEmpty(TextBoxDomainSS.Text.ToString()) == true)
if (string.IsNullOrEmpty(PreTrim(TextBoxDomainSS.Text)) == true)
{
//****** "域名不能为空,请检查相关参数设置!" ******
MessageBox.Show(Application.Current.FindResource("MessageBoxShow_DomainNotEmpty").ToString());

View file

@ -109,8 +109,8 @@
</Grid>
<TextBlock x:Name="TextBlockExplainCheckBoxMuxSelect" Text="{DynamicResource TextBlockExplainCheckBoxMuxSelect}" TextWrapping="Wrap" Grid.Column="2" Grid.Row="3" Grid.ColumnSpan="2" Grid.RowSpan="2"></TextBlock>
<TextBlock x:Name="TextBlockMaskSites" Text="{DynamicResource TextBlockV2RayMaskSites}" Grid.Column="0" Grid.Row="3" Grid.ColumnSpan="2" Visibility="Hidden"></TextBlock>
<TextBox x:Name="TextBoxMaskSites" Style="{StaticResource TitleText}" Tag="{DynamicResource TextBoxV2RayMaskSitesTag}" Grid.Column="1" Grid.Row="3" Margin="5" Visibility="Hidden"></TextBox>
<TextBlock x:Name="TextBlockMaskSites" Text="{DynamicResource TextBlockV2RayMaskSites}" Grid.Column="0" Grid.Row="4" HorizontalAlignment="Right" VerticalAlignment="Center"></TextBlock>
<TextBox x:Name="TextBoxMaskSites" Style="{StaticResource TitleText}" Tag="{DynamicResource TextBoxV2RayMaskSitesTag}" Grid.Column="1" Grid.Row="4" Margin="5"></TextBox>
<Grid Grid.Column="0" Grid.Row="6" Grid.ColumnSpan="4">
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>

View file

@ -28,35 +28,21 @@ namespace ProxySU
}
private void ButtondDecide_Click(object sender, RoutedEventArgs e)
{
if (string.IsNullOrEmpty(TextBoxDomain.Text.ToString()) == true)
if (string.IsNullOrEmpty(PreTrim(TextBoxDomain.Text)) == true)
{
//****** "域名不能为空,请检查相关参数设置!" ******
MessageBox.Show(Application.Current.FindResource("MessageBoxShow_DomainNotEmpty").ToString());
return;
}
//传递域名
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[4] = PreTrim(TextBoxDomain.Text);
//传递伪装网站
MainWindow.ReceiveConfigurationParameters[7] = DisguiseURLprocessing(PreTrim(TextBoxMaskSites.Text));
//传递服务端口
MainWindow.ReceiveConfigurationParameters[1] = "443";
//传递密码(uuid)
MainWindow.ReceiveConfigurationParameters[2] = TextBoxNewUUID.Text.ToString();
MainWindow.ReceiveConfigurationParameters[2] = PreTrim(TextBoxNewUUID.Text);
if (RadioButtonTrojanGoTLS2Web.IsChecked == true)
{
//传递模板类型
@ -72,14 +58,14 @@ namespace ProxySU
//传递方案名称
MainWindow.ReceiveConfigurationParameters[8] = RadioButtonTrojanGoWebSocketTLS2Web.Content.ToString();
//传递路径
MainWindow.ReceiveConfigurationParameters[6] = TextBoxPath.Text;
MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxPath.Text);
}
//传递Mux的concurrency与idle_timeout
if (CheckBoxMuxSelect.IsChecked == true)
{
MainWindow.ReceiveConfigurationParameters[9] = "true";
MainWindow.ReceiveConfigurationParameters[3] = TextBoxConcurrency.Text;
MainWindow.ReceiveConfigurationParameters[5] = TextBoxIdle_timeout.Text;
MainWindow.ReceiveConfigurationParameters[3] = PreTrim(TextBoxConcurrency.Text);
MainWindow.ReceiveConfigurationParameters[5] = PreTrim(TextBoxIdle_timeout.Text);
}
this.Close();
}
@ -150,7 +136,7 @@ namespace ProxySU
//域名检测是否为空
private bool TestDomainIsEmpty()
{
if (string.IsNullOrEmpty(TextBoxDomain.Text.ToString()) == true)
if (string.IsNullOrEmpty(PreTrim(TextBoxDomain.Text)) == true)
{
//****** "域名不能为空,请检查相关参数设置!" ******
MessageBox.Show(Application.Current.FindResource("MessageBoxShow_DomainNotEmpty").ToString());
@ -173,5 +159,28 @@ namespace ProxySU
GridTrojanGoMuxSelected.Visibility = Visibility.Collapsed;
TextBlockExplainCheckBoxMuxSelect.Visibility = Visibility.Collapsed;
}
//TextBox输入内容做预处理
private string PreTrim(string preString)
{
return preString.Trim();
}
//处理伪装网站域名中的前缀
private string DisguiseURLprocessing(string fakeUrl)
{
if (fakeUrl.Length >= 7)
{
string testDomainMask = fakeUrl.Substring(0, 7);
if (String.Equals(testDomainMask, "https:/") || String.Equals(testDomainMask, "http://"))
{
string[] tmpUrl = fakeUrl.Split('/');
fakeUrl = tmpUrl[2];
}
}
return fakeUrl;
}
}
}

View file

@ -372,8 +372,8 @@
<TextBlock x:Name="TextBlockDomain" Text="{DynamicResource TextBlockV2RayDomain}" Grid.Column="0" Grid.Row="4" Grid.ColumnSpan="1" HorizontalAlignment="Right" VerticalAlignment="Center"></TextBlock>
<TextBox x:Name="TextBoxDomain" Style="{StaticResource TitleText}" Tag="{DynamicResource TextBoxDomainPrompt}" Grid.Column="1" Grid.Row="4" Grid.ColumnSpan="3" Margin="3"></TextBox>
<Button x:Name="ButtonDomain" Content="检测" Visibility="Collapsed" Grid.Column="4" Grid.Row="4" Margin="2" Click="ButtonDomain_Click"></Button>
<TextBlock x:Name="TextBlockMaskSites" Text="{DynamicResource TextBlockV2RayMaskSites}" Grid.Column="0" Grid.Row="5" Grid.ColumnSpan="1" Visibility="Hidden"></TextBlock>
<TextBox x:Name="TextBoxMaskSites" Style="{StaticResource TitleText}" Tag="{DynamicResource TextBoxV2RayMaskSitesTag}" Grid.Column="1" Grid.Row="5" Grid.ColumnSpan="3" Margin="3" Visibility="Hidden"></TextBox>
<TextBlock x:Name="TextBlockMaskSites" Text="{DynamicResource TextBlockV2RayMaskSites}" Grid.Column="0" Grid.Row="5" Grid.ColumnSpan="1" HorizontalAlignment="Right" VerticalAlignment="Center" ></TextBlock>
<TextBox x:Name="TextBoxMaskSites" Style="{StaticResource TitleText}" Tag="{DynamicResource TextBoxV2RayMaskSitesTag}" Grid.Column="1" Grid.Row="5" Grid.ColumnSpan="3" Margin="3" ></TextBox>
<Button x:Name="ButtondDecide" Content="{DynamicResource ButtonTrojanGoTemplateOK}" Grid.Column="1" Grid.Row="6" Margin="0" Click="ButtondDecide_Click"></Button>

View file

@ -111,7 +111,7 @@ namespace ProxySU
MainWindow.ReceiveConfigurationParameters[8] = RadioButtonTCP2TLS.Content.ToString();
//传递域名
MainWindow.ReceiveConfigurationParameters[4] = TextBoxDomain.Text.ToString();
MainWindow.ReceiveConfigurationParameters[4] = PreTrim(TextBoxDomain.Text);
}
@ -124,7 +124,7 @@ namespace ProxySU
MainWindow.ReceiveConfigurationParameters[8] = RadioButtonTcpTLS2SelfSigned.Content.ToString();
//传递域名
// MainWindow.ReceiveConfigurationParameters[4] = TextBoxDomain.Text.ToString();
// MainWindow.ReceiveConfigurationParameters[4] = PreTrim(TextBoxDomain.Text);
}
@ -143,12 +143,10 @@ namespace ProxySU
MainWindow.ReceiveConfigurationParameters[8] = RadioButtonVlessXtlsTcp.Content.ToString();
//传递域名
MainWindow.ReceiveConfigurationParameters[4] = TextBoxDomain.Text.ToString();
MainWindow.ReceiveConfigurationParameters[4] = PreTrim(TextBoxDomain.Text);
//传递伪装网站
MainWindow.ReceiveConfigurationParameters[7] = TextBoxMaskSites.Text.ToString();
//处理伪装网站域名中的前缀
DisguiseURLprocessing();
MainWindow.ReceiveConfigurationParameters[7] = DisguiseURLprocessing(PreTrim(TextBoxMaskSites.Text));
}
//VLESS+TCP+TLS+Web模式选中
@ -162,11 +160,9 @@ namespace ProxySU
MainWindow.ReceiveConfigurationParameters[8] = RadioButtonVlessTcpTlsWeb.Content.ToString();
//传递域名
MainWindow.ReceiveConfigurationParameters[4] = TextBoxDomain.Text.ToString();
MainWindow.ReceiveConfigurationParameters[4] = PreTrim(TextBoxDomain.Text);
//传递伪装网站
MainWindow.ReceiveConfigurationParameters[7] = TextBoxMaskSites.Text.ToString();
//处理伪装网站域名中的前缀
DisguiseURLprocessing();
MainWindow.ReceiveConfigurationParameters[7] = DisguiseURLprocessing(PreTrim(TextBoxMaskSites.Text));
}
@ -181,13 +177,11 @@ namespace ProxySU
MainWindow.ReceiveConfigurationParameters[8] = RadioButtonVlessWebSocketTlsWeb.Content.ToString();
//传递路径
MainWindow.ReceiveConfigurationParameters[6] = TextBoxPath.Text.ToString();
MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxPath.Text);
//传递域名
MainWindow.ReceiveConfigurationParameters[4] = TextBoxDomain.Text.ToString();
MainWindow.ReceiveConfigurationParameters[4] = PreTrim(TextBoxDomain.Text);
//传递伪装网站
MainWindow.ReceiveConfigurationParameters[7] = TextBoxMaskSites.Text.ToString();
//处理伪装网站域名中的前缀
DisguiseURLprocessing();
MainWindow.ReceiveConfigurationParameters[7] = DisguiseURLprocessing(PreTrim(TextBoxMaskSites.Text));
}
//VLESS+http2+TLS+Web模式选中
@ -201,13 +195,11 @@ namespace ProxySU
MainWindow.ReceiveConfigurationParameters[8] = RadioButtonVlessHttp2Web.Content.ToString();
//传递路径
MainWindow.ReceiveConfigurationParameters[6] = TextBoxPath.Text.ToString();
MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxPath.Text);
//传递域名
MainWindow.ReceiveConfigurationParameters[4] = TextBoxDomain.Text.ToString();
MainWindow.ReceiveConfigurationParameters[4] = PreTrim(TextBoxDomain.Text);
//传递伪装网站
MainWindow.ReceiveConfigurationParameters[7] = TextBoxMaskSites.Text.ToString();
//处理伪装网站域名中的前缀
DisguiseURLprocessing();
MainWindow.ReceiveConfigurationParameters[7] = DisguiseURLprocessing(PreTrim(TextBoxMaskSites.Text));
}
//VLESS+VMESS+XTLS+TCP+WebSocket+Web模式被选中
@ -219,18 +211,16 @@ namespace ProxySU
//传递方案名称
MainWindow.ReceiveConfigurationParameters[8] = RadioButtonVlessVmessXtlsTcpWebSocketHot.Content.ToString();
//传递路径
MainWindow.ReceiveConfigurationParameters[3] = TextBoxPathVlessWS.Text.ToString();//VLESS ws Path
MainWindow.ReceiveConfigurationParameters[9] = TextBoxPathVmessTcp.Text.ToString();//VMESS tcp Path
MainWindow.ReceiveConfigurationParameters[6] = TextBoxPathVmessWS.Text.ToString();//VMESS ws Path
MainWindow.ReceiveConfigurationParameters[3] = PreTrim(TextBoxPathVlessWS.Text);//VLESS ws Path
MainWindow.ReceiveConfigurationParameters[9] = PreTrim(TextBoxPathVmessTcp.Text);//VMESS tcp Path
MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxPathVmessWS.Text);//VMESS ws Path
//传递域名
MainWindow.ReceiveConfigurationParameters[4] = TextBoxDomain.Text.ToString();
MainWindow.ReceiveConfigurationParameters[4] = PreTrim(TextBoxDomain.Text);
//传递混淆方式(VMESS TCP Path方式所用)
MainWindow.ReceiveConfigurationParameters[5] = "http";
//传递伪装网站
MainWindow.ReceiveConfigurationParameters[7] = TextBoxMaskSites.Text.ToString();
//处理伪装网站域名中的前缀
DisguiseURLprocessing();
MainWindow.ReceiveConfigurationParameters[7] = DisguiseURLprocessing(PreTrim(TextBoxMaskSites.Text));
}
@ -258,9 +248,9 @@ namespace ProxySU
//传递方案名称
MainWindow.ReceiveConfigurationParameters[8] = RadioButtonWebSocketTLS.Content.ToString();
//传递路径
MainWindow.ReceiveConfigurationParameters[6] = TextBoxPath.Text.ToString();
MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxPath.Text);
//传递域名
MainWindow.ReceiveConfigurationParameters[4] = TextBoxDomain.Text.ToString();
MainWindow.ReceiveConfigurationParameters[4] = PreTrim(TextBoxDomain.Text);
}
@ -275,13 +265,11 @@ namespace ProxySU
MainWindow.ReceiveConfigurationParameters[8] = RadioButtonWebSocketTLS2Web.Content.ToString();
//传递路径
MainWindow.ReceiveConfigurationParameters[6] = TextBoxPath.Text.ToString();
MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxPath.Text);
//传递域名
MainWindow.ReceiveConfigurationParameters[4] = TextBoxDomain.Text.ToString();
MainWindow.ReceiveConfigurationParameters[4] = PreTrim(TextBoxDomain.Text);
//传递伪装网站
MainWindow.ReceiveConfigurationParameters[7] = TextBoxMaskSites.Text.ToString();
//处理伪装网站域名中的前缀
DisguiseURLprocessing();
MainWindow.ReceiveConfigurationParameters[7] = DisguiseURLprocessing(PreTrim(TextBoxMaskSites.Text));
}
@ -294,9 +282,9 @@ namespace ProxySU
MainWindow.ReceiveConfigurationParameters[8] = RadioButtonWebSocketTLSselfSigned.Content.ToString();
//传递路径
MainWindow.ReceiveConfigurationParameters[6] = TextBoxPath.Text.ToString();
MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxPath.Text);
//传递域名
//MainWindow.ReceiveConfigurationParameters[4] = TextBoxDomain.Text.ToString();
//MainWindow.ReceiveConfigurationParameters[4] = PreTrim(TextBoxDomain.Text);
}
@ -315,9 +303,9 @@ namespace ProxySU
MainWindow.ReceiveConfigurationParameters[8] = RadioButtonHTTP2.Content.ToString();
//传递路径
MainWindow.ReceiveConfigurationParameters[6] = TextBoxPath.Text.ToString();
MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxPath.Text);
//传递域名
MainWindow.ReceiveConfigurationParameters[4] = TextBoxDomain.Text.ToString();
MainWindow.ReceiveConfigurationParameters[4] = PreTrim(TextBoxDomain.Text);
}
@ -332,13 +320,11 @@ namespace ProxySU
MainWindow.ReceiveConfigurationParameters[8] = RadioButtonHTTP2Web.Content.ToString();
//传递路径
MainWindow.ReceiveConfigurationParameters[6] = TextBoxPath.Text.ToString();
MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxPath.Text);
//传递域名
MainWindow.ReceiveConfigurationParameters[4] = TextBoxDomain.Text.ToString();
MainWindow.ReceiveConfigurationParameters[4] = PreTrim(TextBoxDomain.Text);
//传递伪装网站
MainWindow.ReceiveConfigurationParameters[7] = TextBoxMaskSites.Text.ToString();
//处理伪装网站域名中的前缀
DisguiseURLprocessing();
MainWindow.ReceiveConfigurationParameters[7] = DisguiseURLprocessing(PreTrim(TextBoxMaskSites.Text));
}
@ -351,9 +337,9 @@ namespace ProxySU
MainWindow.ReceiveConfigurationParameters[8] = RadioButtonHTTP2selfSigned.Content.ToString();
//传递路径
MainWindow.ReceiveConfigurationParameters[6] = TextBoxPath.Text.ToString();
MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxPath.Text);
//传递域名
//MainWindow.ReceiveConfigurationParameters[4] = TextBoxDomain.Text.ToString();
//MainWindow.ReceiveConfigurationParameters[4] = PreTrim(TextBoxDomain.Text);
}
@ -371,9 +357,9 @@ namespace ProxySU
//传递伪装类型
MainWindow.ReceiveConfigurationParameters[5] = "none";
//传递mKCP Seed
if (String.IsNullOrEmpty(TextBoxQuicAndMkcpSeedUUID.Text)==false)
if (String.IsNullOrEmpty(PreTrim(TextBoxQuicAndMkcpSeedUUID.Text)) ==false)
{
MainWindow.ReceiveConfigurationParameters[6] = TextBoxQuicAndMkcpSeedUUID.Text;
MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxQuicAndMkcpSeedUUID.Text);
}
}
@ -387,9 +373,9 @@ namespace ProxySU
//传递伪装类型
MainWindow.ReceiveConfigurationParameters[5] = "srtp";
//传递mKCP Seed
if (String.IsNullOrEmpty(TextBoxQuicAndMkcpSeedUUID.Text) == false)
if (String.IsNullOrEmpty(PreTrim(TextBoxQuicAndMkcpSeedUUID.Text)) == false)
{
MainWindow.ReceiveConfigurationParameters[6] = TextBoxQuicAndMkcpSeedUUID.Text;
MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxQuicAndMkcpSeedUUID.Text);
}
}
@ -403,9 +389,9 @@ namespace ProxySU
//传递伪装类型
MainWindow.ReceiveConfigurationParameters[5] = "utp";
//传递mKCP Seed
if (String.IsNullOrEmpty(TextBoxQuicAndMkcpSeedUUID.Text) == false)
if (String.IsNullOrEmpty(PreTrim(TextBoxQuicAndMkcpSeedUUID.Text)) == false)
{
MainWindow.ReceiveConfigurationParameters[6] = TextBoxQuicAndMkcpSeedUUID.Text;
MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxQuicAndMkcpSeedUUID.Text);
}
}
@ -419,9 +405,9 @@ namespace ProxySU
//传递伪装类型
MainWindow.ReceiveConfigurationParameters[5] = "wechat-video";
//传递mKCP Seed
if (String.IsNullOrEmpty(TextBoxQuicAndMkcpSeedUUID.Text) == false)
if (String.IsNullOrEmpty(PreTrim(TextBoxQuicAndMkcpSeedUUID.Text)) == false)
{
MainWindow.ReceiveConfigurationParameters[6] = TextBoxQuicAndMkcpSeedUUID.Text;
MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxQuicAndMkcpSeedUUID.Text);
}
}
@ -435,9 +421,9 @@ namespace ProxySU
//传递伪装类型
MainWindow.ReceiveConfigurationParameters[5] = "dtls";
//传递mKCP Seed
if (String.IsNullOrEmpty(TextBoxQuicAndMkcpSeedUUID.Text) == false)
if (String.IsNullOrEmpty(PreTrim(TextBoxQuicAndMkcpSeedUUID.Text)) == false)
{
MainWindow.ReceiveConfigurationParameters[6] = TextBoxQuicAndMkcpSeedUUID.Text;
MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxQuicAndMkcpSeedUUID.Text);
}
}
@ -451,9 +437,9 @@ namespace ProxySU
//传递伪装类型
MainWindow.ReceiveConfigurationParameters[5] = "wireguard";
//传递mKCP Seed
if (String.IsNullOrEmpty(TextBoxQuicAndMkcpSeedUUID.Text) == false)
if (String.IsNullOrEmpty(PreTrim(TextBoxQuicAndMkcpSeedUUID.Text)) == false)
{
MainWindow.ReceiveConfigurationParameters[6] = TextBoxQuicAndMkcpSeedUUID.Text;
MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxQuicAndMkcpSeedUUID.Text);
}
}
@ -471,7 +457,7 @@ namespace ProxySU
//传递伪装类型
MainWindow.ReceiveConfigurationParameters[5] = "none";
//QUIC 密钥
MainWindow.ReceiveConfigurationParameters[6] = TextBoxQuicAndMkcpSeedUUID.Text;
MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxQuicAndMkcpSeedUUID.Text);
//QUIC加密方法
MainWindow.ReceiveConfigurationParameters[3] = GetEncryptionMethodSS();
}
@ -486,7 +472,7 @@ namespace ProxySU
//传递伪装类型
MainWindow.ReceiveConfigurationParameters[5] = "srtp";
//QUIC 密钥
MainWindow.ReceiveConfigurationParameters[6] = TextBoxQuicAndMkcpSeedUUID.Text;
MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxQuicAndMkcpSeedUUID.Text);
//QUIC加密方法
MainWindow.ReceiveConfigurationParameters[3] = GetEncryptionMethodSS();
}
@ -501,7 +487,7 @@ namespace ProxySU
//传递伪装类型
MainWindow.ReceiveConfigurationParameters[5] = "utp";
//QUIC 密钥
MainWindow.ReceiveConfigurationParameters[6] = TextBoxQuicAndMkcpSeedUUID.Text;
MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxQuicAndMkcpSeedUUID.Text);
//QUIC加密方法
MainWindow.ReceiveConfigurationParameters[3] = GetEncryptionMethodSS();
}
@ -516,7 +502,7 @@ namespace ProxySU
//传递伪装类型
MainWindow.ReceiveConfigurationParameters[5] = "wechat-video";
//QUIC 密钥
MainWindow.ReceiveConfigurationParameters[6] = TextBoxQuicAndMkcpSeedUUID.Text;
MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxQuicAndMkcpSeedUUID.Text);
//QUIC加密方法
MainWindow.ReceiveConfigurationParameters[3] = GetEncryptionMethodSS();
}
@ -531,7 +517,7 @@ namespace ProxySU
//传递伪装类型
MainWindow.ReceiveConfigurationParameters[5] = "dtls";
//QUIC 密钥
MainWindow.ReceiveConfigurationParameters[6] = TextBoxQuicAndMkcpSeedUUID.Text;
MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxQuicAndMkcpSeedUUID.Text);
//QUIC加密方法
MainWindow.ReceiveConfigurationParameters[3] = GetEncryptionMethodSS();
}
@ -546,7 +532,7 @@ namespace ProxySU
//传递伪装类型
MainWindow.ReceiveConfigurationParameters[5] = "wireguard";
//QUIC 密钥
MainWindow.ReceiveConfigurationParameters[6] = TextBoxQuicAndMkcpSeedUUID.Text;
MainWindow.ReceiveConfigurationParameters[6] = PreTrim(TextBoxQuicAndMkcpSeedUUID.Text);
//QUIC加密方法
MainWindow.ReceiveConfigurationParameters[3] = GetEncryptionMethodSS();
}
@ -554,9 +540,9 @@ namespace ProxySU
#endregion
//传递服务端口
MainWindow.ReceiveConfigurationParameters[1] = TextBoxServerListenPort.Text.ToString();
MainWindow.ReceiveConfigurationParameters[1] = PreTrim(TextBoxServerListenPort.Text);
//传递uuid
MainWindow.ReceiveConfigurationParameters[2] = TextBoxNewUUID.Text.ToString();
MainWindow.ReceiveConfigurationParameters[2] = PreTrim(TextBoxNewUUID.Text);
if (RadioButtonVLESSmKCP.IsChecked == true)
{
@ -579,24 +565,23 @@ namespace ProxySU
//伪装网站处理
private void DisguiseURLprocessing()
//DisguiseURLprocessing(string fakeUrl);
private string DisguiseURLprocessing(string fakeUrl)
{
//处理伪装网站域名中的前缀
if (TextBoxMaskSites.Text.ToString().Length >= 7)
if (fakeUrl.Length >= 7)
{
string testDomainMask = TextBoxMaskSites.Text.Substring(0, 7);
string testDomainMask = fakeUrl.Substring(0, 7);
if (String.Equals(testDomainMask, "https:/") || String.Equals(testDomainMask, "http://"))
{
//MessageBox.Show(testDomain);
MainWindow.ReceiveConfigurationParameters[7] = TextBoxMaskSites.Text.Replace("/", "\\/");
}
else
{
MainWindow.ReceiveConfigurationParameters[7] = "http:\\/\\/" + TextBoxMaskSites.Text;
string[] tmpUrl = fakeUrl.Split('/');
fakeUrl = tmpUrl[2];
}
}
return fakeUrl;
}
#region
private void RadioButtonTCP_Checked(object sender, RoutedEventArgs e)
@ -1022,8 +1007,8 @@ namespace ProxySU
//显示伪装网站
private void ShowMaskSites()
{
TextBlockMaskSites.Visibility = Visibility.Collapsed;
TextBoxMaskSites.Visibility = Visibility.Collapsed;
TextBlockMaskSites.Visibility = Visibility.Visible;
TextBoxMaskSites.Visibility = Visibility.Visible;
}
#endregion
@ -1065,7 +1050,11 @@ namespace ProxySU
path = GenerateRandomPath();
TextBoxPathVmessWS.Text = $"/{path}";
}
//TextBox输入内容做预处理
private string PreTrim(string preString)
{
return preString.Trim();
}
//生成随机端口
private int GetRandomPort()
{
@ -1094,7 +1083,7 @@ namespace ProxySU
//域名检测是否为空
private bool TestDomainIsEmpty()
{
if (string.IsNullOrEmpty(TextBoxDomain.Text.ToString()) == true)
if (string.IsNullOrEmpty(PreTrim(TextBoxDomain.Text)) == true)
{
//****** "域名不能为空,请检查相关参数设置!" ******
MessageBox.Show(Application.Current.FindResource("MessageBoxShow_DomainNotEmpty").ToString());

Binary file not shown.