diff options
author | tdback <tyler@tdback.net> | 2024-12-04 18:50:37 -0500 |
---|---|---|
committer | tdback <tyler@tdback.net> | 2024-12-04 18:50:37 -0500 |
commit | 58347fdfe21315ad3ccc0bd7c4703a8ec7aae797 (patch) | |
tree | 393fe8d69962e070c522e889b672ee9e97a88207 /geoip |
initial commit to new repo
Diffstat (limited to 'geoip')
-rwxr-xr-x | geoip | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -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, + }' |