mirror of
https://github.com/2dust/v2rayN.git
synced 2026-02-28 21:23:04 +00:00
Compare commits
No commits in common. "c76c302e443478e619f022e26284014af3b8fe10" and "0c3e42efa6fc0b9b60c423bf0a7973aa37f7f87e" have entirely different histories.
c76c302e44
...
0c3e42efa6
3 changed files with 31 additions and 48 deletions
|
|
@ -1249,47 +1249,6 @@ public static class ConfigHandler
|
|||
return itemSocks;
|
||||
}
|
||||
|
||||
public static CoreConfigContext? GetPreSocksCoreConfigContext(CoreConfigContext nodeContext)
|
||||
{
|
||||
var config = nodeContext.AppConfig;
|
||||
var node = nodeContext.Node;
|
||||
var coreType = AppManager.Instance.GetCoreType(node, node.ConfigType);
|
||||
|
||||
var preSocksItem = GetPreSocksItem(config, node, coreType);
|
||||
if (preSocksItem != null)
|
||||
{
|
||||
return nodeContext with { Node = preSocksItem, };
|
||||
}
|
||||
|
||||
if ((!nodeContext.IsTunEnabled)
|
||||
|| coreType != ECoreType.Xray
|
||||
|| node.ConfigType == EConfigType.Custom)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var tunProtectSsPort = Utils.GetFreePort();
|
||||
var proxyRelaySsPort = Utils.GetFreePort();
|
||||
var preItem = new ProfileItem()
|
||||
{
|
||||
CoreType = ECoreType.sing_box,
|
||||
ConfigType = EConfigType.Shadowsocks,
|
||||
Address = Global.Loopback,
|
||||
Port = proxyRelaySsPort,
|
||||
Password = Global.None,
|
||||
};
|
||||
preItem.SetProtocolExtra(preItem.GetProtocolExtra() with
|
||||
{
|
||||
SsMethod = Global.None,
|
||||
});
|
||||
var preContext = nodeContext with
|
||||
{
|
||||
Node = preItem,
|
||||
TunProtectSsPort = tunProtectSsPort,
|
||||
ProxyRelaySsPort = proxyRelaySsPort,
|
||||
};
|
||||
return preContext;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove servers with invalid test results (timeout)
|
||||
/// Useful for cleaning up subscription lists
|
||||
|
|
|
|||
|
|
@ -67,13 +67,37 @@ public class CoreManager
|
|||
|
||||
var fileName = Utils.GetBinConfigPath(Global.CoreConfigFileName);
|
||||
var context = await CoreConfigHandler.BuildCoreConfigContext(_config, node);
|
||||
var preContext = ConfigHandler.GetPreSocksCoreConfigContext(context);
|
||||
if (preContext is not null)
|
||||
CoreConfigContext? preContext = null;
|
||||
if (context.IsTunEnabled)
|
||||
{
|
||||
context = context with
|
||||
var coreType = AppManager.Instance.GetCoreType(node, node.ConfigType);
|
||||
if (coreType == ECoreType.Xray && node.ConfigType != EConfigType.Custom)
|
||||
{
|
||||
TunProtectSsPort = preContext.TunProtectSsPort, ProxyRelaySsPort = preContext.ProxyRelaySsPort,
|
||||
};
|
||||
var tunProtectSsPort = Utils.GetFreePort();
|
||||
var proxyRelaySsPort = Utils.GetFreePort();
|
||||
context = context with { TunProtectSsPort = tunProtectSsPort, ProxyRelaySsPort = proxyRelaySsPort, };
|
||||
var preItem = new ProfileItem()
|
||||
{
|
||||
CoreType = ECoreType.sing_box,
|
||||
ConfigType = EConfigType.Shadowsocks,
|
||||
Address = Global.Loopback,
|
||||
Port = proxyRelaySsPort,
|
||||
Password = Global.None,
|
||||
};
|
||||
preItem.SetProtocolExtra(preItem.GetProtocolExtra() with
|
||||
{
|
||||
SsMethod = Global.None,
|
||||
});
|
||||
preContext = context with { Node = preItem, };
|
||||
}
|
||||
else
|
||||
{
|
||||
var preItem = ConfigHandler.GetPreSocksItem(_config, node, coreType);
|
||||
if (preItem is not null)
|
||||
{
|
||||
preContext = context with { Node = preItem, };
|
||||
}
|
||||
}
|
||||
}
|
||||
var result = await CoreConfigHandler.GenerateClientConfig(context, fileName);
|
||||
if (result.Success != true)
|
||||
|
|
|
|||
|
|
@ -304,7 +304,7 @@ public partial class CoreConfigV2rayService(CoreConfigContext context)
|
|||
|
||||
var protectNode = new ProfileItem()
|
||||
{
|
||||
CoreType = ECoreType.Xray,
|
||||
CoreType = ECoreType.sing_box,
|
||||
ConfigType = EConfigType.Shadowsocks,
|
||||
Address = Global.Loopback,
|
||||
Port = context.TunProtectSsPort,
|
||||
|
|
@ -333,7 +333,7 @@ public partial class CoreConfigV2rayService(CoreConfigContext context)
|
|||
{
|
||||
inboundTag = new List<string> { "proxy-relay-ss" },
|
||||
outboundTag = hasBalancer ? null : Global.ProxyTag,
|
||||
balancerTag = hasBalancer ? Global.ProxyTag + Global.BalancerTagSuffix: null,
|
||||
balancerTag = hasBalancer ? Global.ProxyTag : null,
|
||||
type = "field"
|
||||
}
|
||||
];
|
||||
|
|
|
|||
Loading…
Reference in a new issue