Final cleanup of ips_to_peers_rxfr
parent
fd9d2201b1
commit
4df5874077
|
@ -27,6 +27,7 @@ format="${1}"
|
|||
res="$("${LIB_DIR:?}/ns_lookup_rxfr")" || exit 4
|
||||
|
||||
# This should read from stdin
|
||||
# TODO: Run this loop in parallel
|
||||
while IFS= read -r line; do
|
||||
printf 'Checking line %s.\n' "${line}"
|
||||
pubkey="$(<<<"${line}" cut -d ' ' -f1)"
|
||||
|
@ -35,5 +36,12 @@ while IFS= read -r line; do
|
|||
ipv6="$(<<<"${ips}" grep ':')"
|
||||
ipv4="${ipv4%%/*}"
|
||||
ipv6="${ipv6%%/*}"
|
||||
<<<"${res}" grep -B1 " ${ipv4}\| ${ipv6}" | sed '/--/d' | awk '{print $2}' | paste -d " " - - >>"${LOGFILE}"
|
||||
domain=$(<<<"${res}" grep -B1 " ${ipv4}" | sed '/--/d' | awk '{print $2}' | paste -d " " - - | awk '{print $1}')
|
||||
case "${format}" in
|
||||
'json') printf '{"domain":"%s","ipv4":"%s","ipv6":"%s","pubkey":"%s"},' \
|
||||
"${domain}" "${ipv4}" "${ipv6}" "${pubkey}";;
|
||||
'tsv') printf '%s\t%s\t%s\t%s\n' "${domain}" "${ipv4}" "${ipv6}" "${pubkey}";;
|
||||
*) printf 'ERROR! Invalid format for %s: %s\n' "${0}" "${format}" >>"${LOGFILE}"
|
||||
exit 5;
|
||||
esac
|
||||
done
|
||||
|
|
Loading…
Reference in New Issue