Skip to content
GitHubRSS

NIP-66: Relay Monitoring

NIP-66 defines a standard for relay monitoring events. BigBrotr implements six health tests and optionally publishes the results as Nostr events.

The Nip66 class in bigbrotr.nips.nip66 runs independent health tests, each producing a specific MetadataType:

Opens a WebSocket connection to the relay and measures the round-trip time in milliseconds. This indicates the relay’s responsiveness.

MetadataTypeNIP66_RTT
MeasuresWebSocket handshake duration (ms)
Network supportAll (clearnet, Tor, I2P, Lokinet)

Inspects the relay’s SSL/TLS certificate for validity, expiration, and issuer information.

MetadataTypeNIP66_SSL
MeasuresCertificate validity, expiration date, issuer chain
Network supportClearnet only (overlay networks use different transport)

Resolves the relay’s hostname and measures DNS resolution time.

MetadataTypeNIP66_DNS
MeasuresResolution time, IP addresses, DNSSEC status
Network supportClearnet only

Looks up the relay’s IP address in MaxMind GeoIP databases to determine geographic location.

MetadataTypeNIP66_GEO
MeasuresCountry, city, ASN, latitude/longitude
DependenciesMaxMind GeoLite2-City.mmdb

Identifies the relay’s Autonomous System (AS) number, ISP, and network prefix.

MetadataTypeNIP66_NET
MeasuresAS number, ISP name, network prefix
DependenciesMaxMind GeoLite2-ASN.mmdb

Sends an HTTP request to the relay’s URL and records the response status, headers, and redirect chain.

MetadataTypeNIP66_HTTP
MeasuresHTTP status code, headers, redirects
Network supportAll

When the Monitor is configured with Nostr keys, it publishes monitoring results as Nostr events:

A replaceable event containing the overall monitoring status for a relay. Each new publication replaces the previous one.

Kind 30166 — Parameterized Replaceable Relay Monitor

Section titled “Kind 30166 — Parameterized Replaceable Relay Monitor”

A parameterized replaceable event where the d tag identifies the relay. This enables clients to subscribe to monitoring data for specific relays.

{
"kind": 30166,
"tags": [
["d", "wss://relay.example.com"],
["rtt", "45"],
["ssl", "valid"],
["dns", "resolved"]
],
"content": "",
"created_at": 1700000000
}

Events are broadcast to configured relays using broadcast_events() from bigbrotr.utils.protocol.

Like NIP-11, all NIP-66 test methods never raise exceptions. Each test returns a result with logs.success indicating whether the test completed successfully. Failed tests produce no metadata — they are simply logged and skipped.

The Geo and Net tests require MaxMind GeoLite2 databases:

  • GeoLite2-City.mmdb — for geographic location
  • GeoLite2-ASN.mmdb — for network/ASN information

These are managed by the GeoReaders mixin in services/common/mixins.py, which handles database file loading and lifecycle management. Database paths are configured in the Monitor’s YAML config.