From 735463d932a3fbfb3e9ca1ff5b1e89a23467c580 Mon Sep 17 00:00:00 2001 From: Keith Irwin Date: Sat, 2 Dec 2023 17:47:08 -0700 Subject: [PATCH] fix: :ambulance: Fix other call of axfr --- back/lib/ips_to_peers | 4 ++-- back/lib/ns_lookup_axfr | 3 +-- back/lib/ns_lookup_axfr_rdns4 | 26 ++++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 4 deletions(-) create mode 100755 back/lib/ns_lookup_axfr_rdns4 diff --git a/back/lib/ips_to_peers b/back/lib/ips_to_peers index 68161ec..1157108 100755 --- a/back/lib/ips_to_peers +++ b/back/lib/ips_to_peers @@ -13,7 +13,7 @@ source /etc/wagon/config format="${1}" # Perform AXFR lookup -res="$(/usr/lib/wagon/ns_lookup_axfr)" || exit 4 +res="$(/usr/lib/wagon/ns_lookup_axfr_rdns4)" || exit 4 # This should read from stdin # TODO: Run this loop in parallel @@ -25,7 +25,7 @@ while IFS= read -r line; do ipv4="${ipv4%%/*}" ipv6="${ipv6%%/*}" rev_ipv4="$(/usr/lib/wagon/ns_update_rev_ipv4 ${ipv4})" - domain=$(<<<"${res}" grep "^${rev_ipv4} name = " | cut -f1 | cut -d' ' -f3 | sed 's/\.$//') + domain="$(<<<"${res}" grep "^${rev_ipv4} name = " | cut -f1 | cut -d' ' -f3 | sed 's/\.$//')" case "${format}" in 'json') printf '{"domain":"%s","ipv4":"%s","ipv6":"%s","pubkey":"%s"},' \ "${domain}" "${ipv4}" "${ipv6}" "${pubkey}";; diff --git a/back/lib/ns_lookup_axfr b/back/lib/ns_lookup_axfr index 9aab4b0..3d0470d 100755 --- a/back/lib/ns_lookup_axfr +++ b/back/lib/ns_lookup_axfr @@ -13,8 +13,7 @@ source /etc/wagon/config -rev_ipv4="$(/usr/lib/wagon/ns_update_rev_ipv4 ${IPV4_HUB} | cut -f1 | cut -d'.' -f3-6)" -res="$(/usr/lib/wagon/ns_lookup_rdns "-query=axfr" "${rev_ipv4}")" +res="$(/usr/lib/wagon/ns_lookup_send "-query=axfr" "${TLD}.")" case $? in 0) printf '%s' "${res}"; exit 0;; 4) printf 'Domain for %s not found!\n' "${1}" >&2; exit 4;; diff --git a/back/lib/ns_lookup_axfr_rdns4 b/back/lib/ns_lookup_axfr_rdns4 new file mode 100755 index 0000000..67336c6 --- /dev/null +++ b/back/lib/ns_lookup_axfr_rdns4 @@ -0,0 +1,26 @@ +#!/bin/bash +# FILE: wagon:back/lib/ns_lookup_rxfr_rdns4 +# DESCRIPTION: Get all IPv4 rDNS records +# USAGE: ns_lookup_rxfr +# OUTPUT: The complete set of records for the IP range +# ERRORS: +# 3: Bad usage +# 4: Domain not found +# 5: Server down +# 6: nslookup not found +# 7: nslookup refused +# 8: nslookup error + +source /etc/wagon/config + +rev_ipv4="$(/usr/lib/wagon/ns_update_rev_ipv4 ${IPV4_HUB} | cut -f1 | cut -d'.' -f3-6)" +res="$(/usr/lib/wagon/ns_lookup_rdns "-query=axfr" "${rev_ipv4}")" +case $? in + 0) printf '%s' "${res}"; exit 0;; + 4) printf 'Domain for %s not found!\n' "${1}" >&2; exit 4;; + 5) printf 'Nameserver not available: %s\n' "${DNS_MASTER}" >&2; exit 5;; + 6) printf 'nslookup not installed!\n' >&2; exit 6;; + 8) printf 'nslookup threw an error!\n' >&2; exit 8;; + 9) printf 'nslookup refused AXFR request!\n' >&2; exit 7;; + *) printf 'Bad usage: %s %s\n' "${0}" "${@}" >&2; exit 3;; +esac