如何检测Windows中的防火墙?

发布于 2024-07-14 13:45:24 字数 95 浏览 12 评论 0原文

我的应用程序需要向网站发出 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

赤濁 2024-07-21 13:45:24

如果它是一个好的防火墙,则不能。 除其他选项外,防火墙还可以:

  • 使用多个不同的 ICMP 消息之一进行回复,指示目的地是无法访问,或者
  • 默默地丢弃请求,导致超时。

一个合理的选择是解释应用程序无法访问网站的原因,并提供一些有用的建议:

    No response from www.site.com:
    * Your computer may not be connected to the Internet.
    * The site may be down.
    * The site may be blocked by a firewall.
    The network indicated that www.site.com is not accessible:
    * Helpful messages go here.

重要的一点是区分故障的类型,并且可能比我上面所做的更好。他们背后的原因。 例如,“无响应”故障排除步骤与“设备告诉我它没有在该端口上侦听”故障排除步骤不同。

If it's a good firewall, you can't. Among other options, a firewall can:

  • reply with one of several different ICMP messages, indicating the destination is not accessible, or
  • silently discard the request, resulting in a timeout.

A reasonable option is to explain why the app was unable to access the website, and provide some helpful suggestions:

    No response from www.site.com:
    * Your computer may not be connected to the Internet.
    * The site may be down.
    * The site may be blocked by a firewall.
    The network indicated that www.site.com is not accessible:
    * Helpful messages go here.

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."

浅忆流年 2024-07-21 13:45:24

尝试以较短的超时时间访问互联网...
如果该命令失败,您可以假设该计算机具有需要用户交互的防火墙。

如果防火墙是好的,你就检测不到它。

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.

饮惑 2024-07-21 13:45:24

使用 Win32 防火墙 api(经典)

Use Win32 Firewall apis (classic)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文