fix #28: ipv6 target parse fix

pull/36/head
lyc8503 2024-05-19 16:35:06 +08:00
parent d09f31898d
commit 50fb6a429b
1 changed files with 3 additions and 2 deletions

View File

@ -16,8 +16,9 @@ export async function getStatus(
if (monitor.method === 'TCP_PING') {
// TCP port endpoint monitor
try {
const [hostname, port] = monitor.target.split(':')
const socket = connect({ hostname: hostname, port: Number(port) })
// This is not a real https connection, but we need to add a dummy `https://` to parse the hostname & port
const parsed = new URL("https://" + monitor.target)
const socket = connect({ hostname: parsed.hostname, port: Number(parsed.port) })
// Now we have an `opened` promise!
// @ts-ignore