This commit is contained in:
2025-09-24 14:46:34 +02:00
parent 51f771e0d7
commit 4b0a28ef21

View File

@@ -19,12 +19,12 @@ FULL_UNIX_SOCKET_PATH="$UNIX_SOCKET_PATH/$UNIX_SOCKET_NAME"
VERSION=$(cat VERSION) VERSION=$(cat VERSION)
echo -e "${CYAN}╭───────────────────────────────────────────────${NC}" echo -e "${CYAN}╭───────────────────────────────────────────────╮${NC}"
echo -e "${CYAN}${NC} Socat-proxy - Version ${VERSION}${NC} ${CYAN}${NC}" echo -e "${CYAN}${NC} Socat-proxy - Version ${VERSION}${NC} ${CYAN}${NC}"
echo -e "${CYAN}├───────────────────────────────────────────────${NC}" echo -e "${CYAN}├───────────────────────────────────────────────┤${NC}"
echo -e "${CYAN}${NC} Source: https://git.djeex.fr/Djeex/socat-proxy ${CYAN}${NC}" echo -e "${CYAN}${NC} Source: https://git.djeex.fr/Djeex/socat-proxy ${CYAN}${NC}"
echo -e "${CYAN}${NC} Mirror: https://github.com/Djeex/socat-proxy ${CYAN}${NC}" echo -e "${CYAN}${NC} Mirror: https://github.com/Djeex/socat-proxy ${CYAN}${NC}"
echo -e "${CYAN}╰───────────────────────────────────────────────${NC}" echo -e "${CYAN}╰───────────────────────────────────────────────╯${NC}"
# Validate required environment variables # Validate required environment variables
@@ -70,7 +70,7 @@ if [ -e "$FULL_UNIX_SOCKET_PATH" ]; then
fi fi
fi fi
echo [~] Creating socket directory structure... echo "[~] Creating socket directory structure..."
# Create directory if needed # Create directory if needed
if mkdir -p "$UNIX_SOCKET_PATH"; then if mkdir -p "$UNIX_SOCKET_PATH"; then
echo "[✓] Created directory $UNIX_SOCKET_PATH" echo "[✓] Created directory $UNIX_SOCKET_PATH"
@@ -80,11 +80,18 @@ else
fi fi
echo "[~] Creating socket with netcat..." echo "[~] Creating socket with netcat..."
# Create socket with nc -lU in background and then kill it to create the socket file # Create socket file by touching it, then remove it (this creates the path but leaves it clean for socat)
if timeout 1 nc -lU "$FULL_UNIX_SOCKET_PATH" 2>/dev/null || true; then touch "$FULL_UNIX_SOCKET_PATH"
echo "[✓] Socket created at $FULL_UNIX_SOCKET_PATH" rm "$FULL_UNIX_SOCKET_PATH"
echo "[✓] Socket path prepared at $FULL_UNIX_SOCKET_PATH"
# Debug: Check if socket file exists and its permissions
if [ -S "$FULL_UNIX_SOCKET_PATH" ]; then
echo "[✓] Socket file exists and is a socket"
ls -la "$FULL_UNIX_SOCKET_PATH"
else else
echo "[!] Socket creation with netcat had issues, but continuing..." echo "[!] Socket file does not exist or is not a socket"
ls -la "$UNIX_SOCKET_PATH"
fi fi
echo "[~] Testing connection to target..." echo "[~] Testing connection to target..."
@@ -115,7 +122,17 @@ echo "[~] Starting socat proxy..."
if socat -d -d UNIX-LISTEN:$FULL_UNIX_SOCKET_PATH,fork,unlink-early TCP:$TARGET_HOST:$TARGET_PORT & then if socat -d -d UNIX-LISTEN:$FULL_UNIX_SOCKET_PATH,fork,unlink-early TCP:$TARGET_HOST:$TARGET_PORT & then
SOCAT_PID=$! SOCAT_PID=$!
echo "[✓] Socat started with PID: $SOCAT_PID" echo "[✓] Socat started with PID: $SOCAT_PID"
echo "[i] Socat command: socat -d -d UNIX-LISTEN:$FULL_UNIX_SOCKET_PATH,fork,unlink-early TCP:$TARGET_HOST:$TARGET_PORT"
echo "[~] Container is ready and running..." echo "[~] Container is ready and running..."
# Debug: Check socket after socat starts
sleep 2
if [ -S "$FULL_UNIX_SOCKET_PATH" ]; then
echo "[✓] Socat socket is active"
ls -la "$FULL_UNIX_SOCKET_PATH"
else
echo "[!] Socat socket not found"
fi
else else
echo "[✗] Failed to start socat proxy" echo "[✗] Failed to start socat proxy"
exit 1 exit 1