Milestone 4: LAN discovery, trust gate, auto-sync, rate limits, events

mDNS-style LAN discovery (iroh MdnsDiscovery, discovery flag, default
on) feeds a presence tracker; trusted peers that appear trigger fetches
of every incomplete pin, and Pin itself now fetches from present
trusted peers. Serving is our own ProtocolHandler: trusted NodeIds get
the full store, everyone else a filtered view limited to open_lan pins
and ticket-exported hashes (plus hashseq children) that answers "not
found" for the rest. Ticket export records standing serve-consent for
that hash; trust changes take effect on new connections. ShapedStore
implements the full iroh-blobs Store trait to charge provider reads to
an upload token bucket and downloader writes to a download bucket;
upload cap 0 closes incoming connections at accept. Subscribe now
streams transfer_progress both ways, peer_joined, and pin_complete.

Tests: forged-ticket trust gating (denied untrusted, served after
trust), 256 KiB/s upload cap enforced by wall clock, event stream
during a transfer, and real-mdns auto-sync between two daemons
(skips where multicast is unavailable).

Dependencies: n0-future, async-channel, futures-lite, bytes — all
already in the tree via iroh; needed directly to name types in
iroh-blobs trait signatures and channels. iroh feature
discovery-local-network for MdnsDiscovery.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-14 22:27:58 +02:00
parent 61171a5ea8
commit 20bdf56668
12 changed files with 1308 additions and 66 deletions
Generated
+40
View File
@@ -2,6 +2,20 @@
# It is not intended for manual editing.
version = 4
[[package]]
name = "acto"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a026259da4f1a13b4af60cda453c392de64c58c12d239c560923e0382f42f2b9"
dependencies = [
"parking_lot",
"pin-project-lite",
"rustc_version",
"smol_str",
"tokio",
"tracing",
]
[[package]]
name = "aead"
version = "0.5.2"
@@ -1764,6 +1778,7 @@ dependencies = [
"strum",
"stun-rs",
"surge-ping",
"swarm-discovery",
"thiserror 2.0.18",
"time",
"tokio",
@@ -3761,6 +3776,12 @@ dependencies = [
"serde",
]
[[package]]
name = "smol_str"
version = "0.1.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fad6c857cbab2627dcf01ec85a623ca4e7dcb5691cbaa3d7fb7653671f0d09c9"
[[package]]
name = "snafu"
version = "0.8.9"
@@ -3949,6 +3970,21 @@ dependencies = [
"tracing",
]
[[package]]
name = "swarm-discovery"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3a95032b94c1dc318f55e0b130e3d2176cda022310a65c3df0092764ea69562"
dependencies = [
"acto",
"anyhow",
"hickory-proto",
"rand 0.8.7",
"socket2 0.5.10",
"tokio",
"tracing",
]
[[package]]
name = "syn"
version = "1.0.109"
@@ -4572,9 +4608,13 @@ name = "varde-daemon"
version = "0.1.0"
dependencies = [
"anyhow",
"async-channel",
"bytes",
"futures-lite",
"iroh",
"iroh-blobs",
"iroh-io",
"n0-future",
"proptest",
"rand 0.8.7",
"reflink-copy",