refactor: Enhance health check target queries to use FQDN for hostname resolution and improve group health check logic in the database layer
Build, Test, and Push CFDM Docker Image / test (push) Successful in 3m40s
Build, Test, and Push CFDM Docker Image / build-and-push (push) Successful in 1m57s
Build, Test, and Push CFDM Docker Image / update-wiki (push) Successful in 6s
Build, Test, and Push CFDM Docker Image / create-release (push) Has been skipped

This commit is contained in:
Denozordec
2026-06-26 00:46:39 +07:00
parent 6038feda66
commit 09b32a5d62
3 changed files with 40 additions and 14 deletions
+18 -6
View File
@@ -1847,6 +1847,7 @@ async function createGroup2(db, cf, body) {
async function updateGroup2(db, cf, id, body) {
const groupType = body.type?.trim() || "custom";
const previous = repos6.getServiceGroup(db, id);
const name = body.name ?? previous.name;
const oldDomain = previous.domain?.trim();
if (oldDomain) {
await cleanupStaleGroupFqdnBindings(db, cf, id, oldDomain);
@@ -1856,7 +1857,7 @@ async function updateGroup2(db, cf, id, body) {
let group = repos6.updateServiceGroup(
db,
id,
body.name,
name,
groupType,
body.icon ?? null,
domain,
@@ -2562,6 +2563,7 @@ import { healthStatusQuerySchema } from "@cfdm/shared";
// src/services/health-check-service.ts
import { connect as connect2 } from "net";
import { Agent, fetch as undiciFetch } from "undici";
import { repos as repos10 } from "@cfdm/db";
function tcpProbe(ip, port, timeoutMs) {
return new Promise((resolve4) => {
@@ -2603,14 +2605,24 @@ function tcpProbe(ip, port, timeoutMs) {
async function httpProbe(ip, target, timeoutMs) {
const started = Date.now();
const path = target.path?.trim() || "/";
const url = `http://${ip}${path.startsWith("/") ? path : `/${path}`}`;
const hostHeader = target.hostname || ip;
const pathWithSlash = path.startsWith("/") ? path : `/${path}`;
const port = target.port ?? 80;
const useTls = port === 443;
const urlHost = useTls ? target.hostname || ip : ip;
const url = `${useTls ? "https" : "http"}://${urlHost}${pathWithSlash}`;
const dispatcher = useTls && target.hostname ? new Agent({
connect: {
servername: target.hostname,
rejectUnauthorized: false
}
}) : void 0;
try {
const response = await fetch(url, {
const response = await undiciFetch(url, {
method: "GET",
headers: { Host: hostHeader },
headers: { Host: target.hostname || ip },
signal: AbortSignal.timeout(timeoutMs),
redirect: "manual"
redirect: "manual",
dispatcher
});
const latency = Date.now() - started;
if (target.expected_status != null) {