TIP-olg-ucentral-client is a Go daemon that acts as a secure Cloud Gateway bridging the OpenWiFi Cloud Controller (via WebSocket/JSON-RPC 2.0 mTLS) and local device microservices using a local NATS message bus.
The default mode relies on strict TLS and NKey validation for production security, but supports an explicit allow_insecure_local_dev flag for CI and local development.
- Loads runtime settings from
config.json. - Establishes a strict mTLS WebSocket connection to the OpenWiFi Cloud Controller.
- Connects to the local NATS message bus.
- Subscribes to the
result.vyos(or configured target) topic to handle asynchronous downstream replies. - Translates incoming OpenWiFi JSON-RPC requests into standardized NATS envelopes.
- Publishes configuration payloads to
cmd.configure.vyos. - Publishes operational actions to
cmd.action.vyos.<action>. - Maintains strict payload size limits (e.g., 10MB configure limit) to prevent memory exhaustion.
- Maintains an active state machine lock for heavy actions (like
upgradeorreboot) to prevent conflicting concurrent state changes. - Manages request timeouts based on configurable environment variables.
- Caches completed transaction responses for a configurable TTL so duplicate requests can be safely replayed without re-executing the downstream operation.
- Pushes standard telemetry directly from NATS to the Cloud Controller (To be implemented).
The client uses JSON as the runtime source of truth.
Default config path:
config.json
Config path resolution:
- The path supplied with
-config. config.jsonwhen-configis omitted.
Example config file:
config.example.json
(Note: This file is provided purely to illustrate the structural schema of the configuration. It contains placeholder values that will fail strict validation out-of-the-box. You must configure it with consistent credentials and network schemes for your specific environment.)
Important rule:
- Environment variables override operational timeouts, payload limits, and cache TTLs. A complete list of all supported operational variables and their defaults is documented in the provided
.env.examplefile. config.jsondictates network routes, queue capacities, and TLS paths. Theserialfield is strictly ignored inconfig.jsonto prevent identity spoofing.
The agent must not hardcode Cloud URLs, NATS servers, or TLS paths.
mTLS enforcement:
By default, the client enforces strict TLS on the Cloud connection requiring ca_file, client_cert_file, and client_key_file to be specified and cryptographically valid.
To successfully configure and connect the client to an OpenWiFi Cloud Controller:
- Obtain mTLS Certificates: You must provision the device with a valid
cert.pemandkey.pemsigned by the Cloud's operational Certificate Authority. You will also need the public Root CA bundle (ca.pemor system certificates). - Set the Target URL: In
config.json, configure thecloud.urlto point to the Cloud Controller's WebSocket port (typically15002, not443), for example:wss://openwifi.example.com:15002. - Configure the Identity: The device identity is securely loaded from the path specified by the
OW_INTERFACE_MAP_FILEenvironment variable, which defaults to/etc/ucentral/interface_map.jsonat boot. This file must be provisioned by the host hardware and must contain a serial number matching what is expected by the Cloud Controller (and bound to the client certificate CN). - Start the Local Bus: Ensure a local NATS server is running and accessible.
- Production: Must use secure
tls://...connections with a validcredentials_fileandca_file. - Local/CI Development: Can use plaintext
nats://127.0.0.1:4222provided"allow_insecure_local_dev": trueis explicitly set in the configuration.
- Production: Must use secure
- Run the Daemon: Start the client using
go run ./cmd/ucentral-client -config ./config.json.
The runtime config is JSON, and local persistent state (like the active state lock) is managed by an OperationStore disk backend, ensuring robust state recovery after restarts and mitigating stale locks.
TIP-olg-ucentral-client/
README.md
SPEC.md
config.example.json
.env.example
go.mod
cmd/
ucentral-client/
main.go
handler.go
main_test.go
handler_test.go
pkg/
config/
config.go
contracts/
enums.go
rpc.go
nats/
client.go
queues/
scheduler.go
reqmgr/
manager.go
cache.go
disk_store.go
websocket/
client.go
tests/
integration_test.go
system_e2e/
system_test.go
go test ./...
UNFORMATTED=$(gofmt -l $(find . -type f -name '*.go' -not -path './.git/*'))
test -z "$UNFORMATTED"
go build ./...
go run ./cmd/ucentral-client -config ./config.jsonThis client has been tested and validated against the opensource OpenLan Cloud Controller Mango Cloud deployment version 1.0. This real-world integration confirms compatibility with core OpenWiFi Cloud Controller specifications, including strict mTLS WebSocket handshakes, JSON-RPC 2.0 schema validation, and real-time NATS state synchronization under production-like conditions.
.github/workflows/ci.yml validates:
- Module verification
gofmtformatting checkgo vetandstaticcheckfor static analysisgovulncheckand advisorygosecfor security vulnerabilitiesgo test -v -race -p=1 ./...(with data race detection and sequential execution)go build ./...
The current binary supports:
- long-running runtime mode using
websocket.WSClientandnats.NATSClient(Start, handler registration, graceful Close) - strict JSON-RPC payload limit parsing and memory clamping via
OLG_PAYLOAD_LIMIT_*environment variables - configuration workflow dispatching to
cmd.configure.vyos - action workflow dispatching to
cmd.action.vyos.<action> - automatic lock release and transaction timeouts when downstream agents fail to respond
- deep JSON-RPC error translations leveraging standard
-32603schemas for application failures
go run ./cmd/ucentral-client -config ./config.jsonOptions
| Option | Description |
|---|---|
-config <path> |
Path to the JSON configuration file. |
Running the client loads the configuration, initializes the CapabilityCache, PriorityScheduler, OperationStore, and NATSClient. It then dials the OpenWiFi Cloud WebSocket.
Once the WSClient achieves a connected and verified state, it begins receiving JSON-RPC frames.
It uses the ReqManager to create transactions and locks. If the request is state-changing (like upgrade or reboot), it sets a lock. It publishes the command to NATS, sets a dispatch timeout, and waits for a response on result.vyos.
When the downstream agent publishes a result, the NATS handler validates the result envelope against expected schema constraints. It parses it via BuildDeviceResultObject(), translates it into JSON-RPC, and pushes it to the Outbound Scheduler back to the Cloud.
TIP-olg-ucentral-client handles Cloud-facing behavior (WebSocket stability, JSON-RPC schema compliance, queueing, request management). vyos-nats-agent (or similar agents) handles device-specific orchestration. Real VyOS behavior stays behind the NATS boundary so the client remains purely a lightweight, high-performance protocol bridge.