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_NAME` | - | Name of the socket file | `docker.sock` |
| `UNIX_SOCKET_PATH` | - | Path to UNIX socket inside container | `/socket` | | `UNIX_SOCKET_PATH` | - | Path to UNIX socket inside container | `/socket` |
| `HOST_SOCKET_PATH` | - | Host path for socket mounting | `/docker/beszel-agent/sock` | | `HOST_SOCKET_PATH` | - | Host path for socket mounting | `/docker/beszel-agent/sock` |
| `DEBUG_LEVEL` | - | Level of logs verbose | `0`,`1`,`2`,`3` |
## 🚢 Quick Start ## 🚢 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_NAME=${UNIX_SOCKET_NAME}
UNIX_SOCKET_PATH=${UNIX_SOCKET_PATH} UNIX_SOCKET_PATH=${UNIX_SOCKET_PATH}
HOST_SOCKET_PATH=${HOST_SOCKET_PATH} HOST_SOCKET_PATH=${HOST_SOCKET_PATH}
DEBUG_LEVEL=${DEBUG_LEVEL:-1} # Default to basic logging
# Remove trailing slashes to avoid double slashes # Remove trailing slashes to avoid double slashes
UNIX_SOCKET_PATH=${UNIX_SOCKET_PATH%/} UNIX_SOCKET_PATH=${UNIX_SOCKET_PATH%/}
@@ -118,8 +119,19 @@ cleanup() {
trap cleanup SIGTERM SIGINT trap cleanup SIGTERM SIGINT
echo "[~] Starting socat proxy..." echo "[~] Starting socat proxy..."
# Start socat with verbose logging and redirect to stdout/stderr # Start socat with configurable verbosity
if socat -d -d UNIX-LISTEN:$FULL_UNIX_SOCKET_PATH,fork,unlink-early TCP:$TARGET_HOST:$TARGET_PORT & then 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=$! 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 "[i] Socat command: socat -d -d UNIX-LISTEN:$FULL_UNIX_SOCKET_PATH,fork,unlink-early TCP:$TARGET_HOST:$TARGET_PORT"
@@ -145,4 +157,3 @@ done
echo "[✗] Socat process has stopped" echo "[✗] Socat process has stopped"
exit 1 exit 1