Conversation
- StunClient: RFC 5389 Binding Request builder and XOR-MAPPED-ADDRESS parser; detects STUN datagrams by magic cookie before KRPC parsing - DhtHandler: routes STUN responses to a pending TCS in the receive loop; exposes DiscoverExternalEndPointAsync (3s timeout) - DhtClient: discovers external endpoint via STUN on bootstrap, then sends announce_peer after every get_peers response that carries a token; uses implied_port=false + TCP listen port when STUN succeeds, implied_port=true as fallback when behind symmetric NAT - DhtClientOptions: StunServers defaults to Google public STUN servers - Torrent: passes TCP listen port into DhtClient for announce_peer Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
xBaank
marked this pull request as draft
April 5, 2026 14:52
Open
…s, drop STUN - TrackerClient now waits on the cancellation token when UsedTrackers is 0 instead of returning immediately, which previously made RunUntilFirstCompletesAsync cancel the entire torrent (including DHT) before any peers could be discovered. - Rewrote DhtClient.GetPeersAsync and IterativeFindNodeAsync as proper Kademlia iterative lookups: sorted shortlists by XOR distance, parallel alpha-rounds, MaxRounds cap so a single lookup yields the actor back to its mailbox in bounded time. Added ResolveIpv4Async to avoid AAAA DNS hangs on IPv6-less networks. - Tuned DhtHandler retry timings (2s x 2) so unresponsive nodes don't block the actor for tens of seconds per query. - Removed STUN-based NAT traversal: it discovers a UDP mapping that can't legitimately drive announce_peer for a separate TCP listen port, added startup latency, and contributed nothing to the read path. announce_peer now always sends ImpliedPort=false; the wire-level field is kept on KrpcMessage for parsing inbound queries from other clients. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.