Skip to content

Instantly share code, notes, and snippets.

@jnnsrctr
Created February 16, 2023 16:12
Show Gist options
  • Save jnnsrctr/30ade5a62293d5c558470230ef3cf8e7 to your computer and use it in GitHub Desktop.
Save jnnsrctr/30ade5a62293d5c558470230ef3cf8e7 to your computer and use it in GitHub Desktop.
Method that checks if a VPN is connected
private static bool VpnCheck()
{
if (NetworkInterface.GetIsNetworkAvailable())
{
NetworkInterface[] interfaces = NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface Interface in interfaces)
{
if (Interface.Description.Contains("Juniper Networks Virtual Adapter")
&& Interface.OperationalStatus == OperationalStatus.Up)
{
return true;
}
}
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment