2006-12-24 06:25:21 +00:00
|
|
|
/* <!-- copyright */
|
|
|
|
/*
|
|
|
|
* aria2 - The high speed download utility
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 Tatsuhiro Tsujikawa
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*
|
|
|
|
* In addition, as a special exception, the copyright holders give
|
|
|
|
* permission to link the code of portions of this program with the
|
|
|
|
* OpenSSL library under certain conditions as described in each
|
|
|
|
* individual source file, and distribute linked combinations
|
|
|
|
* including the two.
|
|
|
|
* You must obey the GNU General Public License in all respects
|
|
|
|
* for all of the code used other than OpenSSL. If you modify
|
|
|
|
* file(s) with this exception, you may extend this exception to your
|
|
|
|
* version of the file(s), but you are not obligated to do so. If you
|
|
|
|
* do not wish to do so, delete this exception statement from your
|
|
|
|
* version. If you delete this exception statement from all source
|
|
|
|
* files in the program, then also delete it here.
|
|
|
|
*/
|
|
|
|
/* copyright --> */
|
|
|
|
#include "DefaultBtMessageFactory.h"
|
|
|
|
#include "DlAbortEx.h"
|
2009-09-29 14:52:42 +00:00
|
|
|
#include "bittorrent_helper.h"
|
2006-12-24 06:25:21 +00:00
|
|
|
#include "BtKeepAliveMessage.h"
|
|
|
|
#include "BtChokeMessage.h"
|
|
|
|
#include "BtUnchokeMessage.h"
|
|
|
|
#include "BtInterestedMessage.h"
|
|
|
|
#include "BtNotInterestedMessage.h"
|
|
|
|
#include "BtHaveMessage.h"
|
|
|
|
#include "BtBitfieldMessage.h"
|
|
|
|
#include "BtBitfieldMessageValidator.h"
|
2009-03-12 15:54:43 +00:00
|
|
|
#include "RangeBtMessageValidator.h"
|
|
|
|
#include "IndexBtMessageValidator.h"
|
2006-12-24 06:25:21 +00:00
|
|
|
#include "BtRequestMessage.h"
|
|
|
|
#include "BtCancelMessage.h"
|
|
|
|
#include "BtPieceMessage.h"
|
|
|
|
#include "BtPieceMessageValidator.h"
|
|
|
|
#include "BtPortMessage.h"
|
|
|
|
#include "BtHaveAllMessage.h"
|
|
|
|
#include "BtHaveNoneMessage.h"
|
|
|
|
#include "BtRejectMessage.h"
|
|
|
|
#include "BtSuggestPieceMessage.h"
|
|
|
|
#include "BtAllowedFastMessage.h"
|
|
|
|
#include "BtHandshakeMessage.h"
|
|
|
|
#include "BtHandshakeMessageValidator.h"
|
2007-12-22 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added uTorrent compatible Peer Exchange.
* src/BencodeVisitor.{h, cc}
* test/BencodeVisitorTest.cc
* src/BtConstants.h
* src/BtContext.h: Added 'private' flag.
* src/BtExtendedMessage.{h, cc}
* test/BtExtendedMessageTest.cc
* src/BtHandshakeMessage.{h, cc}: Set extended messaging bit in
reserved field.
* test/BtHandshakeMessageTest.cc
* src/BtMessageFactory.h
* src/BtRegistry.h
* src/BtRuntime.h: This class holds default extension message
IDs for
aria2. By default, aria2 uses ID 8 for ut_pex.
* src/DefaultBtContext.cc
* src/DefaultBtInteractive.{h, cc}: This class holds
_utPexEnabled.
When it is true, aria2 enables ut_pex. This value is set by
PeerInteractionCommand.
* src/DefaultBtMessageFactory.{h, cc}
* test/DefaultBtMessageFactoryTest.cc
* src/DefaultBtMessageReceiver.cc: Moved the code of fast
extension
handling to DefaultBtInteractive class.
* src/DefaultExtensionMessageFactory.{h, cc}
* test/DefaultExtensionMessageFactoryTest.cc
* src/DefaultPeerStorage.cc: Returns false if a peer is already
in
the container(peers and incomingPeers. The equality is
determined by
Peer::id).
* test/DefaultPeerStorageTest.cc
* src/ExtensionMessage.h
* test/MockExtensionMessage.h
* src/ExtensionMessageFactory.h
* test/MockExtensionMessageFactory.h
* src/HandshakeExtensionMessage.{h, cc}
* test/HandshakeExtensionMessageTest.cc
* src/MetaEntry.h
* src/Peer.{h, cc}
* src/PeerInteractionCommand.cc
* src/PeerReceiveHandshakeCommand.cc: Evaluate the return value
of
addIncomingPeer.
* src/PeerMessageUtil.{h, cc}
* src/PeerObject.h
* src/UTPexExtensionMessage.{h, cc}
* test/UTPexExtensionMessageTest.cc
* src/message.h
* src/prefs.h
Fixed the bug that returns incomplete data when it contains null
character. A convenient constructor was also added.
* src/Data.{h, cc}
Rewritten.
* src/CompactPeerListProcessor.cc
Fixed typos.
* src/message.h
* src/MetaFileUtil.cc
2007-12-22 03:57:55 +00:00
|
|
|
#include "BtExtendedMessage.h"
|
|
|
|
#include "ExtensionMessage.h"
|
2008-02-08 15:53:45 +00:00
|
|
|
#include "Peer.h"
|
|
|
|
#include "Piece.h"
|
2009-06-28 10:37:15 +00:00
|
|
|
#include "DownloadContext.h"
|
2008-02-08 15:53:45 +00:00
|
|
|
#include "PieceStorage.h"
|
2008-11-03 06:49:02 +00:00
|
|
|
#include "PeerStorage.h"
|
2008-04-27 02:22:14 +00:00
|
|
|
#include "StringFormat.h"
|
2008-11-03 06:49:02 +00:00
|
|
|
#include "ExtensionMessageFactory.h"
|
2009-06-28 10:37:15 +00:00
|
|
|
#include "bittorrent_helper.h"
|
2008-02-08 15:53:45 +00:00
|
|
|
|
|
|
|
namespace aria2 {
|
2006-12-24 06:25:21 +00:00
|
|
|
|
2008-02-01 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added DHT functionality, compatible with mainline.
DHT is disabled by default. To enable it, give --enable-dht to
aria2c.
You may need to specify entry point to DHT network using
--dht-entry-point. DHT uses UDP port to listen incoming message.
Use --dht-listen-port to specify port number. Make sure that
your
firewall configuration can pass through UDP traffic to the port.
The routing table is saved in $HOME/.aria2/dht.dat.
* src/DHT*
* src/BNode.{h, cc}
* src/PeerInteractionCommand.cc: enable DHT functionality for a
particular torrent.
* src/Data.cc: Rewritten ctor.
* src/OptionHandlerFactory.cc: Added --enable-dht,
--dht-listen-port,
--dht-entry-point.
* src/DefaultBtInteractive.cc: Send port message if dht is
enabled.
* src/RequestGroup.cc: Initialize DHT functionality. When
download
ends, remove BtContext from DHTPeerAnnounceStorage.
* src/BtPortMessage.{h, cc}: Rewritten.
* src/message.h
* src/OptionHandlerImpl.cc
* src/option_processing.cc: Added --enable-dht,
--dht-listen-port,
--dht-entry-point.
* src/Dictionary.{h, cc} (remove): New function.
* src/prefs.h
* src/DefaultBtMessageFactory.h
* src/BtHandshakeMessage.cc
* src/ActivePeerConnectionCommand.cc
* src/SocketCore.{h, cc}: Added datagram socket support.
* src/DefaultBtMessageFactory.cc
* src/BtSetup.cc: Add BtContext to DHTPeerAnnounceStorage here.
Create DHT commands.
* src/BtMessageFactory.h
* src/PeerMessageUtil.{h, cc}
2008-02-01 17:36:33 +00:00
|
|
|
DefaultBtMessageFactory::DefaultBtMessageFactory():cuid(0),
|
2009-11-22 14:52:17 +00:00
|
|
|
_dhtEnabled(false),
|
|
|
|
_metadataGetMode(false)
|
2008-02-01 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added DHT functionality, compatible with mainline.
DHT is disabled by default. To enable it, give --enable-dht to
aria2c.
You may need to specify entry point to DHT network using
--dht-entry-point. DHT uses UDP port to listen incoming message.
Use --dht-listen-port to specify port number. Make sure that
your
firewall configuration can pass through UDP traffic to the port.
The routing table is saved in $HOME/.aria2/dht.dat.
* src/DHT*
* src/BNode.{h, cc}
* src/PeerInteractionCommand.cc: enable DHT functionality for a
particular torrent.
* src/Data.cc: Rewritten ctor.
* src/OptionHandlerFactory.cc: Added --enable-dht,
--dht-listen-port,
--dht-entry-point.
* src/DefaultBtInteractive.cc: Send port message if dht is
enabled.
* src/RequestGroup.cc: Initialize DHT functionality. When
download
ends, remove BtContext from DHTPeerAnnounceStorage.
* src/BtPortMessage.{h, cc}: Rewritten.
* src/message.h
* src/OptionHandlerImpl.cc
* src/option_processing.cc: Added --enable-dht,
--dht-listen-port,
--dht-entry-point.
* src/Dictionary.{h, cc} (remove): New function.
* src/prefs.h
* src/DefaultBtMessageFactory.h
* src/BtHandshakeMessage.cc
* src/ActivePeerConnectionCommand.cc
* src/SocketCore.{h, cc}: Added datagram socket support.
* src/DefaultBtMessageFactory.cc
* src/BtSetup.cc: Add BtContext to DHTPeerAnnounceStorage here.
Create DHT commands.
* src/BtMessageFactory.h
* src/PeerMessageUtil.{h, cc}
2008-02-01 17:36:33 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
DefaultBtMessageFactory::~DefaultBtMessageFactory() {}
|
|
|
|
|
2006-12-24 06:25:21 +00:00
|
|
|
BtMessageHandle
|
2008-03-09 12:24:01 +00:00
|
|
|
DefaultBtMessageFactory::createBtMessage(const unsigned char* data, size_t dataLength)
|
2006-12-24 06:25:21 +00:00
|
|
|
{
|
2008-04-20 00:50:22 +00:00
|
|
|
AbstractBtMessageHandle msg;
|
2006-12-24 06:25:21 +00:00
|
|
|
if(dataLength == 0) {
|
|
|
|
// keep-alive
|
2008-04-20 00:50:22 +00:00
|
|
|
msg.reset(new BtKeepAliveMessage());
|
2006-12-24 06:25:21 +00:00
|
|
|
} else {
|
2009-09-29 14:52:42 +00:00
|
|
|
uint8_t id = bittorrent::getId(data);
|
2006-12-24 06:25:21 +00:00
|
|
|
switch(id) {
|
|
|
|
case BtChokeMessage::ID:
|
|
|
|
msg = BtChokeMessage::create(data, dataLength);
|
|
|
|
break;
|
|
|
|
case BtUnchokeMessage::ID:
|
|
|
|
msg = BtUnchokeMessage::create(data, dataLength);
|
|
|
|
break;
|
|
|
|
case BtInterestedMessage::ID:
|
2008-11-03 12:04:57 +00:00
|
|
|
{
|
|
|
|
SharedHandle<BtInterestedMessage> m =
|
|
|
|
BtInterestedMessage::create(data, dataLength);
|
|
|
|
m->setPeerStorage(_peerStorage);
|
|
|
|
msg = m;
|
|
|
|
}
|
2006-12-24 06:25:21 +00:00
|
|
|
break;
|
|
|
|
case BtNotInterestedMessage::ID:
|
2008-11-03 06:49:02 +00:00
|
|
|
{
|
|
|
|
SharedHandle<BtNotInterestedMessage> m =
|
|
|
|
BtNotInterestedMessage::create(data, dataLength);
|
|
|
|
m->setPeerStorage(_peerStorage);
|
|
|
|
msg = m;
|
|
|
|
}
|
2006-12-24 06:25:21 +00:00
|
|
|
break;
|
|
|
|
case BtHaveMessage::ID:
|
|
|
|
msg = BtHaveMessage::create(data, dataLength);
|
2008-04-20 00:50:22 +00:00
|
|
|
{
|
2009-11-22 14:52:17 +00:00
|
|
|
if(!_metadataGetMode) {
|
|
|
|
SharedHandle<BtMessageValidator> v
|
|
|
|
(new IndexBtMessageValidator(static_cast<BtHaveMessage*>(msg.get()),
|
|
|
|
_downloadContext->getNumPieces()));
|
|
|
|
msg->setBtMessageValidator(v);
|
|
|
|
}
|
2008-04-20 00:50:22 +00:00
|
|
|
}
|
2006-12-24 06:25:21 +00:00
|
|
|
break;
|
|
|
|
case BtBitfieldMessage::ID:
|
|
|
|
msg = BtBitfieldMessage::create(data, dataLength);
|
2008-04-20 00:50:22 +00:00
|
|
|
{
|
2009-11-22 14:52:17 +00:00
|
|
|
if(!_metadataGetMode) {
|
|
|
|
SharedHandle<BtMessageValidator> v
|
|
|
|
(new BtBitfieldMessageValidator
|
|
|
|
(static_cast<BtBitfieldMessage*>(msg.get()),
|
|
|
|
_downloadContext->getNumPieces()));
|
|
|
|
msg->setBtMessageValidator(v);
|
|
|
|
}
|
2008-04-20 00:50:22 +00:00
|
|
|
}
|
2006-12-24 06:25:21 +00:00
|
|
|
break;
|
|
|
|
case BtRequestMessage::ID: {
|
|
|
|
BtRequestMessageHandle temp = BtRequestMessage::create(data, dataLength);
|
2009-11-22 14:52:17 +00:00
|
|
|
if(!_metadataGetMode) {
|
|
|
|
SharedHandle<BtMessageValidator> validator
|
|
|
|
(new RangeBtMessageValidator
|
|
|
|
(temp.get(),
|
|
|
|
_downloadContext->getNumPieces(),
|
|
|
|
_pieceStorage->getPieceLength(temp->getIndex())));
|
|
|
|
temp->setBtMessageValidator(validator);
|
|
|
|
}
|
2006-12-24 06:25:21 +00:00
|
|
|
msg = temp;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case BtCancelMessage::ID: {
|
|
|
|
BtCancelMessageHandle temp = BtCancelMessage::create(data, dataLength);
|
2009-11-22 14:52:17 +00:00
|
|
|
if(!_metadataGetMode) {
|
|
|
|
SharedHandle<BtMessageValidator> validator
|
|
|
|
(new RangeBtMessageValidator
|
|
|
|
(temp.get(),
|
|
|
|
_downloadContext->getNumPieces(),
|
|
|
|
_pieceStorage->getPieceLength(temp->getIndex())));
|
|
|
|
temp->setBtMessageValidator(validator);
|
|
|
|
}
|
2006-12-24 06:25:21 +00:00
|
|
|
msg = temp;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case BtPieceMessage::ID: {
|
|
|
|
BtPieceMessageHandle temp = BtPieceMessage::create(data, dataLength);
|
2009-11-22 14:52:17 +00:00
|
|
|
if(!_metadataGetMode) {
|
|
|
|
BtMessageValidatorHandle validator
|
|
|
|
(new BtPieceMessageValidator(temp.get(),
|
|
|
|
_downloadContext->getNumPieces(),
|
|
|
|
_pieceStorage->getPieceLength(temp->getIndex())));
|
|
|
|
temp->setBtMessageValidator(validator);
|
|
|
|
}
|
2009-06-28 10:37:15 +00:00
|
|
|
temp->setDownloadContext(_downloadContext);
|
2006-12-24 06:25:21 +00:00
|
|
|
msg = temp;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case BtHaveAllMessage::ID:
|
|
|
|
msg = BtHaveAllMessage::create(data, dataLength);
|
|
|
|
break;
|
|
|
|
case BtHaveNoneMessage::ID:
|
|
|
|
msg = BtHaveNoneMessage::create(data, dataLength);
|
|
|
|
break;
|
|
|
|
case BtRejectMessage::ID: {
|
|
|
|
BtRejectMessageHandle temp = BtRejectMessage::create(data, dataLength);
|
2009-11-22 14:52:17 +00:00
|
|
|
if(!_metadataGetMode) {
|
|
|
|
SharedHandle<BtMessageValidator> validator
|
|
|
|
(new RangeBtMessageValidator
|
|
|
|
(temp.get(),
|
|
|
|
_downloadContext->getNumPieces(),
|
|
|
|
_pieceStorage->getPieceLength(temp->getIndex())));
|
|
|
|
temp->setBtMessageValidator(validator);
|
|
|
|
}
|
2006-12-24 06:25:21 +00:00
|
|
|
msg = temp;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case BtSuggestPieceMessage::ID: {
|
|
|
|
BtSuggestPieceMessageHandle temp = BtSuggestPieceMessage::create(data, dataLength);
|
2009-11-22 14:52:17 +00:00
|
|
|
if(!_metadataGetMode) {
|
|
|
|
SharedHandle<BtMessageValidator> validator
|
|
|
|
(new IndexBtMessageValidator(temp.get(),
|
|
|
|
_downloadContext->getNumPieces()));
|
|
|
|
temp->setBtMessageValidator(validator);
|
|
|
|
}
|
2006-12-24 06:25:21 +00:00
|
|
|
msg = temp;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case BtAllowedFastMessage::ID: {
|
|
|
|
BtAllowedFastMessageHandle temp = BtAllowedFastMessage::create(data, dataLength);
|
2009-11-22 14:52:17 +00:00
|
|
|
if(!_metadataGetMode) {
|
|
|
|
SharedHandle<BtMessageValidator> validator
|
|
|
|
(new IndexBtMessageValidator(temp.get(),
|
|
|
|
_downloadContext->getNumPieces()));
|
|
|
|
temp->setBtMessageValidator(validator);
|
|
|
|
}
|
2006-12-24 06:25:21 +00:00
|
|
|
msg = temp;
|
|
|
|
break;
|
|
|
|
}
|
2008-02-01 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added DHT functionality, compatible with mainline.
DHT is disabled by default. To enable it, give --enable-dht to
aria2c.
You may need to specify entry point to DHT network using
--dht-entry-point. DHT uses UDP port to listen incoming message.
Use --dht-listen-port to specify port number. Make sure that
your
firewall configuration can pass through UDP traffic to the port.
The routing table is saved in $HOME/.aria2/dht.dat.
* src/DHT*
* src/BNode.{h, cc}
* src/PeerInteractionCommand.cc: enable DHT functionality for a
particular torrent.
* src/Data.cc: Rewritten ctor.
* src/OptionHandlerFactory.cc: Added --enable-dht,
--dht-listen-port,
--dht-entry-point.
* src/DefaultBtInteractive.cc: Send port message if dht is
enabled.
* src/RequestGroup.cc: Initialize DHT functionality. When
download
ends, remove BtContext from DHTPeerAnnounceStorage.
* src/BtPortMessage.{h, cc}: Rewritten.
* src/message.h
* src/OptionHandlerImpl.cc
* src/option_processing.cc: Added --enable-dht,
--dht-listen-port,
--dht-entry-point.
* src/Dictionary.{h, cc} (remove): New function.
* src/prefs.h
* src/DefaultBtMessageFactory.h
* src/BtHandshakeMessage.cc
* src/ActivePeerConnectionCommand.cc
* src/SocketCore.{h, cc}: Added datagram socket support.
* src/DefaultBtMessageFactory.cc
* src/BtSetup.cc: Add BtContext to DHTPeerAnnounceStorage here.
Create DHT commands.
* src/BtMessageFactory.h
* src/PeerMessageUtil.{h, cc}
2008-02-01 17:36:33 +00:00
|
|
|
case BtPortMessage::ID: {
|
|
|
|
SharedHandle<BtPortMessage> temp = BtPortMessage::create(data, dataLength);
|
2008-02-10 15:57:00 +00:00
|
|
|
temp->setLocalNode(_localNode);
|
|
|
|
temp->setRoutingTable(_routingTable);
|
2008-02-01 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added DHT functionality, compatible with mainline.
DHT is disabled by default. To enable it, give --enable-dht to
aria2c.
You may need to specify entry point to DHT network using
--dht-entry-point. DHT uses UDP port to listen incoming message.
Use --dht-listen-port to specify port number. Make sure that
your
firewall configuration can pass through UDP traffic to the port.
The routing table is saved in $HOME/.aria2/dht.dat.
* src/DHT*
* src/BNode.{h, cc}
* src/PeerInteractionCommand.cc: enable DHT functionality for a
particular torrent.
* src/Data.cc: Rewritten ctor.
* src/OptionHandlerFactory.cc: Added --enable-dht,
--dht-listen-port,
--dht-entry-point.
* src/DefaultBtInteractive.cc: Send port message if dht is
enabled.
* src/RequestGroup.cc: Initialize DHT functionality. When
download
ends, remove BtContext from DHTPeerAnnounceStorage.
* src/BtPortMessage.{h, cc}: Rewritten.
* src/message.h
* src/OptionHandlerImpl.cc
* src/option_processing.cc: Added --enable-dht,
--dht-listen-port,
--dht-entry-point.
* src/Dictionary.{h, cc} (remove): New function.
* src/prefs.h
* src/DefaultBtMessageFactory.h
* src/BtHandshakeMessage.cc
* src/ActivePeerConnectionCommand.cc
* src/SocketCore.{h, cc}: Added datagram socket support.
* src/DefaultBtMessageFactory.cc
* src/BtSetup.cc: Add BtContext to DHTPeerAnnounceStorage here.
Create DHT commands.
* src/BtMessageFactory.h
* src/PeerMessageUtil.{h, cc}
2008-02-01 17:36:33 +00:00
|
|
|
temp->setTaskQueue(_taskQueue);
|
|
|
|
temp->setTaskFactory(_taskFactory);
|
|
|
|
msg = temp;
|
|
|
|
break;
|
|
|
|
}
|
2007-12-22 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added uTorrent compatible Peer Exchange.
* src/BencodeVisitor.{h, cc}
* test/BencodeVisitorTest.cc
* src/BtConstants.h
* src/BtContext.h: Added 'private' flag.
* src/BtExtendedMessage.{h, cc}
* test/BtExtendedMessageTest.cc
* src/BtHandshakeMessage.{h, cc}: Set extended messaging bit in
reserved field.
* test/BtHandshakeMessageTest.cc
* src/BtMessageFactory.h
* src/BtRegistry.h
* src/BtRuntime.h: This class holds default extension message
IDs for
aria2. By default, aria2 uses ID 8 for ut_pex.
* src/DefaultBtContext.cc
* src/DefaultBtInteractive.{h, cc}: This class holds
_utPexEnabled.
When it is true, aria2 enables ut_pex. This value is set by
PeerInteractionCommand.
* src/DefaultBtMessageFactory.{h, cc}
* test/DefaultBtMessageFactoryTest.cc
* src/DefaultBtMessageReceiver.cc: Moved the code of fast
extension
handling to DefaultBtInteractive class.
* src/DefaultExtensionMessageFactory.{h, cc}
* test/DefaultExtensionMessageFactoryTest.cc
* src/DefaultPeerStorage.cc: Returns false if a peer is already
in
the container(peers and incomingPeers. The equality is
determined by
Peer::id).
* test/DefaultPeerStorageTest.cc
* src/ExtensionMessage.h
* test/MockExtensionMessage.h
* src/ExtensionMessageFactory.h
* test/MockExtensionMessageFactory.h
* src/HandshakeExtensionMessage.{h, cc}
* test/HandshakeExtensionMessageTest.cc
* src/MetaEntry.h
* src/Peer.{h, cc}
* src/PeerInteractionCommand.cc
* src/PeerReceiveHandshakeCommand.cc: Evaluate the return value
of
addIncomingPeer.
* src/PeerMessageUtil.{h, cc}
* src/PeerObject.h
* src/UTPexExtensionMessage.{h, cc}
* test/UTPexExtensionMessageTest.cc
* src/message.h
* src/prefs.h
Fixed the bug that returns incomplete data when it contains null
character. A convenient constructor was also added.
* src/Data.{h, cc}
Rewritten.
* src/CompactPeerListProcessor.cc
Fixed typos.
* src/message.h
* src/MetaFileUtil.cc
2007-12-22 03:57:55 +00:00
|
|
|
case BtExtendedMessage::ID: {
|
|
|
|
if(peer->isExtendedMessagingEnabled()) {
|
2008-11-03 06:49:02 +00:00
|
|
|
msg = BtExtendedMessage::create(_extensionMessageFactory,
|
|
|
|
peer, data, dataLength);
|
2007-12-22 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added uTorrent compatible Peer Exchange.
* src/BencodeVisitor.{h, cc}
* test/BencodeVisitorTest.cc
* src/BtConstants.h
* src/BtContext.h: Added 'private' flag.
* src/BtExtendedMessage.{h, cc}
* test/BtExtendedMessageTest.cc
* src/BtHandshakeMessage.{h, cc}: Set extended messaging bit in
reserved field.
* test/BtHandshakeMessageTest.cc
* src/BtMessageFactory.h
* src/BtRegistry.h
* src/BtRuntime.h: This class holds default extension message
IDs for
aria2. By default, aria2 uses ID 8 for ut_pex.
* src/DefaultBtContext.cc
* src/DefaultBtInteractive.{h, cc}: This class holds
_utPexEnabled.
When it is true, aria2 enables ut_pex. This value is set by
PeerInteractionCommand.
* src/DefaultBtMessageFactory.{h, cc}
* test/DefaultBtMessageFactoryTest.cc
* src/DefaultBtMessageReceiver.cc: Moved the code of fast
extension
handling to DefaultBtInteractive class.
* src/DefaultExtensionMessageFactory.{h, cc}
* test/DefaultExtensionMessageFactoryTest.cc
* src/DefaultPeerStorage.cc: Returns false if a peer is already
in
the container(peers and incomingPeers. The equality is
determined by
Peer::id).
* test/DefaultPeerStorageTest.cc
* src/ExtensionMessage.h
* test/MockExtensionMessage.h
* src/ExtensionMessageFactory.h
* test/MockExtensionMessageFactory.h
* src/HandshakeExtensionMessage.{h, cc}
* test/HandshakeExtensionMessageTest.cc
* src/MetaEntry.h
* src/Peer.{h, cc}
* src/PeerInteractionCommand.cc
* src/PeerReceiveHandshakeCommand.cc: Evaluate the return value
of
addIncomingPeer.
* src/PeerMessageUtil.{h, cc}
* src/PeerObject.h
* src/UTPexExtensionMessage.{h, cc}
* test/UTPexExtensionMessageTest.cc
* src/message.h
* src/prefs.h
Fixed the bug that returns incomplete data when it contains null
character. A convenient constructor was also added.
* src/Data.{h, cc}
Rewritten.
* src/CompactPeerListProcessor.cc
Fixed typos.
* src/message.h
* src/MetaFileUtil.cc
2007-12-22 03:57:55 +00:00
|
|
|
} else {
|
2009-05-18 15:07:15 +00:00
|
|
|
throw DL_ABORT_EX("Received extended message from peer during a session with extended messaging disabled.");
|
2007-12-22 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added uTorrent compatible Peer Exchange.
* src/BencodeVisitor.{h, cc}
* test/BencodeVisitorTest.cc
* src/BtConstants.h
* src/BtContext.h: Added 'private' flag.
* src/BtExtendedMessage.{h, cc}
* test/BtExtendedMessageTest.cc
* src/BtHandshakeMessage.{h, cc}: Set extended messaging bit in
reserved field.
* test/BtHandshakeMessageTest.cc
* src/BtMessageFactory.h
* src/BtRegistry.h
* src/BtRuntime.h: This class holds default extension message
IDs for
aria2. By default, aria2 uses ID 8 for ut_pex.
* src/DefaultBtContext.cc
* src/DefaultBtInteractive.{h, cc}: This class holds
_utPexEnabled.
When it is true, aria2 enables ut_pex. This value is set by
PeerInteractionCommand.
* src/DefaultBtMessageFactory.{h, cc}
* test/DefaultBtMessageFactoryTest.cc
* src/DefaultBtMessageReceiver.cc: Moved the code of fast
extension
handling to DefaultBtInteractive class.
* src/DefaultExtensionMessageFactory.{h, cc}
* test/DefaultExtensionMessageFactoryTest.cc
* src/DefaultPeerStorage.cc: Returns false if a peer is already
in
the container(peers and incomingPeers. The equality is
determined by
Peer::id).
* test/DefaultPeerStorageTest.cc
* src/ExtensionMessage.h
* test/MockExtensionMessage.h
* src/ExtensionMessageFactory.h
* test/MockExtensionMessageFactory.h
* src/HandshakeExtensionMessage.{h, cc}
* test/HandshakeExtensionMessageTest.cc
* src/MetaEntry.h
* src/Peer.{h, cc}
* src/PeerInteractionCommand.cc
* src/PeerReceiveHandshakeCommand.cc: Evaluate the return value
of
addIncomingPeer.
* src/PeerMessageUtil.{h, cc}
* src/PeerObject.h
* src/UTPexExtensionMessage.{h, cc}
* test/UTPexExtensionMessageTest.cc
* src/message.h
* src/prefs.h
Fixed the bug that returns incomplete data when it contains null
character. A convenient constructor was also added.
* src/Data.{h, cc}
Rewritten.
* src/CompactPeerListProcessor.cc
Fixed typos.
* src/message.h
* src/MetaFileUtil.cc
2007-12-22 03:57:55 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2006-12-24 06:25:21 +00:00
|
|
|
default:
|
2009-05-18 15:07:15 +00:00
|
|
|
throw DL_ABORT_EX(StringFormat("Invalid message ID. id=%u", id).str());
|
2006-12-24 06:25:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
setCommonProperty(msg);
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DefaultBtMessageFactory::setCommonProperty(const AbstractBtMessageHandle& msg) {
|
|
|
|
msg->setCuid(cuid);
|
|
|
|
msg->setPeer(peer);
|
2008-11-03 06:49:02 +00:00
|
|
|
msg->setPieceStorage(_pieceStorage);
|
2007-01-16 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To decrease CPU usage in bittorrent download, calculation
results in
BitfieldMan were cached and realtime fetching PeerObject was
removed
with WeakHandle introduced. Option values are set to the objects
by setter before download begins.
* src/DefaultBtRequestFactory.cc: Use messageFactory member.
* src/DefaultBtRequestFactory.h
(dispatcher): BtMessageDispatcherHandle ->
BtMessageDispatcherWeakHandle.
(messageFactory): New variable.
(setBtMessageDispatcher): BtMessageDispatcherHandle ->
BtMessageDispatcherWeakHandle.
(setBtMessageFactory): New function.
* src/DefaultBtMessageDispatcher.cc:
(sendMessages): Use maxUploadSpeedLimit instead of fetching the
value
from Option.
(checkRequestSlotAndDoNecessaryThing): Use requestTimeout
instead of
feating the value from Option.
Use messageFactory member.
* src/PeerInteractionCommand.cc
(PeerInteractionCommand): Added maxDownloadSpeedLimit.
Add reverse dependencies to factory object.
Set maxUploadSpeedLimit and requestTimeout and messageFactory to
dispatcher.
Set messageFactory to receiver.
Set keepAliveInterval and maxDownloadSpeedLimit and
messageFactory to
btInteractive.
Set receiver to peerObject.
Set maxDownloadSpeedLimit to this.
(executeInternal): Use maxDownloadSpeedLimit member.
* src/BtChokeMessage.cc
(doReceivedAction): Use dispatcher, requestFactory member.
(onSendComplete): Use dispatcher member.
* src/PeerInteractionCommand.h
(maxDownloadSpeedLimit): New variable.
* src/DefaultBtMessageReceiver.h
(peerConnection): PeerConnectionHandle ->
PeerConnectionWeakHandle
(dispatcher):
BtMessageDispatcherHandle -> BtMessageDispatcherWeakHandle
(messageFactory): New variable.
(setPeerConnection): PeerConnectionHandle ->
PeerConnectionWeakHandle
(getPeerConnection): PeerConnectionHandle ->
PeerConnectionWeakHandle
(setDispatcher):
BtMessageDispatcherHandle -> BtMessageDispatcherWeakHandle
(setBtMessageFactory): New function.
* src/DefaultBtInteractive.cc
(initiateHandshake): Use messageFactory member.
(addBitfieldMessageToQueue): Use messageFactory member.
(addAllowedFastMessageToQueue): Use messageFactory member.
(decideChoking): Use messageFactory member.
(checkHave): Use messageFactory member.
(sendKeepAlive): Use keepAliveInterval, messageFactory member.
(receiveMessages): Use maxDownloadSpeedLimit member.
(decideInterest): Use messageFactory member.
* src/BtRequestMessage.cc
(doReceivedAction): Use messageFactory, dispatcher member.
(onQueued): Use dispatcher member.
* src/BtPieceMessage.cc
(doReceivedAction): Use dispatcher member.
(send): Use peerConnection member.
(onWrongPiece): Use requestFactory member.
(handleChokingEvent): Use messageFactory, dispatcher member.
(handleCancelSendingPieceEvent): Use messageFactory, dispatcher
member.
* src/BtMessageDispatcher.h
(BtMessageDispatcherWeakHandle): New type definition.
* src/SimpleBtMessage.cc
(send): Use peerConnection member.
* src/BtRejectMessage.cc
(doReceivedAction): Use dispatcher member.
* src/DefaultBtMessageDispatcher.h
(Option.h): Removed include.
(messageFactory): New variable.
(option): Removed.
(maxUploadSpeedLimit): New variable.
(requestTimeout): New variable.
(DefaultBtMessageDispatcher): Removed option.
Added maxUploadSpeedLimit, requestTimeout.
(setOption): Removed.
(getOption): Removed.
(setMaxUploadSpeedLimit): New function.
(setRequestTimeout): New function.
(setBtMessageFactory): New function.
* src/DefaultBtInteractive.h
(btMessageReceiver):
BtMessageReceiverHandle -> BtMessageReceiverWeakHandle
(dispatcher):
BtMessageDispatcherHandle -> BtMessageReceiverWeakHandle
(btRequestFactory):
BtRequestFactoryHandle -> BtRequestFactoryWeakHandle
(peerConnection):
PeerConnectionHandle -> PeerConnectionWeakHandle
(messageFactory): New variable.
(option): Removed.
(keepAliveInterval): New variable.
(maxDownloadSpeedLimit): New variable.
(DefaultBtInteractive): Added keepAliveInterval,
maxDownloadSpeedLimit.
(setBtMessageReceiver):
BtMessageReceiverHandle -> BtMessageReceiverWeakHandle
(setDispatcher):
BtMessageDispatcherHandle -> BtMessageReceiverWeakHandle
(setBtRequestFactory):
BtRequestFactoryHandle -> BtRequestFactoryWeakHandle
(setPeerConnection):
PeerConnectionHandle -> PeerConnectionWeakHandle
(setOption): Removed.
(setKeepAliveInterval): New function.
(setMaxDownloadSpeedLimit): New function.
(setBtMessageFactory): New function.
* src/BitfieldMan.h
(cachedNumMissingBlock): New variable.
(cachedNumFilteredBlock): New variable.
(cachedCompletedLength): New variable.
(cachedFilteredComletedLength): New variable.
(cachedFilteredTotalLength): New variable.
(countMissingBlockNow): New function.
(countFilteredBlockNow): New function.
(getFilteredTotalLengthNow): New function.
(getCompletedLengthNow): New function.
(getFilteredCompletedLengthNow): New function.
(updateCache): New function.
* src/AbstractBtMessage.h
(BtMessageDispatcher.h): New include.
(PeerConnection.h): New include.
(BtRequestFactory.h): New include
(BtMessageFactory.h): New include.
(dispatcher): New variable.
(messageFactory): New variable.
(peerConnection: New variable.
(setBtMessageDispatcher): New function.
(setPeerConnection): New function.
(setBtMessageFactory): New function.
(setBtRequestFactory): New function.
* src/DefaultBtMessageFactory.cc
(setCommonProperty): Set dispatcher, requestFactory, this,
peerConnection to msg.
* src/BtRegistry.h
(BT_MESSAGE_RECEIVER): New macro.
* src/PeerConnection.h
(PeerConnectionWeakHandle): New type definition.
* src/BtMessageFactory.h
(BtMessageFactoryWeakHandle): New type definition.
* src/BitfieldMan.cc
(BitfieldMan): Added cachedNumMissingBlock,
cachedNumFilteredBlock,
cachedCompletedLength, cachedFilteredComletedLength,
cachedFilteredTotalLength.
Call updateCache().
(countMissingBlock): Return cachedNumMissingBlock.
(countMissingBlockNow): New function.
(countBlock): Return cachedNumFilteredBlock if filterEnabled is
true.
(countFilteredBlockNow): New function.
(setBit): Call updateCache().
(unsetBit): Call updateCache().
(setBitfield): Call updateCache().
(clearAllBit): Call updateCache().
(setAllBit): Use setBitInternal instead of setBit.
Call updateCache().
(addFilter): Call updateCache().
(enableFilter): Call updateCache().
(disableFilter): Call updateCache().
(clearFilter): Call updateCache().
(getFilteredTotalLength): Return cachedFilteredTotalLength.
(getFilteredTotalLengthNow): New function.
(getCompletedLength): Return cachedCompletedLength.
(getCompletedLengthNow): New function.
(getFilteredCompletedLength): Return
cachedFilteredComletedLength.
(getFilteredCompletedLengthNow): New function.
(updateCache): New function.
* src/BtMessageReceiver.h
(BtMessageReceiverWeakHandle): New type definition.
* src/DefaultBtMessageReceiver.cc
(receiveHandshake): Use messageFactory member.
(sendHandshake): Use messageFactory member.
(receiveMessage): Use messageFactory member.
* src/DefaultBtMessageFactory.h
(dispatcher): New variable.
(requestFactory): New variable.
(peerConnection): New variablle.
(setBtMessageDispatcher): New function.
(setBtRequestFactory): New function.
(setPeerConnection): New function.
* src/SharedHandle.h
(RefCount): New class.
(WeakHandle): New class.
* src/PeerObject.h
(BtMessageReceiver.h): New include.
(PeerObject): Added btMessageReceiver.
(btMessageReceiver): New variable.
* src/Util.cc
(countBit): Simplified.
* src/BtCancelMessage.cc
(doReceivedAction): Use dispatcher member.
* src/BtRequestFactory.h
(BtRequestFactoryWeakHandle): New type definition.
* src/PeerStorage.h
(downloadSpeed): int -> uint32_t
(uploadSpeed): int -> uint32_t
(sessionDownloadLength): long long int -> uint64_t
(sessionUploadLength): long long int -> uint64_t
2007-01-16 15:20:26 +00:00
|
|
|
msg->setBtMessageDispatcher(dispatcher);
|
|
|
|
msg->setBtRequestFactory(requestFactory);
|
2008-04-20 00:50:22 +00:00
|
|
|
msg->setBtMessageFactory(WeakHandle<BtMessageFactory>(this));
|
2007-01-16 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To decrease CPU usage in bittorrent download, calculation
results in
BitfieldMan were cached and realtime fetching PeerObject was
removed
with WeakHandle introduced. Option values are set to the objects
by setter before download begins.
* src/DefaultBtRequestFactory.cc: Use messageFactory member.
* src/DefaultBtRequestFactory.h
(dispatcher): BtMessageDispatcherHandle ->
BtMessageDispatcherWeakHandle.
(messageFactory): New variable.
(setBtMessageDispatcher): BtMessageDispatcherHandle ->
BtMessageDispatcherWeakHandle.
(setBtMessageFactory): New function.
* src/DefaultBtMessageDispatcher.cc:
(sendMessages): Use maxUploadSpeedLimit instead of fetching the
value
from Option.
(checkRequestSlotAndDoNecessaryThing): Use requestTimeout
instead of
feating the value from Option.
Use messageFactory member.
* src/PeerInteractionCommand.cc
(PeerInteractionCommand): Added maxDownloadSpeedLimit.
Add reverse dependencies to factory object.
Set maxUploadSpeedLimit and requestTimeout and messageFactory to
dispatcher.
Set messageFactory to receiver.
Set keepAliveInterval and maxDownloadSpeedLimit and
messageFactory to
btInteractive.
Set receiver to peerObject.
Set maxDownloadSpeedLimit to this.
(executeInternal): Use maxDownloadSpeedLimit member.
* src/BtChokeMessage.cc
(doReceivedAction): Use dispatcher, requestFactory member.
(onSendComplete): Use dispatcher member.
* src/PeerInteractionCommand.h
(maxDownloadSpeedLimit): New variable.
* src/DefaultBtMessageReceiver.h
(peerConnection): PeerConnectionHandle ->
PeerConnectionWeakHandle
(dispatcher):
BtMessageDispatcherHandle -> BtMessageDispatcherWeakHandle
(messageFactory): New variable.
(setPeerConnection): PeerConnectionHandle ->
PeerConnectionWeakHandle
(getPeerConnection): PeerConnectionHandle ->
PeerConnectionWeakHandle
(setDispatcher):
BtMessageDispatcherHandle -> BtMessageDispatcherWeakHandle
(setBtMessageFactory): New function.
* src/DefaultBtInteractive.cc
(initiateHandshake): Use messageFactory member.
(addBitfieldMessageToQueue): Use messageFactory member.
(addAllowedFastMessageToQueue): Use messageFactory member.
(decideChoking): Use messageFactory member.
(checkHave): Use messageFactory member.
(sendKeepAlive): Use keepAliveInterval, messageFactory member.
(receiveMessages): Use maxDownloadSpeedLimit member.
(decideInterest): Use messageFactory member.
* src/BtRequestMessage.cc
(doReceivedAction): Use messageFactory, dispatcher member.
(onQueued): Use dispatcher member.
* src/BtPieceMessage.cc
(doReceivedAction): Use dispatcher member.
(send): Use peerConnection member.
(onWrongPiece): Use requestFactory member.
(handleChokingEvent): Use messageFactory, dispatcher member.
(handleCancelSendingPieceEvent): Use messageFactory, dispatcher
member.
* src/BtMessageDispatcher.h
(BtMessageDispatcherWeakHandle): New type definition.
* src/SimpleBtMessage.cc
(send): Use peerConnection member.
* src/BtRejectMessage.cc
(doReceivedAction): Use dispatcher member.
* src/DefaultBtMessageDispatcher.h
(Option.h): Removed include.
(messageFactory): New variable.
(option): Removed.
(maxUploadSpeedLimit): New variable.
(requestTimeout): New variable.
(DefaultBtMessageDispatcher): Removed option.
Added maxUploadSpeedLimit, requestTimeout.
(setOption): Removed.
(getOption): Removed.
(setMaxUploadSpeedLimit): New function.
(setRequestTimeout): New function.
(setBtMessageFactory): New function.
* src/DefaultBtInteractive.h
(btMessageReceiver):
BtMessageReceiverHandle -> BtMessageReceiverWeakHandle
(dispatcher):
BtMessageDispatcherHandle -> BtMessageReceiverWeakHandle
(btRequestFactory):
BtRequestFactoryHandle -> BtRequestFactoryWeakHandle
(peerConnection):
PeerConnectionHandle -> PeerConnectionWeakHandle
(messageFactory): New variable.
(option): Removed.
(keepAliveInterval): New variable.
(maxDownloadSpeedLimit): New variable.
(DefaultBtInteractive): Added keepAliveInterval,
maxDownloadSpeedLimit.
(setBtMessageReceiver):
BtMessageReceiverHandle -> BtMessageReceiverWeakHandle
(setDispatcher):
BtMessageDispatcherHandle -> BtMessageReceiverWeakHandle
(setBtRequestFactory):
BtRequestFactoryHandle -> BtRequestFactoryWeakHandle
(setPeerConnection):
PeerConnectionHandle -> PeerConnectionWeakHandle
(setOption): Removed.
(setKeepAliveInterval): New function.
(setMaxDownloadSpeedLimit): New function.
(setBtMessageFactory): New function.
* src/BitfieldMan.h
(cachedNumMissingBlock): New variable.
(cachedNumFilteredBlock): New variable.
(cachedCompletedLength): New variable.
(cachedFilteredComletedLength): New variable.
(cachedFilteredTotalLength): New variable.
(countMissingBlockNow): New function.
(countFilteredBlockNow): New function.
(getFilteredTotalLengthNow): New function.
(getCompletedLengthNow): New function.
(getFilteredCompletedLengthNow): New function.
(updateCache): New function.
* src/AbstractBtMessage.h
(BtMessageDispatcher.h): New include.
(PeerConnection.h): New include.
(BtRequestFactory.h): New include
(BtMessageFactory.h): New include.
(dispatcher): New variable.
(messageFactory): New variable.
(peerConnection: New variable.
(setBtMessageDispatcher): New function.
(setPeerConnection): New function.
(setBtMessageFactory): New function.
(setBtRequestFactory): New function.
* src/DefaultBtMessageFactory.cc
(setCommonProperty): Set dispatcher, requestFactory, this,
peerConnection to msg.
* src/BtRegistry.h
(BT_MESSAGE_RECEIVER): New macro.
* src/PeerConnection.h
(PeerConnectionWeakHandle): New type definition.
* src/BtMessageFactory.h
(BtMessageFactoryWeakHandle): New type definition.
* src/BitfieldMan.cc
(BitfieldMan): Added cachedNumMissingBlock,
cachedNumFilteredBlock,
cachedCompletedLength, cachedFilteredComletedLength,
cachedFilteredTotalLength.
Call updateCache().
(countMissingBlock): Return cachedNumMissingBlock.
(countMissingBlockNow): New function.
(countBlock): Return cachedNumFilteredBlock if filterEnabled is
true.
(countFilteredBlockNow): New function.
(setBit): Call updateCache().
(unsetBit): Call updateCache().
(setBitfield): Call updateCache().
(clearAllBit): Call updateCache().
(setAllBit): Use setBitInternal instead of setBit.
Call updateCache().
(addFilter): Call updateCache().
(enableFilter): Call updateCache().
(disableFilter): Call updateCache().
(clearFilter): Call updateCache().
(getFilteredTotalLength): Return cachedFilteredTotalLength.
(getFilteredTotalLengthNow): New function.
(getCompletedLength): Return cachedCompletedLength.
(getCompletedLengthNow): New function.
(getFilteredCompletedLength): Return
cachedFilteredComletedLength.
(getFilteredCompletedLengthNow): New function.
(updateCache): New function.
* src/BtMessageReceiver.h
(BtMessageReceiverWeakHandle): New type definition.
* src/DefaultBtMessageReceiver.cc
(receiveHandshake): Use messageFactory member.
(sendHandshake): Use messageFactory member.
(receiveMessage): Use messageFactory member.
* src/DefaultBtMessageFactory.h
(dispatcher): New variable.
(requestFactory): New variable.
(peerConnection): New variablle.
(setBtMessageDispatcher): New function.
(setBtRequestFactory): New function.
(setPeerConnection): New function.
* src/SharedHandle.h
(RefCount): New class.
(WeakHandle): New class.
* src/PeerObject.h
(BtMessageReceiver.h): New include.
(PeerObject): Added btMessageReceiver.
(btMessageReceiver): New variable.
* src/Util.cc
(countBit): Simplified.
* src/BtCancelMessage.cc
(doReceivedAction): Use dispatcher member.
* src/BtRequestFactory.h
(BtRequestFactoryWeakHandle): New type definition.
* src/PeerStorage.h
(downloadSpeed): int -> uint32_t
(uploadSpeed): int -> uint32_t
(sessionDownloadLength): long long int -> uint64_t
(sessionUploadLength): long long int -> uint64_t
2007-01-16 15:20:26 +00:00
|
|
|
msg->setPeerConnection(peerConnection);
|
2009-11-22 14:52:17 +00:00
|
|
|
if(_metadataGetMode) {
|
|
|
|
msg->enableMetadataGetMode();
|
|
|
|
}
|
2006-12-24 06:25:21 +00:00
|
|
|
}
|
|
|
|
|
2008-04-20 00:50:22 +00:00
|
|
|
SharedHandle<BtHandshakeMessage>
|
2008-03-09 12:24:01 +00:00
|
|
|
DefaultBtMessageFactory::createHandshakeMessage(const unsigned char* data, size_t dataLength)
|
2006-12-24 06:25:21 +00:00
|
|
|
{
|
2008-02-08 15:53:45 +00:00
|
|
|
SharedHandle<BtHandshakeMessage> msg = BtHandshakeMessage::create(data, dataLength);
|
2008-04-20 00:50:22 +00:00
|
|
|
BtMessageValidatorHandle validator
|
2009-06-28 10:37:15 +00:00
|
|
|
(new BtHandshakeMessageValidator
|
|
|
|
(msg.get(), bittorrent::getInfoHash(_downloadContext)));
|
2006-12-24 06:25:21 +00:00
|
|
|
msg->setBtMessageValidator(validator);
|
|
|
|
setCommonProperty(msg);
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2008-04-20 00:50:22 +00:00
|
|
|
SharedHandle<BtHandshakeMessage>
|
2006-12-24 06:25:21 +00:00
|
|
|
DefaultBtMessageFactory::createHandshakeMessage(const unsigned char* infoHash,
|
|
|
|
const unsigned char* peerId)
|
|
|
|
{
|
2008-04-20 00:50:22 +00:00
|
|
|
SharedHandle<BtHandshakeMessage> msg(new BtHandshakeMessage(infoHash, peerId));
|
|
|
|
BtMessageValidatorHandle validator
|
2009-06-28 10:37:15 +00:00
|
|
|
(new BtHandshakeMessageValidator
|
|
|
|
(msg.get(), bittorrent::getInfoHash(_downloadContext)));
|
2006-12-24 06:25:21 +00:00
|
|
|
msg->setBtMessageValidator(validator);
|
2008-02-01 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added DHT functionality, compatible with mainline.
DHT is disabled by default. To enable it, give --enable-dht to
aria2c.
You may need to specify entry point to DHT network using
--dht-entry-point. DHT uses UDP port to listen incoming message.
Use --dht-listen-port to specify port number. Make sure that
your
firewall configuration can pass through UDP traffic to the port.
The routing table is saved in $HOME/.aria2/dht.dat.
* src/DHT*
* src/BNode.{h, cc}
* src/PeerInteractionCommand.cc: enable DHT functionality for a
particular torrent.
* src/Data.cc: Rewritten ctor.
* src/OptionHandlerFactory.cc: Added --enable-dht,
--dht-listen-port,
--dht-entry-point.
* src/DefaultBtInteractive.cc: Send port message if dht is
enabled.
* src/RequestGroup.cc: Initialize DHT functionality. When
download
ends, remove BtContext from DHTPeerAnnounceStorage.
* src/BtPortMessage.{h, cc}: Rewritten.
* src/message.h
* src/OptionHandlerImpl.cc
* src/option_processing.cc: Added --enable-dht,
--dht-listen-port,
--dht-entry-point.
* src/Dictionary.{h, cc} (remove): New function.
* src/prefs.h
* src/DefaultBtMessageFactory.h
* src/BtHandshakeMessage.cc
* src/ActivePeerConnectionCommand.cc
* src/SocketCore.{h, cc}: Added datagram socket support.
* src/DefaultBtMessageFactory.cc
* src/BtSetup.cc: Add BtContext to DHTPeerAnnounceStorage here.
Create DHT commands.
* src/BtMessageFactory.h
* src/PeerMessageUtil.{h, cc}
2008-02-01 17:36:33 +00:00
|
|
|
msg->setDHTEnabled(_dhtEnabled);
|
2006-12-24 06:25:21 +00:00
|
|
|
setCommonProperty(msg);
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
BtMessageHandle
|
2008-03-09 12:24:01 +00:00
|
|
|
DefaultBtMessageFactory::createRequestMessage(const PieceHandle& piece, size_t blockIndex)
|
2006-12-24 06:25:21 +00:00
|
|
|
{
|
2008-04-20 00:50:22 +00:00
|
|
|
BtRequestMessageHandle msg
|
|
|
|
(new BtRequestMessage(piece->getIndex(),
|
|
|
|
blockIndex*piece->getBlockLength(),
|
|
|
|
piece->getBlockLength(blockIndex),
|
|
|
|
blockIndex));
|
2009-03-12 15:54:43 +00:00
|
|
|
SharedHandle<BtMessageValidator> validator
|
|
|
|
(new RangeBtMessageValidator
|
|
|
|
(msg.get(),
|
2009-06-28 10:37:15 +00:00
|
|
|
_downloadContext->getNumPieces(),
|
2009-03-12 15:54:43 +00:00
|
|
|
_pieceStorage->getPieceLength(msg->getIndex())));
|
2006-12-24 06:25:21 +00:00
|
|
|
msg->setBtMessageValidator(validator);
|
|
|
|
setCommonProperty(msg);
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
BtMessageHandle
|
2008-03-09 12:24:01 +00:00
|
|
|
DefaultBtMessageFactory::createCancelMessage(size_t index, uint32_t begin, size_t length)
|
2006-12-24 06:25:21 +00:00
|
|
|
{
|
2008-04-20 00:50:22 +00:00
|
|
|
BtCancelMessageHandle msg(new BtCancelMessage(index, begin, length));
|
2009-03-12 15:54:43 +00:00
|
|
|
SharedHandle<BtMessageValidator> validator
|
|
|
|
(new RangeBtMessageValidator
|
|
|
|
(msg.get(),
|
2009-06-28 10:37:15 +00:00
|
|
|
_downloadContext->getNumPieces(),
|
2009-03-12 15:54:43 +00:00
|
|
|
_pieceStorage->getPieceLength(index)));
|
2006-12-24 06:25:21 +00:00
|
|
|
msg->setBtMessageValidator(validator);
|
|
|
|
setCommonProperty(msg);
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
BtMessageHandle
|
2008-03-09 12:24:01 +00:00
|
|
|
DefaultBtMessageFactory::createPieceMessage(size_t index, uint32_t begin, size_t length)
|
2006-12-24 06:25:21 +00:00
|
|
|
{
|
2008-04-20 00:50:22 +00:00
|
|
|
BtPieceMessageHandle msg(new BtPieceMessage(index, begin, length));
|
|
|
|
BtMessageValidatorHandle validator
|
|
|
|
(new BtPieceMessageValidator(msg.get(),
|
2009-06-28 10:37:15 +00:00
|
|
|
_downloadContext->getNumPieces(),
|
2008-11-03 06:49:02 +00:00
|
|
|
_pieceStorage->getPieceLength(index)));
|
2006-12-24 06:25:21 +00:00
|
|
|
msg->setBtMessageValidator(validator);
|
2009-06-28 10:37:15 +00:00
|
|
|
msg->setDownloadContext(_downloadContext);
|
2006-12-24 06:25:21 +00:00
|
|
|
setCommonProperty(msg);
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
BtMessageHandle
|
2008-03-09 12:24:01 +00:00
|
|
|
DefaultBtMessageFactory::createHaveMessage(size_t index)
|
2006-12-24 06:25:21 +00:00
|
|
|
{
|
2008-04-20 00:50:22 +00:00
|
|
|
BtHaveMessageHandle msg(new BtHaveMessage(index));
|
|
|
|
SharedHandle<BtMessageValidator> v
|
2009-06-28 10:37:15 +00:00
|
|
|
(new IndexBtMessageValidator(msg.get(), _downloadContext->getNumPieces()));
|
2008-04-20 00:50:22 +00:00
|
|
|
msg->setBtMessageValidator(v);
|
2006-12-24 06:25:21 +00:00
|
|
|
setCommonProperty(msg);
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
BtMessageHandle
|
|
|
|
DefaultBtMessageFactory::createChokeMessage()
|
|
|
|
{
|
2008-04-20 00:50:22 +00:00
|
|
|
BtChokeMessageHandle msg(new BtChokeMessage());
|
2006-12-24 06:25:21 +00:00
|
|
|
setCommonProperty(msg);
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
BtMessageHandle
|
|
|
|
DefaultBtMessageFactory::createUnchokeMessage()
|
|
|
|
{
|
2008-04-20 00:50:22 +00:00
|
|
|
BtUnchokeMessageHandle msg(new BtUnchokeMessage());
|
2006-12-24 06:25:21 +00:00
|
|
|
setCommonProperty(msg);
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
BtMessageHandle
|
|
|
|
DefaultBtMessageFactory::createInterestedMessage()
|
|
|
|
{
|
2008-04-20 00:50:22 +00:00
|
|
|
BtInterestedMessageHandle msg(new BtInterestedMessage());
|
2006-12-24 06:25:21 +00:00
|
|
|
setCommonProperty(msg);
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
BtMessageHandle
|
|
|
|
DefaultBtMessageFactory::createNotInterestedMessage()
|
|
|
|
{
|
2008-04-20 00:50:22 +00:00
|
|
|
BtNotInterestedMessageHandle msg(new BtNotInterestedMessage());
|
2006-12-24 06:25:21 +00:00
|
|
|
setCommonProperty(msg);
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
BtMessageHandle
|
|
|
|
DefaultBtMessageFactory::createBitfieldMessage()
|
|
|
|
{
|
2008-04-20 00:50:22 +00:00
|
|
|
BtBitfieldMessageHandle msg
|
2008-11-03 06:49:02 +00:00
|
|
|
(new BtBitfieldMessage(_pieceStorage->getBitfield(),
|
|
|
|
_pieceStorage->getBitfieldLength()));
|
2008-04-20 00:50:22 +00:00
|
|
|
SharedHandle<BtMessageValidator> v
|
|
|
|
(new BtBitfieldMessageValidator(msg.get(),
|
2009-06-28 10:37:15 +00:00
|
|
|
_downloadContext->getNumPieces()));
|
2008-04-20 00:50:22 +00:00
|
|
|
msg->setBtMessageValidator(v);
|
2006-12-24 06:25:21 +00:00
|
|
|
setCommonProperty(msg);
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
BtMessageHandle
|
|
|
|
DefaultBtMessageFactory::createKeepAliveMessage()
|
|
|
|
{
|
2008-04-20 00:50:22 +00:00
|
|
|
BtKeepAliveMessageHandle msg(new BtKeepAliveMessage());
|
2006-12-24 06:25:21 +00:00
|
|
|
setCommonProperty(msg);
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
BtMessageHandle
|
|
|
|
DefaultBtMessageFactory::createHaveAllMessage()
|
|
|
|
{
|
2008-04-20 00:50:22 +00:00
|
|
|
BtHaveAllMessageHandle msg(new BtHaveAllMessage());
|
2006-12-24 06:25:21 +00:00
|
|
|
setCommonProperty(msg);
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
BtMessageHandle
|
|
|
|
DefaultBtMessageFactory::createHaveNoneMessage()
|
|
|
|
{
|
2008-04-20 00:50:22 +00:00
|
|
|
BtHaveNoneMessageHandle msg(new BtHaveNoneMessage());
|
2006-12-24 06:25:21 +00:00
|
|
|
setCommonProperty(msg);
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
BtMessageHandle
|
2008-03-09 12:24:01 +00:00
|
|
|
DefaultBtMessageFactory::createRejectMessage(size_t index, uint32_t begin, size_t length)
|
2006-12-24 06:25:21 +00:00
|
|
|
{
|
2008-04-20 00:50:22 +00:00
|
|
|
BtRejectMessageHandle msg(new BtRejectMessage(index, begin, length));
|
2009-03-12 15:54:43 +00:00
|
|
|
SharedHandle<BtMessageValidator> validator
|
|
|
|
(new RangeBtMessageValidator
|
|
|
|
(msg.get(),
|
2009-06-28 10:37:15 +00:00
|
|
|
_downloadContext->getNumPieces(),
|
2009-03-12 15:54:43 +00:00
|
|
|
_pieceStorage->getPieceLength(index)));
|
2006-12-24 06:25:21 +00:00
|
|
|
msg->setBtMessageValidator(validator);
|
|
|
|
setCommonProperty(msg);
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
BtMessageHandle
|
2008-03-09 12:24:01 +00:00
|
|
|
DefaultBtMessageFactory::createAllowedFastMessage(size_t index)
|
2006-12-24 06:25:21 +00:00
|
|
|
{
|
2008-04-20 00:50:22 +00:00
|
|
|
BtAllowedFastMessageHandle msg(new BtAllowedFastMessage(index));
|
2009-03-12 15:54:43 +00:00
|
|
|
SharedHandle<BtMessageValidator> validator
|
2009-06-28 10:37:15 +00:00
|
|
|
(new IndexBtMessageValidator(msg.get(), _downloadContext->getNumPieces()));
|
2006-12-24 06:25:21 +00:00
|
|
|
msg->setBtMessageValidator(validator);
|
|
|
|
setCommonProperty(msg);
|
|
|
|
return msg;
|
|
|
|
}
|
2007-12-22 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added uTorrent compatible Peer Exchange.
* src/BencodeVisitor.{h, cc}
* test/BencodeVisitorTest.cc
* src/BtConstants.h
* src/BtContext.h: Added 'private' flag.
* src/BtExtendedMessage.{h, cc}
* test/BtExtendedMessageTest.cc
* src/BtHandshakeMessage.{h, cc}: Set extended messaging bit in
reserved field.
* test/BtHandshakeMessageTest.cc
* src/BtMessageFactory.h
* src/BtRegistry.h
* src/BtRuntime.h: This class holds default extension message
IDs for
aria2. By default, aria2 uses ID 8 for ut_pex.
* src/DefaultBtContext.cc
* src/DefaultBtInteractive.{h, cc}: This class holds
_utPexEnabled.
When it is true, aria2 enables ut_pex. This value is set by
PeerInteractionCommand.
* src/DefaultBtMessageFactory.{h, cc}
* test/DefaultBtMessageFactoryTest.cc
* src/DefaultBtMessageReceiver.cc: Moved the code of fast
extension
handling to DefaultBtInteractive class.
* src/DefaultExtensionMessageFactory.{h, cc}
* test/DefaultExtensionMessageFactoryTest.cc
* src/DefaultPeerStorage.cc: Returns false if a peer is already
in
the container(peers and incomingPeers. The equality is
determined by
Peer::id).
* test/DefaultPeerStorageTest.cc
* src/ExtensionMessage.h
* test/MockExtensionMessage.h
* src/ExtensionMessageFactory.h
* test/MockExtensionMessageFactory.h
* src/HandshakeExtensionMessage.{h, cc}
* test/HandshakeExtensionMessageTest.cc
* src/MetaEntry.h
* src/Peer.{h, cc}
* src/PeerInteractionCommand.cc
* src/PeerReceiveHandshakeCommand.cc: Evaluate the return value
of
addIncomingPeer.
* src/PeerMessageUtil.{h, cc}
* src/PeerObject.h
* src/UTPexExtensionMessage.{h, cc}
* test/UTPexExtensionMessageTest.cc
* src/message.h
* src/prefs.h
Fixed the bug that returns incomplete data when it contains null
character. A convenient constructor was also added.
* src/Data.{h, cc}
Rewritten.
* src/CompactPeerListProcessor.cc
Fixed typos.
* src/message.h
* src/MetaFileUtil.cc
2007-12-22 03:57:55 +00:00
|
|
|
|
2008-02-01 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added DHT functionality, compatible with mainline.
DHT is disabled by default. To enable it, give --enable-dht to
aria2c.
You may need to specify entry point to DHT network using
--dht-entry-point. DHT uses UDP port to listen incoming message.
Use --dht-listen-port to specify port number. Make sure that
your
firewall configuration can pass through UDP traffic to the port.
The routing table is saved in $HOME/.aria2/dht.dat.
* src/DHT*
* src/BNode.{h, cc}
* src/PeerInteractionCommand.cc: enable DHT functionality for a
particular torrent.
* src/Data.cc: Rewritten ctor.
* src/OptionHandlerFactory.cc: Added --enable-dht,
--dht-listen-port,
--dht-entry-point.
* src/DefaultBtInteractive.cc: Send port message if dht is
enabled.
* src/RequestGroup.cc: Initialize DHT functionality. When
download
ends, remove BtContext from DHTPeerAnnounceStorage.
* src/BtPortMessage.{h, cc}: Rewritten.
* src/message.h
* src/OptionHandlerImpl.cc
* src/option_processing.cc: Added --enable-dht,
--dht-listen-port,
--dht-entry-point.
* src/Dictionary.{h, cc} (remove): New function.
* src/prefs.h
* src/DefaultBtMessageFactory.h
* src/BtHandshakeMessage.cc
* src/ActivePeerConnectionCommand.cc
* src/SocketCore.{h, cc}: Added datagram socket support.
* src/DefaultBtMessageFactory.cc
* src/BtSetup.cc: Add BtContext to DHTPeerAnnounceStorage here.
Create DHT commands.
* src/BtMessageFactory.h
* src/PeerMessageUtil.{h, cc}
2008-02-01 17:36:33 +00:00
|
|
|
BtMessageHandle
|
|
|
|
DefaultBtMessageFactory::createPortMessage(uint16_t port)
|
|
|
|
{
|
2008-04-20 00:50:22 +00:00
|
|
|
SharedHandle<BtPortMessage> msg(new BtPortMessage(port));
|
2008-02-01 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added DHT functionality, compatible with mainline.
DHT is disabled by default. To enable it, give --enable-dht to
aria2c.
You may need to specify entry point to DHT network using
--dht-entry-point. DHT uses UDP port to listen incoming message.
Use --dht-listen-port to specify port number. Make sure that
your
firewall configuration can pass through UDP traffic to the port.
The routing table is saved in $HOME/.aria2/dht.dat.
* src/DHT*
* src/BNode.{h, cc}
* src/PeerInteractionCommand.cc: enable DHT functionality for a
particular torrent.
* src/Data.cc: Rewritten ctor.
* src/OptionHandlerFactory.cc: Added --enable-dht,
--dht-listen-port,
--dht-entry-point.
* src/DefaultBtInteractive.cc: Send port message if dht is
enabled.
* src/RequestGroup.cc: Initialize DHT functionality. When
download
ends, remove BtContext from DHTPeerAnnounceStorage.
* src/BtPortMessage.{h, cc}: Rewritten.
* src/message.h
* src/OptionHandlerImpl.cc
* src/option_processing.cc: Added --enable-dht,
--dht-listen-port,
--dht-entry-point.
* src/Dictionary.{h, cc} (remove): New function.
* src/prefs.h
* src/DefaultBtMessageFactory.h
* src/BtHandshakeMessage.cc
* src/ActivePeerConnectionCommand.cc
* src/SocketCore.{h, cc}: Added datagram socket support.
* src/DefaultBtMessageFactory.cc
* src/BtSetup.cc: Add BtContext to DHTPeerAnnounceStorage here.
Create DHT commands.
* src/BtMessageFactory.h
* src/PeerMessageUtil.{h, cc}
2008-02-01 17:36:33 +00:00
|
|
|
setCommonProperty(msg);
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2007-12-22 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added uTorrent compatible Peer Exchange.
* src/BencodeVisitor.{h, cc}
* test/BencodeVisitorTest.cc
* src/BtConstants.h
* src/BtContext.h: Added 'private' flag.
* src/BtExtendedMessage.{h, cc}
* test/BtExtendedMessageTest.cc
* src/BtHandshakeMessage.{h, cc}: Set extended messaging bit in
reserved field.
* test/BtHandshakeMessageTest.cc
* src/BtMessageFactory.h
* src/BtRegistry.h
* src/BtRuntime.h: This class holds default extension message
IDs for
aria2. By default, aria2 uses ID 8 for ut_pex.
* src/DefaultBtContext.cc
* src/DefaultBtInteractive.{h, cc}: This class holds
_utPexEnabled.
When it is true, aria2 enables ut_pex. This value is set by
PeerInteractionCommand.
* src/DefaultBtMessageFactory.{h, cc}
* test/DefaultBtMessageFactoryTest.cc
* src/DefaultBtMessageReceiver.cc: Moved the code of fast
extension
handling to DefaultBtInteractive class.
* src/DefaultExtensionMessageFactory.{h, cc}
* test/DefaultExtensionMessageFactoryTest.cc
* src/DefaultPeerStorage.cc: Returns false if a peer is already
in
the container(peers and incomingPeers. The equality is
determined by
Peer::id).
* test/DefaultPeerStorageTest.cc
* src/ExtensionMessage.h
* test/MockExtensionMessage.h
* src/ExtensionMessageFactory.h
* test/MockExtensionMessageFactory.h
* src/HandshakeExtensionMessage.{h, cc}
* test/HandshakeExtensionMessageTest.cc
* src/MetaEntry.h
* src/Peer.{h, cc}
* src/PeerInteractionCommand.cc
* src/PeerReceiveHandshakeCommand.cc: Evaluate the return value
of
addIncomingPeer.
* src/PeerMessageUtil.{h, cc}
* src/PeerObject.h
* src/UTPexExtensionMessage.{h, cc}
* test/UTPexExtensionMessageTest.cc
* src/message.h
* src/prefs.h
Fixed the bug that returns incomplete data when it contains null
character. A convenient constructor was also added.
* src/Data.{h, cc}
Rewritten.
* src/CompactPeerListProcessor.cc
Fixed typos.
* src/message.h
* src/MetaFileUtil.cc
2007-12-22 03:57:55 +00:00
|
|
|
BtMessageHandle
|
2008-02-08 15:53:45 +00:00
|
|
|
DefaultBtMessageFactory::createBtExtendedMessage(const ExtensionMessageHandle& msg)
|
2007-12-22 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added uTorrent compatible Peer Exchange.
* src/BencodeVisitor.{h, cc}
* test/BencodeVisitorTest.cc
* src/BtConstants.h
* src/BtContext.h: Added 'private' flag.
* src/BtExtendedMessage.{h, cc}
* test/BtExtendedMessageTest.cc
* src/BtHandshakeMessage.{h, cc}: Set extended messaging bit in
reserved field.
* test/BtHandshakeMessageTest.cc
* src/BtMessageFactory.h
* src/BtRegistry.h
* src/BtRuntime.h: This class holds default extension message
IDs for
aria2. By default, aria2 uses ID 8 for ut_pex.
* src/DefaultBtContext.cc
* src/DefaultBtInteractive.{h, cc}: This class holds
_utPexEnabled.
When it is true, aria2 enables ut_pex. This value is set by
PeerInteractionCommand.
* src/DefaultBtMessageFactory.{h, cc}
* test/DefaultBtMessageFactoryTest.cc
* src/DefaultBtMessageReceiver.cc: Moved the code of fast
extension
handling to DefaultBtInteractive class.
* src/DefaultExtensionMessageFactory.{h, cc}
* test/DefaultExtensionMessageFactoryTest.cc
* src/DefaultPeerStorage.cc: Returns false if a peer is already
in
the container(peers and incomingPeers. The equality is
determined by
Peer::id).
* test/DefaultPeerStorageTest.cc
* src/ExtensionMessage.h
* test/MockExtensionMessage.h
* src/ExtensionMessageFactory.h
* test/MockExtensionMessageFactory.h
* src/HandshakeExtensionMessage.{h, cc}
* test/HandshakeExtensionMessageTest.cc
* src/MetaEntry.h
* src/Peer.{h, cc}
* src/PeerInteractionCommand.cc
* src/PeerReceiveHandshakeCommand.cc: Evaluate the return value
of
addIncomingPeer.
* src/PeerMessageUtil.{h, cc}
* src/PeerObject.h
* src/UTPexExtensionMessage.{h, cc}
* test/UTPexExtensionMessageTest.cc
* src/message.h
* src/prefs.h
Fixed the bug that returns incomplete data when it contains null
character. A convenient constructor was also added.
* src/Data.{h, cc}
Rewritten.
* src/CompactPeerListProcessor.cc
Fixed typos.
* src/message.h
* src/MetaFileUtil.cc
2007-12-22 03:57:55 +00:00
|
|
|
{
|
2008-04-20 00:50:22 +00:00
|
|
|
BtExtendedMessageHandle m(new BtExtendedMessage(msg));
|
2007-12-22 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added uTorrent compatible Peer Exchange.
* src/BencodeVisitor.{h, cc}
* test/BencodeVisitorTest.cc
* src/BtConstants.h
* src/BtContext.h: Added 'private' flag.
* src/BtExtendedMessage.{h, cc}
* test/BtExtendedMessageTest.cc
* src/BtHandshakeMessage.{h, cc}: Set extended messaging bit in
reserved field.
* test/BtHandshakeMessageTest.cc
* src/BtMessageFactory.h
* src/BtRegistry.h
* src/BtRuntime.h: This class holds default extension message
IDs for
aria2. By default, aria2 uses ID 8 for ut_pex.
* src/DefaultBtContext.cc
* src/DefaultBtInteractive.{h, cc}: This class holds
_utPexEnabled.
When it is true, aria2 enables ut_pex. This value is set by
PeerInteractionCommand.
* src/DefaultBtMessageFactory.{h, cc}
* test/DefaultBtMessageFactoryTest.cc
* src/DefaultBtMessageReceiver.cc: Moved the code of fast
extension
handling to DefaultBtInteractive class.
* src/DefaultExtensionMessageFactory.{h, cc}
* test/DefaultExtensionMessageFactoryTest.cc
* src/DefaultPeerStorage.cc: Returns false if a peer is already
in
the container(peers and incomingPeers. The equality is
determined by
Peer::id).
* test/DefaultPeerStorageTest.cc
* src/ExtensionMessage.h
* test/MockExtensionMessage.h
* src/ExtensionMessageFactory.h
* test/MockExtensionMessageFactory.h
* src/HandshakeExtensionMessage.{h, cc}
* test/HandshakeExtensionMessageTest.cc
* src/MetaEntry.h
* src/Peer.{h, cc}
* src/PeerInteractionCommand.cc
* src/PeerReceiveHandshakeCommand.cc: Evaluate the return value
of
addIncomingPeer.
* src/PeerMessageUtil.{h, cc}
* src/PeerObject.h
* src/UTPexExtensionMessage.{h, cc}
* test/UTPexExtensionMessageTest.cc
* src/message.h
* src/prefs.h
Fixed the bug that returns incomplete data when it contains null
character. A convenient constructor was also added.
* src/Data.{h, cc}
Rewritten.
* src/CompactPeerListProcessor.cc
Fixed typos.
* src/message.h
* src/MetaFileUtil.cc
2007-12-22 03:57:55 +00:00
|
|
|
setCommonProperty(m);
|
|
|
|
return m;
|
|
|
|
}
|
2008-02-01 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added DHT functionality, compatible with mainline.
DHT is disabled by default. To enable it, give --enable-dht to
aria2c.
You may need to specify entry point to DHT network using
--dht-entry-point. DHT uses UDP port to listen incoming message.
Use --dht-listen-port to specify port number. Make sure that
your
firewall configuration can pass through UDP traffic to the port.
The routing table is saved in $HOME/.aria2/dht.dat.
* src/DHT*
* src/BNode.{h, cc}
* src/PeerInteractionCommand.cc: enable DHT functionality for a
particular torrent.
* src/Data.cc: Rewritten ctor.
* src/OptionHandlerFactory.cc: Added --enable-dht,
--dht-listen-port,
--dht-entry-point.
* src/DefaultBtInteractive.cc: Send port message if dht is
enabled.
* src/RequestGroup.cc: Initialize DHT functionality. When
download
ends, remove BtContext from DHTPeerAnnounceStorage.
* src/BtPortMessage.{h, cc}: Rewritten.
* src/message.h
* src/OptionHandlerImpl.cc
* src/option_processing.cc: Added --enable-dht,
--dht-listen-port,
--dht-entry-point.
* src/Dictionary.{h, cc} (remove): New function.
* src/prefs.h
* src/DefaultBtMessageFactory.h
* src/BtHandshakeMessage.cc
* src/ActivePeerConnectionCommand.cc
* src/SocketCore.{h, cc}: Added datagram socket support.
* src/DefaultBtMessageFactory.cc
* src/BtSetup.cc: Add BtContext to DHTPeerAnnounceStorage here.
Create DHT commands.
* src/BtMessageFactory.h
* src/PeerMessageUtil.{h, cc}
2008-02-01 17:36:33 +00:00
|
|
|
|
|
|
|
void DefaultBtMessageFactory::setTaskQueue(const WeakHandle<DHTTaskQueue>& taskQueue)
|
|
|
|
{
|
|
|
|
_taskQueue = taskQueue;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DefaultBtMessageFactory::setTaskFactory(const WeakHandle<DHTTaskFactory>& taskFactory)
|
|
|
|
{
|
|
|
|
_taskFactory = taskFactory;
|
|
|
|
}
|
2008-02-08 15:53:45 +00:00
|
|
|
|
|
|
|
void DefaultBtMessageFactory::setPeer(const SharedHandle<Peer>& peer)
|
|
|
|
{
|
|
|
|
this->peer = peer;
|
|
|
|
}
|
|
|
|
|
2009-06-28 10:37:15 +00:00
|
|
|
void DefaultBtMessageFactory::setDownloadContext
|
|
|
|
(const SharedHandle<DownloadContext>& downloadContext)
|
2008-02-08 15:53:45 +00:00
|
|
|
{
|
2009-06-28 10:37:15 +00:00
|
|
|
_downloadContext = downloadContext;
|
2008-11-03 06:49:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DefaultBtMessageFactory::setPieceStorage
|
|
|
|
(const SharedHandle<PieceStorage>& pieceStorage)
|
|
|
|
{
|
|
|
|
_pieceStorage = pieceStorage;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DefaultBtMessageFactory::setPeerStorage
|
|
|
|
(const SharedHandle<PeerStorage>& peerStorage)
|
|
|
|
{
|
|
|
|
_peerStorage = peerStorage;
|
2008-02-08 15:53:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DefaultBtMessageFactory::setBtMessageDispatcher(const WeakHandle<BtMessageDispatcher>& dispatcher)
|
|
|
|
{
|
|
|
|
this->dispatcher = dispatcher;
|
|
|
|
}
|
2008-02-10 15:57:00 +00:00
|
|
|
|
2008-11-03 06:49:02 +00:00
|
|
|
void DefaultBtMessageFactory::setExtensionMessageFactory
|
|
|
|
(const SharedHandle<ExtensionMessageFactory>& factory)
|
|
|
|
{
|
|
|
|
_extensionMessageFactory = factory;
|
|
|
|
}
|
|
|
|
|
2008-02-10 15:57:00 +00:00
|
|
|
void DefaultBtMessageFactory::setLocalNode(const WeakHandle<DHTNode>& localNode)
|
|
|
|
{
|
|
|
|
_localNode = localNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DefaultBtMessageFactory::setRoutingTable(const WeakHandle<DHTRoutingTable>& routingTable)
|
|
|
|
{
|
|
|
|
_routingTable = routingTable;
|
|
|
|
}
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
void DefaultBtMessageFactory::setBtRequestFactory(const WeakHandle<BtRequestFactory>& factory)
|
|
|
|
{
|
|
|
|
this->requestFactory = factory;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DefaultBtMessageFactory::setPeerConnection(const WeakHandle<PeerConnection>& connection)
|
|
|
|
{
|
|
|
|
this->peerConnection = connection;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace aria2
|