From 5e2eb5d761aa04e9c2ad0fcac6104622b2cabe71 Mon Sep 17 00:00:00 2001 From: Rajan Patel Date: Sat, 28 May 2022 09:34:54 -0400 Subject: [PATCH] initial commit --- .github/workflows/deploy.yml | 41 ++++++++++++++++++++++++++++++ Dockerfile | 35 +++++++++++++++++++++++++ README.md | 30 ++++++++++++++++++++++ rootfs/etc/services.d/rtlmuxer/run | 4 +++ 4 files changed, 110 insertions(+) create mode 100644 .github/workflows/deploy.yml create mode 100644 Dockerfile create mode 100644 rootfs/etc/services.d/rtlmuxer/run diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..69339e6 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,41 @@ +name: Build and deploy to ghcr.io + +on: + workflow_dispatch: + inputs: + reason: + required: true + description: 'Reason for running this workflow' + push: + branches: + - master + paths-ignore: + - '**.md' + +jobs: + build: + name: 'Build' + runs-on: ubuntu-latest + steps: + - name: "Build:checkout" + uses: actions/checkout@v3 + + - name: "Build:qemu" + uses: docker/setup-qemu-action@v2 + + - name: "Build:buildx" + uses: docker/setup-buildx-action@v2 + + - name: "Build:login" + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: 'Build:buildandpush' + uses: docker/build-push-action@v3.0.0 + with: + push: true + platforms: linux/amd64,linux/arm/v7,linux/arm64 + tags: ghcr.io/${{ github.repository }}:latest,ghcr.io/${{ github.repository }}:${{ github.run_number }}-${{ github.sha }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..bd1da83 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,35 @@ +FROM ghcr.io/sdr-enthusiasts/docker-baseimage:base + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +# hadolint ignore=DL3008,SC2086,DL4006,SC2039 +RUN set -x && \ + TEMP_PACKAGES=() && \ + KEPT_PACKAGES=() && \ + # packages needed to install + TEMP_PACKAGES+=(git) && \ + # packages needed to build + TEMP_PACKAGES+=(build-essential) && \ + # install packages + apt-get update && \ + apt-get install -y --no-install-recommends \ + "${KEPT_PACKAGES[@]}" \ + "${TEMP_PACKAGES[@]}" && \ + # Deploy rtlmuxer + git clone https://github.com/rpatel3001/rtlmuxer.git /src/rtlmuxer && \ + pushd /src/rtlmuxer && \ + make && \ + cp rtlmuxer /usr/local/bin && \ + popd && \ + # Clean up + apt-get remove -y "${TEMP_PACKAGES[@]}" && \ + apt-get autoremove -y && \ + rm -rf /src/* /tmp/* /var/lib/apt/lists/* + +COPY rootfs/ / + +ENV SRC_ADDR="" \ + SRC_PORT="1234" \ + SINK_ADDR="0.0.0.0" \ + RW_SINK_PORT="7373" \ + RO_SINK_PORT="7374" \ No newline at end of file diff --git a/README.md b/README.md index 89a41b6..32364e4 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,32 @@ # docker-rtlmuxer Proxy rtl_tcp compatible streams to allow for multiple clients. + +This container is a thin wrapper around [rpatel3001/rtlmuxer](https://github.com/rpatel3001/rtlmuxer), which is a slightly modified fork of [alexander-sholohov/rtlmuxer](https://github.com/alexander-sholohov/rtlmuxer). + +## Docker Compose Snippet + +``` + rtlmuxer: + container_name: rtlmuxer + hostname: rtlmuxer + image: ghcr.io/rpatel3001/docker-rtlmuxer + restart: always + ports: + - 7373:7373 + - 7374:7374 + volumes: + - /etc/timezone:/etc/timezone:ro + - /etc/localtime:/etc/localtime:ro + environment: + - SRC_ADDR=x.x.x.x +``` + +## Configuration options + +| Variable | Description | Default | +|----------|-------------|---------| +| `SRC_ADDR` | Address of the rtl_tcp source we are proxying. | Unset | +| `SRC_PORT` | Port of the rtl_tcp source we are proxying. | 1234 | +| `SINK_ADDR` | Address to bind for the proxied connections. | 0.0.0.0 | +| `RW_SINK_PORT` | Port to bind for the read/write proxy connection. | 7373 | +| `RO_SINK_PORT` | Port to bind for the read-only proxy connection. | 7374 | \ No newline at end of file diff --git a/rootfs/etc/services.d/rtlmuxer/run b/rootfs/etc/services.d/rtlmuxer/run new file mode 100644 index 0000000..fedc294 --- /dev/null +++ b/rootfs/etc/services.d/rtlmuxer/run @@ -0,0 +1,4 @@ +#!/usr/bin/with-contenv bash +#shellcheck shell=bash + +rtlmuxer --src-address=$SRC_ADDR --src-port=$SRC_PORT --sink-bind-address=$SINK_ADDR --sink-bind-port-a=$RW_SINK_PORT --sink-bind-port-b=$RO_SINK_PORT 2>&1 | stdbuf -o0 awk '{print "[rtlmuxer] " strftime("%Y/%m/%d %H:%M:%S", systime()) " " $0}'