Browse Source

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
changes/30/729230/1
Gregory Thiemonge 2 years ago
parent
commit
6354f92ecc
  1. 14
      octavia/amphorae/backends/utils/udp_check.sh

14
octavia/amphorae/backends/utils/udp_check.sh

@ -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…
Cancel
Save