clone

every nostr nip as a chapter of an illustrated, early-2000s printed game manual

main
nip.guide / source-nips / 66.md
66.md 4.6K rendered
1NIP-662======34Relay Liveness Monitoring5-------------------------67`draft` `optional` `relay`89This NIP defines events for relay discovery and the announcement of relay monitors.1011## Relay Discovery Events1213`30166` relay discovery events document relay characteristics inferred either from a relay's [NIP 11](https://github.com/nostr-protocol/nips/blob/master/11.md) document, or via probing.1415Information corresponding to field in a relay's NIP 11 document MAY contradict actual values if monitors find that a different policy is implemented than is advertised.1617`content` MAY include the stringified JSON of the relay's NIP-11 informational document.1819The only required tag is the `d` tag, which MUST be set to the relay's [normalized](https://datatracker.ietf.org/doc/html/rfc3986#section-6) URL. For relays not accessible via URL, a hex-encoded pubkey MAY be used instead.2021Other tags include:2223- `rtt-open` - The relay's open round-trip time in milliseconds.24- `rtt-read` - The relay's read round-trip time in milliseconds.25- `rtt-write` - The relay's write round-trip time in milliseconds.26- `n` - The relay's network type. SHOULD be one of `clearnet`, `tor`, `i2p`, `loki`27- `T` - The relay type. Enumerated [relay type](https://github.com/nostr-protocol/nips/issues/1282) formatted as `PascalCase`, e.g. `PrivateInbox`28- `N` - NIPs supported by the relay29- `R` - Keys corresponding to requirements per [NIP 11](https://github.com/nostr-protocol/nips/blob/master/11.md)'s `limitations` array, including `auth`, `writes`, `pow`, and `payment`. False values should be specified using a `!` prefix, for example `!auth`.30- `t` - A topic associated with this relay31- `k` - Accepted and unaccepted kinds (false values prepended by `!`) 32- `g` - A [NIP-52](https://github.com/nostr-protocol/nips/blob/master/52.md) geohash3334Tags with more than one value should be repeated, rather than putting all values in a single tag, for example `[["t", "cats"], ["t", "dogs"]]`, rather than `[["t", "cats", "dogs"]]`.3536Example:3738```json39{40 "id": "<eventid>",41 "pubkey": "<monitor's pubkey>",42 "created_at": "<created_at [some recent date ...]>",43 "signature": "<signature>",44 "content": "<optional nip 11 document>",45 "kind": 30166,46 "tags": [47 ["d","wss://some.relay/"],48 ["n", "clearnet"],49 ["N", "40"],50 ["N", "33"],51 ["R", "!payment"],52 ["R", "auth"],53 ["g", "ww8p1r4t8"],54 ["l", "en", "ISO-639-1"],55 ["t", "nsfw" ],56 ["rtt-open", "234" ]57 ]58}59```6061## Relay Monitor Announcements6263Kind `10166` relay monitor announcements advertise the author's intent to publish `30166` events. This event is optional and is intended for monitors who intend to provide monitoring services at a regular and predictable frequency.6465Tags include:6667- `frequency` - The frequency in seconds at which the monitor publishes events.68- `timeout` (optional) - The timeout values for various checks conducted by a monitor. Index `1` is the monitor's timeout in milliseconds. Index `2` describes what test the timeout is used for. If no index `2` is provided, it is inferred that the timeout provided applies to all tests.69- `c` - a lowercase string describing the checks conducted by a monitor. Examples include `open`, `read`, `write`, `auth`, `nip11`, `dns`, and `geo`.70- `g` - [NIP-52](https://github.com/nostr-protocol/nips/blob/master/52.md) geohash tag7172Monitors SHOULD also publish a `kind 0` profile and a `kind 10002` relay selections event.7374Example:7576```json77{78 "id": "<eventid>",79 "pubkey": "<monitor's pubkey>",80 "created_at": "<created_at [some recent date ...]>",81 "signature": "<signature>",82 "content": "",83 "tags": [84 [ "timeout", "open", "5000" ],85 [ "timeout", "read", "3000" ],86 [ "timeout", "write", "3000" ],87 [ "timeout", "nip11", "3000" ],88 [ "frequency", "3600" ],89 [ "c", "ws" ],90 [ "c", "nip11" ],91 [ "c", "ssl" ],92 [ "c", "dns" ],93 [ "c", "geo" ]94 [ "g", "ww8p1r4t8" ]95 ]96}97```9899 ## Risk Mitigation 100 101 - Clients MUST NOT require `30166` events to function. Absence of monitoring data MUST NOT prevent relay connections.102 - A monitor may publish erroneous `30166` events, either by misconfiguration or malicious intent.103 - Clients SHOULD NOT trust a single source. Defenses include: web-of-trust filtering, querying multiple monitors, and discarding filter results if they would remove an unreasonable proportion of relays.