- Go 89.6%
- HTML 4.6%
- Shell 3.1%
- CSS 2.5%
- JavaScript 0.1%
|
All checks were successful
CI / build (push) Successful in 11m29s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|---|---|---|
| .forgejo/workflows | ||
| cmd | ||
| docs/screenshots | ||
| internal | ||
| scripts | ||
| .dockerignore | ||
| .gitignore | ||
| CHANGELOG.md | ||
| config.example.conf | ||
| docker-compose.yml | ||
| Dockerfile | ||
| go.mod | ||
| go.sum | ||
| LICENSE | ||
| Makefile | ||
| README.md | ||
| todo.md | ||
GoThread
A lightweight, spec-compliant threadiverse (Reddit-like) server that federates over ActivityPub. One static Go binary, one SQLite file, a built-in server- rendered UI — self-host in minutes.
GoThread speaks standard ActivityStreams 2.0 types and interops with the threadiverse: it is smoke-tested round-trip against Lemmy (follow, post, comment, vote, private messages and moderation both directions).
Screenshots show data generated by cmd/seed; every remote host is a fictional .test domain.
Features
- Full local forum — communities, posts, comments with threaded sorting (active/hot/new/top/controversial + time windows), votes, markdown-lite (including spoiler blocks), full-text search (global or scoped to a community and/or hashtag), community flairs, user flairs (self-asserted labels shown beside an author's name), post hashtags with per-community tag filtering and a sidebar tag cloud, crossposts grouped by shared link, RSS, pagination, profiles, notifications (mentions/replies/participation), private multireddit lists, NSFW communities.
- Lemmy-compatible client API —
/api/v3(site, communities, posts, comments, users, search) in Lemmy's JSON shapes, so threadiverse apps can browse an instance. Apps log in for a bearer token, and users can create personal API tokens in settings. Writing through the API is not supported yet. - Media hosting — images and video uploads stored in the same SQLite file,
served with
Rangesupport. - Hand-rolled ActivityPub — AS2 vocab with tolerant decode, HTTP signatures (sign RSA, verify RSA + Ed25519), WebFinger, NodeInfo, inbox/outbox, fetch-by-ID, and a delivery queue with retries, backoff and idempotent dedup.
- Moderation — removes/restores, deletes, pins, locks, reports and a mod
log, personal blocks, community bans and instance allow/blocklists. Cross-
instance moderation works: bans propagate to remote instances and remote
Lemmy
ModBanFromCommunityevents are enforced locally. - Admin — rename the instance, toggle registration open/closed with invite links, a federation-health dashboard (queue depth, failures, replay), and single-file backups.
- Email (optional) — SMTP-verified accounts and password resets. With a mail server configured, new accounts must confirm their email before signing in, email changes are staged until verified, unconfirmed registrations are purged after 7 days, and forgotten passwords get a one-time reset link.
Requirements
Go 1.26.10+ (or 1.27.3+) to build. Runtime is a single static binary (no cgo, no external
services); modernc.org/sqlite is the only dependency.
A server does not need Go at all: pushing a version tag (v1.5.0, …) runs the
release workflow, which tests the tagged commit and uploads static
linux/amd64 and linux/arm64 binaries (with SHA256SUMS) as the
gothread-<tag>-linux artifact on the run's page.
scripts/update.sh installs the newest of those builds in one step: it
downloads the latest successful release artifact, checks it against
SHA256SUMS, and installs the binary for the machine's architecture (amd64 or
arm64), keeping the previous one as gothread.old. It only needs curl,
unzip and sha256sum, and does nothing when the binary is already current.
Pre-releases (tags like v1.7.0-beta.1) are skipped unless GOTHREAD_TAG
names one.
scripts/update.sh /opt/gothread/gothread # default: ./gothread
systemctl restart gothread # or however the service runs
# Install a specific tag instead, pre-releases included:
GOTHREAD_TAG=v1.7.0-beta.1 scripts/update.sh /opt/gothread/gothread
Quick start
On a Linux server (amd64 or arm64):
curl -fsSL https://git.jimmy-b.se/JimBer110/GoThread/raw/branch/master/scripts/setup.sh | sudo bash
scripts/setup.sh asks for the domain, instance name, port, registration mode
and optional SMTP settings, writes /opt/gothread/gothread.conf, installs
update.sh next to it and uses it to download the newest stable release.
Run as root on a systemd machine, it also installs and starts a gothread
service running as its own user. GoThread serves plain HTTP on 127.0.0.1, so
put an HTTPS reverse proxy in front of it; the script ends with a Caddy
example. Without sudo it installs into ~/gothread and skips the service.
To read the script before running it, or to answer its questions ahead (the
GOTHREAD_* variables are listed at its top):
curl -fsSLO https://git.jimmy-b.se/JimBer110/GoThread/raw/branch/master/scripts/setup.sh
less setup.sh
sudo GOTHREAD_DOMAIN=forum.example bash setup.sh
From source
go build -o gothread ./cmd/server
./gothread
The defaults are https on 127.0.0.1:8040 with a forum_like.db next to the
binary. For local development over plain HTTP:
./gothread -scheme http -domain 127.0.0.1:8040
For a real instance, copy the example config and edit it:
cp config.example.conf my.conf
# edit my.conf (set DOMAIN, INSTANCE_NAME, SMTP_*, etc.)
./gothread -config my.conf
The config file is KEY = value lines with comments; see
config.example.conf for every key and its default.
- The first registered account becomes the instance admin.
- Register a community, then post — no further setup required.
- Check
./gothread --helpfor every flag, or hit/healthzfor a health check.
Docker
docker build -t gothread .
docker run -p 8040:8040 -e FORUM_LIKE_DOMAIN=forum.example -v gothread-data:/app/data gothread
Configuration
Precedence: defaults < config file < environment < flags. Env vars are
FORUM_LIKE_*; the config file is KEY = value lines (see --help for keys).
Notable settings:
| Flag / env | Default | Purpose |
|---|---|---|
-scheme / SCHEME |
https |
Public URL scheme (http for dev) |
-domain / DOMAIN |
host:port | Public domain, used for federation IDs |
-instance-name / INSTANCE_NAME |
GoThread |
Display name shown in the navbar and titles (seed; change later in /admin) |
-registration-mode / REGISTRATION_MODE |
open |
open or closed (invite links) — a one-time seed; later toggled in /admin/registration |
-federation-mode / FEDERATION_MODE |
blocklist |
blocklist admits all non-blocked hosts; allowlist admits only allowed hosts |
-allow-private-federation |
off | Allow federation to/from private, loopback and link-local addresses (dev/LAN) |
-require-email / REQUIRE_EMAIL |
true |
Make an email mandatory at registration. Without an SMTP server configured, registration is blocked until one is set |
-anon-show-nsfw / ANON_SHOW_NSFW |
off | Off: hide NSFW from logged-out visitors in feeds/search/directory. On: adult-focused mode — logged-out browsers pass a consent wall, then browse unfiltered (seed; change later in /admin/nsfw) |
-smtp-host / SMTP_HOST |
— | SMTP server for email verification and password resets (empty disables all outbound mail) |
-smtp-port / SMTP_PORT |
587 |
SMTP port |
-smtp-username / SMTP_USERNAME |
— | SMTP username (PLAIN auth, only over TLS or localhost) |
-smtp-password / SMTP_PASSWORD |
— | SMTP password |
-smtp-from / SMTP_FROM |
noreply@<domain> |
Sender address on outbound mail |
-smtp-security / SMTP_SECURITY |
starttls |
starttls (587), ssl (implicit TLS, 465), or none (plaintext, local dev only) |
-smtp-insecure / SMTP_INSECURE |
off | Skip TLS certificate verification (test servers) |
-rate-limit-enabled / RATE_LIMIT_ENABLED |
off | Per-client-IP rate limiting on every route (set -trusted-proxies behind a proxy) |
-rate-limit-auth-enabled / RATE_LIMIT_AUTH_ENABLED |
on | Per-client-IP throttling of login, registration and password resets, even with general rate limiting off. An untrusted private/loopback reverse proxy is exempt (with a warning) — set -trusted-proxies |
-backup-dir / BACKUP_DIR |
backups |
Where /admin/backup writes snapshots |
-backup |
— | One-shot: write a snapshot and exit (cron-friendly) |
Federation notes
- SSRF guard: outbound federation to private/loopback/link-local targets is
refused by default. Two instances on
localhostmust both pass-allow-private-federation. - Delivery is asynchronous with retries and backoff. Watch failures and
replay dropped deliveries from the admin federation dashboard (
/admin/federation).
Email is opt-in via -smtp-host; without it, addresses are collected but never
verified. Admins can still mint one-time password reset links by hand (see below).
With a mail server configured:
- Registration — a supplied address must be confirmed from a link before the account can sign in. The username stays reserved until the link is used (or the account is purged after 7 days). If the confirmation email cannot be sent, the registration is rolled back and the username is freed.
- Login — unverified accounts get a resend page instead of a session.
- Password reset —
/forgotmails a one-time, 1-hour link; responses are deliberately identical whether or not the address exists. Resetting revokes every live session. - Admin reset links — with or without SMTP,
/admin/resetlets an admin mint a one-time, 1-hour reset link for any local account (by username or email). Issuing one supersedes any earlier reset link for that account. - Email changes — the current address stays active until the new one is
confirmed; a staged change sits as
pending_emailin settings. - A janitor runs hourly: unverified registrations older than 7 days, spent or expired tokens, and expired sessions are removed.
- Query planner statistics are refreshed on startup and again at every UTC midnight. This only changes how fast queries run, never their results.
Backup & restore
Everything — posts, media, keys — lives in the one SQLite file.
- Backup:
/admin/backup(admin), or./gothread -backup /path/snapshot.db. - Restore: stop the server, replace the DB file with the snapshot, start again.
Development
go build ./... # build
go vet ./... # vet
go test ./... # full test suite (457+ tests, no external services)
gofmt -l . # format check, must print nothing
Smoke suites
Real servers on fixed ports (scripts/), run with go and curl:
federation_smoke.sh— two-instance federation and delivery replaymoderation_smoke.sh— blocks, thread mods, reports, audit log, announced bansmedia_smoke.sh— multipart uploads, media serve/Range/rejectionsregistration_smoke.sh— open/closed toggle, invites, optional emailinterop_smoke.sh— Lemmy round-trip (requires podman + podman-compose)
internal/httpsig/testdata/*.http and internal/ap/testdata/*.json are frozen
requests captured from the interop harness; they pin the signer/verifier to
on-wire shapes.
Layout
cmd/server/— entrypoint, wiring, graceful shutdowninternal/config/— flags/env/file configinternal/mail/— SMTP sending (net/smtponly, no new dependencies)internal/storage/— SQLite viadatabase/sql, embedded migrationsinternal/ap/— AS2/AP vocab with tolerant decodeinternal/httpsig/— HTTP signaturesinternal/federation/— delivery queue, dedup, fetch-by-ID, SSRF guardinternal/web/— routes, sessions, server-rendered templates, admin UI
License
AGPL-3.0. If you modify GoThread and serve it over a network, you must offer users the modified source (section 13).

