rups
A Network UPS Tools (NUT) client library for Rust.
- Connect to
upsd/nut-serverusing TCP - Login with username and password
- List UPS devices
- List variables for a UPS device
- Connect securely with SSL (optional feature)
- Supports blocking and async (Tokio)
Getting Started
You'll need a running instance of the NUT daemon (upsd, version >= 2.6.4) and
a compatible UPS device
to use this library:
Verify that your UPS is connected using the built-in upsc tool:
Example
The rupsc CLI is written using this library, and is a clone of NUT's built-in upsc tool.
Below is a sample program using this library (cargo run --example blocking).
You can also run the async version of this code using
cargo run --example async --features async-rt (source: rups/examples/async.rs).
// rups/examples/blocking.rs
use env;
use Connection;
use ;
use TryInto;
SSL
You can turn on SSL support by adding .with_ssl(true) in the ConfigBuilder. This requires the ssl feature, which
uses rustls under the hood.
Note that, by default, .with_ssl(true) will enable strict verification. This means it will verify the server
certificate's DNS entries, check for revocation, and verify the chain using the local root trust. You must also ensure
that the connection hostname is a valid DNS name (e.g. localhost, not 127.0.0.1).
If the server is using a self-signed certificate, and you'd like to ignore the strict validation, you can add
.with_insecure_ssl(true) along with .with_ssl(true).
Async (Tokio)
The rups library supports async network requests. This requires the async feature, which uses Tokio v1 under the
hood.
For SSL support, you must use the async-ssl feature as well.
Pronunciation
r-oops
License
The crates in this repository are licensed as such:
rups: MIT License, see./LICENSErupsc: GPL-3.0 or later, see./rupsc/LICENSE