Last active
March 2, 2020 21:54
-
-
Save francisco-perez-sorrosal/5da1dd83620d61407c27dae25a82b6b6 to your computer and use it in GitHub Desktop.
Netcat Webserver with config Serving Delay
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
PORT=${1:-8000} | |
SERVING_DELAY_SECS=${2:-10} | |
command -v pv >/dev/null 2>&1 || { echo >&2 "pv requied but not installed. Exiting..."; exit 1; } | |
cat <<EOF > /tmp/index.html | |
<!doctype html> | |
<html> | |
<body> | |
<h1>A webpage served by netcat</h1> | |
</body> | |
</html> | |
EOF | |
echo "Launching netcat Web Server in port $PORT with rate limit of $SERVING_DELAY_SECS secs" | |
while true; do pv --rate-limit $SERVING_DELAY_SECS /tmp/index.html | nc -l $PORT; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment