syncthing

package
v0.20.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 4, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

Package syncthing is Brigade's bundled sync adapter (plan folder-sync 4.4): `brigade sync-adapter syncthing <verb>`, one JSON request on stdin, one 4.3 result envelope on stdout, the verbs of the sync-adapter protocol (plan 4.3: describe, attach, apply, status, detach).

It drives a DEDICATED Syncthing instance per machine, never the user's own: its home is <state_dir>/sync/syncthing (0700), holding Syncthing's config.xml, certificate and index beside Brigade's book-keeping — daemon.pid, port, listen-port, lock, syncthing.log and one refs/<session_id> file per attached session (holding the pid of the session's watcher, so a reference whose process died is pruned). The first attach starts `syncthing serve` detached in its own session; the last detach shuts it down, so sync runs only while a session is active (plan section 1). Everything else — discovery, relays, transfer, conflicts, deletions, the trash can — is Syncthing's, with its defaults as they are (the owner's ruling of 2026-09-22: no options added) but one: the instance listens for peers on a port of its own (listen-port) instead of 22000, so it never shares a port with a Syncthing the person runs themselves.

This package is the ONE place Brigade starts a long-running daemon, which is why it has its own exec carve-out in .golangci.yml. The daemon is spawned as an argv array with the allow-listed environment of adapterkit.ChildEnv; its REST API is bound to 127.0.0.1 on a port Brigade picks, and the API key is read from config.xml on every call — never put on argv, never logged. Syncthing's response bodies are never logged either.

Nothing here imports internal/harness or internal/adapters: the harness reaches this package only across a process boundary, through the sync-adapter protocol (plan 4.3), exactly as it reaches an external `brigade-sync-<name>` adapter.

Index

Constants

View Source
const Name = "syncthing"

Name is the adapter's name: the `sync.adapter` value of .brigade.json that selects it, and the prefix the harness puts on its peer descriptor on the wire (`syncthing:<device id>`, plan 4.3).

View Source
const ProtocolVersion = "sync/1"

ProtocolVersion is the sync-adapter protocol this adapter speaks (plan 4.3). It is not the backend protocol's "1": the two protocols version independently.

Variables

This section is empty.

Functions

func Run

func Run(args []string, stdin io.Reader, stdout, stderr io.Writer, environ []string) int

Run executes one verb and returns its 4.6 exit status. It is the seam the `brigade sync-adapter syncthing` entry dispatches to: args are the words after the adapter name (the verb), and the streams and the environment are parameters so tests never touch the process's own. stdin must be the real os.Stdin from an entry point, for adapterkit.ReadInput's terminal refusal.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL