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:
@@ -19,6 +19,9 @@ inheritance) on something simple before adding real networking on top.
|
||||
cp .env.example .env
|
||||
cargo run # the daemon: cloud uplink + go2rtc watchdog
|
||||
cargo run --example printer_polymorphism # standalone demo, no network/env needed
|
||||
|
||||
cp printers.example.toml printers.toml # fill in your real printers (gitignored)
|
||||
cargo run --example test_bambu_certs # real TLS handshake test against each Bambu printer
|
||||
```
|
||||
|
||||
## Structure
|
||||
@@ -27,16 +30,26 @@ cargo run --example printer_polymorphism # standalone demo, no network/env nee
|
||||
src/
|
||||
main.rs Runs the uplink and the go2rtc watchdog side by side
|
||||
config.rs Loads settings from environment variables
|
||||
fleet.rs Loads printers.toml into ready-to-use PrinterHandles
|
||||
uplink/ WebSocket client to continuum-backend: connect, heartbeat, reconnect on drop
|
||||
printer/ Printer trait + PrinterBase + PrinterHandle enum + one stub per vendor
|
||||
printer/ GenericPrinter trait + PrinterBase + PrinterHandle enum + one stub per vendor
|
||||
go2rtc.rs Restarts the go2rtc camera-restreaming process if it dies
|
||||
examples/
|
||||
printer_polymorphism.rs Runs all three printer stubs through one `connect()` call site
|
||||
printer_polymorphism.rs Runs all five printer stubs through one `connect()` call site
|
||||
test_bambu_certs.rs Loads printers.toml, does a real TLS handshake to each Bambu printer
|
||||
```
|
||||
|
||||
`src/printer/` is where the "inheritance" question lives — see that
|
||||
module's doc comment for the trait+enum pattern this project uses instead
|
||||
of class inheritance, and run the example above to see it work.
|
||||
of class inheritance, and run `printer_polymorphism` to see it work.
|
||||
|
||||
`printers.toml` (gitignored — copy from `printers.example.toml`) holds real
|
||||
per-printer connection details: host, access code, and — since not every
|
||||
Bambu printer trusts the same certificate (see `certs/README.md`) — an
|
||||
optional per-printer CA override. `src/fleet.rs` loads it; nothing in
|
||||
`main.rs` uses it yet, but `test_bambu_certs` does, as a real (if narrow —
|
||||
just the TLS handshake, no MQTT) way to check a printer's certificate
|
||||
without needing the full MQTT client built yet.
|
||||
|
||||
## What's not here yet (on purpose)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user