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

View File

@ -86,7 +86,9 @@ async function webhookNotify(webhook: WebhookConfig, message: string) {
let url = webhook.url let url = webhook.url
let method = webhook.method let method = webhook.method
let headers = new Headers(webhook.headers as any) 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) templateWebhookPlayload(payloadTemplated, message)
let body = undefined let body = undefined