Proxy Lasttest Skript

Version vom 1. Januar 2021, 21:19 Uhr von Andreas (Diskussion | Beiträge) (Textersetzung - „</source>“ durch „</syntaxhighlight>“)

Mit Hilfe dieses kleinen Skriptes kann man einen Proxy Server etwas unter Dampf stellen. Man muss lediglich eine Konfigurationsdatei erstellen in der Pro Zeile ein Webaufruf (URL) zu finden ist. Das Tool geht dann dieses Liste durch und öffnet via Proxy (-h und -p) diese URL.

proxy-lasttest.sh <source lang=bash>

  1. !/bin/bash
  2. Name: proxy-lasttest.sh
  3. Subscription: This script makes makes a proxy test
  4. by N. Vongeheur
  5. License:
  6. This program is free software: you can redistribute it and/or modify it
  7. under the terms of the GNU General Public License as published by the
  8. Free Software Foundation, either version 3 of the License, or (at your option)
  9. any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  12. or FITNESS FOR A PARTICULAR PURPOSE.
  13. Set the language

export LANG="en_US.UTF-8"

  1. Load the Pathes

export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

function usage() { echo " Usage:" echo " $(basename $0) -c COUNT -f /Path/to/url_file -h PROXY_HOST -p PROXY_PORT" echo "" echo " -c COUNT How often should the URLs be called" echo " -f /Path/to/url_file File with target URLs (One per line)" echo " -h PROXY_HOST Which Proxy to use" echo " -p PROXY_PORT Proxy Port" echo " -s Silent-Mode" exit 1 }

while getopts "c:f:p:h:s" opt do

       case ${opt} in

c) COUNT=${OPTARG} ;;

       f)      URLS=${OPTARG}

;; h) PROXY_HOST=${OPTARG} ;; p) PROXY_PORT=${OPTARG} ;; s) SILENT="-s" ;;

       *)      usage

;;

       esac

done

[ -z "$1" ] && usage

  1. [ -z ${COUNT} -o -z ${URLS} -o -z ${PROXY_HOST} -o -z ${PROXY_PORT} ] && usage

[ -n "${PROXY_HOST}" ] && PROXY_STRING="-x http://${PROXY_HOST}:${PROXY_PORT}"

for ((c=0; c<=${COUNT}; c++)) do cat ${URLS} | while read url do CHECK_OUT=$(curl -k ${SILENT} ${PROXY_STRING} ${url} | grep "The domain name does not exist") RC=$? [ -z "${CHECK_OUT}" -a "${RC}" = 1 -a -z "${SILENT}" ] && echo "${url} wurde erfolgreich aufgerufen" [ -n "${CHECK_OUT}" -o "${RC}" != 1 ] && echo "WARNING: ${url} wurde nicht erfolgreich aufgerufen" [ -z "${SILENT}" ] && echo "" done done

</syntaxhighlight>