mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 18:27:36 +00:00
Merge pull request #3545 from Infisical/fix-dns-resolve-fallback
fix(external-connections): Use DNS Lookup as Fallback for DNS Resolve
This commit is contained in:
@@ -24,8 +24,16 @@ export const verifyHostInputValidity = async (host: string, isGateway = false) =
|
|||||||
if (net.isIPv4(el)) {
|
if (net.isIPv4(el)) {
|
||||||
exclusiveIps.push(el);
|
exclusiveIps.push(el);
|
||||||
} else {
|
} else {
|
||||||
const resolvedIps = await dns.resolve4(el);
|
try {
|
||||||
exclusiveIps.push(...resolvedIps);
|
const resolvedIps = await dns.resolve4(el);
|
||||||
|
exclusiveIps.push(...resolvedIps);
|
||||||
|
} catch (error) {
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -38,8 +46,16 @@ export const verifyHostInputValidity = async (host: string, isGateway = false) =
|
|||||||
if (normalizedHost === "localhost" || normalizedHost === "host.docker.internal") {
|
if (normalizedHost === "localhost" || normalizedHost === "host.docker.internal") {
|
||||||
throw new BadRequestError({ message: "Invalid db host" });
|
throw new BadRequestError({ message: "Invalid db host" });
|
||||||
}
|
}
|
||||||
const resolvedIps = await dns.resolve4(host);
|
try {
|
||||||
inputHostIps.push(...resolvedIps);
|
const resolvedIps = await dns.resolve4(host);
|
||||||
|
inputHostIps.push(...resolvedIps);
|
||||||
|
} catch (error) {
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isGateway && !(appCfg.DYNAMIC_SECRET_ALLOW_INTERNAL_IP || appCfg.ALLOW_INTERNAL_IP_CONNECTIONS)) {
|
if (!isGateway && !(appCfg.DYNAMIC_SECRET_ALLOW_INTERNAL_IP || appCfg.ALLOW_INTERNAL_IP_CONNECTIONS)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user