mirror of
https://github.com/2dust/v2rayN.git
synced 2026-10-21 20:55:01 +03:00
Tun protect (#8779)
* Tun protect * Remove EnableExInbound * Fix * Fix balancer tag * Fix --------- Co-authored-by: 2dust <31833384+2dust@users.noreply.github.com>
This commit is contained in:
@@ -67,7 +67,14 @@ public class CoreManager
|
||||
|
||||
var fileName = Utils.GetBinConfigPath(Global.CoreConfigFileName);
|
||||
var context = await CoreConfigHandler.BuildCoreConfigContext(_config, node);
|
||||
context = context with { IsTunEnabled = _config.TunModeItem.EnableTun };
|
||||
var preContext = ConfigHandler.GetPreSocksCoreConfigContext(context);
|
||||
if (preContext is not null)
|
||||
{
|
||||
context = context with
|
||||
{
|
||||
TunProtectSsPort = preContext.TunProtectSsPort, ProxyRelaySsPort = preContext.ProxyRelaySsPort,
|
||||
};
|
||||
}
|
||||
var result = await CoreConfigHandler.GenerateClientConfig(context, fileName);
|
||||
if (result.Success != true)
|
||||
{
|
||||
@@ -88,7 +95,7 @@ public class CoreManager
|
||||
}
|
||||
|
||||
await CoreStart(context);
|
||||
await CoreStartPreService(context);
|
||||
await CoreStartPreService(preContext);
|
||||
if (_processService != null)
|
||||
{
|
||||
await UpdateFunc(true, $"{node.GetSummary()}");
|
||||
@@ -183,30 +190,22 @@ public class CoreManager
|
||||
_processService = proc;
|
||||
}
|
||||
|
||||
private async Task CoreStartPreService(CoreConfigContext context)
|
||||
private async Task CoreStartPreService(CoreConfigContext? preContext)
|
||||
{
|
||||
var node = context.Node;
|
||||
if (_processService != null && !_processService.HasExited)
|
||||
if (_processService is { HasExited: false } && preContext != null)
|
||||
{
|
||||
var coreType = AppManager.Instance.GetCoreType(node, node.ConfigType);
|
||||
var itemSocks = ConfigHandler.GetPreSocksItem(_config, node, coreType);
|
||||
if (itemSocks != null)
|
||||
var preCoreType = preContext?.Node?.CoreType ?? ECoreType.sing_box;
|
||||
var fileName = Utils.GetBinConfigPath(Global.CorePreConfigFileName);
|
||||
var result = await CoreConfigHandler.GenerateClientConfig(preContext, fileName);
|
||||
if (result.Success)
|
||||
{
|
||||
var preCoreType = itemSocks.CoreType ?? ECoreType.sing_box;
|
||||
var fileName = Utils.GetBinConfigPath(Global.CorePreConfigFileName);
|
||||
var itemSocksContext = await CoreConfigHandler.BuildCoreConfigContext(_config, itemSocks);
|
||||
itemSocksContext.ProtectDomainList.AddRangeSafe(context.ProtectDomainList);
|
||||
var result = await CoreConfigHandler.GenerateClientConfig(itemSocksContext, fileName);
|
||||
if (result.Success)
|
||||
var coreInfo = CoreInfoManager.Instance.GetCoreInfo(preCoreType);
|
||||
var proc = await RunProcess(coreInfo, Global.CorePreConfigFileName, true, true);
|
||||
if (proc is null)
|
||||
{
|
||||
var coreInfo = CoreInfoManager.Instance.GetCoreInfo(preCoreType);
|
||||
var proc = await RunProcess(coreInfo, Global.CorePreConfigFileName, true, true);
|
||||
if (proc is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_processPreService = proc;
|
||||
return;
|
||||
}
|
||||
_processPreService = proc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user