Skip to content

Comments

multi: add spam option for test client. #4

Draft
dnldd wants to merge 8 commits intobisoncraft:masterfrom
dnldd:testclient-spam-option
Draft

multi: add spam option for test client. #4
dnldd wants to merge 8 commits intobisoncraft:masterfrom
dnldd:testclient-spam-option

Conversation

@dnldd
Copy link
Contributor

@dnldd dnldd commented Feb 5, 2026

This adds a feature to the test client where it publishes spam for the purposes of testing out broadcast restrictions. The harness has also been updated to allow toggling this feature when needed.

NB: this is based on #3 , it'll be prepared to merge after that.

@dnldd dnldd force-pushed the testclient-spam-option branch from 1224696 to 826bd71 Compare February 10, 2026 21:45
@dnldd dnldd force-pushed the testclient-spam-option branch 2 times, most recently from 07197f8 to 7a3ce45 Compare February 18, 2026 16:50
This implements a ban manager that tracks client ips and their associated infractions. Associated tests have been added.
This adds a broadcast rate limiter for clients to control frequency of broadcasts made by clients.
This updates tatanka handlers to punish clients sending malformed messages, spamming broadcasts or impersonating nodes by posting to
restricted topics like the clients ban and oracle topics. Unauthorized errors now propagate to the client to terminate it.
This restructures infractions by gossiping infractions immediately to the mesh, this way mesh nodes keep an equivalent infractions dataset.
Also connecting nodes on startup request for an infraction snapshot, via the infractions snapshot protocol, from one of the mesh nodes
picked at random. The ban manager ensures infractions are deduplicated by checking if an infraction key exists for an infraction or not.
Associated tests have been updated accordingly and an integration test for new nodes joining a mesh and requesting an infraction snapshot
has been added.
This updates client message publishing to return a response in order to be notified of infractions when publishing messages.
The check prevented clients from publishing messages with topic names
starting with "client_infractions", but this was defensive without
real security benefit.

Real infractions use clientInfractionsTopic (whitelist-only, node-to-node).
Clients cannot access the whitelist-only topic (peerFilter blocks non-whitelist
peers). If a client publishes topic="client_infractions" to clientMessageTopic,
it's just a normal broadcast with no effect on the ban system. Infractions are
never sent to clients, so spoofing has no impact.

This differs from the oracle topic check (retained), where clients actually
receive oracle data and could be misled by spoofed messages if the Sender
field is not validated.

This also:

- Fixes double expiry calculation in recordInfraction: extract expiry to single
  variable so local infraction and gossip message use identical timestamp
- Replaces unbounded context.Background() with timeout context in recordInfraction
  to prevent indefinite gossip blocking
- Skips MalformedMessage infraction on io.EOF (clean disconnect) in 5 handlers:
  handleClientPush, handleClientSubscribe, handleClientPublish, handlePostBonds,
  handleClientRelayMessage. Only record infraction for actual parse errors.
Fixed flaky TestMeshConnectionManagerFailover by separating exponential backoff
semantics: backoff now applies only when all nodes are exhausted, not when
primary connection fails with alternatives available. On primary connection error,
immediately call attemptConnect() to try alternatives. On failed connection attempts
(no nodes available), apply exponential backoff before retrying. This maintains
graceful error recovery while fixing unnecessary delays that caused test timeouts.

Backoff is applied only in the appropriate scenario: when we've tried all options
and need to wait before retrying, not when we have alternatives to try immediately.
This adds a feature to the test client where it publishes spam for the purposes of testing out broadcast restrictions. The harness has also
been updated to allow toggling this feature when needed.
@dnldd dnldd force-pushed the testclient-spam-option branch from 7a3ce45 to 68dd915 Compare February 19, 2026 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant