Delta Chat gateway built on top of libtacky (in component mode)
  • Go 57.9%
  • Tcl 37.4%
  • Python 2.5%
  • Shell 1.6%
  • Makefile 0.4%
  • Other 0.2%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-11-21 23:27:26 +02:00
component rooms: every member dict says sees_jids 1, the rooms being non-anonymous to their members as before (the service's per-viewer rule since feat/mucservice-5; the room's rule would say the same, said here so that it does not hang on the defaults) 2026-11-21 23:27:26 +02:00
docs namespaces: urn:tacky:mail:0 is https://ns.another.im/mail/0 everywhere (the component, its disco and caps, the hints, the courier, docs and the e2e), and DESIGN.md's mention of urn:tacky:mtproto-e2e:0 https://ns.another.im/mtproto-e2e/0, by the user's ruling of 2026-11-21 (/data/another-im/ns-rename-2026-11-21.tsv) and libtacky develop e6ec84de, which reads no old name; CHANGELOG's Unreleased says so 2026-11-21 16:57:08 +02:00
engine deltagram 0.0.6 on libtacky integ/1.3 fe4fe0bc: the version in postimeesd, the component and the README, CHANGELOG's entry dated (the gateway's companion) 2026-11-18 16:12:13 +02:00
libtacky@0623923072 libtacky submodule to feat/mucservice-5 06239230: the MUC service's security fixes (sees_jids per viewer in member answers, XEP-0463 lists to owners and admins only, a body always a message, moderate's author in the context, at most five invites a message, an invalid reserved nick refusing the join), which the rooms take next 2026-11-21 23:27:14 +02:00
tests/e2e namespaces: urn:tacky:mail:0 is https://ns.another.im/mail/0 everywhere (the component, its disco and caps, the hints, the courier, docs and the e2e), and DESIGN.md's mention of urn:tacky:mtproto-e2e:0 https://ns.another.im/mtproto-e2e/0, by the user's ruling of 2026-11-21 (/data/another-im/ns-rename-2026-11-21.tsv) and libtacky develop e6ec84de, which reads no old name; CHANGELOG's Unreleased says so 2026-11-21 16:57:08 +02:00
tools README figures by make stats on the rooms' round 3 and the namespace rename (Tcl 5,620 lines; coverage still d710cc3's, coverage-all not run); fake gate 846 passed, 0 failed over 14 rigs, loop rig 90 passed, 0 failed. tools/__pycache__/stats.cpython-314.pyc, a compiled copy committed by mistake, leaves the tree (it held the old namespace) 2026-11-21 17:00:08 +02:00
.gitignore deltagram: the Delta Chat gateway, skeleton and design 2026-11-17 14:10:36 +02:00
.gitmodules deltagram: the Delta Chat gateway, skeleton and design 2026-11-17 14:10:36 +02:00
CHANGELOG.md namespaces: urn:tacky:mail:0 is https://ns.another.im/mail/0 everywhere (the component, its disco and caps, the hints, the courier, docs and the e2e), and DESIGN.md's mention of urn:tacky:mtproto-e2e:0 https://ns.another.im/mtproto-e2e/0, by the user's ruling of 2026-11-21 (/data/another-im/ns-rename-2026-11-21.tsv) and libtacky develop e6ec84de, which reads no old name; CHANGELOG's Unreleased says so 2026-11-21 16:57:08 +02:00
Dockerfile build: dist/postimeesd (Makefile, Dockerfile's builder output and COPY), the health check looks for comm postimeesd (tools/container-init.sh), tools/stats.py's component map 2026-11-18 04:54:31 +02:00
LICENSE deltagram: the Delta Chat gateway, skeleton and design 2026-11-17 14:10:36 +02:00
Makefile build: dist/postimeesd (Makefile, Dockerfile's builder output and COPY), the health check looks for comm postimeesd (tools/container-init.sh), tools/stats.py's component map 2026-11-18 04:54:31 +02:00
README.md README figures by make stats on the rooms' round 3 and the namespace rename (Tcl 5,620 lines; coverage still d710cc3's, coverage-all not run); fake gate 846 passed, 0 failed over 14 rigs, loop rig 90 passed, 0 failed. tools/__pycache__/stats.cpython-314.pyc, a compiled copy committed by mistake, leaves the tree (it held the old namespace) 2026-11-21 17:00:08 +02:00

Deltagram

Delta Chat for your XMPP domain. Run it beside your own XMPP server, point the domain's MX at it, and every user is reachable from Delta Chat at their own address: alice@another.im the JID is alice@another.im the chatmail address. Nothing to link, nothing to log into.

Version 0.0.6. Licence GPL-3.0 (LICENSE).

What you get

  • dist/deltagram: the XMPP component (XEP-0114), Tcl on libtacky's tacky::xmpp::component, one executable with the interpreter inside.
  • dist/postimeesd: the mail engine (Go, static), the component's child: SMTP in from the MX, SMTP out to the contacts' servers, DKIM-signed.
  • The image with both, which anotherim-server runs beside ejabberd.
  • Plain XMPP for the clients: service discovery, jabber:iq:gateway, ad-hoc and chat-line commands, XEP-0106 contact addresses, Delta Chat groups as rooms (XEP-0045).

OpenPGP (Autocrypt) is end to end between the user's devices and the contact; the gateway holds no key. No mail server, no IMAP, no Delta Chat core behind it. Everything per user is in a sealed store; a copy of the data directory is useless without the key, which is kept outside it.

Features

  • Texts, replies and quotes, files, images, voice messages, stickers, locations, contact cards, both ways, through the server's upload service
  • Reactions (XEP-0444), corrections (XEP-0308), retractions (XEP-0424), read receipts (XEP-0333 ⇄ MDN), delivery receipts when the contact's server took the mail
  • Contacts in the roster, their names and avatars, a vCard with their fingerprint and whether they are verified
  • Verified contacts and groups by SecureJoin: the Invite command shows the user's QR code and link, Join takes a Delta Chat invite
  • Delta Chat groups as rooms: members, add and remove, name and image, leaving, the room's recent history
  • Encryption automatic once a contact's key is known; a changed key is announced in the chat
  • Mail that is not chat is refused at the door (or handed to the domain's previous MX), so there is no spam and no backscatter

How it fits together

 XMPP clients (libtacky 1.3 devices hold the OpenPGP keys)
   │  XMPP
   ▼
 XMPP server (ejabberd)
   │  XEP-0114, XEP-0356 roster and iq privileges, XEP-0363 upload
   ▼
 deltagram          component/: users, contacts, rooms, the courier
   │  JSON lines on stdin and stdout (docs/frames.md)
   ▼
 postimeesd         engine/: the sealed stores and queue, mail composed and parsed
   │  SMTP, DKIM, SPF
   ▼
 the contacts' mail servers (chatmail relays, Delta Chat)
  • The component is everything XMPP: who the user is, the roster, the rooms, the stanzas each way.
  • The engine is everything mail: the MX and its policy, delivery and its queue, MIME and Autocrypt, the stores at rest.
  • The device encrypts and decrypts; the gateway carries ciphertext.

The code by component and language, generated by tools/stats.py (make stats; the coverage column by make coverage-all):

component language what it is code tests coverage
companion Tcl companion.tcl: the gateway's companion, chatmail to OX and XEP-0027 for a user who opted in; securejoin.tcl: its Invite and Join; ox.tcl: OpenPGP clients at contact JIDs; web.tcl: its HTTP 1,111 311 100.0 % procs
contacts Tcl roster.tcl: the contacts in the user's roster (XEP-0356 pushes, else XEP-0144), paced; vcard.tcl: a contact's card; avatar.tcl: its Chat-User-Avatar as its avatar 605 175 100.0 % procs
engine Tcl engine.tcl: the link to postimeesd 146 0 100.0 % procs
Go cmd/postimeesd: the process, its keys; internal/engine: requests, events, the stores; internal/frame: the wire 2,233 3,792 99.2 % stmts
fake Go internal/fake: a scripted mail engine for the e2e (-fake) 2,680 1,706 100.0 % stmts
gateway Tcl main.tcl: options and the XEP-0114 component; gateway.tcl: presence, jabber:iq:gateway, the version, unknown users; addr.tcl: addresses as JIDs (XEP-0106); disco.tcl; commands.tcl, prefs.tcl: Status, Settings, blocking 835 735 100.0 % procs
groups Tcl muc.tcl: Delta Chat groups as rooms, the backend of libtacky's MUC service; rooms.tcl: their lifecycle and administration; nickprep.tcl: the resourceprep tables a nick is kept to 1,468 304 99.3 % procs
keys and hints Tcl keys.tcl: the user's OpenPGP key from PEP (XEP-0373) to the engine; hints.tcl: what a device tells the gateway (https://ns.another.im/mail/0) 287 0 100.0 % procs
mail in Go internal/smtpd: the MX and its policy; internal/auth: SPF and DKIM for the From domain; engine/inbound.go: mail to events 839 709 98.8 % stmts
mail out Go internal/deliver: SMTP to the MX found, DKIM signing; engine/queue.go: the sealed queue and its backoff; engine/send.go: the sends 1,125 1,030 97.0 % stmts
media Tcl media.tcl: files both ways; upload.tcl: the server's upload service (XEP-0363) 468 0 100.0 % procs
Go internal/fetch: shared files fetched, aesgcm:// decrypted 880 1,179 99.2 % stmts
messages Tcl message.tcl: the courier of https://ns.another.im/mail/0 and the cleartext bridging, 1:1 700 246 100.0 % procs
Go internal/mail: chat and classic mail composed and parsed (MIME, Autocrypt headers) 1,120 652 98.6 % stmts
storage Go internal/seal: encryption at rest; internal/store: the sealed per-user store 942 1,101 98.8 % stmts
everything else make, Dockerfile, sh, Python, Tcl the Makefile, Dockerfile, e2e scripts and tools/ 766 1,297 --
total (without everything else) Tcl 5,620 · Go 9,819 15,439 11,940 Tcl 99.8 % procs · Go 99.0 % stmts

code: lines without blanks and comments; libtacky is not counted, and the everything else row is not in the total. tests: test lines per component (COMPONENTS in tools/stats.py). coverage: Go statements run by the engine's tests; Tcl procedures called under the e2e in both privilege modes, from the make coverage-all run on 2026-11-18 at commit d710cc3.

Status and tests

The latest release is v0.0.6, on libtacky integ/1.3 (fe4fe0bc, 2026-11-18), a patch of the 0.0 line: the companion, in the gateway, for users of OpenPGP clients (Gajim, Profanity, Dino) who opt in.

The engine's Go tests run each package alone and two engines for two mail domains mailing each other over SMTP on the loopback. The e2e runs the component against ejabberd and a scripted engine (postimeesd -fake), in both privilege modes, sharded across rigs. The loop rig (make e2e-loop) runs two real gateways for two domains and two libtacky 1.3 devices holding their keys: encrypted mail both ways, a photo by url, reactions, edits, receipts, retractions, SecureJoin, a group with a keyless local member, classic mail, DKIM and SPF, a restart, and a user with no device whose OX client writes to Delta Chat through the gateway's companion, a file each way, SecureJoin both ways. anotherim-server's deployment test runs against the image.

Not yet tested: a run against a Delta Chat app itself. The device side is libtacky 1.3's (integ/1.3), unreleased when this was written.

15,439 lines of code (Tcl 5,620 · Go 9,819), 11,940 lines of tests, 682 test cases defined. Coverage: Tcl 99.8 % procs · Go 99.0 % stmts (make coverage-all on 2026-11-18 at commit d710cc3).

suite family files cases
Go: engine 10 89
Go: fake 8 45
Go: mail in 4 23
Go: mail out 2 24
Go: media 3 29
Go: messages 2 32
Go: storage 4 64
Tcl, no server: addr.tcl (addr-test.tcl) 1 22
e2e, the fake engine: the common start (e2e.tcl) 1 15
e2e, the fake engine: messages, classic (messages.tcl) 1 38
e2e, the fake engine: encrypted (encrypted.tcl) 1 18
e2e, the fake engine: contacts, hints, keys (contacts.tcl) 1 37
e2e, the fake engine: commands, gone, upload (commands.tcl) 1 20
e2e, the fake engine: ox (ox.tcl) 1 10
e2e, the fake engine: companion (companion.tcl) 1 52
e2e, the fake engine: rooms (rooms.tcl) 1 67
e2e, the fake engine: edges (edges.tcl) 1 19
loop rig: two gateways, two libtacky 1.3 devices (loop.tcl, loop/checks.tcl) 2 78
total 45 682

cases: Go test and fuzz functions, and the checks a Tcl suite defines (a check in a loop counts once). make stats regenerates these numbers; the coverage comes from the last make coverage-all, its full report in _build/cov/REPORT.md.

Building

Everything builds and runs in a container (podman, else docker): Go in golang, Tcl and the rigs in libtacky's build image (the submodule libtacky/).

git clone --recurse-submodules ssh://git@dev.another.im:3022/another-im/deltagram.git
cd deltagram
make build test
target what it does
make build dist/deltagram and dist/postimeesd
make test the engine's go vet and race tests
make e2e-fake the e2e against ejabberd and the fake engine, both privilege modes, sharded (tests/e2e/gate.sh: rigs on ports from 30000, E2E_PORT_BASE; logs in _build/e2e)
make e2e-loop the loop rig (tests/e2e/loop.sh: DG_LIBTACKY, a built libtacky 1.3 checkout; LOOP_PORT_BASE)
make e2e both
make coverage-all both test runs under coverage, into _build/cov and this README
make stats this README's tables (make stats-check fails when they are stale)
make image, make publish the runtime image, pushed to the registry

Using it

anotherim-server runs the image beside ejabberd (make env ... DELTAGRAM=1 there) and prints the DNS records the domain needs: the MX, SPF, the DKIM key, DMARC. Port 25 must reach the gateway and the gateway must reach the world on 25. See anotherim-server's README, "Delta Chat".

By hand:

postimeesd keygen > /etc/deltagram/key                # the master key, once
postimeesd dkim-keygen -o /etc/deltagram/dkim.pem     # prints the TXT record
CREDENTIALS_DIRECTORY=/etc/deltagram COMPONENT_SECRET=... \
  deltagram -domain delta.example.org -data /var/lib/deltagram

component/main.tcl's header lists the options; postimeesd -h the engine's. Received files go into the server's upload service under a daily bound per user, -upload-daily (2 GiB), of which one sender who is not a contact may spend -upload-sender-daily (256 MiB). A user of an OpenPGP client (OX: Gajim, Profanity; XEP-0027: Dino) turns on "Translate for my OpenPGP client", an ad-hoc command of the gateway (or says companion on to it): the gateway then reads and translates that user's Delta Chat mail.

Documents

path what
docs/DESIGN.md the design: its shape, addressing, the wire to the device (https://ns.another.im/mail/0), the costs
docs/frames.md the engine ⇄ component protocol
docs/rooms.md what a client may rely on in a group's room
engine/internal/fake/README.md the fake engine the e2e drives
CHANGELOG.md the releases