mirror of
https://github.com/proxysu/ProxySU.git
synced 2024-11-25 06:36:08 +03:00
update new version
This commit is contained in:
parent
6be1fdb84a
commit
2378f0c416
@ -1,5 +1,6 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace ProxySuper.Core.Models.Projects
|
namespace ProxySuper.Core.Models.Projects
|
||||||
{
|
{
|
||||||
@ -10,7 +11,13 @@ namespace ProxySuper.Core.Models.Projects
|
|||||||
Port = 443;
|
Port = 443;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<int> FreePorts => new List<int>();
|
public List<int> FreePorts
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new List<int> { 80, 443, Port }.Distinct().ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ProjectType Type { get; set; } = ProjectType.NaiveProxy;
|
public ProjectType Type { get; set; } = ProjectType.NaiveProxy;
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace ProxySuper.Core.Models.Projects
|
namespace ProxySuper.Core.Models.Projects
|
||||||
{
|
{
|
||||||
@ -17,7 +18,7 @@ namespace ProxySuper.Core.Models.Projects
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return new List<int>();
|
return new List<int> { 80, 443, Port }.Distinct().ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using ProxySuper.Core.Services;
|
using ProxySuper.Core.Services;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace ProxySuper.Core.Models.Projects
|
namespace ProxySuper.Core.Models.Projects
|
||||||
{
|
{
|
||||||
@ -35,11 +36,46 @@ namespace ProxySuper.Core.Models.Projects
|
|||||||
ShadowSocksMethod = "aes-128-gcm";
|
ShadowSocksMethod = "aes-128-gcm";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public bool WithTLS
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var withOutTLSList = new List<XrayType> {
|
||||||
|
XrayType.ShadowsocksAEAD,
|
||||||
|
XrayType.VLESS_KCP,
|
||||||
|
XrayType.VMESS_KCP
|
||||||
|
};
|
||||||
|
|
||||||
|
return Types.Except(withOutTLSList).Count() > 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public bool IsFullbackMode
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var withoutFullback = new List<XrayType> {
|
||||||
|
XrayType.ShadowsocksAEAD,
|
||||||
|
XrayType.VLESS_KCP,
|
||||||
|
XrayType.VMESS_KCP,
|
||||||
|
XrayType.VLESS_gRPC,
|
||||||
|
};
|
||||||
|
|
||||||
|
return Types.Except(withoutFullback).Count() > 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
public List<int> FreePorts
|
public List<int> FreePorts
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
var list = new List<int>();
|
var list = new List<int>();
|
||||||
|
list.Add(80);
|
||||||
|
list.Add(443);
|
||||||
|
|
||||||
if (Types.Contains(XrayType.VLESS_KCP))
|
if (Types.Contains(XrayType.VLESS_KCP))
|
||||||
{
|
{
|
||||||
list.Add(VLESS_KCP_Port);
|
list.Add(VLESS_KCP_Port);
|
||||||
@ -60,7 +96,7 @@ namespace ProxySuper.Core.Models.Projects
|
|||||||
list.Add(VLESS_gRPC_Port);
|
list.Add(VLESS_gRPC_Port);
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list.Distinct().ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,11 +31,7 @@ namespace ProxySuper.Core.Services
|
|||||||
WriteOutput("检测安装系统环境完成");
|
WriteOutput("检测安装系统环境完成");
|
||||||
|
|
||||||
WriteOutput("配置服务器端口...");
|
WriteOutput("配置服务器端口...");
|
||||||
OpenPort(Parameters.FreePorts.ToArray());
|
ConfigFirewalld();
|
||||||
Parameters.FreePorts.ForEach(port =>
|
|
||||||
{
|
|
||||||
SetPortFree(port);
|
|
||||||
});
|
|
||||||
WriteOutput("端口配置完成");
|
WriteOutput("端口配置完成");
|
||||||
|
|
||||||
WriteOutput("安装必要的系统工具...");
|
WriteOutput("安装必要的系统工具...");
|
||||||
@ -120,7 +116,7 @@ namespace ProxySuper.Core.Services
|
|||||||
RunCmd("rm -rf /usr/bin/brook");
|
RunCmd("rm -rf /usr/bin/brook");
|
||||||
|
|
||||||
Console.WriteLine("关闭端口");
|
Console.WriteLine("关闭端口");
|
||||||
ClosePort(Parameters.FreePorts.ToArray());
|
ResetFirewalld();
|
||||||
|
|
||||||
WriteOutput("******卸载完成******");
|
WriteOutput("******卸载完成******");
|
||||||
}
|
}
|
||||||
|
@ -49,16 +49,12 @@ namespace ProxySuper.Core.Services
|
|||||||
EnsureSystemEnv();
|
EnsureSystemEnv();
|
||||||
WriteOutput("检测安装系统环境完成");
|
WriteOutput("检测安装系统环境完成");
|
||||||
|
|
||||||
WriteOutput("配置服务器端口...");
|
|
||||||
ConfigurePort();
|
|
||||||
WriteOutput("端口配置完成");
|
|
||||||
|
|
||||||
WriteOutput("安装必要的系统工具...");
|
WriteOutput("安装必要的系统工具...");
|
||||||
ConfigureSoftware();
|
ConfigureSoftware();
|
||||||
WriteOutput("系统工具安装完成");
|
WriteOutput("系统工具安装完成");
|
||||||
|
|
||||||
WriteOutput("配置防火墙...");
|
WriteOutput("配置防火墙...");
|
||||||
ConfigureFirewall();
|
ConfigFirewalld();
|
||||||
WriteOutput("防火墙配置完成");
|
WriteOutput("防火墙配置完成");
|
||||||
|
|
||||||
WriteOutput("同步系统和本地时间...");
|
WriteOutput("同步系统和本地时间...");
|
||||||
|
@ -259,103 +259,30 @@ namespace ProxySuper.Core.Services
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 关闭端口
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="portList"></param>
|
|
||||||
protected void ClosePort(params int[] portList)
|
|
||||||
{
|
|
||||||
string cmd;
|
|
||||||
|
|
||||||
cmd = RunCmd("command -v firewall-cmd");
|
|
||||||
if (!string.IsNullOrEmpty(cmd))
|
|
||||||
{
|
|
||||||
//有很奇怪的vps主机,在firewalld未运行时,端口是关闭的,无法访问。所以要先启动firewalld
|
|
||||||
//用于保证acme.sh申请证书成功
|
|
||||||
cmd = RunCmd("firewall-cmd --state");
|
|
||||||
if (cmd.Trim() != "running")
|
|
||||||
{
|
|
||||||
RunCmd("systemctl restart firewalld");
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var port in portList)
|
|
||||||
{
|
|
||||||
RunCmd($"firewall-cmd --zone=public --remove-port={port}/tcp --permanent");
|
|
||||||
RunCmd($"firewall-cmd --zone=public --remove-port={port}/udp --permanent");
|
|
||||||
}
|
|
||||||
RunCmd("yes | firewall-cmd --reload");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cmd = RunCmd("command -v ufw");
|
|
||||||
if (!string.IsNullOrEmpty(cmd))
|
|
||||||
{
|
|
||||||
foreach (var port in portList)
|
|
||||||
{
|
|
||||||
RunCmd($"ufw delete allow {port}/tcp");
|
|
||||||
RunCmd($"ufw delete allow {port}/udp");
|
|
||||||
}
|
|
||||||
RunCmd("yes | ufw reload");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 开放端口
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="portList"></param>
|
|
||||||
protected void OpenPort(params int[] portList)
|
|
||||||
{
|
|
||||||
string cmd;
|
|
||||||
|
|
||||||
cmd = RunCmd("command -v firewall-cmd");
|
|
||||||
if (!string.IsNullOrEmpty(cmd))
|
|
||||||
{
|
|
||||||
//有很奇怪的vps主机,在firewalld未运行时,端口是关闭的,无法访问。所以要先启动firewalld
|
|
||||||
//用于保证acme.sh申请证书成功
|
|
||||||
cmd = RunCmd("firewall-cmd --state");
|
|
||||||
if (cmd.Trim() != "running")
|
|
||||||
{
|
|
||||||
RunCmd("systemctl restart firewalld");
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var port in portList)
|
|
||||||
{
|
|
||||||
RunCmd($"firewall-cmd --zone=public --add-port={port}/tcp --permanent");
|
|
||||||
RunCmd($"firewall-cmd --zone=public --add-port={port}/udp --permanent");
|
|
||||||
}
|
|
||||||
RunCmd("yes | firewall-cmd --reload");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cmd = RunCmd("command -v ufw");
|
|
||||||
if (string.IsNullOrEmpty(cmd))
|
|
||||||
{
|
|
||||||
RunCmd(GetInstallCmd("ufw"));
|
|
||||||
RunCmd("echo y | ufw enable");
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var port in portList)
|
|
||||||
{
|
|
||||||
RunCmd($"ufw allow {port}/tcp");
|
|
||||||
RunCmd($"ufw allow {port}/udp");
|
|
||||||
}
|
|
||||||
RunCmd("yes | ufw reload");
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 配置防火墙
|
/// 配置防火墙
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected void ConfigureFirewall()
|
protected void ConfigFirewalld()
|
||||||
{
|
{
|
||||||
var portList = new List<int>();
|
Parameters.FreePorts.ForEach(port =>
|
||||||
portList.Add(80);
|
{
|
||||||
portList.Add(Parameters.Port);
|
SetPortFree(port);
|
||||||
portList.AddRange(Parameters.FreePorts);
|
});
|
||||||
|
|
||||||
OpenPort(portList.ToArray());
|
OpenPort(_sshClient.ConnectionInfo.Port);
|
||||||
|
OpenPort(Parameters.FreePorts.ToArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重置防火墙
|
||||||
|
/// </summary>
|
||||||
|
protected void ResetFirewalld()
|
||||||
|
{
|
||||||
|
Parameters.FreePorts.ForEach(port =>
|
||||||
|
{
|
||||||
|
SetPortFree(port);
|
||||||
|
});
|
||||||
|
ClosePort(Parameters.FreePorts.ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -448,7 +375,7 @@ namespace ProxySuper.Core.Services
|
|||||||
|
|
||||||
RunCmd($"wget -O caddy.tar.gz {url}");
|
RunCmd($"wget -O caddy.tar.gz {url}");
|
||||||
RunCmd("mkdir /etc/caddy");
|
RunCmd("mkdir /etc/caddy");
|
||||||
RunCmd("tar -zxvf caddy.tar.gz caddy -C /etc/caddy");
|
RunCmd("tar -zxvf caddy.tar.gz -C /etc/caddy");
|
||||||
RunCmd("cp -rf /etc/caddy/caddy /usr/bin");
|
RunCmd("cp -rf /etc/caddy/caddy /usr/bin");
|
||||||
WriteToFile(Caddy.DefaultCaddyFile, "/etc/caddy/Caddyfile");
|
WriteToFile(Caddy.DefaultCaddyFile, "/etc/caddy/Caddyfile");
|
||||||
WriteToFile(Caddy.Service, "/etc/systemd/system/caddy.service");
|
WriteToFile(Caddy.Service, "/etc/systemd/system/caddy.service");
|
||||||
@ -456,6 +383,11 @@ namespace ProxySuper.Core.Services
|
|||||||
RunCmd("systemctl enable caddy");
|
RunCmd("systemctl enable caddy");
|
||||||
|
|
||||||
RunCmd("mkdir /usr/share/caddy");
|
RunCmd("mkdir /usr/share/caddy");
|
||||||
|
|
||||||
|
if (!FileExists("/usr/bin/caddy"))
|
||||||
|
{
|
||||||
|
throw new Exception("Caddy服务器安装失败,请联系开发者!");
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 官方安装步骤
|
#region 官方安装步骤
|
||||||
@ -527,55 +459,6 @@ namespace ProxySuper.Core.Services
|
|||||||
return OnlyIpv6;
|
return OnlyIpv6;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected bool SetPortFree(int port, bool force = true)
|
|
||||||
{
|
|
||||||
string result = RunCmd($"lsof -n -P -i :{port} | grep LISTEN");
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(result))
|
|
||||||
{
|
|
||||||
if (force)
|
|
||||||
{
|
|
||||||
var btnResult = MessageBox.Show($"{port}端口被占用,将强制停止占用{port}端口的程序?", "提示", MessageBoxButton.YesNo);
|
|
||||||
if (btnResult == MessageBoxResult.No)
|
|
||||||
{
|
|
||||||
throw new Exception($"{port}端口被占用,安装停止!");
|
|
||||||
}
|
|
||||||
|
|
||||||
string[] process = result.Split(' ');
|
|
||||||
RunCmd($"systemctl stop {process[0]}");
|
|
||||||
RunCmd($"systemctl disable {process[0]}");
|
|
||||||
RunCmd($"pkill {process[0]}");
|
|
||||||
return SetPortFree(port, force: false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ConfigurePort()
|
|
||||||
{
|
|
||||||
if (Parameters.Port == 80 || Parameters.Port == 443)
|
|
||||||
{
|
|
||||||
SetPortFree(80);
|
|
||||||
SetPortFree(443);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SetPortFree(80);
|
|
||||||
SetPortFree(443);
|
|
||||||
SetPortFree(Parameters.Port);
|
|
||||||
|
|
||||||
Parameters.FreePorts.ForEach(port =>
|
|
||||||
{
|
|
||||||
SetPortFree(port);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void SetNat64()
|
protected void SetNat64()
|
||||||
{
|
{
|
||||||
var dns64List = FilterFastestIP();
|
var dns64List = FilterFastestIP();
|
||||||
@ -638,6 +521,121 @@ namespace ProxySuper.Core.Services
|
|||||||
return dns64List.Keys.ToList();
|
return dns64List.Keys.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool SetPortFree(int port, bool force = true)
|
||||||
|
{
|
||||||
|
string result = RunCmd($"lsof -n -P -i :{port} | grep LISTEN");
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(result))
|
||||||
|
{
|
||||||
|
if (force)
|
||||||
|
{
|
||||||
|
var btnResult = MessageBox.Show($"{port}端口被占用,将强制停止占用{port}端口的程序?", "提示", MessageBoxButton.YesNo);
|
||||||
|
if (btnResult == MessageBoxResult.No)
|
||||||
|
{
|
||||||
|
throw new Exception($"{port}端口被占用,安装停止!");
|
||||||
|
}
|
||||||
|
|
||||||
|
string[] process = result.Split(' ');
|
||||||
|
RunCmd($"systemctl stop {process[0]}");
|
||||||
|
RunCmd($"systemctl disable {process[0]}");
|
||||||
|
RunCmd($"pkill {process[0]}");
|
||||||
|
return SetPortFree(port, force: false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 关闭端口
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="portList"></param>
|
||||||
|
private void ClosePort(params int[] portList)
|
||||||
|
{
|
||||||
|
string cmd;
|
||||||
|
|
||||||
|
cmd = RunCmd("command -v firewall-cmd");
|
||||||
|
if (!string.IsNullOrEmpty(cmd))
|
||||||
|
{
|
||||||
|
//有很奇怪的vps主机,在firewalld未运行时,端口是关闭的,无法访问。所以要先启动firewalld
|
||||||
|
//用于保证acme.sh申请证书成功
|
||||||
|
cmd = RunCmd("firewall-cmd --state");
|
||||||
|
if (cmd.Trim() != "running")
|
||||||
|
{
|
||||||
|
RunCmd("systemctl restart firewalld");
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var port in portList)
|
||||||
|
{
|
||||||
|
RunCmd($"firewall-cmd --zone=public --remove-port={port}/tcp --permanent");
|
||||||
|
RunCmd($"firewall-cmd --zone=public --remove-port={port}/udp --permanent");
|
||||||
|
}
|
||||||
|
RunCmd("yes | firewall-cmd --reload");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cmd = RunCmd("command -v ufw");
|
||||||
|
if (!string.IsNullOrEmpty(cmd))
|
||||||
|
{
|
||||||
|
foreach (var port in portList)
|
||||||
|
{
|
||||||
|
RunCmd($"ufw delete allow {port}/tcp");
|
||||||
|
RunCmd($"ufw delete allow {port}/udp");
|
||||||
|
}
|
||||||
|
RunCmd("yes | ufw reload");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 开放端口
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="portList"></param>
|
||||||
|
private void OpenPort(params int[] portList)
|
||||||
|
{
|
||||||
|
string cmd;
|
||||||
|
|
||||||
|
cmd = RunCmd("command -v firewall-cmd");
|
||||||
|
if (!string.IsNullOrEmpty(cmd))
|
||||||
|
{
|
||||||
|
//有很奇怪的vps主机,在firewalld未运行时,端口是关闭的,无法访问。所以要先启动firewalld
|
||||||
|
//用于保证acme.sh申请证书成功
|
||||||
|
cmd = RunCmd("firewall-cmd --state");
|
||||||
|
if (cmd.Trim() != "running")
|
||||||
|
{
|
||||||
|
RunCmd("systemctl restart firewalld");
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var port in portList)
|
||||||
|
{
|
||||||
|
RunCmd($"firewall-cmd --zone=public --add-port={port}/tcp --permanent");
|
||||||
|
RunCmd($"firewall-cmd --zone=public --add-port={port}/udp --permanent");
|
||||||
|
}
|
||||||
|
RunCmd("yes | firewall-cmd --reload");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cmd = RunCmd("command -v ufw");
|
||||||
|
if (string.IsNullOrEmpty(cmd))
|
||||||
|
{
|
||||||
|
RunCmd(GetInstallCmd("ufw"));
|
||||||
|
RunCmd("echo y | ufw enable");
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var port in portList)
|
||||||
|
{
|
||||||
|
RunCmd($"ufw allow {port}/tcp");
|
||||||
|
RunCmd($"ufw allow {port}/udp");
|
||||||
|
}
|
||||||
|
RunCmd("yes | ufw reload");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
@ -776,11 +774,15 @@ namespace ProxySuper.Core.Services
|
|||||||
{
|
{
|
||||||
using (var sftp = new SftpClient(_sshClient.ConnectionInfo))
|
using (var sftp = new SftpClient(_sshClient.ConnectionInfo))
|
||||||
{
|
{
|
||||||
sftp.Connect();
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
sftp.Connect();
|
||||||
sftp.UploadFile(stream, path, true);
|
sftp.UploadFile(stream, path, true);
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
sftp.Disconnect();
|
sftp.Disconnect();
|
||||||
|
@ -21,13 +21,13 @@ namespace ProxySuper.Core.Services
|
|||||||
if (settings.BrookType == BrookType.wsserver)
|
if (settings.BrookType == BrookType.wsserver)
|
||||||
{
|
{
|
||||||
var address = HttpUtility.UrlEncode($"ws://{settings.IP}:{settings.Port}");
|
var address = HttpUtility.UrlEncode($"ws://{settings.IP}:{settings.Port}");
|
||||||
return $"brook://wsserver?password={password}&ws={address}";
|
return $"brook://wsserver?password={password}&wsserver={address}";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings.BrookType == BrookType.wssserver)
|
if (settings.BrookType == BrookType.wssserver)
|
||||||
{
|
{
|
||||||
var address = HttpUtility.UrlEncode($"wss://{settings.Domain}:{settings.Port}");
|
var address = HttpUtility.UrlEncode($"wss://{settings.Domain}:{settings.Port}");
|
||||||
return $"brook://wssserver?password={password}&wss={address}";
|
return $"brook://wssserver?password={password}&wssserver={address}";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings.BrookType == BrookType.socks5)
|
if (settings.BrookType == BrookType.socks5)
|
||||||
|
@ -79,16 +79,12 @@ namespace ProxySuper.Core.Services
|
|||||||
EnsureSystemEnv();
|
EnsureSystemEnv();
|
||||||
WriteOutput("检测安装系统环境完成");
|
WriteOutput("检测安装系统环境完成");
|
||||||
|
|
||||||
WriteOutput("配置服务器端口...");
|
|
||||||
ConfigurePort();
|
|
||||||
WriteOutput("端口配置完成");
|
|
||||||
|
|
||||||
WriteOutput("安装必要的系统工具...");
|
WriteOutput("安装必要的系统工具...");
|
||||||
ConfigureSoftware();
|
ConfigureSoftware();
|
||||||
WriteOutput("系统工具安装完成");
|
WriteOutput("系统工具安装完成");
|
||||||
|
|
||||||
WriteOutput("配置防火墙...");
|
WriteOutput("配置防火墙...");
|
||||||
ConfigureFirewall();
|
ConfigFirewalld();
|
||||||
WriteOutput("防火墙配置完成");
|
WriteOutput("防火墙配置完成");
|
||||||
|
|
||||||
WriteOutput("同步系统和本地时间...");
|
WriteOutput("同步系统和本地时间...");
|
||||||
|
@ -117,6 +117,10 @@ namespace ProxySuper.Core.Services
|
|||||||
uuidList.Insert(0, parameters.UUID);
|
uuidList.Insert(0, parameters.UUID);
|
||||||
|
|
||||||
var xrayConfig = LoadXrayConfig();
|
var xrayConfig = LoadXrayConfig();
|
||||||
|
|
||||||
|
if (parameters.IsFullbackMode)
|
||||||
|
{
|
||||||
|
#region Fullbacks
|
||||||
var baseBound = GetBound("VLESS_TCP_XTLS.json");
|
var baseBound = GetBound("VLESS_TCP_XTLS.json");
|
||||||
baseBound.port = parameters.Port;
|
baseBound.port = parameters.Port;
|
||||||
baseBound.settings.fallbacks.Add(JToken.FromObject(new
|
baseBound.settings.fallbacks.Add(JToken.FromObject(new
|
||||||
@ -141,26 +145,6 @@ namespace ProxySuper.Core.Services
|
|||||||
xrayConfig.inbounds.Add(JToken.FromObject(wsInbound));
|
xrayConfig.inbounds.Add(JToken.FromObject(wsInbound));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parameters.Types.Contains(XrayType.VLESS_gRPC))
|
|
||||||
{
|
|
||||||
var gRPCInBound = GetBound("VLESS_gRPC.json");
|
|
||||||
gRPCInBound.port = parameters.VLESS_gRPC_Port;
|
|
||||||
SetClients(gRPCInBound, uuidList);
|
|
||||||
gRPCInBound.streamSettings.grpcSettings.serviceName = parameters.VLESS_gRPC_ServiceName;
|
|
||||||
gRPCInBound.streamSettings.tlsSettings.serverName = parameters.Domain;
|
|
||||||
xrayConfig.inbounds.Add(JToken.FromObject(gRPCInBound));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parameters.Types.Contains(XrayType.VLESS_KCP))
|
|
||||||
{
|
|
||||||
var kcpBound = GetBound("VLESS_KCP.json");
|
|
||||||
kcpBound.port = parameters.VLESS_KCP_Port;
|
|
||||||
SetClients(kcpBound, uuidList);
|
|
||||||
kcpBound.streamSettings.kcpSettings.header.type = parameters.VLESS_KCP_Type;
|
|
||||||
kcpBound.streamSettings.kcpSettings.seed = parameters.VLESS_KCP_Seed;
|
|
||||||
xrayConfig.inbounds.Add(JToken.FromObject(kcpBound));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parameters.Types.Contains(XrayType.VMESS_TCP))
|
if (parameters.Types.Contains(XrayType.VMESS_TCP))
|
||||||
{
|
{
|
||||||
var mtcpBound = GetBound("VMESS_TCP.json");
|
var mtcpBound = GetBound("VMESS_TCP.json");
|
||||||
@ -191,16 +175,6 @@ namespace ProxySuper.Core.Services
|
|||||||
xrayConfig.inbounds.Add(JToken.FromObject(mwsBound));
|
xrayConfig.inbounds.Add(JToken.FromObject(mwsBound));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parameters.Types.Contains(XrayType.VMESS_KCP))
|
|
||||||
{
|
|
||||||
var kcpBound = GetBound("VMESS_KCP.json");
|
|
||||||
kcpBound.port = parameters.VMESS_KCP_Port;
|
|
||||||
SetClients(kcpBound, uuidList);
|
|
||||||
kcpBound.streamSettings.kcpSettings.header.type = parameters.VMESS_KCP_Type;
|
|
||||||
kcpBound.streamSettings.kcpSettings.seed = parameters.VMESS_KCP_Seed;
|
|
||||||
xrayConfig.inbounds.Add(JToken.FromObject(kcpBound));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parameters.Types.Contains(XrayType.Trojan_TCP))
|
if (parameters.Types.Contains(XrayType.Trojan_TCP))
|
||||||
{
|
{
|
||||||
var trojanTcpBound = GetBound("Trojan_TCP.json");
|
var trojanTcpBound = GetBound("Trojan_TCP.json");
|
||||||
@ -214,6 +188,40 @@ namespace ProxySuper.Core.Services
|
|||||||
});
|
});
|
||||||
xrayConfig.inbounds.Add(JToken.FromObject(trojanTcpBound));
|
xrayConfig.inbounds.Add(JToken.FromObject(trojanTcpBound));
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parameters.Types.Contains(XrayType.VLESS_gRPC))
|
||||||
|
{
|
||||||
|
var gRPCInBound = GetBound("VLESS_gRPC.json");
|
||||||
|
gRPCInBound.port = parameters.VLESS_gRPC_Port;
|
||||||
|
SetClients(gRPCInBound, uuidList);
|
||||||
|
gRPCInBound.streamSettings.grpcSettings.serviceName = parameters.VLESS_gRPC_ServiceName;
|
||||||
|
gRPCInBound.streamSettings.tlsSettings.serverName = parameters.Domain;
|
||||||
|
xrayConfig.inbounds.Add(JToken.FromObject(gRPCInBound));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parameters.Types.Contains(XrayType.VLESS_KCP))
|
||||||
|
{
|
||||||
|
var kcpBound = GetBound("VLESS_KCP.json");
|
||||||
|
kcpBound.port = parameters.VLESS_KCP_Port;
|
||||||
|
SetClients(kcpBound, uuidList);
|
||||||
|
kcpBound.streamSettings.kcpSettings.header.type = parameters.VLESS_KCP_Type;
|
||||||
|
kcpBound.streamSettings.kcpSettings.seed = parameters.VLESS_KCP_Seed;
|
||||||
|
xrayConfig.inbounds.Add(JToken.FromObject(kcpBound));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (parameters.Types.Contains(XrayType.VMESS_KCP))
|
||||||
|
{
|
||||||
|
var kcpBound = GetBound("VMESS_KCP.json");
|
||||||
|
kcpBound.port = parameters.VMESS_KCP_Port;
|
||||||
|
SetClients(kcpBound, uuidList);
|
||||||
|
kcpBound.streamSettings.kcpSettings.header.type = parameters.VMESS_KCP_Type;
|
||||||
|
kcpBound.streamSettings.kcpSettings.seed = parameters.VMESS_KCP_Seed;
|
||||||
|
xrayConfig.inbounds.Add(JToken.FromObject(kcpBound));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (parameters.Types.Contains(XrayType.ShadowsocksAEAD))
|
if (parameters.Types.Contains(XrayType.ShadowsocksAEAD))
|
||||||
|
@ -3,6 +3,8 @@ using ProxySuper.Core.Models.Projects;
|
|||||||
using Renci.SshNet;
|
using Renci.SshNet;
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
|
||||||
@ -50,25 +52,24 @@ namespace ProxySuper.Core.Services
|
|||||||
EnsureSystemEnv();
|
EnsureSystemEnv();
|
||||||
WriteOutput("检测安装系统环境完成");
|
WriteOutput("检测安装系统环境完成");
|
||||||
|
|
||||||
WriteOutput("配置服务器端口...");
|
|
||||||
ConfigurePort();
|
|
||||||
WriteOutput("端口配置完成");
|
|
||||||
|
|
||||||
WriteOutput("安装必要的系统工具...");
|
WriteOutput("安装必要的系统工具...");
|
||||||
ConfigureSoftware();
|
ConfigureSoftware();
|
||||||
WriteOutput("系统工具安装完成");
|
WriteOutput("系统工具安装完成");
|
||||||
|
|
||||||
WriteOutput("配置防火墙...");
|
WriteOutput("配置防火墙...");
|
||||||
ConfigureFirewall();
|
ConfigFirewalld();
|
||||||
WriteOutput("防火墙配置完成");
|
WriteOutput("防火墙配置完成");
|
||||||
|
|
||||||
WriteOutput("同步系统和本地时间...");
|
WriteOutput("同步系统和本地时间...");
|
||||||
SyncTimeDiff();
|
SyncTimeDiff();
|
||||||
WriteOutput("时间同步完成");
|
WriteOutput("时间同步完成");
|
||||||
|
|
||||||
|
if (Parameters.WithTLS)
|
||||||
|
{
|
||||||
WriteOutput("检测域名是否绑定本机IP...");
|
WriteOutput("检测域名是否绑定本机IP...");
|
||||||
ValidateDomain();
|
ValidateDomain();
|
||||||
WriteOutput("域名检测完成");
|
WriteOutput("域名检测完成");
|
||||||
|
}
|
||||||
|
|
||||||
WriteOutput("安装Caddy...");
|
WriteOutput("安装Caddy...");
|
||||||
InstallCaddy();
|
InstallCaddy();
|
||||||
@ -105,7 +106,7 @@ namespace ProxySuper.Core.Services
|
|||||||
WriteOutput("卸载证书");
|
WriteOutput("卸载证书");
|
||||||
UninstallAcme();
|
UninstallAcme();
|
||||||
WriteOutput("关闭端口");
|
WriteOutput("关闭端口");
|
||||||
ClosePort(Parameters.FreePorts.ToArray());
|
ResetFirewalld();
|
||||||
|
|
||||||
WriteOutput("************ 卸载完成 ************");
|
WriteOutput("************ 卸载完成 ************");
|
||||||
}
|
}
|
||||||
@ -129,8 +130,11 @@ namespace ProxySuper.Core.Services
|
|||||||
{
|
{
|
||||||
EnsureRootAuth();
|
EnsureRootAuth();
|
||||||
EnsureSystemEnv();
|
EnsureSystemEnv();
|
||||||
ConfigurePort();
|
|
||||||
ConfigureFirewall();
|
RunCmd("systemctl stop caddy");
|
||||||
|
RunCmd("systemctl stop xray");
|
||||||
|
|
||||||
|
ConfigFirewalld();
|
||||||
var configJson = XrayConfigBuilder.BuildXrayConfig(Parameters);
|
var configJson = XrayConfigBuilder.BuildXrayConfig(Parameters);
|
||||||
var stream = new MemoryStream(Encoding.UTF8.GetBytes(configJson));
|
var stream = new MemoryStream(Encoding.UTF8.GetBytes(configJson));
|
||||||
RunCmd("rm -rf /usr/local/etc/xray/config.json");
|
RunCmd("rm -rf /usr/local/etc/xray/config.json");
|
||||||
@ -288,10 +292,12 @@ namespace ProxySuper.Core.Services
|
|||||||
RunCmd(@"mv /usr/local/etc/xray/config.json /usr/local/etc/xray/config.json.1");
|
RunCmd(@"mv /usr/local/etc/xray/config.json /usr/local/etc/xray/config.json.1");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Parameters.WithTLS)
|
||||||
|
{
|
||||||
WriteOutput("安装TLS证书");
|
WriteOutput("安装TLS证书");
|
||||||
InstallCertToXray();
|
InstallCertToXray();
|
||||||
WriteOutput("TLS证书安装完成");
|
WriteOutput("TLS证书安装完成");
|
||||||
|
}
|
||||||
|
|
||||||
var configJson = XrayConfigBuilder.BuildXrayConfig(Parameters);
|
var configJson = XrayConfigBuilder.BuildXrayConfig(Parameters);
|
||||||
WriteToFile(configJson, "/usr/local/etc/xray/config.json");
|
WriteToFile(configJson, "/usr/local/etc/xray/config.json");
|
||||||
|
@ -49,5 +49,5 @@ using System.Windows;
|
|||||||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
|
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
|
||||||
//通过使用 "*",如下所示:
|
//通过使用 "*",如下所示:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("4.0.3.0")]
|
[assembly: AssemblyVersion("4.0.4.0")]
|
||||||
[assembly: AssemblyFileVersion("4.0.3.0")]
|
[assembly: AssemblyFileVersion("4.0.4.0")]
|
||||||
|
@ -67,13 +67,13 @@
|
|||||||
<sys:String x:Key="VlessXtlsDesc" xml:space="preserve">VLESS over TCP With XTLS
Preferred</sys:String>
|
<sys:String x:Key="VlessXtlsDesc" xml:space="preserve">VLESS over TCP With XTLS
Preferred</sys:String>
|
||||||
<sys:String x:Key="VlessTcpDesc" xml:space="preserve">VLESS over TCP with TLS
XTLS is Preferred</sys:String>
|
<sys:String x:Key="VlessTcpDesc" xml:space="preserve">VLESS over TCP with TLS
XTLS is Preferred</sys:String>
|
||||||
<sys:String x:Key="VlessWsDesc" xml:space="preserve">VLESS over WS with TLS
Support CDN</sys:String>
|
<sys:String x:Key="VlessWsDesc" xml:space="preserve">VLESS over WS with TLS
Support CDN</sys:String>
|
||||||
<sys:String x:Key="VlessKcpDesc" xml:space="preserve">VLESS mKCP
low delay</sys:String>
|
<sys:String x:Key="VlessKcpDesc" xml:space="preserve">VLESS mKCP
low delay,without Domain</sys:String>
|
||||||
<sys:String x:Key="VmessWsDesc" xml:space="preserve">VMESS over WS with TLS
Support CDN</sys:String>
|
<sys:String x:Key="VmessWsDesc" xml:space="preserve">VMESS over WS with TLS
Support CDN</sys:String>
|
||||||
<sys:String x:Key="VmessKcpDesc" xml:space="preserve">VMESS mKCP
low delay</sys:String>
|
<sys:String x:Key="VmessKcpDesc" xml:space="preserve">VMESS mKCP
low delay,without Domian</sys:String>
|
||||||
<sys:String x:Key="SSDesc" xml:space="preserve">ShadowSocks
Support CDN</sys:String>
|
<sys:String x:Key="SSDesc" xml:space="preserve">ShadowSocks
Support UDP,without Domain</sys:String>
|
||||||
<sys:String x:Key="TrojanDesc" xml:space="preserve">Trojan over TCP with TLS
Trojan</sys:String>
|
<sys:String x:Key="TrojanDesc" xml:space="preserve">Trojan over TCP with TLS
Trojan</sys:String>
|
||||||
|
|
||||||
<sys:String x:Key="XrayDomain">Address</sys:String>
|
<sys:String x:Key="XrayDomain">Domain/IP</sys:String>
|
||||||
<sys:String x:Key="XrayMarkDomain">GuiseHost</sys:String>
|
<sys:String x:Key="XrayMarkDomain">GuiseHost</sys:String>
|
||||||
<sys:String x:Key="XrayUUID">UUID</sys:String>
|
<sys:String x:Key="XrayUUID">UUID</sys:String>
|
||||||
<sys:String x:Key="MultiUser">Multi User</sys:String>
|
<sys:String x:Key="MultiUser">Multi User</sys:String>
|
||||||
|
@ -65,14 +65,14 @@
|
|||||||
<sys:String x:Key="VlessXtlsDesc" xml:space="preserve">VLESS Over TCP With XTLS
性能數倍,首選方式。</sys:String>
|
<sys:String x:Key="VlessXtlsDesc" xml:space="preserve">VLESS Over TCP With XTLS
性能數倍,首選方式。</sys:String>
|
||||||
<sys:String x:Key="VlessTcpDesc" xml:space="preserve">VLESS over TCP with TLS
仍推薦XTLS。</sys:String>
|
<sys:String x:Key="VlessTcpDesc" xml:space="preserve">VLESS over TCP with TLS
仍推薦XTLS。</sys:String>
|
||||||
<sys:String x:Key="VlessWsDesc" xml:space="preserve">VLESS over WS with TLS
推薦,支持CDN。</sys:String>
|
<sys:String x:Key="VlessWsDesc" xml:space="preserve">VLESS over WS with TLS
推薦,支持CDN。</sys:String>
|
||||||
<sys:String x:Key="VlessKcpDesc" xml:space="preserve">VLESS mKCP
遊戲推薦,延遲低。</sys:String>
|
<sys:String x:Key="VlessKcpDesc" xml:space="preserve">VLESS mKCP
遊戲推薦,延遲低,免域名。</sys:String>
|
||||||
<sys:String x:Key="VmessWsDesc" xml:space="preserve">VMESS over WS with TLS
推薦,支持CDN。</sys:String>
|
<sys:String x:Key="VmessWsDesc" xml:space="preserve">VMESS over WS with TLS
推薦,支持CDN。</sys:String>
|
||||||
<sys:String x:Key="VmessKcpDesc" xml:space="preserve">VMESS mKCP
遊戲推薦,延遲低。</sys:String>
|
<sys:String x:Key="VmessKcpDesc" xml:space="preserve">VMESS mKCP
遊戲推薦,延遲低,免域名。</sys:String>
|
||||||
<sys:String x:Key="SSDesc" xml:space="preserve">ShadowSocks
SS,支持udp。</sys:String>
|
<sys:String x:Key="SSDesc" xml:space="preserve">ShadowSocks
SS,支持udp,免域名。</sys:String>
|
||||||
<sys:String x:Key="TrojanDesc" xml:space="preserve">Trojan over TCP with TLS
Trojan。</sys:String>
|
<sys:String x:Key="TrojanDesc" xml:space="preserve">Trojan over TCP with TLS
Trojan。</sys:String>
|
||||||
|
|
||||||
|
|
||||||
<sys:String x:Key="XrayDomain">域名</sys:String>
|
<sys:String x:Key="XrayDomain">域名/IP</sys:String>
|
||||||
<sys:String x:Key="XrayMarkDomain">偽裝域名</sys:String>
|
<sys:String x:Key="XrayMarkDomain">偽裝域名</sys:String>
|
||||||
<sys:String x:Key="XrayUUID">UUID</sys:String>
|
<sys:String x:Key="XrayUUID">UUID</sys:String>
|
||||||
<sys:String x:Key="MultiUser">多用戶</sys:String>
|
<sys:String x:Key="MultiUser">多用戶</sys:String>
|
||||||
|
@ -66,14 +66,14 @@
|
|||||||
<sys:String x:Key="VlessXtlsDesc" xml:space="preserve">VLESS Over TCP With XTLS
性能数倍,首选方式。</sys:String>
|
<sys:String x:Key="VlessXtlsDesc" xml:space="preserve">VLESS Over TCP With XTLS
性能数倍,首选方式。</sys:String>
|
||||||
<sys:String x:Key="VlessTcpDesc" xml:space="preserve">VLESS over TCP with TLS
仍推荐XTLS。</sys:String>
|
<sys:String x:Key="VlessTcpDesc" xml:space="preserve">VLESS over TCP with TLS
仍推荐XTLS。</sys:String>
|
||||||
<sys:String x:Key="VlessWsDesc" xml:space="preserve">VLESS over WS with TLS
推荐,支持CDN。</sys:String>
|
<sys:String x:Key="VlessWsDesc" xml:space="preserve">VLESS over WS with TLS
推荐,支持CDN。</sys:String>
|
||||||
<sys:String x:Key="VlessKcpDesc" xml:space="preserve">VLESS mKCP
游戏推荐,延迟低。</sys:String>
|
<sys:String x:Key="VlessKcpDesc" xml:space="preserve">VLESS mKCP
游戏推荐,延迟低,免域名。</sys:String>
|
||||||
<sys:String x:Key="VmessWsDesc" xml:space="preserve">VMESS over WS with TLS
推荐,支持CDN。</sys:String>
|
<sys:String x:Key="VmessWsDesc" xml:space="preserve">VMESS over WS with TLS
推荐,支持CDN。</sys:String>
|
||||||
<sys:String x:Key="VmessKcpDesc" xml:space="preserve">VMESS mKCP
游戏推荐,延迟低。</sys:String>
|
<sys:String x:Key="VmessKcpDesc" xml:space="preserve">VMESS mKCP
游戏推荐,延迟低,免域名。</sys:String>
|
||||||
<sys:String x:Key="SSDesc" xml:space="preserve">ShadowSocks
SS,支持udp。</sys:String>
|
<sys:String x:Key="SSDesc" xml:space="preserve">ShadowSocks
SS,支持udp,免域名。</sys:String>
|
||||||
<sys:String x:Key="TrojanDesc" xml:space="preserve">Trojan over TCP with TLS
Trojan。</sys:String>
|
<sys:String x:Key="TrojanDesc" xml:space="preserve">Trojan over TCP with TLS
Trojan。</sys:String>
|
||||||
|
|
||||||
|
|
||||||
<sys:String x:Key="XrayDomain">域名</sys:String>
|
<sys:String x:Key="XrayDomain">域名/IP</sys:String>
|
||||||
<sys:String x:Key="XrayMarkDomain">伪装域名</sys:String>
|
<sys:String x:Key="XrayMarkDomain">伪装域名</sys:String>
|
||||||
<sys:String x:Key="XrayUUID">UUID</sys:String>
|
<sys:String x:Key="XrayUUID">UUID</sys:String>
|
||||||
<sys:String x:Key="MultiUser">多用户</sys:String>
|
<sys:String x:Key="MultiUser">多用户</sys:String>
|
||||||
|
Loading…
Reference in New Issue
Block a user