Browse Source

fix ping

pull/205/head
LouisLam 4 years ago
parent
commit
d5149f90b4
  1. 4
      server/ping-lite.js
  2. 2
      server/server.js
  3. 4
      server/util-server.js

4
server/ping-lite.js

@ -122,10 +122,6 @@ Ping.prototype.send = function (callback) {
ms = stdout.match(self._regmatch); // parse out the ##ms response
ms = (ms && ms[1]) ? Number(ms[1]) : ms;
if (! ms) {
debug(stdout)
}
callback(null, ms, stdout);
}
};

2
server/server.js

@ -581,7 +581,7 @@ let indexHTML = fs.readFileSync("./dist/index.html").toString();
if (hostname) {
console.log(`Listening on ${hostname}:${port}`);
} else {
console.log("Listening on ${port}");
console.log(`Listening on ${port}`);
}
startMonitors();
});

4
server/util-server.js

@ -47,11 +47,11 @@ exports.tcping = function (hostname, port) {
exports.ping = async (hostname) => {
try {
await exports.pingAsync(hostname);
return await exports.pingAsync(hostname);
} catch (e) {
// If the host cannot be resolved, try again with ipv6
if (e.message.includes("service not known")) {
await exports.pingAsync(hostname, true);
return await exports.pingAsync(hostname, true);
} else {
throw e;
}

Loading…
Cancel
Save