Verify if sendThrough is a local address.

https://github.com/2dust/v2rayN/issues/9562
This commit is contained in:
2dust
2026-06-19 18:09:18 +08:00
parent 616eea39f9
commit 00903d3531
3 changed files with 22 additions and 0 deletions

View File

@@ -716,6 +716,18 @@ public class Utils
return (endpoints, connections);
}
public static bool IsLocalIP(string ipAddress)
{
if (!IPAddress.TryParse(ipAddress, out var targetAddress))
{
return false;
}
return NetworkInterface.GetAllNetworkInterfaces()
.SelectMany(ni => ni.GetIPProperties().UnicastAddresses)
.Any(ua => ua.Address.Equals(targetAddress));
}
#endregion Speed Test
#region Miscellaneous

View File

@@ -83,6 +83,11 @@ public partial class CoreConfigSingboxService
{
return;
}
if (!Utils.IsLocalIP(sendThrough))
{
return;
}
foreach (var outbound in _coreConfig.outbounds ?? [])
{
outbound.inet4_bind_address = ShouldBindNet(outbound) ? sendThrough : null;

View File

@@ -176,6 +176,11 @@ public partial class CoreConfigV2rayService
{
return;
}
if (!Utils.IsLocalIP(sendThrough))
{
return;
}
foreach (var outbound in _coreConfig.outbounds ?? [])
{
outbound.sendThrough = ShouldBindNet(outbound) ? sendThrough : null;