Open
Description
I'm setting up a local test based on StressTest.cs
. I subscribed to event handlers, and noticed that each peer was trying and failing to connect to themself. Example output -
Connection failed: ipv4://127.0.0.1:37001/, HandshakeFailed
Peer Disconnected: ipv4://127.0.0.1:37001/
Connection failed: ipv4://127.0.0.1:37001/, EncryptionNegiotiationFailed
Peer Disconnected: ipv4://127.0.0.1:37001/
After some debugging, I realized that AnnounceResponse
's peers PeerInfo.PeerId
is empty. When created on the Tracker at SimpleTorrentManager.GetPeers
, with compact=1
the PeerId isn't included. In TorrentManager.AddPeer
, this check then doesn't get hit -
if (Engine!.PeerId.Equals (peer.Info.PeerId))
return false;
Which results in the torrent manager adding itself as a peer.
I think a proper fix would be to include the PeerId in the compact byte[].
For a workaround I extended HttpTrackerListener
, turning off "compact"
private class NonCompactHttpTrackerListener : HttpTrackerListener
{
public NonCompactHttpTrackerListener( string httpPrefix ) : base( httpPrefix )
{
}
public override BEncodedDictionary Handle( NameValueCollection collection, IPAddress remoteAddress, bool isScrape )
{
collection[ "compact" ] = "0"; // don't compact the peers, it results in missing data which causes peers to try to connect to themself (and fail)
return base.Handle( collection, remoteAddress, isScrape );
}
}
Metadata
Metadata
Assignees
Labels
No labels