mirror of
https://github.com/proxysu/ProxySU.git
synced 2024-11-25 06:36:08 +03:00
bbr and domain validation
This commit is contained in:
parent
f6d28efac9
commit
0072c9c99c
@ -12,14 +12,15 @@ namespace ProxySU_Core.Models
|
|||||||
|
|
||||||
public XraySettings()
|
public XraySettings()
|
||||||
{
|
{
|
||||||
|
var guid = Guid.NewGuid().ToString();
|
||||||
Port = 443;
|
Port = 443;
|
||||||
UUID = Guid.NewGuid().ToString();
|
UUID = guid;
|
||||||
Types = new List<XrayType> { XrayType.VLESS_TCP_XTLS };
|
Types = new List<XrayType> { XrayType.VLESS_TCP_XTLS };
|
||||||
VLESS_WS_Path = "/vlessws";
|
VLESS_WS_Path = "/vlessws";
|
||||||
VLESS_TCP_Path = "/vlesstcp";
|
VLESS_TCP_Path = "/vlesstcp";
|
||||||
VMESS_WS_Path = "/vmessws";
|
VMESS_WS_Path = "/vmessws";
|
||||||
VMESS_TCP_Path = "/vmesstcp";
|
VMESS_TCP_Path = "/vmesstcp";
|
||||||
TrojanPassword = Guid.NewGuid().ToString();
|
TrojanPassword = guid;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -66,7 +66,16 @@ namespace ProxySU_Core.ViewModels.Developers
|
|||||||
caddyStr = caddyStr.Replace("##domain##", parameters.Domain);
|
caddyStr = caddyStr.Replace("##domain##", parameters.Domain);
|
||||||
if (!useCustomWeb && !string.IsNullOrEmpty(parameters.MaskDomain))
|
if (!useCustomWeb && !string.IsNullOrEmpty(parameters.MaskDomain))
|
||||||
{
|
{
|
||||||
caddyStr = caddyStr.Replace("##reverse_proxy##", $"reverse_proxy {parameters.MaskDomain} {{ header_up Host {parameters.MaskDomain} }}");
|
var prefix = "http://";
|
||||||
|
if (parameters.MaskDomain.StartsWith("https://"))
|
||||||
|
{
|
||||||
|
prefix = "https://";
|
||||||
|
}
|
||||||
|
var domain = parameters.MaskDomain
|
||||||
|
.TrimStart("http://".ToCharArray())
|
||||||
|
.TrimStart("https://".ToCharArray());
|
||||||
|
|
||||||
|
caddyStr = caddyStr.Replace("##reverse_proxy##", $"reverse_proxy {prefix}{domain} {{ \n header_up Host {domain} \n }}");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -312,9 +312,7 @@ namespace ProxySU_Core.ViewModels.Developers
|
|||||||
var cmd = $"dig @resolver1.opendns.com AAAA {Parameters.Domain} +short -6 {cmdFilter}";
|
var cmd = $"dig @resolver1.opendns.com AAAA {Parameters.Domain} +short -6 {cmdFilter}";
|
||||||
var result = RunCmd(cmd).TrimEnd('\r', '\n');
|
var result = RunCmd(cmd).TrimEnd('\r', '\n');
|
||||||
|
|
||||||
if (result != IPv6)
|
if (result == IPv6) return;
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
@ -323,11 +321,19 @@ namespace ProxySU_Core.ViewModels.Developers
|
|||||||
var cmd = $"dig @resolver1.opendns.com A {Parameters.Domain} +short -4 {cmdFilter}";
|
var cmd = $"dig @resolver1.opendns.com A {Parameters.Domain} +short -4 {cmdFilter}";
|
||||||
var result = RunCmd(cmd).TrimEnd('\r', '\n');
|
var result = RunCmd(cmd).TrimEnd('\r', '\n');
|
||||||
|
|
||||||
if (result != IPv4)
|
if (result == IPv4) return;
|
||||||
{
|
|
||||||
throw new Exception("域名未能解析到服务器IP,请检查域名配置");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var btnResult = MessageBox.Show(
|
||||||
|
$"{Parameters.Domain}未能正常解析到服务器的IP,如果您使用了CDN请忽略,是否继续安装?", "提示", MessageBoxButton.YesNo);
|
||||||
|
|
||||||
|
if (btnResult == MessageBoxResult.No)
|
||||||
|
{
|
||||||
|
throw new Exception($"域名解析失败,安装停止!");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -447,7 +453,7 @@ namespace ProxySU_Core.ViewModels.Developers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetNat64()
|
protected void SetNat64()
|
||||||
{
|
{
|
||||||
var dns64List = FilterFastestIP();
|
var dns64List = FilterFastestIP();
|
||||||
if (dns64List.Count == 0)
|
if (dns64List.Count == 0)
|
||||||
@ -468,7 +474,7 @@ namespace ProxySU_Core.ViewModels.Developers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RemoveNat64()
|
protected void RemoveNat64()
|
||||||
{
|
{
|
||||||
RunCmd("rm /etc/resolv.conf");
|
RunCmd("rm /etc/resolv.conf");
|
||||||
RunCmd("mv /etc/resolv.conf.proxysu /etc/resolv.conf");
|
RunCmd("mv /etc/resolv.conf.proxysu /etc/resolv.conf");
|
||||||
|
@ -51,7 +51,6 @@ namespace ProxySU_Core.ViewModels.Developers
|
|||||||
RunCmd("unzip /usr/share/caddy/caddy.zip -d /usr/share/caddy");
|
RunCmd("unzip /usr/share/caddy/caddy.zip -d /usr/share/caddy");
|
||||||
RunCmd("chmod -R 777 /usr/share/caddy");
|
RunCmd("chmod -R 777 /usr/share/caddy");
|
||||||
UploadCaddyFile(useCustomWeb: true);
|
UploadCaddyFile(useCustomWeb: true);
|
||||||
RunCmd("systemctl restart caddy");
|
|
||||||
WriteOutput("************ 上传网站模板完成 ************");
|
WriteOutput("************ 上传网站模板完成 ************");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +75,6 @@ namespace ProxySU_Core.ViewModels.Developers
|
|||||||
WriteOutput("************ 重装Caddy完成 ************");
|
WriteOutput("************ 重装Caddy完成 ************");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public override void Install()
|
public override void Install()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -129,6 +127,10 @@ namespace ProxySU_Core.ViewModels.Developers
|
|||||||
InstallCaddy();
|
InstallCaddy();
|
||||||
WriteOutput("Caddy安装完成");
|
WriteOutput("Caddy安装完成");
|
||||||
|
|
||||||
|
WriteOutput("启动BBR");
|
||||||
|
EnableBBR();
|
||||||
|
WriteOutput("BBR启动成功");
|
||||||
|
|
||||||
UploadCaddyFile();
|
UploadCaddyFile();
|
||||||
WriteOutput("************");
|
WriteOutput("************");
|
||||||
WriteOutput("安装完成,尽情享用吧......");
|
WriteOutput("安装完成,尽情享用吧......");
|
||||||
@ -146,7 +148,60 @@ namespace ProxySU_Core.ViewModels.Developers
|
|||||||
var stream = new MemoryStream(Encoding.UTF8.GetBytes(configJson));
|
var stream = new MemoryStream(Encoding.UTF8.GetBytes(configJson));
|
||||||
RunCmd("mv /etc/caddy/Caddyfile /etc/caddy/Caddyfile.back");
|
RunCmd("mv /etc/caddy/Caddyfile /etc/caddy/Caddyfile.back");
|
||||||
UploadFile(stream, "/etc/caddy/Caddyfile");
|
UploadFile(stream, "/etc/caddy/Caddyfile");
|
||||||
RunCmd("systemctl reload caddy");
|
RunCmd("systemctl restart caddy");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void EnableBBR()
|
||||||
|
{
|
||||||
|
var osVersion = RunCmd("uname -r");
|
||||||
|
var canInstallBBR = CheckKernelVersionBBR(osVersion.Split('-')[0]);
|
||||||
|
|
||||||
|
var bbrInfo = RunCmd("sysctl net.ipv4.tcp_congestion_control | grep bbr");
|
||||||
|
var installed = bbrInfo.Contains("bbr");
|
||||||
|
if (canInstallBBR && !installed)
|
||||||
|
{
|
||||||
|
RunCmd(@"bash -c 'echo ""net.core.default_qdisc=fq"" >> /etc/sysctl.conf'");
|
||||||
|
RunCmd(@"bash -c 'echo ""net.ipv4.tcp_congestion_control=bbr"" >> /etc/sysctl.conf'");
|
||||||
|
RunCmd(@"sysctl -p");
|
||||||
|
|
||||||
|
if (OnlyIpv6)
|
||||||
|
{
|
||||||
|
RemoveNat64();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!canInstallBBR)
|
||||||
|
{
|
||||||
|
WriteOutput("****** 系统不满足启用BBR条件,启动失败。 ******");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool CheckKernelVersionBBR(string kernelVer)
|
||||||
|
{
|
||||||
|
string[] linuxKernelCompared = kernelVer.Split('.');
|
||||||
|
if (int.Parse(linuxKernelCompared[0]) > 4)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (int.Parse(linuxKernelCompared[0]) < 4)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (int.Parse(linuxKernelCompared[0]) == 4)
|
||||||
|
{
|
||||||
|
if (int.Parse(linuxKernelCompared[1]) >= 9)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (int.Parse(linuxKernelCompared[1]) < 9)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InstallXrayWithCert()
|
private void InstallXrayWithCert()
|
||||||
|
@ -299,13 +299,8 @@
|
|||||||
|
|
||||||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
|
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
|
||||||
<Label Content="密码" Width="120" />
|
<Label Content="密码" Width="120" />
|
||||||
<TextBox Text="{Binding Settings.TrojanPassword}" IsReadOnly="True" Width="200" />
|
<TextBox Text="{Binding Settings.TrojanPassword}" IsReadOnly="True" Width="300" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
|
|
||||||
<Label Content="域名" Width="120" />
|
|
||||||
<TextBox Text="{Binding Settings.Domain}" IsReadOnly="True" Width="200" />
|
|
||||||
</StackPanel>
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user