Beispiel #1
0
        private void RebuildInterfaceList()
        {
            LocalInterfaces.Clear();
            // build interface list
            LocalInterfaces.Add(new InterfaceAddress(InterfaceAddress.EInterfaceType.Default, null));
            LocalInterfaces.Add(new InterfaceAddress(InterfaceAddress.EInterfaceType.All, null));
            foreach (var nic in NetworkUtils.GetActiveInterfaces())
            {
                foreach (var ip in nic.IPv4.Addresses)
                {
                    LocalInterfaces.Add(new InterfaceAddress(
                                            InterfaceAddress.EInterfaceType.Specific, nic, ip));
                }

                if (Properties.Settings.Default.IPv6Support)
                {
                    foreach (var ip in nic.IPv6.Addresses)
                    {
                        LocalInterfaces.Add(new InterfaceAddress(
                                                InterfaceAddress.EInterfaceType.Specific, nic, ip));
                    }
                }
            }

            SelectedListenInterface = LocalInterfaces.FirstOrDefault();
        }
Beispiel #2
0
 public static void findLocalIP()
 {
     NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
     foreach (NetworkInterface adapter in nics)
     {
         foreach (var x in adapter.GetIPProperties().UnicastAddresses)
         {
             if (x.Address.AddressFamily == AddressFamily.InterNetwork && x.IsDnsEligible)
             {
                 LocalInterfaces.Add(x.Address.ToString(), x.IPv4Mask.ToString(), adapter.Name);
             }
         }
     }
 }