fix(network): fix network availability detection #45
This commit is contained in:
parent
4b16e2d065
commit
87bbb4fbe4
@ -1,7 +1,7 @@
|
|||||||
// https://stackoverflow.com/questions/15270902/check-for-internet-connectivity-in-nodejs
|
// https://stackoverflow.com/questions/15270902/check-for-internet-connectivity-in-nodejs
|
||||||
module.exports = function checkInternet(cb) {
|
module.exports = function checkInternet(cb) {
|
||||||
require('dns').lookup('google.com',function(err) {
|
require('dns').lookup('google.com',function(err) {
|
||||||
if (err && err.code == "ENOTFOUND") {
|
if (err && (err.code == "ENOTFOUND" || err.code == "EAI_AGAIN")) {
|
||||||
cb(false);
|
cb(false);
|
||||||
} else {
|
} else {
|
||||||
cb(true);
|
cb(true);
|
||||||
|
Loading…
Reference in New Issue
Block a user