1
0
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:
autumn 2021-07-12 17:58:51 +08:00
parent 6be1fdb84a
commit 2378f0c416
14 changed files with 310 additions and 262 deletions

View File

@ -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;

View File

@ -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();
} }
} }

View File

@ -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();
} }
} }

View File

@ -7,17 +7,17 @@ namespace ProxySuper.Core.Services
public class BrookProject : ProjectBase<BrookSettings> public class BrookProject : ProjectBase<BrookSettings>
{ {
private string brookServiceTemp = @" private string brookServiceTemp = @"
[Unit] [Unit]
Description=brook service Description=brook service
After=network.target syslog.target After=network.target syslog.target
Wants=network.target Wants=network.target
[Service] [Service]
Type=simple Type=simple
ExecStart=##run_cmd## ExecStart=##run_cmd##
[Install] [Install]
WantedBy=multi-user.target"; WantedBy=multi-user.target";
public BrookProject(SshClient sshClient, BrookSettings parameters, Action<string> writeOutput) : base(sshClient, parameters, writeOutput) public BrookProject(SshClient sshClient, BrookSettings parameters, Action<string> writeOutput) : base(sshClient, parameters, writeOutput)
{ {
@ -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("******卸载完成******");
} }

View File

@ -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("同步系统和本地时间...");

View File

@ -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();

View File

@ -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)

View File

@ -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("同步系统和本地时间...");

View File

@ -117,28 +117,78 @@ namespace ProxySuper.Core.Services
uuidList.Insert(0, parameters.UUID); uuidList.Insert(0, parameters.UUID);
var xrayConfig = LoadXrayConfig(); 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"); #region Fullbacks
wsInbound.port = VLESS_WS_Port; var baseBound = GetBound("VLESS_TCP_XTLS.json");
SetClients(wsInbound, uuidList); baseBound.port = parameters.Port;
wsInbound.streamSettings.wsSettings.path = parameters.VLESS_WS_Path;
baseBound.settings.fallbacks.Add(JToken.FromObject(new baseBound.settings.fallbacks.Add(JToken.FromObject(new
{ {
dest = VLESS_WS_Port, dest = FullbackPort
path = parameters.VLESS_WS_Path,
xver = 1,
})); }));
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)) if (parameters.Types.Contains(XrayType.VLESS_gRPC))
@ -161,35 +211,7 @@ namespace ProxySuper.Core.Services
xrayConfig.inbounds.Add(JToken.FromObject(kcpBound)); 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)) if (parameters.Types.Contains(XrayType.VMESS_KCP))
{ {
@ -201,20 +223,6 @@ namespace ProxySuper.Core.Services
xrayConfig.inbounds.Add(JToken.FromObject(kcpBound)); 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)) if (parameters.Types.Contains(XrayType.ShadowsocksAEAD))
{ {

View File

@ -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("时间同步完成");
WriteOutput("检测域名是否绑定本机IP..."); if (Parameters.WithTLS)
ValidateDomain(); {
WriteOutput("域名检测完成"); WriteOutput("检测域名是否绑定本机IP...");
ValidateDomain();
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");
} }
WriteOutput("安装TLS证书"); if (Parameters.WithTLS)
InstallCertToXray(); {
WriteOutput("TLS证书安装完成"); WriteOutput("安装TLS证书");
InstallCertToXray();
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");

View File

@ -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")]

View File

@ -67,13 +67,13 @@
<sys:String x:Key="VlessXtlsDesc" xml:space="preserve">VLESS over TCP With XTLS&#x0a;Preferred</sys:String> <sys:String x:Key="VlessXtlsDesc" xml:space="preserve">VLESS over TCP With XTLS&#x0a;Preferred</sys:String>
<sys:String x:Key="VlessTcpDesc" xml:space="preserve">VLESS over TCP with TLS&#x0a;XTLS is Preferred</sys:String> <sys:String x:Key="VlessTcpDesc" xml:space="preserve">VLESS over TCP with TLS&#x0a;XTLS is Preferred</sys:String>
<sys:String x:Key="VlessWsDesc" xml:space="preserve">VLESS over WS with TLS&#x0a;Support CDN</sys:String> <sys:String x:Key="VlessWsDesc" xml:space="preserve">VLESS over WS with TLS&#x0a;Support CDN</sys:String>
<sys:String x:Key="VlessKcpDesc" xml:space="preserve">VLESS mKCP&#x0a;low delay</sys:String> <sys:String x:Key="VlessKcpDesc" xml:space="preserve">VLESS mKCP&#x0a;low delaywithout Domain</sys:String>
<sys:String x:Key="VmessWsDesc" xml:space="preserve">VMESS over WS with TLS&#x0a;Support CDN</sys:String> <sys:String x:Key="VmessWsDesc" xml:space="preserve">VMESS over WS with TLS&#x0a;Support CDN</sys:String>
<sys:String x:Key="VmessKcpDesc" xml:space="preserve">VMESS mKCP&#x0a;low delay</sys:String> <sys:String x:Key="VmessKcpDesc" xml:space="preserve">VMESS mKCP&#x0a;low delaywithout Domian</sys:String>
<sys:String x:Key="SSDesc" xml:space="preserve">ShadowSocks&#x0a;Support CDN</sys:String> <sys:String x:Key="SSDesc" xml:space="preserve">ShadowSocks&#x0a;Support UDPwithout Domain</sys:String>
<sys:String x:Key="TrojanDesc" xml:space="preserve">Trojan over TCP with TLS&#x0a;Trojan</sys:String> <sys:String x:Key="TrojanDesc" xml:space="preserve">Trojan over TCP with TLS&#x0a;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>

View File

@ -65,14 +65,14 @@
<sys:String x:Key="VlessXtlsDesc" xml:space="preserve">VLESS Over TCP With XTLS&#x0a;性能數倍,首選方式。</sys:String> <sys:String x:Key="VlessXtlsDesc" xml:space="preserve">VLESS Over TCP With XTLS&#x0a;性能數倍,首選方式。</sys:String>
<sys:String x:Key="VlessTcpDesc" xml:space="preserve">VLESS over TCP with TLS&#x0a;仍推薦XTLS。</sys:String> <sys:String x:Key="VlessTcpDesc" xml:space="preserve">VLESS over TCP with TLS&#x0a;仍推薦XTLS。</sys:String>
<sys:String x:Key="VlessWsDesc" xml:space="preserve">VLESS over WS with TLS&#x0a;推薦支持CDN。</sys:String> <sys:String x:Key="VlessWsDesc" xml:space="preserve">VLESS over WS with TLS&#x0a;推薦支持CDN。</sys:String>
<sys:String x:Key="VlessKcpDesc" xml:space="preserve">VLESS mKCP&#x0a;遊戲推薦,延遲低。</sys:String> <sys:String x:Key="VlessKcpDesc" xml:space="preserve">VLESS mKCP&#x0a;遊戲推薦,延遲低,免域名。</sys:String>
<sys:String x:Key="VmessWsDesc" xml:space="preserve">VMESS over WS with TLS&#x0a;推薦支持CDN。</sys:String> <sys:String x:Key="VmessWsDesc" xml:space="preserve">VMESS over WS with TLS&#x0a;推薦支持CDN。</sys:String>
<sys:String x:Key="VmessKcpDesc" xml:space="preserve">VMESS mKCP&#x0a;遊戲推薦,延遲低。</sys:String> <sys:String x:Key="VmessKcpDesc" xml:space="preserve">VMESS mKCP&#x0a;遊戲推薦,延遲低,免域名。</sys:String>
<sys:String x:Key="SSDesc" xml:space="preserve">ShadowSocks&#x0a;SS支持udp。</sys:String> <sys:String x:Key="SSDesc" xml:space="preserve">ShadowSocks&#x0a;SS支持udp,免域名。</sys:String>
<sys:String x:Key="TrojanDesc" xml:space="preserve">Trojan over TCP with TLS&#x0a;Trojan。</sys:String> <sys:String x:Key="TrojanDesc" xml:space="preserve">Trojan over TCP with TLS&#x0a;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>

View File

@ -66,14 +66,14 @@
<sys:String x:Key="VlessXtlsDesc" xml:space="preserve">VLESS Over TCP With XTLS&#x0a;性能数倍,首选方式。</sys:String> <sys:String x:Key="VlessXtlsDesc" xml:space="preserve">VLESS Over TCP With XTLS&#x0a;性能数倍,首选方式。</sys:String>
<sys:String x:Key="VlessTcpDesc" xml:space="preserve">VLESS over TCP with TLS&#x0a;仍推荐XTLS。</sys:String> <sys:String x:Key="VlessTcpDesc" xml:space="preserve">VLESS over TCP with TLS&#x0a;仍推荐XTLS。</sys:String>
<sys:String x:Key="VlessWsDesc" xml:space="preserve">VLESS over WS with TLS&#x0a;推荐支持CDN。</sys:String> <sys:String x:Key="VlessWsDesc" xml:space="preserve">VLESS over WS with TLS&#x0a;推荐支持CDN。</sys:String>
<sys:String x:Key="VlessKcpDesc" xml:space="preserve">VLESS mKCP&#x0a;游戏推荐,延迟低。</sys:String> <sys:String x:Key="VlessKcpDesc" xml:space="preserve">VLESS mKCP&#x0a;游戏推荐,延迟低,免域名。</sys:String>
<sys:String x:Key="VmessWsDesc" xml:space="preserve">VMESS over WS with TLS&#x0a;推荐支持CDN。</sys:String> <sys:String x:Key="VmessWsDesc" xml:space="preserve">VMESS over WS with TLS&#x0a;推荐支持CDN。</sys:String>
<sys:String x:Key="VmessKcpDesc" xml:space="preserve">VMESS mKCP&#x0a;游戏推荐,延迟低。</sys:String> <sys:String x:Key="VmessKcpDesc" xml:space="preserve">VMESS mKCP&#x0a;游戏推荐,延迟低,免域名。</sys:String>
<sys:String x:Key="SSDesc" xml:space="preserve">ShadowSocks&#x0a;SS支持udp。</sys:String> <sys:String x:Key="SSDesc" xml:space="preserve">ShadowSocks&#x0a;SS支持udp,免域名。</sys:String>
<sys:String x:Key="TrojanDesc" xml:space="preserve">Trojan over TCP with TLS&#x0a;Trojan。</sys:String> <sys:String x:Key="TrojanDesc" xml:space="preserve">Trojan over TCP with TLS&#x0a;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>