fix: Round ping to the nearest int
All checks were successful
Build Docker / Build_Docker (push) Successful in 1m11s
All checks were successful
Build Docker / Build_Docker (push) Successful in 1m11s
This commit is contained in:
parent
32506c6fee
commit
25d9f1314e
@ -235,7 +235,6 @@
|
|||||||
resolve({ id, pingTime: null, error: "Error: Invalid server ID" });
|
resolve({ id, pingTime: null, error: "Error: Invalid server ID" });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log("Pinging server for " + id);
|
|
||||||
|
|
||||||
const startTime = performance.now(); // Record the start time
|
const startTime = performance.now(); // Record the start time
|
||||||
const serverUrl = `https://${id}.hnsdoh.com/dns-query?dns=CagBAAABAAAAAAAACHdvb2RidXJuAAABAAE=`;
|
const serverUrl = `https://${id}.hnsdoh.com/dns-query?dns=CagBAAABAAAAAAAACHdvb2RidXJuAAABAAE=`;
|
||||||
@ -250,9 +249,11 @@
|
|||||||
.then(response => {
|
.then(response => {
|
||||||
const endTime = performance.now(); // Record the end time
|
const endTime = performance.now(); // Record the end time
|
||||||
const pingTime = endTime - startTime; // Calculate ping time
|
const pingTime = endTime - startTime; // Calculate ping time
|
||||||
|
// Round the ping time to the nearest integer
|
||||||
|
const pingTimeRounded = Math.round(pingTime);
|
||||||
|
|
||||||
// Resolve with the ID and ping time
|
// Resolve with the ID and ping time
|
||||||
resolve({ id, pingTime, error: null });
|
resolve({ id, pingTime:pingTimeRounded, error: null });
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
// Resolve with an error message instead of rejecting
|
// Resolve with an error message instead of rejecting
|
||||||
|
Loading…
Reference in New Issue
Block a user