diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 14:11:00 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 14:11:00 +0000 |
commit | af754e596a8dbb05ed8580c342e7fe02e08b28e0 (patch) | |
tree | b2f334c2b55ede42081aa6710a72da784547d8ea /src/tests/tls/block.sh | |
parent | Initial commit. (diff) | |
download | freeradius-af754e596a8dbb05ed8580c342e7fe02e08b28e0.tar.xz freeradius-af754e596a8dbb05ed8580c342e7fe02e08b28e0.zip |
Adding upstream version 3.2.3+dfsg.upstream/3.2.3+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tests/tls/block.sh')
-rwxr-xr-x | src/tests/tls/block.sh | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/tests/tls/block.sh b/src/tests/tls/block.sh new file mode 100755 index 0000000..20d8bab --- /dev/null +++ b/src/tests/tls/block.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# +# Simple script blocking requests from proxy to home server +# +# This works only on Linux. It can be used to create random networking issues. + +if [ $UID -ne 0 ]; then + echo "Only 'root' can modify 'iptables' rules" + exit 1 +fi + +# avoid keep the server blocked +function trap_ctrlc () +{ + echo "Ctrl-C caught...performing clean up" + + iptables -D INPUT -p tcp --dport 2083 -j REJECT 1> /dev/null 2>&1 + exit 0 +} + +trap "trap_ctrlc" 2 + +MAXWAIT=5 +while true; do + _wait="$((RANDOM % MAXWAIT))" + + echo "(*) Blocking the port 2083 for ${_wait}s" + iptables -A INPUT -p tcp --dport 2083 -j REJECT + sleep $_wait + + echo "(*) Allowing the port 2083 for ${_wait}s" + iptables -D INPUT -p tcp --dport 2083 -j REJECT + sleep $_wait +done |