penguin/tinyproxy

An L4 proxy designed to act as a tiny transparent shim

commit 9c18424f2c65e8b14277122b381136f35f311c24

author斟酌 鵬兄 <tgckpg@gmail.com>
date2026-06-10T15:19:42Z
subjectversion CI
commit 9c18424f2c65e8b14277122b381136f35f311c24
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date:   2026-06-10T15:19:42Z

    version CI
---
 .github/workflows/cmake-multi-platform.yml | 28 ++++++++++++++++++++++++++--
 dockerfiles/github-perf.Dockerfile         |  4 +++-
 docs/tinyproxy.conf.5.scd                  |  6 ++++++
 examples/bind-wait.conf                    | 28 ++++++++++++++++++++++++++++
 mk/common.mk                               |  4 +++-
 src/tinyproxy.c                            |  6 +++++-
 6 files changed, 71 insertions(+), 5 deletions(-)

diff --git a/.github/workflows/cmake-multi-platform.yml b/.github/workflows/cmake-multi-platform.yml
index 4734df7..d2a1909 100644
--- a/.github/workflows/cmake-multi-platform.yml
+++ b/.github/workflows/cmake-multi-platform.yml
@@ -88,6 +88,16 @@ jobs:
             strace \
             haproxy
 
+      - &set_build_version
+        name: Set Build Version
+        run: |
+          if [ "${GITHUB_REF_TYPE:-}" = "tag" ]; then
+            BUILD_VER="${GITHUB_REF_NAME}"
+          else
+            BUILD_VER="dev-${GITHUB_SHA::12}"
+          fi
+          echo "BUILD_VER=${BUILD_VER}" >> "$GITHUB_ENV"
+
       - &build_static
         name: Build
         shell: sh
@@ -96,10 +106,19 @@ jobs:
 
           mkdir -p dist/debug dist/prod
 
-          make clean all STATIC=1 EXTRA_CFLAGS="-Og -g3 -Wpedantic" LIBEVENT_SRC=./libevent
+          make clean all \
+            STATIC=1 \
+            EXTRA_CFLAGS="-Og -g3 -Wpedantic" \
+            LIBEVENT_SRC=./libevent \
+            VERSION="$BUILD_VER"
+
           cp bin/tinyproxy dist/debug/tinyproxy
 
-          make clean all STATIC=1 LIBEVENT_SRC=./libevent
+          make clean all \
+            STATIC=1 \
+            LIBEVENT_SRC=./libevent \
+            VERSION="$BUILD_VER"
+
           cp bin/tinyproxy dist/prod/tinyproxy
           strip dist/prod/tinyproxy
 
@@ -185,6 +204,7 @@ jobs:
       - *download_libevent_source
       - *extract_libevent
       - *install_linux_deps
+      - *set_build_version
       - *build_static
       - *verify_static
       - *test
@@ -285,6 +305,8 @@ jobs:
           brew list libevent >/dev/null 2>&1 || brew install libevent
           brew list haproxy >/dev/null 2>&1 || brew install haproxy
 
+      - *set_build_version
+
       - name: Build
         run: |
           set -eu
@@ -569,6 +591,7 @@ jobs:
           cp ".cache/libevent/${LIBEVENT_TARBALL}" "./${LIBEVENT_TARBALL}"
 
       - *set_image_name
+      - *set_build_version
       - *setup_buildx
       - *login_ghcr
 
@@ -581,6 +604,7 @@ jobs:
           push: true
           build-args: |
             LIBEVENT_TARBALL=${{ env.LIBEVENT_TARBALL }}
+            BUILD_VER=${{ env.BUILD_VER }}
           tags: |
             ${{ env.IMAGE_NAME }}:${{ github.ref_name }}-debian-slim
           labels: |
diff --git a/dockerfiles/github-perf.Dockerfile b/dockerfiles/github-perf.Dockerfile
index 32f0fb2..8d3cb11 100644
--- a/dockerfiles/github-perf.Dockerfile
+++ b/dockerfiles/github-perf.Dockerfile
@@ -1,6 +1,7 @@
 FROM debian:trixie-slim AS build
 
 ARG LIBEVENT_TARBALL
+ARG BUILD_VER
 
 RUN apt-get update \
 	&& apt-get install -y --no-install-recommends \
@@ -29,7 +30,8 @@ RUN mkdir -p /build/libevent \
 		TOTAL=20 \
 		FD_LIMIT=512 \
 		LARGE_ROUNDTRIP_SIZE=4096 \
-		SEQUENTIAL_CONNECTIONS=20
+		SEQUENTIAL_CONNECTIONS=20 \
+		VERSION=${BUILD_VER}
 
 FROM debian:trixie-slim AS runtime
 
diff --git a/docs/tinyproxy.conf.5.scd b/docs/tinyproxy.conf.5.scd
index 1c62f47..64ea5af 100644
--- a/docs/tinyproxy.conf.5.scd
+++ b/docs/tinyproxy.conf.5.scd
@@ -78,6 +78,12 @@ broadcast_reply=upstream
 
 # ENDPOINTS
 
+tcp [ADDR]:PORT
+	Support IPv4, IPv6
+
+udp [ADDR]:PORT
+	Support IPv4, IPv6
+
 unix /tmp/backend.sock
 	Unix sock
 
diff --git a/examples/bind-wait.conf b/examples/bind-wait.conf
new file mode 100644
index 0000000..a7129fd
--- /dev/null
+++ b/examples/bind-wait.conf
@@ -0,0 +1,28 @@
+# Wait for a listen address to become available before failing startup.
+#
+# This is useful for Kubernetes rolling updates when using hostNetwork
+# and fixed listen ports. The replacement pod can start and pull its
+# image while the previous pod is still running, then wait for the
+# listen port to be released.
+#
+# Example DaemonSet strategy:
+#
+# apiVersion: apps/v1
+# kind: DaemonSet
+# spec:
+#   updateStrategy:
+#     type: RollingUpdate
+#     rollingUpdate:
+#       maxSurge: 1
+#       maxUnavailable: 0
+#   template:
+#     spec:
+#       hostNetwork: true
+#       # Do not define hostPort or a fixed-port readinessProbe.
+#       ...
+#
+# In this example, the new tinyproxy instance waits up to 30 seconds
+# for :80 and :443 to become available before failing startup.
+#
+tcp :80  tcp 10.0.1.1:80  bind_wait=30,keep_alive,proxy_v2
+tcp :443 tcp 10.0.1.1:443 bind_wait=30,keep_alive,proxy_v2
diff --git a/mk/common.mk b/mk/common.mk
index 5abe399..e88f15e 100644
--- a/mk/common.mk
+++ b/mk/common.mk
@@ -14,16 +14,18 @@ STATIC ?= 0
 
 EXEEXT :=
 WINDOWS_LDLIBS :=
+VERSION ?= dev
 
 ifeq ($(OS),Windows_NT)
 EXEEXT := .exe
 WINDOWS_LDLIBS += -lws2_32
 endif
 
-BASE_CFLAGS ?= -O2 -DNDEBUG -Wall -Wextra -ffunction-sections -fdata-sections
+BASE_CFLAGS ?= -O2 -Wall -Wextra -ffunction-sections -fdata-sections
 
 CFLAGS += $(BASE_CFLAGS)
 CFLAGS += $(EXTRA_CFLAGS)
+CFLAGS += -DTINYPROXY_VERSION=\"$(VERSION)\"
 
 CPPFLAGS += -I$(SRC_DIR)
 
diff --git a/src/tinyproxy.c b/src/tinyproxy.c
index a02a45d..b819250 100644
--- a/src/tinyproxy.c
+++ b/src/tinyproxy.c
@@ -16,6 +16,10 @@
 #include "route.h"
 #include "route_runtime.h"
 
+#ifndef TINYPROXY_VERSION
+#define TINYPROXY_VERSION "dev"
+#endif
+
 static void usage(FILE *out, const char *prog)
 {
 	fprintf(out,
@@ -147,7 +151,7 @@ int main(int argc, char **argv)
 				return 0;
 
 			case 'v':
-				fprintf(stdout, "tinyproxy v0.2.0\n");
+				fprintf(stdout, "tinyproxy %s\n", TINYPROXY_VERSION);
 				free(inline_routes);
 				return 0;