You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// This helper function Checks whether the remote IP Adress is actually a local address internalstaticboolIsLocalIpAddress(IPAddressremoteAddress){if(s_MachineIpAddress==null){StringhostName=GetMachineName();// NOTE: We intentionally allow exceptions from these api's// propagate out to the caller.IPHostEntryipEntries=Dns.GetHostEntry(hostName);// If there is only one entry we should cache itif(ipEntries!=null&&ipEntries.AddressList.Length==1){if(Socket.OSSupportsIPv4){s_MachineIpAddress=GetMachineAddress(ipEntries,AddressFamily.InterNetwork);}else{s_MachineIpAddress=GetMachineAddress(ipEntries,AddressFamily.InterNetworkV6);}}else{returnIsLocalIpAddress(ipEntries,remoteAddress.AddressFamily,remoteAddress);}}returns_MachineIpAddress.Equals(remoteAddress);}//This helper function compares and IpAddress with all addresses in IpHostEntry internalstaticboolIsLocalIpAddress(IPHostEntryhost,AddressFamilyaddressFamily,IPAddressremoteAddress){if(host!=null){IPAddress[]addressList=host.AddressList;for(inti=0;i<addressList.Length;i++){if(addressList[i].AddressFamily==addressFamily){if(addressList[i].Equals(remoteAddress))returntrue;}}}returnfalse;}
IsLocal 判断不完善导致循环
使用machinename和ip时
The text was updated successfully, but these errors were encountered: