fix no magic

pull/147/head
lyc8503 2025-10-29 21:23:36 +08:00
parent f17ef9bad2
commit cf2b81cb2e
2 changed files with 22 additions and 14 deletions

View File

@ -69,15 +69,18 @@ export async function getStatusWithGlobalPing(
globalPingRequest = {
type: 'ping',
target: targetUrl.hostname,
locations: [
{
magic: gpUrl.searchParams.get('magic') || '',
},
],
locations:
gpUrl.searchParams.get('magic') !== null
? [
{
magic: gpUrl.searchParams.get('magic'),
},
]
: undefined,
measurementOptions: {
port: targetUrl.port,
packets: 1,
protocol: 'tcp',
protocol: 'tcp', // TODO: icmp?
ipVersion: Number(gpUrl.searchParams.get('ipVersion') || 4),
},
}
@ -92,11 +95,14 @@ export async function getStatusWithGlobalPing(
globalPingRequest = {
type: 'http',
target: targetUrl.hostname,
locations: [
{
magic: gpUrl.searchParams.get('magic') || '',
},
],
locations:
gpUrl.searchParams.get('magic') !== null
? [
{
magic: gpUrl.searchParams.get('magic'),
},
]
: undefined,
measurementOptions: {
request: {
method: monitor.method,
@ -104,7 +110,7 @@ export async function getStatusWithGlobalPing(
query: targetUrl.search === '' ? undefined : targetUrl.search,
headers: Object.fromEntries(
Object.entries(monitor.headers ?? {}).map(([key, value]) => [key, String(value)])
), // TODO: headers
), // TODO: host header?
},
port:
targetUrl.port === ''

View File

@ -86,7 +86,9 @@ async function webhookNotify(webhook: WebhookConfig, message: string) {
let url = webhook.url
let method = webhook.method
let headers = new Headers(webhook.headers as any)
let payloadTemplated: { [key: string]: string | number } = JSON.parse(JSON.stringify(webhook.payload))
let payloadTemplated: { [key: string]: string | number } = JSON.parse(
JSON.stringify(webhook.payload)
)
templateWebhookPlayload(payloadTemplated, message)
let body = undefined