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}"