1
0
Fork 0

idc changed a lot of files

This commit is contained in:
Arthur Khachaturov 2024-11-28 22:19:16 +03:00
parent 628baf3eea
commit 94d2955ab0
No known key found for this signature in database
GPG key ID: CAC2B7EB6DF45D55
31 changed files with 267 additions and 80 deletions

View file

@ -1,6 +1,21 @@
#!/bin/bash
API_ENDPOINT="http://ip-api.com/json/$1"'?fields=7876383'
printf "%s" "$(curl "${API_ENDPOINT}" 2>/dev/null)" | jq -r '[ "IP: \(.query)", "Country: \(.country)", "City: \(.city)", "ISP: \(.isp)", "ASN: \(.as)" ][] | "\(.)"'
get_stats() {
api_response=$(curl "${API_ENDPOINT}" 2>/dev/null)
ip=$(jq -r .query <<<"$api_response")
ptr="$(dig -x "$ip" | grep -A 1 'ANSWER SECTION' | grep -v 'ANSWER SECTION')"
jq -r '[ "IP: \(.query)", "Country: \(.country)", "City: \(.city)", "ISP: \(.isp)", "ASN: \(.as)" ][] | "\(.)"' <<<"$api_response"
[ -n "$ptr" ] && echo "PTR: $ptr"
}
if [ -t 0 ] && [ -t 1 ]; then
get_stats
elif [ -t 1 ]; then
notify-send -i /dev/null "Your IP address" "$(get_stats)"
else
curl -s ip.me
fi
# vim: ft=bash