From bc9f481717861f2063b006498b04f43a95e58e22 Mon Sep 17 00:00:00 2001 From: skidoodle Date: Sun, 29 Sep 2024 17:58:21 +0200 Subject: [PATCH] Refactor IP data lookup with caching and enable gzip compression --- readme.md | 18 ++++++++++++ server.go | 84 +++++++++++++++++++++++++++++++++---------------------- 2 files changed, 69 insertions(+), 33 deletions(-) diff --git a/readme.md b/readme.md index ffd5ade..1617ecf 100644 --- a/readme.md +++ b/readme.md @@ -1,7 +1,9 @@ # ipinfo + `ipinfo` is a powerful and efficient IP information service written in Go. It fetches GeoIP data to provide detailed information about an IP address, including geographical location, ASN, and related network details. The service automatically updates its GeoIP databases to ensure accuracy and reliability. ## Features + - **IP Geolocation**: Provides city, region, country, continent, and coordinates for any IP address. - **ASN Information**: Includes autonomous system number and organization. - **Hostname Lookup**: Retrieves the hostname associated with the IP address. @@ -9,7 +11,9 @@ - **JSONP Support**: Allows JSONP responses for cross-domain requests. ## Example Endpoints + ### Get information about an IP address + ```sh $ curl https://ip.albert.lol/9.9.9.9 { @@ -25,14 +29,18 @@ $ curl https://ip.albert.lol/9.9.9.9 "loc": "37.8767,-122.2676" } ``` + ### Get specific information (e.g., city) about an IP address + ```sh $ curl https://ip.albert.lol/9.9.9.9/city { "city": "Berkeley" } ``` + ### Use JSONP callback function + ```sh $ curl https://test.albert.lol/9.9.9.9?callback=Quad9 /**/ typeof Quad9 === 'function' && Quad9({ @@ -48,6 +56,7 @@ $ curl https://test.albert.lol/9.9.9.9?callback=Quad9 "loc": "37.8767,-122.2676" }); ``` + ```html