Enable extra inbound for tun mode

pull/3943/head
2dust 2023-06-04 17:11:37 +08:00
parent b176ad03aa
commit 2fd21690a5
2 changed files with 29 additions and 20 deletions

View File

@ -106,30 +106,19 @@ namespace v2rayN.Handler
private int inbound(SingboxConfig singboxConfig)
{
try
{
if (_config.tunModeItem.enableTun)
{
singboxConfig.inbounds.Clear();
if (_config.tunModeItem.mtu <= 0)
if (!_config.tunModeItem.enableTun || (_config.tunModeItem.enableTun && _config.tunModeItem.enableExInbound))
{
_config.tunModeItem.mtu = Convert.ToInt32(Global.TunMtus[0]);
}
if (Utils.IsNullOrEmpty(_config.tunModeItem.stack))
var inbound = new Inbound4Sbox()
{
_config.tunModeItem.stack = Global.TunStacks[0];
}
type = Global.InboundSocks,
tag = Global.InboundSocks,
listen = Global.Loopback,
};
singboxConfig.inbounds.Add(inbound);
var tunInbound = Utils.FromJson<Inbound4Sbox>(Utils.GetEmbedText(Global.TunSingboxInboundFileName));
tunInbound.mtu = _config.tunModeItem.mtu;
tunInbound.strict_route = _config.tunModeItem.strictRoute;
tunInbound.stack = _config.tunModeItem.stack;
singboxConfig.inbounds.Add(tunInbound);
}
else
{
var inbound = singboxConfig.inbounds[0];
inbound.listen_port = LazyConfig.Instance.GetLocalPort(Global.InboundSocks);
inbound.sniff = _config.inbound[0].sniffingEnabled;
inbound.sniff_override_destination = _config.inbound[0].routeOnly ? false : _config.inbound[0].sniffingEnabled;
@ -174,6 +163,25 @@ namespace v2rayN.Handler
}
}
}
if (_config.tunModeItem.enableTun)
{
if (_config.tunModeItem.mtu <= 0)
{
_config.tunModeItem.mtu = Convert.ToInt32(Global.TunMtus[0]);
}
if (Utils.IsNullOrEmpty(_config.tunModeItem.stack))
{
_config.tunModeItem.stack = Global.TunStacks[0];
}
var tunInbound = Utils.FromJson<Inbound4Sbox>(Utils.GetEmbedText(Global.TunSingboxInboundFileName));
tunInbound.mtu = _config.tunModeItem.mtu;
tunInbound.strict_route = _config.tunModeItem.strictRoute;
tunInbound.stack = _config.tunModeItem.stack;
singboxConfig.inbounds.Add(tunInbound);
}
}
catch (Exception ex)
{

View File

@ -163,6 +163,7 @@ namespace v2rayN.Mode
public bool strictRoute { get; set; }
public string stack { get; set; }
public int mtu { get; set; }
public bool enableExInbound { get; set; }
}
[Serializable]