Skip to content

v0.5.2

Choose a tag to compare

@richlegrand richlegrand released this 19 Oct 18:13
· 20 commits to main since this release

A patch release: five fixes, and a startup block a daemon can live with.
Nothing changes about how you start a listener, and 0.5.1 command lines
keep working.

Two of these came from @lars18th, who is running a listener as a service
on OpenWRT and sharing a drive root from Windows.

Downloads go to the browser's download manager

The file browser read a whole download into memory and saved it as a Blob
at the end, so a file had to fit inside the tab. A 32 GB file stalled near
2 GB, and Chrome gave out at its 32 GiB data limit.

Clicking a file now navigates a hidden frame to the download endpoint and
the browser writes the file as it arrives. The same 32 GB file is past
10 GB with every Chrome process flat.

Two details fell out of it. Downloads are sent as
application/octet-stream, because the service worker injects its shims
into any navigation answering text/html, and a saved .html would
otherwise have come out with script tags in front of it. And
Content-Disposition now carries the filename twice -- a printable-ASCII
form, and the exact name as RFC 5987 filename* -- because WebKit reading
a service worker's response keeps the name but swaps the extension for
.html, so an accented .txt saved as .html. Chromium and Firefox take
either form.

A daemon's startup block is two lines

-noqr in 0.5.1 took the QR code out and left six lines of logo above it.
The whole block is reprinted on every reconnect, so a listener under
systemd wrote the logo into its journal each time it came back.

The logo is now printed only when stdout is a terminal, alongside the bold
and the side-by-side layout that already were. Off a terminal -- a
journal, a pipe, a log file -- the block is the version and the URL:

bitbang-cli v0.5.2
URL: https://bitba.ng/<uid>#<code>

The blank line that closed the Sharing block is gated the same way. In a
journal every line already carries a timestamp and a unit name, so a
separator there is an entry that says nothing.

A terminal is unchanged, and -noqr remains its own flag: the QR is drawn
with Unicode half-blocks, which a Windows console on the wrong code page
cannot render whether or not anyone is watching. (#34)

Sharing a filesystem root served nothing

serve files D:\ listed the drive and then refused every file in it.
serve files / does the same on Unix.

The path check appends a separator before comparing, so that a share of
/srv/photos does not also match /srv/photos-old. A base that is
already a root ends in a separator of its own, so / became // and
D:\ became D:\\ -- prefixes that nothing matches. Every file under the
share resolved to nothing and read as not found.

It was reported as a Windows browser bug and is neither: cp failed
identically, and Linux fails the same way for anyone who shares /.
Windows surfaced it because sharing a drive root is a reasonable thing to
do. (#38)

POSTs from a proxied page reached the target empty

A form or JSON POST from a page behind serve proxy arrived with no
Content-Length, so it went on to the target chunked, and a target that
does not decode chunked requests read an empty body. Python's
http.server is one; embedded servers are worse.

That is the ordinary case rather than an edge case. A service worker
cannot read Content-Length, because the browser appends it after the fetch
handler has run, so the length is gone before the request is sent.

Bodies are now measured up to 64 KB before the request is built. A form or
JSON body ends inside that and goes out with an exact length; anything
larger streams as it did before, chunked, with its flow control intact.

Connecting to a device that carries media

A device that declares streams -- an ESP32 camera's video and audio --
opens a data channel per stream beside the control one. connect took
every channel as the control channel, so the second to open panicked.

Channels whose protocol begins bitbang-stream/ are now ignored, the same
rule the browser dispatches on. They carry nothing until a client
subscribes, and connect subscribes to none of them.

A link table written by 0.5.0-rc1

0.5.0-rc1 wrote scope as a list of capabilities; 0.5.0 renamed it to
grant and made it a sentence. A table left over from the pre-release
stopped a listener starting, and said only

Link table error: ... json: unknown field "scope"

which names what is wrong and nothing about what to do. The error now
names the rename and the new spelling.

It is still an error rather than a silent migration. Rewriting a
capability list into a grant on someone's behalf is a quiet
reinterpretation of an access control, and anyone holding such a table can
edit one line.