updating readme

This commit is contained in:
Jacob Haug 2023-10-04 12:01:09 -04:00
parent 3ad94767b0
commit d60343d31c
No known key found for this signature in database
GPG Key ID: 46EA1D5A70DC1AB5
1 changed files with 35 additions and 51 deletions

View File

@ -1,54 +1,52 @@
# echoip
![Build Status](https://github.com/mpolden/echoip/workflows/ci/badge.svg)
A simple service for looking up your IP address. This is the code that powers
https://ifconfig.co.
https://ip.level.io.
## Usage
Just the business, please:
```
$ curl ifconfig.co
$ curl ip.level.io
127.0.0.1
$ http ifconfig.co
$ http ip.level.io
127.0.0.1
$ wget -qO- ifconfig.co
$ wget -qO- ip.level.io
127.0.0.1
$ fetch -qo- https://ifconfig.co
$ fetch -qo- https://ip.level.io
127.0.0.1
$ bat -print=b ifconfig.co/ip
$ bat -print=b ip.level.io/ip
127.0.0.1
```
Country and city lookup:
```
$ curl ifconfig.co/country
$ curl ip.level.io/country
Elbonia
$ curl ifconfig.co/country-iso
$ curl ip.level.io/country-iso
EB
$ curl ifconfig.co/city
$ curl ip.level.io/city
Bornyasherk
$ curl ifconfig.co/asn
$ curl ip.level.io/asn
AS59795
$ curl ifconfig.co/asn-org
$ curl ip.level.io/asn-org
Hosting4Real
```
As JSON:
```
$ curl -H 'Accept: application/json' ifconfig.co # or curl ifconfig.co/json
$ curl -H 'Accept: application/json' ip.level.io # or curl ip.level.io/json
{
"city": "Bornyasherk",
"country": "Elbonia",
@ -63,7 +61,7 @@ $ curl -H 'Accept: application/json' ifconfig.co # or curl ifconfig.co/json
Port testing:
```
$ curl ifconfig.co/port/80
$ curl ip.level.io/port/80
{
"ip": "127.0.0.1",
"port": 80,
@ -76,44 +74,22 @@ between IPv4 and IPv6 lookup.
## Features
* Easy to remember domain name
* Fast
* Supports IPv6
* Supports HTTPS
* Supports common command-line clients (e.g. `curl`, `httpie`, `ht`, `wget` and `fetch`)
* JSON output
* ASN, country and city lookup using the MaxMind GeoIP database
* Port testing
* All endpoints (except `/port`) can return information about a custom IP address specified via `?ip=` query parameter
* Open source under the [BSD 3-Clause license](https://opensource.org/licenses/BSD-3-Clause)
- Easy to remember domain name
- Fast
- Supports IPv6
- Supports HTTPS
- Supports common command-line clients (e.g. `curl`, `httpie`, `ht`, `wget` and `fetch`)
- JSON output
- ASN, country and city lookup using the MaxMind GeoIP database
- Port testing
- All endpoints (except `/port`) can return information about a custom IP address specified via `?ip=` query parameter
- Open source under the [BSD 3-Clause license](https://opensource.org/licenses/BSD-3-Clause)
## Why?
* To scratch an itch
* An excuse to use Go for something
* Faster than ifconfig.me and has IPv6 support
## Building
Compiling requires the [Golang compiler](https://golang.org/) to be installed.
This package can be installed with:
`go install github.com/mpolden/echoip/...@latest`
For more information on building a Go project, see the [official Go
documentation](https://golang.org/doc/code.html).
## Docker image
A Docker image is available on [Docker
Hub](https://hub.docker.com/r/mpolden/echoip), which can be downloaded with:
`docker pull mpolden/echoip`
## [GeoIP](https://www.maxmind.com/en/geoip2-databases)/[GeoLite](https://dev.maxmind.com/geoip/geolite2-free-geolocation-data?) Database (MaxMind)
To utilise MaxMind [GeoIP](https://www.maxmind.com/en/geoip2-databases)/[GeoLite](https://dev.maxmind.com/geoip/geolite2-free-geolocation-data?) database to enhance the information provided to end users, you can download the relevant **binary** databases (`.mmdb` format) directly from MaxMind using the above links.
**Please Note**: This has only been tested using the free, GeoLite database.
- To scratch an itch
- An excuse to use Go for something
- Faster than ifconfig.me and has IPv6 support
### Usage
@ -124,16 +100,24 @@ Usage of echoip:
Size of response cache. Set to 0 to disable
-H value
Header to trust for remote IP, if present (e.g. X-Real-IP)
-P Enables profiling handlers
-S string
IP Stack API Key
-a string
Path to GeoIP ASN database
-c string
Path to GeoIP city database
-d string
Which database to use, 'ipstack' or 'geoip' (default "geoip")
-f string
Path to GeoIP country database
-h Use HTTPS for IP Stack ( only non-free accounts )
-l string
Listening address (default ":8080")
-p Enable port lookup
-r Perform reverse hostname lookups
-s Show sponsor logo
-t string
Path to template directory (default "html")
Path to template dir (default "html")
-x Enable security module for IP Stack ( must have security module, aka. non-free account. )
```