fix cpanel

This commit is contained in:
2026-07-09 00:21:36 +02:00
parent 371dfaf76a
commit 5304fa4e18
2 changed files with 440 additions and 3 deletions
+8 -3
View File
@@ -73,9 +73,13 @@ async function parseResponse(res, debug = false) {
);
}
const envelope = JSON.parse(text);
if (debug) console.log('[cpanel] full envelope:', JSON.stringify(envelope, null, 2));
if (res.status >= 400) throw new Error(`cPanel HTTP ${res.status}`);
// Imunify360 / WAF blocks return a flat { message: "..." } with HTTP 200
if (envelope.message && !envelope.result) {
throw new Error(`cPanel blocked: ${envelope.message}`);
}
// UAPI wraps the payload in result{} but some installs omit it
const result = envelope.result ?? envelope;
const statusVal = result.status ?? result.result;
@@ -166,7 +170,6 @@ async function listZones() {
const main = info.main_domain ? [info.main_domain] : [];
const addon = Array.isArray(info.addon_domains) ? info.addon_domains : [];
const parked = Array.isArray(info.parked_domains) ? info.parked_domains : [];
// sub_domains are sub.domain.tld — only include the apex, not subs
domains = [...new Set([...main, ...addon, ...parked])].filter(Boolean);
}
} catch (err) {
@@ -183,7 +186,9 @@ async function listZones() {
return raw.replace(/\.$/, '');
}).filter(Boolean);
}
} catch { /* ignore */ }
} catch (err) {
console.log('[cpanel] Zone::listzone unavailable:', err.message);
}
}
return domains.map(d => ({ id: d, name: d }));