Debug mode
This commit is contained in:
@@ -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
|
||||||
|
|
||||||
|
@@ -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%/}
|
||||||
@@ -20,7 +21,7 @@ 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}"
|
||||||
@@ -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
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user