Upgrading
CasWAF is developed on the master branch of caswaf/caswaf, and each gateway runs a checkout of it. The tables are updated by CasWAF itself when it starts, so upgrading is getting the new code and restarting.
By hand
cd /opt/caswaf
git pull
cd web && yarn install && yarn build && cd ..
go build -o caswaf .
sudo systemctl restart caswaf-site-caswafSkip the web step when nothing under web/ changed. The console's files are read from web/build on each request, so a new build shows without a restart.
Restarting the gateway drops the connections it holds and resets rate limit counts and passed CAPTCHAs. With several nodes, upgrade them one at a time.
If conf/app.conf has local changes that conflict with a change upstream, git pull stops; move your values aside, pull, and put them back.
Self-update
A gateway can update itself from Git. Every five minutes it checks for new commits on the branch its checkout tracks, and if there are any:
- it pulls them and builds a new program,
<appDir>/_bin/<dbName>/<dbName>_<commit>.exe; - it rebuilds the console if anything under
web/changed; a failed console build does not hold the update back; - it restarts on the new program: on Linux by pointing its systemd unit at the new program and exiting, so systemd starts it again; on Windows by starting the new program a few seconds later and exiting.
If the build fails, it goes back to the commit it was running, keeps running, and does not try that upstream commit again; it waits for the next one.
Self-update runs only when all of these hold:
- the machine runs Windows, or Linux with CasWAF as a systemd service;
- CasWAF runs from a Git checkout, and Go, and Yarn for the console, are installed;
- there is an entry for the machine on the Nodes page, owned by
admin, with Self update on; - the node's Upgrade mode allows it now:
At Any Time, or the half hour from 23:00 UTC+8 forHalf A Hour;No Upgradestops it.
Turn it on for a test node first, and for the rest once you trust the branch you follow. For a fixed version, point the checkout at a branch you move yourself.
Nodes
Run CasWAF on several machines against one database: what is shared, what each gateway keeps to itself, and the node settings for upgrades.
Roadmap
What is being built next in CasWAF: deploying applications from Git, richer request records, countries in IP rules, wildcard certificates and roles in the console.