mirror of https://github.com/oxen-io/lokinet
Merge remote-tracking branch 'upstream/stable' into fedora/34
commit
50ff2618d0
@ -1,6 +0,0 @@
|
||||
ARG ARCH=amd64
|
||||
FROM ${ARCH}/debian:bullseye
|
||||
RUN /bin/bash -c 'echo "man-db man-db/auto-update boolean false" | debconf-set-selections'
|
||||
RUN apt-get -o=Dpkg::Use-Pty=0 -q update \
|
||||
&& apt-get -o=Dpkg::Use-Pty=0 -q dist-upgrade -y \
|
||||
&& apt-get -o=Dpkg::Use-Pty=0 -q autoremove -y
|
@ -1,6 +0,0 @@
|
||||
ARG ARCH=amd64
|
||||
FROM ${ARCH}/debian:buster
|
||||
RUN /bin/bash -c 'echo "man-db man-db/auto-update boolean false" | debconf-set-selections'
|
||||
RUN apt-get -o=Dpkg::Use-Pty=0 -q update \
|
||||
&& apt-get -o=Dpkg::Use-Pty=0 -q dist-upgrade -y \
|
||||
&& apt-get -o=Dpkg::Use-Pty=0 -q autoremove -y
|
@ -1,6 +0,0 @@
|
||||
ARG ARCH=amd64
|
||||
FROM ${ARCH}/debian:sid
|
||||
RUN /bin/bash -c 'echo "man-db man-db/auto-update boolean false" | debconf-set-selections'
|
||||
RUN apt-get -o=Dpkg::Use-Pty=0 -q update \
|
||||
&& apt-get -o=Dpkg::Use-Pty=0 -q dist-upgrade -y \
|
||||
&& apt-get -o=Dpkg::Use-Pty=0 -q autoremove -y
|
@ -1,6 +0,0 @@
|
||||
ARG ARCH=amd64
|
||||
FROM ${ARCH}/debian:stable
|
||||
RUN /bin/bash -c 'echo "man-db man-db/auto-update boolean false" | debconf-set-selections'
|
||||
RUN apt-get -o=Dpkg::Use-Pty=0 -q update \
|
||||
&& apt-get -o=Dpkg::Use-Pty=0 -q dist-upgrade -y \
|
||||
&& apt-get -o=Dpkg::Use-Pty=0 -q autoremove -y
|
@ -1,6 +0,0 @@
|
||||
ARG ARCH=amd64
|
||||
FROM ${ARCH}/debian:testing
|
||||
RUN /bin/bash -c 'echo "man-db man-db/auto-update boolean false" | debconf-set-selections'
|
||||
RUN apt-get -o=Dpkg::Use-Pty=0 -q update \
|
||||
&& apt-get -o=Dpkg::Use-Pty=0 -q dist-upgrade -y \
|
||||
&& apt-get -o=Dpkg::Use-Pty=0 -q autoremove -y
|
@ -1,39 +0,0 @@
|
||||
ARG ARCH=amd64
|
||||
FROM registry.oxen.rocks/lokinet-ci-debian-bullseye-base/${ARCH}
|
||||
RUN apt-get -o=Dpkg::Use-Pty=0 -q install --no-install-recommends -y \
|
||||
automake \
|
||||
ccache \
|
||||
cmake \
|
||||
eatmydata \
|
||||
g++ \
|
||||
gdb \
|
||||
git \
|
||||
libboost-program-options-dev \
|
||||
libboost-serialization-dev \
|
||||
libboost-thread-dev \
|
||||
libcurl4-openssl-dev \
|
||||
libevent-dev \
|
||||
libgtest-dev \
|
||||
libhidapi-dev \
|
||||
libjemalloc-dev \
|
||||
libminiupnpc-dev \
|
||||
libreadline-dev \
|
||||
libsodium-dev \
|
||||
libsqlite3-dev \
|
||||
libssl-dev \
|
||||
libsystemd-dev \
|
||||
libtool \
|
||||
libunbound-dev \
|
||||
libunwind8-dev \
|
||||
libusb-1.0.0-dev \
|
||||
libuv1-dev \
|
||||
libzmq3-dev \
|
||||
lsb-release \
|
||||
make \
|
||||
nettle-dev \
|
||||
ninja-build \
|
||||
openssh-client \
|
||||
patch \
|
||||
pkg-config \
|
||||
python3-dev \
|
||||
qttools5-dev
|
@ -1,40 +0,0 @@
|
||||
ARG ARCH=amd64
|
||||
FROM registry.oxen.rocks/lokinet-ci-debian-buster-base/${ARCH}
|
||||
RUN apt-get -o=Dpkg::Use-Pty=0 -q install --no-install-recommends -y \
|
||||
automake \
|
||||
ccache \
|
||||
cmake \
|
||||
eatmydata \
|
||||
g++ \
|
||||
gdb \
|
||||
git \
|
||||
libboost-program-options-dev \
|
||||
libboost-serialization-dev \
|
||||
libboost-thread-dev \
|
||||
libcurl4-openssl-dev \
|
||||
libevent-dev \
|
||||
libgtest-dev \
|
||||
libhidapi-dev \
|
||||
libjemalloc-dev \
|
||||
libminiupnpc-dev \
|
||||
libreadline-dev \
|
||||
libsodium-dev \
|
||||
libsqlite3-dev \
|
||||
libssl-dev \
|
||||
libsystemd-dev \
|
||||
libtool \
|
||||
libunbound-dev \
|
||||
libunwind8-dev \
|
||||
libusb-1.0.0-dev \
|
||||
libuv1-dev \
|
||||
libzmq3-dev \
|
||||
lsb-release \
|
||||
make \
|
||||
nettle-dev \
|
||||
ninja-build \
|
||||
openssh-client \
|
||||
patch \
|
||||
pkg-config \
|
||||
python3-dev \
|
||||
qttools5-dev \
|
||||
xz-utils
|
@ -1,39 +0,0 @@
|
||||
ARG ARCH=amd64
|
||||
FROM registry.oxen.rocks/lokinet-ci-debian-sid-base/${ARCH}
|
||||
RUN apt-get -o=Dpkg::Use-Pty=0 --no-install-recommends -q install -y \
|
||||
automake \
|
||||
ccache \
|
||||
cmake \
|
||||
eatmydata \
|
||||
g++ \
|
||||
gdb \
|
||||
git \
|
||||
libboost-program-options-dev \
|
||||
libboost-serialization-dev \
|
||||
libboost-thread-dev \
|
||||
libcurl4-openssl-dev \
|
||||
libevent-dev \
|
||||
libgtest-dev \
|
||||
libhidapi-dev \
|
||||
libjemalloc-dev \
|
||||
libminiupnpc-dev \
|
||||
libreadline-dev \
|
||||
libsodium-dev \
|
||||
libsqlite3-dev \
|
||||
libssl-dev \
|
||||
libsystemd-dev \
|
||||
libtool \
|
||||
libunbound-dev \
|
||||
libunwind8-dev \
|
||||
libusb-1.0.0-dev \
|
||||
libuv1-dev \
|
||||
libzmq3-dev \
|
||||
lsb-release \
|
||||
make \
|
||||
nettle-dev \
|
||||
ninja-build \
|
||||
openssh-client \
|
||||
patch \
|
||||
pkg-config \
|
||||
python3-dev \
|
||||
qttools5-dev
|
@ -1,39 +0,0 @@
|
||||
ARG ARCH=amd64
|
||||
FROM registry.oxen.rocks/lokinet-ci-debian-stable-base/${ARCH}
|
||||
RUN apt-get -o=Dpkg::Use-Pty=0 -q install --no-install-recommends -y \
|
||||
automake \
|
||||
ccache \
|
||||
cmake \
|
||||
eatmydata \
|
||||
g++ \
|
||||
gdb \
|
||||
git \
|
||||
libboost-program-options-dev \
|
||||
libboost-serialization-dev \
|
||||
libboost-thread-dev \
|
||||
libcurl4-openssl-dev \
|
||||
libevent-dev \
|
||||
libgtest-dev \
|
||||
libhidapi-dev \
|
||||
libjemalloc-dev \
|
||||
libminiupnpc-dev \
|
||||
libreadline-dev \
|
||||
libsodium-dev \
|
||||
libsqlite3-dev \
|
||||
libssl-dev \
|
||||
libsystemd-dev \
|
||||
libtool \
|
||||
libunbound-dev \
|
||||
libunwind8-dev \
|
||||
libusb-1.0.0-dev \
|
||||
libuv1-dev \
|
||||
libzmq3-dev \
|
||||
lsb-release \
|
||||
make \
|
||||
nettle-dev \
|
||||
ninja-build \
|
||||
openssh-client \
|
||||
patch \
|
||||
pkg-config \
|
||||
python3-dev \
|
||||
qttools5-dev
|
@ -1,31 +0,0 @@
|
||||
ARG ARCH=amd64
|
||||
FROM ${ARCH}/ubuntu:bionic
|
||||
RUN /bin/bash -c 'echo "man-db man-db/auto-update boolean false" | debconf-set-selections'
|
||||
RUN apt-get -o=Dpkg::Use-Pty=0 -q update \
|
||||
&& apt-get -o=Dpkg::Use-Pty=0 -q dist-upgrade -y \
|
||||
&& apt-get -o=Dpkg::Use-Pty=0 -q --no-install-recommends install -y \
|
||||
autoconf \
|
||||
automake \
|
||||
ccache \
|
||||
cmake \
|
||||
eatmydata \
|
||||
file \
|
||||
g++-8 \
|
||||
gdb \
|
||||
git \
|
||||
gperf \
|
||||
libjemalloc-dev \
|
||||
libpgm-dev \
|
||||
libtool \
|
||||
libuv1-dev \
|
||||
libzmq3-dev \
|
||||
lsb-release \
|
||||
make \
|
||||
ninja-build \
|
||||
openssh-client \
|
||||
openssh-client \
|
||||
patch \
|
||||
pkg-config \
|
||||
python3-dev \
|
||||
qttools5-dev \
|
||||
&& mkdir -p /usr/lib/x86_64-linux-gnu/pgm-5.2/include
|
@ -1,42 +0,0 @@
|
||||
ARG ARCH=amd64
|
||||
FROM ${ARCH}/ubuntu:focal
|
||||
RUN /bin/bash -c 'echo "man-db man-db/auto-update boolean false" | debconf-set-selections'
|
||||
RUN apt-get -o=Dpkg::Use-Pty=0 -q update \
|
||||
&& apt-get -o=Dpkg::Use-Pty=0 -q dist-upgrade -y \
|
||||
&& apt-get -o=Dpkg::Use-Pty=0 --no-install-recommends -q install -y \
|
||||
automake \
|
||||
ccache \
|
||||
cmake \
|
||||
eatmydata \
|
||||
g++ \
|
||||
gdb \
|
||||
git \
|
||||
libboost-program-options-dev \
|
||||
libboost-serialization-dev \
|
||||
libboost-thread-dev \
|
||||
libcurl4-openssl-dev \
|
||||
libevent-dev \
|
||||
libgtest-dev \
|
||||
libhidapi-dev \
|
||||
libjemalloc-dev \
|
||||
libminiupnpc-dev \
|
||||
libreadline-dev \
|
||||
libsodium-dev \
|
||||
libsqlite3-dev \
|
||||
libssl-dev \
|
||||
libsystemd-dev \
|
||||
libtool \
|
||||
libunbound-dev \
|
||||
libunwind8-dev \
|
||||
libusb-1.0.0-dev \
|
||||
libuv1-dev \
|
||||
libzmq3-dev \
|
||||
lsb-release \
|
||||
make \
|
||||
nettle-dev \
|
||||
ninja-build \
|
||||
openssh-client \
|
||||
patch \
|
||||
pkg-config \
|
||||
python3-dev \
|
||||
qttools5-dev
|
@ -1,42 +0,0 @@
|
||||
ARG ARCH=amd64
|
||||
FROM ${ARCH}/ubuntu:impish
|
||||
RUN /bin/bash -c 'echo "man-db man-db/auto-update boolean false" | debconf-set-selections'
|
||||
RUN apt-get -o=Dpkg::Use-Pty=0 -q update \
|
||||
&& apt-get -o=Dpkg::Use-Pty=0 -q dist-upgrade -y \
|
||||
&& apt-get -o=Dpkg::Use-Pty=0 --no-install-recommends -q install -y \
|
||||
automake \
|
||||
ccache \
|
||||
cmake \
|
||||
eatmydata \
|
||||
g++ \
|
||||
gdb \
|
||||
git \
|
||||
libboost-program-options-dev \
|
||||
libboost-serialization-dev \
|
||||
libboost-thread-dev \
|
||||
libcurl4-openssl-dev \
|
||||
libevent-dev \
|
||||
libgtest-dev \
|
||||
libhidapi-dev \
|
||||
libjemalloc-dev \
|
||||
libminiupnpc-dev \
|
||||
libreadline-dev \
|
||||
libsodium-dev \
|
||||
libsqlite3-dev \
|
||||
libssl-dev \
|
||||
libsystemd-dev \
|
||||
libtool \
|
||||
libunbound-dev \
|
||||
libunwind8-dev \
|
||||
libusb-1.0.0-dev \
|
||||
libuv1-dev \
|
||||
libzmq3-dev \
|
||||
lsb-release \
|
||||
make \
|
||||
nettle-dev \
|
||||
ninja-build \
|
||||
openssh-client \
|
||||
patch \
|
||||
pkg-config \
|
||||
python3-dev \
|
||||
qttools5-dev
|
@ -1,42 +0,0 @@
|
||||
ARG ARCH=amd64
|
||||
FROM ${ARCH}/ubuntu:latest
|
||||
RUN /bin/bash -c 'echo "man-db man-db/auto-update boolean false" | debconf-set-selections'
|
||||
RUN apt-get -o=Dpkg::Use-Pty=0 -q update \
|
||||
&& apt-get -o=Dpkg::Use-Pty=0 -q dist-upgrade -y \
|
||||
&& apt-get -o=Dpkg::Use-Pty=0 --no-install-recommends -q install -y \
|
||||
automake \
|
||||
ccache \
|
||||
cmake \
|
||||
eatmydata \
|
||||
g++ \
|
||||
gdb \
|
||||
git \
|
||||
libboost-program-options-dev \
|
||||
libboost-serialization-dev \
|
||||
libboost-thread-dev \
|
||||
libcurl4-openssl-dev \
|
||||
libevent-dev \
|
||||
libgtest-dev \
|
||||
libhidapi-dev \
|
||||
libjemalloc-dev \
|
||||
libminiupnpc-dev \
|
||||
libreadline-dev \
|
||||
libsodium-dev \
|
||||
libsqlite3-dev \
|
||||
libssl-dev \
|
||||
libsystemd-dev \
|
||||
libtool \
|
||||
libunbound-dev \
|
||||
libunwind8-dev \
|
||||
libusb-1.0.0-dev \
|
||||
libuv1-dev \
|
||||
libzmq3-dev \
|
||||
lsb-release \
|
||||
make \
|
||||
nettle-dev \
|
||||
ninja-build \
|
||||
openssh-client \
|
||||
patch \
|
||||
pkg-config \
|
||||
python3-dev \
|
||||
qttools5-dev
|
@ -1,42 +0,0 @@
|
||||
ARG ARCH=amd64
|
||||
FROM ${ARCH}/ubuntu:rolling
|
||||
RUN /bin/bash -c 'echo "man-db man-db/auto-update boolean false" | debconf-set-selections'
|
||||
RUN apt-get -o=Dpkg::Use-Pty=0 -q update \
|
||||
&& apt-get -o=Dpkg::Use-Pty=0 -q dist-upgrade -y \
|
||||
&& apt-get -o=Dpkg::Use-Pty=0 --no-install-recommends -q install -y \
|
||||
automake \
|
||||
ccache \
|
||||
cmake \
|
||||
eatmydata \
|
||||
g++ \
|
||||
gdb \
|
||||
git \
|
||||
libboost-program-options-dev \
|
||||
libboost-serialization-dev \
|
||||
libboost-thread-dev \
|
||||
libcurl4-openssl-dev \
|
||||
libevent-dev \
|
||||
libgtest-dev \
|
||||
libhidapi-dev \
|
||||
libjemalloc-dev \
|
||||
libminiupnpc-dev \
|
||||
libreadline-dev \
|
||||
libsodium-dev \
|
||||
libsqlite3-dev \
|
||||
libssl-dev \
|
||||
libsystemd-dev \
|
||||
libtool \
|
||||
libunbound-dev \
|
||||
libunwind8-dev \
|
||||
libusb-1.0.0-dev \
|
||||
libuv1-dev \
|
||||
libzmq3-dev \
|
||||
lsb-release \
|
||||
make \
|
||||
nettle-dev \
|
||||
ninja-build \
|
||||
openssh-client \
|
||||
patch \
|
||||
pkg-config \
|
||||
python3-dev \
|
||||
qttools5-dev
|
@ -1,10 +0,0 @@
|
||||
ARG ARCH=amd64
|
||||
FROM registry.oxen.rocks/lokinet-ci-debian-bullseye/${ARCH}
|
||||
RUN apt-get -o=Dpkg::Use-Pty=0 --no-install-recommends -q install -y \
|
||||
ccache \
|
||||
debhelper \
|
||||
devscripts \
|
||||
equivs \
|
||||
git \
|
||||
git-buildpackage \
|
||||
python3-dev
|
@ -1,10 +0,0 @@
|
||||
ARG ARCH=amd64
|
||||
FROM registry.oxen.rocks/lokinet-ci-debian-sid/${ARCH}
|
||||
RUN apt-get -o=Dpkg::Use-Pty=0 --no-install-recommends -q install -y \
|
||||
ccache \
|
||||
debhelper \
|
||||
devscripts \
|
||||
equivs \
|
||||
git \
|
||||
git-buildpackage \
|
||||
python3-dev
|
@ -1,10 +0,0 @@
|
||||
ARG ARCH=amd64
|
||||
FROM registry.oxen.rocks/lokinet-ci-ubuntu-focal/${ARCH}
|
||||
RUN apt-get -o=Dpkg::Use-Pty=0 --no-install-recommends -q install -y \
|
||||
ccache \
|
||||
debhelper \
|
||||
devscripts \
|
||||
equivs \
|
||||
git \
|
||||
git-buildpackage \
|
||||
python3-dev
|
@ -1,10 +0,0 @@
|
||||
ARG ARCH=amd64
|
||||
FROM registry.oxen.rocks/lokinet-ci-ubuntu-impish/${ARCH}
|
||||
RUN apt-get -o=Dpkg::Use-Pty=0 --no-install-recommends -q install -y \
|
||||
ccache \
|
||||
debhelper \
|
||||
devscripts \
|
||||
equivs \
|
||||
git \
|
||||
git-buildpackage \
|
||||
python3-dev
|
@ -1,23 +0,0 @@
|
||||
ARG ARCH=amd64
|
||||
FROM registry.oxen.rocks/lokinet-ci-debian-testing-base/${ARCH}
|
||||
RUN /bin/bash -c 'sed -i "s/main/main contrib/g" /etc/apt/sources.list'
|
||||
RUN apt-get -o=Dpkg::Use-Pty=0 -q update \
|
||||
&& apt-get -o=Dpkg::Use-Pty=0 -q install --no-install-recommends -y \
|
||||
android-sdk \
|
||||
automake \
|
||||
ccache \
|
||||
cmake \
|
||||
curl \
|
||||
git \
|
||||
google-android-ndk-installer \
|
||||
libtool \
|
||||
make \
|
||||
openssh-client \
|
||||
patch \
|
||||
pkg-config \
|
||||
wget \
|
||||
xz-utils \
|
||||
zip \
|
||||
&& git clone https://github.com/Shadowstyler/android-sdk-licenses.git /tmp/android-sdk-licenses \
|
||||
&& cp -a /tmp/android-sdk-licenses/*-license /usr/lib/android-sdk/licenses \
|
||||
&& rm -rf /tmp/android-sdk-licenses
|
@ -1 +0,0 @@
|
||||
../00-debian-buster-base.dockerfile
|
@ -1 +0,0 @@
|
||||
../00-debian-stable-base.dockerfile
|
@ -1 +0,0 @@
|
||||
../10-debian-buster.dockerfile
|
@ -1 +0,0 @@
|
||||
../10-debian-stable.dockerfile
|
@ -1 +0,0 @@
|
||||
../00-debian-sid-base.dockerfile
|
@ -1 +0,0 @@
|
||||
../10-debian-sid.dockerfile
|
@ -1 +0,0 @@
|
||||
../40-debian-sid-debhelper.dockerfile
|
@ -1,7 +0,0 @@
|
||||
ARG ARCH=amd64
|
||||
FROM registry.oxen.rocks/lokinet-ci-debian-sid/${ARCH}
|
||||
RUN apt-get -o=Dpkg::Use-Pty=0 -q install --no-install-recommends -y \
|
||||
clang-13 \
|
||||
libc++-13-dev \
|
||||
libc++abi-13-dev \
|
||||
lld-13
|
@ -1,24 +0,0 @@
|
||||
ARG ARCH=amd64
|
||||
FROM registry.oxen.rocks/lokinet-ci-debian-testing-base/${ARCH}
|
||||
RUN apt-get -o=Dpkg::Use-Pty=0 -q install --no-install-recommends -y \
|
||||
autoconf \
|
||||
automake \
|
||||
build-essential \
|
||||
ccache \
|
||||
cmake \
|
||||
eatmydata \
|
||||
file \
|
||||
g++-mingw-w64-x86-64-posix \
|
||||
git \
|
||||
gperf \
|
||||
libtool \
|
||||
make \
|
||||
ninja-build \
|
||||
nsis \
|
||||
openssh-client \
|
||||
patch \
|
||||
pkg-config \
|
||||
qttools5-dev \
|
||||
zip \
|
||||
&& update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix \
|
||||
&& update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix
|
@ -1,7 +0,0 @@
|
||||
ARG ARCH=amd64
|
||||
FROM registry.oxen.rocks/lokinet-ci-android/${ARCH}
|
||||
RUN cd /opt \
|
||||
&& curl https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_2.2.2-stable.tar.xz \
|
||||
| tar xJv \
|
||||
&& ln -s /opt/flutter/bin/flutter /usr/local/bin/ \
|
||||
&& flutter precache
|
@ -1 +0,0 @@
|
||||
../00-debian-stable-base.dockerfile
|
@ -1 +0,0 @@
|
||||
../10-debian-stable.dockerfile
|
@ -1,7 +0,0 @@
|
||||
ARG ARCH=amd64
|
||||
FROM registry.oxen.rocks/lokinet-ci-debian-sid-base/${ARCH}
|
||||
RUN apt-get -o=Dpkg::Use-Pty=0 -q install --no-install-recommends -y \
|
||||
clang-format-11 \
|
||||
eatmydata \
|
||||
git \
|
||||
jsonnet
|
@ -1,17 +0,0 @@
|
||||
FROM node:14.16.1
|
||||
RUN /bin/bash -c 'echo "man-db man-db/auto-update boolean false" | debconf-set-selections'
|
||||
RUN apt-get -o=Dpkg::Use-Pty=0 -q update \
|
||||
&& apt-get -o=Dpkg::Use-Pty=0 -q dist-upgrade -y \
|
||||
&& apt-get -o=Dpkg::Use-Pty=0 -q install --no-install-recommends -y \
|
||||
ccache \
|
||||
cmake \
|
||||
eatmydata \
|
||||
g++ \
|
||||
gdb \
|
||||
git \
|
||||
make \
|
||||
ninja-build \
|
||||
openssh-client \
|
||||
patch \
|
||||
pkg-config \
|
||||
wine
|
@ -0,0 +1,350 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import subprocess
|
||||
import tempfile
|
||||
import optparse
|
||||
import sys
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
import threading
|
||||
|
||||
parser = optparse.OptionParser()
|
||||
parser.add_option("--no-cache", action="store_true",
|
||||
help="Run `docker build` with the `--no-cache` option to ignore existing images")
|
||||
parser.add_option("--parallel", "-j", type="int", default=1,
|
||||
help="Run up to this many builds in parallel")
|
||||
parser.add_option("--distro", type="string", default="",
|
||||
help="Build only this distro; should be DISTRO-CODE or DISTRO-CODE/ARCH, "
|
||||
"e.g. debian-sid/amd64")
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
registry_base = 'registry.oxen.rocks/lokinet-ci-'
|
||||
|
||||
distros = [*(('debian', x) for x in ('sid', 'stable', 'testing', 'bullseye', 'buster')),
|
||||
*(('ubuntu', x) for x in ('rolling', 'lts', 'impish', 'hirsute', 'focal', 'bionic'))]
|
||||
|
||||
if options.distro:
|
||||
d = options.distro.split('-')
|
||||
if len(d) != 2 or d[0] not in ('debian', 'ubuntu') or not d[1]:
|
||||
print("Bad --distro value '{}'".format(options.distro), file=sys.stderr)
|
||||
sys.exit(1)
|
||||
distros = [(d[0], d[1].split('/')[0])]
|
||||
|
||||
|
||||
manifests = {} # "image:latest": ["image/amd64", "image/arm64v8", ...]
|
||||
manifestlock = threading.Lock()
|
||||
|
||||
|
||||
def arches(distro):
|
||||
if options.distro and '/' in options.distro:
|
||||
arch = options.distro.split('/')
|
||||
if arch not in ('amd64', 'i386', 'arm64v8', 'arm32v7'):
|
||||
print("Bad --distro value '{}'".format(options.distro), file=sys.stderr)
|
||||
sys.exit(1)
|
||||
return [arch]
|
||||
|
||||
a = ['amd64', 'arm64v8', 'arm32v7']
|
||||
if distro[0] == 'debian' or distro == ('ubuntu', 'bionic'):
|
||||
a.append('i386') # i386 builds don't work on later ubuntu
|
||||
return a
|
||||
|
||||
|
||||
hacks = {
|
||||
registry_base + 'ubuntu-bionic-builder': """g++-8 \
|
||||
&& mkdir -p /usr/lib/x86_64-linux-gnu/pgm-5.2/include""",
|
||||
}
|
||||
|
||||
|
||||
failure = False
|
||||
|
||||
lineno = 0
|
||||
linelock = threading.Lock()
|
||||
|
||||
|
||||
def print_line(myline, value):
|
||||
linelock.acquire()
|
||||
global lineno
|
||||
if sys.__stdout__.isatty():
|
||||
jump = lineno - myline
|
||||
print("\033[{jump}A\r\033[K{value}\033[{jump}B\r".format(jump=jump, value=value), end='')
|
||||
sys.stdout.flush()
|
||||
else:
|
||||
print(value)
|
||||
linelock.release()
|
||||
|
||||
|
||||
def run_or_report(*args, myline):
|
||||
try:
|
||||
subprocess.run(
|
||||
args, check=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, encoding='utf8')
|
||||
except subprocess.CalledProcessError as e:
|
||||
with tempfile.NamedTemporaryFile(suffix=".log", delete=False) as log:
|
||||
log.write("Error running {}: {}\n\nOutput:\n\n".format(' '.join(args), e).encode())
|
||||
log.write(e.output.encode())
|
||||
global failure
|
||||
failure = True
|
||||
print_line(myline, "\033[31;1mError! See {} for details", log.name)
|
||||
raise e
|
||||
|
||||
|
||||
def build_tag(tag_base, arch, contents):
|
||||
if failure:
|
||||
raise ChildProcessError()
|
||||
|
||||
linelock.acquire()
|
||||
global lineno
|
||||
myline = lineno
|
||||
lineno += 1
|
||||
print()
|
||||
linelock.release()
|
||||
|
||||
with tempfile.NamedTemporaryFile() as dockerfile:
|
||||
dockerfile.write(contents.encode())
|
||||
dockerfile.flush()
|
||||
|
||||
tag = '{}/{}'.format(tag_base, arch)
|
||||
print_line(myline, "\033[33;1mRebuilding \033[35;1m{}\033[0m".format(tag))
|
||||
run_or_report('docker', 'build', '--pull', '-f', dockerfile.name, '-t', tag,
|
||||
*(('--no-cache',) if options.no_cache else ()), '.', myline=myline)
|
||||
print_line(myline, "\033[33;1mPushing \033[35;1m{}\033[0m".format(tag))
|
||||
run_or_report('docker', 'push', tag, myline=myline)
|
||||
print_line(myline, "\033[32;1mFinished build \033[35;1m{}\033[0m".format(tag))
|
||||
|
||||
latest = tag_base + ':latest'
|
||||
global manifests
|
||||
manifestlock.acquire()
|
||||
if latest in manifests:
|
||||
manifests[latest].append(tag)
|
||||
else:
|
||||
manifests[latest] = [tag]
|
||||
manifestlock.release()
|
||||
|
||||
|
||||
def base_distro_build(distro, arch):
|
||||
tag = '{r}{distro[0]}-{distro[1]}-base'.format(r=registry_base, distro=distro)
|
||||
codename = 'latest' if distro == ('ubuntu', 'lts') else distro[1]
|
||||
build_tag(tag, arch, """
|
||||
FROM {}/{}:{}
|
||||
RUN /bin/bash -c 'echo "man-db man-db/auto-update boolean false" | debconf-set-selections'
|
||||
RUN apt-get -o=Dpkg::Use-Pty=0 -q update \
|
||||
&& apt-get -o=Dpkg::Use-Pty=0 -q dist-upgrade -y \
|
||||
&& apt-get -o=Dpkg::Use-Pty=0 -q autoremove -y \
|
||||
{hacks}
|
||||
""".format(arch, distro[0], codename, hacks=hacks.get(tag, '')))
|
||||
|
||||
|
||||
def distro_build(distro, arch):
|
||||
prefix = '{r}{distro[0]}-{distro[1]}'.format(r=registry_base, distro=distro)
|
||||
fmtargs = dict(arch=arch, distro=distro, prefix=prefix)
|
||||
|
||||
# (distro)-(codename)-base: Base image from upstream: we sync the repos, but do nothing else.
|
||||
if (distro, arch) != (('debian', 'stable'), 'amd64'): # debian-stable-base/amd64 already built
|
||||
base_distro_build(distro, arch)
|
||||
|
||||
# (distro)-(codename)-builder: Deb builder image used for building debs; we add the basic tools
|
||||
# we use to build debs, not including things that should come from the dependencies in the
|
||||
# debian/control file.
|
||||
build_tag(prefix + '-builder', arch, """
|
||||
FROM {prefix}-base/{arch}
|
||||
RUN apt-get -o=Dpkg::Use-Pty=0 -q update \
|
||||
&& apt-get -o=Dpkg::Use-Pty=0 -q dist-upgrade -y \
|
||||
&& apt-get -o=Dpkg::Use-Pty=0 --no-install-recommends -q install -y \
|
||||
ccache \
|
||||
devscripts \
|
||||
equivs \
|
||||
g++ \
|
||||
git \
|
||||
git-buildpackage \
|
||||
openssh-client \
|
||||
{hacks}
|
||||
""".format(**fmtargs, hacks=hacks.get(prefix + '-builder', '')))
|
||||
|
||||
# (distro)-(codename): Basic image we use for most builds. This takes the -builder and adds
|
||||
# most dependencies found in our packages.
|
||||
build_tag(prefix, arch, """
|
||||
FROM {prefix}-builder/{arch}
|
||||
RUN apt-get -o=Dpkg::Use-Pty=0 -q update \
|
||||
&& apt-get -o=Dpkg::Use-Pty=0 -q dist-upgrade -y \
|
||||
&& apt-get -o=Dpkg::Use-Pty=0 --no-install-recommends -q install -y \
|
||||
automake \
|
||||
ccache \
|
||||
cmake \
|
||||
eatmydata \
|
||||
g++ \
|
||||
gdb \
|
||||
git \
|
||||
libboost-program-options-dev \
|
||||
libboost-serialization-dev \
|
||||
libboost-thread-dev \
|
||||
libcurl4-openssl-dev \
|
||||
libevent-dev \
|
||||
libgtest-dev \
|
||||
libhidapi-dev \
|
||||
libjemalloc-dev \
|
||||
libminiupnpc-dev \
|
||||
libreadline-dev \
|
||||
libsodium-dev \
|
||||
libsqlite3-dev \
|
||||
libssl-dev \
|
||||
libsystemd-dev \
|
||||
libtool \
|
||||
libunbound-dev \
|
||||
libunwind8-dev \
|
||||
libusb-1.0.0-dev \
|
||||
libuv1-dev \
|
||||
libzmq3-dev \
|
||||
lsb-release \
|
||||
make \
|
||||
nettle-dev \
|
||||
ninja-build \
|
||||
openssh-client \
|
||||
patch \
|
||||
pkg-config \
|
||||
pybind11-dev \
|
||||
python3-dev \
|
||||
python3-pip \
|
||||
python3-pybind11 \
|
||||
python3-pytest \
|
||||
python3-setuptools \
|
||||
qttools5-dev \
|
||||
{hacks}
|
||||
""".format(**fmtargs, hacks=hacks.get(prefix, '')))
|
||||
|
||||
|
||||
# Android and flutter builds on top of debian-stable-base and adds a ton of android crap; we
|
||||
# schedule this job as soon as the debian-sid-base/amd64 build finishes, because they easily take
|
||||
# the longest and are by far the biggest images.
|
||||
def android_builds():
|
||||
build_tag(registry_base + 'android', 'amd64', """
|
||||
FROM {r}debian-stable-base
|
||||
RUN /bin/bash -c 'sed -i "s/main/main contrib/g" /etc/apt/sources.list'
|
||||
RUN apt-get -o=Dpkg::Use-Pty=0 -q update \
|
||||
&& apt-get -o=Dpkg::Use-Pty=0 -q dist-upgrade -y \
|
||||
&& apt-get -o=Dpkg::Use-Pty=0 -q install --no-install-recommends -y \
|
||||
android-sdk \
|
||||
automake \
|
||||
ccache \
|
||||
cmake \
|
||||
curl \
|
||||
git \
|
||||
google-android-ndk-installer \
|
||||
libtool \
|
||||
make \
|
||||
openssh-client \
|
||||
patch \
|
||||
pkg-config \
|
||||
wget \
|
||||
xz-utils \
|
||||
zip \
|
||||
&& git clone https://github.com/Shadowstyler/android-sdk-licenses.git /tmp/android-sdk-licenses \
|
||||
&& cp -a /tmp/android-sdk-licenses/*-license /usr/lib/android-sdk/licenses \
|
||||
&& rm -rf /tmp/android-sdk-licenses
|
||||
""".format(r=registry_base))
|
||||
|
||||
build_tag(registry_base + 'flutter', 'amd64', """
|
||||
FROM {r}android
|
||||
RUN cd /opt \
|
||||
&& curl https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_2.2.2-stable.tar.xz \
|
||||
| tar xJv \
|
||||
&& ln -s /opt/flutter/bin/flutter /usr/local/bin/ \
|
||||
&& flutter precache
|
||||
""".format(r=registry_base))
|
||||
|
||||
|
||||
# lint is a tiny build (on top of debian-stable-base) with just formatting checking tools
|
||||
def lint_build():
|
||||
build_tag(registry_base + 'lint', 'amd64', """
|
||||
FROM {r}debian-stable-base
|
||||
RUN apt-get -o=Dpkg::Use-Pty=0 -q install --no-install-recommends -y \
|
||||
clang-format-11 \
|
||||
eatmydata \
|
||||
git \
|
||||
jsonnet
|
||||
""".format(r=registry_base))
|
||||
|
||||
|
||||
def nodejs_build():
|
||||
build_tag(registry_base + 'nodejs', 'amd64', """
|
||||
FROM node:14.16.1
|
||||
RUN /bin/bash -c 'echo "man-db man-db/auto-update boolean false" | debconf-set-selections'
|
||||
RUN apt-get -o=Dpkg::Use-Pty=0 -q update \
|
||||
&& apt-get -o=Dpkg::Use-Pty=0 -q dist-upgrade -y \
|
||||
&& apt-get -o=Dpkg::Use-Pty=0 -q install --no-install-recommends -y \
|
||||
ccache \
|
||||
cmake \
|
||||
eatmydata \
|
||||
g++ \
|
||||
gdb \
|
||||
git \
|
||||
make \
|
||||
ninja-build \
|
||||
openssh-client \
|
||||
patch \
|
||||
pkg-config \
|
||||
wine
|
||||
""")
|
||||
|
||||
|
||||
# Start debian-stable-base/amd64 on its own, because other builds depend on it and we want to get
|
||||
# those (especially android/flutter) fired off as soon as possible (because it's slow and huge).
|
||||
if ('debian', 'stable') in distros:
|
||||
base_distro_build(['debian', 'stable'], 'amd64')
|
||||
|
||||
executor = ThreadPoolExecutor(max_workers=max(options.parallel, 1))
|
||||
|
||||
if options.distro:
|
||||
jobs = []
|
||||
else:
|
||||
jobs = [executor.submit(b) for b in (android_builds, lint_build, nodejs_build)]
|
||||
|
||||
for d in distros:
|
||||
for a in arches(d):
|
||||
jobs.append(executor.submit(distro_build, d, a))
|
||||
while len(jobs):
|
||||
j = jobs.pop(0)
|
||||
try:
|
||||
j.result()
|
||||
except (ChildProcessError, subprocess.CalledProcessError):
|
||||
for k in jobs:
|
||||
k.cancel()
|
||||
|
||||
|
||||
if failure:
|
||||
print("Error(s) occured, aborting!", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
print("\n\n\033[32;1mAll builds finished successfully; pushing manifests...\033[0m\n")
|
||||
|
||||
|
||||
def push_manifest(latest, tags):
|
||||
if failure:
|
||||
raise ChildProcessError()
|
||||
|
||||
linelock.acquire()
|
||||
global lineno
|
||||
myline = lineno
|
||||
lineno += 1
|
||||
print()
|
||||
linelock.release()
|
||||
|
||||
subprocess.run(['docker', 'manifest', 'rm', latest], stderr=subprocess.DEVNULL, check=False)
|
||||
print_line(myline, "\033[33;1mCreating manifest \033[35;1m{}\033[0m".format(latest))
|
||||
run_or_report('docker', 'manifest', 'create', latest, *tags, myline=myline)
|
||||
print_line(myline, "\033[33;1mPushing manifest \033[35;1m{}\033[0m".format(latest))
|
||||
run_or_report('docker', 'manifest', 'push', latest, myline=myline)
|
||||
print_line(myline, "\033[32;1mFinished manifest \033[35;1m{}\033[0m".format(latest))
|
||||
|
||||
|
||||
for latest, tags in manifests.items():
|
||||
jobs.append(executor.submit(push_manifest, latest, tags))
|
||||
|
||||
while len(jobs):
|
||||
j = jobs.pop(0)
|
||||
try:
|
||||
j.result()
|
||||
except (ChildProcessError, subprocess.CalledProcessError):
|
||||
for k in jobs:
|
||||
k.cancel()
|
||||
|
||||
|
||||
print("\n\n\033[32;1mAll done!\n")
|
@ -1,44 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -o errexit
|
||||
|
||||
trap 'echo -e "\n\n\n\e[31;1mAn error occurred!\e[1m\n\n"' ERR
|
||||
|
||||
registry=registry.oxen.rocks
|
||||
|
||||
if [[ $# -eq 0 ]]; then
|
||||
files=(*.dockerfile i386/*.dockerfile arm64v8/*.dockerfile arm32v7/*.dockerfile)
|
||||
else
|
||||
files=("$@")
|
||||
fi
|
||||
|
||||
declare -A manifests
|
||||
|
||||
for file in "${files[@]}"; do
|
||||
if [[ "$file" == */* ]]; then
|
||||
arch="${file%%/*}"
|
||||
name="${file#*/}"
|
||||
else
|
||||
arch="amd64"
|
||||
name="$file"
|
||||
fi
|
||||
|
||||
name="${name#[0-9][0-9]-}" # s/^\d\d-//
|
||||
name="${name%.dockerfile}" # s/\.dockerfile$//
|
||||
namearch=$registry/lokinet-ci-$name/$arch
|
||||
latest=$registry/lokinet-ci-$name:latest
|
||||
echo -e "\e[32;1mrebuilding \e[35;1m$namearch\e[0m"
|
||||
docker build --pull -f $file -t $namearch --build-arg ARCH=$arch .
|
||||
docker push $namearch
|
||||
|
||||
manifests[$latest]="${manifests[$latest]} $namearch"
|
||||
done
|
||||
|
||||
for latest in "${!manifests[@]}"; do
|
||||
echo -e "\e[32;1mpushing new manifest for \e[33;1m$latest[\e[35;1m${manifests[$latest]} \e[33;1m]\e[0m"
|
||||
docker manifest rm $latest 2>/dev/null || true
|
||||
docker manifest create $latest ${manifests[$latest]}
|
||||
docker manifest push $latest
|
||||
done
|
||||
|
||||
echo -e "\n\n\n\e[32;1mAll done!\e[1m\n\n"
|
@ -1,312 +0,0 @@
|
||||
#include <catch2/catch.hpp>
|
||||
#include <crypto/crypto.hpp>
|
||||
#include <crypto/crypto_libsodium.hpp>
|
||||
#include <string_view>
|
||||
|
||||
#include <router_contact.hpp>
|
||||
#include <iwp/iwp.hpp>
|
||||
#include <util/meta/memfn.hpp>
|
||||
#include <messages/link_message_parser.hpp>
|
||||
#include <messages/discard.hpp>
|
||||
#include <util/time.hpp>
|
||||
|
||||
#include <net/net_if.hpp>
|
||||
#include "ev/ev.hpp"
|
||||
|
||||
#undef LOG_TAG
|
||||
#define LOG_TAG __FILE__
|
||||
|
||||
namespace iwp = llarp::iwp;
|
||||
namespace util = llarp::util;
|
||||
|
||||
/// make an iwp link
|
||||
template <bool inbound, typename... Args>
|
||||
static llarp::LinkLayer_ptr
|
||||
make_link(Args&&... args)
|
||||
{
|
||||
if (inbound)
|
||||
return iwp::NewInboundLink(std::forward<Args>(args)...);
|
||||
return iwp::NewOutboundLink(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
/// a single iwp link with associated keys and members to make unit tests work
|
||||
struct IWPLinkContext
|
||||
{
|
||||
llarp::RouterContact rc;
|
||||
llarp::IpAddress localAddr;
|
||||
llarp::LinkLayer_ptr link;
|
||||
std::shared_ptr<llarp::KeyManager> keyManager;
|
||||
llarp::LinkMessageParser m_Parser;
|
||||
llarp::EventLoop_ptr m_Loop;
|
||||
/// is the test done on this context ?
|
||||
bool gucci = false;
|
||||
|
||||
IWPLinkContext(std::string_view addr, llarp::EventLoop_ptr loop)
|
||||
: localAddr{std::move(addr)}
|
||||
, keyManager{std::make_shared<llarp::KeyManager>()}
|
||||
, m_Parser{nullptr}
|
||||
, m_Loop{std::move(loop)}
|
||||
{
|
||||
// generate keys
|
||||
llarp::CryptoManager::instance()->identity_keygen(keyManager->identityKey);
|
||||
llarp::CryptoManager::instance()->encryption_keygen(keyManager->encryptionKey);
|
||||
llarp::CryptoManager::instance()->encryption_keygen(keyManager->transportKey);
|
||||
|
||||
// set keys in rc
|
||||
rc.pubkey = keyManager->identityKey.toPublic();
|
||||
rc.enckey = keyManager->encryptionKey.toPublic();
|
||||
}
|
||||
|
||||
template <typename Func_t>
|
||||
void
|
||||
Call(Func_t work)
|
||||
{
|
||||
m_Loop->call_soon(std::move(work));
|
||||
}
|
||||
|
||||
bool
|
||||
HandleMessage(llarp::ILinkSession* from, const llarp_buffer_t& buf)
|
||||
{
|
||||
return m_Parser.ProcessFrom(from, buf);
|
||||
}
|
||||
|
||||
/// initialize link
|
||||
template <bool inbound>
|
||||
void
|
||||
InitLink(std::function<void(llarp::ILinkSession*)> established)
|
||||
{
|
||||
link = make_link<inbound>(
|
||||
keyManager,
|
||||
m_Loop,
|
||||
// getrc
|
||||
[&]() -> const llarp::RouterContact& { return rc; },
|
||||
// link message handler
|
||||
util::memFn(&IWPLinkContext::HandleMessage, this),
|
||||
// sign buffer
|
||||
[&](llarp::Signature& sig, const llarp_buffer_t& buf) {
|
||||
REQUIRE(llarp::CryptoManager::instance()->sign(sig, keyManager->identityKey, buf));
|
||||
return true;
|
||||
},
|
||||
// before connect
|
||||
nullptr,
|
||||
// established handler
|
||||
[established](llarp::ILinkSession* s, bool linkIsInbound) {
|
||||
REQUIRE(s != nullptr);
|
||||
REQUIRE(inbound == linkIsInbound);
|
||||
established(s);
|
||||
return true;
|
||||
},
|
||||
// renegotiate handler
|
||||
[](llarp::RouterContact newrc, llarp::RouterContact oldrc) {
|
||||
REQUIRE(newrc.pubkey == oldrc.pubkey);
|
||||
return true;
|
||||
},
|
||||
// timeout handler
|
||||
[&](llarp::ILinkSession*) {
|
||||
m_Loop->stop();
|
||||
FAIL("session timeout");
|
||||
},
|
||||
// session closed handler
|
||||
[](llarp::RouterID) {},
|
||||
// pump done handler
|
||||
[]() {},
|
||||
// do work function
|
||||
[l = m_Loop](llarp::Work_t work) { l->call_soon(work); });
|
||||
REQUIRE(link->Configure(
|
||||
m_Loop, llarp::net::LoopbackInterfaceName(), AF_INET, *localAddr.getPort()));
|
||||
|
||||
if (inbound)
|
||||
{
|
||||
// only add address info on the recipient's rc
|
||||
rc.addrs.emplace_back();
|
||||
REQUIRE(link->GetOurAddressInfo(rc.addrs.back()));
|
||||
}
|
||||
// sign rc
|
||||
REQUIRE(rc.Sign(keyManager->identityKey));
|
||||
REQUIRE(keyManager != nullptr);
|
||||
}
|
||||
};
|
||||
|
||||
using Context_ptr = std::shared_ptr<IWPLinkContext>;
|
||||
|
||||
/// run an iwp unit test after setup
|
||||
/// call take 2 parameters, test and a timeout
|
||||
///
|
||||
/// test is a callable that takes 5 arguments:
|
||||
/// 0) std::function<EventLoop_ptr(void)> that starts the iwp links and gives an event loop to call with
|
||||
/// 1) std::function<void(void)> that ends the unit test if we are done
|
||||
/// 2) std::function<void(void)> that ends the unit test right now as a success
|
||||
/// 3) client iwp link context (shared_ptr)
|
||||
/// 4) relay iwp link context (shared_ptr)
|
||||
///
|
||||
/// timeout is a std::chrono::duration that tells the driver how long to run the unit test for
|
||||
/// before it should assume failure of unit test
|
||||
template <typename Func_t, typename Duration_t = std::chrono::milliseconds>
|
||||
void
|
||||
RunIWPTest(Func_t test, Duration_t timeout = 10s)
|
||||
{
|
||||
// shut up logs
|
||||
llarp::LogSilencer shutup;
|
||||
// set up event loop
|
||||
auto loop = llarp::EventLoop::create();
|
||||
|
||||
llarp::LogContext::Instance().Initialize(
|
||||
llarp::eLogDebug, llarp::LogType::File, "stdout", "unit test", [loop](auto work) {
|
||||
loop->call_soon(work);
|
||||
});
|
||||
|
||||
// turn off bogon blocking
|
||||
auto oldBlockBogons = llarp::RouterContact::BlockBogons;
|
||||
llarp::RouterContact::BlockBogons = false;
|
||||
|
||||
// set up cryptography
|
||||
llarp::sodium::CryptoLibSodium crypto{};
|
||||
llarp::CryptoManager manager{&crypto};
|
||||
|
||||
// set up client
|
||||
auto initiator = std::make_shared<IWPLinkContext>("127.0.0.1:3001", loop);
|
||||
// set up server
|
||||
auto recipient = std::make_shared<IWPLinkContext>("127.0.0.1:3002", loop);
|
||||
|
||||
// function for ending unit test on success
|
||||
auto endIfDone = [initiator, recipient, loop]() {
|
||||
if (initiator->gucci and recipient->gucci)
|
||||
{
|
||||
loop->stop();
|
||||
}
|
||||
};
|
||||
// function to start test and give loop to unit test
|
||||
auto start = [initiator, recipient, loop]() {
|
||||
REQUIRE(initiator->link->Start());
|
||||
REQUIRE(recipient->link->Start());
|
||||
return loop;
|
||||
};
|
||||
|
||||
// function to end test immediately
|
||||
auto endTest = [loop] { loop->stop(); };
|
||||
|
||||
loop->call_later(timeout, [] { FAIL("test timeout"); });
|
||||
test(start, endIfDone, endTest, initiator, recipient);
|
||||
loop->run();
|
||||
llarp::RouterContact::BlockBogons = oldBlockBogons;
|
||||
}
|
||||
|
||||
/// ensure clients can connect to relays
|
||||
TEST_CASE("IWP handshake", "[iwp]")
|
||||
{
|
||||
RunIWPTest([](std::function<llarp::EventLoop_ptr(void)> start,
|
||||
std::function<void(void)> endIfDone,
|
||||
[[maybe_unused]] std::function<void(void)> endTestNow,
|
||||
Context_ptr alice,
|
||||
Context_ptr bob) {
|
||||
// set up initiator
|
||||
alice->InitLink<false>([=](auto remote) {
|
||||
REQUIRE(remote->GetRemoteRC() == bob->rc);
|
||||
alice->gucci = true;
|
||||
endIfDone();
|
||||
});
|
||||
// set up recipient
|
||||
bob->InitLink<true>([=](auto remote) {
|
||||
REQUIRE(remote->GetRemoteRC() == alice->rc);
|
||||
bob->gucci = true;
|
||||
endIfDone();
|
||||
});
|
||||
// start unit test
|
||||
auto loop = start();
|
||||
// try establishing a session
|
||||
loop->call([link = alice->link, rc = bob->rc]() { REQUIRE(link->TryEstablishTo(rc)); });
|
||||
});
|
||||
}
|
||||
|
||||
/// ensure relays cannot connect to clients
|
||||
TEST_CASE("IWP handshake reverse", "[iwp]")
|
||||
{
|
||||
RunIWPTest([](std::function<llarp::EventLoop_ptr(void)> start,
|
||||
[[maybe_unused]] std::function<void(void)> endIfDone,
|
||||
std::function<void(void)> endTestNow,
|
||||
Context_ptr alice,
|
||||
Context_ptr bob) {
|
||||
alice->InitLink<false>([](auto) {});
|
||||
bob->InitLink<true>([](auto) {});
|
||||
// start unit test
|
||||
auto loop = start();
|
||||
// try establishing a session in the wrong direction
|
||||
loop->call([link = bob->link, rc = alice->rc, endTestNow] {
|
||||
REQUIRE(not link->TryEstablishTo(rc));
|
||||
endTestNow();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/// ensure iwp can send messages between sessions
|
||||
TEST_CASE("IWP send messages", "[iwp]")
|
||||
{
|
||||
int aliceNumSent = 0;
|
||||
int bobNumSent = 0;
|
||||
RunIWPTest([&aliceNumSent, &bobNumSent](std::function<llarp::EventLoop_ptr(void)> start,
|
||||
std::function<void(void)> endIfDone,
|
||||
std::function<void(void)> endTestNow,
|
||||
Context_ptr alice,
|
||||
Context_ptr bob) {
|
||||
constexpr int numSend = 64;
|
||||
// when alice makes a session to bob send `aliceNumSend` messages to him
|
||||
alice->InitLink<false>([endIfDone, alice, &aliceNumSent](auto session) {
|
||||
for (auto index = 0; index < numSend; index++)
|
||||
{
|
||||
alice->Call([session, endIfDone, alice, &aliceNumSent]() {
|
||||
// generate a discard message that is 512 bytes long
|
||||
llarp::DiscardMessage msg;
|
||||
std::vector<byte_t> msgBuff(512);
|
||||
llarp_buffer_t buf(msgBuff);
|
||||
// add random padding
|
||||
llarp::CryptoManager::instance()->randomize(buf);
|
||||
// encode the discard message
|
||||
msg.BEncode(&buf);
|
||||
// send the message
|
||||
session->SendMessageBuffer(msgBuff, [endIfDone, alice, &aliceNumSent](auto status) {
|
||||
if (status == llarp::ILinkSession::DeliveryStatus::eDeliverySuccess)
|
||||
{
|
||||
// on successful transmit increment the number we sent
|
||||
aliceNumSent++;
|
||||
}
|
||||
// if we sent all the messages sucessfully we end the unit test
|
||||
alice->gucci = aliceNumSent == numSend;
|
||||
endIfDone();
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
bob->InitLink<true>([endIfDone, bob, &bobNumSent](auto session) {
|
||||
for (auto index = 0; index < numSend; index++)
|
||||
{
|
||||
bob->Call([session, endIfDone, bob, &bobNumSent]() {
|
||||
// generate a discard message that is 512 bytes long
|
||||
llarp::DiscardMessage msg;
|
||||
std::vector<byte_t> msgBuff(512);
|
||||
llarp_buffer_t buf(msgBuff);
|
||||
// add random padding
|
||||
llarp::CryptoManager::instance()->randomize(buf);
|
||||
// encode the discard message
|
||||
msg.BEncode(&buf);
|
||||
// send the message
|
||||
session->SendMessageBuffer(msgBuff, [endIfDone, bob, &bobNumSent](auto status) {
|
||||
if (status == llarp::ILinkSession::DeliveryStatus::eDeliverySuccess)
|
||||
{
|
||||
// on successful transmit increment the number we sent
|
||||
bobNumSent++;
|
||||
}
|
||||
// if we sent all the messages sucessfully we end the unit test
|
||||
bob->gucci = bobNumSent == numSend;
|
||||
endIfDone();
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
// start unit test
|
||||
auto loop = start();
|
||||
// try establishing a session from alice to bob
|
||||
loop->call([link = alice->link, rc = bob->rc, endTestNow]() {
|
||||
REQUIRE(link->TryEstablishTo(rc));
|
||||
});
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue