Commit Graph
297 Commits
Author SHA1 Message Date
Storm Dragon c1722c2491 The official Mumble client has two protections Barnard was missing. After UDP decryption fails for over five seconds, it requests a cryptographic resync, retrying no more than every five seconds. It always accepts TCP-tunneled voice, even while UDP is active, because transports can briefly overlap during fallback. These are now implemented. 2026.09.09 2026-09-08 12:20:30 -04:00
Storm Dragon ca9c25f2d8 Fixed an edge case durring disonnect when remember transmission 2026-09-06 18:41:28 -04:00
Storm Dragon e8df68c749 Fixed the menu, remember transmission should be there now. 2026-09-06 18:31:04 -04:00
Storm Dragon 01ca0da7ff Optionally remember transmission state on reconnect. 2026-09-06 18:24:52 -04:00
Storm Dragon 6817ecd90b Touch ups and additional capabilities added to fifo functionality. Sample Fenrir scripts in extra 2026-09-06 17:55:21 -04:00
Storm Dragon 4ef8553c7d First attempt didn't work. 2026-09-06 01:13:31 -04:00
Storm Dragon 2b5fe91d6c Restore transmit state after unmute/deafen. Send proper notifications to other users. 2026-09-06 01:04:10 -04:00
Storm Dragon 97e0dc9281 Updated how mute and deafen for self works, more similar to official client behavior. 2026-09-05 22:11:03 -04:00
Storm Dragon cf9746c8de Add alt+d deafen keyboard shortcut. 2026-09-05 21:53:57 -04:00
Storm Dragon f21e7c9960 Actually set exe perms on the build script. 2026-09-05 13:17:37 -04:00
Storm Dragon 07418eb60f Simple script to build Barnard and its TUI. 2026-09-05 13:16:47 -04:00
Storm Dragon 6bea646327 Add keyboard settings regression tests 2026-09-05 12:55:49 -04:00
Storm Dragon 202530743a More keyboard refactor. 2026-09-05 12:43:31 -04:00
Storm Dragon 97fcde7e96 Add mnemonic mute controls 2026-09-05 00:57:37 -04:00
Storm Dragon ef19a558d2 Redesign default tree controls 2026-09-05 00:34:40 -04:00
Storm Dragon db2d441dfc Merge branch 'bmmcginty' into testing
# Conflicts:
#	README.md
#	barnard-ui
#	barnard.go
#	client.go
#	client_notification_test.go
#	config/user_config.go
#	extras/barnard-sound.sh
#	gumble/gumble/audio.go
#	gumble/gumble/audiolisteners.go
#	gumble/gumble/client.go
#	gumble/gumble/config.go
#	gumble/gumble/handlers.go
#	gumble/gumble/user.go
#	gumble/gumbleopenal/stream.go
#	main.go
#	ui_tree.go
2026-09-05 00:18:02 -04:00
Storm Dragon afd4148e9a Replace Python launcher with native Go UI 2026-09-03 11:43:21 -04:00
Storm DragonandBrandon McGinty 0d4daeb45a Merge Brandon McGinty's latest Barnard hardening
Merge the rewritten contributor history through ecf0027, including bounded queues and buffers, safer packet handling, audio resource cleanup, regression coverage, and the memory watcher.

Co-authored-by: Brandon McGinty <git@bmcginty.us>
2026-09-03 01:28:28 -04:00
Brandon McGintyandClaude Opus 5 ecf00271b3 add a memory watcher script
Records resident memory alongside the Go heap size and dumps heap and
goroutine profiles once memory passes a threshold, while the process is
still alive to ask.

The ratio between the two numbers is what identifies the source: barnard's
Go heap sits at a few megabytes in normal operation, so memory growth with a
flat Go heap points at cgo allocations in OpenAL, opus or rnnoise, which the
Go collector cannot see and therefore never applies back pressure to.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-24 12:32:52 -04:00
Brandon McGintyandClaude Opus 5 31ae03ad65 bound the per-source recording backlog
Each tick drains one fixed chunk per source, so if the encoder stalls the
loop never makes the deficit up and the backlog only grows from there. The
queues had no cap, so a long recording against a slow encoder grew for as
long as it ran.

Cap each queue and keep the newest audio; discarding the newest instead
would only push the recording further behind.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-24 12:32:44 -04:00
Brandon McGintyandClaude Opus 5 53894b33ae do not block the read routine on a late reject
The connect channel was unbuffered. Once DialWithDialer has returned on its
synchronization timeout nothing reads that channel again, so a Reject
arriving afterwards blocked handleReject, and with it readRoutine, forever.
That leaks the goroutine along with the client, its user and channel maps
and its read buffer, and because readRoutine never reaches its exit path the
ping and UDP routines are never signalled to stop either.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-24 12:32:44 -04:00
Brandon McGintyandClaude Opus 5 fe322ce067 release the read buffer after an oversized packet
The buffer grew to the largest packet ever received and was never given
back, so a single large ACL, user list or channel comment pinned its full
size, up to the ten megabyte packet limit, for the life of the connection.

Keep a modest buffer between packets and allocate larger ones only for as
long as they are needed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-24 12:32:44 -04:00
Brandon McGintyandClaude Opus 5 ef9bd19fc9 bound the configured audio buffer count
Buffers had a lower bound but no upper one, and it is allocated per speaking
user twice over: as a queue of decoded frames and as OpenAL playback
buffers. Each buffer holds up to one maximum sized frame, so a large value
multiplied by a populated channel is a substantial amount of memory.

Cap it, and reject the flag up front so the failure names the flag rather
than surfacing later as a dial error.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-24 12:32:44 -04:00
Brandon McGintyandClaude Opus 5 0d62f745ca reuse the stereo Opus encoder across connections
Every connect built a fresh stereo encoder for file playback. Each one holds
a little under a megabyte of encoder state, so on a flaky link that is close
to a megabyte of churn per reconnect for no benefit; the encoder is already
reset when file playback ends.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-24 12:32:30 -04:00
Brandon McGintyandClaude Opus 5 5cdb2684b5 keep the tone test output open across a reconnect
The saver reserves its output file exclusively, so opening it a second time
fails. connect opened a new one per connection and a disconnect closed it,
which meant the first reconnect died with "file exists" instead of resuming.

Open the saver once and re-attach it on reconnect, and close it on exit
instead. Detaching and closing are now separate, since only shutdown wants
both.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-24 12:32:21 -04:00
Brandon McGintyandClaude Opus 5 77fad24560 release the audio stream a reconnect replaces
connect assigned b.Stream without releasing the stream already there, and
OnDisconnect started a reconnect loop unconditionally, so two connects could
race to install a stream. The loser was simply overwritten.

An overwritten stream is never destroyed, so it keeps its OpenAL device, its
render thread, and its entry in the shared audio listener list, which only
Destroy removes. It therefore stays subscribed for the life of the process
and every later audio packet from every user is dispatched to it as well: a
goroutine, a packet queue and a set of playback buffers per orphan, per
user. The file playback stream and the tone test saver were replaced the
same way.

Release whatever is being replaced, and allow only one reconnect loop at a
time.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-24 12:32:06 -04:00
Brandon McGintyandClaude Opus 5 da1c6bdc26 release jitter buffer entries as they are consumed
Packets are removed from the jitter buffer by resliceing past them, which
leaves the popped entries in the backing array. Each one pins a decoded
audio frame until the array is next reallocated.

Clear the slot before resliceing.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-24 12:31:25 -04:00
Brandon McGintyandClaude Opus 5 7647fdb233 release per-user audio resources before tearing down the renderer
Destroy detached the audio listener, which closes each per-user stream
channel and ends the goroutines OnAudioStream started, and then immediately
destroyed the OpenAL context and closed the renderer without waiting for
them. Those goroutines delete their OpenAL source and buffers through
s.render, which returns false once the renderer is closed, so the deletes
were silently skipped and the resources were left to the device.

Track the goroutines and let them finish first, bounded so a wedged renderer
cannot hang a reconnect. Both device close calls now report failure as well:
alcCloseDevice frees nothing and returns false while a device still has
contexts, buffers or sources outstanding, and dropping the handle after that
leaks the device and everything it owns somewhere the Go collector cannot
see it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-24 12:31:16 -04:00
Brandon McGintyandClaude Opus 5 82ecf713ff keep audio listeners reachable after a detach
AudioListeners.Attach set the tail pointer only when the list was empty, so
tail stayed on the first item ever attached. Once anything detached, the next
attach linked itself onto a node that was no longer in the list and that
listener never received audio again.

The equivalent code in Listeners.Attach is correct; this one had diverged
from it. The reconnect path detaches and re-attaches on every cycle, so this
was reachable in normal use.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-24 12:31:03 -04:00
Brandon McGintyandClaude Opus 5 f03d576604 reject an out-of-range tunnelled audio length
The length is taken from the packet and only checked against the upper
bound, so a negative value passed the check and then panicked on the slice
expression that follows.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-24 12:30:56 -04:00
Brandon McGintyandClaude Opus 5 1e73d192ba reject a channel parent that is its own descendant
handleChannelState applied whatever parent the server named, so a channel
could be made its own ancestor. That leaves Parent/Children cyclic, and
everything that walks the channel tree afterwards recurses until it exhausts
memory.

Ignore such a move and keep the existing parent rather than corrupting the
graph. The ancestry walk is itself bounded so a graph that is already cyclic
cannot hang the check.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-24 12:30:44 -04:00
Brandon McGintyandClaude Opus 5 07c923c4c9 bound the tree rebuild against a cyclic channel graph
rebuild_rec followed parent/child links with no depth limit, so a channel
graph in which a channel is its own ancestor recursed until the process ran
out of memory.

Cap the depth and give the whole rebuild a single node budget. Accumulating
into one slice rather than returning a new slice per node makes that budget
apply to the tree as a whole instead of to each level, and removes an
allocation per node.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-24 12:30:29 -04:00
Brandon McGintyandClaude Opus 5 314b838e33 bound the chat scrollback and wrap only new lines
AddLine re-wrapped every stored line on each append, and the buffer it
re-wrapped had no upper bound, so the work a session did grew as the square
of its length. Wrapping also built each display line by concatenating one
rune at a time, reallocating per character.

Wrap just the line being added, build it with a strings.Builder, and cap the
retained history. Trimming is done a block at a time because it forces a
rebuild; discarding a single line per append would re-wrap the whole buffer
again.

Measured over the same benchmark, 4000 lines went from 42s and 18.8GB
allocated to 4ms and 1MB, and 20000 lines now complete in 85ms.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-24 12:30:23 -04:00
Storm DragonandBrandon McGinty 001ccd4622 Merge Python Barnard launcher improvements
Co-authored-by: Brandon McGinty <git@bmcginty.us>
2026-08-20 16:01:14 -04:00
Brandon McGintyandClaude Opus 5 0c8eec1bf6 rewrite barnard-ui in Python
Replace the shell implementation with Python while keeping the same
dialog-based interface and the same file layout under
~/.config/barnard.
The shell version parsed servers.conf with string operations that lost
whitespace and silently discarded entries it could not read, and every
new feature meant more quoting and subshell handling.

Refuse to start on a servers.conf we cannot interpret.
Unknown keys, stray sections, and invalid ports now name the file and
line instead of being dropped and rewritten over the top of the user's
file. Duplicate server names are reported rather than silently
collapsed.

Keep a backup of the previous server list and flush it to disk.
A save is written to a temporary file, the old one is copied to .bak,
and both the file and its directory are synced before the replace.

Confirm before overwriting or removing a server.

Bracket IPv6 addresses when building the -server argument.
The shell version joined address and port with a colon, which is not a
usable address for an IPv6 literal.

Take the hostname from os.uname rather than the environment.
HOSTNAME is a shell variable and is not exported, so the connect
username lost its host part.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-20 14:42:52 -04:00
Brandon McGintyandClaude Opus 5 e64c6df2b7 document the UDP protocol, Windows status, and new options
Add UDP_ENCRYPTION.md describing the OCB2 crypt state, the 1.5 native
protobuf envelope, nonce handling, and the version negotiation that
selects between the 1.5 and legacy payload formats.
The protocol is only described across several Mumble source files, and
getting the nonce direction wrong is not visible as anything except
audio that never arrives.

Add WINDOWS.md recording what builds there today and what does not.

Update the README for the new command line options and the tone test
mode.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-20 14:42:52 -04:00
Brandon McGintyandClaude Opus 5 3dc77cedd6 add audio tests against a live Mumble server
Add integration tests behind a build tag that connect to a local
Mumble server and check the audio path end to end.
Unit tests cover the codec and the packet format separately, but
neither catches a mismatch that only appears against a real server.
These send a known tone and verify the frequency, packet ordering, and
sequence continuity that come back, at 10 ms and longer intervals, over
native UDP and over the TCP tunnel.

Add a reference-vector test for the 1.5 protobuf envelope carried
inside the TCP tunnel.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-20 14:42:52 -04:00
Brandon McGintyandClaude Opus 5 b77a491ec9 update Go dependencies
Move opus, go-toml, protobuf, go-runewidth, and golang.org/x/net to
their current releases.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-20 14:42:52 -04:00
Brandon McGintyandClaude Opus 5 d02177af71 log the incoming audio path at packet level
Record decoder creation, sequence numbers, frame lengths, and decode
results for each tunneled audio packet, and note when a slow listener
has a packet dropped.
Diagnosing a codec or ordering problem previously meant adding print
statements and rebuilding. These sit at info and debug, so they cost
nothing unless -logfile is given.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-20 14:42:52 -04:00
Brandon McGintyandClaude Opus 5 872149c977 run all terminal work on the UI goroutine and lock shared client state
Route network and audio callbacks through a bounded UI queue.
Protocol handlers, the audio thread, and key handlers all drew to
termbox widgets directly, which is a data race against the render
loop. postUI is now the only path from a callback to a widget, work is
dropped during shutdown, and the queue never blocks the caller.

Guard the mutable client state with mutexes.
Connection and transmission flags, the selected user, the muted
channel set, and the audio stream pointer were each read and written
from at least two goroutines. Lookups that walk the client's user and
channel maps take the client lock and copy what they need.

Snapshot the display string when a tree item is built.
Tree items held live pointers and formatted themselves during
rendering, so a user removed between rebuild and draw was dereferenced
on the render path.

Cancel reconnect retries on shutdown and release audio before
reconnecting.
Quitting during a retry left the goroutine sleeping until its timer
expired, and a reconnect built a second OpenAL stream on top of the
first. Cleanup is idempotent so repeated disconnect events are safe.

Make UI shutdown idempotent and join the event poller.
Close could be called more than once, and the polling goroutine could
be left trying to deliver an event after Run had returned. Run now
also reports a termbox initialization failure instead of returning nil.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-20 14:42:52 -04:00
Brandon McGintyandClaude Opus 5 a564286402 accept IPv6 server addresses without a port
Append the default port only when the address does not already have
one.
The check looked for any colon, so a bare IPv6 literal such as
2001:db8::1 was treated as already carrying a port and was passed
through unusable, while a bracketed literal without a port never got
one appended.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-20 14:42:52 -04:00
Brandon McGintyandClaude Opus 5 ecca0a63ed add a tone test mode that bypasses the soundcard
Add -tone-test to transmit a generated 440 Hz Opus tone and save
incoming audio to the file named by -tone-out.
Diagnosing an audio problem previously required a working capture and
playback device, which is exactly what is in question. This mode opens
no OpenAL device at all, so the network and codec path can be tested
on a machine with no sound hardware.

Open the capture file before starting the generator.
Starting transmission first left a tone goroutine running with nowhere
to write when the path was unusable.

Refuse file playback while in tone test mode, and ignore the
microphone volume keys.
Both operate on a stream that does not exist here.

Stop the generator and detach the file saver on disconnect.
A reconnect otherwise attached a second saver to the same file.

Add -auto-transmit to key the microphone as soon as the connection is
up.
Useful for a bot or a monitoring client that should never need a
keypress. It runs from both the connect event and the point where the
audio stream is created, because the server's welcome arrives before
the stream exists.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-20 14:42:52 -04:00
Brandon McGintyandClaude Opus 5 17a4662c6c strip terminal control sequences from server-supplied text
Remove control, DEL, and bidi characters before display.
HTML escaping was the only filter, which leaves ANSI and OSC escape
sequences intact. A remote user could move the cursor, recolour the
screen, or reorder what was shown by putting escape codes in a
message, a nickname, or a channel name. Names rendered in the channel
tree go through the same filter now.

Keep the text box cursor and the prompt on rune boundaries.
Both indexed by byte, so editing a line containing multi-byte
characters could split one and render replacement characters.

Handle text view lines that carry no timestamp.
Toggling timestamps assumed every stored line had one and sliced past
the end of lines that did not.

Ignore key events on an empty tree.
The handlers indexed the item list before checking that it had any
items.

Remove the beep helpers.
They shelled out to an optional "beep" binary and panicked when it was
absent.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-20 14:42:52 -04:00
Brandon McGintyandClaude Opus 5 97ec48534e bound notification delivery and expand placeholders once
Give the notification queue a buffer and drop events when it is full.
The channel was unbuffered, so a slow or hung notification command
blocked whichever UI or network callback happened to raise the event.

Expand the command placeholders in a single pass.
Substituting %event, then %who, then %what meant text arriving in an
earlier field could contain a later placeholder and have it expanded,
letting a remote user inject their own text into the command.

Move the command runner behind a build tag and drop the POSIX default
on Windows.
The helper script it pointed at does not exist there, so the default
was a command that could only fail.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-20 14:42:52 -04:00
Brandon McGintyandClaude Opus 5 4f41dd4ed6 harden and platformize FIFO handling
Reject a FIFO path that points to an existing non-FIFO object.
Previously we removed whatever was at that path before creating the
pipe, so pointing -fifo at a regular file silently deleted it. An
existing FIFO is reused and only a missing path is created.

Move the implementation into fifo_unix.go and fifo_windows.go.
This lets the Unix build use syscall.Mkfifo directly, which is not
available on Windows.

Prevent the reader from endlessly spinning on a closed FIFO after an
error.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-20 14:42:52 -04:00
Brandon McGintyandClaude Opus 5 c5baaae6a7 stop file playback processes and their children reliably
Kill ffmpeg's whole process group rather than just the process.
ffmpeg spawns helpers for some inputs, so stopping playback left them
running and holding the output pipe open. The player now starts the
command in its own process group and signals the group.

Wait for the playback worker to finish before starting a new file.
Playing a second file while the first was shutting down left two
workers writing to the same stream.

Make pausing nonblocking.
The pause path could block on a full pipe and hang the UI thread that
requested it.

Install and reset the stereo encoder under the client lock.
File playback swapped the encoder field directly while a voice frame
could be encoding with it, and a finished file left the encoder
carrying state into the next one.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-20 14:42:52 -04:00
Brandon McGintyandClaude Opus 5 fbb6a148ff restore the saved microphone volume on connect
Apply the persisted microphone volume when the stream is created.
The value was written to the configuration on every adjustment but
never read back, so the microphone returned to full gain on each
start.

Read a saved volume of zero as zero rather than as a missing value.
A user who muted their microphone and quit came back unmuted.

Save the configuration after a volume change and report a failure.
The setter only updated the in-memory value, so the new level was lost
unless something else happened to save afterwards.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-20 14:42:52 -04:00
Brandon McGintyandClaude Opus 5 cb4f91596e make microphone AGC less aggressive and switchable
Lower the gain ceiling and slow the attack of the automatic gain
control.
It amplified room noise between words hard enough to be audible as a
rising hiss whenever the speaker paused.

Add an AGC toggle on F12 and an /agc command.
AGC has always been applied unconditionally, which is wrong for a
microphone that is already levelled by hardware or by the system
mixer. The preference is saved and reapplied on connect, defaulting to
on so existing setups are unaffected.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-20 14:42:52 -04:00
Brandon McGintyandClaude Opus 5 17173b779b report configuration failures instead of crashing
Return errors from the save path rather than panicking.
Every write panicked on failure, so a read-only or missing
configuration directory killed a running client. The parent directory
is created when absent, and callers now show the failure in the output
window and carry on.

Write through an unpredictable temporary file.
The old fixed ".tmp" name next to the configuration was a symlink
target an attacker could plant in advance.

Serialize configuration reads and writes.
Hotkey handlers, the audio thread, and the connection callbacks all
touch the same structure, so saves could interleave with updates.

Parse addresses with SplitHostPort.
Splitting on every colon broke IPv6 addresses and panicked outright on
an address with no port. Both now fall back to Mumble's default port.

Fail immediately when an explicitly requested config file is missing
or is not a regular file.
Silently falling back to defaults hid a mistyped -config path.

Supply defaults for the clear-output and scroll-to-top and -bottom
hotkeys.
The UI registered listeners for them but the configuration never
filled the keys in, so the bindings were nil and the keys did nothing.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-20 14:42:52 -04:00
Brandon McGintyandClaude Opus 5 7e1faba06b make the outgoing packet interval configurable
Add -audio-interval to choose a 10, 20, 40, or 60 ms packet duration.
Longer packets cut per-packet overhead on slow or lossy links at the
cost of latency. Anything else is rejected at startup rather than
silently truncated to 10 ms frames.

Step the audio sequence by the frame duration.
Sequence numbers are Mumble timestamps in 10 ms units, so a 60 ms
packet advances the counter by six. Incrementing by one made the
receiver see every packet as arriving far too early.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-20 14:42:52 -04:00