1
0
mirror of https://github.com/proxysu/ProxySU.git synced 2024-11-21 20:56:08 +03:00

update 4.0.4

This commit is contained in:
autumn 2021-07-13 11:05:10 +08:00
parent b9b41b6554
commit 860dfb6520
4 changed files with 75 additions and 103 deletions

View File

@ -3,6 +3,7 @@ using ProxySuper.Core.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
namespace ProxySuper.Core.Models.Projects
{
@ -37,33 +38,11 @@ namespace ProxySuper.Core.Models.Projects
}
[JsonIgnore]
public bool WithTLS
public bool IsIPAddress
{
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;
return IPAddress.TryParse(Domain, out _);
}
}

View File

@ -722,7 +722,6 @@ namespace ProxySuper.Core.Services
throw new Exception("安装 acme.sh 失败,请联系开发者!");
}
RunCmd("cd ~/.acme.sh/");
RunCmd("alias acme.sh=~/.acme.sh/acme.sh");
// 申请证书

View File

@ -67,7 +67,7 @@ namespace ProxySuper.Core.Services
public static string BuildCaddyConfig(XraySettings parameters, bool useCustomWeb = false)
{
var caddyStr = File.ReadAllText(Path.Combine(CaddyFileDir, "base.caddyfile"));
caddyStr = caddyStr.Replace("##domain##", parameters.Domain);
caddyStr = caddyStr.Replace("##domain##", parameters.IsIPAddress ? "" : parameters.Domain);
caddyStr = caddyStr.Replace("##port##", FullbackPort.ToString());
if (!useCustomWeb && !string.IsNullOrEmpty(parameters.MaskDomain))
@ -118,79 +118,77 @@ namespace ProxySuper.Core.Services
var xrayConfig = LoadXrayConfig();
if (parameters.IsFullbackMode)
var baseBound = GetBound("VLESS_TCP_XTLS.json");
baseBound.port = parameters.Port;
baseBound.settings.fallbacks.Add(JToken.FromObject(new
{
#region Fullbacks
var baseBound = GetBound("VLESS_TCP_XTLS.json");
baseBound.port = parameters.Port;
dest = FullbackPort
}));
xrayConfig.inbounds.Add(baseBound);
SetClients(baseBound, uuidList, withXtls: true);
#region Fullbacks
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 = FullbackPort
dest = VLESS_WS_Port,
path = parameters.VLESS_WS_Path,
xver = 1,
}));
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
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))
{
var gRPCInBound = GetBound("VLESS_gRPC.json");
@ -211,8 +209,6 @@ namespace ProxySuper.Core.Services
xrayConfig.inbounds.Add(JToken.FromObject(kcpBound));
}
if (parameters.Types.Contains(XrayType.VMESS_KCP))
{
var kcpBound = GetBound("VMESS_KCP.json");
@ -223,7 +219,6 @@ namespace ProxySuper.Core.Services
xrayConfig.inbounds.Add(JToken.FromObject(kcpBound));
}
if (parameters.Types.Contains(XrayType.ShadowsocksAEAD))
{
var ssBound = GetBound("Shadowsocks-AEAD.json");

View File

@ -68,18 +68,17 @@ namespace ProxySuper.Core.Services
SyncTimeDiff();
WriteOutput("时间同步完成");
if (Parameters.WithTLS)
if (!Parameters.IsIPAddress)
{
WriteOutput("检测域名是否绑定本机IP...");
ValidateDomain();
WriteOutput("域名检测完成");
WriteOutput("安装Caddy...");
InstallCaddy();
WriteOutput("Caddy安装完成");
}
WriteOutput("安装Caddy...");
InstallCaddy();
WriteOutput("Caddy安装完成");
WriteOutput("安装Xray-Core...");
InstallXrayWithCert();
WriteOutput("Xray-Core安装完成");
@ -297,7 +296,7 @@ namespace ProxySuper.Core.Services
RunCmd(@"mv /usr/local/etc/xray/config.json /usr/local/etc/xray/config.json.1");
}
if (Parameters.WithTLS)
if (!Parameters.IsIPAddress)
{
WriteOutput("安装TLS证书");
InstallCertToXray();