Add printers.toml (gitignored) + real TLS cert test against actual hardware
New: - printers.example.toml (committed template) / printers.toml (gitignored, real hosts + access codes don't belong in git) — a list of real printers with vendor, host, access_code/api_key/com_port, and an optional per-printer CA override. - src/fleet.rs loads that file into ready-to-use PrinterHandles, matching vendor strings to the right constructor. - BambuPrinter::test_tls_handshake() does a real (blocking, one-shot) TLS handshake to port 8883 using that printer's configured BambuTls trust mode — no MQTT protocol, just 'does the certificate verify'. Added native-tls and toml as direct dependencies for this. - examples/test_bambu_certs.rs loads printers.toml and runs the handshake test against every Bambu entry. Also fixes a real bug found while testing against unreachable IPs: plain TcpStream::connect has no timeout and hung indefinitely on an offline printer — switched to connect_timeout (5s). Verified with cargo check --all-targets (0 errors) and by actually running test_bambu_certs against a local printers.toml (correctly errored on a missing cert file, then correctly timed out against unreachable test IPs instead of hanging).
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
//! 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"))?;
|
||||
|
||||
for printer in &printers {
|
||||
if let PrinterHandle::BambuV1(bambu) | PrinterHandle::BambuV2(bambu) = printer {
|
||||
print!("{}: ", bambu.base().name);
|
||||
match bambu.test_tls_handshake() {
|
||||
Ok(()) => println!("OK — certificate verified"),
|
||||
Err(err) => println!("FAILED — {err}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user