问题
I have a win app and I need to be able to help troubleshoot VPN issues that might be blocking my app. First I need to be able to tell if they have VPN or are connected to VPN.
I saw an older post on the same question (7months ago) with nothing definitive so I was curious if there were newer ideas or thoughts.
I suppose I can query the system folders for things like VPN or cisco but... it seems a little hack'ish.
Ideas or thoughts?
回答1:
Take a look at this link:
C# code to maintain VPN connection programatically
It uses ping to validate connections but also allows you to connect and disconnect.
回答2:
Here's an interesting thread
Failing that, I'd consider calling netsh through PowerShell.
回答3:
Look for the presence of another style of adapters besides Ethernet, list all of the network connections and their types, unless they have a 56.6k modem, if they have a PPP style adapter, it would strongly indicate a VPN tunnel.
回答4:
You should look at IPWarner, it's an API that contains millions of IP addresses in its database, which allows you to detect if the IP is good or not (Hosting/VPN/Proxy...)
来源:https://stackoverflow.com/questions/4940031/detect-vpn-via-c-sharp-or-api