mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-08 14:28:20 +00:00
improvement: address feedback
This commit is contained in:
@@ -9,7 +9,7 @@ import { getDbConnectionHost } from "@app/lib/knex";
|
|||||||
export const verifyHostInputValidity = async (host: string, isGateway = false) => {
|
export const verifyHostInputValidity = async (host: string, isGateway = false) => {
|
||||||
const appCfg = getConfig();
|
const appCfg = getConfig();
|
||||||
|
|
||||||
if (appCfg.isDevelopmentMode) return [host];
|
// if (appCfg.isDevelopmentMode) return [host];
|
||||||
|
|
||||||
const reservedHosts = [appCfg.DB_HOST || getDbConnectionHost(appCfg.DB_CONNECTION_URI)].concat(
|
const reservedHosts = [appCfg.DB_HOST || getDbConnectionHost(appCfg.DB_CONNECTION_URI)].concat(
|
||||||
(appCfg.DB_READ_REPLICAS || []).map((el) => getDbConnectionHost(el.DB_CONNECTION_URI)),
|
(appCfg.DB_READ_REPLICAS || []).map((el) => getDbConnectionHost(el.DB_CONNECTION_URI)),
|
||||||
@@ -27,8 +27,11 @@ export const verifyHostInputValidity = async (host: string, isGateway = false) =
|
|||||||
try {
|
try {
|
||||||
const resolvedIps = await dns.resolve4(el);
|
const resolvedIps = await dns.resolve4(el);
|
||||||
exclusiveIps.push(...resolvedIps);
|
exclusiveIps.push(...resolvedIps);
|
||||||
} catch {
|
} catch (error) {
|
||||||
const resolvedIps = (await dns.lookup(el, { all: true })).map(({ address }) => address);
|
// only try lookup if not found
|
||||||
|
if ((error as { code: string })?.code !== "ENOTFOUND") throw error;
|
||||||
|
|
||||||
|
const resolvedIps = (await dns.lookup(el, { all: true, family: 4 })).map(({ address }) => address);
|
||||||
exclusiveIps.push(...resolvedIps);
|
exclusiveIps.push(...resolvedIps);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -46,8 +49,11 @@ export const verifyHostInputValidity = async (host: string, isGateway = false) =
|
|||||||
try {
|
try {
|
||||||
const resolvedIps = await dns.resolve4(host);
|
const resolvedIps = await dns.resolve4(host);
|
||||||
inputHostIps.push(...resolvedIps);
|
inputHostIps.push(...resolvedIps);
|
||||||
} catch {
|
} catch (error) {
|
||||||
const resolvedIps = (await dns.lookup(host, { all: true })).map(({ address }) => address);
|
// only try lookup if not found
|
||||||
|
if ((error as { code: string })?.code !== "ENOTFOUND") throw error;
|
||||||
|
|
||||||
|
const resolvedIps = (await dns.lookup(host, { all: true, family: 4 })).map(({ address }) => address);
|
||||||
inputHostIps.push(...resolvedIps);
|
inputHostIps.push(...resolvedIps);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user