1
0
mirror of https://github.com/byReqz/conn.git synced 2024-11-22 09:01:15 +00:00

add validate function

This commit is contained in:
Nils 2021-11-28 15:40:45 +01:00
parent acd564445e
commit 768479ca2f
Signed by: byreqz
GPG Key ID: 396A62D7D436749E

35
conn.sh
View File

@ -58,6 +58,7 @@ function prepare {
#check_update
get_args $@
set_argvars $args
validate $input
}
function get_args {
@ -81,6 +82,36 @@ function set_argvars {
if [[ $@ =~ -6 ]] || [[ $@ =~ --force-ipv6 ]];then
only6=true
fi
if [[ $@ =~ -4 ]] || [[ $@ =~ --force-ipv4 ]];then
only4=true
fi
if [[ $@ =~ -y ]] || [[ $@ =~ --yes ]];then
doportscan=true
fi
if [[ $@ =~ -n ]] || [[ $@ =~ --no ]];then
doportscan=false
fi
if [[ $@ =~ -s ]] || [[ $@ =~ --simple ]];then
simpleoutput=true
fi
if [[ $@ =~ -w ]] || [[ $@ =~ --wait ]];then
waitcheck=true
fi
if [[ $@ =~ -f ]] || [[ $@ =~ --fast ]];then
oscheck=false
fi
}
function validate {
for arg in $@; do
if $(ip route show "$arg" 2&> /dev/null);then
hosts="$hosts $arg"
elif $(nslookup "$arg" > /dev/null);then
hosts="$hosts $arg"
else
echo "invalid input: $arg"
fi
done
}
function main {
@ -88,8 +119,8 @@ function main {
}
if [[ -n $1 ]];then
prepare $@
main "$input"
prepare "$@"
main "$hosts"
elif [[ "$1" == "-u" ]];then
run_update
elif [[ "$1" == "-h" ]];then