From 71fbc87f32a7af87121afc3f7154577d6683636f Mon Sep 17 00:00:00 2001
From: Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>
Date: Sat, 12 Oct 2019 00:10:55 +0900
Subject: [PATCH] Add interop Dockerfile

---
 interop/Dockerfile      | 28 +++++++++++++++++++++++++++
 interop/run_endpoint.sh | 42 +++++++++++++++++++++++++++++++++++++++++
 interop/server.crt      | 13 +++++++++++++
 interop/server.key      |  5 +++++
 4 files changed, 88 insertions(+)
 create mode 100644 interop/Dockerfile
 create mode 100644 interop/run_endpoint.sh
 create mode 100644 interop/server.crt
 create mode 100644 interop/server.key

diff --git a/interop/Dockerfile b/interop/Dockerfile
new file mode 100644
index 00000000..30dde878
--- /dev/null
+++ b/interop/Dockerfile
@@ -0,0 +1,28 @@
+FROM martenseemann/quic-network-simulator-endpoint:latest
+
+RUN apt-get update && \
+    apt-get install -y \
+        git g++ make binutils autoconf automake autotools-dev libtool \
+	pkg-config libev-dev libjemalloc-dev \
+        libev4 libjemalloc2 ca-certificates mime-support && \
+    git clone --depth 1 -b openssl-quic-draft-23 https://github.com/tatsuhiro-t/openssl && \
+    cd openssl && ./config enable-tls1_3 --openssldir=/etc/ssl && make -j$(nproc) && make install_sw && cd .. && rm -rf openssl && \
+    git clone --depth 1 https://github.com/ngtcp2/nghttp3 && \
+    cd nghttp3 && autoreconf -i && \
+    ./configure --enable-lib-only && \
+    make -j$(nproc) && make install-strip && cd .. && rm -rf nghttp3 && \
+    git clone --depth 1 -b interop https://github.com/ngtcp2/ngtcp2 && \
+    cd ngtcp2 && autoreconf -i && \
+    ./configure && \
+    make -j$(nproc) && make install-strip && cp examples/server examples/client /usr/local/bin && cd .. && rm -rf ngtcp2 && \
+    strip /usr/local/lib/*.so.*.* /usr/local/lib/engines-*/*.so && \
+    rm -rf /usr/local/lib/libssl.so /usr/local/lib/libcrypto.so /usr/local/lib/libssl.a /usr/local/lib/libcrypto.a /usr/local/lib/pkgconfig/*ssl.pc /usr/local/include/openssl/* && \
+    apt-get -y purge git g++ make binutils autoconf automake autotools-dev libtool pkg-config \
+        libev-dev libjemalloc-dev && \
+    apt-get -y autoremove --purge && \
+    rm -rf /var/log/*
+
+COPY run_endpoint.sh .
+COPY server.key server.crt /etc/ngtcp2/
+RUN chmod +x run_endpoint.sh
+ENTRYPOINT [ "./run_endpoint.sh" ]
diff --git a/interop/run_endpoint.sh b/interop/run_endpoint.sh
new file mode 100644
index 00000000..a4861458
--- /dev/null
+++ b/interop/run_endpoint.sh
@@ -0,0 +1,42 @@
+#!/bin/bash
+
+# Set up the routing needed for the simulation
+/setup.sh
+
+# The following variables are available for use:
+# - ROLE contains the role of this execution context, client or server
+# - SERVER_PARAMS contains user-supplied command line parameters
+# - CLIENT_PARAMS contains user-supplied command line parameters
+
+case $TESTCASE in
+    handshake|transfer|retry|resumption|http3)
+	:
+	;;
+    *)
+	exit 127
+	;;
+esac
+
+LOG=/logs/log.txt
+
+if [ "$ROLE" == "client" ]; then
+    # Wait for the simulator to start up.
+    /wait-for-it.sh sim:57832 -s -t 30
+    CLIENT_ARGS="server 443 --download /downloads -s --no-quic-dump --no-http-dump"
+    if [ "$TESTCASE" == "resumption" ]; then
+	CLIENT_ARGS="$CLIENT_ARGS --session-file session.txt --tp-file tp.txt"
+	REQS=($REQUESTS)
+	REQUESTS=${REQS[0]}
+	/usr/local/bin/client $CLIENT_ARGS $REQUESTS $CLIENT_PARAMS &> $LOG
+	REQUESTS=${REQS[@]:1}
+	/usr/local/bin/client $CLIENT_ARGS $REQUESTS $CLIENT_PARAMS &> $LOG
+    else
+	/usr/local/bin/client $CLIENT_ARGS $REQUESTS $CLIENT_PARAMS &> $LOG
+    fi
+elif [ "$ROLE" == "server" ]; then
+    SERVER_ARGS="0.0.0.0 443 /etc/ngtcp2/server.key /etc/ngtcp2/server.crt -s -d /www"
+    if [ "$TESTCASE" == "retry" ]; then
+	SERVER_ARGS="$SERVER_ARGS -V"
+    fi
+    /usr/local/bin/server $SERVER_ARGS $SERVER_PARAMS &> $LOG
+fi
diff --git a/interop/server.crt b/interop/server.crt
new file mode 100644
index 00000000..24fc60c6
--- /dev/null
+++ b/interop/server.crt
@@ -0,0 +1,13 @@
+-----BEGIN CERTIFICATE-----
+MIICBzCCAa2gAwIBAgIUMJv04JRwEtfTelLSoNR8mJdeGh4wCgYIKoZIzj0EAwIw
+WTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoMGElu
+dGVybmV0IFdpZGdpdHMgUHR5IEx0ZDESMBAGA1UEAwwJbG9jYWxob3N0MB4XDTE5
+MTAxMDA4NTc0NFoXDTI5MTAwNzA4NTc0NFowWTELMAkGA1UEBhMCQVUxEzARBgNV
+BAgMClNvbWUtU3RhdGUxITAfBgNVBAoMGEludGVybmV0IFdpZGdpdHMgUHR5IEx0
+ZDESMBAGA1UEAwwJbG9jYWxob3N0MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE
+en0drEYCSocujcGDDu+vt1ApM/Hvw7iMNT7Si3A9kNh0Lgbu7fBU2ZO9yksDTHhx
+ylkI7L+Z9w4FuAHG6eDyYaNTMFEwHQYDVR0OBBYEFAcyYjlrrhiiwQTjxvx3f54M
+W+MPMB8GA1UdIwQYMBaAFAcyYjlrrhiiwQTjxvx3f54MW+MPMA8GA1UdEwEB/wQF
+MAMBAf8wCgYIKoZIzj0EAwIDSAAwRQIgPh11lGFYYS+UpNZ7sRvZ1FZ/W7li7xKH
+LkLiB8jd7aECIQDLYqC5JPKpyDAVz07CbYEQO0dOcTbbO2Gft4YBppzN0A==
+-----END CERTIFICATE-----
diff --git a/interop/server.key b/interop/server.key
new file mode 100644
index 00000000..ea486aca
--- /dev/null
+++ b/interop/server.key
@@ -0,0 +1,5 @@
+-----BEGIN EC PRIVATE KEY-----
+MHcCAQEEINjb/AOSYGqz7oYtO7/uXmUViMi5fECkCeBYYJedxYuyoAoGCCqGSM49
+AwEHoUQDQgAEen0drEYCSocujcGDDu+vt1ApM/Hvw7iMNT7Si3A9kNh0Lgbu7fBU
+2ZO9yksDTHhxylkI7L+Z9w4FuAHG6eDyYQ==
+-----END EC PRIVATE KEY-----
-- 
GitLab