35 lines
1.3 KiB
Rust
35 lines
1.3 KiB
Rust
//! Run with: cargo run --example test_bambu_certs
|
|
//!
|
|
//! Loads printers.toml (copy printers.example.toml to get started, fill in
|
|
//! your real printers) and attempts a raw TLS handshake to each Bambu
|
|
//! printer's MQTTS port (8883) - no MQTT protocol involved, just "does the
|
|
//! certificate verify". Prusa/Klipper entries are skipped; they don't have
|
|
//! this trust question.
|
|
|
|
use continuum_proxy::fleet;
|
|
use continuum_proxy::printer::{GenericPrinter, PrinterHandle};
|
|
|
|
fn main() -> anyhow::Result<()> {
|
|
let printers = fleet::load(std::path::Path::new("printers.toml"))?;
|
|
|
|
// BambuV1Printer and BambuV2Printer are separate types (each *has* a
|
|
// BambuGenericPrinter rather than being the same struct), so this
|
|
// needs one arm per variant rather than a single `A(x) | B(x)` pattern.
|
|
for printer in &printers {
|
|
match printer {
|
|
PrinterHandle::BambuV1(bambu) => report(bambu.base().name.as_str(), bambu.test_tls_handshake()),
|
|
PrinterHandle::BambuV2(bambu) => report(bambu.base().name.as_str(), bambu.test_tls_handshake()),
|
|
_ => {}
|
|
}
|
|
}
|
|
|
|
Ok(())
|
|
}
|
|
|
|
fn report(name: &str, result: anyhow::Result<()>) {
|
|
match result {
|
|
Ok(()) => println!("{name}: OK - certificate verified"),
|
|
Err(err) => println!("{name}: FAILED - {err}"),
|
|
}
|
|
}
|