mirror of
https://github.com/flynx/proxmox-utils.git
synced 2025-10-28 10:40:07 +00:00
added udp/tcp port tests...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
692d3aa4fe
commit
e62dea61e7
36
check-status
36
check-status
@ -22,6 +22,7 @@ case $1 in
|
||||
echo "Suage:"
|
||||
echo " `basename $0` URL ..."
|
||||
echo
|
||||
# XXX would be fun to make the docs dynamic...
|
||||
echo "Supported URL formats and schemes:"
|
||||
echo " http://<url>"
|
||||
echo " https://<url>"
|
||||
@ -55,6 +56,39 @@ source .pct-helpers
|
||||
declare -A HANDLERS
|
||||
|
||||
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Port
|
||||
#
|
||||
# tcp://<addr>:<port>
|
||||
# udp://<addr>:<port>
|
||||
#
|
||||
|
||||
HANDLERS[tcp]=check-port
|
||||
HANDLERS[udp]=check-port
|
||||
|
||||
check-port(){
|
||||
local udp=
|
||||
if [[ "${1:0:3}" == "udp" ]] ; then
|
||||
udp='u'
|
||||
fi
|
||||
local target=`sed \
|
||||
-e 's/^.*\s*\(tcp\|udp\):\/\///' \
|
||||
-e 's/^\s*//;s/\s*$//' \
|
||||
<<<$1`
|
||||
local port=`cut -sd ':' -f 2 <<<$target`
|
||||
port=${port:=80}
|
||||
target=`cut -d ':' -f 1 <<<$target`
|
||||
|
||||
local res=$(timeout $TIMEOUT nc -vz${udp} $target $port 2>&1)
|
||||
|
||||
if [[ "$res" =~ .*open$ ]] ; then
|
||||
echo ERROR
|
||||
else
|
||||
echo OK
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Proxmox lxc
|
||||
#
|
||||
@ -140,7 +174,7 @@ check-ovpn(){
|
||||
target=`cut -d ':' -f 1 <<<$target`
|
||||
|
||||
local res=$(echo -e "\x38\x01\x00\x00\x00\x00\x00\x00\x00" \
|
||||
| timeout $TIMEOUT nc -u 46.138.244.248 5555 \
|
||||
| timeout $TIMEOUT nc -u $target $port \
|
||||
| cat -v)
|
||||
|
||||
if [ -z $res ] ; then
|
||||
|
||||
@ -26,7 +26,7 @@ TMP_PASS_LEN=${TMP_PASS_LEN:=32}
|
||||
DFL_EMAIL=${DFL_EMAIL:=user@example.com}
|
||||
DFL_DOMAIN=${DFL_DOMAIN:=example.com}
|
||||
DFL_ID=${DFL_ID:=500}
|
||||
DFL_CTHOSTNAME=${DFL_CTHOSTNAME:=gate-test}
|
||||
DFL_CTHOSTNAME=${DFL_CTHOSTNAME:=gate}
|
||||
DFL_WAN_IP=${DFL_WAN_IP:=192.168.1.101/24}
|
||||
DFL_WAN_GATE=${DFL_WAN_GATE:=192.168.1.252}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user