From 58347fdfe21315ad3ccc0bd7c4703a8ec7aae797 Mon Sep 17 00:00:00 2001 From: tdback Date: Wed, 4 Dec 2024 18:50:37 -0500 Subject: initial commit to new repo --- geoip | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 geoip (limited to 'geoip') diff --git a/geoip b/geoip new file mode 100755 index 0000000..4b4f521 --- /dev/null +++ b/geoip @@ -0,0 +1,24 @@ +#!/bin/sh + +# geoip: Locate an IP address in the world. Requires `jq`. + +API="http://ip-api.com/json" + +if [ "$#" -ne 1 ] || echo "$1" | grep -qvxP "(\d{1,3}\.){3}\d{1,3}"; then + echo "please provide a valid IP address" >&2 + exit 1 +fi + +curl -s "$API/$1" | + jq '{ + ip: .query, + isp: .isp, + org: .org, + country: .country, + regionName: .regionName, + city: .city, + zip: .zip, + lat: .lat, + lon: .lon, + timezone: .timezone, + }' -- cgit v1.2.3