mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Only timeout for imds endpoints
This commit is contained in:
parent
7f1cbab717
commit
11bd9b3c19
1 changed files with 3 additions and 3 deletions
|
|
@ -3,7 +3,7 @@ import { ui } from "../environment/userInteraction.js";
|
||||||
import { isImdsEndpoint } from "./isImdsEndpoint.js";
|
import { isImdsEndpoint } from "./isImdsEndpoint.js";
|
||||||
|
|
||||||
/** @type {string[]} */
|
/** @type {string[]} */
|
||||||
let timedoutEndpoints = [];
|
let timedoutImdsEndpoints = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {import("http").IncomingMessage} req
|
* @param {import("http").IncomingMessage} req
|
||||||
|
|
@ -43,7 +43,7 @@ function tunnelRequestToDestination(req, clientSocket, head) {
|
||||||
const { port, hostname } = new URL(`http://${req.url}`);
|
const { port, hostname } = new URL(`http://${req.url}`);
|
||||||
const isImds = isImdsEndpoint(hostname);
|
const isImds = isImdsEndpoint(hostname);
|
||||||
|
|
||||||
if (timedoutEndpoints.includes(hostname)) {
|
if (timedoutImdsEndpoints.includes(hostname)) {
|
||||||
clientSocket.end("HTTP/1.1 502 Bad Gateway\r\n\r\n");
|
clientSocket.end("HTTP/1.1 502 Bad Gateway\r\n\r\n");
|
||||||
if (isImds) {
|
if (isImds) {
|
||||||
ui.writeVerbose(
|
ui.writeVerbose(
|
||||||
|
|
@ -74,9 +74,9 @@ function tunnelRequestToDestination(req, clientSocket, head) {
|
||||||
serverSocket.setTimeout(connectTimeout);
|
serverSocket.setTimeout(connectTimeout);
|
||||||
|
|
||||||
serverSocket.on("timeout", () => {
|
serverSocket.on("timeout", () => {
|
||||||
timedoutEndpoints.push(hostname);
|
|
||||||
// Suppress error logging for IMDS endpoints - timeouts are expected when not in cloud
|
// Suppress error logging for IMDS endpoints - timeouts are expected when not in cloud
|
||||||
if (isImds) {
|
if (isImds) {
|
||||||
|
timedoutImdsEndpoints.push(hostname);
|
||||||
ui.writeVerbose(
|
ui.writeVerbose(
|
||||||
`Safe-chain: connect to ${hostname}:${
|
`Safe-chain: connect to ${hostname}:${
|
||||||
port || 443
|
port || 443
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue