From 686dd511a6e580ab7b9381d38607d76ed883b4fa Mon Sep 17 00:00:00 2001 From: Laine Gholson Date: Sat, 31 Oct 2015 20:01:52 -0500 Subject: [PATCH 1/2] Add support for .local domains with avahi --- testssl.sh | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/testssl.sh b/testssl.sh index 69d1209..2669379 100755 --- a/testssl.sh +++ b/testssl.sh @@ -4389,6 +4389,13 @@ get_a_record() { local saved_openssl_conf="$OPENSSL_CONF" OPENSSL_CONF="" # see https://github.com/drwetter/testssl.sh/issues/134 + if [[ "$NODE" == *.local ]]; then + if which avahi-resolve &>/dev/null; then + ip4=$(filter_ip4_address $(avahi-resolve -4 -n $NODE 2>/dev/null | sed -E 's/\t/ /' | sed "s/^.*$NODE //")) + else + fatal "Local hostname given but no 'avahi-resolve' avaliable." + fi + fi if [[ -z "$ip4" ]]; then which dig &> /dev/null && \ ip4=$(filter_ip4_address $(dig +short -t a "$1" 2>/dev/null | sed '/^;;/d')) @@ -4414,7 +4421,13 @@ get_aaaa_record() { OPENSSL_CONF="" # see https://github.com/drwetter/testssl.sh/issues/134 if [[ -z "$ip6" ]]; then - if which host &> /dev/null ; then + if [[ "$NODE" == *.local ]]; then + if which avahi-resolve &>/dev/null; then + ip6=$(filter_ip6_address $(avahi-resolve -6 -n $NODE 2>/dev/null | sed -E 's/\t/ /' | sed "s/^.*$NODE //")) + else + fatal "Local hostname given but no 'avahi-resolve' avaliable." + fi + elif which host &> /dev/null ; then ip6=$(filter_ip6_address $(host -t aaaa "$NODE" | grep -v alias | grep -v "no AAAA record" | sed 's/^.*address //')) elif which dig &> /dev/null; then ip6=$(filter_ip6_address $(dig +short -t aaaa "$NODE" 2>/dev/null)) From 8c173764bdd117a75a32f1e9385e3f2018475574 Mon Sep 17 00:00:00 2001 From: Laine Gholson Date: Sun, 1 Nov 2015 10:40:44 -0600 Subject: [PATCH 2/2] Use 'awk' instead of 'sed -E' --- testssl.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testssl.sh b/testssl.sh index 2669379..f567750 100755 --- a/testssl.sh +++ b/testssl.sh @@ -4391,7 +4391,7 @@ get_a_record() { OPENSSL_CONF="" # see https://github.com/drwetter/testssl.sh/issues/134 if [[ "$NODE" == *.local ]]; then if which avahi-resolve &>/dev/null; then - ip4=$(filter_ip4_address $(avahi-resolve -4 -n $NODE 2>/dev/null | sed -E 's/\t/ /' | sed "s/^.*$NODE //")) + ip4=$(filter_ip4_address $(avahi-resolve -4 -n $NODE 2>/dev/null | awk '{ print $2 }')) else fatal "Local hostname given but no 'avahi-resolve' avaliable." fi @@ -4423,7 +4423,7 @@ get_aaaa_record() { if [[ -z "$ip6" ]]; then if [[ "$NODE" == *.local ]]; then if which avahi-resolve &>/dev/null; then - ip6=$(filter_ip6_address $(avahi-resolve -6 -n $NODE 2>/dev/null | sed -E 's/\t/ /' | sed "s/^.*$NODE //")) + ip6=$(filter_ip6_address $(avahi-resolve -6 -n $NODE 2>/dev/null | awk '{ print $2 }')) else fatal "Local hostname given but no 'avahi-resolve' avaliable." fi