| Crates.io | rustpatcher-macros |
| lib.rs | rustpatcher-macros |
| version | 0.1.0 |
| created_at | 2025-03-05 21:49:25.785079+00 |
| updated_at | 2025-03-05 21:49:25.785079+00 |
| description | p2p patching system |
| homepage | |
| repository | https://github.com/rustonbsd/rustpatcher |
| max_upload_size | |
| id | 1579859 |
| size | 5,535 |
Secure Decentralized Software Updates - Working work in progress
# Cargo.toml
[dependencies]
rustpatcher = "0.1"
cargo run -- rustpatcher init
Output:
New keys generated:
Trusted-Key = mw6iuq1iu7qd5gcz59qpjnu6tw9yn7pn4gxxkdbqwwwxfzyziuro
Shared-Secret = 8656fg8j6s43a4jndkzdysjuof588zezsn6s8sd6wwcpwf6b3r9y
Add to build.rs:
println!("cargo:rustc-env=TRUSTED_KEY=mw6iuq...");
println!("cargo:rustc-env=SHARED_SECRET_KEY=8656fg...");
// build.rs
fn main() {
println!("cargo:rustc-env=TRUSTED_KEY={}", env!("TRUSTED_KEY"));
println!("cargo:rustc-env=SHARED_SECRET_KEY={}", env!("SHARED_SECRET_KEY"));
}
// main.rs
use rustpatcher::Patcher;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let patcher = Patcher::new()
.trusted_key_from_z32_str(env!("TRUSTED_KEY"))
.shared_secret_key_from_z32_str(env!("SHARED_SECRET_KEY"))
.build()
.await?;
}
# Increment version in Cargo.toml first
cargo run -- rustpatcher publish
Creates signed package with:
sequenceDiagram
Master->>+PKARR: Publish signed package
Master->>+Iroh: Announce version topic
Master-->>Network: Propagate via DHT
sequenceDiagram
Client->>+PKARR: Check version records
PKARR-->>-Client: Return latest signed package
Client->>+Iroh: Discover peers via topic
Iroh-->>-Client: Return node list
Client->>Peer: Establish P2P connection
Peer-->>Client: Stream verified update
Client->>Self: Safe replace via self_replace
Version Propagation
Update Verification
// Verification chain
if pub_key.verify(&data, &sig).is_ok()
&& compute_hash(data) == stored_hash
&& version > current_version {
apply_update()
}
Self-Update Mechanism
| Command | Function |
|---|---|
init |
Generate cryptographic identity |
publish |
Create/distribute signed package |
Zero configuration needed for peer discovery - automatic via Iroh Topic Tracker