- Go 67.1%
- Shell 8%
- CSS 7.7%
- PowerShell 5.6%
- HTML 5.4%
- Other 6.2%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
|
||
| cmd | ||
| deploy | ||
| docker | ||
| internal | ||
| scripts | ||
| .env.example | ||
| .gitignore | ||
| docker-compose.yml | ||
| Dockerfile | ||
| go.mod | ||
| go.sum | ||
| LICENSE | ||
| README.md | ||
AniFuse Subs (sub.anikitty.moe)
Public subtitle catalog for AniFuse.
- Site: https://sub.anikitty.moe
- API:
GET https://sub.anikitty.moe/v1/subs?anilistId=&episode= - Source of truth: this Forgejo repo — never GitHub
- License: Apache 2.0
Monochrome glass UI. Tracks are aggregated, deduped (identical file/content collapses; at most one row per sourceId + language), stamped with age, and fetched through a one-contact-per-source TTL gate so enrichment cannot loop forever.
Secrets (random on create)
Self-hosters get unique cryptographically random secrets on first setup. Defaults like changeme are refused at ensure-time, container entrypoint, and process boot.
| Secret | Purpose |
|---|---|
SUBS_ENCRYPTION_KEY |
AES-256-GCM sealing for episode track listings and SRT bodies (AFSEAL1:…). 32 random bytes as hex (64 chars). |
POSTGRES_PASSWORD |
Postgres role password for compose / DATABASE_URL. |
Generate (first boot)
Any one of:
./scripts/ensure-secrets.sh # Linux / macOS / VPS
./scripts/compose-up.sh # ensure + docker compose up -d --build
go run ./cmd/ensure-secrets # cross-platform (crypto/rand)
Windows (PowerShell):
.\scripts\ensure-secrets.ps1
docker compose up -d --build
What it does:
- Creates
.envfrom.env.exampleif missing. - If
SUBS_ENCRYPTION_KEYorPOSTGRES_PASSWORDis empty / placeholder / weak, replaces it withopenssl rand -hex 32(orcrypto/rand//dev/urandom). - Sets
.envto mode0600(owner-only). Never commits.env. - Re-runs are safe: existing strong secrets are left untouched.
Losing SUBS_ENCRYPTION_KEY
Sealed rows (*_sealed) become permanently unreadable. Back up .env (or SUBS_ENCRYPTION_KEY_FILE) offline before production use. There is no recovery without the key material.
Key rotation
- Stop writers (
docker compose stop subs). - Export / re-seal is not automated — treat rotation as a new vault:
- Generate a new key (
openssl rand -hex 32). - Drop sealed cache tables / volume or stand up a fresh Postgres volume.
- Set
SUBS_ENCRYPTION_KEYto the new value in.env(mode0600). - Start services and re-fetch / re-ingest catalogs.
- Generate a new key (
- Keep the old key offline only if you still need to decrypt a backup of the old volume.
Optional file-based key (root-owned):
sudo install -d -m 0700 /etc/anifuse-subs
openssl rand -hex 32 | sudo tee /etc/anifuse-subs/encryption.key >/dev/null
sudo chmod 0600 /etc/anifuse-subs/encryption.key
export SUBS_ENCRYPTION_KEY_FILE=/etc/anifuse-subs/encryption.key
Encryption layers
| Layer | What |
|---|---|
| In transit | TLS at Caddy (sub.anikitty.moe). Prefer sslmode=require on DATABASE_URL when Postgres is remote. |
| At rest (disk) | Encrypt the Postgres volume (LUKS / cloud disk encryption / host TDE). |
| At rest (app) | AES-256-GCM sealed blobs (AFSEAL1:…) via SUBS_ENCRYPTION_KEY / _FILE. |
Postgres (only primary store)
SQLite is not used. Connection string:
export DATABASE_URL='postgres://anifuse_subs:SECRET@127.0.0.1:5432/anifuse_subs?sslmode=require'
Schema is created on boot (episodes, files, fetch_gate, schema_migrations). Track JSON and file bodies live in *_sealed columns as ciphertext.
Quick start (Docker Compose)
./scripts/ensure-secrets.sh # or compose-up.sh / ensure-secrets.ps1
docker compose up -d --build
curl -sS http://127.0.0.1:8791/health
curl -sS 'http://127.0.0.1:8791/v1/subs?anilistId=1535&episode=1'
Optional: set UPSTREAM_SUBS_ORIGIN to a legacy /api/subs/{id}/{ep} host. Each episode and file id is contacted at most once per 30 minutes (memory + Postgres fetch_gate).
Run from source
go mod tidy
go run ./cmd/ensure-secrets
set -a && . ./.env && set +a
export DATABASE_URL="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@127.0.0.1:5433/${POSTGRES_DB}?sslmode=disable"
go run ./cmd/server
API shape
GET /v1/subs?anilistId=1535&episode=1
{
"anilistId": 1535,
"episode": 1,
"title": "Death Note",
"cached": true,
"resolvedAtMs": 1730000000000,
"tracks": [
{
"id": "anikoto|en|…",
"sourceId": "anikoto",
"source": "Anikoto",
"language": "en",
"label": "🇬🇧 English",
"url": "https://sub.anikitty.moe/v1/file?id=…",
"mimeType": "application/x-subrip",
"ageMs": 120000,
"ageLabel": "2m ago",
"resolvedAtMs": 1730000000000
}
]
}
Also:
| Method | Path | Notes |
|---|---|---|
| GET | /v1/file?id={64hex} |
Sealed SRT download |
| GET | /v1/library |
Local sealed shows |
| GET | /api/subs/{id}/{ep} |
Legacy SoftReplace shape |
| GET | /health |
Liveness |
Caddy + DNS (sub.anikitty.moe)
- DNS A/AAAA
sub.anikitty.moe→ VPS (143.246.203.212). - Append
deploy/Caddyfile.snippetto the host Caddyfile. systemctl reload caddy(or your Caddy unit).- Run compose / binary on
127.0.0.1:8791(afterensure-secrets).
Android app wiring
AniFuse (anifuse-android) points SubtitleLibrary at:
https://sub.anikitty.moe
and prefers GET /v1/subs?anilistId=&episode=. Disk/memory caption cache remains the offline SoftReplace fallback when the host is unreachable.
No encryption keys ship in the Android APK. Clients only talk HTTPS to the public API.
To point a fork at your self-host, change SUBTITLE_LIBRARY_ORIGIN in the Android client (or set a future build-time override) to your public HTTPS base.
Security notes
- Do not commit
.env, encryption keys, Postgres passwords, orapp.inisecrets. - Empty /
changeme/ placeholder secrets are rejected — the API will not start. - Bind Postgres to localhost (or private network) unless TLS + strong auth are configured.
- The service stores captions operators choose to cache; it does not scrape from the Android APK.
Forgejo
https://git.anikitty.moe/anifuse/anifuse-subs
Public by default. origin must stay on Forgejo — never mirror to GitHub.