This commit is contained in:
pika 2025-07-05 13:32:29 +02:00
parent 84e0d3b4b4
commit a5528e68f4
2 changed files with 39 additions and 115 deletions

34
.zshrc
View file

@ -352,37 +352,3 @@ main() {
if check_root; then
main
fi
resolve() {
local quiet=false
if [[ "$1" == "-q" ]]; then
quiet=true
shift
fi
local ip="$1"
local server="$2"
local dig_out
dig_out=$(command dig +noall +answer -x "$ip" ${server:+@$server} 2>/dev/null)
local line ptr hostname time
line=$(grep 'PTR' <<<"$dig_out")
ptr=$(awk '{print $4}' <<<"$line")
time=$(awk '{print $2}' <<<"$dig_out")
hostname=$(awk '{print $5}' <<<"$line" | sed 's/\.$//')
if $quiet; then
[[ -n "$hostname" ]] && echo "$hostname"
return
fi
if [[ -n "$hostname" ]]; then
# ✅ resolved
printf "${BOLD}${GREEN}%s${NC} \033[1;90m%s${NC} \033[32m%s${NC} \033[2m%s ms${NC}\n" \
"$ptr" "$ip" "$hostname" "$time"
else
# ❌ not resolved
printf "❌ \033[1;31m%s${NC} \033[1;90m%s${NC} \033[1;31mNOT FOUND${NC} \033[2m%s ms\033[0m\n" \
"PTR" "$ip" "${time:-0}"
fi
}