[grade=C urn:ump:meylbfvzagdtgff4oapeyqkvjmletbb6q7iul5suvwcw5gq66wxa] fix(ux): invalid explicit DNS ports are REJECTED, not silently defaulted
Deploy judge r1 (dc-prod-deploy-dns2-full, grade C) blocked on the serialiser silently replacing an invalid explicit port (9090junk/0/-1/ 70000) with the provider default — pointing the adapter at the wrong service instead of reporting the user's typo. Now: empty field → provider default (legitimate); invalid EXPLICIT value → buildDnsConfig throws with an actionable message; the wizard surfaces it via showNotification and aborts the save. Tests flipped to pin the reject-not-fallback contract (throw + empty-field default preserved).
This commit is contained in:
5 files changed
+146
-129
No files matched your search
@@ -17,23 +17,26 @@
|
||||
|
||||
function normalizePort(rawPort) {
|
||||
var s = String(rawPort == null ? '' : rawPort).trim();
|
||||
if (!/^\d{1,5}$/.test(s)) return null; // full-string digits only (no "9090junk")
|
||||
if (s === '') return null; // empty → caller applies provider default
|
||||
if (!/^\d{1,5}$/.test(s)) return { error: true };
|
||||
var n = parseInt(s, 10);
|
||||
return n >= 1 && n <= 65535 ? n : null; // valid TCP/UDP range
|
||||
if (!(n >= 1 && n <= 65535)) return { error: true };
|
||||
return n;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the config.dns object from the wizard's DNS provider step.
|
||||
*
|
||||
* @param {string} selectedProvider - technitium|cloudflare|powerdns|rfc2136|manual
|
||||
* @param {string} ip - server IP from the form
|
||||
* @param {string} rawPort - raw port field (may be empty/whitespace)
|
||||
* @param {string} token - API key / TSIG-adjacent secret from the form
|
||||
* @param {number} defaultDnsPort - legacy generic default (Technitium API, 5380)
|
||||
* @returns {Object} config.dns — generic fields PLUS provider-specific aliases
|
||||
* Throws on an INVALID EXPLICIT port — a typo like "9090junk" must be
|
||||
* reported to the user, never silently swapped for a default (the default
|
||||
* would point the adapter at the wrong service).
|
||||
*/
|
||||
function buildDnsConfig(selectedProvider, ip, rawPort, token, defaultDnsPort) {
|
||||
var portRaw = normalizePort(rawPort);
|
||||
var resolved = normalizePort(rawPort);
|
||||
if (resolved && resolved.error) {
|
||||
throw new Error('Invalid port "' + String(rawPort).trim() + '" for the ' +
|
||||
selectedProvider + ' provider — enter a whole number between 1 and 65535.');
|
||||
}
|
||||
var portRaw = resolved; // null = field left empty
|
||||
var providerDefault = PROVIDER_PORT_DEFAULTS[selectedProvider] || null;
|
||||
// explicit input > provider default > legacy generic default
|
||||
var port = portRaw != null ? portRaw : (providerDefault || defaultDnsPort);
|
||||
|
||||
Reference in new issue
Block a user