Skip to content

Moderation & the connection log

This page shows how to let a moderator act on your server: who may moderate, what each action changes, and how the connection log ties a peer ID to an IP address for an abuse report.

/etc/ricochet/config.yaml
security:
moderators:
- 12D3KooWExampleTrustAndSafety...

security.moderators lists the peers that may use the moderation protocol, /ricochet/moderation/1.0.0. It is empty by default, so nobody may moderate. Every entry must parse as a peer ID, or the server stops at startup with moderators entry "..." is not a peer ID.

The server checks the caller before it reads the request: anyone not on the list gets a 403 with unauthorized: moderation requires a moderator. A moderator is usually the identity of the desk where someone reviews abuse reports. The list is separate from trusted peers: a moderator gets no forwarding or connection rights, and a trusted peer cannot moderate.

Operation What it does
ban Bans a peer, with an optional reason (cut to 500 characters)
unban Lifts a ban; says whether there was one
getBan Shows a peer’s ban, if it has one
listBans Lists every ban
removePost Removes one microblog post by its id (see below)
connections Reads a peer’s connection log

Each request is one JSON frame with an operation:

{"operation": "ban", "peerId": "12D3KooW...", "reason": "spam"}

A moderator cannot be banned: the server refuses with a moderator cannot be banned. The fields of every operation are on Protocol IDs.

A ban takes a peer off your server without deleting anything of theirs:

  • Its connections close, and the server never dials it again, so the relay and push notifications do not reach it on their own.
  • It may still connect, to learn why. A banned peer reaches only the Ricochet protocols, plus identify and ping. Streams on anything else (the DHT, GossipSub, the relay) are reset. On the Ricochet protocols, every request gets a 403 with unauthorized: banned: a moderator banned this peer; only its trust-safety folder can be read, except three: retrieving from its own trust-safety folder, marking messages there delivered, and deleting its own messages. That folder is where a moderation desk leaves the peer its ban notice.
  • Its directory listing is removed. An unban does not put it back; the peer lists itself again with a new directory join.
  • Its documents, feeds and collections are hidden from everyone else, whatever their visibility. Lists answer empty and reads get the ordinary private-resource refusal, which says nothing about the ban. Nothing is deleted, so an unban shows them again.

Bans are kept in the peer_bans table and loaded at startup, so they outlast a restart. The startup log says how many: moderation with moderators and bans counts.

A ban is for taking someone off your server, not for capping abuse: a new peer ID costs nothing to make. Rate limits and admission control do that job; see Admission & rate limits.

removePost takes the author’s peerId and the post’s postId, and follows the microblog layout the OverNode app uses:

  • the post is an entry in the author’s feed microblog, and its replies are in the author’s feed microblog/threads/<postId>;
  • its images are documents microblog/media/<postId>-img<N>.

It removes the post’s entry, with the author’s own edits, deletes, reactions and boosts of it; a reply’s entry in the thread it is in; the post’s replies thread, when the post started one; and its images. It touches nothing else of anyone else’s. The answer says how many entries, which feeds, whether the thread went and how many images. When nothing matched, it answers 404 with no post <postId> by <peerId> here.

An app with another layout gets nothing from removePost; ban the peer instead.

Every moderator action is logged at WARN with the moderator’s peer ID, reads of the connection log included, so the server log shows who did what:

Log message When
moderation: peer banned A ban, with target and reason
moderation: peer unbanned An unban, with was_banned
moderation: post removed A post removal, with what went
moderation: connection log read A connection log lookup, with the peer looked up

The server records every connection, in and out:

Field What
peerId The peer
ip The IP it came from, or the host name of a DNS address
remoteAddr The remote multiaddr
transport udx, tcp, quic-v1, ws, …
direction inbound or outbound
connectedAt, disconnectedAt When it opened and closed

It exists so that an abuse report can tie a peer ID to an IP address at a time. Once a connection closes, nothing else on the server remembers where it came from.

disconnectedAt is empty while the connection is open, and when the server stopped without seeing it close.

/etc/ricochet/config.yaml
audit:
connection_log_days: 90

The log is on by default and keeps rows for 90 days. Once an hour the server deletes older rows and logs connection log purged with the count. 0 turns the log off: nothing is recorded or purged, and startup logs connection log off (audit.connection_log_days is 0). A negative value stops the server at startup.

Recording never slows a connection: events wait in a queue of 4096 and one goroutine writes them. If the database falls behind and the queue fills, events are dropped and the server logs connection log queue full; events dropped. A failed write logs, at most once a minute, connection not logged (run schema.sql if peer_connections is missing).

Only moderators read it, with the connections operation:

{"operation": "connections", "peerId": "12D3KooW...", "since": "2026-10-01T00:00:00Z", "limit": 500}

since (RFC 3339) and limit (default 500, at most 2000) are optional. The answer lists the peer’s connections newest first, and the retention in force (0 when the log is off):

{"success": true, "retentionDays": 90, "connections": [
{"peerId": "12D3KooW...", "ip": "203.0.113.7", "remoteAddr": "/ip4/203.0.113.7/udp/55223/udx",
"transport": "udx", "direction": "inbound",
"connectedAt": "2026-10-16T09:12:03Z", "disconnectedAt": null}]}
  1. Run the release’s schema.sql on your database. It creates peer_bans and peer_connections; see Upgrades & draining. Without them the server still starts, logs bans not loaded; run schema.sql to create peer_bans, refuses every ban, and logs a warning for each connection it fails to record.
  2. Add your moderation desk’s peer ID to security.moderators, and restart.
  3. Decide audit.connection_log_days.
  4. Check the startup log for moderation with the moderator count, and connection log on with the retention.

Moderation requests appear as moa in the protocol label of the request metrics. The protocol has no rate limit.