@ -349,9 +349,9 @@ void Tracker::processAnnounceRequest()
| | ( announceReq . event = = ANNOUNCE_REQUEST_EVENT_COMPLETED )
| | ( announceReq . event = = ANNOUNCE_REQUEST_EVENT_COMPLETED )
| | ( announceReq . event = = ANNOUNCE_REQUEST_EVENT_STARTED )
| | ( announceReq . event = = ANNOUNCE_REQUEST_EVENT_STARTED )
| | ( announceReq . event = = ANNOUNCE_REQUEST_EVENT_PAUSED ) ) {
| | ( announceReq . event = = ANNOUNCE_REQUEST_EVENT_PAUSED ) ) {
// [BEP-21] Extension for partial seeds (partial support)
// [BEP-21] Extension for partial seeds
// (partial support - we don't support BEP-48 so the part that concerns that is not supported)
registerPeer ( announceReq ) ;
registerPeer ( announceReq ) ;
prepareAnnounceResponse ( announceReq ) ;
}
}
else if ( announceReq . event = = ANNOUNCE_REQUEST_EVENT_STOPPED ) {
else if ( announceReq . event = = ANNOUNCE_REQUEST_EVENT_STOPPED ) {
unregisterPeer ( announceReq ) ;
unregisterPeer ( announceReq ) ;
@ -359,6 +359,8 @@ void Tracker::processAnnounceRequest()
else {
else {
throw TrackerError ( " Invalid \" event \" parameter " ) ;
throw TrackerError ( " Invalid \" event \" parameter " ) ;
}
}
prepareAnnounceResponse ( announceReq ) ;
}
}
void Tracker : : registerPeer ( const TrackerAnnounceRequest & announceReq )
void Tracker : : registerPeer ( const TrackerAnnounceRequest & announceReq )
@ -404,6 +406,7 @@ void Tracker::prepareAnnounceResponse(const TrackerAnnounceRequest &announceReq)
lt : : entry : : string_type peers ;
lt : : entry : : string_type peers ;
lt : : entry : : string_type peers6 ;
lt : : entry : : string_type peers6 ;
if ( announceReq . event ! = ANNOUNCE_REQUEST_EVENT_STOPPED ) {
int counter = 0 ;
int counter = 0 ;
for ( const Peer & peer : asConst ( torrentStats . peers ) ) {
for ( const Peer & peer : asConst ( torrentStats . peers ) ) {
if ( counter + + > = announceReq . numwant )
if ( counter + + > = announceReq . numwant )
@ -414,6 +417,7 @@ void Tracker::prepareAnnounceResponse(const TrackerAnnounceRequest &announceReq)
else if ( peer . endpoint . size ( ) = = 18 ) // IPv6 + port
else if ( peer . endpoint . size ( ) = = 18 ) // IPv6 + port
peers6 . append ( peer . endpoint ) ;
peers6 . append ( peer . endpoint ) ;
}
}
}
replyDict [ ANNOUNCE_RESPONSE_PEERS ] = peers ; // required, even it's empty
replyDict [ ANNOUNCE_RESPONSE_PEERS ] = peers ; // required, even it's empty
if ( ! peers6 . empty ( ) )
if ( ! peers6 . empty ( ) )
@ -422,6 +426,7 @@ void Tracker::prepareAnnounceResponse(const TrackerAnnounceRequest &announceReq)
else {
else {
lt : : entry : : list_type peerList ;
lt : : entry : : list_type peerList ;
if ( announceReq . event ! = ANNOUNCE_REQUEST_EVENT_STOPPED ) {
int counter = 0 ;
int counter = 0 ;
for ( const Peer & peer : torrentStats . peers ) {
for ( const Peer & peer : torrentStats . peers ) {
if ( counter + + > = announceReq . numwant )
if ( counter + + > = announceReq . numwant )
@ -437,6 +442,7 @@ void Tracker::prepareAnnounceResponse(const TrackerAnnounceRequest &announceReq)
peerList . emplace_back ( peerDict ) ;
peerList . emplace_back ( peerDict ) ;
}
}
}
replyDict [ ANNOUNCE_RESPONSE_PEERS ] = peerList ;
replyDict [ ANNOUNCE_RESPONSE_PEERS ] = peerList ;
}
}