Fix netcat option in udp_check.sh for CentOS/RHEL
-w (timeout) option doesn't do anything in nmap-ncat (default netcat in CentOS/RHEL) for UDP datagrams, and nmap-ncat has a default idle timeout set to 2 seconds. We can get the same behavior as netcap-openbsd (Debian/Ubuntu) by setting that idle timeout (-i) option to 1 second. This commit detects the flavor of the netcat binary (nmap vs other) and uses it to adapt the parameters. Story: 2007688 Task: 39800 Change-Id: I0100aaa428477f011bd39a90dd4ec98199b4bebc
This commit is contained in:
parent
9a1d6d3585
commit
6354f92ecc
@ -1,4 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
nc_cmd=`which nc`
|
||||
$nc_cmd -uzv -w1 $1 $2 > /dev/null
|
||||
|
||||
nc_flavor=$($nc_cmd --version 2>&1 | grep -o nmap)
|
||||
case "$nc_flavor" in
|
||||
nmap)
|
||||
nc_flavor_opts="-i1"
|
||||
;;
|
||||
*) # default, probably openbsd
|
||||
nc_flavor_opts="-w1"
|
||||
;;
|
||||
esac
|
||||
|
||||
$nc_cmd -uzv $nc_flavor_opts $1 $2 > /dev/null
|
||||
exit $?
|
||||
|
Loading…
Reference in New Issue
Block a user