mirror of https://github.com/aria2/aria2
Don't try legacy BitTorrent handshake when connection did not established.
parent
ce2d401dce
commit
3020087a75
|
@ -197,22 +197,32 @@ bool InitiatorMSEHandshakeCommand::executeInternal() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InitiatorMSEHandshakeCommand::tryNewPeer()
|
||||||
|
{
|
||||||
|
if(peerStorage_->isPeerAvailable() && btRuntime_->lessThanEqMinPeers()) {
|
||||||
|
SharedHandle<Peer> peer = peerStorage_->getUnusedPeer();
|
||||||
|
peer->usedBy(getDownloadEngine()->newCUID());
|
||||||
|
PeerInitiateConnectionCommand* command =
|
||||||
|
new PeerInitiateConnectionCommand(peer->usedBy(), requestGroup_, peer,
|
||||||
|
getDownloadEngine(), btRuntime_);
|
||||||
|
command->setPeerStorage(peerStorage_);
|
||||||
|
command->setPieceStorage(pieceStorage_);
|
||||||
|
getDownloadEngine()->addCommand(command);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool InitiatorMSEHandshakeCommand::prepareForNextPeer(time_t wait)
|
bool InitiatorMSEHandshakeCommand::prepareForNextPeer(time_t wait)
|
||||||
{
|
{
|
||||||
if(getOption()->getAsBool(PREF_BT_REQUIRE_CRYPTO)) {
|
if(sequence_ == INITIATOR_SEND_KEY) {
|
||||||
A2_LOG_INFO(fmt("CUID#%lld - Establishing connection using legacy BitTorrent"
|
// We don't try legacy handshake when connection did not
|
||||||
" handshake is disabled by preference.",
|
// established.
|
||||||
|
tryNewPeer();
|
||||||
|
return true;
|
||||||
|
} else if(getOption()->getAsBool(PREF_BT_REQUIRE_CRYPTO)) {
|
||||||
|
A2_LOG_INFO(fmt("CUID#%lld - Establishing connection using legacy"
|
||||||
|
" BitTorrent handshake is disabled by preference.",
|
||||||
getCuid()));
|
getCuid()));
|
||||||
if(peerStorage_->isPeerAvailable() && btRuntime_->lessThanEqMinPeers()) {
|
tryNewPeer();
|
||||||
SharedHandle<Peer> peer = peerStorage_->getUnusedPeer();
|
|
||||||
peer->usedBy(getDownloadEngine()->newCUID());
|
|
||||||
PeerInitiateConnectionCommand* command =
|
|
||||||
new PeerInitiateConnectionCommand(peer->usedBy(), requestGroup_, peer,
|
|
||||||
getDownloadEngine(), btRuntime_);
|
|
||||||
command->setPeerStorage(peerStorage_);
|
|
||||||
command->setPieceStorage(pieceStorage_);
|
|
||||||
getDownloadEngine()->addCommand(command);
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
// try legacy BitTorrent handshake
|
// try legacy BitTorrent handshake
|
||||||
|
|
|
@ -70,6 +70,8 @@ private:
|
||||||
MSEHandshake* mseHandshake_;
|
MSEHandshake* mseHandshake_;
|
||||||
|
|
||||||
const SharedHandle<Option>& getOption() const;
|
const SharedHandle<Option>& getOption() const;
|
||||||
|
|
||||||
|
void tryNewPeer();
|
||||||
protected:
|
protected:
|
||||||
virtual bool executeInternal();
|
virtual bool executeInternal();
|
||||||
virtual bool prepareForNextPeer(time_t wait);
|
virtual bool prepareForNextPeer(time_t wait);
|
||||||
|
|
Loading…
Reference in New Issue