Read the config with Viper and environment variables, on Go 1.27.4
Security / Vulnerability check (push) Successful in 41s
Test / Lint and test (push) Successful in 1m54s

The config loader uses Viper instead of BurntSushi/toml. Every setting
can also come from UBERBRINGER_<SECTION>_<KEY>, which wins over the
file, and UBERBRINGER_CONFIG sets the default of --config; set empty, no
file is read, so a container can run from the environment alone. Each
setting is bound to its own variable, so a variable named after a
section changes nothing.

The file is parsed with go-toml and checked as written: unknown keys,
empty tables and keys that differ only in case are errors, a UTF-8 BOM
is skipped and a UTF-16 file is refused. Values are decoded strictly:
durations are strings, numbers decimal, flags true or false, and a
fraction for a whole number is refused. Errors name the file, the line
of a syntax error and the variables that were set, never their values.

`uberbringer config get <key>` prints one setting as the daemon would
use it. install.sh reads body_limit, bind_ip and port through it, so the
config is checked before the service restarts and Caddy proxies to the
configured address. The script then waits for the daemon to answer,
downloads Caddy's key and source list before replacing them, requires
Caddy's own repository, keeps the Caddyfile during dpkg upgrades,
detects an existing import loosely, logs Caddy's other errors, drops
query strings from the access log and validates the domain and printer
address more tightly.

go.mod names Go 1.27.4 with no toolchain line, and the workflows check
against the go line. The changelog folds the unreleased entries into
0.2.0, which is not tagged yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
57_WolveandClaude Opus 5.5 committed 2026-11-30 08:12:57 -06:00
1 parent 92dcacb3b9
commit eacd0bfd27
18 files changed
+1244 -248

No files matched your search

+87 -59
View File
@@ -7,52 +7,6 @@ version may break callers; such changes are listed under **Breaking**.
## [Unreleased]
### Added
- 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 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.
`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. README § 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
`?`.
- `[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 new code `too_many_lines`.
- `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.
### Changed
- 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. A
character the code page has prints as before, so cp1252 keeps its curly
quotes and cp858 its `€`.
- `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 block field on another element type, such as `title` on `text`, is
listed there (`field "title" does not apply to text`) instead of failing
the whole decode as an unknown field.
## [0.2.0] - 2026-11-30
The daemon is rewritten, and so are its install script and release process,
@@ -165,9 +119,69 @@ upgrade a 0.1 install.
`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 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.
`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. README § 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
`?`.
- `[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`.
- `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.
@@ -199,31 +213,45 @@ upgrade a 0.1 install.
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, obtains and renews the certificate itself, redirects HTTP to
HTTPS, sets `X-Real-IP` and adds HSTS and other security headers.
- Caddy limits bodies to `webserver.body_limit` and answers a larger one
with the daemon's `413` `body_too_large` JSON.
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 only
gains the `import` line and keeps its owner and mode.
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.
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`.
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.
- Domains, ACME email addresses and printer addresses that contain
anything other than the characters such values need are rejected.
- 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:
- The minimum is Go 1.26.
- The toolchain is pinned in `go.mod` as `toolchain go1.27.4`, which fixes
GO-2026-6859. CI, the security scan and releases all use it.
- 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