mirror of
https://github.com/proxysu/ProxySU.git
synced 2025-02-21 08:53:17 +03:00
优化NaiveProxy网络参数,若符合条件,自动启用BBR
This commit is contained in:
parent
f0aa7bc793
commit
b1ccd74b40
3
.gitignore
vendored
3
.gitignore
vendored
@ -15,6 +15,9 @@
|
|||||||
[Dd]ebugPublic/
|
[Dd]ebugPublic/
|
||||||
# [Rr]elease/
|
# [Rr]elease/
|
||||||
[Rr]eleases/
|
[Rr]eleases/
|
||||||
|
naive_config/
|
||||||
|
trojan_config/
|
||||||
|
v2ray_config/
|
||||||
x64/
|
x64/
|
||||||
x86/
|
x86/
|
||||||
build/
|
build/
|
||||||
|
@ -284,11 +284,43 @@
|
|||||||
<WebBrowser x:Name="WebBrowserResourcesAndTools" Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="9" Grid.RowSpan="13" Source="https://github.com/proxysu/windows/wiki/ResourcesAndTools" />
|
<WebBrowser x:Name="WebBrowserResourcesAndTools" Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="9" Grid.RowSpan="13" Source="https://github.com/proxysu/windows/wiki/ResourcesAndTools" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<!--<TabItem Header="关于" Width="110" Height="30">
|
<TabItem Header="关于" Width="110" Height="30">
|
||||||
<Grid>
|
<Grid>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="0.3*"></ColumnDefinition>
|
||||||
|
<ColumnDefinition></ColumnDefinition>
|
||||||
|
<ColumnDefinition></ColumnDefinition>
|
||||||
|
<ColumnDefinition></ColumnDefinition>
|
||||||
|
<ColumnDefinition></ColumnDefinition>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="0.3*"></RowDefinition>
|
||||||
|
<RowDefinition></RowDefinition>
|
||||||
|
<RowDefinition></RowDefinition>
|
||||||
|
<RowDefinition></RowDefinition>
|
||||||
|
<RowDefinition></RowDefinition>
|
||||||
|
<RowDefinition></RowDefinition>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Grid Grid.Column="1" Grid.Row="1" Grid.ColumnSpan="2">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition></ColumnDefinition>
|
||||||
|
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition></RowDefinition>
|
||||||
|
<RowDefinition></RowDefinition>
|
||||||
|
<RowDefinition></RowDefinition>
|
||||||
|
<RowDefinition></RowDefinition>
|
||||||
|
<RowDefinition></RowDefinition>
|
||||||
|
<RowDefinition></RowDefinition>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<TextBlock Text="程序版本:1.5.1" Grid.Column="0" Grid.Row="0"></TextBlock>
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</TabItem>-->
|
|
||||||
|
</Grid>
|
||||||
|
</TabItem>
|
||||||
|
|
||||||
</TabControl>
|
</TabControl>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
|
@ -492,9 +492,9 @@ namespace ProxySU
|
|||||||
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
Thread.Sleep(1000);
|
Thread.Sleep(1000);
|
||||||
|
|
||||||
var result = client.RunCommand("uname -r");
|
string result = client.RunCommand("uname -r").Result;
|
||||||
//var result = client.RunCommand("cat /root/test.ver");
|
|
||||||
string[] linuxKernelVerStr= result.Result.Split('-');
|
string[] linuxKernelVerStr= result.Split('-');
|
||||||
|
|
||||||
bool detectResult = DetectKernelVersion(linuxKernelVerStr[0]);
|
bool detectResult = DetectKernelVersion(linuxKernelVerStr[0]);
|
||||||
if (detectResult == false)
|
if (detectResult == false)
|
||||||
@ -923,6 +923,20 @@ namespace ProxySU
|
|||||||
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
Thread.Sleep(1000);
|
Thread.Sleep(1000);
|
||||||
|
|
||||||
|
//测试BBR条件,若满足提示是否启用
|
||||||
|
result = client.RunCommand("uname -r").Result;
|
||||||
|
//var result = client.RunCommand("cat /root/test.ver");
|
||||||
|
linuxKernelVerStr = result.Split('-');
|
||||||
|
|
||||||
|
detectResult = DetectKernelVersionBBR(linuxKernelVerStr[0]);
|
||||||
|
string resultCmdTestBBR = client.RunCommand(@"sysctl net.ipv4.tcp_congestion_control | grep bbr").Result;
|
||||||
|
//如果内核满足大于等于4.9,且还未启用BBR,则启用BBR
|
||||||
|
if (detectResult == true && resultCmdTestBBR.Contains("bbr") == false)
|
||||||
|
{
|
||||||
|
client.RunCommand(@"bash - c 'echo ""net.core.default_qdisc = fq"" >> /etc/sysctl.conf'");
|
||||||
|
client.RunCommand(@"bash - c 'echo ""net.ipv4.tcp_congestion_control = bbr"" >> /etc/sysctl.conf'");
|
||||||
|
client.RunCommand(@"sysctl -p");
|
||||||
|
}
|
||||||
|
|
||||||
//生成客户端配置
|
//生成客户端配置
|
||||||
currentStatus = "生成客户端配置......";
|
currentStatus = "生成客户端配置......";
|
||||||
@ -1762,6 +1776,21 @@ namespace ProxySU
|
|||||||
client.RunCommand("caddy -service restart");
|
client.RunCommand("caddy -service restart");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//测试BBR条件,若满足提示是否启用
|
||||||
|
var result = client.RunCommand("uname -r");
|
||||||
|
//var result = client.RunCommand("cat /root/test.ver");
|
||||||
|
string[] linuxKernelVerStr = result.Result.Split('-');
|
||||||
|
|
||||||
|
bool detectResult = DetectKernelVersionBBR(linuxKernelVerStr[0]);
|
||||||
|
string resultCmdTestBBR = client.RunCommand(@"sysctl net.ipv4.tcp_congestion_control | grep bbr").Result;
|
||||||
|
//如果内核满足大于等于4.9,且还未启用BBR,则启用BBR
|
||||||
|
if (detectResult == true && resultCmdTestBBR.Contains("bbr") == false)
|
||||||
|
{
|
||||||
|
client.RunCommand(@"bash - c 'echo ""net.core.default_qdisc = fq"" >> /etc/sysctl.conf'");
|
||||||
|
client.RunCommand(@"bash - c 'echo ""net.ipv4.tcp_congestion_control = bbr"" >> /etc/sysctl.conf'");
|
||||||
|
client.RunCommand(@"sysctl -p");
|
||||||
|
}
|
||||||
|
|
||||||
//生成客户端配置
|
//生成客户端配置
|
||||||
currentStatus = "生成客户端配置......";
|
currentStatus = "生成客户端配置......";
|
||||||
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
@ -2240,6 +2269,61 @@ namespace ProxySU
|
|||||||
//启动Caddy服务
|
//启动Caddy服务
|
||||||
client.RunCommand("caddy -service restart");
|
client.RunCommand("caddy -service restart");
|
||||||
|
|
||||||
|
//优化网络参数
|
||||||
|
sshCmd= @"bash - c 'echo ""fs.file-max = 51200"" >> /etc/sysctl.conf'";
|
||||||
|
client.RunCommand(sshCmd);
|
||||||
|
sshCmd = @"bash - c 'echo ""net.core.rmem_max = 67108864"" >> /etc/sysctl.conf'";
|
||||||
|
client.RunCommand(sshCmd);
|
||||||
|
sshCmd = @"bash - c 'echo ""net.core.wmem_max = 67108864"" >> /etc/sysctl.conf'";
|
||||||
|
client.RunCommand(sshCmd);
|
||||||
|
sshCmd = @"bash - c 'echo ""net.core.rmem_default = 65536"" >> /etc/sysctl.conf'";
|
||||||
|
client.RunCommand(sshCmd);
|
||||||
|
sshCmd = @"bash - c 'echo ""net.core.wmem_default = 65536"" >> /etc/sysctl.conf'";
|
||||||
|
client.RunCommand(sshCmd);
|
||||||
|
sshCmd = @"bash - c 'echo ""net.core.netdev_max_backlog = 4096"" >> /etc/sysctl.conf'";
|
||||||
|
client.RunCommand(sshCmd);
|
||||||
|
sshCmd = @"bash - c 'echo ""net.core.somaxconn = 4096"" >> /etc/sysctl.conf'";
|
||||||
|
client.RunCommand(sshCmd);
|
||||||
|
sshCmd = @"bash - c 'echo ""net.ipv4.tcp_syncookies = 1"" >> /etc/sysctl.conf'";
|
||||||
|
client.RunCommand(sshCmd);
|
||||||
|
sshCmd = @"bash - c 'echo ""net.ipv4.tcp_tw_reuse = 1"" >> /etc/sysctl.conf'";
|
||||||
|
client.RunCommand(sshCmd);
|
||||||
|
sshCmd = @"bash - c 'echo ""net.ipv4.tcp_tw_recycle = 0"" >> /etc/sysctl.conf'";
|
||||||
|
client.RunCommand(sshCmd);
|
||||||
|
sshCmd = @"bash - c 'echo ""net.ipv4.tcp_fin_timeout = 30"" >> /etc/sysctl.conf'";
|
||||||
|
client.RunCommand(sshCmd);
|
||||||
|
sshCmd = @"bash - c 'echo ""net.ipv4.tcp_keepalive_time = 1200"" >> /etc/sysctl.conf'";
|
||||||
|
client.RunCommand(sshCmd);
|
||||||
|
sshCmd = @"bash - c 'echo ""net.ipv4.ip_local_port_range = 10000 65000"" >> /etc/sysctl.conf'";
|
||||||
|
client.RunCommand(sshCmd);
|
||||||
|
sshCmd = @"bash - c 'echo ""net.ipv4.tcp_max_syn_backlog = 4096"" >> /etc/sysctl.conf'";
|
||||||
|
client.RunCommand(sshCmd);
|
||||||
|
sshCmd = @"bash - c 'echo ""net.ipv4.tcp_max_tw_buckets = 5000"" >> /etc/sysctl.conf'";
|
||||||
|
client.RunCommand(sshCmd);
|
||||||
|
sshCmd = @"bash - c 'echo ""net.ipv4.tcp_rmem = 4096 87380 67108864"" >> /etc/sysctl.conf'";
|
||||||
|
client.RunCommand(sshCmd);
|
||||||
|
sshCmd = @"bash - c 'echo ""net.ipv4.tcp_wmem = 4096 65536 67108864"" >> /etc/sysctl.conf'";
|
||||||
|
client.RunCommand(sshCmd);
|
||||||
|
sshCmd = @"bash - c 'echo ""net.ipv4.tcp_mtu_probing = 1"" >> /etc/sysctl.conf'";
|
||||||
|
client.RunCommand(sshCmd);
|
||||||
|
sshCmd = @"sysctl -p";
|
||||||
|
client.RunCommand(sshCmd);
|
||||||
|
|
||||||
|
//测试BBR条件,若满足提示是否启用
|
||||||
|
var result = client.RunCommand("uname -r");
|
||||||
|
//var result = client.RunCommand("cat /root/test.ver");
|
||||||
|
string[] linuxKernelVerStr = result.Result.Split('-');
|
||||||
|
|
||||||
|
bool detectResult = DetectKernelVersionBBR(linuxKernelVerStr[0]);
|
||||||
|
string resultCmdTestBBR = client.RunCommand(@"sysctl net.ipv4.tcp_congestion_control | grep bbr").Result;
|
||||||
|
//如果内核满足大于等于4.9,且还未启用BBR,则启用BBR
|
||||||
|
if (detectResult == true && resultCmdTestBBR.Contains("bbr") == false)
|
||||||
|
{
|
||||||
|
client.RunCommand(@"bash - c 'echo ""net.core.default_qdisc = fq"" >> /etc/sysctl.conf'");
|
||||||
|
client.RunCommand(@"bash - c 'echo ""net.ipv4.tcp_congestion_control = bbr"" >> /etc/sysctl.conf'");
|
||||||
|
client.RunCommand(@"sysctl -p");
|
||||||
|
}
|
||||||
|
|
||||||
//生成客户端配置
|
//生成客户端配置
|
||||||
currentStatus = "生成客户端配置......";
|
currentStatus = "生成客户端配置......";
|
||||||
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||||
@ -2319,23 +2403,7 @@ namespace ProxySU
|
|||||||
MessageBox.Show("远程主机连接信息有误,请检查");
|
MessageBox.Show("远程主机连接信息有误,请检查");
|
||||||
return;
|
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(() => StartTestAndEnableBBR(connectionInfo, TextBlockSetUpProcessing, ProgressBarSetUpProcessing));
|
Thread thread = new Thread(() => StartTestAndEnableBBR(connectionInfo, TextBlockSetUpProcessing, ProgressBarSetUpProcessing));
|
||||||
thread.SetApartmentState(ApartmentState.STA);
|
thread.SetApartmentState(ApartmentState.STA);
|
||||||
thread.Start();
|
thread.Start();
|
||||||
@ -2430,8 +2498,8 @@ namespace ProxySU
|
|||||||
|
|
||||||
//启用BBR
|
//启用BBR
|
||||||
|
|
||||||
client.RunCommand(@"echo ""net.core.default_qdisc = fq"" >> /etc/sysctl.conf");
|
client.RunCommand(@"bash - c 'echo ""net.core.default_qdisc = fq"" >> /etc/sysctl.conf'");
|
||||||
client.RunCommand(@"echo ""net.ipv4.tcp_congestion_control = bbr"" >> /etc/sysctl.conf");
|
client.RunCommand(@"bash - c 'echo ""net.ipv4.tcp_congestion_control = bbr"" >> /etc/sysctl.conf'");
|
||||||
client.RunCommand(@"sysctl -p");
|
client.RunCommand(@"sysctl -p");
|
||||||
|
|
||||||
resultCmdTestBBR = client.RunCommand(@"sysctl net.ipv4.tcp_congestion_control | grep bbr").Result;
|
resultCmdTestBBR = client.RunCommand(@"sysctl net.ipv4.tcp_congestion_control | grep bbr").Result;
|
||||||
|
Binary file not shown.
Binary file not shown.
BIN
ProxySU/bin/Release/trojan_config/trojan.exe
Normal file
BIN
ProxySU/bin/Release/trojan_config/trojan.exe
Normal file
Binary file not shown.
BIN
ProxySU/bin/Release/v2ray_config/v2ctl.exe
Normal file
BIN
ProxySU/bin/Release/v2ray_config/v2ctl.exe
Normal file
Binary file not shown.
BIN
ProxySU/bin/Release/v2ray_config/v2ray.exe
Normal file
BIN
ProxySU/bin/Release/v2ray_config/v2ray.exe
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user