From 6d4f96cabb82539b79c6ec4ddc1b9e99a7d7b5ba Mon Sep 17 00:00:00 2001 From: JMARyA Date: Tue, 3 Sep 2024 10:47:08 +0200 Subject: [PATCH] fix --- .env | 6 ++++++ Dockerfile | 2 +- README.md | 5 ++--- docker-compose.yml | 7 +------ entrypoint.sh | 4 +--- 5 files changed, 11 insertions(+), 13 deletions(-) create mode 100644 .env diff --git a/.env b/.env new file mode 100644 index 0000000..e323014 --- /dev/null +++ b/.env @@ -0,0 +1,6 @@ +HOST="https://chisel.example.com" +LOCAL_PORT="8080" +REMOTE_PORT="8080" +USER="user" +TOKEN="token" +PROTOCOL="tcp" diff --git a/Dockerfile b/Dockerfile index 1742e6a..7b61d46 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,7 @@ RUN go build -o chisel main.go FROM alpine:latest RUN apk update && apk upgrade && \ - apk add --no-cache socat bash + apk add --no-cache bash COPY --from=builder /chisel/chisel /usr/bin/chisel COPY ./entrypoint.sh /entrypoint.sh diff --git a/README.md b/README.md index 17976d0..5464fa3 100644 --- a/README.md +++ b/README.md @@ -3,14 +3,13 @@ This container allows to forward a local port to a remote system running chisel # TODO - Load Balancing -- Error Handling -- UDP ## Configuration The container is configured through environment variables: - `$HOST`: The host running chisel server -- `$LOCAL_PORT`: The local port to forward - `$LOCAL_HOST`: The local host address +- `$LOCAL_PORT`: The local port to forward - `$REMOTE_PORT`: The remote port to expose the forward on - `$USER`: Authentication User - `$TOKEN`: Authentication Token +- `$PROTOCOL`: The protocol to use (`tcp` / `udp`) diff --git a/docker-compose.yml b/docker-compose.yml index c57a5fd..03caf9f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,9 +2,4 @@ services: forward: build: . restart: unless-stopped - environment: - HOST: "https://chisel.example.com" - LOCAL_PORT: "8080" - REMOTE_PORT: "8080" - USER: "user" - TOKEN: "token" + env_file: .env diff --git a/entrypoint.sh b/entrypoint.sh index bf81fd2..8897e04 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,5 +1,3 @@ #!/bin/bash -socat TCP4-LISTEN:$LOCAL_PORT,fork,reuseaddr TCP4:TCP4:$LOCAL_HOST:$LOCAL_PORT & -chisel client --auth "$USER:$TOKEN" "$HOST" "R:$LOCAL_HOST:$LOCAL_PORT:127.0.0.1:$REMOTE_PORT" & -wait +chisel client --auth "$USER:$TOKEN" "$HOST" "R:0.0.0.0:$REMOTE_PORT:$LOCAL_HOST:$LOCAL_PORT/${PROTOCOL:-tcp}"