- Rust 70.1%
- TypeScript 26.9%
- Shell 3%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .pi | ||
| backend | ||
| dist | ||
| frontend | ||
| scripts | ||
| .gitignore | ||
| LICENSE | ||
| Metadata.toml | ||
| README.md | ||
CalagoWRT
CalagoWRT is a native Rust/React extension for the Calagopus Panel. It mirrors assigned Calagopus node allocations to named OpenWrt UCI redirect rules and manages only rules prefixed with calagopus_.
- Author: Fenchel
- Extension package:
dev.fenchel.calagowrt - Version: 1.0.1
- Supported Panel:
>=1.2.0, <2.0.0 - Reference target: Calagopus Panel
release-1.2.0, commitfd0edda22035148ab61eb66b4748a95ebc11c025
Behavior
An assigned allocation becomes a DNAT redirect with the same external and destination port and the allocation IP as destination. Calagopus 1.2 uses UUIDs rather than integer allocation IDs, so the deterministic UCI section name is:
calagopus_<allocation UUID without hyphens>
Example:
config redirect 'calagopus_67e5504410b1426f9247bb680e5fe0c8'
option target 'DNAT'
option name 'calagopus_67e5504410b1426f9247bb680e5fe0c8'
option src 'wan'
option dest 'lan'
option proto 'tcp udp'
option src_dport '25565'
option dest_ip '192.0.2.10'
option dest_port '25565'
option enabled '1'
Every reconcile reads uci show firewall, creates or updates missing/different managed sections, removes stale managed sections, then commits and reloads the firewall at most once. Foreign UCI sections are never changed. An assigned allocation with an invalid port or unspecified/invalid destination IP is reported as skipped and its existing rule is protected from deletion.
Install
Extensions require a Calagopus :heavy Docker image or a source development environment.
- Build
dev_fenchel_calagowrt.c7s.zipusing Build and export, or download it from a release. - In Calagopus, open Admin → Extensions and upload the archive.
- Wait for the heavy-image build to finish and reload the page.
- Grant the desired
calagowrt.*permissions to admin roles. - Open Admin → Extensions → CalagoWRT → Configure.
For a source environment:
panel-rs extensions add dev_fenchel_calagowrt.c7s.zip
panel-rs extensions apply --profile balanced
OpenWrt SSH setup
Create a dedicated key and install its public half for the configured OpenWrt user (normally root):
ssh-keygen -t ed25519 -f ~/.ssh/calagowrt -C calagowrt
ssh-copy-id -i ~/.ssh/calagowrt.pub root@openwrt.example
The account must be able to run:
uci show firewall
uci get/set/delete/commit firewall
service firewall reload
OpenWrt commonly grants these commands only to root. Restrict network access to SSH at the firewall and use a dedicated key. Calagopus 1.2 does not expose a host-key pinning control to extensions; CalagoWRT therefore accepts the key presented by the configured host. Use a trusted management network or an SSH tunnel.
Settings
| Setting | Meaning |
|---|---|
| Enabled | Enables manual and scheduled synchronization |
| Host / SSH port / Username | OpenWrt SSH endpoint |
| Private key | OpenSSH private key; encrypted with Calagopus' application key |
| Passphrase | Optional encrypted private-key passphrase |
| Source / destination zone | UCI firewall zones, defaults wan → lan |
| Protocol | tcp udp, tcp, or udp |
| Timeout | DNS, connection, authentication, and command timeout (1–300 seconds) |
| Sync interval | Minutes between reconciliations; 0 disables the scheduler |
Leaving either secret field empty while editing preserves the encrypted value already stored. The configuration page provides separate confirmed Delete private key and Delete passphrase actions; deleting the private key also disables the bridge. Test SSH connection verifies key parsing, authentication, and permission to read the UCI firewall configuration. Secrets are omitted from API responses, logs, dry-run output, source, and packages.
Use
- Admin → CalagoWRT: searchable, sortable, paginated allocation overview.
- Synchronize: confirmed full reconcile.
- Dry run: reads OpenWrt and calculates commands but does not execute them. Commands are available from the CLI and logged to the browser console for an admin-triggered dry run.
- Delete free: confirmed deletion of globally unassigned allocations. The SQL
DELETErepeats the unassigned condition, so a concurrently assigned allocation is not removed.
CLI:
panel-rs calagowrt sync
panel-rs calagowrt sync --dry-run
The scheduled task runs only on Calagopus' primary application instance. A PostgreSQL advisory lock also prevents overlapping scheduled/manual runs across instances.
Calagopus 1.2 capability notes
| Requested capability | Calagopus 1.2 implementation |
|---|---|
| Allocation identity | Node allocation UUID; UCI-safe compact UUID replaces Pelican's integer ID |
| Create/update/delete allocation events | NodeAllocation has no model event traits in 1.2.0; full periodic/manual reconcile is the safe adapter |
| Assignment events | ServerAllocation update/delete hooks exist, but creation has no hook and after-hooks run inside the DB transaction; network I/O there could roll back allocation changes, so it is intentionally not used |
| Locked allocation field | No such field exists in Calagopus 1.2's node allocation model; the overview omits it |
| Allocation notes | Notes belong to an assigned ServerAllocation; free allocations have no notes |
| Secret store | Per-setting encryption through Database::encrypt/decrypt |
| Distributed scheduling | Primary-instance task plus PostgreSQL advisory lock |
These adapters avoid copying Laravel/Pelican classes and avoid coupling external SSH failures to Calagopus allocation transactions.
Build and export
Use an official Panel 1.2.x checkout:
git clone --branch release-1.2.0 https://github.com/calagopus/panel.git calagopus-panel
PANEL_ROOT="$PWD/calagopus-panel" ./scripts/check.sh
PANEL_ROOT="$PWD/calagopus-panel" ./scripts/export.sh
The official panel-rs extensions export dev.fenchel.calagowrt command writes the archive to exported-extensions/dev_fenchel_calagowrt.c7s.zip in the Panel checkout.
Troubleshooting
- disabled: enable the extension and configure all SSH fields.
- already-running: another panel process or admin is synchronizing; retry after it finishes.
- public key entered: the Panel field needs the private key beginning with
-----BEGIN OPENSSH PRIVATE KEY-----, not the one-line.pubvalue. - unsupported private-key format: convert or regenerate the key in OpenSSH format; CRLF and literal
\\nline endings are normalized automatically. - authentication rejected: verify the user, key, passphrase, and OpenWrt
authorized_keys. Use Test SSH connection to get the precise validation stage. - command timeout: increase the timeout and test SSH from the Panel host.
- rule remains skipped: correct the allocation IP/port; the existing rule is deliberately preserved until the desired target becomes valid.
- build fails: use the heavy image build log under Admin → Extensions; 8 GB RAM may be needed for extension builds.