## [1.88.1](http://forgejo:3000/ircforever/managebot/compare/v1.88.0...v1.88.1) (2026-12-01) ### Bug Fixes * **ids:** dynamic-DNS and file-sharing lookups are info, not attacks ([ |
||
|---|---|---|
| .forgejo/workflows | ||
| cmd | ||
| config | ||
| contrib/znc/evrdmoved | ||
| db | ||
| internal | ||
| test/integration | ||
| web | ||
| .dockerignore | ||
| .env.example | ||
| .gitignore | ||
| .releaserc.json | ||
| CHANGELOG.md | ||
| docker-compose.yml | ||
| Dockerfile | ||
| go.mod | ||
| go.sum | ||
| Makefile | ||
| README.md | ||
managebot
An IRC bot that automates IRCNow bouncer (BNC) approvals. It replaces the manual
!bnc approve workflow with two questions answered automatically:
- Is this a real person? — email verification (click a link or
!verify <code>), plus MX/disposable-domain checks and IRC client signals (TLS, CTCP). - Is this someone farming multiple accounts? — correlation across IP,
subnet (/24 & /64), normalized email (catches
j.o.h.n+x@gmail), and similar nicks, plus DNSBL / Tor-exit / hosting-ASN reputation on the connecting IP.
Each request gets an additive risk score. Below CHECK_APPROVE_THRESHOLD it
is auto-approved; at/above CHECK_REJECT_THRESHOLD it is auto-rejected; in
between it is escalated to staff in the team channel with the evidence and
!approve / !reject buttons.
On top of the score, the sign-up similarity check (internal/services/similarity)
tells staff which existing account a request looks like and why: the same SSH
key, the same exact non-shared IP from any source (sign-up, SSH, ZNC, IRC), the
same normalised email or the same proxy client are strong; the same residential
/24 or /64, a name stem that matches once digits are dropped (farham437 ≈
farham4377) or a cluster staff banned as linked are medium; the same ASN, IRC
client or sign-up time are only context. Shared infrastructure (iCloud Private
Relay, CDN/VPN egress, Tor, our own hosts and the webchat gateway) never counts
as an address match. It is a warning, never a ban: the request page shows a
"Similar accounts" panel and the queue a badge, and a strong match with a banned
account sends a request that would be auto-approved to staff review instead.
The only thing kept compatible with the old system is the ZNC control
convention: accounts are created via *controlpanel AddUser, gated with
*blockuser block (created blocked), approval = unblock, rejection = DelUser.
Architecture
Layered (per team Go standards): cmd → commands → services → repositories → db.
Repositories are only used by services; everything is interface-driven and wired
by DI in internal/commands/serve.go.
cmd/main.go entry point
config/ env-driven config (configor)
db/ embedded migrations (golang-migrate)
internal/
commands/ cobra CLI: serve, migrate up|down
db/ gorm connection + repositories (request, sighting, decision)
checks/ signal detectors: ip (DNSBL/Tor/ASN), email (MX/disposable/normalize), similarity
services/risk/ aggregates checks + correlation -> verdict
services/similarity/ sign-up similarity check: which existing account a request looks like, and why
services/approval/ lifecycle orchestrator (intake -> verify -> assess -> act)
znc/ ZNC control-module driver
irc/ girc client: command routing + WHOIS enrichment
http/ click-to-verify web endpoint + healthz
mail/ SMTP verification emails
Verification (either method works)
On !bnc <username> <email> the bot creates the account blocked, emails a
code, and waits. The user activates with either:
- clicking
HTTP_BASE_URL/verify?token=...from the email, or - typing
!verify <code>on IRC.
Only after verification does the risk engine run.
Email verifications with an action
Separately from registration, email_verifications holds verifications that
gate an action ("purpose"). Each account has at most one pending link of any
purpose: issuing a new one invalidates the old. Tokens are stored only as
SHA-256 digests.
- reverify (dashboard "re-verify email"): staff ask an existing user to
re-confirm their address. Completing it (link or
!verify <code>) records the confirmation and changes nothing else: status, services and ZNC are untouched. Links last 7 days. - password_reset (
!bncreset <username>): emails the account owner a link to choose a new bouncer password. Only the person who can read that inbox can complete it:- 256-bit single-use tokens, claimed atomically, valid for 1 hour.
- Opening the link only shows the form; the password is accepted only by the form POST, never over IRC, so mail-scanner prefetches can't use or burn it.
- The IRC reply is identical for every outcome (no account enumeration) and each nick has a 1-minute cooldown. A new request invalidates the old link.
- No strength policy. Passwords are only refused if they can't reach ZNC intact: empty, line breaks or control characters, leading/trailing spaces, or over 300 bytes.
- Only approved accounts with an active ZNC service qualify. Changing the account's email cancels pending links.
- The new password is never stored or logged; the old generated one is wiped, and the owner is emailed a "password changed" notice.
Emails
Every email is sent as multipart/alternative: the plain-text body plus an
HTML version in the ircforever.org style (dark terminal window on a light
page). The HTML is built from MJML at development time and committed, so
production needs only Go:
cd internal/mail/templates
npm install # once; mjml is a dev-only dependency
node build.mjs window html # src/*.mjml + themes/window.json -> html/*.html
Colours live in themes/*.json (all pairs meet WCAG AA 4.5:1). Values are
filled by Go's html/template; if a template ever fails to render, the email
still goes out as text.
Announcing evrd to ZNC users
managebot announce-evrd emails every active ZNC user about evrd, with a link
to move themselves over: a user in znc.conf (through the provision agent) with
an approved account and an email, whose ZNC service isn't blocked, who has no
evrd account yet and hasn't been invited before. ZNC's own *blockuser list
isn't visible to managebot, so pass those names with --skip. Each invite
sent is recorded in the activity log (evrd-invite); --resend includes
people invited already.
managebot announce-evrd --skip a,b # list who'd get it, and who's left out and why
managebot announce-evrd --to me@example.org --as alice # one test copy, written for alice (its link moves no one)
managebot announce-evrd --skip a,b --send # email everyone listed (2s apart; --pause)
Telling ZNC clients where evrd is
A moved user's client that still points at ZNC is refused by the
evrdmoved ZNC module with evrd's address and how to
sign in, instead of "account disabled". managebot marks each move with it
(Moved <user> to *evrdmoved, ZNC_EVRDMOVED) and clears it when an
account on evrd is deleted.
Self-serve moves to evrd
A ZNC user can move themselves, without staff, with a link that only ever
goes to their account's email: the invite's, or one from !moveme <username> (7 days). It opens /move-to-evrd on the set-password host
(account.4evr.sh), which shows the networks that would move; nothing happens
until they press Move me to evrd (a POST, so mail scanners opening links
can't set it off). That runs the same move as !migrate, and the team channel
is told. A new portal login's set-password link still goes by email, never
onto the page. The links are HMAC-signed with EVRD_MOVE_SECRET and bound to
the account's email; nothing is stored, a link is spent once the account is
on evrd, and rotating the secret voids them all.
On the VPS the image has no shell, so run it beside the bot:
docker run --rm --network container:managebot --env-file managebot.env managebot:deploy announce-evrd …
(the image's entrypoint is ./managebot).
Running
# Local dev
cp .env.example .env # fill in IRC_PASSWORD etc.
make setup # starts postgres (compose) + runs migrations
make run # go run cmd/main.go serve
# Docker (production)
docker compose up -d # postgres + managebot
docker compose run --rm migrate # apply migrations (profile: tools)
Note:
docker-compose.ymlpublishes Postgres on5432. If that port is busy, change the published port or run migrations through themigrateservice which talks to the container directly.
Configuration
All via environment variables — see .env.example and config/config.go. Key knobs:
| Var | Default | Purpose |
|---|---|---|
IRC_SERVER / IRC_PORT / IRC_PASSWORD |
— | ZNC/IRC login (user/network:pass) |
IRC_STAFF |
— | comma-separated nicks allowed !approve/!reject |
IRC_PUBLIC_CHANNEL |
#ircforever |
public channel the bot sits in and greets joiners of |
IRC_WELCOME / IRC_WELCOME_MESSAGE |
true / built-in |
NOTICE new joiners of the public channel to stay for updates + support ({nick}, {channel} substituted) |
HTTP_BASE_URL |
http://localhost:8080 |
origin used in verification links |
SMTP_* |
mail.ircforever.org:25 |
verification email delivery |
CHECK_APPROVE_THRESHOLD |
20 |
auto-approve at/below |
CHECK_REJECT_THRESHOLD |
60 |
auto-reject at/above |
CHECK_FLAGGED_ASNS |
— | hosting/VPN AS numbers to penalize |
CHECK_SHARED_NETS |
— | more shared infrastructure for the similarity check (cidr=name,…, on top of the built-in list) |
CHECK_DNSBLS |
spamhaus,barracuda,dronebl | DNS blocklists |
ZNC_CLONE_USER |
— | ZNC template account cloned for each new ZNC bouncer, so it gets the template's networks (empty = bare AddUser). evrd users pick networks from evrd's network directory instead |
EVRD_PROVISION_TOKEN |
— | evrd's provision_token; turns on !evrd and !migrate (empty = off). Deleting an account in the dashboard deletes the evrd account managebot made for it first (evrd's DELETE /api/provision/users/{username}); if evrd won't, nothing is deleted. The vhost's rDNS is reset, and the portal login goes too when its email is the account's |
EVRD_API_URL / EVRD_URL |
https://evrd.ircforever.org (both) |
evrd's provisioning API (bearer token; managebot runs on another host), and the web app (emails, and where the set-password page sends evrd users) |
EVRD_IRC_HOST / EVRD_IRC_PORT |
evrd.ircforever.org / 4353 |
what IRC clients connect to, for the email |
EVRD_HOME_NETWORK |
IRCForever irc.ircforever.org +6697 |
the network an !evrd sign-up starts with (name host [+]port, + = TLS) |
EVRD_MOVE_SECRET |
— | signs self-serve move links (invite emails, !moveme); openssl rand -hex 32. Empty = self-serve moves off |
EVRD_VHOST_PREFIX6 / EVRD_VHOST_IPV4 |
— | evrd vhosts: each !evrd sign-up and !migrated user gets <user>.ircforever.org (EVRD_VHOST_DOMAIN) on a /128 of their own from this prefix (routed to evrd's host, with a local route for it; evrd binds it with freebind) plus this IPv4 for IPv4-only networks, as every network's bind host. A migrated user's ZNC vhost name moves to the new address once ZNC is off IRC. DNS goes through the provision agent (POST /dns, needs PROVISION_URL). Empty = no vhosts (evrd picks each user's address from its upstream_prefix6) |
HCLOUD_TOKEN / HCLOUD_SERVER_ID |
— | Hetzner Cloud API token (read & write) and evrd's server, to set rDNS for evrd vhosts (best-effort; empty = no rDNS) |
VICTORIAMETRICS_URL |
— (http://victoriametrics:8428 in docker-compose) |
the VictoriaMetrics that scrapes the shells host's Incus exporter, for the account page's shell charts (GET /api/requests/{id}/shell-metrics?range=1h|6h|24h|7d: memory vs the limit, CPU as % of one core, network in/out bytes/s; cached 60s). Queried inside the docker network only. Empty = off |
Tests
make test # unit tests
go test -race ./... # unit tests, race detector
# Integration (build-tagged `integration`):
go test -tags=integration ./test/integration/...
- Unit: pure check logic (normalize/disposable/similarity/subnet), the ZNC command contract, the risk verdict thresholds + dedupe signals (mocked detectors), and the full approval lifecycle (in-memory fakes).
- Integration:
postgres_test.go— real Postgres via env (DBHOST/DBPORT/...), runs migrations and exercises every repository. Skips if the DB is unreachable.irc_znc_test.go— spins up an in-process IRC server, connects a real girc client, injects a!bnc, and asserts the bot WHOISes the user and emits the correct*controlpanel/*blockusercontrol commands end to end.
Commands (IRC)
| Command | Who | Effect |
|---|---|---|
!bnc <username> <email> |
anyone | request a bouncer; creates blocked account + sends verification |
!verify <code> |
requester | confirm email, triggers checks |
!evrd <username> <email> |
anyone | request a bouncer on evrd: same checks and verification as !bnc; on approval an evrd account with the home network, a portal login and a set-password email |
!bncreset <username> |
anyone | email the account owner a 1-hour link to choose a new bouncer password (an account on evrd is told it has no ZNC password, and where to sign in) |
!moveme <username> |
anyone | email the account owner a 7-day link to move their ZNC bouncer to evrd themselves (see Self-serve moves to evrd); same reply whatever the account |
!approve <username> |
staff | override-approve (unblock) |
!reject <username> |
staff | override-reject (deluser) |
!migrate <username> |
staff | move a ZNC account to evrd: the networks ZNC was set to connect (servers, identity, channels, SASL — read from znc.conf by the provision agent; switched-off ones, such as the clone template's, are left out and counted) are created in evrd (odd channel entries and server-less networks left out; if evrd refuses any network, it stops there with ZNC untouched), the ZNC networks disconnected and the account blocked (kept for a rollback), then evrd connects them; the owner gets a portal login and an email (set-password link, then on to evrd) |
!vhost <username> |
staff | give an account already on evrd its own vhost, as !evrd and !migrate do: <user>.ircforever.org on an address from EVRD_VHOST_PREFIX6 (DNS and rDNS published; a ZNC-era address is let go), set as the bind host of every network the account has (evrd reconnects the connected ones). Safe to repeat |
!help |
anyone | list commands; reminds users that updates/support only happen in the public channel |
Support mailbox
The dashboard's mail page reads and answers support@ircforever.org. managebot polls the inbox over IMAP (read-only, so mail clients still see messages as unread) and sends replies through SMTP submission as the support address, saving a copy in Sent. Every dashboard email uses the support template (internal/mail/templates/src/support.mjml) and is signed with the staff member's name. Attachments of up to 20 MB per email can be added by picking, dropping or pasting files. Each account page has a correspondence section with every email to and from that address, including the verification and welcome emails managebot sends.
New mail from a person posts a line in the team channel. Automated mail (cron output, DMARC reports, bounces, anything with Auto-Submitted/Precedence/List-Id) is stored and marked read, but not announced.
| env | default | |
|---|---|---|
SUPPORT_PASSWORD |
— | the mailbox password; unset = mailbox off |
SUPPORT_ADDRESS / SUPPORT_USER |
support@ircforever.org / the address |
|
SUPPORT_NAME |
IRCForever Support |
From name |
SUPPORT_IMAP_HOST / _PORT |
mail.ircforever.org / 993 |
|
SUPPORT_SMTP_HOST / _PORT |
mail.ircforever.org / 587 |
|
SUPPORT_MAILBOX / SUPPORT_SENT_MAILBOX |
INBOX / Sent |
|
SUPPORT_POLL_SECONDS |
60 |
|
SUPPORT_MAX_UPLOAD_MB |
20 |
|
SUPPORT_DRY_RUN |
false |
log outgoing mail without sending (local dev) |
Run managebot migrate up before the first start (migration 000014).