如何检测Windows中的防火墙?
我的应用程序需要向网站发出 GET 请求,我希望能够知道它是否被防火墙阻止,并要求用户添加例外。
我怎样才能发现我的获取请求失败是因为防火墙而不是其他原因?
My app needs to make a GET request to a website and I'd like to be able to know if it's being blocked by a firewall, and ask the user to add an exception.
How can I find out that my get request failed because of a firewall, instead of something else?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果它是一个好的防火墙,则不能。 除其他选项外,防火墙还可以:
一个合理的选择是解释应用程序无法访问网站的原因,并提供一些有用的建议:
重要的一点是区分故障的类型,并且可能比我上面所做的更好。他们背后的原因。 例如,“无响应”故障排除步骤与“设备告诉我它没有在该端口上侦听”故障排除步骤不同。
If it's a good firewall, you can't. Among other options, a firewall can:
A reasonable option is to explain why the app was unable to access the website, and provide some helpful suggestions:
The important point is to differentiate, perhaps better than I did above, between the types of failure, and the reasons behind them. For example, the steps for troubleshooting "no response" will be different from those for troubleshooting "the device told me it's not listening on that port."
尝试以较短的超时时间访问互联网...
如果该命令失败,您可以假设该计算机具有需要用户交互的防火墙。
如果防火墙是好的,你就检测不到它。
Try to access the internet with a short timeout...
If the command fails, you can suppose that the machine has a firewall which requires user interaction.
If the firewall is good, you can't detect it.
使用 Win32 防火墙 api(经典)
Use Win32 Firewall apis (classic)