feat: native SDK fallback to ICANN when PubkyTLS direct endpoint is unreachable#352
Conversation
17ebc0e to
a6eed11
Compare
a6eed11 to
fb9dc82
Compare
86667
left a comment
There was a problem hiding this comment.
Reasonable to have this logic in cross_request() and solid caching stratergy.
The code is quite ugly though, I'm sure AI could clean it up a bit. eg:
cross_request()can be split up - currently mixes transport resolution with request building- A small struct owning caching and some of this logic would be nice
I especially dont like this pattern:
let transport = if let Some(t) = transport {
t
} else {
// 30 lines of code
}
|
@SeverinAlexB made this useful comment in Homegate - pubky/homegate#20 (review) Probably applies here too. |
7369fa1 to
4336784
Compare
4336784 to
917627a
Compare
|
@86667 Thanks a lot for the review! Pushed one commit addressing the function complexity problem. Much cleaner now, used Sev's "skills". One function |
86667
left a comment
There was a problem hiding this comment.
Looking good. Couple bits which could be added but not blockers imo.
Problem
Native clients (Pubky Ring, CLI tools) can't reach homeservers behind Cloudflare Tunnel or NAT proxies.
A homeserver's PKARR record advertises two HTTPS endpoints:
target="."+ A/AAAA + port, PubkyTLS (RFC 7250)The native SDK delegates to pkarr's reqwest
Resolveimpl, which returns only the first endpoint (direct). When that IP is unreachable, typical for Umbrel behind Cloudflare Tunnel, the TCP connection hangs for ~75-120s and fails. The ICANN endpoint is never tried.WASM builds are unaffected: they already resolve all endpoints and pick the ICANN one.
Prior work
Why this belongs in pubky-sdk, not pkarr
The fallback requires choosing between two
reqwest::Clientinstances with different TLS stacks (self.httpfor PubkyTLS vsself.icann_httpfor X.509). Thereqwest::dns::Resolvetrait only returns socket addresses, it cannot express "switch TLS config." Pkarr already exposes all endpoints viaresolve_https_endpoints(); the SDK just wasn't consuming them on native.Closes pubky/pkarr#220. Supersedes #324.
Changes
cross_request()now explicitly resolves PKARR endpoints and selects transport:icann_http+pubky-hostheaderDecisions are cached per public key (60s TTL), this value is likely too small, we might want +1hour. Concurrent requests for the same host coalesce on a single probe via per-key async guards.