Commit 2547c0a
feat(discovery): the daemon derives a peer's identity port itself — the by-hand dial, encoded (#1301 caller side)
Measured live 2026-08-15, BigMama -> M5: the peer was enrolled, its Mac
answered mDNS, its daemon was LISTENING on its identity-derived stable port
— and every STORED endpoint for it carried a stale ephemeral port from the
pre-#1369 churn. Discovery dialed corpses and reported "0 routes, 96
enrolled peers". The connection that finally worked was a human doing the
derivation by hand:
arp/mDNS -> the IP (192.168.1.249)
stable_lan_port(id) -> the port (57958, from peer 2f0aed7f)
airc dial --expected-peer ... -> CONNECTED, authenticated
A user without a terminal cannot do any of that. Joel: "There is no one to
manually do shit... all of this must work automatically for users." So the
sequence becomes a dial rung.
`identity_port_candidates` pairs every IP already known for a peer (stored
endpoints; learned IPs ride in via the existing #9 rung) with the ONE port
knowable WITHOUT any advertisement: stable_lan_port of the peer's transport
host. Derived from the dial PIN, not the record peer — the listener binds
the wire-owning scope's identity, so a record answered by a declared host
must derive from that host (machine-vs-scope, same rule as the TLS pin).
Appended LAST, not prepended: post-#1369 the advertised port IS the stable
port, so stored endpoints normally win and this rung costs nothing. It pays
exactly when the stored set is stale — churn-era records, or a peer whose
bind fell back — and failure-counted eviction retires the corpses so the
rung stops paying their timeouts. When a stored endpoint already carries the
derived port, no candidate is added (pinned by test).
With #1369 (bind keeps the stable port across restarts) this closes the loop
from both ends: the listener stays where identity says it should be, and the
dialer can now find it there with nothing but the trust store.
Verified: cargo test -p airc-lib --lib — 336 passed, 0 failed.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc1 parent f04a59e commit 2547c0a
1 file changed
Lines changed: 104 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
101 | 144 | | |
102 | 145 | | |
103 | 146 | | |
| |||
515 | 558 | | |
516 | 559 | | |
517 | 560 | | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
518 | 566 | | |
519 | 567 | | |
520 | 568 | | |
| |||
1197 | 1245 | | |
1198 | 1246 | | |
1199 | 1247 | | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
1200 | 1304 | | |
1201 | 1305 | | |
1202 | 1306 | | |
| |||
0 commit comments