Debug mode

This commit is contained in:
2025-09-24 15:43:35 +02:00
parent 4714570953
commit f98e5f0333
3 changed files with 18 additions and 6 deletions

View File

@@ -23,6 +23,7 @@ A lightweight Docker container that creates a UNIX socket proxy to TCP connectio
| `UNIX_SOCKET_NAME` | - | Name of the socket file | `docker.sock` |
| `UNIX_SOCKET_PATH` | - | Path to UNIX socket inside container | `/socket` |
| `HOST_SOCKET_PATH` | - | Host path for socket mounting | `/docker/beszel-agent/sock` |
| `DEBUG_LEVEL` | - | Level of logs verbose | `0`,`1`,`2`,`3` |
## 🚢 Quick Start

View File

@@ -1 +1 @@
1.0
1.0.0

View File

@@ -9,6 +9,7 @@ TARGET_PORT=${TARGET_PORT}
UNIX_SOCKET_NAME=${UNIX_SOCKET_NAME}
UNIX_SOCKET_PATH=${UNIX_SOCKET_PATH}
HOST_SOCKET_PATH=${HOST_SOCKET_PATH}
DEBUG_LEVEL=${DEBUG_LEVEL:-1} # Default to basic logging
# Remove trailing slashes to avoid double slashes
UNIX_SOCKET_PATH=${UNIX_SOCKET_PATH%/}
@@ -20,7 +21,7 @@ FULL_UNIX_SOCKET_PATH="$UNIX_SOCKET_PATH/$UNIX_SOCKET_NAME"
VERSION=$(cat VERSION)
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} Source: https://git.djeex.fr/Djeex/socat-proxy ${CYAN}${NC}"
echo -e "${CYAN}${NC} Mirror: https://github.com/Djeex/socat-proxy ${CYAN}${NC}"
@@ -118,8 +119,19 @@ cleanup() {
trap cleanup SIGTERM SIGINT
echo "[~] Starting socat proxy..."
# Start socat with verbose logging and redirect to stdout/stderr
if socat -d -d UNIX-LISTEN:$FULL_UNIX_SOCKET_PATH,fork,unlink-early TCP:$TARGET_HOST:$TARGET_PORT & then
# Start socat with configurable verbosity
DEBUG_FLAGS=""
if [ "$DEBUG_LEVEL" -eq 1 ]; then
DEBUG_FLAGS="-d"
elif [ "$DEBUG_LEVEL" -eq 2 ]; then
DEBUG_FLAGS="-d -d"
elif [ "$DEBUG_LEVEL" -eq 3 ]; then
DEBUG_FLAGS="-d -d -d"
fi
echo "[i] Using debug level: $DEBUG_LEVEL ($DEBUG_FLAGS)"
if socat $DEBUG_FLAGS UNIX-LISTEN:$FULL_UNIX_SOCKET_PATH,fork,unlink-early TCP:$TARGET_HOST:$TARGET_PORT & then
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"
@@ -144,5 +156,4 @@ while kill -0 "$SOCAT_PID" 2>/dev/null; do
done
echo "[✗] Socat process has stopped"
exit 1
exit 1