Merge branch 'new-ping' into staging
Some checks failed
Docker Build and Push / build-and-push (push) Failing after 1m21s
Some checks failed
Docker Build and Push / build-and-push (push) Failing after 1m21s
This commit is contained in:
@@ -58,20 +58,6 @@ const fetchServers = async (): Promise<Server[]> => {
|
||||
tcp: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "eu",
|
||||
name: "Europe",
|
||||
location: "Frankfurt",
|
||||
subdomain: "eu.tunnl.live",
|
||||
coordinates: [8.6821, 50.1109],
|
||||
ping: null,
|
||||
status: "online",
|
||||
pingStatus: "idle",
|
||||
capabilities: {
|
||||
http: true,
|
||||
tcp: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "sgp",
|
||||
name: "Singapore",
|
||||
@@ -93,25 +79,7 @@ const fetchServers = async (): Promise<Server[]> => {
|
||||
blockedPorts: [8080, 8443, 9000],
|
||||
supportsAutoAssign: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "id",
|
||||
name: "Indonesia",
|
||||
location: "Bogor",
|
||||
subdomain: "id.tunnl.live",
|
||||
coordinates: [106.8456, -6.595],
|
||||
ping: null,
|
||||
status: "online",
|
||||
pingStatus: "idle",
|
||||
capabilities: {
|
||||
http: true,
|
||||
tcp: true,
|
||||
},
|
||||
portRestrictions: {
|
||||
blockedPorts: [22, 80, 443, 3306, 5432, 6379],
|
||||
supportsAutoAssign: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
]
|
||||
|
||||
return mockServers.filter((server) => server.status === "online")
|
||||
@@ -125,15 +93,11 @@ const testServerPing = (
|
||||
const timeout = 5000
|
||||
let resolved = false
|
||||
|
||||
const pingUrl = `wss://ping.${server.subdomain}`
|
||||
|
||||
try {
|
||||
const ws = new WebSocket(pingUrl)
|
||||
const pingUrl = `https://ping.${server.subdomain}`
|
||||
|
||||
const timeoutId = setTimeout(() => {
|
||||
if (!resolved) {
|
||||
resolved = true
|
||||
ws.close()
|
||||
resolve({
|
||||
server,
|
||||
ping: null,
|
||||
@@ -142,59 +106,45 @@ const testServerPing = (
|
||||
}
|
||||
}, timeout)
|
||||
|
||||
ws.onopen = () => {
|
||||
console.log(`Connected to ${pingUrl}`)
|
||||
fetch(pingUrl, {
|
||||
method: "HEAD",
|
||||
cache: "no-cache",
|
||||
})
|
||||
.then((res) => {
|
||||
if (resolved) return
|
||||
|
||||
resolved = true
|
||||
clearTimeout(timeoutId)
|
||||
|
||||
if (!res.ok) {
|
||||
resolve({
|
||||
server,
|
||||
ping: null,
|
||||
status: "failed",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
ws.onmessage = (event) => {
|
||||
if (event.data === "pong" && !resolved) {
|
||||
resolved = true
|
||||
const ping = Date.now() - startTime
|
||||
clearTimeout(timeoutId)
|
||||
ws.close()
|
||||
|
||||
resolve({
|
||||
server,
|
||||
ping,
|
||||
status: "success",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
ws.onclose = (event) => {
|
||||
if (!resolved) {
|
||||
})
|
||||
.catch((err) => {
|
||||
if (resolved) return
|
||||
resolved = true
|
||||
clearTimeout(timeoutId)
|
||||
|
||||
console.error(`HEAD ping error for ${pingUrl}:`, err)
|
||||
resolve({
|
||||
server,
|
||||
ping: null,
|
||||
status: "failed",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
ws.onerror = (error) => {
|
||||
if (!resolved) {
|
||||
resolved = true
|
||||
clearTimeout(timeoutId)
|
||||
console.error(`WebSocket error for ${pingUrl}:`, error)
|
||||
|
||||
resolve({
|
||||
server,
|
||||
ping: null,
|
||||
status: "failed",
|
||||
})
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Failed to create WebSocket for ${pingUrl}:`, error)
|
||||
resolve({
|
||||
server,
|
||||
ping: null,
|
||||
status: "failed",
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
2639
package-lock.json
generated
2639
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user