mirror of
https://github.com/dcarrillo/whatismyip.git
synced 2024-11-16 08:31:13 +00:00
3.1 KiB
3.1 KiB
What is my IP address
Just another "what is my IP address" service, including geolocation and headers information, written in go with high performance in mind, it uses gin which uses httprouter a lightweight high performance HTTP multiplexer.
Take a look at ifconfig.es a live site using whatismyip
Get your public IP easily from the command line:
curl ifconfig.es
127.0.0.1
curl -6 ifconfig.es
::1
Features
- TLS available
- Can run behind a proxy by trusting a custom header (usually
X-Real-IP
) to figure out the source IP address. - IPv4 and IPv6.
- Geolocation info including ASN. This feature is possible thanks to maxmind GeoLite2 databases. In order to use these databases, a -icense key is needed. Please visit Maxmind site for further instructions and get a free license.
- High performance
- HTML with templates, text plain and JSON output.
Endpoints
- https://ifconfig.es/
- https://ifconfig.es/json
- https://ifconfig.es/geo
- https://ifconfig.es/asn
- https://ifconfig.es/all
- https://ifconfig.es/headers
- https://ifconfig.es/<header_name>
Build
Golang >= 1.17 is required. Previous versions may work.
make build
Usage
Usage of ./whatismyip:
-bind string
Listening address (see https://pkg.go.dev/net?#Listen) (default ":8080")
-geoip2-asn string
Path to GeoIP2 ASN database
-geoip2-city string
Path to GeoIP2 city database
-template string
Path to template file
-tls-bind string
Listening address for TLS (see https://pkg.go.dev/net?#Listen)
-tls-crt string
When using TLS, path to certificate file
-tls-key string
When using TLS, path to private key file
-trusted-header string
Trusted request header for remote IP (e.g. X-Real-IP)
-version
Output version information and exit
Docker
An ultra-light (13MB) image is available.
Running a container locally using test databases
make docker-run
From Docker Hub
docker run --tty --interactive --rm \
-v $PWD/<path to city database>:/tmp/GeoIP2-City-Test.mmdb:ro \
-v $PWD/<path to ASN database>:/tmp/GeoLite2-ASN-Test.mmdb:ro -p 8080:8080 \
dcarrillo/whatismyip:latest \
-geoip2-city /tmp/GeoIP2-City-Test.mmdb \
-geoip2-asn /tmp/GeoLite2-ASN-Test.mmdb