mirror of https://github.com/quasar/Quasar.git
Fixed lan ip determination for virtual physical nics
This commit is contained in:
parent
d291490181
commit
507e1dd74d
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Management;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Net.Sockets;
|
||||
|
@ -142,6 +143,9 @@ namespace xClient.Core.Helper
|
|||
public static string GetLanIp()
|
||||
{
|
||||
foreach (NetworkInterface ni in NetworkInterface.GetAllNetworkInterfaces())
|
||||
{
|
||||
GatewayIPAddressInformation gatewayAddress = ni.GetIPProperties().GatewayAddresses.FirstOrDefault();
|
||||
if (gatewayAddress != null) //exclude virtual physical nic with no default gateway
|
||||
{
|
||||
if (ni.NetworkInterfaceType == NetworkInterfaceType.Wireless80211 ||
|
||||
ni.NetworkInterfaceType == NetworkInterfaceType.Ethernet &&
|
||||
|
@ -157,6 +161,7 @@ namespace xClient.Core.Helper
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return "-";
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue