Skip to content
This repository has been archived by the owner on Aug 22, 2021. It is now read-only.

Commit

Permalink
not print null when IPv4 record is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
phlinhng committed Mar 8, 2021
1 parent 401363e commit 2d46b71
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/xwall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ checkIP() {
local resolvedIP4="$(curl -sSL https://cloudflare-dns.com/dns-query\?name\=$1\&type\=A -H 'accept: application/dns-json' | jq ".Answer[0].data" --raw-output)"

[ ! -z "${realIP4}" ] && printf "%s %s\n" "detected IPv4 address:" "${realIP4}" | writeLog >> $log_path
[ ! -z "${resolvedIP4}" ] && printf "%s %s\n" "found A record:" "${resolvedIP4}" | writeLog >> $log_path
([ ! -z "${resolvedIP4}" ] && [ "${resolvedIP4}" != "null" ]) && printf "%s %s\n" "found A record:" "${resolvedIP4}" | writeLog >> $log_path

if [[ "${realIP4}" == "${resolvedIP4}" ]]; then
echo "A record matched." | writeLog >> $log_path
Expand All @@ -149,7 +149,7 @@ checkIP() {
local realIP6="$(curl -sL ${ip6_api} -m 5)"
local resolvedIP6="$(curl -sSL https://cloudflare-dns.com/dns-query\?name\=$1\&type\=AAAA -H 'accept: application/dns-json' | jq ".Answer[0].data" --raw-output)"
[ ! -z "${realIP6}" ] && printf "%s %s\n" "detected IPv6 address:" "${realIP6}" | writeLog >> $log_path
[ ! -z "${resolvedIP6}" ] && printf "%s %s\n" "found AAAA record:" "${resolvedIP6}" | writeLog >> $log_path
([ ! -z "${resolvedIP6}" ] && [ "${resolvedIP6}" != "null" ]) && printf "%s %s\n" "found AAAA record:" "${resolvedIP6}" | writeLog >> $log_path
if [[ "${realIP6}" == "${resolvedIP6}" ]]; then
echo "AAAA record matched." | writeLog >> $log_path
return 0
Expand Down

0 comments on commit 2d46b71

Please sign in to comment.