A lightweight, self-hosted Looking Glass web API written in Go that allows users to run network diagnostic commands like ping
and mtr
(My Traceroute) on demand. Supports both streaming and non-streaming output modes.
- Run
ping
ormtr
to test connectivity from your server - Stream results in real-time using
NDJSON
- Validate IPv4 and domain targets
- Easy to deploy with Docker
- Written with
chi
and idiomatic Go
- Go 1.20+
- Docker (optional, for containerized deployment)
go build -o looking-glass
./looking-glass
docker build -t go-looking-glass .
docker run --rm -p 8080:8080 go-looking-glass
Ping a target.
Query Parameters:
Param | Description | Required | Example |
---|---|---|---|
target |
Domain or IPv4 to ping | ✅ | 8.8.8.8 |
streaming |
Enable streaming via NDJSON | ❌ | true or false |
Examples:
-
Non-streaming:
curl "http://localhost:8080/ping?target=8.8.8.8"
-
Streaming:
curl "http://localhost:8080/ping?target=8.8.8.8&streaming=true"
Run MTR (My Traceroute) with --raw
and 10 report cycles.
Query Parameters:
Param | Description | Required | Example |
---|---|---|---|
target |
Domain or IPv4 to trace | ✅ | google.com |
streaming |
Enable streaming via NDJSON | ❌ | true or false |
Examples:
-
Non-streaming:
curl "http://localhost:8080/mtr?target=google.com"
-
Streaming:
curl "http://localhost:8080/mtr?target=google.com&streaming=true"
- Uses Go's
os/exec
to runping
andmtr
- Parses the output line-by-line
- Sends back structured JSON or NDJSON if streaming
- Validates input to prevent command injection or malformed requests
- Validates IPv4 addresses and domain formats
- Does not support IPv6 (yet)
- Make sure to secure your deployment (e.g., with reverse proxy, auth, rate limiting)
- Go
- Chi Router
mtr
,ping
(must be installed in the container or host)
- Add IPv6 support
- WebSocket streaming support
- UI dashboard
Streaming Ping
{"type":"ping","seq":1,"rtt_ms":12.7}
{"type":"ping","seq":2,"rtt_ms":12.9}
Non-Streaming MTR
[
{"type":"hop","hop":1,"ip":"192.168.1.1"},
{"type":"ping","hop":1,"rtt":15,"cycle_id":1},
...
]
MIT License. Feel free to use and modify.