From fa60f128d638a6134ee06839ad0682512f6421b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Fri, 26 Sep 2014 16:07:29 +0200 Subject: [PATCH] Quit using "yes" in ssl-opt.sh with openssl It caused s_server to send an AppData record of 16Kb every millisecond or so, which destroyed readability of the proxy and client logs. --- programs/test/udp_proxy.c | 5 ++--- tests/ssl-opt.sh | 28 +++++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/programs/test/udp_proxy.c b/programs/test/udp_proxy.c index 47d72b0ef..110a7c753 100644 --- a/programs/test/udp_proxy.c +++ b/programs/test/udp_proxy.c @@ -367,13 +367,12 @@ static unsigned char dropped[2048] = { 0 }; void update_dropped( const packet *p ) { size_t id = p->len % sizeof( dropped ); - - ++dropped[id]; - const unsigned char *end = p->buf + p->len; const unsigned char *cur = p->buf; size_t len = ( ( cur[11] << 8 ) | cur[12] ) + 13; + ++dropped[id]; + /* Avoid counting single record twice */ if( len == p->len ) return; diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index 10fd04d49..f5949bf52 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -18,7 +18,7 @@ set -u : ${GNUTLS_CLI:=gnutls-cli} : ${GNUTLS_SERV:=gnutls-serv} -O_SRV="$OPENSSL_CMD s_server -cert data_files/server5.crt -key data_files/server5.key" +O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key" O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client" G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key" G_CLI="$GNUTLS_CLI" @@ -172,6 +172,28 @@ is_polar() { echo "$1" | grep 'ssl_server2\|ssl_client2' > /dev/null } +# openssl s_server doesn't have -www with DTLS +check_osrv_dtls() { + if echo "$SRV_CMD" | grep 's_server.*-dtls' >/dev/null; then + NEEDS_INPUT=1 + SRV_CMD="$( echo $SRV_CMD | sed s/-www// )" + else + NEEDS_INPUT=0 + fi +} + +# provide input to commands that need it +provide_input() { + if [ $NEEDS_INPUT -eq 0 ]; then + return + fi + + while true; do + echo "HTTP/1.0 200 OK" + sleep 1 + done +} + # has_mem_err has_mem_err() { if ( grep -F 'All heap blocks were freed -- no leaks are possible' "$1" && @@ -299,9 +321,9 @@ run_test() { # assume proxy starts faster than server fi + check_osrv_dtls echo "$SRV_CMD" > $SRV_OUT - # "yes" is for servers without -www (openssl with DTLS) - yes "HTTP/1.0 200 OK" | $SRV_CMD >> $SRV_OUT 2>&1 & + provide_input | $SRV_CMD >> $SRV_OUT 2>&1 & SRV_PID=$! wait_server_start