Commit Graph

29 Commits (e39dd961715b78843dfefd7bd83df237edd199d0)

Author SHA1 Message Date
Tatsuhiro Tsujikawa 93e5dbed32 2010-11-12 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Removed SharedHandle::isNull(). Instead we added operator* and
	operator unspecified_bool_type. Removed use of WeakHandle and
	replaced with raw pointer.
2010-11-12 12:48:48 +00:00
Tatsuhiro Tsujikawa bc98e39fe5 2010-11-11 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
To match the behavior of friend operator functions in
	SharedHandle.h to std::tr1::shared_ptr, we intentionally broke
	these functions and modified code so that our code does not depend
	on old behavior.
	* src/AbstractCommand.cc
	* src/DHTAbstractNodeLookupTask.h
	* src/DHTBucket.cc
	* src/DHTMessageReceiver.cc
	* src/DHTNodeLookupEntry.cc
	* src/DHTRoutingTable.cc
	* src/DefaultBtRequestFactory.cc
	* src/DefaultPeerStorage.cc
	* src/DefaultPieceStorage.cc
	* src/DownloadContext.cc
	* src/EpollEventPoll.cc
	* src/Event.h
	* src/HttpConnection.cc
	* src/KqueueEventPoll.cc
	* src/MultiDiskAdaptor.cc
	* src/PeerAbstractCommand.cc
	* src/PieceStatMan.cc
	* src/PollEventPoll.cc
	* src/PortEventPoll.cc
	* src/SegmentMan.cc
	* src/SelectEventPoll.cc
	* src/SelectEventPoll.h
	* src/ServerStatMan.cc
	* src/SharedHandle.h
	* src/UnknownLengthPieceStorage.cc
	* src/a2functional.h
	* src/option_processing.cc
	* src/version_usage.cc
	* test/BNodeTest.cc
	* test/DHTAnnouncePeerMessageTest.cc
	* test/DHTBucketTest.cc
	* test/DHTFindNodeMessageTest.cc
	* test/DHTGetPeersMessageTest.cc
	* test/DHTIDCloserTest.cc
	* test/DHTMessageFactoryImplTest.cc
	* test/DHTPingMessageTest.cc
	* test/DefaultBtRequestFactoryTest.cc
	* test/DefaultPeerStorageTest.cc
	* test/SequentialPickerTest.cc
	* test/SingletonHolderTest.cc
2010-11-11 07:33:43 +00:00
Tatsuhiro Tsujikawa 785a27f6e8 2010-08-04 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Add only gracefully disconnected peer to ut_pex dropped list.  Add
	incoming dropped list to PeerStorage.
	* src/DefaultBtInteractive.cc
	* src/DefaultPeerStorage.cc
	* src/InitiatorMSEHandshakeCommand.cc
	* src/Peer.cc
	* src/Peer.h
	* src/PeerConnection.cc
	* src/PeerConnection.h
	* src/PeerInteractionCommand.cc
	* src/PeerReceiveHandshakeCommand.cc
	* src/ReceiverMSEHandshakeCommand.cc
	* src/UTPexExtensionMessage.cc
	* test/DefaultPeerStorageTest.cc
	* test/UTPexExtensionMessageTest.cc
2010-08-04 15:00:38 +00:00
Tatsuhiro Tsujikawa 2176b68116 2010-08-04 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Rewritten ut_pex peer selection.
	* src/DefaultBtInteractive.cc
	* src/DefaultPeerStorage.cc
	* src/DefaultPeerStorage.h
	* src/PeerStorage.h
	* src/UTPexExtensionMessage.h
	* test/DefaultPeerStorageTest.cc
	* test/MockPeerStorage.h
	* test/UTPexExtensionMessageTest.cc
2010-08-04 12:25:46 +00:00
Tatsuhiro Tsujikawa 55258bc019 2010-06-13 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Renamed member variables
	* src/ActivePeerConnectionCommand.cc
	* src/BtLeecherStateChoke.cc
	* src/BtPieceMessage.cc
	* src/BtPortMessage.cc
	* src/BtSeederStateChoke.cc
	* src/DHTGetPeersReplyMessage.cc
	* src/DefaultBtInteractive.cc
	* src/DefaultPeerStorage.cc
	* src/HandshakeExtensionMessage.cc
	* src/LpdReceiveMessageCommand.cc
	* src/Peer.cc
	* src/Peer.h
	* src/PeerAbstractCommand.cc
	* src/PeerInitiateConnectionCommand.cc
	* src/PeerListenCommand.cc
	* src/SimpleBtMessage.cc
	* src/UTPexExtensionMessage.cc
	* src/XmlRpcMethodImpl.cc
	* test/DHTAnnouncePeerMessageTest.cc
	* test/DHTGetPeersMessageTest.cc
	* test/DHTGetPeersReplyMessageTest.cc
	* test/DHTMessageFactoryImplTest.cc
	* test/DHTPeerAnnounceEntryTest.cc
	* test/DHTPeerAnnounceStorageTest.cc
	* test/DefaultPeerStorageTest.cc
	* test/HandshakeExtensionMessageTest.cc
	* test/LpdMessageReceiverTest.cc
	* test/PeerListProcessorTest.cc
	* test/PeerTest.cc
	* test/UTPexExtensionMessageTest.cc
2010-06-13 01:53:49 +00:00
Tatsuhiro Tsujikawa 4f7746a89c 2010-06-12 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Renamed member variables. Removed unused member variable.
	* src/DefaultPeerStorage.cc
	* src/DefaultPeerStorage.h
	* src/RequestGroup.cc
	* test/DefaultPeerStorageTest.cc
2010-06-12 08:50:50 +00:00
Tatsuhiro Tsujikawa c342bde962 2010-02-28 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Use vector instead of deque for containers which is used for
	mostly read-only purpose.
2010-02-28 12:30:11 +00:00
Tatsuhiro Tsujikawa 4db349c1f3 2010-01-06 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Untabify. Fixed one line in copyright which is longer than 80
	columns.
	* src
	* test
2010-01-05 16:01:46 +00:00
Tatsuhiro Tsujikawa e976b23728 2009-10-23 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Renamed Util.{cc,h} as util.{cc,h}
	* src/Util.cc
	* src/Util.h
	* src/util.cc
	* src/util.h
2009-10-22 15:35:33 +00:00
Tatsuhiro Tsujikawa 5699b67526 2009-06-28 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Rewritten DownloadContext and removed SingleFileDownloadContext
	and BtContext and its derived classes. BitTorrent specific
	attributes are now set by DownloadContext::setAttribute() with key
	bittorrent::BITTORRENT.
	* src/AbstractBtMessage.cc
	* src/AbstractBtMessage.h
	* src/AbstractCommand.cc
	* src/AbstractCommand.h
	* src/AbstractProxyRequestCommand.cc
	* src/AbstractProxyResponseCommand.cc
	* src/ActivePeerConnectionCommand.cc
	* src/ActivePeerConnectionCommand.h
	* src/AnnounceList.cc
	* src/BtCheckIntegrityEntry.cc
	* src/BtConstants.h
	* src/BtContext.h: Removed
	* src/BtDependency.cc
	* src/BtExtendedMessage.cc
	* src/BtPieceMessage.cc
	* src/BtPieceMessage.h
	* src/BtPostDownloadHandler.cc
	* src/BtRegistry.cc
	* src/BtRegistry.h
	* src/BtSetup.cc
	* src/CheckIntegrityCommand.cc
	* src/CheckIntegrityEntry.cc
	* src/ChecksumCheckIntegrityEntry.cc
	* src/ConsoleStatCalc.cc
	* src/ContentTypeRequestGroupCriteria.cc
	* src/DHTGetPeersCommand.cc
	* src/DHTGetPeersCommand.h
	* src/DHTPeerLookupTask.cc
	* src/DHTPeerLookupTask.h
	* src/DHTTaskFactory.h
	* src/DHTTaskFactoryImpl.cc
	* src/DHTTaskFactoryImpl.h
	* src/DefaultBtAnnounce.cc
	* src/DefaultBtAnnounce.h
	* src/DefaultBtContext.cc: Removed
	* src/DefaultBtContext.h: Removed
	* src/DefaultBtInteractive.cc
	* src/DefaultBtInteractive.h
	* src/DefaultBtMessageDispatcher.cc
	* src/DefaultBtMessageDispatcher.h
	* src/DefaultBtMessageFactory.cc
	* src/DefaultBtMessageFactory.h
	* src/DefaultBtMessageReceiver.cc
	* src/DefaultBtMessageReceiver.h
	* src/DefaultBtProgressInfoFile.cc
	* src/DefaultBtRequestFactory.cc
	* src/DefaultBtRequestFactory.h
	* src/DefaultExtensionMessageFactory.cc
	* src/DefaultExtensionMessageFactory.h
	* src/DefaultPeerStorage.cc
	* src/DefaultPeerStorage.h
	* src/DefaultPieceStorage.cc
	* src/DefaultSegmentManFactory.cc
	* src/DiskAdaptor.cc
	* src/DiskAdaptor.h
	* src/DownloadContext.cc
	* src/DownloadContext.h
	* src/DownloadEngine.cc
	* src/DownloadEngineFactory.cc
	* src/DownloadHandler.cc
	* src/DownloadResult.h
	* src/FileAllocationCommand.cc
	* src/FileAllocationDispatcherCommand.cc
	* src/FileAllocationEntry.cc
	* src/FileEntry.h
	* src/FillRequestGroupCommand.cc
	* src/FtpDownloadCommand.cc
	* src/FtpFinishDownloadCommand.cc
	* src/FtpInitiateConnectionCommand.cc
	* src/FtpNegotiationCommand.cc
	* src/FtpTunnelRequestCommand.cc
	* src/FtpTunnelResponseCommand.cc
	* src/HandshakeExtensionMessage.cc
	* src/HandshakeExtensionMessage.h
	* src/HaveEraseCommand.cc
	* src/HttpDownloadCommand.cc
	* src/HttpInitiateConnectionCommand.cc
	* src/HttpProxyRequestCommand.cc
	* src/HttpProxyResponseCommand.cc
	* src/HttpRequest.cc
	* src/HttpRequest.h
	* src/HttpRequestCommand.cc
	* src/HttpResponseCommand.cc
	* src/HttpServerBodyCommand.cc
	* src/HttpServerCommand.cc
	* src/HttpSkipResponseCommand.cc
	* src/InitiateConnectionCommandFactory.cc
	* src/InitiatorMSEHandshakeCommand.cc
	* src/InitiatorMSEHandshakeCommand.h
	* src/IteratableChecksumValidator.cc
	* src/IteratableChecksumValidator.h
	* src/IteratableChunkChecksumValidator.cc
	* src/MSEHandshake.cc
	* src/MSEHandshake.h
	* src/Makefile.am
	* src/Makefile.in
	* src/Metalink2RequestGroup.cc
	* src/MetalinkPostDownloadHandler.cc
	* src/MultiDiskAdaptor.cc
	* src/MultiDiskAdaptor.h
	* src/MultiFileAllocationIterator.cc
	* src/MultiUrlRequestInfo.cc
	* src/PeerChokeCommand.cc
	* src/PeerChokeCommand.h
	* src/PeerInitiateConnectionCommand.cc
	* src/PeerInitiateConnectionCommand.h
	* src/PeerInteractionCommand.cc
	* src/PeerInteractionCommand.h
	* src/PeerReceiveHandshakeCommand.cc
	* src/PieceHashCheckIntegrityEntry.cc
	* src/RealtimeCommand.cc
	* src/ReceiverMSEHandshakeCommand.cc
	* src/RequestGroup.cc
	* src/RequestGroup.h
	* src/RequestGroupEntry.cc
	* src/RequestGroupMan.cc
	* src/SeedCheckCommand.cc
	* src/SeedCheckCommand.h
	* src/SegmentMan.cc
	* src/ShareRatioSeedCriteria.h
	* src/SingleFileDownloadContext.cc: Removed
	* src/SingleFileDownloadContext.h: Removed
	* src/SleepCommand.cc
	* src/StreamCheckIntegrityEntry.cc
	* src/TrackerWatcherCommand.cc
	* src/TrackerWatcherCommand.h
	* src/UnknownLengthPieceStorage.cc
	* src/Util.cc
	* src/Util.h
	* src/XmlRpcMethodImpl.cc
	* src/bittorrent_helper.cc
	* src/bittorrent_helper.h
	* src/download_helper.cc
	* src/main.cc
	* src/option_processing.cc
	* test/BitfieldManTest.cc
	* test/BittorrentHelperTest.cc
	* test/BtCancelMessageTest.cc
	* test/BtChokeMessageTest.cc
	* test/BtDependencyTest.cc
	* test/BtPieceMessageTest.cc
	* test/BtPostDownloadHandlerTest.cc
	* test/BtRegistryTest.cc
	* test/BtRejectMessageTest.cc
	* test/BtRequestMessageTest.cc
	* test/DHTPeerAnnounceStorageTest.cc
	* test/DefaultBtAnnounceTest.cc
	* test/DefaultBtContextTest.cc: Removed
	* test/DefaultBtMessageDispatcherTest.cc
	* test/DefaultBtMessageFactoryTest.cc
	* test/DefaultBtProgressInfoFileTest.cc
	* test/DefaultBtRequestFactoryTest.cc
	* test/DefaultExtensionMessageFactoryTest.cc
	* test/DefaultPeerStorageTest.cc
	* test/DefaultPieceStorageTest.cc
	* test/DirectDiskAdaptorTest.cc
	* test/DownloadContextTest.cc
	* test/DownloadHandlerFactoryTest.cc
	* test/DownloadHelperTest.cc
	* test/HandshakeExtensionMessageTest.cc
	* test/HttpRequestTest.cc
	* test/HttpResponseTest.cc
	* test/IteratableChecksumValidatorTest.cc
	* test/IteratableChunkChecksumValidatorTest.cc
	* test/MSEHandshakeTest.cc
	* test/Makefile.am
	* test/Makefile.in
	* test/Metalink2RequestGroupTest.cc
	* test/MetalinkPostDownloadHandlerTest.cc
	* test/MockBtContext.h: Removed
	* test/MockDHTTaskFactory.h
	* test/MockDownloadContext.h: Removed
	* test/MockPieceStorage.h
	* test/MultiDiskAdaptorTest.cc
	* test/MultiFileAllocationIteratorTest.cc
	* test/RequestGroupManTest.cc
	* test/RequestGroupTest.cc
	* test/SegmentManTest.cc
	* test/ShareRatioSeedCriteriaTest.cc
	* test/SingleFileDownloadContextTest.cc: Removed
	* test/UtilTest.cc
	* test/XmlRpcMethodTest.cc
2009-06-28 10:37:15 +00:00
Tatsuhiro Tsujikawa ca2567f2a2 2009-01-18 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added --bt-max-peers option to specify the maximum number of
	peers per torrent. 0 means unlimited number of peers.
	* src/ActivePeerConnectionCommand.cc
	* src/BtRuntime.h
	* src/DefaultPeerStorage.cc
	* src/DefaultPeerStorage.h
	* src/OptionHandlerFactory.cc
	* src/RequestGroup.cc
	* src/option_processing.cc
	* src/prefs.cc
	* src/prefs.h
	* src/usage_text.h
	* test/DefaultPeerStorageTest.cc
2009-01-18 10:11:08 +00:00
Tatsuhiro Tsujikawa fcb7254bf5 2008-08-07 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Fixed memory leak in test code
	* test/AnnounceListTest.cc
	* test/DefaultPeerListProcessorTest.cc
	* test/DefaultPeerStorageTest.cc
	* test/MetaFileUtilTest.cc
2008-08-07 14:21:50 +00:00
Tatsuhiro Tsujikawa 7a74971caa 2008-06-10 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Always remove a peer from cache in 
DefaultPeerStorage::returnPeer(),
	to make room more fleshy, recently found peers.
	Peer::_badConditionStartTime is not used anymore. Consider to 
remove
	it.
	* src/DefaultPeerStorage.cc
	* test/DefaultPeerStorageTest.cc
2008-06-10 11:29:10 +00:00
Tatsuhiro Tsujikawa 05f0646112 2008-05-11 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Changed method signature:
	PeerStorage::getActivePeers
	* src/DHTPeerAnnounceEntry.cc
	* src/DefaultPeerStorage.cc
	* src/DefaultPeerStorage.h
	* src/PeerStorage.h
	* test/DefaultPeerStorageTest.cc
	* test/MockPeerStorage.h
2008-05-11 12:58:48 +00:00
Tatsuhiro Tsujikawa 3505201f33 2008-04-20 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Rewritten SharedHandle. Now copy constructor taking raw pointer 
has
	keyword explicit and SharedHandle's default constructor 
initializes
	its internal obj to null, old implementation initializes it 
using
	obj's default constructor.
	To assign null, write SharedHandle<T> x(...); x.reset();
	TODO: test/SharedHandleTest.cc needs more tests.
	* src/SharedHandle.h
2008-04-20 00:50:22 +00:00
Tatsuhiro Tsujikawa 2555098ecd 2008-03-08 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Type clarification
	* src/DefaultPeerStorage.{h, cc}
	* test/DefaultPeerStorageTest.cc
2008-03-08 10:44:25 +00:00
Tatsuhiro Tsujikawa c064a2cd9e 2008-02-10 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Extract the Peer class's member variables, which are only needed 
after
	PeerInteractionCommand, into PeerSessionResource class.
	This class is instantiated in PeerInteractionCommand class's 
ctor and
	released in its dtor.
	This will make Peer class lightweight and uses less memory for 
peers
	which are not connected and wait in the queue.
	* src/PeerChokeCommand.cc
	* src/PeerSessionResource.{h, cc}
	* src/PeerInteractionCommand.cc
	* src/PeerAbstractCommand.cc: Note: 0 is given to onAbort() 
function.
	* src/DefaultBtInteractive.cc
	* src/BtPieceMessage.cc
	* src/BtInterestedMessage.cc
	* src/BtUnchokeMessage.cc
	* src/DefaultPeerStorage.{h, cc}
	* src/PeerInitiateConnectionCommand.cc
	* src/ActivePeerConnectionCommand.cc
	* src/BtNotInterestedMessage.cc
	* src/DefaultBtMessageDispatcher.cc
	* src/BtChokeMessage.cc
	* src/BtRequestMessage.cc
	* src/Peer.{h, cc}
	* src/BtRegistry.h
	* src/TrackerWatcherCommand.cc
	* src/PeerReceiveHandshakeCommand.cc
	* test/BtExtendedMessageTest.cc
	* test/BtAllowedFastMessageTest.cc
	* test/BtCancelMessageTest.cc
	* test/DefaultPieceStorageTest.cc
	* test/BtBitfieldMessageTest.cc
	* test/BtHaveMessageTest.cc
	* test/BtNotInterestedMessageTest.cc
	* test/BtRequestMessageTest.cc
	* test/PeerSessionResourceTest.cc
	* test/DefaultBtMessageDispatcherTest.cc
	* test/PeerTest.cc
	* test/BtInterestedMessageTest.cc
	* test/BtRejectMessageTest.cc
	* test/BtChokeMessageTest.cc
	* test/DefaultPeerStorageTest.cc
	* test/BtHaveNoneMessageTest.cc
	* test/BtHaveAllMessageTest.cc
	* test/DefaultExtensionMessageFactoryTest.cc
	* test/BtUnchokeMessageTest.cc
	* test/DefaultBtMessageFactoryTest.cc
	* test/HandshakeExtensionMessageTest.cc
	* test/UTPexExtensionMessageTest.cc
	* test/DefaultBtRequestFactoryTest.cc
	* test/BtPieceMessageTest.cc
	
	Removed typedef PeerStats.
	* src/PeerStat.h
	* src/SegmentMan.cc
2008-02-09 17:14:40 +00:00
Tatsuhiro Tsujikawa 1b7c198289 2008-02-08 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Removed "using namespace std;" from all sources. Appended std:: 
prefix to c++
	standard classes.
	Included string.h where mem* function are used.
2008-02-08 15:53:45 +00:00
Tatsuhiro Tsujikawa f412691770 2008-01-10 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Fixed the bug that DefaultPeerStorage::returnPeer() may delete wrong
	peer if there are peers that have same ipaddr and port.
	I've experiened segmentation fault and "pure virtual function was
	called" error.
	* src/Peer.h
	* test/PeerTest.cc
	* src/DefaultPeerStorage.cc
	* test/DefaultPeerStorageTest.cc
2008-01-10 14:59:11 +00:00
Tatsuhiro Tsujikawa e39f7a7e9c 2007-12-26 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Allocate bitfield in Peer when it is really used. More 
specifically,
	bitfield in Peer is allocated after the connection is 
established and
	deallocated when the connection is dropped.
	Since 2 parameters(piece length and total length) was removed 
from the
	constructor of Peer class, many test classes were modified 
accordingly.
	See svn log for more detailed information.
	* src/PeerInteractionCommand.cc
	* src/CompactPeerListProcessor.cc
	* src/Peer.cc
	* src/DefaultPeerListProcessor.cc
	* src/PeerListenCommand.cc
	* src/PeerReceiveHandshakeCommand.cc

	Fixed memory leak
	* src/Piece.cc
2007-12-26 14:26:55 +00:00
Tatsuhiro Tsujikawa f5b68379d5 2007-12-25 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Removed incomingPeer. Set 0 to peer's port if it is not a listening
	port.
	* src/DefaultPeerStorage.{h, cc}
	* test/DefaultPeerStorageTest.cc
	* src/HandshakeExtensionMessage.cc
	* test/HandshakeExtensionMessageTest.cc
	* src/Peer.{h, cc}: Added ipaddr and port to identity comparison.
	* src/PeerStorage.h
	* test/MockPeerStorage.h
	* src/PeerListenCommand.cc
2007-12-25 12:34:23 +00:00
Tatsuhiro Tsujikawa 51cb6b5ba9 2007-12-22 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Allow a peer in incomingPeer to be added peers.
	* src/DefaultPeerStorage.cc
	* test/DefaultPeerStorageTest.cc
2007-12-22 06:08:58 +00:00
Tatsuhiro Tsujikawa 286f34cb3f 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
Tatsuhiro Tsujikawa 19ef788023 Merged Ross's patch to test code. 2007-07-23 14:09:46 +00:00
Tatsuhiro Tsujikawa 453e2f10dd 2007-06-03 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
RequestGroup::getNextCommand() was renamed to 
createNextCommand().
	Added its overloaded method.
	* src/RequestGroup.h 
	(_numConcurrentCommand): New variable.
	(setNumConcurrentCommand): New function.
	* src/RequestGroup.cc
	
	Abort download if same file is being downloaded concurrently.
	* src/RequestGroup.h, src/RequestGroupMan.cc
	(isSameFileBeingDownloaded): New function.
	* src/HttpResponseCommand.cc (executeInternal)
	* src/FtpNegotiateCommand.cc (recvSize)
	* src/message.h (EX_DUPLICATE_FILE_DOWNLOAD): New definition.
	
	* main.cc: Added help message for -i option.
2007-06-03 14:24:37 +00:00
Tatsuhiro Tsujikawa dd37b7be0a 2007-04-06 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* src/PeerAbstractCommand.cc
	(onAbort): Call PeerStorage::returnPeer()
	* src/DefaultPeerStorage.h, src/DefaultPeerStorage.cc
	(incomingPeers): New variable.
	(addIncomingPeer): New function.
	(returnPeer): New function.
	(onErasingPeer): New function.
	(addPeer): push_back -> push_front
	(getActivePeers): Rewritten.
	(calculateStat): Rewritten.
	* src/PeerStorage.h
	(TransferStat::copy): New function.
	(TransferStat::TransferStat): New function.
	(TransferStat::operator=): New function.
	(addIncomingPeer): New function.
	(returnPeer): New function.
	* src/PeerListenCommand.cc
	(execute): Use PeerStorage::addIncomingPeer() instead of
	Peer::addPeer().
2007-04-05 16:47:59 +00:00
Tatsuhiro Tsujikawa e78c8b0a03 Fixed compilation errors 2007-03-28 16:11:04 +00:00
Tatsuhiro Tsujikawa 9c3e8fbd9c 2006-12-24 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Rewritten a portion of bittorrent implementation:
	
	* src/BtMessageValidator.h: New class.
	* src/BtBitfieldMessageValidator.h: New class.
	* src/BtHandshakeMessageValidator.h: New class.
	* src/BtRequestMessageValidator.h: New class.
	* src/BtSuggestPieceMessageValidator.h: New class.
	* src/BtAllowedFastMessageValidator.h: New class.
	* src/BtRejectMessageValidator.h: New class.
	* src/BtCancelMessageValidator.h: New class.
	* src/BtPieceMessageValidator.h: New class.
	* src/BtHaveMessageValidator.h: New class.
	* src/BtEventListener.h: New class.
	* src/AbstractBtEventListener.h: New class.
	* src/BtEvent.h: New class.
	* src/BtChokingEvent.h: New class.
	* src/BtChokedEvent.h: New class.
	* src/BtCancelSendingPieceEvent.h: New class.
	* src/BtAbortOutstandingRequestEvent.h: New class.
	* src/Randomizer.h: New class.
	* src/SimpleRandomizer.h: New class.
	* src/BtMessage.h: New class.
	* src/AbstractBtMessage.h: New class.
	* src/SimpleBtMessage.h: New class.
	* src/BtHaveMessage.h: New class.
	* src/BtInterestedMessage.h: New class.
	* src/BtAllowedFastMessage.h: New class.
	* src/BtUnchokeMessage.h: New class.
	* src/BtCancelMessage.h: New class.
	* src/BtNotInterestedMessage.h: New class.
	* src/BtChokeMessage.h: New class.
	* src/BtHaveNoneMessage.h: New class.
	* src/BtHandshakeMessage.h: New class.
	* src/BtSuggestPieceMessage.h: New class.
	* src/BtHaveMessage.h: New class.
	* src/BtPieceMessage.h: New class.
	* src/BtHaveAllMessage.h: New class.
	* src/BtKeepAliveMessage.h: New class.
	* src/BtPortMessage.h: New class.
	* src/BtRejectMessage.h: New class.
	* src/BtBitfieldMessage.h: New class.
	* src/BtRequestMessage.h: New class.
	* src/DefaultBtRequestFactory.h: New class.
	* src/DefaultBtMessageReceiver.h: New class.
	* src/BtInteractive.h: New class.
	* src/BtMessageDispatcher.h: New class.
	* src/DefaultBtMessageDispatcher.h: New class.
	* src/DefaultBtInteractive.h: New class.
	* src/BitfieldManFactory.h: New class.
	* src/HandleRegistry.h: New class.
	* src/BtMessageFactory.h: New class.
	* src/BtMessageReceiver.h: New class.
	* src/DefaultBtMessageFactory.h: New class.
	* src/PeerObject.h: New class.
	* src/BtRequestFactory.h: New class.
2006-12-24 06:25:21 +00:00
Tatsuhiro Tsujikawa ec642ad294 2006-11-05 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To divide TorrentMan into 6 classes: BtContext, BtRuntime,
	PeerStorage, PieceStorage, BtAnnounce and BtProgressInfoFile

	* src/TrackerWatcherComand.h: Made subclass of 
BtContextAwareCommand.
	* src/SeedCheckCommand.cc: Use pieceStorage, btRuntime
	* src/PeerAbstractCommand.h: Made subclass of 
BtContextAwareCommand.
	* src/PeerAbstractCommand.cc: Use btRuntime.
	* src/BtContextAwareCommand.h: New class.
	* src/FileEntry.h: Added accessor methods for following 
variables.
	(path): Made private.
	(length): Made private.
	(offset): Made private.
	(extracted): Made private.
	(requested): Made private.
	(FileEntries): New definition.
	(FileEntryHandle): New definition.
	* src/FileEntry.cc: New file.
	* src/HaveEraseCommand.h: Made subclass of 
BtContextAwareCommand.
	* src/HaveEraseCommand.cc: Use btRuntime, pieceStorage.
	* src/PeerChokeCommand.h: Made subclass of 
BtContextAwareCommand.
	* src/PeerChokeCommand.cc: Use btRuntime, peerStorage, 
pieceStorage.
	* src/PieceStorage.h: New file.
	* src/PeerInteractionCommand.h: Use btContext.
	* src/PeerInteractionCommand.cc: Use pieceStorage, peerStorage,
	btRuntime.
	* src/DefaultBtProgressInfoFile.h: New file.
	* src/DefaultBtProgressInfoFile.cc: New file.
	* src/File.cc
	(Util.h): New include.
	(mkdirs): New function.
	* src/MultiDiskAdaptor.h
	(mkdir): New function.
	* src/PeerListProcessor.h
	(Peers): Removed.
	* src/PeerInteraction.h
	(torrentMan): Removed.
	(btContext): New variable.
	(peerStorage): New variable.
	(pieceStorage): New variable.
	(btAnnounce): New variable.
	(getTorrentMan): Removed.
	(getBtContext): New function.
	* src/PeerInteraction.cc: Use btContext, peerStorage, 
pieceStorage,
	btAnnounce.
	* src/HandshakeMessage.h
	(TorrentMan.h): Removed.
	* src/HandshakeMessage.cc: Use btContext.
	* src/DefaultBtAnnounce.cc: New file.
	* src/MultiDiskWriter.cc: Use the accessor methods of FileEntry.
	* src/DefaultPieceStorage.cc: New file.
	* src/DefaultBtContext.h: New file.
	* src/TorrentRequestInfo.cc: Use btContext, pieceStorage.
	Use the accessor methods of FileEntry.
	* src/CookieBox.cc: Updated to use Util::slice().
	* src/PieceMessage.cc: Use btContext, pieceStorage.
	* src/common.h (SharedHandle.h): New include.
	* src/PeerMessage.cc (PeerMessage): Added btContext, 
peerStorage,
	pieceStorage.
	* src/TorrentAutoSaveCommand.h: Made subclass of 
BtContextAwareCommand.
	* src/DiskAdaptor.h
	(topDir): Removed.
	(getFileEntryFromPath): Changed the return type to 
FileEntryHandle.
	(setTopDir): Removed.
	(getTopDir): Removed.
	* src/BtContext.h: New file.
	* src/DefaultPeerStorage.h: New file.
	* src/PieceMessage.h (TorrentMan.h): Removed.
	* src/RequestMessage.h (TorrentMan.h): Removed.
	* src/TorrentDownloadEngine.h
	(uploadLength): New variable.
	(btContext): New variable.
	(btRuntime): New variable.
	(pieceStorage): New variable.
	(peerStorage): New variable.
	(btAnnounce): New variable.
	(btProgressInfoFile): New variable.
	(torrentMan): Removed.
	(setBtContext): New function.
	* src/TorrentDownloadEngine.cc: Use BtContext, BtRuntime, 
pieceStorage,
	peerStorage, btAnnounce, btProgressInfoFile.
	* src/Piece.h
	(toString): New function.
	(Pieces): New type definition.
	* src/Peer.h
	(active): New variable.
	(Peer): Added active.
	(activate): Set active to true.
	(deactivate): Set active to false.
	(isActive): New function.
	(Peers): New type definition.
	* src/DirectDiskAdaptor.cc
	(getFilePath): Use the accessor methods of FileEntry.
	* src/TorrentConsoleDownloadEngine.h
	(afterEachIteration): New function.
	* src/TorrentConsoleDownloadEngine.cc
	(haltRequested): New variable.
	(sendStatistics): Use pieceStorage, btRuntime.
	(afterEachIteration): New function.
	* src/AnnounceList: AnnounceTier->AnnounceTierHandle.
	* src/Directry.h
	(Directory): New function.
	(DirectoryHandle): New type definition.
	* src/BtProgressInfoFile.h: New file.
	* src/RequestMessage.cc: Use pieceStorage.
	* src/BtRuntime.h: New file.
	* src/DefaultBtContext.cc: New file.
	* src/BitfieldMan.h
	(getCompletedLength): New function(private).
	(getCompletedLength): New function.
	(getFilteredCompletedLength): New function.
	* src/BitfieldMan.h
	(getCompletedLength): New function(private).
	(getCompletedLength): New function.
	(getFilteredCompletedLength): New function.
	* src/MultiDiskAdaptor.cc
	(mkdir): New function.
	(openFile): Call mkdir().
	(initAndOpenFile): Call mkdir().
	* src/CancelMessage.h
	(TorrentMan.h): Removed.
	* src/RejectMessage.h
	(TorrentMan.h): Removed.
	* src/DownloadEngineFactory.cc
	(DefaultPieceStorage.h): New include.
	(DefaultPeerStorage.h): New include.
	(DefaultBtAnnounce.h): New include.
	(DefaultBtProgressInfoFile.h): New include.
	(newTorrentConsoleEngine): Rewritten.
	* src/ShareRatioSeedCriteria.h
	(torrentMan): Removed.
	(btContext): New variable.
	(peerStorage): New variable.
	(btRuntime): New variable.
	(evaluate): Use btContext, btRuntime, peerStorage.
	* src/AnnounceTier.h: New file.
	* src/BtAnnounce.h: New file.
	* src/BtRegistry.h: New file.
	* src/PeerInitiateConnectionCommand.h: Added btContext.
	* src/PeerConnection.h (TorrentMan.h): Removed.
	* src/PeerMessageFactory.cc: Use btContext, pieceStorage.
	* src/Util.h
	(slice): Added an argument.
	* src/Util.cc
	(slice): Added an argument to control whether trim is made or 
not.
	* src/PeerStorage.h: New file.
	* src/BtRegistry.cc: New file.
	* src/TrackerUpdateCommand.h: Made subclass of 
BtContextAwareCommand.
	* src/CopyDiskAdaptor.cc: Use the accessor methods of FileEntry.
	* src/MultiDiskWriter.h: FileEntry -> FileEntryHandle
	* src/PeerListenCommand.cc: Use btRuntime, peerStorage, 
btContext.
	* src/TorrentRequestInfo.h
	(e): Removed.
	(showFileEntry): Added an argument.
	(getDownloadEngine): Return 0.
	* src/DefaultBtAnnounce.h: New file.
	* src/TorrentAutoSaveCommand.cc: Use btRuntime, 
btProgressInfoFile.
	* src/TrackerWatcherComand.cc: Use btRuntime, btAnnounce,
	* src/PeerMessageFactory.h
	(btContext): New variable.
	(pieceStorage): New variable.
	* src/TrackerUpdateCommand.cc: Use btRuntime, peerStorage, 
btContext,
	btAnnounce.
	* src/DiskAdaptor.cc
	(DiskAdaptor): Removed topDir.
	(~DiskAdaptor): Removed topDir.
	* src/PeerListenCommand.h: Made subclass of 
BtContextAwareCommand.
	* src/SeedCheckCommand.h: Made subclass of 
BtContextAwareCommand.
	* src/File.h (mkdirs): New function.
	* src/DefaultPeerStorage): New file.
	* src/DownloadEngineFactory.h
	(newTorrentConsoleEngine): Use btContext.
	* src/BtContextAwareCommand.cc: New file.
	* src/PeerInitiateConnectionCommand.cc: Use btRuntime, 
peerStorage.
	* src/PeerMessage.h
	(btContext): New variable.
	(peerStorage): New variable.
	(pieceStorage): New variable.
	(setBtContext): New function.
	* src/Directry.cc
	(Directory): New function.
	(createDir): Do nothing if name.size() == 0.
	* src/AnnounceList.h
	(AnnounceTier): Removed. 
	(AnnounceTiers): Removed.
	* src/DefaultPieceStorage.h: New file.
	* src/Piece.cc (toString): New function.
	
	To fix typo:
	
	* src/main.cc (showVersion): Fixed typo.

	To fix compile warning:
	
	* src/DelegatingPeerListProcessor.cc
	(canHandle): Added "return false".
2006-11-05 15:04:17 +00:00