fix cpanel
This commit is contained in:
@@ -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 }));
|
||||
|
||||
Reference in New Issue
Block a user