Repository navigation
Releases
Releases · Vetox-Inc/VetoxBot-Sluice
v1.1.0
A request Discord answers is handled as in 1.0.1. This release is about the ones Sluice refuses: each is counted by
reason, the faults among them are logged, and the limits behind them can be watched before they are reached.
Added
sluice --check, which reads the settings as a start would and exits without opening a port or joining a
cluster: with status 0 when they are valid, and otherwise with the error a start would stop on.- A warning at startup for a setting that is accepted and probably a mistake: a timeout under 100 milliseconds,
MAX_RETRY_CAPTURE_BYTESbelowMAX_RETRY_BODY_BYTES, and a state file that is off because the process has no
cache directory. - A reason in
sluice_failures_totalfor every error Sluice answers with on its own and for a client that left
before its answer: 24 reasons where there were 9, listed in CONFIG.md. The nine keep
their meaning. Every reason is exported from the start, at 0, so that an alert sees its first failure. - A warning in the log for the failures an operator has to act on, such as a Discord that cannot be reached, a
rejected token or aMAX_limit that is reached. It names the method and the route, and comes at most once every 30
seconds for a reason, with a count of the failures in between. - Metrics:
sluice_warnings_total;sluice_resource_usageandsluice_resource_limit, which show how close the
limits on clients, bearer tokens, buckets, requests in flight and retry copies are;sluice_global_limit, the
requests a second each bot is paced at;sluice_invalid_requests_limit, the count at which a node stops sending;
andsluice_build_info, which carries the version. - Alert rules for Prometheus in
prometheus/alerts.yml, with tests of every rule, and a row
for the new metrics in the Grafana dashboard. - A systemd unit in
systemd/sluice.servicethat gives Sluice the network and its state
directory, and nothing else of the host. - The release archives carry the unit, the alert rules and the dashboard beside the binary.
- A hangup (
SIGHUP) stops Sluice the waySIGTERMdoes, letting the requests in flight finish, unless Sluice was
started to ignore it, asnohupdoes. The npm launcher passes a hangup on either way. - The startup log line names the upstream and counts the entries of
BOT_RATELIMIT_OVERRIDESandBOT_WIDE_ROUTES.
Changed
- At
MAX_BUCKET_STATES, Sluice first drops the buckets that nothing uses, waits for or has to wait out, and refuses
a request only when that leaves no room. It used to answer503until the next periodic clean-up. sluice_queue_wait_secondsincludes the wait of a request that Sluice answered itself after it had queued.- With
DISABLE_401_LOCK=true, a token Discord answered401is sent one request at a time until Discord accepts
one, as a token Sluice has not seen before is. Its requests used to go out side by side. - The image is published from the
releaseenvironment, as the npm packages are, and a run by hand of either
workflow refuses a tag that is not onmaster. - A release is published only after the whole of CI has passed on its commit, and only from a tag on
master. - CI runs discord.js against the built binary, the alert-rule tests and a build of the image for its three
platforms, and it also runs once a week.
Fixed
- A stop signal that arrived twice within a second ended Sluice at once and cut off the requests in flight. It does
when a process manager or a terminal signals a whole process group and a launcher, such as the npm one, passes the
signal on. The two now count as one stop. - On Windows, the npm launcher ended Sluice at once on Ctrl+C. It now leaves the stop to Sluice, which finishes the
requests in flight. - With
DISABLE_401_LOCK=true, a401from Discord counted as proof that the token was real, so the ID inside a
rejected token could become aclientIdin metrics. Such a token now staysUnverified. - A webhook or interaction token sent where the ID belongs, by a client that swapped the two, was kept in the route
label of the metrics and the log. Anything but an ID in that place is now!. - A bot token whose first part decodes to more than 20 digits no longer has those digits kept as a bot ID.
- A request path that is not valid UTF-8 was logged with every such request. It is logged once.
- In a cluster, a request for another node whose client left was counted as
peer_error. It isclient_closed. - A
Retry-Aftertoo large to be a duration, on a refusal by Discord's edge, could pause traffic for one second
instead of the longest pause. - A state file that cannot be saved is reported once, and once more when saving works again, instead of every 5
seconds. - The warning for an edge check that reached no verdict says why.
- A route in a log line reads as its metric label does:
/webhooks/!/!used to come out as/webhooks/!/:token.
v1.0.1
Documentation and wording only: requests are handled exactly as in 1.0.0.
Added
- A benchmark of traffic through Sluice against the same traffic sent directly, reported in
BENCHMARKS.md and reproducible withbench/run.sh.
Changed
- The documentation is rewritten, and the npm package's description and README with it.
sluice --helplists the settings in the groups CONFIG.md now uses.- The startup warning for
BUFFER_SIZEnamesMAX_QUEUE_DEPTHas what bounds a queue. - A node that is not part of a cluster logs "Running as a single node" at startup, in place of "Running in
stand-alone mode".
v1.0.0
The first release.
Added
Queueing:
- One queue for each of Discord's buckets, learned from
X-RateLimit-Bucketand kept apart per channel, guild and
webhook. A queue sends one request at a time, first in first out. - Pacing of each bot's global limit, taken when a request is sent.
BOT_RATELIMIT_OVERRIDESsets a raised limit, and
BOT_WIDE_ROUTESnames routes Discord limits per bot across guilds although their headers do not say so. - Bounded waits. A request waits up to
QUEUE_TIMEOUT, 10 seconds by default, for its turn, and then gets a429with
Retry-After, as does one that finds its queue full. An attempt that goesREQUEST_TIMEOUTwithout progress
answers408, and an upload that keeps moving is never cut short. - Retries of Discord's 429s whenever the request body can be sent again. A shared-scope 429 holds up only its own
request, and cooldowns follow the exactretry_afterof Discord's body.
Protecting the IP:
- A budget of 9,500 invalid responses per 10 minutes, after which Sluice answers
503instead of sending. - A bot token Discord rejected is refused by Sluice afterwards. A token is judged only by routes it authenticates:
webhook-token and interaction calls neither mark it invalid nor are refused because of it. - An
Authorizationscheme Discord never accepts gets its401from Sluice. - Calls to a webhook Discord reported as unknown (10015) or invalid (50027) are answered by Sluice for an hour.
- Cloudflare-block detection (
CLOUDFLARE_BAN_DETECTION): a 429 or 403 withoutViabacks off the refused route, and
pauses all traffic once a request of Sluice's own confirms that the edge blocks this IP. STATE_FILE, which keeps the invalid-response history, a Cloudflare block and the deleted webhooks across restarts.CLIENT_AUTH_SECRET, which makes clients present a shared secret inX-Sluice-Auth.
Requests and responses:
- Requests reach Discord as sent, with their path encoding intact. A path without the
/apiprefix is forwarded under
it, repeated slashes are collapsed, and paths with dot segments, encoded separators or an encoded?are refused. ForwardedandX-Forwarded-*headers are dropped. Sluice supplies aUser-Agentwhen there is none, puts its own
in front of one that does not start withDiscordBot, and asks Discord for gzip itself.- Every response Sluice generates carries
generated-by-proxy: trueandVia: 1.1 sluice, except the 429 it answers
during a Cloudflare block. - Sluice's own errors are JSON in Discord's error shape, and its own 429s carry Discord's
X-RateLimit-*headers, so
discord.js reports and waits them out as it does Discord's. - Bucket names and metric labels are built only from identifiers Sluice has checked, so neither a crafted token nor
an unusual path can add text to them or multiply them. - Interaction follow-ups are recognised by their application's ID as well as by the interaction token's format.
Operations:
- Prometheus metrics under the
sluice_prefix, whichMETRICS_NAMESPACEchanges: Discord's responses, queue wait,
failures, invalid responses, Cloudflare blocks, edge refusals, answers for deleted webhooks and deprecated API
versions. TheclientIdlabel holds a bot's user ID once Discord accepts its token. /sluice/healthzfor liveness and/sluice/health/upstreamfor the state of this IP at Discord.- Graceful shutdown: on
SIGTERM, liveness fails, the node leaves its cluster, and requests in flight get up to 15
seconds to finish. - Logging through Go's
log/slog, with tokens redacted from every field, as text or as JSON (LOG_FORMAT). A warning
the first time a client uses a deprecated API version or none. - Clusters of nodes that gossip under a shared secret and pass requests to each other over mutual TLS, with
CLUSTER_ADVERTISE_ADDRfor nodes behind Docker or NAT. DISCORD_API_URL, to point Sluice at a mock or a staging server.sluice --versionandsluice --help.- Release binaries, a multi-arch container image on GHCR and npm packages, all with build provenance.
Deprecated
/nirn/healthz,BUFFER_SIZEandDISABLE_GLOBAL_RATELIMIT_DETECTIONare still accepted and will be removed in
Sluice 2.0. Sluice logs a warning when a client calls/nirn/healthz.
Sluice derives from nirn-proxy 1.3.3. MIGRATING.md lists what differs for those moving from it.