Lightweight IP address detector which also provides some optional request metadata.
https://ip.skobk.in
- Go 69.9%
- Go Template 29.3%
- Dockerfile 0.8%
Go 1.25 → 1.27, golangci-lint v2.8 → v2.15, Alpine 3.20 → 3.24, matching the latest stable releases (go1.27.2, v2.15.0, 3.24.2). Build, vet, tests, and lint pass on the new toolchain. Co-Authored-By: GLM-5.3 Flash <noreply@z.ai> |
||
|---|---|---|
| .woodpecker | ||
| cmd/ip-detect | ||
| docs | ||
| internal | ||
| .dockerignore | ||
| .gitignore | ||
| .golangci.yml | ||
| Dockerfile | ||
| go.mod | ||
| go.sum | ||
| README.md | ||
Minimalistic IP detector
A tiny Go service that returns your remote address metadata in HTML, JSON, or plain text. It mirrors the old PHP utility while adding reverse DNS lookups, request logging, and a refreshed UI.
Requirements
- Go 1.27 or newer
Run locally
# Serve on the default :8080
go run ./cmd/ip-detect
# Override settings with environment variables
IPD_ADDR=":9090" \
IPD_TRUSTED_SUBNETS="10.0.0.0/8,192.168.0.0/16" \
go run ./cmd/ip-detect
Configuration
All knobs are exposed via environment variables prefixed with IPD_. Common options:
| Variable | Default | Purpose |
|---|---|---|
ADDR |
:8080 |
Bind address/port. |
READ_TIMEOUT / WRITE_TIMEOUT |
5s |
HTTP read/write limits. |
READ_HEADER_TIMEOUT |
5s |
Timeout for reading request headers. |
IDLE_TIMEOUT |
30s |
Keep-alive idle timeout. |
MAX_HEADER_BYTES |
1048576 |
Maximum request header size in bytes. |
SHUTDOWN_TIMEOUT |
10s |
Graceful shutdown timeout. |
TRUST_FORWARDED |
false |
Whether to honor X-Forwarded-For / X-Real-IP. |
TRUSTED_SUBNETS |
`` | Comma-separated CIDRs required to trust proxy headers (empty = trust every proxy when TRUST_FORWARDED is true). |
RESOLVE_PTR |
true |
Resolve PTR records for the detected IP. |
RESOLVE_TIMEOUT |
500ms |
Reverse DNS lookup timeout per request. |
INCLUDE_UA |
true |
Attach the User-Agent header to responses. |
INCLUDE_TS |
true |
Emit the current UTC timestamp. |
INCLUDE_CONNECTION |
true |
Include protocol/host/remote address connection data in responses (and HTML). |
INCLUDE_TLS |
true |
Include TLS session details in responses (and HTML). |
INCLUDE_PREFERENCES |
true |
Include client preference headers in responses (and HTML). |
INCLUDE_ORIGIN |
true |
Include origin context headers in responses (and HTML). |
INCLUDE_CLIENT_HINTS |
true |
Include User-Agent Client Hints in responses (and HTML). |
INCLUDE_PROXY |
false |
Include proxy-related headers in responses (and HTML) when enabled. |
INCLUDE_HEADERS |
false |
Include full request headers in responses (and HTML) when enabled. |
LOG_LEVEL |
info |
One of debug, info, warn, error. |
LOG_FORMAT |
text |
text or json output. |
Docker
Image
An Alpine-based multi-stage build is provided:
docker build -t skobkin/ip-detect .
docker run --rm -p 8080:8080 skobkin/ip-detect
Compose stack
You can find example stack here.
