From 66e4bf6279e49cc57e458edf9aaa79e76647cb31 Mon Sep 17 00:00:00 2001 From: zeus Date: Wed, 12 Jan 2022 17:54:40 +0200 Subject: [PATCH] EP --- install/usr/share/swarmlab.io/sec/swarmlab-sec | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/install/usr/share/swarmlab.io/sec/swarmlab-sec b/install/usr/share/swarmlab.io/sec/swarmlab-sec index 0f54800..873aa88 100755 --- a/install/usr/share/swarmlab.io/sec/swarmlab-sec +++ b/install/usr/share/swarmlab.io/sec/swarmlab-sec @@ -26,6 +26,20 @@ set -e + +function EPHEMERAL_PORT() { + LOW_BOUND=49152 + RANGE=16384 + while true; do + CANDIDATE=$[$LOW_BOUND + ($RANDOM % $RANGE)] + (echo "" >/dev/tcp/127.0.0.1/${CANDIDATE}) >/dev/null 2>&1 + if [ $? -ne 0 ]; then + echo $CANDIDATE + break + fi + done +} + DOCKERuser="docker" PACKAGES=$(cat <