mirror of https://github.com/aria2/aria2
2008-02-28 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Fixed possible busy loop if first 20 bytes are not received for a few minutes. * src/MSEHandshake.{h, cc} (identifyHandshakeType) * src/ReceiverMSEHandshakeCommand.ccpull/1/head
parent
c1fd47809d
commit
50bb9bd36d
|
@ -1,3 +1,10 @@
|
||||||
|
2008-02-28 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
|
Fixed possible busy loop if first 20 bytes are not received for a few
|
||||||
|
minutes.
|
||||||
|
* src/MSEHandshake.{h, cc} (identifyHandshakeType)
|
||||||
|
* src/ReceiverMSEHandshakeCommand.cc
|
||||||
|
|
||||||
2008-02-27 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
2008-02-27 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
Fixed compilation error
|
Fixed compilation error
|
||||||
|
|
|
@ -91,9 +91,10 @@ MSEHandshake::HANDSHAKE_TYPE MSEHandshake::identifyHandshakeType()
|
||||||
if(!_socket->isReadable(0)) {
|
if(!_socket->isReadable(0)) {
|
||||||
return HANDSHAKE_NOT_YET;
|
return HANDSHAKE_NOT_YET;
|
||||||
}
|
}
|
||||||
int32_t bufLength = 20;
|
int32_t bufLength = 20-_rbufLength;
|
||||||
_socket->peekData(_rbuf, bufLength);
|
_socket->readData(_rbuf+_rbufLength, bufLength);
|
||||||
if(bufLength != 20) {
|
_rbufLength += bufLength;
|
||||||
|
if(_rbufLength < 20) {
|
||||||
return HANDSHAKE_NOT_YET;
|
return HANDSHAKE_NOT_YET;
|
||||||
}
|
}
|
||||||
if(_rbuf[0] == BtHandshakeMessage::PSTR_LENGTH &&
|
if(_rbuf[0] == BtHandshakeMessage::PSTR_LENGTH &&
|
||||||
|
@ -597,4 +598,14 @@ SharedHandle<ARC4Decryptor> MSEHandshake::getDecryptor() const
|
||||||
return _decryptor;
|
return _decryptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const unsigned char* MSEHandshake::getBuffer() const
|
||||||
|
{
|
||||||
|
return _rbuf;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t MSEHandshake::getBufferLength() const
|
||||||
|
{
|
||||||
|
return _rbufLength;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -172,6 +172,10 @@ public:
|
||||||
SharedHandle<ARC4Encryptor> getEncryptor() const;
|
SharedHandle<ARC4Encryptor> getEncryptor() const;
|
||||||
|
|
||||||
SharedHandle<ARC4Decryptor> getDecryptor() const;
|
SharedHandle<ARC4Decryptor> getDecryptor() const;
|
||||||
|
|
||||||
|
const unsigned char* getBuffer() const;
|
||||||
|
|
||||||
|
size_t getBufferLength() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -90,7 +90,12 @@ bool ReceiverMSEHandshakeCommand::executeInternal()
|
||||||
if(e->option->getAsBool(PREF_BT_REQUIRE_CRYPTO)) {
|
if(e->option->getAsBool(PREF_BT_REQUIRE_CRYPTO)) {
|
||||||
throw new DlAbortEx("The legacy BitTorrent handshake is not acceptable by the preference.");
|
throw new DlAbortEx("The legacy BitTorrent handshake is not acceptable by the preference.");
|
||||||
}
|
}
|
||||||
Command* c = new PeerReceiveHandshakeCommand(cuid, peer, e, socket);
|
SharedHandle<PeerConnection> peerConnection =
|
||||||
|
new PeerConnection(cuid, socket, e->option);
|
||||||
|
peerConnection->presetBuffer(_mseHandshake->getBuffer(),
|
||||||
|
_mseHandshake->getBufferLength());
|
||||||
|
Command* c = new PeerReceiveHandshakeCommand(cuid, peer, e, socket,
|
||||||
|
peerConnection);
|
||||||
e->commands.push_back(c);
|
e->commands.push_back(c);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue