Files
uberbringer/CHANGELOG.md
T
57_WolveandClaude Opus 5.5 fb76284129
Security / Vulnerability check (push) Successful in 40s
Test / Lint and test (push) Failing after 6m43s
Add ntfy subscriptions with digests, quiet hours and a cut feed
[[ntfy.subscriptions]] tables make the daemon subscribe to ntfy topics
itself and print each message as a notification card, so the phone's
ntfy app is the only client. Each subscription is one ntfy.Subscriber in
the daemon's errgroup: one event loop owns its state, and one goroutine
per connection reads the JSON stream. internal/app hands its messages to
modules.FromNtfy, Card, Validate and Submit with the source ntfy:<name>
and the message's ID as ref, so ntfy never imports modules.

The cursor is ntfy server time, never an ID. ntfy sends open before the
replay, so only keepalives and messages dealt with move it, and a
reconnect asks for two minutes before it, since a message is dated
before its attachment is stored. The IDs of the messages a replay could
send again are kept, at least the last 512 and 20,000 at most, so a
flood in the overlap never reprints; when the cap forgets IDs a replay
could send, the floor rises past them. A saved floor bounds replays: a
first start sets it to the open event's time, and max_backlog (default
1h, at most 12h), measured by the server's clock as each connection
tells it (its open event, else its Date, then the monotonic clock), never the
host's, so replays are requested unclamped and filtered as they arrive,
raises it when it clamps, so what it left out stays out. The
state, with the held messages and the receipt times, is written
atomically at most once a second and at shutdown. Redirects are never
followed, so credentials never go to another address or over plain http.
A stalled stream reconnects after twice the keepalive plus 15 s,
failures back off 5 to 120 s with jitter, a 429 waits for Retry-After,
and refused credentials, checked at startup through /auth, show as
unauthorized and retry every 5 minutes. A full print queue pauses
reading and retries the message from 1 s to 30 s, and the cursor moves
past it only once it is queued.

The paper budget is a strict window: at most rate_limit receipts (5) in
any rate_window (10m), digests included; the rest are held and print on
one digest card once there is room, and outside quiet hours
bypass_priority (5) and above print at once. Quiet hours hold everything
below their min_priority for one Overnight digest when the window ends,
or drop it; windows cross midnight and keep their times of day when
clocks change, also where the change skips midnight or a window's end.
A message whose sequence printed before, on a card or a digest row, is marked
(updated), or skipped with ntfy.format.updates = "skip"; the first of a
sequence its publisher named prints plain.

/healthz lists the subscriptions without changing how its status code is
decided, and no credential, topic or message text reaches it, the logs
or a config error. Subscriptions come from the file only, with strict
keys and per-entry defaults; credentials are optional, at most one kind.
ntfy.state_dir is required with a subscription: the unit gains
StateDirectory=uberbringer, install.sh writes the path into a new
config, and the Docker image sets it for a volume and runs as the fixed
user 10001. README explains how to lock a self-hosted ntfy server down
so that only your publishers can print.

Breaking: printer.cut_feed (default 3) feeds blank lines before every
cut, so the last line no longer sits right at the cut. They count toward
format.max_lines once per copy, so a job within 3 lines a copy of the
limit now fails. The renderer's option is 0 unless set, so the pinned
receipts keep their bytes.

testing/synctest drives the subscriber on a virtual clock, including a
24-hour soak with floods, repeats, refusals, a full queue, quiet hours
and a restart that fails on any leaked goroutine; it replaces a 24-hour
run on hardware. Tests over real sockets cover net/http's goroutines and
redirects to plain http and to another port.

Checked on the TM-T88IV against a live ntfy server: a phone message, quiet
hours with priorities 3 and 5 and the Overnight digest, a stale cursor, a
30-minute outage with an update, a wrong token, and the three-line cut
feed. The digest and the cut-feed card are pinned in TestPaperReceipts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 17:50:23 -06:00

24 KiB
Raw Blame History

Changelog

All notable changes to Überbringer are recorded here. The format follows Keep a Changelog, and versions follow Semantic Versioning. Until 1.0, a minor version may break callers; such changes are listed under Breaking.

Unreleased

Breaking

  • A job with a raw element prints only with a token issued with uberbringer token --raw. Every other token, every token issued so far included, gets 403 token_scope for it and keeps every other route. Re-issue tokens with --raw for the clients that send ESC/POS bytes of their own.
  • Every receipt feeds printer.cut_feed blank lines (default 3) before each cut, so that its last line no longer sits right at the cut. Previews show them before the cut, and they count toward format.max_lines: 3 lines for each cut in each copy, the final cut and every cut element. So a job close to the limit can now fail: 400 lines in 5 copies was 2000 and is now 2015, and with one cut element inside each copy, 2030. Set cut_feed = 0 for the old spacing and count.

Added

  • Notifications:
    • The notify module prints a card from {"title", "message", "priority", "tags"}, with topic, click, up to 3 actions, image, markdown and time as options, for scripts, cron jobs and phone shortcuts.
    • The ntfy module prints one ntfy message as ntfy sends it, such as the ntfy client's $NTFY_RAW, so the client can print a topic with one entry in its client.yml and no other tools. docs/api.md gives the recipe for Linux and Windows.
    • Both print the same card: its form follows the priority (a dark URGENT rule and a double box, a double box headed HIGH, a single box, or no box), tags print as markers such as [!] in front of the title, links print as QR codes, and attached images print after the card. A subset of markdown is laid out, and emoji are left out. Titles, topics, tags, labels, links and messages are capped in length: notify refuses a payload over a cap, and from an ntfy message the text over a cap is cut and the tags and links over one are left out. A card that cannot be laid out prints as a plain receipt, and the fault is logged and reported to Sentry.
    • [ntfy.format] (style, max_lines, qr, images, markdown) and [ntfy.markers] in the config shape the cards.
  • Scoped tokens: uberbringer token --modules ntfy,notify issues a token that may only print and preview through those modules and read job status and the module list. Any other route answers 403 with the new error code token_scope. A token whose mod claim is null, or whose mod or raw claim is written in another letter case, is refused with 401.
  • ntfy subscriptions: [[ntfy.subscriptions]] tables in the config make the daemon subscribe to ntfy topics itself and print each message as a notification card, so no other client is needed.
    • After a restart or an outage, the messages missed print once each, up to max_backlog (default 1 hour) back; repeats never print twice.
    • A paper budget, rate_limit receipts per rate_window (default 5 in 10 minutes), holds the rest of a flood and prints it on one digest receipt once there is room. By default, priority 5 always prints at once.
    • Optional quiet hours ([ntfy.subscriptions.quiet]) print only urgent messages during a daily window and the rest on one Overnight digest when it ends.
    • A message that replaces one the subscription printed is marked (updated), or left out with ntfy.format.updates = "skip".
    • ntfy.state_dir keeps each subscription's state across restarts. install.sh writes it into a new config and the systemd unit gains StateDirectory=uberbringer, so /var/lib/uberbringer is writable; the Docker image sets it to that path, for a volume, and runs as user and group 10001, so a mounted token file can be given to it.
    • A redirect from the server is never followed, so credentials never go to another address or over plain http; the connection fails, and its error says that the server redirects and to set server to the address it redirects to.
  • GET /healthz lists the ntfy subscriptions in an ntfy array, with their state, counts and last error. Its status code still depends on the printer alone.
  • GET /api/v1/jobs/:id reports the job's source: print, module:<name>, or ntfy:<subscription>. The worker's log lines carry the source and the ID of the request, or of the ntfy message, that sent the job.
  • image elements take "optional": true: an image that cannot be fetched or decoded prints as [image unavailable] instead of failing the job, and one whose width is wider than the paper shrinks to it.
  • box takes "title_bold": true to print its title bold.

Changed

  • A QR code that could be wider than the paper prints with smaller modules instead of running off its edge. Its width is worked out as if its data were bytes, so a code of digits or capitals may shrink before it strictly has to.

0.2.0 - 2026-11-30

The daemon is rewritten, and so are its install script and release process, and it is now licensed under the EUPL-1.2. Read Breaking before you upgrade a 0.1 install.

Breaking

  • POST /api/v1/print takes {"elements": [...]} instead of {"data": [...]}. A body in the old format is refused with 400 invalid_job, and its message points to docs/api.md, which describes the elements.
  • POST /api/v1/print answers 202 Accepted with a Location header and a JSON job (id, status, created_at). 0.1 answered 200 with the text OK - <id>. Job IDs are job_ TypeIDs instead of numbers.
  • Every error is JSON: {"error": "...", "code": "...", "details": [...]}. Clients should match on code. 0.1 answered with {"message": "..."} or plain text.
  • Bearer tokens are read only from the Authorization header. A token in a ?token= query string gets 401. 0.1 tokens keep working in the header while api.secret is unchanged.
  • install.sh sets up Caddy instead of nginx and acme.sh, on a fresh host. It does not upgrade a host set up by the 0.1 script. See README § Quick start.
  • printer.address is required. The 0.1 install script did not write it, so add a [printer] section with address to such a config before starting 0.2. Unknown config keys are now errors, so a typo no longer falls back to a default silently. api.secret must be at least 32 bytes; secrets generated by the 0.1 install script are long enough.
  • config.toml is no longer tracked in the repository. If a clone uses it, copy it aside before pulling and put it back afterwards; git then leaves it untracked. New setups start from configs/config.example.toml.

Added

  • Print queue. A job is accepted at once and printed in order by a single background worker. A failed send is retried with a doubling delay (printer.retries, printer.retry_delay). A full queue answers 503 queue_full with Retry-After: 10.

  • GET /api/v1/jobs/:id reports queued, printing, done or failed. A failed job includes an error. The last queue.history finished jobs are kept.

  • Elements:

    • text: sizes 1–8 (or separate width and height), bold, underline, invert, Font B and alignment;
    • feed and qr;
    • barcode: EAN-13, EAN-8, UPC-A, UPC-E, CODE39 and CODE128;
    • image, raw and cut.
  • copies (1–5) prints the job several times, cutting after each copy.

  • UTF-8 text is transcoded to printer.codepage: cp437 by default, or cp850, cp858 or cp1252. A character the code page lacks prints as ?. Control characters are removed.

  • Word wrap at word boundaries for the paper width and character size. The position is tracked across "newline": false elements.

  • Images come from a URL or base64, as PNG, JPEG, GIF or WebP. Each is scaled to the paper and dithered, with limits on download size, pixel count and printed height.

  • Printer profiles, chosen with printer.model:

    • tm-t88 (TM-T88IV to VII), the default;
    • tm-m50 (TM-m50, TM-m50II);
    • tm-t20 (TM-T20, II, III);
    • generic-80mm and generic-58mm.

    printer.paper_width and printer.columns override the profile.

  • GET /healthz reports live printer status: paper near end or out, cover open, errors.

    • It answers 200 when the printer is ready or does not answer status requests, and 503 when it is unreachable, not ready or too slow to answer.
    • A printer that looks not ready is read again 750 ms later, so a printer that is busy cutting or feeding raises no false alarm.
  • A stable code in every error response, listed in docs/api.md § Errors. Examples are job_not_found and not_found for 404, and queue_full and shutting_down for 503. A 405 carries Allow, and a 429 carries Retry-After.

  • Cache-Control: no-store on /healthz and on every /api/v1 response, error responses included.

  • Commands uberbringer secret, which prints a new API secret, and uberbringer token [--subject] [--ttl], which prints a signed bearer token.

  • Config sections:

    • [webserver]: rate limit, trusted proxies, body limit and timeouts;
    • [queue], [images] and [sentry];
    • [log]: level, and text or JSON format.

    Every optional key has a default, shown in configs/config.example.toml.

  • Graceful shutdown on SIGINT and SIGTERM. A receipt that is printing is finished, and waiting jobs are marked failed.

  • Logging:

    • one request line per request, at INFO, or at WARN for a 5xx answer;
    • for an unexpected failure, one ERROR request failed line and one Sentry event;
    • for a recovered panic, one ERROR panic line with its stack trace and one Sentry event.
  • An Alpine Dockerfile that runs as a non-root user.

  • A hardened systemd unit, packaging/uberbringer.service, shipped in the release archives and installed to /usr/local/lib/systemd/system/.

    • It has no capabilities and a read-only file system, and its address families and system calls are restricted.
    • It sets start-rate limits.
    • Customise it with systemctl edit uberbringer drop-ins.
  • install.sh:

    • takes the printer address as its third argument;
    • installs a given release with UBERBRINGER_VERSION=vX.Y.Z;
    • installs on arm64, armv7 and armv6 as well as amd64.
  • Release archives contain LICENSE.txt, README.md, docs/api.md, docs/swagger.json, CHANGELOG.md, configs/config.example.toml and packaging/uberbringer.service next to the binary.

  • docs/api.md, the API reference: routes, elements, blocks and error codes. README covers installing, configuration and the command line.

  • docs/swagger.json, the OpenAPI 3.1 document of the HTTP API: every route with its parameters, responses and the error codes it and its middleware answer with, and the schemas of the job and of every response. It is generated from the route table and the Go types (go generate ./...), served at GET /openapi.json without a token, and shipped in the release archives and the Docker build. CI fails when it is out of date.

  • A weekly govulncheck run (Mondays 06:00 UTC, and on every push to main), so a new advisory against unchanged dependencies is reported.

  • A Makefile for development. make check runs the CI gate in the same order, make vuln runs govulncheck and make snapshot builds the release archives without publishing them. make builds report the version without a leading v, as release binaries do.

  • Blocks, laid out to the printer model's width when the job prints:

    • box: single, double, double-h, double-v or ascii borders, a title set into the top border (inline or capped), a footer in the bottom border, padding, fit and columns. Its body is text or children: text, feed, kv, lists and rules, which print as dividers joined to the borders.
    • rule: nine line styles, from single and double to shades, dashes and dots, with an optional label.
    • kv: key-value rows joined by a leader; long values wrap.
    • list: items with a dot, dash, number or checkbox bullet, and done to tick checklist items ([√], or [x] on code pages without √). Long items wrap with a hanging indent. A list can stand alone or go inside a box.

    size (1–3) and font scale a block's borders and text together. On cp850, cp858 and cp1252, glyphs the code page lacks fall back to ones it has. docs/api.md § Blocks lists the fields.

  • POST /api/v1/preview and uberbringer preview [file.json|-] show the lines a job would print, read back from its rendered bytes, without printing it or fetching images. The route answers plain text, or JSON with the styled runs, the line count and warnings for characters printed as ?.

  • Modules, which build a receipt from a few plain fields:

    • POST /api/v1/print/:module queues it and POST /api/v1/preview/:module previews it. ?copies= sets the copies; ?printer= is reserved and takes only default.
    • GET /api/v1/modules lists the modules.
    • uberbringer preview --module <name> shows the receipt a module builds from a payload.
    • The note module prints a box with a title, the text, a checklist and the time in the bottom border, from {"title", "text", "items", "done"}, with style, footer and stamp as options. docs/api.md § Modules describes it.
    • The module routes answer with the error codes invalid_payload (400), invalid_query (400), unknown_printer (400), module_not_found (404) and module_failed (422).
  • [format] with max_lines (default 2000): a job that would print more lines fails instead of printing. /api/v1/preview answers such a job with 422 and the code too_many_lines.

  • format.timezone (default Local) and format.time_layout (default 02 Jan 15:04) set how modules print times. The binary carries the time zone database, so zone names load on Windows and in slim containers.

  • printer.box_line_spacing (default 0): the line spacing used while a box prints, to close the gaps in its vertical borders. The default, the printer's own spacing, was checked on paper on the TM-T88IV.

  • examples/blocks.json, a receipt with every block style, padding, size and junction, for checking the borders on paper.

  • Every config key can be set by an environment variable, UBERBRINGER_<SECTION>_<KEY> (e.g. UBERBRINGER_PRINTER_ADDRESS), which wins over the config file. Numbers are decimal digits, flags true or false, durations strings such as 5s, and lists comma-separated. An empty variable counts as unset; one of only spaces is an error. A failed load names the set UBERBRINGER_* variables that match no setting.

  • UBERBRINGER_CONFIG sets the default of --config. Set empty, or with --config "", no config file is read, so a container can run from environment variables alone. The Docker image sets it to /etc/uberbringer/config.toml.

  • uberbringer config get <key> prints one setting as the daemon would use it, and fails when the configuration does not load. It never prints api.secret. install.sh reads the config through it.

Changed

  • The config is read with Viper. 0.1 config files load as before. Unknown keys are errors, empty tables included, and so are two keys that differ only in case. A duration must be a string such as "5s", and a number with a fraction for a whole-number setting is refused. A number, flag or list may also be written as a string, as in an environment variable. A file that starts with a UTF-8 byte order mark loads; a UTF-16 file is refused with a message saying so. A TOML syntax error names its line and column, and other errors name the file and the UBERBRINGER_* variables that were set, never their values.
  • Text is composed to Unicode NFC before it is printed, so a decomposed é prints as é. Characters the code page lacks fold to look-alikes instead of printing as ?: curly quotes print as " and ', – as -, — as --, … as ..., • as ·, → ← as -> <-, ✓ ✔ as √ (or x), × as x, € as EUR and ™ as TM. An emoji sequence, with its skin tone, variation selector or joined emoji, prints as one ? instead of one per code point, and zero-width spaces and joiners are removed.
  • invalid_job details name nested elements by their path, e.g. elements[0].children[3] (qr): not allowed inside a box; place it after the box. A field that applies to another element type, such as title on text, is listed there (field "title" does not apply to text).
  • The licence is now the European Union Public Licence v. 1.2 (EUPL-1.2), replacing the GNU Affero General Public License v3.0. Releases up to and including 0.1.2 stay available under AGPL-3.0.
  • The HTTP server is Fiber v3 instead of Echo. ESC/POS commands come from an in-house package instead of justinmichaelvieira/escpos.
  • printer.model defaults to tm-t88: 512 dots, 42 Font A columns. On a 576-dot printer such as a TM-T20, set model = "tm-t20" to use the full width. A profile wider than the printer makes it break words at the right edge; a narrower one only shortens lines.
  • Request IDs are req_ TypeIDs (UUIDv7).
  • Rate limiting is per client and covers /api only: webserver.rate_limit requests per webserver.rate_window, 60 per minute by default. Behind the reverse proxy, the client is the X-Real-IP set by the proxy on 127.0.0.1. 0.1 allowed about one request per second on every route.
  • Error messages are fixed texts set by the server. The HTTP framework's own text, which can quote bytes of the request, is never sent; an unknown route answers not found.
  • Expected refusals are not logged as errors or sent to Sentry: 4xx answers, a full queue, shutdown, and an unhealthy /healthz.
  • Release binaries take their default Sentry DSN from the SENTRY_DSN CI secret instead of from the repository. sentry.dsn and the SENTRY_DSN environment variable override it.
  • install.sh, user and secrets:
    • The service runs as a dedicated uberbringer user instead of root.
    • The config is written under umask 027 and set to 0640 root:uberbringer.
    • The first API token goes to /etc/uberbringer/initial-token (0600, root) instead of the terminal. Re-runs create no new tokens.
  • install.sh, reverse proxy and certificate:
    • Caddy replaces nginx and acme.sh. It is installed from Caddy's own apt repository, and the script stops if that repository can't be read. Caddy obtains and renews the certificate itself, redirects HTTP to HTTPS, sets X-Real-IP and adds HSTS and other security headers. Its access log leaves out query strings.
    • Caddy proxies to webserver.bind_ip and webserver.port, limits bodies to webserver.body_limit and answers a larger one with the daemon's 413 body_too_large JSON. Its other errors are logged with their cause.
    • The site is /etc/caddy/uberbringer.caddy, imported by the Caddyfile. The package's default Caddyfile is replaced; an edited Caddyfile gains the import line only if no line imports the site, and keeps its owner and mode.
    • The configuration is validated as the caddy user. If Caddy rejects it, the previous Caddy files are restored and the script stops with Caddy's error.
  • install.sh, download:
    • The download is checked against the release's checksums.txt (sha256). Apart from installing curl and gnupg, nothing on the host changes until the release is verified.
    • apt-get update runs before packages are installed, and apt output goes to /var/log/uberbringer-install.log. dpkg keeps a changed Caddyfile without asking.
    • Caddy's signing key and source list are downloaded before the installed ones are replaced, so a failed download leaves them as they were.
  • install.sh, re-runs and validation:
    • A re-run upgrades the binary, the unit and Caddy, keeps the config, an edited Caddyfile and unit drop-ins, rewrites the Caddy site and restarts the service.
    • The config is read with the new binary before the service is restarted, so a config that does not load stops the script and leaves the running service alone. After the restart, the script waits for the daemon to answer.
    • The domain must be a DNS name with a dot, not an IP address. The printer address must not carry a port. ACME email addresses and both of these are limited to the characters such values need.
  • Go:
    • Go 1.27.4, the latest release, which fixes GO-2026-6859, is the minimum Go and the one CI, the security scan and releases use. go.mod has no separate toolchain line.
    • Every dependency is upgraded, and vendor/ is gone.
    • The module path is still the bare uberbringer, so build from a clone.
  • CI moved from .github/workflows to .gitea/workflows. test.yml runs once per branch push, and its gate is gofmt, goimports, go mod tidy -diff, go vet, staticcheck, go test -race -timeout 5m and goreleaser check. It builds no binaries: they are built only for release tags on main.
  • Releases:
    • Releases are cut only from v* tags whose commit is on main, with goreleaser pinned to 2.20.3.
    • -rc.N tags are published as prereleases, and an rc tag on the same commit as the final tag cannot be picked by mistake.
    • A release fails, instead of silently rewriting go.mod and go.sum, when they are not tidy.
    • File times come from the tag's commit, so rebuilding a tag gives byte-identical archives.
    • Release notes start with a link to this file.

Removed

  • The {"data": [...]} job format with numeric item types, and token lookup from query strings (see Breaking).
  • The pull-request labeler workflow, which had no configuration.
  • The vendor/ directory and the .idea/ project files.

Fixed

  • A job is validated in full before it is queued; the 400 lists every problem. Nothing reaches the printer unless the whole receipt rendered.
  • A failed connection to the printer is retried, and the job is then marked failed. In 0.1 it panicked the request handler, which answered 500.
  • Request logs never contain tokens.
  • Sentry no longer receives the Authorization header or print contents.
  • install.sh writes the [printer] section. Without it, 0.1 dialled port 9100 on the local host.

Security

  • The config.toml tracked in 0.1.x held an API secret, and that secret is still readable in the repository history.
    • An install that uses it must replace api.secret with the output of uberbringer secret, then issue new tokens. Every token signed with the old secret stops working.
    • Installs set up by install.sh generated their own secret and are not affected.
  • The 0.1 install script left /etc/uberbringer/config.toml, API secret included, readable by every user (mode 0644 under the usual umask). Its unit runs the daemon as root, so on such a host run chmod 0600 /etc/uberbringer/config.toml.
  • Image URLs are fetched through an SSRF guard.
    • A URL is refused when it resolves to a loopback, private or link-local address, cloud metadata endpoints included.
    • The check runs at connect time, after DNS resolution, and again on every redirect.
    • images.allow_private_networks turns the address check off. images.allowed_hosts limits fetches to the listed hosts, which may then be on the LAN.
    • 0.1 fetched any URL.
  • api.secret must be at least 32 bytes (see Breaking).

0.1.2 - 2025-01-12

Added

  • Item type 7 prints the image at the URL given in text.

0.1.1 - 2025-01-12

Added

  • First release:
    • POST /api/v1/print with {"data": [...]} items of types 1–6: text, bold text, QR code, line feed, n line feeds and raw hex;
    • HS256 bearer tokens;
    • install.sh for Debian and Ubuntu with nginx and an acme.sh certificate.