# Limristem eMail topology modes

Limristem eMail can run in three **named** deployment modes. Choose them at install time (`LIMRISTEM_MAIL_TOPOLOGY_MODE`), via CLI (`manage-topology.sh` / `limristem-mail topology`), API (`POST /topology/wizard`), or the web panel **Topology** wizard.

## Mode names

| ID | Product name | Description |
|----|--------------|-------------|
| `standalone` | **Standalone** | Single node owns all mailboxes, DB and local Maildir. Default. |
| `routed` | **Routed Mesh** | Same domain across multiple hosts; each mailbox has a **home server**. Edge relays delivery to the correct backend (split-domain routing). |
| `cluster` | **Storage Cluster** | Multiple frontends share one mailbox store (NFS, Ceph, or S3 with local cache). |

## Routed Mesh (`routed`)

### Database strategies

| Strategy | Env | Behaviour |
|----------|-----|-----------|
| `shared` | `LIMRISTEM_MAIL_ROUTED_DB_STRATEGY=shared` | One MariaDB master for all nodes (recommended when network allows). |
| `synced` | `LIMRISTEM_MAIL_ROUTED_DB_STRATEGY=synced` | Each node keeps a local DB; `cluster_sync_queue` + timer replicate users. Payloads are HMAC-signed over HTTPS with the internode token. |

### Security

- Internode API requires `LIMRISTEM_MAIL_INTERNODE_TOKEN` (min 32 chars, Bearer + HMAC body signature).
- Peer URLs must be `https://` only (no credentials in URL).
- Postfix `transport_maps` only targets **registered** `cluster_servers` hosts.
- No open relay: remote transport is per-mailbox, not for arbitrary domains.

## Storage Cluster (`cluster`)

| Backend | Env |
|---------|-----|
| NFS | `LIMRISTEM_MAIL_CLUSTER_STORAGE=nfs` + mount path |
| Ceph | `LIMRISTEM_MAIL_CLUSTER_STORAGE=ceph` |
| S3 | `LIMRISTEM_MAIL_CLUSTER_STORAGE=s3` + endpoint/bucket/keys |

S3 cache controls (reduce chatter):

- `LIMRISTEM_MAIL_S3_CACHE_TTL_SECONDS` (default 3600)
- `LIMRISTEM_MAIL_S3_CACHE_MAX_MB` (default 10240)

Secrets for S3/storage are encrypted at rest in `config/topology.json` when saved via the wizard API.

## Operations panel / API (reputation & deliverability)

| Capability | Panel | API |
|------------|-------|-----|
| Deliverability (DNS/TLS/script) | Operations | `GET/POST /operations/deliverability` |
| Connectivity e2e (ports/TLS) | Operations | `GET /operations/e2e` |
| Outbound IP DNSBL self-check | Operations | `GET /operations/ip-reputation` |
| Inbound RBL toggle (Rspamd) | Operations | `GET/PUT /operations/rbl` |
| Manual reputation CRUD | (API) | `/reputation` |
| Privacy-safe traffic stats | Traffic / Statistics | `/stats/*` |
| Admin MFA | Security | `/auth/*` |
| Update channel (stable/nightly) | Settings | `PATCH /admin/settings` |

Inbound DNSBL is **off by default** (false-positive risk). Prefer dedicated resolvers when enabling.

Full API reference: `docs/API.md`.

## CLI

```bash
sudo limristem-mail topology show --json
sudo /opt/limristem-mail/bin/manage-topology.sh apply-mode routed --server-id node-a --routed-db shared --internode-token "$TOKEN"
sudo /opt/limristem-mail/bin/manage-rbl.sh set no
sudo limristem-mail topology refresh-transport --json
sudo limristem-mail topology process-sync-queue --json
```
