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:

Measures WebSocket latency in three phases: open (connection establishment), read (first message receipt), and write (message send acknowledgment). Each phase is timed independently. If any phase fails, subsequent phases are skipped (cascading failure).

MetadataTypeNIP66_RTT
MeasuresOpen/read/write latency in milliseconds (3-phase)
Network supportAll (clearnet, Tor, I2P, Lokinet)

Inspects the relay’s SSL/TLS certificate using a two-connection methodology. Captures certificate validity, expiration date, issuer chain, Subject Alternative Names (SANs), cipher suite, protocol version, and SHA-256 fingerprint.

MetadataTypeNIP66_SSL
MeasuresCertificate validity, expiration, issuer, SANs, cipher, fingerprint
Network supportClearnet only (overlay networks use different transport)

Resolves the relay’s hostname and collects DNS record types: A, AAAA, CNAME, NS, and PTR records with TTL values.

MetadataTypeNIP66_DNS
MeasuresA/AAAA/CNAME/NS/PTR records, TTL
Network supportClearnet only

Looks up the relay’s IP address in the MaxMind GeoLite2-City database to determine geographic location, including geohash (precision 9) and timezone.

MetadataTypeNIP66_GEO
MeasuresCountry, city, coordinates, timezone, geohash
DependenciesMaxMind GeoLite2-City.mmdb
Network supportClearnet only

Identifies the relay’s IPv4/IPv6 addresses, Autonomous System (AS) number, organization, and network ranges.

MetadataTypeNIP66_NET
MeasuresIP addresses, ASN, organization, network ranges
DependenciesMaxMind GeoLite2-ASN.mmdb
Network supportClearnet only

Captures the Server and X-Powered-By HTTP headers from the WebSocket upgrade response using trace hooks.

MetadataTypeNIP66_HTTP
MeasuresServer header, X-Powered-By header
Network supportAll

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

A replaceable event announcing the monitor’s capabilities, supported networks, and configuration. Each new publication replaces the previous one.

An ephemeral event containing individual health test results. Not stored long-term by relays.

A parameterized replaceable (addressable) event where the d tag identifies the relay. Contains aggregated health data per relay, enabling 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.