mirror of
https://github.com/2dust/v2rayN.git
synced 2026-02-28 21:23:04 +00:00
Fix
This commit is contained in:
parent
3768e0d989
commit
437ba09d06
3 changed files with 35 additions and 30 deletions
|
|
@ -95,14 +95,14 @@ public static class CoreConfigHandler
|
|||
{
|
||||
var result = new RetResult();
|
||||
var context = await BuildCoreConfigContext(config, new());
|
||||
foreach (var serverTestItem in selecteds.Where(serverTestItem => !serverTestItem.IndexId.IsNullOrEmpty()))
|
||||
{
|
||||
var node = await AppManager.Instance.GetProfileItem(serverTestItem.IndexId!);
|
||||
if (node != null)
|
||||
var ids = selecteds.Where(serverTestItem => !serverTestItem.IndexId.IsNullOrEmpty())
|
||||
.Select(serverTestItem => serverTestItem.IndexId!)
|
||||
.ToList();
|
||||
foreach (var id in ids)
|
||||
{
|
||||
var node = await AppManager.Instance.GetProfileItem(id) ?? new();
|
||||
await FillNodeContext(context, node, false);
|
||||
}
|
||||
}
|
||||
if (coreType == ECoreType.sing_box)
|
||||
{
|
||||
result = new CoreConfigSingboxService(context).GenerateClientSpeedtestConfig(selecteds);
|
||||
|
|
@ -186,34 +186,37 @@ public static class CoreConfigHandler
|
|||
return node;
|
||||
}
|
||||
context.AllProxiesMap[node.IndexId] = node;
|
||||
var newItems = new List<ProfileItem> { node };
|
||||
|
||||
if (node.ConfigType.IsGroupType())
|
||||
{
|
||||
var groupChildList = await GroupProfileManager.GetAllChildProfileItems(node);
|
||||
foreach (var childItem in groupChildList)
|
||||
{
|
||||
context.AllProxiesMap[childItem.IndexId] = childItem;
|
||||
newItems.Add(childItem);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var profileItemPair in context.AllProxiesMap)
|
||||
foreach (var item in newItems)
|
||||
{
|
||||
var address = profileItemPair.Value.Address;
|
||||
var address = item.Address;
|
||||
if (Utils.IsDomain(address))
|
||||
{
|
||||
context.ProtectDomainList.Add(address);
|
||||
}
|
||||
|
||||
if (profileItemPair.Value.EchConfigList.IsNullOrEmpty())
|
||||
if (item.EchConfigList.IsNullOrEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var echQuerySni = profileItemPair.Value.Sni;
|
||||
if (profileItemPair.Value.StreamSecurity == Global.StreamSecurity
|
||||
&& profileItemPair.Value.EchConfigList?.Contains("://") == true)
|
||||
var echQuerySni = item.Sni;
|
||||
if (item.StreamSecurity == Global.StreamSecurity
|
||||
&& item.EchConfigList?.Contains("://") == true)
|
||||
{
|
||||
var idx = profileItemPair.Value.EchConfigList.IndexOf('+');
|
||||
echQuerySni = idx > 0 ? profileItemPair.Value.EchConfigList[..idx] : profileItemPair.Value.Sni;
|
||||
var idx = item.EchConfigList.IndexOf('+');
|
||||
echQuerySni = idx > 0 ? item.EchConfigList[..idx] : item.Sni;
|
||||
}
|
||||
if (!Utils.IsDomain(echQuerySni))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -349,6 +349,7 @@ public partial class CoreConfigSingboxService
|
|||
{
|
||||
GenDnsServers();
|
||||
_coreConfig.dns ??= new();
|
||||
_coreConfig.dns.rules ??= [];
|
||||
_coreConfig.dns.rules.Clear();
|
||||
_coreConfig.dns.final = Global.SingboxDirectDNSTag;
|
||||
_coreConfig.route.default_domain_resolver = new()
|
||||
|
|
|
|||
|
|
@ -83,8 +83,8 @@ public partial class CoreConfigV2rayService(CoreConfigContext context)
|
|||
return ret;
|
||||
}
|
||||
|
||||
var v2rayConfig = JsonUtils.Deserialize<V2rayConfig>(result);
|
||||
if (v2rayConfig == null)
|
||||
_coreConfig = JsonUtils.Deserialize<V2rayConfig>(result);
|
||||
if (_coreConfig == null)
|
||||
{
|
||||
ret.Msg = ResUI.FailedGenDefaultConfiguration;
|
||||
return ret;
|
||||
|
|
@ -103,9 +103,9 @@ public partial class CoreConfigV2rayService(CoreConfigContext context)
|
|||
}
|
||||
|
||||
GenLog();
|
||||
v2rayConfig.inbounds.Clear();
|
||||
v2rayConfig.outbounds.Clear();
|
||||
v2rayConfig.routing.rules.Clear();
|
||||
_coreConfig.inbounds.Clear();
|
||||
_coreConfig.outbounds.Clear();
|
||||
_coreConfig.routing.rules.Clear();
|
||||
|
||||
var initPort = AppManager.Instance.GetLocalPort(EInboundProtocol.speedtest);
|
||||
|
||||
|
|
@ -159,13 +159,14 @@ public partial class CoreConfigV2rayService(CoreConfigContext context)
|
|||
protocol = EInboundProtocol.mixed.ToString(),
|
||||
};
|
||||
inbound.tag = inbound.protocol + inbound.port.ToString();
|
||||
v2rayConfig.inbounds.Add(inbound);
|
||||
_coreConfig.inbounds.Add(inbound);
|
||||
|
||||
var tag = Global.ProxyTag + inbound.port.ToString();
|
||||
var isBalancer = false;
|
||||
//outbound
|
||||
var proxyOutbounds = BuildAllProxyOutbounds(tag);
|
||||
v2rayConfig.outbounds.AddRange(proxyOutbounds);
|
||||
var proxyOutbounds =
|
||||
new CoreConfigV2rayService(context with { Node = item }).BuildAllProxyOutbounds(tag);
|
||||
_coreConfig.outbounds.AddRange(proxyOutbounds);
|
||||
if (proxyOutbounds.Count(n => n.tag.StartsWith(tag)) > 1)
|
||||
{
|
||||
isBalancer = true;
|
||||
|
|
@ -186,12 +187,12 @@ public partial class CoreConfigV2rayService(CoreConfigContext context)
|
|||
rule.balancerTag = tag;
|
||||
rule.outboundTag = null;
|
||||
}
|
||||
v2rayConfig.routing.rules.Add(rule);
|
||||
_coreConfig.routing.rules.Add(rule);
|
||||
}
|
||||
|
||||
//ret.Msg =string.Format(ResUI.SuccessfulConfiguration"), node.getSummary());
|
||||
ret.Success = true;
|
||||
ret.Data = JsonUtils.Serialize(v2rayConfig);
|
||||
ret.Data = JsonUtils.Serialize(_coreConfig);
|
||||
return ret;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
@ -228,8 +229,8 @@ public partial class CoreConfigV2rayService(CoreConfigContext context)
|
|||
return ret;
|
||||
}
|
||||
|
||||
var v2rayConfig = JsonUtils.Deserialize<V2rayConfig>(result);
|
||||
if (v2rayConfig == null)
|
||||
_coreConfig = JsonUtils.Deserialize<V2rayConfig>(result);
|
||||
if (_coreConfig == null)
|
||||
{
|
||||
ret.Msg = ResUI.FailedGenDefaultConfiguration;
|
||||
return ret;
|
||||
|
|
@ -238,9 +239,9 @@ public partial class CoreConfigV2rayService(CoreConfigContext context)
|
|||
GenLog();
|
||||
GenOutbounds();
|
||||
|
||||
v2rayConfig.routing.rules.Clear();
|
||||
v2rayConfig.inbounds.Clear();
|
||||
v2rayConfig.inbounds.Add(new()
|
||||
_coreConfig.routing.rules.Clear();
|
||||
_coreConfig.inbounds.Clear();
|
||||
_coreConfig.inbounds.Add(new()
|
||||
{
|
||||
tag = $"{EInboundProtocol.socks}{port}",
|
||||
listen = Global.Loopback,
|
||||
|
|
@ -250,7 +251,7 @@ public partial class CoreConfigV2rayService(CoreConfigContext context)
|
|||
|
||||
ret.Msg = string.Format(ResUI.SuccessfulConfiguration, "");
|
||||
ret.Success = true;
|
||||
ret.Data = JsonUtils.Serialize(v2rayConfig);
|
||||
ret.Data = JsonUtils.Serialize(_coreConfig);
|
||||
return ret;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
|
|||
Loading…
Reference in a new issue