mirror of
https://github.com/proxysu/ProxySU.git
synced 2024-11-24 22:26:07 +03:00
update new version
This commit is contained in:
parent
6be1fdb84a
commit
2378f0c416
@ -1,5 +1,6 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace ProxySuper.Core.Models.Projects
|
||||
{
|
||||
@ -10,7 +11,13 @@ namespace ProxySuper.Core.Models.Projects
|
||||
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;
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace ProxySuper.Core.Models.Projects
|
||||
{
|
||||
@ -17,7 +18,7 @@ namespace ProxySuper.Core.Models.Projects
|
||||
{
|
||||
get
|
||||
{
|
||||
return new List<int>();
|
||||
return new List<int> { 80, 443, Port }.Distinct().ToList();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
using ProxySuper.Core.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace ProxySuper.Core.Models.Projects
|
||||
{
|
||||
@ -35,11 +36,46 @@ namespace ProxySuper.Core.Models.Projects
|
||||
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
|
||||
{
|
||||
get
|
||||
{
|
||||
var list = new List<int>();
|
||||
list.Add(80);
|
||||
list.Add(443);
|
||||
|
||||
if (Types.Contains(XrayType.VLESS_KCP))
|
||||
{
|
||||
list.Add(VLESS_KCP_Port);
|
||||
@ -60,7 +96,7 @@ namespace ProxySuper.Core.Models.Projects
|
||||
list.Add(VLESS_gRPC_Port);
|
||||
}
|
||||
|
||||
return list;
|
||||
return list.Distinct().ToList();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,17 +7,17 @@ namespace ProxySuper.Core.Services
|
||||
public class BrookProject : ProjectBase<BrookSettings>
|
||||
{
|
||||
private string brookServiceTemp = @"
|
||||
[Unit]
|
||||
Description=brook service
|
||||
After=network.target syslog.target
|
||||
Wants=network.target
|
||||
[Unit]
|
||||
Description=brook service
|
||||
After=network.target syslog.target
|
||||
Wants=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=##run_cmd##
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=##run_cmd##
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target";
|
||||
[Install]
|
||||
WantedBy=multi-user.target";
|
||||
|
||||
public BrookProject(SshClient sshClient, BrookSettings parameters, Action<string> writeOutput) : base(sshClient, parameters, writeOutput)
|
||||
{
|
||||
@ -31,11 +31,7 @@ namespace ProxySuper.Core.Services
|
||||
WriteOutput("检测安装系统环境完成");
|
||||
|
||||
WriteOutput("配置服务器端口...");
|
||||
OpenPort(Parameters.FreePorts.ToArray());
|
||||
Parameters.FreePorts.ForEach(port =>
|
||||
{
|
||||
SetPortFree(port);
|
||||
});
|
||||
ConfigFirewalld();
|
||||
WriteOutput("端口配置完成");
|
||||
|
||||
WriteOutput("安装必要的系统工具...");
|
||||
@ -120,7 +116,7 @@ namespace ProxySuper.Core.Services
|
||||
RunCmd("rm -rf /usr/bin/brook");
|
||||
|
||||
Console.WriteLine("关闭端口");
|
||||
ClosePort(Parameters.FreePorts.ToArray());
|
||||
ResetFirewalld();
|
||||
|
||||
WriteOutput("******卸载完成******");
|
||||
}
|
||||
|
@ -49,16 +49,12 @@ namespace ProxySuper.Core.Services
|
||||
EnsureSystemEnv();
|
||||
WriteOutput("检测安装系统环境完成");
|
||||
|
||||
WriteOutput("配置服务器端口...");
|
||||
ConfigurePort();
|
||||
WriteOutput("端口配置完成");
|
||||
|
||||
WriteOutput("安装必要的系统工具...");
|
||||
ConfigureSoftware();
|
||||
WriteOutput("系统工具安装完成");
|
||||
|
||||
WriteOutput("配置防火墙...");
|
||||
ConfigureFirewall();
|
||||
ConfigFirewalld();
|
||||
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>
|
||||
protected void ConfigureFirewall()
|
||||
protected void ConfigFirewalld()
|
||||
{
|
||||
var portList = new List<int>();
|
||||
portList.Add(80);
|
||||
portList.Add(Parameters.Port);
|
||||
portList.AddRange(Parameters.FreePorts);
|
||||
Parameters.FreePorts.ForEach(port =>
|
||||
{
|
||||
SetPortFree(port);
|
||||
});
|
||||
|
||||
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>
|
||||
@ -448,7 +375,7 @@ namespace ProxySuper.Core.Services
|
||||
|
||||
RunCmd($"wget -O caddy.tar.gz {url}");
|
||||
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");
|
||||
WriteToFile(Caddy.DefaultCaddyFile, "/etc/caddy/Caddyfile");
|
||||
WriteToFile(Caddy.Service, "/etc/systemd/system/caddy.service");
|
||||
@ -456,6 +383,11 @@ namespace ProxySuper.Core.Services
|
||||
RunCmd("systemctl enable caddy");
|
||||
|
||||
RunCmd("mkdir /usr/share/caddy");
|
||||
|
||||
if (!FileExists("/usr/bin/caddy"))
|
||||
{
|
||||
throw new Exception("Caddy服务器安装失败,请联系开发者!");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 官方安装步骤
|
||||
@ -527,55 +459,6 @@ namespace ProxySuper.Core.Services
|
||||
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()
|
||||
{
|
||||
var dns64List = FilterFastestIP();
|
||||
@ -638,6 +521,121 @@ namespace ProxySuper.Core.Services
|
||||
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
|
||||
|
||||
|
||||
@ -776,11 +774,15 @@ namespace ProxySuper.Core.Services
|
||||
{
|
||||
using (var sftp = new SftpClient(_sshClient.ConnectionInfo))
|
||||
{
|
||||
sftp.Connect();
|
||||
try
|
||||
{
|
||||
sftp.Connect();
|
||||
sftp.UploadFile(stream, path, true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
finally
|
||||
{
|
||||
sftp.Disconnect();
|
||||
|
@ -21,13 +21,13 @@ namespace ProxySuper.Core.Services
|
||||
if (settings.BrookType == BrookType.wsserver)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
|
@ -77,18 +77,14 @@ namespace ProxySuper.Core.Services
|
||||
|
||||
WriteOutput("检测安装系统环境...");
|
||||
EnsureSystemEnv();
|
||||
WriteOutput("检测安装系统环境完成");
|
||||
|
||||
WriteOutput("配置服务器端口...");
|
||||
ConfigurePort();
|
||||
WriteOutput("端口配置完成");
|
||||
WriteOutput("检测安装系统环境完成");
|
||||
|
||||
WriteOutput("安装必要的系统工具...");
|
||||
ConfigureSoftware();
|
||||
WriteOutput("系统工具安装完成");
|
||||
|
||||
WriteOutput("配置防火墙...");
|
||||
ConfigureFirewall();
|
||||
ConfigFirewalld();
|
||||
WriteOutput("防火墙配置完成");
|
||||
|
||||
WriteOutput("同步系统和本地时间...");
|
||||
|
@ -117,28 +117,78 @@ namespace ProxySuper.Core.Services
|
||||
uuidList.Insert(0, parameters.UUID);
|
||||
|
||||
var xrayConfig = LoadXrayConfig();
|
||||
var baseBound = GetBound("VLESS_TCP_XTLS.json");
|
||||
baseBound.port = parameters.Port;
|
||||
baseBound.settings.fallbacks.Add(JToken.FromObject(new
|
||||
{
|
||||
dest = FullbackPort
|
||||
}));
|
||||
xrayConfig.inbounds.Add(baseBound);
|
||||
SetClients(baseBound, uuidList, withXtls: true);
|
||||
|
||||
if (parameters.Types.Contains(XrayType.VLESS_WS))
|
||||
if (parameters.IsFullbackMode)
|
||||
{
|
||||
var wsInbound = GetBound("VLESS_WS.json");
|
||||
wsInbound.port = VLESS_WS_Port;
|
||||
SetClients(wsInbound, uuidList);
|
||||
wsInbound.streamSettings.wsSettings.path = parameters.VLESS_WS_Path;
|
||||
#region Fullbacks
|
||||
var baseBound = GetBound("VLESS_TCP_XTLS.json");
|
||||
baseBound.port = parameters.Port;
|
||||
baseBound.settings.fallbacks.Add(JToken.FromObject(new
|
||||
{
|
||||
dest = VLESS_WS_Port,
|
||||
path = parameters.VLESS_WS_Path,
|
||||
xver = 1,
|
||||
dest = FullbackPort
|
||||
}));
|
||||
xrayConfig.inbounds.Add(JToken.FromObject(wsInbound));
|
||||
xrayConfig.inbounds.Add(baseBound);
|
||||
SetClients(baseBound, uuidList, withXtls: true);
|
||||
|
||||
if (parameters.Types.Contains(XrayType.VLESS_WS))
|
||||
{
|
||||
var wsInbound = GetBound("VLESS_WS.json");
|
||||
wsInbound.port = VLESS_WS_Port;
|
||||
SetClients(wsInbound, uuidList);
|
||||
wsInbound.streamSettings.wsSettings.path = parameters.VLESS_WS_Path;
|
||||
baseBound.settings.fallbacks.Add(JToken.FromObject(new
|
||||
{
|
||||
dest = VLESS_WS_Port,
|
||||
path = parameters.VLESS_WS_Path,
|
||||
xver = 1,
|
||||
}));
|
||||
xrayConfig.inbounds.Add(JToken.FromObject(wsInbound));
|
||||
}
|
||||
|
||||
if (parameters.Types.Contains(XrayType.VMESS_TCP))
|
||||
{
|
||||
var mtcpBound = GetBound("VMESS_TCP.json");
|
||||
mtcpBound.port = VMESS_TCP_Port;
|
||||
SetClients(mtcpBound, uuidList);
|
||||
mtcpBound.streamSettings.tcpSettings.header.request.path = parameters.VMESS_TCP_Path;
|
||||
baseBound.settings.fallbacks.Add(JToken.FromObject(new
|
||||
{
|
||||
dest = VMESS_TCP_Port,
|
||||
path = parameters.VMESS_TCP_Path,
|
||||
xver = 1,
|
||||
}));
|
||||
xrayConfig.inbounds.Add(JToken.FromObject(mtcpBound));
|
||||
}
|
||||
|
||||
if (parameters.Types.Contains(XrayType.VMESS_WS))
|
||||
{
|
||||
var mwsBound = GetBound("VMESS_WS.json");
|
||||
mwsBound.port = VMESS_WS_Port;
|
||||
SetClients(mwsBound, uuidList);
|
||||
mwsBound.streamSettings.wsSettings.path = parameters.VMESS_WS_Path;
|
||||
baseBound.settings.fallbacks.Add(JToken.FromObject(new
|
||||
{
|
||||
dest = VMESS_WS_Port,
|
||||
path = parameters.VMESS_WS_Path,
|
||||
xver = 1,
|
||||
}));
|
||||
xrayConfig.inbounds.Add(JToken.FromObject(mwsBound));
|
||||
}
|
||||
|
||||
if (parameters.Types.Contains(XrayType.Trojan_TCP))
|
||||
{
|
||||
var trojanTcpBound = GetBound("Trojan_TCP.json");
|
||||
trojanTcpBound.port = Trojan_TCP_Port;
|
||||
trojanTcpBound.settings.clients[0].password = parameters.TrojanPassword;
|
||||
trojanTcpBound.settings.fallbacks[0].dest = FullbackPort;
|
||||
baseBound.settings.fallbacks[0] = JToken.FromObject(new
|
||||
{
|
||||
dest = Trojan_TCP_Port,
|
||||
xver = 1,
|
||||
});
|
||||
xrayConfig.inbounds.Add(JToken.FromObject(trojanTcpBound));
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
if (parameters.Types.Contains(XrayType.VLESS_gRPC))
|
||||
@ -161,35 +211,7 @@ namespace ProxySuper.Core.Services
|
||||
xrayConfig.inbounds.Add(JToken.FromObject(kcpBound));
|
||||
}
|
||||
|
||||
if (parameters.Types.Contains(XrayType.VMESS_TCP))
|
||||
{
|
||||
var mtcpBound = GetBound("VMESS_TCP.json");
|
||||
mtcpBound.port = VMESS_TCP_Port;
|
||||
SetClients(mtcpBound, uuidList);
|
||||
mtcpBound.streamSettings.tcpSettings.header.request.path = parameters.VMESS_TCP_Path;
|
||||
baseBound.settings.fallbacks.Add(JToken.FromObject(new
|
||||
{
|
||||
dest = VMESS_TCP_Port,
|
||||
path = parameters.VMESS_TCP_Path,
|
||||
xver = 1,
|
||||
}));
|
||||
xrayConfig.inbounds.Add(JToken.FromObject(mtcpBound));
|
||||
}
|
||||
|
||||
if (parameters.Types.Contains(XrayType.VMESS_WS))
|
||||
{
|
||||
var mwsBound = GetBound("VMESS_WS.json");
|
||||
mwsBound.port = VMESS_WS_Port;
|
||||
SetClients(mwsBound, uuidList);
|
||||
mwsBound.streamSettings.wsSettings.path = parameters.VMESS_WS_Path;
|
||||
baseBound.settings.fallbacks.Add(JToken.FromObject(new
|
||||
{
|
||||
dest = VMESS_WS_Port,
|
||||
path = parameters.VMESS_WS_Path,
|
||||
xver = 1,
|
||||
}));
|
||||
xrayConfig.inbounds.Add(JToken.FromObject(mwsBound));
|
||||
}
|
||||
|
||||
if (parameters.Types.Contains(XrayType.VMESS_KCP))
|
||||
{
|
||||
@ -201,20 +223,6 @@ namespace ProxySuper.Core.Services
|
||||
xrayConfig.inbounds.Add(JToken.FromObject(kcpBound));
|
||||
}
|
||||
|
||||
if (parameters.Types.Contains(XrayType.Trojan_TCP))
|
||||
{
|
||||
var trojanTcpBound = GetBound("Trojan_TCP.json");
|
||||
trojanTcpBound.port = Trojan_TCP_Port;
|
||||
trojanTcpBound.settings.clients[0].password = parameters.TrojanPassword;
|
||||
trojanTcpBound.settings.fallbacks[0].dest = FullbackPort;
|
||||
baseBound.settings.fallbacks[0] = JToken.FromObject(new
|
||||
{
|
||||
dest = Trojan_TCP_Port,
|
||||
xver = 1,
|
||||
});
|
||||
xrayConfig.inbounds.Add(JToken.FromObject(trojanTcpBound));
|
||||
}
|
||||
|
||||
|
||||
if (parameters.Types.Contains(XrayType.ShadowsocksAEAD))
|
||||
{
|
||||
|
@ -3,6 +3,8 @@ using ProxySuper.Core.Models.Projects;
|
||||
using Renci.SshNet;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
|
||||
@ -50,25 +52,24 @@ namespace ProxySuper.Core.Services
|
||||
EnsureSystemEnv();
|
||||
WriteOutput("检测安装系统环境完成");
|
||||
|
||||
WriteOutput("配置服务器端口...");
|
||||
ConfigurePort();
|
||||
WriteOutput("端口配置完成");
|
||||
|
||||
WriteOutput("安装必要的系统工具...");
|
||||
ConfigureSoftware();
|
||||
WriteOutput("系统工具安装完成");
|
||||
|
||||
WriteOutput("配置防火墙...");
|
||||
ConfigureFirewall();
|
||||
ConfigFirewalld();
|
||||
WriteOutput("防火墙配置完成");
|
||||
|
||||
WriteOutput("同步系统和本地时间...");
|
||||
SyncTimeDiff();
|
||||
WriteOutput("时间同步完成");
|
||||
|
||||
WriteOutput("检测域名是否绑定本机IP...");
|
||||
ValidateDomain();
|
||||
WriteOutput("域名检测完成");
|
||||
if (Parameters.WithTLS)
|
||||
{
|
||||
WriteOutput("检测域名是否绑定本机IP...");
|
||||
ValidateDomain();
|
||||
WriteOutput("域名检测完成");
|
||||
}
|
||||
|
||||
WriteOutput("安装Caddy...");
|
||||
InstallCaddy();
|
||||
@ -105,7 +106,7 @@ namespace ProxySuper.Core.Services
|
||||
WriteOutput("卸载证书");
|
||||
UninstallAcme();
|
||||
WriteOutput("关闭端口");
|
||||
ClosePort(Parameters.FreePorts.ToArray());
|
||||
ResetFirewalld();
|
||||
|
||||
WriteOutput("************ 卸载完成 ************");
|
||||
}
|
||||
@ -129,8 +130,11 @@ namespace ProxySuper.Core.Services
|
||||
{
|
||||
EnsureRootAuth();
|
||||
EnsureSystemEnv();
|
||||
ConfigurePort();
|
||||
ConfigureFirewall();
|
||||
|
||||
RunCmd("systemctl stop caddy");
|
||||
RunCmd("systemctl stop xray");
|
||||
|
||||
ConfigFirewalld();
|
||||
var configJson = XrayConfigBuilder.BuildXrayConfig(Parameters);
|
||||
var stream = new MemoryStream(Encoding.UTF8.GetBytes(configJson));
|
||||
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");
|
||||
}
|
||||
|
||||
WriteOutput("安装TLS证书");
|
||||
InstallCertToXray();
|
||||
WriteOutput("TLS证书安装完成");
|
||||
|
||||
if (Parameters.WithTLS)
|
||||
{
|
||||
WriteOutput("安装TLS证书");
|
||||
InstallCertToXray();
|
||||
WriteOutput("TLS证书安装完成");
|
||||
}
|
||||
|
||||
var configJson = XrayConfigBuilder.BuildXrayConfig(Parameters);
|
||||
WriteToFile(configJson, "/usr/local/etc/xray/config.json");
|
||||
|
@ -49,5 +49,5 @@ using System.Windows;
|
||||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
|
||||
//通过使用 "*",如下所示:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("4.0.3.0")]
|
||||
[assembly: AssemblyFileVersion("4.0.3.0")]
|
||||
[assembly: AssemblyVersion("4.0.4.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="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="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="VmessKcpDesc" xml:space="preserve">VMESS mKCP
low delay</sys:String>
|
||||
<sys:String x:Key="SSDesc" xml:space="preserve">ShadowSocks
Support CDN</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 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="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="XrayUUID">UUID</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="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="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="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="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="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="XrayUUID">UUID</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="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="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="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="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="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="XrayUUID">UUID</sys:String>
|
||||
<sys:String x:Key="MultiUser">多用户</sys:String>
|
||||
|
Loading…
Reference in New Issue
Block a user