Syncthing Relay Integration Strategy

Audience: AI readers and technical staff. Working document defining the how, the why, and the steps to offer relay.btoven.net as a relay compatible with the Syncthing protocol — either by reusing the official strelaysrv binary, integrating it as a subprocess, or reimplementing the protocol in this project’s Rust code.

Status: Strategy / Research


1. Executive Summary

Syncthing relies on a network of community relays to forward end-to-end encrypted traffic when two devices cannot connect directly (symmetric NAT, firewalls, CGNAT). Any operator can run a relay and either:

  1. Use it privately (only its own instances), or
  2. Join the public pool and appear listed at https://relays.syncthing.net/ for any Syncthing user.

The current relay project (Rust) is a federated instance-directory network (Guestbook / OGBP), a different concept from the Syncthing relay. To be Syncthing-compatible we must expose the Syncthing relay v1 protocol (relay://).

RouteDescriptionEffortCompatibilityControl/Privacy
A. Official binaryRun strelaysrv (Go) as-isLow100%Low
B. Subprocess integrationEmbed strelaysrv, orchestrated by our Rust relayMedium100%Medium
C. ReimplementationImplement Syncthing relay v1 protocol in RustHighNeeds validationHigh

Recommendation: Route A in the short term (immediate compatibility); Route C as a medium/long-term evolution.


2. How the Syncthing Relay Works

2.1 strelaysrv

  • Written in Go. Listens on two ports: data :22067/tcp (TLS) and status :22070/tcp (HTTP).
  • On first start it generates its own TLS certificates and prints its device ID.

2.2 Relevant flags

FlagUsage
-listenData listen address (default :22067)
-ext-addressExternally advertised address (e.g. :443)
-status-srvStatus service (default :22070); empty = disabled
-poolsPools to join (default https://relays.syncthing.net/endpoint); empty = private
-global-rate / -per-session-rateRate limits
-network-timeout / -message-timeout / -ping-intervalTimeouts and keepalive
-keysDirectory for cert.pem/key.pem
-tokenShared secret (disables pools)
-provided-byProvider description

2.3 Relay v1 protocol

  • Client connects via TLS to relay://<host>:<port>/?id=<relayDeviceID>.
  • Protobuf messages: Ping/Pong, JoinRelayRequest, JoinSessionRequest, SessionInvitation, ConnectRequest, ConnectResponse, SessionLeft.
  • The relay never sees content (only forwards E2E-encrypted bytes). It does see: IPs, device IDs, and volume.

2.4 Client configuration

relay://<host|ip>[:port]/?id=<relay device ID>

With token:

relay://<host|ip>[:port]/?id=<relay device ID>&token=mySecretToken

2.5 The public pool (https://relays.syncthing.net/)

  • Self-announcement via -status-srv (JSON stats) and -pools.
  • No vetting/approval by the Syncthing project: listing is automatic if the relay works. The operator is responsible.

3. The Three Routes

Route A — Official binary

Pros: 100% compatibility, zero protocol maintenance, immediate pool join. Cons: a second Go service separate from our Rust stack; security control limited to flags.

Route B — Subprocess

Pros: 100% compatibility; our Rust relay orchestrates the lifecycle. Cons: still depends on the Go binary; orchestration complexity; limited fine-grained control.

Route C — Reimplementation in Rust

Pros: own code aligned with our infrastructure; full control. Cons: high effort and interop risk (exact protobuf, Syncthing-style TLS cert, device-ID computation); must also reimplement the status server for the pool.


4. Security & Privacy

  • A public relay knows IPs, device IDs, and volume/patterns; not content (E2E encryption).
  • Public risks: resource consumption by third parties, IP exposure, abuse/DoS, operational responsibility, metadata leakage.
  • Private risks: only useful for own instances; requires manual configuration.
  • Mitigations: TLS (inherent), rate limits, timeouts, token, isolation, minimal logs, observability, updates.
  • Recommended decision: start private (no -pools); promote to public only after validating sizing and a logs policy.

5. Deployment (Docker)

services:
  syncthing-relay:
    image: syncthing/relaysrv:latest
    restart: unless-stopped
    ports:
      - "22067:22067"
      - "22070:22070"
    command:
      - -listen=:22067
      - -status-srv=:22070
      - -pools=          # empty = private; remove to go public
      - -provided-by=BTOVEN NETWORK
      - -global-rate=52428800
      - -per-session-rate=10485760
      - -network-timeout=2m
      - -message-timeout=1m
      - -ping-interval=1m
    volumes:
      - syncthing-relay-data:/var/strelaysrv

6. References

  • https://docs.syncthing.net/users/strelaysrv.html
  • https://docs.syncthing.net/users/relaying.html
  • https://relays.syncthing.net/
  • https://github.com/syncthing/relaysrv