udphole

Basic UDP wormhole proxy
git clone git://git.finwo.net/app/udphole
Log | Files | Refs | README | LICENSE

commit 4b5396a82ccf557d80810c5ec848c70a50940229
parent cbf4c967161ed814b903a636929817a6bbe8dd1e
Author: Robin Bron <robin.bron@yourhosting.nl>
Date:   Mon,  2 Mar 2026 22:55:12 +0100

v1.3.1

Diffstat:
M.github/workflows/docker.yml | 100+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------
MDockerfile | 33++++-----------------------------
MMakefile | 2+-
Mentrypoint.sh | 14+++++++++++++-
4 files changed, 111 insertions(+), 38 deletions(-)

diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml @@ -1,5 +1,5 @@ --- -name: Docker Build & Push +name: Build & Push on: push: @@ -12,15 +12,83 @@ on: pull_request: branches: - main - workflow_dispatch: - -env: - REGISTRY: docker.io - IMAGE_NAME: finwo/udphole jobs: + version: + name: Extract version + runs-on: ubuntu-latest + outputs: + version: ${{ steps.version.outputs.version }} + steps: + - name: Extract version + id: version + run: | + if [[ "${{ github.ref }}" == refs/tags/v* ]]; then + echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT + else + echo "version=latest" >> $GITHUB_OUTPUT + fi + + build-binaries: + name: Build binaries + runs-on: ubuntu-latest + needs: version + strategy: + matrix: + include: + - name: linux-amd64 + bin: udphole-linux-amd64 + cross: false + + - name: linux-arm64 + arch: aarch64 + bin: udphole-linux-arm64 + cross: true + + - name: linux-riscv64 + arch: riscv64 + bin: udphole-linux-riscv64 + cross: true + + steps: + - uses: actions/checkout@v4 + + - uses: finwo/dep@main + name: Install dep + + - name: Install dependencies + run: dep install + + - if: '!matrix.cross' + name: Build native + run: | + make -j udphole VERSION=${{ needs.version.outputs.version }} + mv udphole ${{ matrix.bin }} + + - if: matrix.cross + uses: uraimo/run-on-arch-action@v3 + name: Build cross + with: + arch: ${{ matrix.arch }} + distro: ubuntu24.04 + githubToken: ${{ github.token }} + install: | + apt-get update -y + apt-get install -yq build-essential + run: | + make -j udphole VERSION=${{ needs.version.outputs.version }} + mv udphole ${{ matrix.bin }} + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.bin }} + path: ${{ matrix.bin }} + retention-days: 1 + docker: runs-on: ubuntu-latest + needs: [version, build-binaries] permissions: contents: read packages: write @@ -35,6 +103,13 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: Download all artifacts + uses: actions/download-artifact@v4 + with: + path: . + pattern: udphole-linux-* + merge-multiple: true + - name: Log in to Docker Hub if: github.event_name != 'pull_request' uses: docker/login-action@v3 @@ -46,7 +121,7 @@ jobs: id: meta uses: docker/metadata-action@v5 with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + images: docker.io/finwo/udphole tags: | type=ref,event=branch type=ref,event=pr @@ -66,3 +141,14 @@ jobs: labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max + build-args: VERSION=${{ needs.version.outputs.version }} + + - name: Update Docker Hub description + if: github.event_name != 'pull_request' + uses: peter-evans/dockerhub-description@v5 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + repository: finwo/udphole + short-description: "UDP hole punching proxy with RESP2 API" + readme-filepath: README.md diff --git a/Dockerfile b/Dockerfile @@ -1,37 +1,12 @@ -FROM debian:bookworm-slim AS builder +ARG VERSION=latest -RUN apt-get update && apt-get install -y \ - gcc \ - make \ - wget \ - crossbuild-essential-amd64 \ - crossbuild-essential-arm64 \ - crossbuild-essential-riscv64 +FROM busybox:latest -RUN wget -O /usr/local/bin/dep https://raw.githubusercontent.com/finwo/dep/master/dep && \ - chmod +x /usr/local/bin/dep +ARG TARGETARCH -WORKDIR /src -COPY . . +COPY udphole-linux-${TARGETARCH} /usr/bin/udphole -RUN dep ensure && \ - make -j \ - CC=aarch64-linux-gnu-gcc CFLAGS="-static-libgcc" TARGETARCH=arm64 && \ - mv udphole udphole-arm64 && \ - make clean && \ - make -j \ - CC=riscv64-linux-gnu-gcc CFLAGS="-static-libgcc" TARGETARCH=riscv64 && \ - mv udphole udphole-riscv64 && \ - make clean && \ - make -j \ - CC=gcc CFLAGS="-static-libgcc" TARGETARCH=amd64 && \ - mv udphole udphole-amd64 - -FROM --platform=${TARGETPLATFORM} busybox:latest - -COPY --from=builder /src/udphole-${TARGETARCH} /usr/bin/udphole COPY entrypoint.sh /etc/rc.local - RUN chmod +x /etc/rc.local ENTRYPOINT ["/bin/ash", "/etc/rc.local"] diff --git a/Makefile b/Makefile @@ -7,7 +7,7 @@ SRC:= # UNAME_SYSTEM=$(call lc,$(shell uname -s)) BIN?=udphole -VERSION?=1.2.0 +VERSION?=1.3.1 CC:=gcc CPP:=g++ diff --git a/entrypoint.sh b/entrypoint.sh @@ -2,7 +2,19 @@ set -e CONFIG_PATH="/etc/udphole.conf" -UDPHBIN="/usr/bin/udphole" + +ARCH="$(uname -m)" +case "$ARCH" in + x86_64) ARCH=amd64 ;; + aarch64) ARCH=arm64 ;; + riscv64) ARCH=riscv64 ;; +esac + +UDPHBIN="/usr/bin/udphole-linux-${ARCH}" + +if [ ! -f "$UDPHBIN" ]; then + UDPHBIN="/usr/bin/udphole-linux-amd64" +fi if [ -f "$CONFIG_PATH" ]; then echo "Using mounted config: $CONFIG_PATH"