Skip to content

CLI: fedify relay command #510

@dahlia

Description

@dahlia

Background

The @fedify/relay package (introduced in Fedify 2.0.0) provides ActivityPub relay implementations supporting both Mastodon and LitePub protocols. However, to test or experiment with a relay server, developers currently need to write boilerplate code to set up the server, configure tunneling for external access, and handle storage.

The existing fedify inbox command demonstrates how a CLI tool can simplify federation testing by providing an ephemeral server with automatic tunneling. A similar fedify relay command would lower the barrier for developers who want to:

  • Test how their ActivityPub server interacts with relays
  • Experiment with relay protocols before implementing their own relay
  • Debug federation issues involving relay servers
  • Quickly spin up a relay for local development environments

Proposed feature

Add a new fedify relay command that starts an ActivityPub relay server with sensible defaults for development and testing.

Usage

Start a Mastodon-compatible relay with in-memory storage and automatic tunneling:

fedify relay --protocol mastodon

Start a LitePub-compatible relay with persistent SQLite storage (followers survive restarts):

fedify relay --protocol litepub --persistent ./relay.db

Start a relay that accepts subscriptions from a specific domain:

fedify relay --protocol mastodon --accept-follow '*@mastodon.social'

Start a relay that auto-approves all subscription requests:

fedify relay --protocol mastodon --accept-follow '*'

Full example with all options:

fedify relay \
  --protocol mastodon \
  --port 8000 \
  --name "My Test Relay" \
  --persistent ./relay.db \
  --accept-follow '*@mastodon.social' \
  --accept-follow '*@fosstodon.org'

Options

Option Short Description Default
--protocol <TYPE> -p Relay protocol: mastodon or litepub (required)
--persistent <PATH> SQLite database path for persistent storage (in-memory)
--port <PORT> -P Local server port 8000
--name <NAME> -n Display name of the relay actor "Fedify Relay"
--accept-follow <PATTERN> -a Auto-accept subscription requests matching pattern (can be specified multiple times; see fedify inbox) (reject all)
--no-tunnel -T Disable tunneling (local access only) false
--debug -d Enable debug logging false

Implementation notes

  • Tunneling via @hongminhee/localtunnel (consistent with fedify inbox)
  • MemoryKvStore by default; SqliteKvStore when --persistent is specified
  • Domain derived from tunnel URL automatically
  • Consider adding a web UI to monitor connected followers and relayed activities
  • Follow the --accept-follow pattern from fedify inbox for subscription approval

Related

  • @fedify/relay package
  • fedify inbox command (similar UX pattern)

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions