The first letter of the guiconfig attribute must be capitalized.

This commit is contained in:
2dust
2024-10-23 17:00:33 +08:00
parent 2d143687b8
commit 3c550c094a
75 changed files with 1355 additions and 1451 deletions
@@ -43,7 +43,7 @@
File.Delete(fileName);
}
string addressFileName = node.address;
string addressFileName = node.Address;
if (Utils.IsNullOrEmpty(addressFileName))
{
ret.Msg = ResUI.FailedGetDefaultConfiguration;
@@ -21,7 +21,7 @@ namespace ServiceLib.Services.CoreConfig
try
{
if (node == null
|| node.port <= 0)
|| node.Port <= 0)
{
ret.Msg = ResUI.CheckServerSettings;
return ret;
@@ -137,7 +137,7 @@ namespace ServiceLib.Services.CoreConfig
var item = await AppHandler.Instance.GetProfileItem(it.IndexId);
if (it.ConfigType is EConfigType.VMess or EConfigType.VLESS)
{
if (item is null || Utils.IsNullOrEmpty(item.id) || !Utils.IsGuidByParse(item.id))
if (item is null || Utils.IsNullOrEmpty(item.Id) || !Utils.IsGuidByParse(item.Id))
{
continue;
}
@@ -184,19 +184,19 @@ namespace ServiceLib.Services.CoreConfig
{
continue;
}
if (item.configType == EConfigType.Shadowsocks
&& !Global.SsSecuritiesInSingbox.Contains(item.security))
if (item.ConfigType == EConfigType.Shadowsocks
&& !Global.SsSecuritiesInSingbox.Contains(item.Security))
{
continue;
}
if (item.configType == EConfigType.VLESS
&& !Global.Flows.Contains(item.flow))
if (item.ConfigType == EConfigType.VLESS
&& !Global.Flows.Contains(item.Flow))
{
continue;
}
if (it.ConfigType is EConfigType.VLESS or EConfigType.Trojan
&& item.streamSecurity == Global.StreamSecurityReality
&& item.publicKey.IsNullOrEmpty())
&& item.StreamSecurity == Global.StreamSecurityReality
&& item.PublicKey.IsNullOrEmpty())
{
continue;
}
@@ -278,32 +278,32 @@ namespace ServiceLib.Services.CoreConfig
var tagProxy = new List<string>();
foreach (var it in selecteds)
{
if (it.configType == EConfigType.Custom)
if (it.ConfigType == EConfigType.Custom)
{
continue;
}
if (it.port <= 0)
if (it.Port <= 0)
{
continue;
}
var item = await AppHandler.Instance.GetProfileItem(it.indexId);
var item = await AppHandler.Instance.GetProfileItem(it.IndexId);
if (item is null)
{
continue;
}
if (it.configType is EConfigType.VMess or EConfigType.VLESS)
if (it.ConfigType is EConfigType.VMess or EConfigType.VLESS)
{
if (Utils.IsNullOrEmpty(item.id) || !Utils.IsGuidByParse(item.id))
if (Utils.IsNullOrEmpty(item.Id) || !Utils.IsGuidByParse(item.Id))
{
continue;
}
}
if (item.configType == EConfigType.Shadowsocks
&& !Global.SsSecuritiesInSingbox.Contains(item.security))
if (item.ConfigType == EConfigType.Shadowsocks
&& !Global.SsSecuritiesInSingbox.Contains(item.Security))
{
continue;
}
if (item.configType == EConfigType.VLESS && !Global.Flows.Contains(item.flow))
if (item.ConfigType == EConfigType.VLESS && !Global.Flows.Contains(item.Flow))
{
continue;
}
@@ -381,7 +381,7 @@ namespace ServiceLib.Services.CoreConfig
File.Delete(fileName);
}
string addressFileName = node.address;
string addressFileName = node.Address;
if (Utils.IsNullOrEmpty(addressFileName))
{
ret.Msg = ResUI.FailedGetDefaultConfiguration;
@@ -397,7 +397,7 @@ namespace ServiceLib.Services.CoreConfig
return ret;
}
if (node.address == Global.CoreMultipleLoadConfigFileName)
if (node.Address == Global.CoreMultipleLoadConfigFileName)
{
var txtFile = File.ReadAllText(addressFileName);
var singboxConfig = JsonUtils.Deserialize<SingboxConfig>(txtFile);
@@ -502,9 +502,9 @@ namespace ServiceLib.Services.CoreConfig
if (_config.RoutingBasicItem.EnableRoutingAdvanced)
{
var routing = await ConfigHandler.GetDefaultRouting(_config);
if (Utils.IsNotEmpty(routing.domainStrategy4Singbox))
if (Utils.IsNotEmpty(routing.DomainStrategy4Singbox))
{
inbound.domain_strategy = routing.domainStrategy4Singbox;
inbound.domain_strategy = routing.DomainStrategy4Singbox;
}
}
@@ -584,19 +584,19 @@ namespace ServiceLib.Services.CoreConfig
{
try
{
outbound.server = node.address;
outbound.server_port = node.port;
outbound.type = Global.ProtocolTypes[node.configType];
outbound.server = node.Address;
outbound.server_port = node.Port;
outbound.type = Global.ProtocolTypes[node.ConfigType];
switch (node.configType)
switch (node.ConfigType)
{
case EConfigType.VMess:
{
outbound.uuid = node.id;
outbound.alter_id = node.alterId;
if (Global.VmessSecurities.Contains(node.security))
outbound.uuid = node.Id;
outbound.alter_id = node.AlterId;
if (Global.VmessSecurities.Contains(node.Security))
{
outbound.security = node.security;
outbound.security = node.Security;
}
else
{
@@ -608,8 +608,8 @@ namespace ServiceLib.Services.CoreConfig
}
case EConfigType.Shadowsocks:
{
outbound.method = AppHandler.Instance.GetShadowsocksSecurities(node).Contains(node.security) ? node.security : Global.None;
outbound.password = node.id;
outbound.method = AppHandler.Instance.GetShadowsocksSecurities(node).Contains(node.Security) ? node.Security : Global.None;
outbound.password = node.Id;
await GenOutboundMux(node, outbound);
break;
@@ -617,57 +617,57 @@ namespace ServiceLib.Services.CoreConfig
case EConfigType.SOCKS:
{
outbound.version = "5";
if (Utils.IsNotEmpty(node.security)
&& Utils.IsNotEmpty(node.id))
if (Utils.IsNotEmpty(node.Security)
&& Utils.IsNotEmpty(node.Id))
{
outbound.username = node.security;
outbound.password = node.id;
outbound.username = node.Security;
outbound.password = node.Id;
}
break;
}
case EConfigType.HTTP:
{
if (Utils.IsNotEmpty(node.security)
&& Utils.IsNotEmpty(node.id))
if (Utils.IsNotEmpty(node.Security)
&& Utils.IsNotEmpty(node.Id))
{
outbound.username = node.security;
outbound.password = node.id;
outbound.username = node.Security;
outbound.password = node.Id;
}
break;
}
case EConfigType.VLESS:
{
outbound.uuid = node.id;
outbound.uuid = node.Id;
outbound.packet_encoding = "xudp";
if (Utils.IsNullOrEmpty(node.flow))
if (Utils.IsNullOrEmpty(node.Flow))
{
await GenOutboundMux(node, outbound);
}
else
{
outbound.flow = node.flow;
outbound.flow = node.Flow;
}
break;
}
case EConfigType.Trojan:
{
outbound.password = node.id;
outbound.password = node.Id;
await GenOutboundMux(node, outbound);
break;
}
case EConfigType.Hysteria2:
{
outbound.password = node.id;
outbound.password = node.Id;
if (Utils.IsNotEmpty(node.path))
if (Utils.IsNotEmpty(node.Path))
{
outbound.obfs = new()
{
type = "salamander",
password = node.path.TrimEx(),
password = node.Path.TrimEx(),
};
}
@@ -677,18 +677,18 @@ namespace ServiceLib.Services.CoreConfig
}
case EConfigType.TUIC:
{
outbound.uuid = node.id;
outbound.password = node.security;
outbound.congestion_control = node.headerType;
outbound.uuid = node.Id;
outbound.password = node.Security;
outbound.congestion_control = node.HeaderType;
break;
}
case EConfigType.WireGuard:
{
outbound.private_key = node.id;
outbound.peer_public_key = node.publicKey;
outbound.reserved = Utils.String2List(node.path)?.Select(int.Parse).ToList();
outbound.local_address = Utils.String2List(node.requestHost);
outbound.mtu = Utils.ToInt(node.shortId.IsNullOrEmpty() ? Global.TunMtus.FirstOrDefault() : node.shortId);
outbound.private_key = node.Id;
outbound.peer_public_key = node.PublicKey;
outbound.reserved = Utils.String2List(node.Path)?.Select(int.Parse).ToList();
outbound.local_address = Utils.String2List(node.RequestHost);
outbound.mtu = Utils.ToInt(node.ShortId.IsNullOrEmpty() ? Global.TunMtus.FirstOrDefault() : node.ShortId);
break;
}
}
@@ -731,39 +731,39 @@ namespace ServiceLib.Services.CoreConfig
{
try
{
if (node.streamSecurity == Global.StreamSecurityReality || node.streamSecurity == Global.StreamSecurity)
if (node.StreamSecurity == Global.StreamSecurityReality || node.StreamSecurity == Global.StreamSecurity)
{
var server_name = string.Empty;
if (Utils.IsNotEmpty(node.sni))
if (Utils.IsNotEmpty(node.Sni))
{
server_name = node.sni;
server_name = node.Sni;
}
else if (Utils.IsNotEmpty(node.requestHost))
else if (Utils.IsNotEmpty(node.RequestHost))
{
server_name = Utils.String2List(node.requestHost)?.First();
server_name = Utils.String2List(node.RequestHost)?.First();
}
var tls = new Tls4Sbox()
{
enabled = true,
server_name = server_name,
insecure = Utils.ToBool(node.allowInsecure.IsNullOrEmpty() ? _config.CoreBasicItem.DefAllowInsecure.ToString().ToLower() : node.allowInsecure),
insecure = Utils.ToBool(node.AllowInsecure.IsNullOrEmpty() ? _config.CoreBasicItem.DefAllowInsecure.ToString().ToLower() : node.AllowInsecure),
alpn = node.GetAlpn(),
};
if (Utils.IsNotEmpty(node.fingerprint))
if (Utils.IsNotEmpty(node.Fingerprint))
{
tls.utls = new Utls4Sbox()
{
enabled = true,
fingerprint = node.fingerprint.IsNullOrEmpty() ? _config.CoreBasicItem.DefFingerprint : node.fingerprint
fingerprint = node.Fingerprint.IsNullOrEmpty() ? _config.CoreBasicItem.DefFingerprint : node.Fingerprint
};
}
if (node.streamSecurity == Global.StreamSecurityReality)
if (node.StreamSecurity == Global.StreamSecurityReality)
{
tls.reality = new Reality4Sbox()
{
enabled = true,
public_key = node.publicKey,
short_id = node.shortId
public_key = node.PublicKey,
short_id = node.ShortId
};
tls.insecure = false;
}
@@ -787,43 +787,43 @@ namespace ServiceLib.Services.CoreConfig
{
case nameof(ETransport.h2):
transport.type = nameof(ETransport.http);
transport.host = Utils.IsNullOrEmpty(node.requestHost) ? null : Utils.String2List(node.requestHost);
transport.path = Utils.IsNullOrEmpty(node.path) ? null : node.path;
transport.host = Utils.IsNullOrEmpty(node.RequestHost) ? null : Utils.String2List(node.RequestHost);
transport.path = Utils.IsNullOrEmpty(node.Path) ? null : node.Path;
break;
case nameof(ETransport.tcp): //http
if (node.headerType == Global.TcpHeaderHttp)
if (node.HeaderType == Global.TcpHeaderHttp)
{
if (node.configType == EConfigType.Shadowsocks)
if (node.ConfigType == EConfigType.Shadowsocks)
{
outbound.plugin = "obfs-local";
outbound.plugin_opts = $"obfs=http;obfs-host={node.requestHost};";
outbound.plugin_opts = $"obfs=http;obfs-host={node.RequestHost};";
}
else
{
transport.type = nameof(ETransport.http);
transport.host = Utils.IsNullOrEmpty(node.requestHost) ? null : Utils.String2List(node.requestHost);
transport.path = Utils.IsNullOrEmpty(node.path) ? null : node.path;
transport.host = Utils.IsNullOrEmpty(node.RequestHost) ? null : Utils.String2List(node.RequestHost);
transport.path = Utils.IsNullOrEmpty(node.Path) ? null : node.Path;
}
}
break;
case nameof(ETransport.ws):
transport.type = nameof(ETransport.ws);
transport.path = Utils.IsNullOrEmpty(node.path) ? null : node.path;
if (Utils.IsNotEmpty(node.requestHost))
transport.path = Utils.IsNullOrEmpty(node.Path) ? null : node.Path;
if (Utils.IsNotEmpty(node.RequestHost))
{
transport.headers = new()
{
Host = node.requestHost
Host = node.RequestHost
};
}
break;
case nameof(ETransport.httpupgrade):
transport.type = nameof(ETransport.httpupgrade);
transport.path = Utils.IsNullOrEmpty(node.path) ? null : node.path;
transport.host = Utils.IsNullOrEmpty(node.requestHost) ? null : node.requestHost;
transport.path = Utils.IsNullOrEmpty(node.Path) ? null : node.Path;
transport.host = Utils.IsNullOrEmpty(node.RequestHost) ? null : node.RequestHost;
break;
@@ -833,9 +833,9 @@ namespace ServiceLib.Services.CoreConfig
case nameof(ETransport.grpc):
transport.type = nameof(ETransport.grpc);
transport.service_name = node.path;
transport.idle_timeout = _config.GrpcItem.IdleTimeout.ToString("##s");
transport.ping_timeout = _config.GrpcItem.HealthCheckTimeout.ToString("##s");
transport.service_name = node.Path;
transport.idle_timeout = _config.GrpcItem.IdleTimeout?.ToString("##s");
transport.ping_timeout = _config.GrpcItem.HealthCheckTimeout?.ToString("##s");
transport.permit_without_stream = _config.GrpcItem.PermitWithoutStream;
break;
@@ -856,13 +856,13 @@ namespace ServiceLib.Services.CoreConfig
private async Task<int> GenMoreOutbounds(ProfileItem node, SingboxConfig singboxConfig)
{
if (node.subid.IsNullOrEmpty())
if (node.Subid.IsNullOrEmpty())
{
return 0;
}
try
{
var subItem = await AppHandler.Instance.GetSubItem(node.subid);
var subItem = await AppHandler.Instance.GetSubItem(node.Subid);
if (subItem is null)
{
return 0;
@@ -873,9 +873,9 @@ namespace ServiceLib.Services.CoreConfig
var txtOutbound = Utils.GetEmbedText(Global.SingboxSampleOutbound);
//Previous proxy
var prevNode = await AppHandler.Instance.GetProfileItemViaRemarks(subItem.prevProfile);
var prevNode = await AppHandler.Instance.GetProfileItemViaRemarks(subItem.PrevProfile);
if (prevNode is not null
&& prevNode.configType != EConfigType.Custom)
&& prevNode.ConfigType != EConfigType.Custom)
{
var prevOutbound = JsonUtils.Deserialize<Outbound4Sbox>(txtOutbound);
await GenOutbound(prevNode, prevOutbound);
@@ -886,9 +886,9 @@ namespace ServiceLib.Services.CoreConfig
}
//Next proxy
var nextNode = await AppHandler.Instance.GetProfileItemViaRemarks(subItem.nextProfile);
var nextNode = await AppHandler.Instance.GetProfileItemViaRemarks(subItem.NextProfile);
if (nextNode is not null
&& nextNode.configType != EConfigType.Custom)
&& nextNode.ConfigType != EConfigType.Custom)
{
var nextOutbound = JsonUtils.Deserialize<Outbound4Sbox>(txtOutbound);
await GenOutbound(nextNode, nextOutbound);
@@ -963,10 +963,10 @@ namespace ServiceLib.Services.CoreConfig
var routing = await ConfigHandler.GetDefaultRouting(_config);
if (routing != null)
{
var rules = JsonUtils.Deserialize<List<RulesItem>>(routing.ruleSet);
var rules = JsonUtils.Deserialize<List<RulesItem>>(routing.RuleSet);
foreach (var item in rules ?? [])
{
if (item.enabled)
if (item.Enabled)
{
await GenRoutingUserRule(item, singboxConfig.route.rules);
}
@@ -978,7 +978,7 @@ namespace ServiceLib.Services.CoreConfig
var lockedItem = await ConfigHandler.GetLockedRoutingItem(_config);
if (lockedItem != null)
{
var rules = JsonUtils.Deserialize<List<RulesItem>>(lockedItem.ruleSet);
var rules = JsonUtils.Deserialize<List<RulesItem>>(lockedItem.RuleSet);
foreach (var item in rules ?? [])
{
await GenRoutingUserRule(item, singboxConfig.route.rules);
@@ -1185,11 +1185,11 @@ namespace ServiceLib.Services.CoreConfig
var strDNS = string.Empty;
if (_config.TunModeItem.EnableTun)
{
strDNS = Utils.IsNullOrEmpty(item?.tunDNS) ? Utils.GetEmbedText(Global.TunSingboxDNSFileName) : item?.tunDNS;
strDNS = Utils.IsNullOrEmpty(item?.TunDNS) ? Utils.GetEmbedText(Global.TunSingboxDNSFileName) : item?.TunDNS;
}
else
{
strDNS = Utils.IsNullOrEmpty(item?.normalDNS) ? Utils.GetEmbedText(Global.DNSSingboxNormalFileName) : item?.normalDNS;
strDNS = Utils.IsNullOrEmpty(item?.NormalDNS) ? Utils.GetEmbedText(Global.DNSSingboxNormalFileName) : item?.NormalDNS;
}
var dns4Sbox = JsonUtils.Deserialize<Dns4Sbox>(strDNS);
@@ -1218,9 +1218,9 @@ namespace ServiceLib.Services.CoreConfig
dns4Sbox.servers.Add(new()
{
tag = tag,
address = Utils.IsNullOrEmpty(dNSItem?.domainDNSAddress) ? Global.SingboxDomainDNSAddress.FirstOrDefault() : dNSItem?.domainDNSAddress,
address = Utils.IsNullOrEmpty(dNSItem?.DomainDNSAddress) ? Global.SingboxDomainDNSAddress.FirstOrDefault() : dNSItem?.DomainDNSAddress,
detour = Global.DirectTag,
strategy = Utils.IsNullOrEmpty(dNSItem?.domainStrategy4Freedom) ? null : dNSItem?.domainStrategy4Freedom,
strategy = Utils.IsNullOrEmpty(dNSItem?.DomainStrategy4Freedom) ? null : dNSItem?.DomainStrategy4Freedom,
});
dns4Sbox.rules.Insert(0, new()
{
@@ -1248,12 +1248,12 @@ namespace ServiceLib.Services.CoreConfig
}
//Tun2SocksAddress
if (_config.TunModeItem.EnableTun && node?.configType == EConfigType.SOCKS && Utils.IsDomain(node?.sni))
if (_config.TunModeItem.EnableTun && node?.ConfigType == EConfigType.SOCKS && Utils.IsDomain(node?.Sni))
{
dns4Sbox.rules.Insert(0, new()
{
server = tag,
domain = [node?.sni]
domain = [node?.Sni]
});
}
@@ -1337,9 +1337,9 @@ namespace ServiceLib.Services.CoreConfig
if (_config.RoutingBasicItem.EnableRoutingAdvanced)
{
var routing = await ConfigHandler.GetDefaultRouting(_config);
if (Utils.IsNotEmpty(routing.customRulesetPath4Singbox))
if (Utils.IsNotEmpty(routing.CustomRulesetPath4Singbox))
{
var result = Utils.LoadResource(routing.customRulesetPath4Singbox);
var result = Utils.LoadResource(routing.CustomRulesetPath4Singbox);
if (Utils.IsNotEmpty(result))
{
customRulesets = (JsonUtils.Deserialize<List<Ruleset4Sbox>>(result) ?? [])
@@ -21,7 +21,7 @@ namespace ServiceLib.Services.CoreConfig
try
{
if (node == null
|| node.port <= 0)
|| node.Port <= 0)
{
ret.Msg = ResUI.CheckServerSettings;
return ret;
@@ -109,36 +109,36 @@ namespace ServiceLib.Services.CoreConfig
var tagProxy = new List<string>();
foreach (var it in selecteds)
{
if (it.configType == EConfigType.Custom)
if (it.ConfigType == EConfigType.Custom)
{
continue;
}
if (it.configType is EConfigType.Hysteria2 or EConfigType.TUIC or EConfigType.WireGuard)
if (it.ConfigType is EConfigType.Hysteria2 or EConfigType.TUIC or EConfigType.WireGuard)
{
continue;
}
if (it.port <= 0)
if (it.Port <= 0)
{
continue;
}
var item = await AppHandler.Instance.GetProfileItem(it.indexId);
var item = await AppHandler.Instance.GetProfileItem(it.IndexId);
if (item is null)
{
continue;
}
if (it.configType is EConfigType.VMess or EConfigType.VLESS)
if (it.ConfigType is EConfigType.VMess or EConfigType.VLESS)
{
if (Utils.IsNullOrEmpty(item.id) || !Utils.IsGuidByParse(item.id))
if (Utils.IsNullOrEmpty(item.Id) || !Utils.IsGuidByParse(item.Id))
{
continue;
}
}
if (item.configType == EConfigType.Shadowsocks
&& !Global.SsSecuritiesInSingbox.Contains(item.security))
if (item.ConfigType == EConfigType.Shadowsocks
&& !Global.SsSecuritiesInSingbox.Contains(item.Security))
{
continue;
}
if (item.configType == EConfigType.VLESS && !Global.Flows.Contains(item.flow))
if (item.ConfigType == EConfigType.VLESS && !Global.Flows.Contains(item.Flow))
{
continue;
}
@@ -256,7 +256,7 @@ namespace ServiceLib.Services.CoreConfig
var item = await AppHandler.Instance.GetProfileItem(it.IndexId);
if (it.ConfigType is EConfigType.VMess or EConfigType.VLESS)
{
if (item is null || Utils.IsNullOrEmpty(item.id) || !Utils.IsGuidByParse(item.id))
if (item is null || Utils.IsNullOrEmpty(item.Id) || !Utils.IsGuidByParse(item.Id))
{
continue;
}
@@ -303,19 +303,19 @@ namespace ServiceLib.Services.CoreConfig
{
continue;
}
if (item.configType == EConfigType.Shadowsocks
&& !Global.SsSecuritiesInXray.Contains(item.security))
if (item.ConfigType == EConfigType.Shadowsocks
&& !Global.SsSecuritiesInXray.Contains(item.Security))
{
continue;
}
if (item.configType == EConfigType.VLESS
&& !Global.Flows.Contains(item.flow))
if (item.ConfigType == EConfigType.VLESS
&& !Global.Flows.Contains(item.Flow))
{
continue;
}
if (it.ConfigType is EConfigType.VLESS or EConfigType.Trojan
&& item.streamSecurity == Global.StreamSecurityReality
&& item.publicKey.IsNullOrEmpty())
&& item.StreamSecurity == Global.StreamSecurityReality
&& item.PublicKey.IsNullOrEmpty())
{
continue;
}
@@ -465,14 +465,14 @@ namespace ServiceLib.Services.CoreConfig
var routing = await ConfigHandler.GetDefaultRouting(_config);
if (routing != null)
{
if (Utils.IsNotEmpty(routing.domainStrategy))
if (Utils.IsNotEmpty(routing.DomainStrategy))
{
v2rayConfig.routing.domainStrategy = routing.domainStrategy;
v2rayConfig.routing.domainStrategy = routing.DomainStrategy;
}
var rules = JsonUtils.Deserialize<List<RulesItem>>(routing.ruleSet);
var rules = JsonUtils.Deserialize<List<RulesItem>>(routing.RuleSet);
foreach (var item in rules)
{
if (item.enabled)
if (item.Enabled)
{
var item2 = JsonUtils.Deserialize<RulesItem4Ray>(JsonUtils.Serialize(item));
await GenRoutingUserRule(item2, v2rayConfig);
@@ -485,7 +485,7 @@ namespace ServiceLib.Services.CoreConfig
var lockedItem = await ConfigHandler.GetLockedRoutingItem(_config);
if (lockedItem != null)
{
var rules = JsonUtils.Deserialize<List<RulesItem>>(lockedItem.ruleSet);
var rules = JsonUtils.Deserialize<List<RulesItem>>(lockedItem.RuleSet);
foreach (var item in rules)
{
var item2 = JsonUtils.Deserialize<RulesItem4Ray>(JsonUtils.Serialize(item));
@@ -584,7 +584,7 @@ namespace ServiceLib.Services.CoreConfig
{
try
{
switch (node.configType)
switch (node.ConfigType)
{
case EConfigType.VMess:
{
@@ -598,8 +598,8 @@ namespace ServiceLib.Services.CoreConfig
{
vnextItem = outbound.settings.vnext[0];
}
vnextItem.address = node.address;
vnextItem.port = node.port;
vnextItem.address = node.Address;
vnextItem.port = node.Port;
UsersItem4Ray usersItem;
if (vnextItem.users.Count <= 0)
@@ -612,12 +612,12 @@ namespace ServiceLib.Services.CoreConfig
usersItem = vnextItem.users[0];
}
//远程服务器用户ID
usersItem.id = node.id;
usersItem.alterId = node.alterId;
usersItem.id = node.Id;
usersItem.alterId = node.AlterId;
usersItem.email = Global.UserEMail;
if (Global.VmessSecurities.Contains(node.security))
if (Global.VmessSecurities.Contains(node.Security))
{
usersItem.security = node.security;
usersItem.security = node.Security;
}
else
{
@@ -641,10 +641,10 @@ namespace ServiceLib.Services.CoreConfig
{
serversItem = outbound.settings.servers[0];
}
serversItem.address = node.address;
serversItem.port = node.port;
serversItem.password = node.id;
serversItem.method = AppHandler.Instance.GetShadowsocksSecurities(node).Contains(node.security) ? node.security : "none";
serversItem.address = node.Address;
serversItem.port = node.Port;
serversItem.password = node.Id;
serversItem.method = AppHandler.Instance.GetShadowsocksSecurities(node).Contains(node.Security) ? node.Security : "none";
serversItem.ota = false;
serversItem.level = 1;
@@ -667,18 +667,18 @@ namespace ServiceLib.Services.CoreConfig
{
serversItem = outbound.settings.servers[0];
}
serversItem.address = node.address;
serversItem.port = node.port;
serversItem.address = node.Address;
serversItem.port = node.Port;
serversItem.method = null;
serversItem.password = null;
if (Utils.IsNotEmpty(node.security)
&& Utils.IsNotEmpty(node.id))
if (Utils.IsNotEmpty(node.Security)
&& Utils.IsNotEmpty(node.Id))
{
SocksUsersItem4Ray socksUsersItem = new()
{
user = node.security,
pass = node.id,
user = node.Security,
pass = node.Id,
level = 1
};
@@ -702,8 +702,8 @@ namespace ServiceLib.Services.CoreConfig
{
vnextItem = outbound.settings.vnext[0];
}
vnextItem.address = node.address;
vnextItem.port = node.port;
vnextItem.address = node.Address;
vnextItem.port = node.Port;
UsersItem4Ray usersItem;
if (vnextItem.users.Count <= 0)
@@ -715,23 +715,23 @@ namespace ServiceLib.Services.CoreConfig
{
usersItem = vnextItem.users[0];
}
usersItem.id = node.id;
usersItem.id = node.Id;
usersItem.email = Global.UserEMail;
usersItem.encryption = node.security;
usersItem.encryption = node.Security;
await GenOutboundMux(node, outbound, _config.CoreBasicItem.MuxEnabled);
if (node.streamSecurity == Global.StreamSecurityReality
|| node.streamSecurity == Global.StreamSecurity)
if (node.StreamSecurity == Global.StreamSecurityReality
|| node.StreamSecurity == Global.StreamSecurity)
{
if (Utils.IsNotEmpty(node.flow))
if (Utils.IsNotEmpty(node.Flow))
{
usersItem.flow = node.flow;
usersItem.flow = node.Flow;
await GenOutboundMux(node, outbound, false);
}
}
if (node.streamSecurity == Global.StreamSecurityReality && Utils.IsNullOrEmpty(node.flow))
if (node.StreamSecurity == Global.StreamSecurityReality && Utils.IsNullOrEmpty(node.Flow))
{
await GenOutboundMux(node, outbound, _config.CoreBasicItem.MuxEnabled);
}
@@ -751,9 +751,9 @@ namespace ServiceLib.Services.CoreConfig
{
serversItem = outbound.settings.servers[0];
}
serversItem.address = node.address;
serversItem.port = node.port;
serversItem.password = node.id;
serversItem.address = node.Address;
serversItem.port = node.Port;
serversItem.password = node.Id;
serversItem.ota = false;
serversItem.level = 1;
@@ -765,7 +765,7 @@ namespace ServiceLib.Services.CoreConfig
}
}
outbound.protocol = Global.ProtocolTypes[node.configType];
outbound.protocol = Global.ProtocolTypes[node.ConfigType];
await GenBoundStreamSettings(node, outbound.streamSettings);
}
catch (Exception ex)
@@ -804,8 +804,8 @@ namespace ServiceLib.Services.CoreConfig
try
{
streamSettings.network = node.GetNetwork();
string host = node.requestHost.TrimEx();
string sni = node.sni;
string host = node.RequestHost.TrimEx();
string sni = node.Sni;
string useragent = "";
if (!_config.CoreBasicItem.DefUserAgent.IsNullOrEmpty())
{
@@ -820,15 +820,15 @@ namespace ServiceLib.Services.CoreConfig
}
//if tls
if (node.streamSecurity == Global.StreamSecurity)
if (node.StreamSecurity == Global.StreamSecurity)
{
streamSettings.security = node.streamSecurity;
streamSettings.security = node.StreamSecurity;
TlsSettings4Ray tlsSettings = new()
{
allowInsecure = Utils.ToBool(node.allowInsecure.IsNullOrEmpty() ? _config.CoreBasicItem.DefAllowInsecure.ToString().ToLower() : node.allowInsecure),
allowInsecure = Utils.ToBool(node.AllowInsecure.IsNullOrEmpty() ? _config.CoreBasicItem.DefAllowInsecure.ToString().ToLower() : node.AllowInsecure),
alpn = node.GetAlpn(),
fingerprint = node.fingerprint.IsNullOrEmpty() ? _config.CoreBasicItem.DefFingerprint : node.fingerprint
fingerprint = node.Fingerprint.IsNullOrEmpty() ? _config.CoreBasicItem.DefFingerprint : node.Fingerprint
};
if (Utils.IsNotEmpty(sni))
{
@@ -842,17 +842,17 @@ namespace ServiceLib.Services.CoreConfig
}
//if Reality
if (node.streamSecurity == Global.StreamSecurityReality)
if (node.StreamSecurity == Global.StreamSecurityReality)
{
streamSettings.security = node.streamSecurity;
streamSettings.security = node.StreamSecurity;
TlsSettings4Ray realitySettings = new()
{
fingerprint = node.fingerprint.IsNullOrEmpty() ? _config.CoreBasicItem.DefFingerprint : node.fingerprint,
fingerprint = node.Fingerprint.IsNullOrEmpty() ? _config.CoreBasicItem.DefFingerprint : node.Fingerprint,
serverName = sni,
publicKey = node.publicKey,
shortId = node.shortId,
spiderX = node.spiderX,
publicKey = node.PublicKey,
shortId = node.ShortId,
spiderX = node.SpiderX,
show = false,
};
@@ -877,11 +877,11 @@ namespace ServiceLib.Services.CoreConfig
kcpSettings.writeBufferSize = _config.KcpItem.WriteBufferSize;
kcpSettings.header = new Header4Ray
{
type = node.headerType
type = node.HeaderType
};
if (Utils.IsNotEmpty(node.path))
if (Utils.IsNotEmpty(node.Path))
{
kcpSettings.seed = node.path;
kcpSettings.seed = node.Path;
}
streamSettings.kcpSettings = kcpSettings;
break;
@@ -889,7 +889,7 @@ namespace ServiceLib.Services.CoreConfig
case nameof(ETransport.ws):
WsSettings4Ray wsSettings = new();
wsSettings.headers = new Headers4Ray();
string path = node.path;
string path = node.Path;
if (Utils.IsNotEmpty(host))
{
wsSettings.headers.Host = host;
@@ -909,9 +909,9 @@ namespace ServiceLib.Services.CoreConfig
case nameof(ETransport.httpupgrade):
HttpupgradeSettings4Ray httpupgradeSettings = new();
if (Utils.IsNotEmpty(node.path))
if (Utils.IsNotEmpty(node.Path))
{
httpupgradeSettings.path = node.path;
httpupgradeSettings.path = node.Path;
}
if (Utils.IsNotEmpty(host))
{
@@ -928,9 +928,9 @@ namespace ServiceLib.Services.CoreConfig
maxConcurrentUploads = 10
};
if (Utils.IsNotEmpty(node.path))
if (Utils.IsNotEmpty(node.Path))
{
splithttpSettings.path = node.path;
splithttpSettings.path = node.Path;
}
if (Utils.IsNotEmpty(host))
{
@@ -947,7 +947,7 @@ namespace ServiceLib.Services.CoreConfig
{
httpSettings.host = Utils.String2List(host);
}
httpSettings.path = node.path;
httpSettings.path = node.Path;
streamSettings.httpSettings = httpSettings;
@@ -957,14 +957,14 @@ namespace ServiceLib.Services.CoreConfig
QuicSettings4Ray quicsettings = new()
{
security = host,
key = node.path,
key = node.Path,
header = new Header4Ray
{
type = node.headerType
type = node.HeaderType
}
};
streamSettings.quicSettings = quicsettings;
if (node.streamSecurity == Global.StreamSecurity)
if (node.StreamSecurity == Global.StreamSecurity)
{
if (Utils.IsNotEmpty(sni))
{
@@ -972,7 +972,7 @@ namespace ServiceLib.Services.CoreConfig
}
else
{
streamSettings.tlsSettings.serverName = node.address;
streamSettings.tlsSettings.serverName = node.Address;
}
}
break;
@@ -981,8 +981,8 @@ namespace ServiceLib.Services.CoreConfig
GrpcSettings4Ray grpcSettings = new()
{
authority = Utils.IsNullOrEmpty(host) ? null : host,
serviceName = node.path,
multiMode = node.headerType == Global.GrpcMultiMode,
serviceName = node.Path,
multiMode = node.HeaderType == Global.GrpcMultiMode,
idle_timeout = _config.GrpcItem.IdleTimeout,
health_check_timeout = _config.GrpcItem.HealthCheckTimeout,
permit_without_stream = _config.GrpcItem.PermitWithoutStream,
@@ -993,13 +993,13 @@ namespace ServiceLib.Services.CoreConfig
default:
//tcp
if (node.headerType == Global.TcpHeaderHttp)
if (node.HeaderType == Global.TcpHeaderHttp)
{
TcpSettings4Ray tcpSettings = new()
{
header = new Header4Ray
{
type = node.headerType
type = node.HeaderType
}
};
@@ -1012,9 +1012,9 @@ namespace ServiceLib.Services.CoreConfig
request = request.Replace("$requestUserAgent$", $"\"{useragent}\"");
//Path
string pathHttp = @"/";
if (Utils.IsNotEmpty(node.path))
if (Utils.IsNotEmpty(node.Path))
{
string[] arrPath = node.path.Split(',');
string[] arrPath = node.Path.Split(',');
pathHttp = string.Join("\",\"", arrPath);
}
request = request.Replace("$requestPath$", $"\"{pathHttp}\"");
@@ -1037,8 +1037,8 @@ namespace ServiceLib.Services.CoreConfig
try
{
var item = await AppHandler.Instance.GetDNSItem(ECoreType.Xray);
var normalDNS = item?.normalDNS;
var domainStrategy4Freedom = item?.domainStrategy4Freedom;
var normalDNS = item?.NormalDNS;
var domainStrategy4Freedom = item?.DomainStrategy4Freedom;
if (Utils.IsNullOrEmpty(normalDNS))
{
normalDNS = Utils.GetEmbedText(Global.DNSV2rayNormalFileName);
@@ -1066,7 +1066,7 @@ namespace ServiceLib.Services.CoreConfig
}
// 追加至 dns 设置
if (item.useSystemHosts)
if (item.UseSystemHosts)
{
var systemHosts = Utils.GetSystemHosts();
if (systemHosts.Count > 0)
@@ -1102,12 +1102,12 @@ namespace ServiceLib.Services.CoreConfig
var servers = dns["servers"];
if (servers != null)
{
if (Utils.IsDomain(node.address))
if (Utils.IsDomain(node.Address))
{
var dnsServer = new DnsServer4Ray()
{
address = Utils.IsNullOrEmpty(dNSItem?.domainDNSAddress) ? Global.DomainDNSAddress.FirstOrDefault() : dNSItem?.domainDNSAddress,
domains = [node.address]
address = Utils.IsNullOrEmpty(dNSItem?.DomainDNSAddress) ? Global.DomainDNSAddress.FirstOrDefault() : dNSItem?.DomainDNSAddress,
domains = [node.Address]
};
servers.AsArray().Add(JsonUtils.SerializeToNode(dnsServer));
}
@@ -1194,13 +1194,13 @@ namespace ServiceLib.Services.CoreConfig
return 0;
}
if (node.subid.IsNullOrEmpty())
if (node.Subid.IsNullOrEmpty())
{
return 0;
}
try
{
var subItem = await AppHandler.Instance.GetSubItem(node.subid);
var subItem = await AppHandler.Instance.GetSubItem(node.Subid);
if (subItem is null)
{
return 0;
@@ -1211,12 +1211,12 @@ namespace ServiceLib.Services.CoreConfig
var txtOutbound = Utils.GetEmbedText(Global.V2raySampleOutbound);
//Previous proxy
var prevNode = await AppHandler.Instance.GetProfileItemViaRemarks(subItem.prevProfile);
var prevNode = await AppHandler.Instance.GetProfileItemViaRemarks(subItem.PrevProfile);
if (prevNode is not null
&& prevNode.configType != EConfigType.Custom
&& prevNode.configType != EConfigType.Hysteria2
&& prevNode.configType != EConfigType.TUIC
&& prevNode.configType != EConfigType.WireGuard)
&& prevNode.ConfigType != EConfigType.Custom
&& prevNode.ConfigType != EConfigType.Hysteria2
&& prevNode.ConfigType != EConfigType.TUIC
&& prevNode.ConfigType != EConfigType.WireGuard)
{
var prevOutbound = JsonUtils.Deserialize<Outbounds4Ray>(txtOutbound);
await GenOutbound(prevNode, prevOutbound);
@@ -1230,12 +1230,12 @@ namespace ServiceLib.Services.CoreConfig
}
//Next proxy
var nextNode = await AppHandler.Instance.GetProfileItemViaRemarks(subItem.nextProfile);
var nextNode = await AppHandler.Instance.GetProfileItemViaRemarks(subItem.NextProfile);
if (nextNode is not null
&& nextNode.configType != EConfigType.Custom
&& nextNode.configType != EConfigType.Hysteria2
&& nextNode.configType != EConfigType.TUIC
&& nextNode.configType != EConfigType.WireGuard)
&& nextNode.ConfigType != EConfigType.Custom
&& nextNode.ConfigType != EConfigType.Hysteria2
&& nextNode.ConfigType != EConfigType.TUIC
&& nextNode.ConfigType != EConfigType.WireGuard)
{
var nextOutbound = JsonUtils.Deserialize<Outbounds4Ray>(txtOutbound);
await GenOutbound(nextNode, nextOutbound);