如何检测JavaScript中的DNS查找错误 [英] How to detect DNS lookup error in JavaScript

查看:114
本文介绍了如何检测JavaScript中的DNS查找错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道有没有办法检测JavaScript中的DNS查找错误。

I was wondering is there a way to detect DNS lookup error in JavaScript.

是否有一些代码或一些技巧?

is there some code or some trick work ?

或者这是一个不可能的任务?

or this is a mission impossible?

有人可以清楚吗?非常感谢!

can somebody shed light on this? thanks a lot!

推荐答案

无法准确预测当随机的DNS查找失败时会发生什么行为最终用户的机器。

It's not possible to accurately predict what behavior will occurr when there's a 'DNS Lookup failure' on a random end-user's machine.

例如,当对不存在的域(NXDOMAIN)执行查找时,许多ISP返回自己的帮助搜索页面/站点。这也被称为 DNS劫持

For example, many ISPs return their own 'helper' search pages/sites when a lookup is performed on a non-existant domain (NXDOMAIN). This is also known as DNS Hijacking.

用户还可以在本地的主机文件上配置自己的域条目,这将给出假阳性。

A user may also configure their own domain entries on a local 'hostfile', which would give a 'false positive'.

为了更可靠的方法,您应该在您的服务器上执行此查找,这将提供一个更好的指标,以确定该域是否可以访问更广泛的世界。它也将让您区分网站只是从用户的机器而不是无法访问,而不是无效的条目。

For a more reliable method, you should perform this lookup on your server, which should give a better indicator as to whether the domain is reachable to the wider world. It will also let you differentiate between the site is merely being down or unreachable from the user's machine, instead of an invalid entry.

这篇关于如何检测JavaScript中的DNS查找错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆