Browse Source

Enhancements from writing blog post

master
Starbeamrainbowlabs 5 years ago
parent
commit
0e6967cd33
1 changed files with 8 additions and 3 deletions
  1. +8
    -3
      PixelHub-Server/PixelHub/NetTools.cs

+ 8
- 3
PixelHub-Server/PixelHub/NetTools.cs View File

@ -19,10 +19,8 @@ namespace SBRL.Utilities
foreach (NetworkInterface nic in nics)
{
Console.WriteLine("Id: {0}, Description: {1}", nic.Id, nic.Description);
IPInterfaceProperties ipProps = nic.GetIPProperties();
IPv4InterfaceProperties ip4Props = ipProps.GetIPv4Properties();
if (nic.Id == targetInterfaceName)
return ip4Props.Index;
return nic.GetIPv4Index();
}
throw new Exception($"Error: Can't find network interface with the name {targetInterfaceName}.");
}
@ -51,6 +49,13 @@ namespace SBRL.Utilities
}
}
}
public static int GetIPv4Index(this NetworkInterface nic)
{
IPInterfaceProperties ipProps = nic.GetIPProperties();
IPv4InterfaceProperties ip4Props = ipProps.GetIPv4Properties();
return ip4Props.Index;
}
}
}