From fa1f6d9945e2b5c80ad27a02514c966406fdb288 Mon Sep 17 00:00:00 2001 From: Midgard Date: Tue, 29 Oct 2024 14:37:11 +0100 Subject: [PATCH] Query flanagan.zeus.gent directly to avoid stale cached results --- buildlist | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/buildlist b/buildlist index fb2ef4c..b3feaad 100755 --- a/buildlist +++ b/buildlist @@ -1,15 +1,6 @@ #!/bin/bash -# This program is free software: you can redistribute it and/or modify it under the terms of the -# GNU Affero General Public License as published by the Free Software Foundation, either version 3 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License along with this program. -# If not, see . +FLANAGAN="5.75.131.131" source members.sh NUMGRP="${#MEMBERS[@]}" @@ -39,8 +30,7 @@ total_ipv4=0 total_ipv6=0 try_url() { - # Use shell redirection to send all output to /dev/null because cURL is noisy at times, even with --silent - wget -O/dev/null --timeout 3 "$1" "$2" &>/dev/null + curl --max-time 4 --connect-timeout 3 --resolve "*:443:$2" "$1" &>/dev/null } # Begin list of groups @@ -50,20 +40,24 @@ for i in "${MEMBERS[@]}"; do hostname="$i.user.zeus.gent" https="https://$hostname" + ipv4="" + ipv6="" dns_ipv4=false dns_ipv6=false has_ipv4=false has_ipv6=false - ipv4="no" - ipv6="no" + ipv4_report="no" + ipv6_report="no" # Fetch DNS records - dns="$(host "$hostname")" + dns="$(host "$hostname" "$FLANAGAN")" if printf '%s' "$dns" | grep -q "has address"; then dns_ipv4=true + ipv4="$(printf '%s' "$dns" | sed -En '/has address/{s/^.* address //p;q}')" fi if printf '%s' "$dns" | grep -q "has IPv6 address"; then dns_ipv6=true + ipv6="$(printf '%s' "$dns" | sed -En '/has IPv6 address/{s/^.* address //p;q}')" fi if [ $dns_ipv4 = false -a $dns_ipv6 = false ]; then @@ -71,11 +65,11 @@ for i in "${MEMBERS[@]}"; do fi # Try site over HTTPS - if try_url --inet4-only "$https"; then + if [ $dns_ipv4 = true ] && try_url "$https" "$ipv4"; then ((total_ipv4 ++)) has_ipv4=true fi - if try_url --inet6-only "$https"; then + if [ $dns_ipv6 = true ] && try_url "$https" "$ipv6"; then ((total_ipv6 ++)) has_ipv6=true fi @@ -85,14 +79,14 @@ for i in "${MEMBERS[@]}"; do ssltest="analyze" fi if [ "$has_ipv4" = true ]; then - ipv4="yes" + ipv4_report="yes" elif [ "$dns_ipv4" = true ]; then - ipv4="no HTTPS" + ipv4_report="no HTTPS" fi if [ "$has_ipv6" = true ]; then - ipv6="yes" + ipv6_report="yes" elif [ "$dns_ipv6" = true ]; then - ipv6="no HTTPS" + ipv6_report="no HTTPS" fi if [ "$has_ipv4" = true -o "$has_ipv6" = true ]; then @@ -100,7 +94,7 @@ for i in "${MEMBERS[@]}"; do else name="$i" fi - printf '\t%s%s%s%s\n' "$name" "$ipv4" "$ipv6" "$ssltest" >> "$TMPOUT" + printf '\t%s%s%s%s\n' "$name" "$ipv4_report" "$ipv6_report" "$ssltest" >> "$TMPOUT" done printf '\n' >> "$TMPOUT"