bidirectional ip reflection for listener address discovery

This commit is contained in:
2026-02-09 16:02:23 -03:00
parent 59e9e420be
commit 7b47ef155c
31 changed files with 3192 additions and 269 deletions

View File

@@ -0,0 +1,64 @@
# Dockerfile for MWP NAT Traversal Testing
#
# Build context should be the project root (zig-p2p/)
# Run: docker build -f docker-tests/nat/Dockerfile -t mwp-peer .
FROM debian:bookworm-slim AS builder
# Install dependencies
RUN apt-get update && apt-get install -y \
curl \
xz-utils \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Install Zig
ARG ZIG_VERSION=0.15.2
ARG TARGETARCH
RUN set -ex; \
case "${TARGETARCH}" in \
amd64) ZIG_ARCH="x86_64" ;; \
arm64) ZIG_ARCH="aarch64" ;; \
*) echo "Unsupported architecture: ${TARGETARCH}"; exit 1 ;; \
esac; \
curl -fsSL "https://ziglang.org/download/${ZIG_VERSION}/zig-${ZIG_ARCH}-linux-${ZIG_VERSION}.tar.xz" -o /tmp/zig.tar.xz && \
tar -xJf /tmp/zig.tar.xz -C /opt && \
mv /opt/zig-${ZIG_ARCH}-linux-${ZIG_VERSION} /opt/zig && \
rm /tmp/zig.tar.xz
ENV PATH="/opt/zig:${PATH}"
# Copy source and build
WORKDIR /build
COPY src ./src
COPY build.zig ./build.zig
COPY examples ./examples
COPY docker-tests ./docker-tests
COPY tests ./tests
# Build all targets (needed for install step)
RUN zig build && \
cp zig-out/bin/mwp-demo /build/mwp-demo && \
ls -la /build/mwp-demo
# =============================================================================
# Runtime Stage
# =============================================================================
FROM debian:bookworm-slim AS runtime
RUN apt-get update && apt-get install -y \
ca-certificates \
iproute2 \
iputils-ping \
net-tools \
tcpdump \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /build/mwp-demo /usr/local/bin/mwp-demo
RUN chmod +x /usr/local/bin/mwp-demo
WORKDIR /app
# Default command shows help
CMD ["mwp-demo", "--help"]