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
|
2010-01-05 16:01:46 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2006-12-24 06:25:21 +00:00
|
|
|
*
|
|
|
|
* 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"
|
2010-11-20 09:36:14 +00:00
|
|
|
#include "fmt.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
|
|
|
|
2013-06-30 07:55:15 +00:00
|
|
|
DefaultBtMessageFactory::DefaultBtMessageFactory()
|
|
|
|
: cuid_{0},
|
|
|
|
downloadContext_{nullptr},
|
|
|
|
pieceStorage_{nullptr},
|
|
|
|
peerStorage_{nullptr},
|
|
|
|
dhtEnabled_(false),
|
|
|
|
dispatcher_{nullptr},
|
|
|
|
requestFactory_{nullptr},
|
|
|
|
peerConnection_{nullptr},
|
|
|
|
localNode_{nullptr},
|
|
|
|
routingTable_{nullptr},
|
|
|
|
taskQueue_{nullptr},
|
|
|
|
taskFactory_{nullptr},
|
|
|
|
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
|
|
|
{}
|
|
|
|
|
2013-06-30 07:55:15 +00:00
|
|
|
std::unique_ptr<BtMessage>
|
2010-06-12 08:23:49 +00:00
|
|
|
DefaultBtMessageFactory::createBtMessage
|
|
|
|
(const unsigned char* data, size_t dataLength)
|
2006-12-24 06:25:21 +00:00
|
|
|
{
|
2013-06-30 07:55:15 +00:00
|
|
|
auto msg = std::unique_ptr<AbstractBtMessage>{};
|
2006-12-24 06:25:21 +00:00
|
|
|
if(dataLength == 0) {
|
|
|
|
// keep-alive
|
2013-06-30 07:55:15 +00:00
|
|
|
msg = make_unique<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:
|
2013-06-30 07:55:15 +00:00
|
|
|
msg = BtChokeMessage::create(data, dataLength);
|
2006-12-24 06:25:21 +00:00
|
|
|
break;
|
|
|
|
case BtUnchokeMessage::ID:
|
2013-06-30 07:55:15 +00:00
|
|
|
msg = BtUnchokeMessage::create(data, dataLength);
|
2006-12-24 06:25:21 +00:00
|
|
|
break;
|
2013-06-30 07:55:15 +00:00
|
|
|
case BtInterestedMessage::ID: {
|
|
|
|
auto m = BtInterestedMessage::create(data, dataLength);
|
|
|
|
m->setPeerStorage(peerStorage_);
|
|
|
|
msg = std::move(m);
|
2006-12-24 06:25:21 +00:00
|
|
|
break;
|
2013-06-30 07:55:15 +00:00
|
|
|
}
|
|
|
|
case BtNotInterestedMessage::ID: {
|
|
|
|
auto m = BtNotInterestedMessage::create(data, dataLength);
|
|
|
|
m->setPeerStorage(peerStorage_);
|
|
|
|
msg = std::move(m);
|
2006-12-24 06:25:21 +00:00
|
|
|
break;
|
2013-06-30 07:55:15 +00:00
|
|
|
}
|
2006-12-24 06:25:21 +00:00
|
|
|
case BtHaveMessage::ID:
|
2013-06-30 07:55:15 +00:00
|
|
|
msg = BtHaveMessage::create(data, dataLength);
|
2012-09-27 14:40:25 +00:00
|
|
|
if(!metadataGetMode_) {
|
2013-06-23 07:12:19 +00:00
|
|
|
msg->setBtMessageValidator(make_unique<IndexBtMessageValidator>
|
|
|
|
(static_cast<BtHaveMessage*>(msg.get()),
|
|
|
|
downloadContext_->getNumPieces()));
|
2008-04-20 00:50:22 +00:00
|
|
|
}
|
2006-12-24 06:25:21 +00:00
|
|
|
break;
|
|
|
|
case BtBitfieldMessage::ID:
|
2013-06-30 07:55:15 +00:00
|
|
|
msg = BtBitfieldMessage::create(data, dataLength);
|
2012-09-27 14:40:25 +00:00
|
|
|
if(!metadataGetMode_) {
|
2013-06-23 07:12:19 +00:00
|
|
|
msg->setBtMessageValidator(make_unique<BtBitfieldMessageValidator>
|
|
|
|
(static_cast<BtBitfieldMessage*>(msg.get()),
|
|
|
|
downloadContext_->getNumPieces()));
|
2008-04-20 00:50:22 +00:00
|
|
|
}
|
2006-12-24 06:25:21 +00:00
|
|
|
break;
|
|
|
|
case BtRequestMessage::ID: {
|
2013-06-30 07:55:15 +00:00
|
|
|
auto m = BtRequestMessage::create(data, dataLength);
|
2010-06-21 13:51:56 +00:00
|
|
|
if(!metadataGetMode_) {
|
2013-06-23 07:12:19 +00:00
|
|
|
m->setBtMessageValidator
|
|
|
|
(make_unique<RangeBtMessageValidator>
|
2013-06-30 07:55:15 +00:00
|
|
|
(static_cast<BtRequestMessage*>(m.get()),
|
2010-06-21 13:51:56 +00:00
|
|
|
downloadContext_->getNumPieces(),
|
2012-09-27 14:40:25 +00:00
|
|
|
pieceStorage_->getPieceLength(m->getIndex())));
|
2009-11-22 14:52:17 +00:00
|
|
|
}
|
2013-06-30 07:55:15 +00:00
|
|
|
msg = std::move(m);
|
2006-12-24 06:25:21 +00:00
|
|
|
break;
|
|
|
|
}
|
2013-06-30 07:55:15 +00:00
|
|
|
case BtPieceMessage::ID: {
|
|
|
|
auto m = BtPieceMessage::create(data, dataLength);
|
2010-06-21 13:51:56 +00:00
|
|
|
if(!metadataGetMode_) {
|
2013-06-23 07:12:19 +00:00
|
|
|
m->setBtMessageValidator
|
2013-06-30 07:55:15 +00:00
|
|
|
(make_unique<BtPieceMessageValidator>
|
|
|
|
(static_cast<BtPieceMessage*>(m.get()),
|
2010-06-21 13:51:56 +00:00
|
|
|
downloadContext_->getNumPieces(),
|
2012-09-27 14:40:25 +00:00
|
|
|
pieceStorage_->getPieceLength(m->getIndex())));
|
2009-11-22 14:52:17 +00:00
|
|
|
}
|
2013-06-30 07:55:15 +00:00
|
|
|
m->setDownloadContext(downloadContext_);
|
|
|
|
m->setPeerStorage(peerStorage_);
|
|
|
|
msg = std::move(m);
|
2006-12-24 06:25:21 +00:00
|
|
|
break;
|
|
|
|
}
|
2013-06-30 07:55:15 +00:00
|
|
|
case BtCancelMessage::ID: {
|
|
|
|
auto m = BtCancelMessage::create(data, dataLength);
|
2010-06-21 13:51:56 +00:00
|
|
|
if(!metadataGetMode_) {
|
2013-06-23 07:12:19 +00:00
|
|
|
m->setBtMessageValidator
|
2013-06-30 07:55:15 +00:00
|
|
|
(make_unique<RangeBtMessageValidator>
|
|
|
|
(static_cast<BtCancelMessage*>(m.get()),
|
2010-06-21 13:51:56 +00:00
|
|
|
downloadContext_->getNumPieces(),
|
2012-09-27 14:40:25 +00:00
|
|
|
pieceStorage_->getPieceLength(m->getIndex())));
|
2009-11-22 14:52:17 +00:00
|
|
|
}
|
2013-06-30 07:55:15 +00:00
|
|
|
msg = std::move(m);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case BtPortMessage::ID: {
|
|
|
|
auto m = BtPortMessage::create(data, dataLength);
|
|
|
|
m->setLocalNode(localNode_);
|
|
|
|
m->setRoutingTable(routingTable_);
|
|
|
|
m->setTaskQueue(taskQueue_);
|
|
|
|
m->setTaskFactory(taskFactory_);
|
|
|
|
msg = std::move(m);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case BtSuggestPieceMessage::ID: {
|
|
|
|
auto m = BtSuggestPieceMessage::create(data, dataLength);
|
|
|
|
if(!metadataGetMode_) {
|
|
|
|
m->setBtMessageValidator(make_unique<IndexBtMessageValidator>
|
|
|
|
(static_cast<BtSuggestPieceMessage*>(m.get()),
|
|
|
|
downloadContext_->getNumPieces()));
|
|
|
|
}
|
|
|
|
msg = std::move(m);
|
2006-12-24 06:25:21 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case BtHaveAllMessage::ID:
|
2013-06-30 07:55:15 +00:00
|
|
|
msg = BtHaveAllMessage::create(data, dataLength);
|
2006-12-24 06:25:21 +00:00
|
|
|
break;
|
|
|
|
case BtHaveNoneMessage::ID:
|
2013-06-30 07:55:15 +00:00
|
|
|
msg = BtHaveNoneMessage::create(data, dataLength);
|
2006-12-24 06:25:21 +00:00
|
|
|
break;
|
|
|
|
case BtRejectMessage::ID: {
|
2013-06-30 07:55:15 +00:00
|
|
|
auto m = BtRejectMessage::create(data, dataLength);
|
2010-06-21 13:51:56 +00:00
|
|
|
if(!metadataGetMode_) {
|
2013-06-23 07:12:19 +00:00
|
|
|
m->setBtMessageValidator
|
|
|
|
(make_unique<RangeBtMessageValidator>
|
2013-06-30 07:55:15 +00:00
|
|
|
(static_cast<BtRejectMessage*>(m.get()),
|
2010-06-21 13:51:56 +00:00
|
|
|
downloadContext_->getNumPieces(),
|
2012-09-27 14:40:25 +00:00
|
|
|
pieceStorage_->getPieceLength(m->getIndex())));
|
2009-11-22 14:52:17 +00:00
|
|
|
}
|
2013-06-30 07:55:15 +00:00
|
|
|
msg = std::move(m);
|
2006-12-24 06:25:21 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case BtAllowedFastMessage::ID: {
|
2013-06-30 07:55:15 +00:00
|
|
|
auto m = BtAllowedFastMessage::create(data, dataLength);
|
2010-06-21 13:51:56 +00:00
|
|
|
if(!metadataGetMode_) {
|
2013-06-23 07:12:19 +00:00
|
|
|
m->setBtMessageValidator(make_unique<IndexBtMessageValidator>
|
2013-06-30 07:55:15 +00:00
|
|
|
(static_cast<BtAllowedFastMessage*>(m.get()),
|
|
|
|
downloadContext_->getNumPieces()));
|
2009-11-22 14:52:17 +00:00
|
|
|
}
|
2013-06-30 07:55:15 +00:00
|
|
|
msg = std::move(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
|
|
|
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: {
|
2010-06-21 13:51:56 +00:00
|
|
|
if(peer_->isExtendedMessagingEnabled()) {
|
2013-06-30 07:55:15 +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 {
|
2010-06-12 08:23:49 +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:
|
2010-11-20 09:36:14 +00:00
|
|
|
throw DL_ABORT_EX(fmt("Invalid message ID. id=%u", id));
|
2006-12-24 06:25:21 +00:00
|
|
|
}
|
|
|
|
}
|
2012-09-27 14:40:25 +00:00
|
|
|
setCommonProperty(msg.get());
|
2013-06-30 07:55:15 +00:00
|
|
|
return std::move(msg);
|
2006-12-24 06:25:21 +00:00
|
|
|
}
|
|
|
|
|
2012-09-27 14:40:25 +00:00
|
|
|
void DefaultBtMessageFactory::setCommonProperty(AbstractBtMessage* msg)
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
msg->setCuid(cuid_);
|
|
|
|
msg->setPeer(peer_);
|
|
|
|
msg->setPieceStorage(pieceStorage_);
|
|
|
|
msg->setBtMessageDispatcher(dispatcher_);
|
|
|
|
msg->setBtRequestFactory(requestFactory_);
|
2010-11-12 12:48:48 +00:00
|
|
|
msg->setBtMessageFactory(this);
|
2010-06-21 13:51:56 +00:00
|
|
|
msg->setPeerConnection(peerConnection_);
|
|
|
|
if(metadataGetMode_) {
|
2009-11-22 14:52:17 +00:00
|
|
|
msg->enableMetadataGetMode();
|
|
|
|
}
|
2006-12-24 06:25:21 +00:00
|
|
|
}
|
|
|
|
|
2013-06-30 07:55:15 +00:00
|
|
|
std::unique_ptr<BtHandshakeMessage>
|
2010-06-12 08:23:49 +00:00
|
|
|
DefaultBtMessageFactory::createHandshakeMessage
|
|
|
|
(const unsigned char* data, size_t dataLength)
|
2006-12-24 06:25:21 +00:00
|
|
|
{
|
2013-06-30 07:55:15 +00:00
|
|
|
auto msg = BtHandshakeMessage::create(data, dataLength);
|
2013-06-23 07:12:19 +00:00
|
|
|
msg->setBtMessageValidator(make_unique<BtHandshakeMessageValidator>
|
|
|
|
(msg.get(),
|
|
|
|
bittorrent::getInfoHash(downloadContext_)));
|
2012-09-27 14:40:25 +00:00
|
|
|
setCommonProperty(msg.get());
|
2006-12-24 06:25:21 +00:00
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2013-06-30 07:55:15 +00:00
|
|
|
std::unique_ptr<BtHandshakeMessage>
|
2006-12-24 06:25:21 +00:00
|
|
|
DefaultBtMessageFactory::createHandshakeMessage(const unsigned char* infoHash,
|
2010-01-05 16:01:46 +00:00
|
|
|
const unsigned char* peerId)
|
2006-12-24 06:25:21 +00:00
|
|
|
{
|
2013-06-30 07:55:15 +00:00
|
|
|
auto msg = make_unique<BtHandshakeMessage>(infoHash, peerId);
|
2010-06-21 13:51:56 +00:00
|
|
|
msg->setDHTEnabled(dhtEnabled_);
|
2012-09-27 14:40:25 +00:00
|
|
|
setCommonProperty(msg.get());
|
2006-12-24 06:25:21 +00:00
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2013-06-30 07:55:15 +00:00
|
|
|
std::unique_ptr<BtRequestMessage>
|
2010-02-28 12:30:11 +00:00
|
|
|
DefaultBtMessageFactory::createRequestMessage
|
2013-06-21 16:10:38 +00:00
|
|
|
(const std::shared_ptr<Piece>& piece, size_t blockIndex)
|
2006-12-24 06:25:21 +00:00
|
|
|
{
|
2013-06-30 07:55:15 +00:00
|
|
|
auto msg = make_unique<BtRequestMessage>(piece->getIndex(),
|
|
|
|
blockIndex*piece->getBlockLength(),
|
|
|
|
piece->getBlockLength(blockIndex),
|
|
|
|
blockIndex);
|
|
|
|
setCommonProperty(msg.get());
|
|
|
|
return msg;
|
2006-12-24 06:25:21 +00:00
|
|
|
}
|
|
|
|
|
2013-06-30 07:55:15 +00:00
|
|
|
std::unique_ptr<BtCancelMessage>
|
2010-06-12 08:23:49 +00:00
|
|
|
DefaultBtMessageFactory::createCancelMessage
|
2011-12-07 15:51:20 +00:00
|
|
|
(size_t index, int32_t begin, int32_t length)
|
2006-12-24 06:25:21 +00:00
|
|
|
{
|
2013-06-30 07:55:15 +00:00
|
|
|
auto msg = make_unique<BtCancelMessage>(index, begin, length);
|
|
|
|
setCommonProperty(msg.get());
|
|
|
|
return msg;
|
2006-12-24 06:25:21 +00:00
|
|
|
}
|
|
|
|
|
2013-06-30 07:55:15 +00:00
|
|
|
std::unique_ptr<BtPieceMessage>
|
2010-06-12 08:23:49 +00:00
|
|
|
DefaultBtMessageFactory::createPieceMessage
|
2011-12-07 15:51:20 +00:00
|
|
|
(size_t index, int32_t begin, int32_t length)
|
2006-12-24 06:25:21 +00:00
|
|
|
{
|
2013-06-30 07:55:15 +00:00
|
|
|
auto msg = make_unique<BtPieceMessage>(index, begin, length);
|
2010-06-21 13:51:56 +00:00
|
|
|
msg->setDownloadContext(downloadContext_);
|
2013-06-30 07:55:15 +00:00
|
|
|
setCommonProperty(msg.get());
|
|
|
|
return msg;
|
2006-12-24 06:25:21 +00:00
|
|
|
}
|
|
|
|
|
2013-06-30 07:55:15 +00:00
|
|
|
std::unique_ptr<BtHaveMessage>
|
2008-03-09 12:24:01 +00:00
|
|
|
DefaultBtMessageFactory::createHaveMessage(size_t index)
|
2006-12-24 06:25:21 +00:00
|
|
|
{
|
2013-06-30 07:55:15 +00:00
|
|
|
auto msg = make_unique<BtHaveMessage>(index);
|
|
|
|
setCommonProperty(msg.get());
|
|
|
|
return msg;
|
2006-12-24 06:25:21 +00:00
|
|
|
}
|
|
|
|
|
2013-06-30 07:55:15 +00:00
|
|
|
std::unique_ptr<BtChokeMessage>
|
2006-12-24 06:25:21 +00:00
|
|
|
DefaultBtMessageFactory::createChokeMessage()
|
|
|
|
{
|
2013-06-30 07:55:15 +00:00
|
|
|
auto msg = make_unique<BtChokeMessage>();
|
|
|
|
setCommonProperty(msg.get());
|
|
|
|
return msg;
|
2006-12-24 06:25:21 +00:00
|
|
|
}
|
|
|
|
|
2013-06-30 07:55:15 +00:00
|
|
|
std::unique_ptr<BtUnchokeMessage>
|
2006-12-24 06:25:21 +00:00
|
|
|
DefaultBtMessageFactory::createUnchokeMessage()
|
|
|
|
{
|
2013-06-30 07:55:15 +00:00
|
|
|
auto msg = make_unique<BtUnchokeMessage>();
|
|
|
|
setCommonProperty(msg.get());
|
|
|
|
return msg;
|
2006-12-24 06:25:21 +00:00
|
|
|
}
|
2012-09-27 14:40:25 +00:00
|
|
|
|
2013-06-30 07:55:15 +00:00
|
|
|
std::unique_ptr<BtInterestedMessage>
|
2006-12-24 06:25:21 +00:00
|
|
|
DefaultBtMessageFactory::createInterestedMessage()
|
|
|
|
{
|
2013-06-30 07:55:15 +00:00
|
|
|
auto msg = make_unique<BtInterestedMessage>();
|
|
|
|
setCommonProperty(msg.get());
|
|
|
|
return msg;
|
2006-12-24 06:25:21 +00:00
|
|
|
}
|
|
|
|
|
2013-06-30 07:55:15 +00:00
|
|
|
std::unique_ptr<BtNotInterestedMessage>
|
2006-12-24 06:25:21 +00:00
|
|
|
DefaultBtMessageFactory::createNotInterestedMessage()
|
|
|
|
{
|
2013-06-30 07:55:15 +00:00
|
|
|
auto msg = make_unique<BtNotInterestedMessage>();
|
|
|
|
setCommonProperty(msg.get());
|
|
|
|
return msg;
|
2006-12-24 06:25:21 +00:00
|
|
|
}
|
|
|
|
|
2013-06-30 07:55:15 +00:00
|
|
|
std::unique_ptr<BtBitfieldMessage>
|
2006-12-24 06:25:21 +00:00
|
|
|
DefaultBtMessageFactory::createBitfieldMessage()
|
|
|
|
{
|
2013-06-30 07:55:15 +00:00
|
|
|
auto msg = make_unique<BtBitfieldMessage>
|
|
|
|
(pieceStorage_->getBitfield(),
|
|
|
|
pieceStorage_->getBitfieldLength());
|
|
|
|
setCommonProperty(msg.get());
|
|
|
|
return msg;
|
2006-12-24 06:25:21 +00:00
|
|
|
}
|
|
|
|
|
2013-06-30 07:55:15 +00:00
|
|
|
std::unique_ptr<BtKeepAliveMessage>
|
2006-12-24 06:25:21 +00:00
|
|
|
DefaultBtMessageFactory::createKeepAliveMessage()
|
|
|
|
{
|
2013-06-30 07:55:15 +00:00
|
|
|
auto msg = make_unique<BtKeepAliveMessage>();
|
|
|
|
setCommonProperty(msg.get());
|
|
|
|
return msg;
|
2012-09-27 14:40:25 +00:00
|
|
|
}
|
2006-12-24 06:25:21 +00:00
|
|
|
|
2013-06-30 07:55:15 +00:00
|
|
|
std::unique_ptr<BtHaveAllMessage>
|
2006-12-24 06:25:21 +00:00
|
|
|
DefaultBtMessageFactory::createHaveAllMessage()
|
|
|
|
{
|
2013-06-30 07:55:15 +00:00
|
|
|
auto msg = make_unique<BtHaveAllMessage>();
|
|
|
|
setCommonProperty(msg.get());
|
|
|
|
return msg;
|
2006-12-24 06:25:21 +00:00
|
|
|
}
|
|
|
|
|
2013-06-30 07:55:15 +00:00
|
|
|
std::unique_ptr<BtHaveNoneMessage>
|
2006-12-24 06:25:21 +00:00
|
|
|
DefaultBtMessageFactory::createHaveNoneMessage()
|
|
|
|
{
|
2013-06-30 07:55:15 +00:00
|
|
|
auto msg = make_unique<BtHaveNoneMessage>();
|
|
|
|
setCommonProperty(msg.get());
|
|
|
|
return msg;
|
2006-12-24 06:25:21 +00:00
|
|
|
}
|
|
|
|
|
2013-06-30 07:55:15 +00:00
|
|
|
std::unique_ptr<BtRejectMessage>
|
2010-06-12 08:23:49 +00:00
|
|
|
DefaultBtMessageFactory::createRejectMessage
|
2011-12-07 15:51:20 +00:00
|
|
|
(size_t index, int32_t begin, int32_t length)
|
2006-12-24 06:25:21 +00:00
|
|
|
{
|
2013-06-30 07:55:15 +00:00
|
|
|
auto msg = make_unique<BtRejectMessage>(index, begin, length);
|
|
|
|
setCommonProperty(msg.get());
|
|
|
|
return msg;
|
2006-12-24 06:25:21 +00:00
|
|
|
}
|
|
|
|
|
2013-06-30 07:55:15 +00:00
|
|
|
std::unique_ptr<BtAllowedFastMessage>
|
2008-03-09 12:24:01 +00:00
|
|
|
DefaultBtMessageFactory::createAllowedFastMessage(size_t index)
|
2006-12-24 06:25:21 +00:00
|
|
|
{
|
2013-06-30 07:55:15 +00:00
|
|
|
auto msg = make_unique<BtAllowedFastMessage>(index);
|
|
|
|
setCommonProperty(msg.get());
|
|
|
|
return msg;
|
2006-12-24 06:25:21 +00:00
|
|
|
}
|
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
|
|
|
|
2013-06-30 07:55:15 +00:00
|
|
|
std::unique_ptr<BtPortMessage>
|
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::createPortMessage(uint16_t port)
|
|
|
|
{
|
2013-06-30 07:55:15 +00:00
|
|
|
auto msg = make_unique<BtPortMessage>(port);
|
|
|
|
setCommonProperty(msg.get());
|
|
|
|
return msg;
|
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
|
|
|
}
|
|
|
|
|
2013-06-30 07:55:15 +00:00
|
|
|
std::unique_ptr<BtExtendedMessage>
|
2010-06-12 08:23:49 +00:00
|
|
|
DefaultBtMessageFactory::createBtExtendedMessage
|
2013-06-30 07:55:15 +00:00
|
|
|
(const std::shared_ptr<ExtensionMessage>& exmsg)
|
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
|
|
|
{
|
2013-06-30 07:55:15 +00:00
|
|
|
auto msg = make_unique<BtExtendedMessage>(exmsg);
|
|
|
|
setCommonProperty(msg.get());
|
|
|
|
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
|
|
|
|
2010-11-12 12:48:48 +00:00
|
|
|
void DefaultBtMessageFactory::setTaskQueue(DHTTaskQueue* taskQueue)
|
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
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
taskQueue_ = taskQueue;
|
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
|
|
|
}
|
|
|
|
|
2010-11-12 12:48:48 +00:00
|
|
|
void DefaultBtMessageFactory::setTaskFactory(DHTTaskFactory* taskFactory)
|
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
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
taskFactory_ = taskFactory;
|
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
|
|
|
}
|
2008-02-08 15:53:45 +00:00
|
|
|
|
2013-06-21 16:10:38 +00:00
|
|
|
void DefaultBtMessageFactory::setPeer(const std::shared_ptr<Peer>& peer)
|
2008-02-08 15:53:45 +00:00
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
peer_ = peer;
|
2008-02-08 15:53:45 +00:00
|
|
|
}
|
|
|
|
|
2009-06-28 10:37:15 +00:00
|
|
|
void DefaultBtMessageFactory::setDownloadContext
|
2013-06-22 15:01:40 +00:00
|
|
|
(DownloadContext* downloadContext)
|
2008-02-08 15:53:45 +00:00
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
downloadContext_ = downloadContext;
|
2008-11-03 06:49:02 +00:00
|
|
|
}
|
|
|
|
|
2013-06-22 15:01:40 +00:00
|
|
|
void DefaultBtMessageFactory::setPieceStorage(PieceStorage* pieceStorage)
|
2008-11-03 06:49:02 +00:00
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
pieceStorage_ = pieceStorage;
|
2008-11-03 06:49:02 +00:00
|
|
|
}
|
|
|
|
|
2013-06-22 15:01:40 +00:00
|
|
|
void DefaultBtMessageFactory::setPeerStorage(PeerStorage* peerStorage)
|
2008-11-03 06:49:02 +00:00
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
peerStorage_ = peerStorage;
|
2008-02-08 15:53:45 +00:00
|
|
|
}
|
|
|
|
|
2010-06-12 08:23:49 +00:00
|
|
|
void DefaultBtMessageFactory::setBtMessageDispatcher
|
2010-11-12 12:48:48 +00:00
|
|
|
(BtMessageDispatcher* dispatcher)
|
2008-02-08 15:53:45 +00:00
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
dispatcher_ = dispatcher;
|
2008-02-08 15:53:45 +00:00
|
|
|
}
|
2008-02-10 15:57:00 +00:00
|
|
|
|
2008-11-03 06:49:02 +00:00
|
|
|
void DefaultBtMessageFactory::setExtensionMessageFactory
|
2013-06-21 16:10:38 +00:00
|
|
|
(const std::shared_ptr<ExtensionMessageFactory>& factory)
|
2008-11-03 06:49:02 +00:00
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
extensionMessageFactory_ = factory;
|
2008-11-03 06:49:02 +00:00
|
|
|
}
|
|
|
|
|
2010-11-12 12:48:48 +00:00
|
|
|
void DefaultBtMessageFactory::setLocalNode(DHTNode* localNode)
|
2008-02-10 15:57:00 +00:00
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
localNode_ = localNode;
|
2008-02-10 15:57:00 +00:00
|
|
|
}
|
|
|
|
|
2010-11-12 12:48:48 +00:00
|
|
|
void DefaultBtMessageFactory::setRoutingTable(DHTRoutingTable* routingTable)
|
2008-02-10 15:57:00 +00:00
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
routingTable_ = routingTable;
|
2008-02-10 15:57:00 +00:00
|
|
|
}
|
|
|
|
|
2010-11-12 12:48:48 +00:00
|
|
|
void DefaultBtMessageFactory::setBtRequestFactory(BtRequestFactory* factory)
|
2008-02-08 15:53:45 +00:00
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
requestFactory_ = factory;
|
2008-02-08 15:53:45 +00:00
|
|
|
}
|
|
|
|
|
2010-11-12 12:48:48 +00:00
|
|
|
void DefaultBtMessageFactory::setPeerConnection(PeerConnection* connection)
|
2008-02-08 15:53:45 +00:00
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
peerConnection_ = connection;
|
2008-02-08 15:53:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace aria2
|