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"
|
|
|
|
#include "PeerMessageUtil.h"
|
|
|
|
#include "BtKeepAliveMessage.h"
|
|
|
|
#include "BtChokeMessage.h"
|
|
|
|
#include "BtUnchokeMessage.h"
|
|
|
|
#include "BtInterestedMessage.h"
|
|
|
|
#include "BtNotInterestedMessage.h"
|
|
|
|
#include "BtHaveMessage.h"
|
|
|
|
#include "BtHaveMessageValidator.h"
|
|
|
|
#include "BtBitfieldMessage.h"
|
|
|
|
#include "BtBitfieldMessageValidator.h"
|
|
|
|
#include "BtRequestMessage.h"
|
|
|
|
#include "BtRequestMessageValidator.h"
|
|
|
|
#include "BtCancelMessage.h"
|
|
|
|
#include "BtCancelMessageValidator.h"
|
|
|
|
#include "BtPieceMessage.h"
|
|
|
|
#include "BtPieceMessageValidator.h"
|
|
|
|
#include "BtPortMessage.h"
|
|
|
|
#include "BtHaveAllMessage.h"
|
|
|
|
#include "BtHaveNoneMessage.h"
|
|
|
|
#include "BtRejectMessage.h"
|
|
|
|
#include "BtRejectMessageValidator.h"
|
|
|
|
#include "BtSuggestPieceMessage.h"
|
|
|
|
#include "BtSuggestPieceMessageValidator.h"
|
|
|
|
#include "BtAllowedFastMessage.h"
|
|
|
|
#include "BtAllowedFastMessageValidator.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"
|
|
|
|
#include "BtRegistry.h"
|
|
|
|
#include "BtContext.h"
|
|
|
|
#include "PieceStorage.h"
|
|
|
|
|
|
|
|
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),
|
|
|
|
btContext(0),
|
|
|
|
pieceStorage(0),
|
|
|
|
peer(0),
|
|
|
|
_dhtEnabled(false)
|
|
|
|
{}
|
|
|
|
|
|
|
|
DefaultBtMessageFactory::~DefaultBtMessageFactory() {}
|
|
|
|
|
2006-12-24 06:25:21 +00:00
|
|
|
BtMessageHandle
|
2007-01-25 16:47:29 +00:00
|
|
|
DefaultBtMessageFactory::createBtMessage(const unsigned char* data, int32_t dataLength)
|
2006-12-24 06:25:21 +00:00
|
|
|
{
|
|
|
|
AbstractBtMessageHandle msg(0);
|
|
|
|
if(dataLength == 0) {
|
|
|
|
// keep-alive
|
|
|
|
msg = new BtKeepAliveMessage();
|
|
|
|
} else {
|
2007-01-25 16:47:29 +00:00
|
|
|
int8_t id = PeerMessageUtil::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:
|
|
|
|
msg = BtInterestedMessage::create(data, dataLength);
|
|
|
|
break;
|
|
|
|
case BtNotInterestedMessage::ID:
|
|
|
|
msg = BtNotInterestedMessage::create(data, dataLength);
|
|
|
|
break;
|
|
|
|
case BtHaveMessage::ID:
|
|
|
|
msg = BtHaveMessage::create(data, dataLength);
|
|
|
|
msg->setBtMessageValidator(new BtHaveMessageValidator((BtHaveMessage*)msg.get(),
|
|
|
|
btContext->getNumPieces()));
|
|
|
|
break;
|
|
|
|
case BtBitfieldMessage::ID:
|
|
|
|
msg = BtBitfieldMessage::create(data, dataLength);
|
|
|
|
msg->setBtMessageValidator(new BtBitfieldMessageValidator((BtBitfieldMessage*)msg.get(),
|
|
|
|
btContext->getNumPieces()));
|
|
|
|
break;
|
|
|
|
case BtRequestMessage::ID: {
|
|
|
|
BtRequestMessageHandle temp = BtRequestMessage::create(data, dataLength);
|
|
|
|
BtMessageValidatorHandle validator =
|
|
|
|
new BtRequestMessageValidator(temp.get(),
|
|
|
|
btContext->getNumPieces(),
|
|
|
|
pieceStorage->getPieceLength(temp->getIndex()));
|
|
|
|
temp->setBtMessageValidator(validator);
|
|
|
|
msg = temp;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case BtCancelMessage::ID: {
|
|
|
|
BtCancelMessageHandle temp = BtCancelMessage::create(data, dataLength);
|
|
|
|
BtMessageValidatorHandle validator =
|
|
|
|
new BtCancelMessageValidator(temp.get(),
|
|
|
|
btContext->getNumPieces(),
|
|
|
|
pieceStorage->getPieceLength(temp->getIndex()));
|
|
|
|
temp->setBtMessageValidator(validator);
|
|
|
|
msg = temp;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case BtPieceMessage::ID: {
|
|
|
|
BtPieceMessageHandle temp = BtPieceMessage::create(data, dataLength);
|
|
|
|
BtMessageValidatorHandle validator =
|
|
|
|
new BtPieceMessageValidator(temp.get(),
|
|
|
|
btContext->getNumPieces(),
|
|
|
|
pieceStorage->getPieceLength(temp->getIndex()));
|
|
|
|
temp->setBtMessageValidator(validator);
|
|
|
|
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);
|
|
|
|
BtMessageValidatorHandle validator =
|
|
|
|
new BtRejectMessageValidator(temp.get(),
|
|
|
|
btContext->getNumPieces(),
|
|
|
|
pieceStorage->getPieceLength(temp->getIndex()));
|
|
|
|
temp->setBtMessageValidator(validator);
|
|
|
|
msg = temp;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case BtSuggestPieceMessage::ID: {
|
|
|
|
BtSuggestPieceMessageHandle temp = BtSuggestPieceMessage::create(data, dataLength);
|
|
|
|
BtMessageValidatorHandle validator =
|
|
|
|
new BtSuggestPieceMessageValidator(temp.get(),
|
|
|
|
btContext->getNumPieces());
|
|
|
|
temp->setBtMessageValidator(validator);
|
|
|
|
msg = temp;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case BtAllowedFastMessage::ID: {
|
|
|
|
BtAllowedFastMessageHandle temp = BtAllowedFastMessage::create(data, dataLength);
|
|
|
|
BtMessageValidatorHandle validator =
|
|
|
|
new BtAllowedFastMessageValidator(temp.get(),
|
|
|
|
btContext->getNumPieces());
|
|
|
|
temp->setBtMessageValidator(validator);
|
|
|
|
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);
|
|
|
|
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()) {
|
|
|
|
msg = BtExtendedMessage::create(btContext, peer, (const char*)data, dataLength);
|
|
|
|
} else {
|
|
|
|
throw new DlAbortEx("Received extended message from peer during a session with extended messaging disabled.");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2006-12-24 06:25:21 +00:00
|
|
|
default:
|
2007-01-25 16:47:29 +00:00
|
|
|
throw new DlAbortEx("Invalid message ID. id=%d", id);
|
2006-12-24 06:25:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
setCommonProperty(msg);
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DefaultBtMessageFactory::setCommonProperty(const AbstractBtMessageHandle& msg) {
|
|
|
|
msg->setCuid(cuid);
|
|
|
|
msg->setPeer(peer);
|
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->setBtContext(btContext);
|
|
|
|
msg->setBtMessageDispatcher(dispatcher);
|
|
|
|
msg->setBtRequestFactory(requestFactory);
|
|
|
|
msg->setBtMessageFactory(this);
|
|
|
|
msg->setPeerConnection(peerConnection);
|
2006-12-24 06:25:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BtMessageHandle
|
2007-01-25 16:47:29 +00:00
|
|
|
DefaultBtMessageFactory::createHandshakeMessage(const unsigned char* data, int32_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);
|
2006-12-24 06:25:21 +00:00
|
|
|
BtMessageValidatorHandle validator =
|
|
|
|
new BtHandshakeMessageValidator(msg.get(),
|
|
|
|
btContext->getInfoHash());
|
|
|
|
msg->setBtMessageValidator(validator);
|
|
|
|
setCommonProperty(msg);
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
BtMessageHandle
|
|
|
|
DefaultBtMessageFactory::createHandshakeMessage(const unsigned char* infoHash,
|
|
|
|
const unsigned char* peerId)
|
|
|
|
{
|
2008-02-08 15:53:45 +00:00
|
|
|
SharedHandle<BtHandshakeMessage> msg = new BtHandshakeMessage(infoHash, peerId);
|
2006-12-24 06:25:21 +00:00
|
|
|
BtMessageValidatorHandle validator =
|
|
|
|
new BtHandshakeMessageValidator(msg.get(),
|
|
|
|
btContext->getInfoHash());
|
|
|
|
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
|
2006-12-24 15:55:59 +00:00
|
|
|
DefaultBtMessageFactory::createRequestMessage(const PieceHandle& piece, int32_t blockIndex)
|
2006-12-24 06:25:21 +00:00
|
|
|
{
|
|
|
|
BtRequestMessageHandle msg =
|
|
|
|
new BtRequestMessage(piece->getIndex(),
|
|
|
|
blockIndex*piece->getBlockLength(),
|
|
|
|
piece->getBlockLength(blockIndex),
|
|
|
|
blockIndex);
|
|
|
|
BtMessageValidatorHandle validator =
|
|
|
|
new BtRequestMessageValidator(msg.get(),
|
|
|
|
btContext->getNumPieces(),
|
|
|
|
pieceStorage->getPieceLength(msg->getIndex()));
|
|
|
|
msg->setBtMessageValidator(validator);
|
|
|
|
setCommonProperty(msg);
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
BtMessageHandle
|
2007-01-25 16:47:29 +00:00
|
|
|
DefaultBtMessageFactory::createCancelMessage(int32_t index, int32_t begin, int32_t length)
|
2006-12-24 06:25:21 +00:00
|
|
|
{
|
|
|
|
BtCancelMessageHandle msg = new BtCancelMessage(index, begin, length);
|
|
|
|
BtMessageValidatorHandle validator =
|
|
|
|
new BtCancelMessageValidator(msg.get(),
|
|
|
|
btContext->getNumPieces(),
|
|
|
|
pieceStorage->getPieceLength(index));
|
|
|
|
msg->setBtMessageValidator(validator);
|
|
|
|
setCommonProperty(msg);
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
BtMessageHandle
|
2007-01-25 16:47:29 +00:00
|
|
|
DefaultBtMessageFactory::createPieceMessage(int32_t index, int32_t begin, int32_t length)
|
2006-12-24 06:25:21 +00:00
|
|
|
{
|
|
|
|
BtPieceMessageHandle msg = new BtPieceMessage(index, begin, length);
|
|
|
|
BtMessageValidatorHandle validator =
|
|
|
|
new BtPieceMessageValidator(msg.get(),
|
|
|
|
btContext->getNumPieces(),
|
|
|
|
pieceStorage->getPieceLength(index));
|
|
|
|
msg->setBtMessageValidator(validator);
|
|
|
|
setCommonProperty(msg);
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
BtMessageHandle
|
2006-12-24 15:55:59 +00:00
|
|
|
DefaultBtMessageFactory::createHaveMessage(int32_t index)
|
2006-12-24 06:25:21 +00:00
|
|
|
{
|
|
|
|
BtHaveMessageHandle msg = new BtHaveMessage(index);
|
|
|
|
msg->setBtMessageValidator(new BtHaveMessageValidator(msg.get(),
|
|
|
|
btContext->getNumPieces()));
|
|
|
|
setCommonProperty(msg);
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
BtMessageHandle
|
|
|
|
DefaultBtMessageFactory::createChokeMessage()
|
|
|
|
{
|
|
|
|
BtChokeMessageHandle msg = new BtChokeMessage();
|
|
|
|
setCommonProperty(msg);
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
BtMessageHandle
|
|
|
|
DefaultBtMessageFactory::createUnchokeMessage()
|
|
|
|
{
|
|
|
|
BtUnchokeMessageHandle msg = new BtUnchokeMessage();
|
|
|
|
setCommonProperty(msg);
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
BtMessageHandle
|
|
|
|
DefaultBtMessageFactory::createInterestedMessage()
|
|
|
|
{
|
|
|
|
BtInterestedMessageHandle msg = new BtInterestedMessage();
|
|
|
|
setCommonProperty(msg);
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
BtMessageHandle
|
|
|
|
DefaultBtMessageFactory::createNotInterestedMessage()
|
|
|
|
{
|
|
|
|
BtNotInterestedMessageHandle msg = new BtNotInterestedMessage();
|
|
|
|
setCommonProperty(msg);
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
BtMessageHandle
|
|
|
|
DefaultBtMessageFactory::createBitfieldMessage()
|
|
|
|
{
|
|
|
|
BtBitfieldMessageHandle msg =
|
|
|
|
new BtBitfieldMessage(pieceStorage->getBitfield(),
|
|
|
|
pieceStorage->getBitfieldLength());
|
|
|
|
msg->setBtMessageValidator(new BtBitfieldMessageValidator(msg.get(),
|
|
|
|
btContext->getNumPieces()));
|
|
|
|
setCommonProperty(msg);
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
BtMessageHandle
|
|
|
|
DefaultBtMessageFactory::createKeepAliveMessage()
|
|
|
|
{
|
|
|
|
BtKeepAliveMessageHandle msg = new BtKeepAliveMessage();
|
|
|
|
setCommonProperty(msg);
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
BtMessageHandle
|
|
|
|
DefaultBtMessageFactory::createHaveAllMessage()
|
|
|
|
{
|
|
|
|
BtHaveAllMessageHandle msg = new BtHaveAllMessage();
|
|
|
|
setCommonProperty(msg);
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
BtMessageHandle
|
|
|
|
DefaultBtMessageFactory::createHaveNoneMessage()
|
|
|
|
{
|
|
|
|
BtHaveNoneMessageHandle msg = new BtHaveNoneMessage();
|
|
|
|
setCommonProperty(msg);
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
BtMessageHandle
|
2007-01-25 16:47:29 +00:00
|
|
|
DefaultBtMessageFactory::createRejectMessage(int32_t index, int32_t begin, int32_t length)
|
2006-12-24 06:25:21 +00:00
|
|
|
{
|
|
|
|
BtRejectMessageHandle msg = new BtRejectMessage(index, begin, length);
|
|
|
|
BtMessageValidatorHandle validator =
|
|
|
|
new BtRejectMessageValidator(msg.get(),
|
|
|
|
btContext->getNumPieces(),
|
|
|
|
pieceStorage->getPieceLength(index));
|
|
|
|
msg->setBtMessageValidator(validator);
|
|
|
|
setCommonProperty(msg);
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
BtMessageHandle
|
2006-12-24 15:55:59 +00:00
|
|
|
DefaultBtMessageFactory::createAllowedFastMessage(int32_t index)
|
2006-12-24 06:25:21 +00:00
|
|
|
{
|
|
|
|
BtAllowedFastMessageHandle msg = new BtAllowedFastMessage(index);
|
|
|
|
BtMessageValidatorHandle validator =
|
|
|
|
new BtAllowedFastMessageValidator(msg.get(),
|
|
|
|
btContext->getNumPieces());
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
SharedHandle<BtPortMessage> msg = new BtPortMessage(port);
|
|
|
|
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
|
|
|
{
|
|
|
|
BtExtendedMessageHandle m = new BtExtendedMessage(msg);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DefaultBtMessageFactory::setBtContext(const SharedHandle<BtContext>& btContext)
|
|
|
|
{
|
|
|
|
this->btContext = btContext;
|
|
|
|
this->pieceStorage = PIECE_STORAGE(btContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DefaultBtMessageFactory::setBtMessageDispatcher(const WeakHandle<BtMessageDispatcher>& dispatcher)
|
|
|
|
{
|
|
|
|
this->dispatcher = dispatcher;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DefaultBtMessageFactory::setBtRequestFactory(const WeakHandle<BtRequestFactory>& factory)
|
|
|
|
{
|
|
|
|
this->requestFactory = factory;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DefaultBtMessageFactory::setPeerConnection(const WeakHandle<PeerConnection>& connection)
|
|
|
|
{
|
|
|
|
this->peerConnection = connection;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace aria2
|