mirror of
https://github.com/2dust/v2rayN.git
synced 2026-11-04 03:25:00 +03:00
Verify if sendThrough is a local address.
https://github.com/2dust/v2rayN/issues/9562
This commit is contained in:
@@ -716,6 +716,18 @@ public class Utils
|
|||||||
return (endpoints, connections);
|
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
|
#endregion Speed Test
|
||||||
|
|
||||||
#region Miscellaneous
|
#region Miscellaneous
|
||||||
|
|||||||
@@ -83,6 +83,11 @@ public partial class CoreConfigSingboxService
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!Utils.IsLocalIP(sendThrough))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var outbound in _coreConfig.outbounds ?? [])
|
foreach (var outbound in _coreConfig.outbounds ?? [])
|
||||||
{
|
{
|
||||||
outbound.inet4_bind_address = ShouldBindNet(outbound) ? sendThrough : null;
|
outbound.inet4_bind_address = ShouldBindNet(outbound) ? sendThrough : null;
|
||||||
|
|||||||
@@ -176,6 +176,11 @@ public partial class CoreConfigV2rayService
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!Utils.IsLocalIP(sendThrough))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var outbound in _coreConfig.outbounds ?? [])
|
foreach (var outbound in _coreConfig.outbounds ?? [])
|
||||||
{
|
{
|
||||||
outbound.sendThrough = ShouldBindNet(outbound) ? sendThrough : null;
|
outbound.sendThrough = ShouldBindNet(outbound) ? sendThrough : null;
|
||||||
|
|||||||
Reference in New Issue
Block a user