mirror of https://github.com/aria2/aria2
92 Commits (49c4f82561470d0856542cccc6f5e97f2cd188b6)
Author | SHA1 | Message | Date |
---|---|---|---|
Tatsuhiro Tsujikawa | 6f96fdc587 | Show 1/10 unit in size | |
Tatsuhiro Tsujikawa | d5bb035642 |
2007-06-10 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* src/AbstractCommand.cc (execute): Changed log level of MSG_RESTARTING_DOWNLOAD and MSG_MAX_TRY from error to info. Added MSG_DOWNLOAD_ABORTED after MSG_MAX_TRY. * src/message.h (MSG_TORRENT_DOWNLOAD_ABORTED): New definition. (MSG_DOWNLOAD_ABORTED): Added %s. (MSG_RESTARTING_DOWNLOAD): Added %s. (MSG_DOWNLOAD_ALREADY_COMPLETED): Updated. * src/PeerAbstractCommand.cc (execute): MSG_DOWNLOAD_ABORTED -> MSG_TORRENT_DOWNLOAD_ABORTED * src/Request.h (cookieBox): Made ShardHandle. * src/RequestGroup.h, src/RequestGroup.cc (createNextCommandWithAdj): New function. * src/FileAllocationCommand.cc (executeInternal): Use createNextCommandWithAdj(). * src/CheckIntegrityCommand.cc (executeInternal): Use createNextCommandWithAdj(). Added --load-cookies command-option. * src/OptionHandlerFactory.cc (createOptionHandlers): Added PREF_LOAD_COOKIES. * src/CookieBox.h, src/CookieBox.cc: Rwritten using CookieParser. Now aria2 can handle cookie's expiration date. * src/Cookie.h (expires): Changed its type to time_t. * src/main.cc: Added --load-cookies command-line option. * src/prefs.h (PREF_LOAD_COOKIES): New definition. * src/Util.h, src/Util.cc (httpGMT): New function. * src/Request.cc (Request): Initialize cookieBox using CookieBoxFactory. * src/CookieBoxFactory.h, src/CookieBoxFactory.cc: New class. * src/CookieParser.h, src/CookieParser.cc: New class. * src/main.cc: Chagned the default value of --metalink-servers to 5. * src/HttpResponseCommand.cc (handleOtherEncoding): Call RequestGroup::shouldCancelDownloadForSafety |
|
Tatsuhiro Tsujikawa | 2d522cf6b7 |
2007-06-09 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added -j command-line option. * src/OptionHandlerFactory.cc (createOptionHandlers) * src/main.cc * src/ByteArrayDiskWriter.h, src/ByteArrayDiskWriter.cc Rewritten using stringstream. * src/TrackerUpdateCommand.h, src/TrackerUpdateCommand.cc Rewritten using stringstream. |
|
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. |
|
Tatsuhiro Tsujikawa | ccdd5b31a3 |
2007-06-01 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* src/FileAllocationCommand.cc: Derived from RealtimeCommand. * src/CheckIntegrityCommand.cc: Derived from RealtimeCommand. * src/MetalinkEntry.h (checksum): Changed to ChecksumHandle * src/MetalinkRequestInfo.cc (checksum): Changed to ChecksumHandle * src/File.cc (mkdirs): OPEN_MODE -> DIR_OPEN_MODE * src/common.h (DIR_OPEN_MODE): New definition * src/RequestGroup.cc (prepareForNextAction): Added an argument. * src/message.h (MSG_GOOD_CHECKSUM): New definition (MSG_BAD_CHECKSUM): New definition * src/HttpResponseCommand.cc (handleDefaultEncoding): Continue download sequence in new non-segmented download. * src/FileAllocationEntry.h (_nextDownloadCommand): New variable. * src/DownloadCommand.cc (prepareForNextSegment): Create ChecksumCommand if checksum is available. * src/RealtimeCommand.h, src/RealtimeCommand.cc: New class. * src/IteratableChecksumValidator.h, src/IteratableChecksumValidator.cc: New class. * src/ChecksumCommand.h, src/ChecksumCommand.cc: New class. |
|
Tatsuhiro Tsujikawa | eaf2d53a91 |
2007-05-20 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* Added the simultaneous download feature. |
|
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(). |
|
Tatsuhiro Tsujikawa | 24d199632b |
2007-03-28 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To cache resolved hostname: * src/AbstractCommand.h, src/AbstractCommand.cc (resolveHostname): Put outside #ifdef ENABLE_ASYNC_DNS clause. Added dns cache. * src/FtpInitiateConnectionCommand.cc (executeInternal): Removed #ifdef ENABLE_ASYNC_DNS. * src/NameResolver.h, src/NameResolver.cc: Added synchronized NameResolver working without ares. * src/TorrentRequestInfo.cc (execute): Don't cache dns in torrent download. * src/HttpInitiateConnectionCommand.cc (executeInternal): Removed #ifdef ENABLE_ASYNC_DNS * src/DNSCache.h: New class. * src/UrlRequestInfo.cc (execute): Use dns cache |
|
Tatsuhiro Tsujikawa | a1b57c5755 | ||
Tatsuhiro Tsujikawa | 6e6ba30c60 |
2007-03-28 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To add the command-line option which disables netrc support: * src/OptionHandlerFactory.cc (createOptionHandlers): Added PREF_NO_NETRC. * src/main.cc: Added -n option. * src/prefs.h (PREF_NO_NETRC): New definition. * src/RequestFactory.cc: Do not use netrc in ftp if PREF_NO_NETRC is V_TRUE. Note that netrc is not used in http, http proxy even if PREF_NO_NETRC is V_FALSE. This may get configurable in the future release. To clear peer's error status by time basis: * src/PeerAbstractCommand.cc (onAbort): Call Peer::startBadCondition(). * src/Peer.h, src/Peer.cc (error): Removed. (_badConditionStartTime): New variable. (_badConditionInterval): New variable. Initialized to 10 seconds. (startBadCondition): New function. (isGood): New function. * src/DefaultPeerStorage.cc (addPeer): Use Peer::isGood(). (FindFinePeer): Use Peer::isGood(). Always include port number in http request header: * src/HttpRequest.cc (getHostText): Always include port number in http request header. |
|
Tatsuhiro Tsujikawa | 9b73454b07 |
2007-03-26 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To the ability to read options from a config file: * src/main.cc: Command-line parameter validation is delegated to OptionHandler class. * src/OptionHandlerFactory.h, src/OptionHandlerFactory.cc: New class. * src/Option.h, src/Option.cc (clear): New function. * src/OptionParser.h, src/OptionParser.cc: New class. * src/OptionHandler.h: New class. * src/NameMatchOptionHandler.h: New class. * src/OptionHandlerImpl.h: New classes. * src/prefs.h: '_' -> '-' (FTP_PASV_ENABLED): Renamed to FTP_PASV. (FTP_PASV): New definition. * src/Util.h, src/Util.cc (getRealSize): New function. To disable netrc support if .netrc file does not have correct permissions: * src/File.h, src/File.cc (mode): New function. To prevent confidential information to be logged: * src/HttpConnection.h, src/HttpConnection.cc (eraseConfidentialInfo): New function. (sendRequest): Call eraseConfidentialInfo(). (sendProxyRequest): Call eraseConfidentialInfo(). * src/main.cc: Validate permissions of .netrc file. To add --user-agent command-line option: * src/main.cc: Added new command line option: --user-agent * src/prefs.h (PREF_USER_AGENT): New definition. * src/HttpRequestCommand.cc (executeInternal): Set user-agent option parameter to HttpRequest object. Marged the patches from Dan Fandrich. |
|
Tatsuhiro Tsujikawa | a37aaa9c0c |
2007-03-24 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To add the ability to resume downloading a partially downloaded file which is downloaded from the beginning: * src/FileAllocator.h: Made abstract class. New DefaultFileAllocator takes this role. * src/main.cc: Added -c option. * src/BitfieldMan.h, src/BitfieldMan.cc (setBitRange): New function. * src/DiskWriter.h (openExistingFile): Added totalLength argument. * src/prefs.h (PREF_CONTINUE): New definition. * src/SegmentMan.h, src/SegmentMan.cc (markPieceDone): New function. * src/DefaultDiskWriter.cc (createNewDiskWriter): Add GlowFileAllocator to the new object. * src/AbstractDiskWriter.h (glowFileAllocator): New variable. * src/AbstractDiskWriter.cc (openExistingFile): Now preallocate file space from the end of the existing file if totalLength argument is specified and grater than 0. * src/UrlRequestInfo.cc: If -c option is specified and the file to download exists in local, continue the download of the file. --allow-overwrite=true is assumed in this context. * src/DefaultFileAllocator.h, src/DefaultFileAllocator.cc: New class. * src/GlowFileAllocator.h, src/GlowFileAllocator.cc: New class. Throw exception if --check-integrity=true is specified but chunk checksums are not provided: * src/UrlRequestInfo.cc |
|
Tatsuhiro Tsujikawa | 5649cf6cda |
2007-03-21 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* src/Request.h: Use AuthResolver to get authentication information. * src/main.cc: Made RequestFactory a singleton object. Netrc is now set to RequestFactory object. * src/AuthConfigItem.h, src/AuthConfigItem.cc: Removed. * src/AuthConfig.h, src/AuthConfig.cc: Rewritten. * src/TrackerWatcherComand.cc: Use RequestFactorySingletonHolder to create Request object. |
|
Tatsuhiro Tsujikawa | 7ff627079f |
2007-03-19 Tatsuhiro Tsujikawa <tujikawa at valkyrie dot rednoah com>
To integrate Netrc into exsiting classes: * src/Request.h (_userDefinedAuthConfig): New variable. (findNetrcAuthenticator): New function. (segment): Removed. (setUserDefinedAuthConfig): New function. (resolveHttpAuthConfigItem): New function. (resolveFtpAuthConfigItem): New function. (resolveHttpProxyAuthConfigItem): New function. * src/HttpRequest.h (authConfig): Removed. (proxyAuthConfig): Removed. (setAuthConfig): Removed. (setProxyAuthConfig): Removed. * src/UrlRequest.h (getHeadResult): Added a parameter: authConfigHandle * src/common.h (SingletonHolder.h): New include. * src/main.cc (Netrc.h): New include. (main): Removed initial values of PREF_FTP_USER, PREF_FTP_PASSWD. Added initial value of PREF_NETRC_PATH. Added the initialization of netrc. * src/AuthConfig.h: New class. * src/prefs.h (PREF_NETRC_PATH): New definition. * src/HttpAuthConfig.h: Removed. * src/Netrc.cc (getRequiredNextToken): New function. (skipMacdef): New function. (parse): Rewritten. * src/Netrc.h (getRequiredNextToken): New function. (skipMacdef): New function. * src/Util.h, src/Util.cc (getHomeDir): New function. * src/TrackerWatcherComand.cc (createRequestCommand): Use AuthConfig. * src/FtpConnection.cc (sendUser): Use Request::resolveFtpAuthConfigItem(). (sendPass): Use Request::resolveFtpAuthConfigItem(). * src/Request.cc (findNetrcAuthenticator): New function. (resolveHttpAuthConfigItem): New function. (resolveFtpAuthConfigItem): New function. (resolveHttpProxyAuthConfigItem): New function. * src/UrlRequestInfo.cc: Use AuthConfig. * src/HttpRequest.cc (createRequest): Use authConfig. (getProxyAuthString): Use authConfig. (configure): Removed PREF_HTTP_USER, PREF_HTTP_PASSWD, PREF_HTTP_PROXY_USER, PREF_HTTP_PROXY_PASSWD. |
|
Tatsuhiro Tsujikawa | 11907c175d |
2007-03-15 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To handle Segment as SegmentHandle: * src/AbstractCommand.cc (execute): Rewritten. * src/SegmentMan.h: Segment -> SegmentHandle Introducded HttpResponse class, HttpRequest class to improve code extensiveness and make it clear: * src/HttpDownloadCommand.cc: transfer encoders are now managed by HttpResponse class. * src/HttpRequest.h, src/HttpRequest.cc: New class. * src/HttpResponse.h, src/HttpResponse.cc: New class. * src/HttpConnection.cc: Contruction of http request were moved to HttpRequest class. * src/HttpResponseCommand.h, src/HttpResponseCommand.cc: Refactored. * src/HttpRequestCommand.cc (executeInternal): Rewritten. * src/HttpAuthConfig.h: New class. * src/Range.h: New class. To make FtpTunnel{Request, Response}Command and HttpProxy{Request, Response}Command derived from AbstractProxy{Request, Response}Command: * src/FtpTunnelResponseCommand.h, src/FtpTunnelResponseCommand.cc: Derived from AbstractProxyRequestCommand class. * src/FtpTunnelRequestCommand.h, src/FtpTunnelRequestCommand.cc: Derived from AbstractProxyResponseCommand class. * src/HttpProxyRequestCommand.h, src/HttpProxyRequestCommand.cc: Derived from AbstractProxyRequestCommand class. * src/HttpProxyResponseCommand.h, src/HttpProxyResponseCommand.cc: Derived from AbstractProxyResponseCommand class. * src/AbstractProxyRequestCommand.h, src/AbstractProxyRequestCommand.cc : New class. * src/AbstractProxyResponseCommand.h, src/AbstractProxyResponseCommand.cc: New class. To add netrc support: * src/Netrc.h, src/Netrc.cc: New class. * src/Util.h, src/Util.cc (split): New function. * src/HttpHeader.cc (getRange): Fixed so that it inspects "Content-Range" header instead of "Range" header. * src/HttpHeader.h (getStatus): Removed. (setStatus): Removed. * src/Segment.h (getPositionToWrite): New function. |
|
Tatsuhiro Tsujikawa | ea6d9493c8 |
2007-01-23 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To add chunk checksum validation: * src/MetalinkEntry.h (MetalinkChunkChecksum.h): New include. (chunkChecksum): New variable. * src/Request.h (method): New variable. (setMethod): New function. (getMethod): New function. (METHOD_GET): New static constant. (METHOD_HEAD): New static constant. * src/Xml2MetalinkProcessor.h (getPieceHash): New function. * src/PieceStorage.h (markAllPiecesDone): New function. (checkIntegrity): New function. * src/FileAllocator.h (NullFileAllocationMonitor.h): New include. (FileAllocator): Initialize fileAllocationMonitor with new NullFileAllocationMonitor(). * src/MultiDiskAdaptor.h (messageDigest.h): Remove include. (ctx): Removed. (hashUpdate): Added ctx. (MultiDiskAdaptor): Removed ctx. (sha1Sum): Renamed as messageDigest. (messageDigest): New function. * src/UrlRequestInfo.h (HeadResult): New class. (digestAlgo): New variable. (chunkChecksumLength): New variable. (chunkChecksums): New variable. (getHeadResult): New function. (UrlRequestInfo): Added digestAlgo, chunkChecksumLength. (setDigestAlgo): New function. (setChunkChecksumLength): New function. (setChunkChecksums): New function. * src/DefaultPieceStorage.cc (DiskAdaptorWriter.h): New include. (ChunkChecksumValidator.h): New include. (markAllPiecesDone): New function. (checkIntegrity): New function. * src/DefaultBtContext.h (getPieceHashes): New function. * src/TorrentRequestInfo.cc (execute): Try to validate chunk checksum if file already exists and .aria2 file doesn't there and user allows aria2 to overwrite it. * src/messageDigest.h (~MessageDigestContext): Added digestFree(). * src/MetalinkRequestInfo.cc (execute): Set digestAlgo, chunkChecksum, chunkChecksums to reqInfo. * src/DiskAdaptor.h (messageDigest.h): New include. (sha1Sum): Renamed as messageDigest. (messageDigest): New function. * src/DownloadCommand.h (PeerStat.h): New include. (maxDownloadSpeedLimit): New variable. (startupIdleTime): New variable. (lowestDownloadSpeedLimit): New variable. (peerStat): New variable. (setMaxDownloadSpeedLimit): New function. (setStartupIdleTime): New function. (setLowestDownloadSPeedLimit): New function. * src/BtContext.h (getPieceHashes): New function. * src/main.cc (main): Set PREF_REALTIME_CHUNK_CHECKSUM and PREF_CHECK_INTEGRITY option to true for testing purpose. * src/BtPieceMessage.cc (checkPieceHash): Use messageDigest * src/DownloadEngine.cc (SetDescriptor): Removed. (AccumulateActiveCommand): Removed. (waitData): Rewritten. (updateFdSet): Rewritten. * src/MultiDiskAdaptor.cc (hashUpdate): Added ctx. (sha1Sum): Renamed as messageDigest. (messageDigest): New function. * src/BitfieldMan.h (isBitRangeSet): New function. (unsetBitRange): New function. * src/ByteArrayDiskWriter.h (sha1Sum): Renamed as messageDigest. (messageDigest): New function. * src/ConsoleDownloadEngine.cc (calculateStatistics): If nspeed < 0 then set nspeed to 0. * src/DiskWriter.h (messageDigest.h): New include. (sha1Sum): Renamed as messageDigest. (messageDigest): New function. * src/ChunkChecksumValidator.h: New class. * src/DiskAdaptorWriter.h: New class. * src/prefs.h (PREF_REALTIME_CHUNK_CHECKSUM): New definition. (PREF_CHECK_INTEGRITY): New definition. * src/HttpResponseCommand.cc (handleDefaultEncoding): Added method "HEAD" handling. Removed the call to e->segmentMan->shouldCancelDownloadForSafety(). (handleOtherEncoding): Added the call to e->segmentMan->shouldCancelDownloadForSafety(). (createHttpDownloadCommand): Set maxDownloadSpeedLimit, startupIdleTime, lowestDownloadSpeedLimit to command. * src/SegmentMan.h (getSegmentEntryByIndex): New function. (getSegmentEntryByCuid): New function. (getSegmentEntryIteratorByCuid): New function. (diskWriter): DiskWriter -> DiskWriterHandle (pieceHashes): New variable. (chunkHashLength): New variable. (digestAlgo): New variable. (FindPeerStat): Removed. (getPeerStat): Rewritten. (markAllPiecesDone): New function. (checkIntegrity): New function. (tryChunkChecksumValidation): New function. (isChunkChecksumValidationReady): New function. * src/BitfieldMan.cc (BitfieldMan): Initialized bitfieldLength, blocks to 0. (BitfieldMan): Initialized blockLength, totalLength, bitfieldLength, blocks to 0. (isBitRangeSet): New function. (unsetBitRange): New function. * src/FtpNegotiateCommand.cc (executeInternal): Set maxDownloadSpeedLimit, startupIdleTime, lowestDownloadSpeedLimit to command. (recvSize): Added method "HEAD" handling. Removed the call to e->segmentMan->shouldCancelDownloadForSafety(). * src/AbstractSingleDiskAdaptor.cc (sha1Sum): Renamed as messageDigest. (messageDigest): New function. * src/AbstractSingleDiskAdaptor.h (sha1Sum): Renamed as messageDigest. (messageDigest): New function. * src/Util.h (indexRange): New function. * src/MetalinkEntry.cc (MetalinkEntry): Initialized chunkChecksum to 0. * src/ShaVisitor.cc (~ShaVisitor): Removed the call to ctx.digestFree(). * src/SegmentMan.cc (ChunkChecksumValidator.h): New include. (SegmentMan): Initialized chunkHashLength to 0. Initialized digestAlgo to DIGEST_ALGO_SHA1. (~SegmentMan): Removed diskWriter. (FindSegmentEntryByIndex): Removed. (FindSegmentEntryByCuid): Removed. (checkoutSegment): Rewritten. (findSlowerSegmentEntry): Rewritten. (getSegment): Rewritten. (updateSegment): Rewritten. (completeSegment): Rewritten. (markAllPiecesDone): New function. (checkIntegrity): New function. (isChunkChecksumValidationReady): New function. (tryChunkChecksumValidation): New function. * src/Xml2MetalinkProcessor.cc (getEntry): Get size and set it to entry. Get chunk checksum and set it to entry. (getPieceHash): New function. * src/Util.cc (sha1Sum): Removed ctx.digestFree() (fileChecksum): Removed ctx.digestFree() (indexRange): New function. * src/Request.cc (METHOD_GET): New variable. (METHOD_HEAD): New variable. (Request): Added method. * src/UrlRequestInfo.cc (FatalException.h): New include. (message.h): New include. (operator<<): Added operator<< for class HeadResult. (getHeadResult): New function. (execute): Get filename and size in separate download engine. * src/ChunkChecksumValidator.cc: New class. * src/DownloadCommand.cc: (DownloadCommand): Added peerStat. (executeInternal): Use maxDownloadSpeedLimit member instead of getting the value from Option. The buffer size is now 16KB. Use peerStat member instead of getting it from SegmentMan. Use startupIdleTime member instead of gettingit from Option. Added chunk checksum validation. * src/AbstractDiskWriter.cc (AbstractDiskWriter): Removed ctx. (~AbstractDiskWriter): Removed ctx.digestFree() (writeDataInternal): Returns the return value of write. (readDataInternal): Returns the return value of read. (sha1Sum): Renamed as messageDigest (messageDigest): New function. * src/AbstractDiwkWriter.h (messageDigest.h): Removed include. (ctx): Removed. (sha1Sum): Renamed as messageDigest (messageDigest): New function. * src/DefaultPieceStorage.h (markAllPiecesDone): New function. (checkIntegrity): New function. * src/NullFileAllocationMonitor.h: New class. |
|
Tatsuhiro Tsujikawa | 3a412f89b2 |
2007-01-08 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To add an ability to pre-allocate file space: * src/DirectDiskAdaptor.h: Rewritten. * src/PieceStorage.h: DiskAdaptor -> DiskAdaptorHandle * src/MultiDiskAdaptor.h: Rewritten. * src/DefaultPieceStorage.cc (MultiDiskWriter.h): Removed include. (PreAllocationDiskWriter.h): Removed include. (FileAllocationMonitor.h): New include. (~DefaultPieceStorage): Removed deletion of diskAdaptor. (initStorage): Rewritten. (getDiskAdaptor): DiskAdaptor -> DiskAdaptorHandle * src/FileAllocator.h: New class. * src/FileAllocator.cc: New class. * src/FileAllocationMonitor.h: New class. * src/FileAllocationMonitor.cc: New class. * src/ConsoleFileAllocationMonitor.h: New class. * src/ConsoleFileAllocationMonitor.cc: New class. * src/AbstractSingleDiskAdaptor.h: New class. * src/AbstractSingleDiskAdaptor.cc: New class. * src/DiskAdaptor.h (Directory.h): Removed include. (DiskWriter.h): Removed include. (FileEntry.h): Removed include. (diskWriter): Removed. (DiskAdaptor): Removed diskWriter. (openFile): Made pure virtual. (closeFile): Made pure virtual. (openExistingFile): Made pure virtual. (initAndOpenFile): Made pure virtual. (writeData): Made pure virtual. (readData): Made pure virtual. (sha1Sum): Made pure virtual. (getStoreDir): Returns const reference of storeDir. (DiskAdaptorHandle): New type definition. * src/main.cc (ConsoleFileAllocationMonitor.h): New include. (showUsage): Added default value description of -s option. Added the description of --file-allocation option. (main): Set default value of --file-allocation option to 'none'. Added --file-allocation command-line option. Setup FileAllocationMonitorFactory. * src/FtpInitiateConnectionCommand.cc (executeInternal): Removed diskWriter related processing, which was moved to FtpNegotiationCommand.cc. * src/DirectDiskAdaptor.cc (getFilePath): Made non-const. * src/CopyDiskAdaptor.h (DiskAdaptor.h): Removed include. (DiskWriter.h): Removed include. (AbstractSingleDiskAdaptor.h): New include. (getFilePath): Made non-const. Added virtual keyword. (CopyDiskAdaptor): Removed diskWriter. (getTempFile): Returns const reference. (CopyDiskAdaptorHandle): New type definition. * src/ByteArrayDiskWriter.cc (clear): Simplified. (initAndOpenFile): Rewritten. (openFile): Call initAndOpenFile() * src/MultiDiskAdaptor.cc: Rewritten. * src/DownloadEngineFactory.cc (FileAllocator.h): New include. (FileAllocationMonitor.h): New include. (newConsoleEngine): Call DefaultDiskWriter::createNewDiskWriter() to create DefaultDiskWriter with file allocator. * src/DiskWriter.h (initAndOpenFile): Added totalLength argument. (openFile): Added totalLength argument. * src/prefs.h (PREF_FILE_ALLOCATION): New definition. (V_PREALLOC): New definition. (V_NONE): New definition. * src/HttpResponseCommand.cc (handleDefaultEncoding): Call DefaultDiskWriter::initAndOpenFile with size. * src/FtpNegotiateCommand.cc (Util.h): New include. (recvSize): Open file here. * src/Util.h (ullitos): New function. * src/CopyDiskWriter.h (getFilePath): Made non-const. * src/DefaultDiskWriter.h (Option.h): New include. (totalLength): Removed. (DefaultDiskWriter): Removed totalLength. (initAndOpenFile): Added totalLength argument. (DefaultDiskWriterHandle): New type definition. (createNewDiskWriter): New function. * src/Util.cc (ullitos): New function. * src/DefaultDiskWriter.cc (message.h): New include. (FileAllocator.h): New include. (prefs.h): New include. (Util.h): New include. (DefaultDiskWriter): Removed totalLength. (initAndOpenFile): Added file allocation. (createNewDiskWriter): New function. Just for temporary solution. It will be rewritten later. * src/DiskAdaptor.cc (DiskAdaptor): Removed diskWriter. * src/AbstractDiskWriter.cc (LogFactory.h): New include. (AbstractDiskWriter): Added fileAllocator, logger. (openFile): Added totalLength argument. * src/AbstractDiskWriter.h (FileAllocator.h): New include. (Logger.h): New include. (fileAllocator): New variable. (logger): New variable. (openFile): Added totalLength argument. Added virtual keyword explicitly. (openExistingFile): Added totalLength argument. Added virtual keyword explicitly. (closeFile): Added virtual keyword explicitly. (sha1Sum): Added virtual keyword explicitly. (writeData): Added virtual keyword explicitly. (readData): Added virtual keyword explicitly. (setFileAllocator): New function. * src/DefaultPieceStorage.h (FileAllocator.h): New include. (diskAdaptor): DiskAdaptor -> DiskAdaptorHandle (getDiskAdaptor): DiskAdaptor -> DiskAdaptorHandle * src/FileProgressMonitor.h: New class. To compile aria2 on PC-BSD: * src/DefaultBtContext.cc (libgen.h): New include. To fix memory leak: * src/Exception.h (~Exception): Delete cause. Fixed memory leak. |
|
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. |
|
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". |
|
Tatsuhiro Tsujikawa | b8737b0e7c |
2006-10-20 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To simplify TrackerWatherCommand, TrackerUpdateCommand and make the process of announce request testable. * src/TrackerWatcherCommand.h (TimeA2.h): Removed. (interval): Removed. (checkPoint): Removed. (createRequestCommand): Added an argument 'url'. (TrackerWatherCommand): Removed interval. (createCommand): New function. * src/DownloadEngineFactory.cc (newTorrentConsoleEngine): Updated according to the changes in TrackerWatherCommand. * src/TorrentMan.cc (DelegatingPeerListProcessor.h): New includes. (TorrentMan): Added the initialization of announceInterval. (isStoppedAnnounceReady): New function. (isCompletedAnnounceReady): New function. (isDefaultAnnounceReady): New function. (isAnnounceReady): New function. (getAnnounceUrl): New function. (announceStart): New function. (announceFailure): New function. (announceSuccess): New function. (isAllAnnounceFailed): New function. (resetAnnounce): New function. (processAnnounceResponse): New function. (needMorePeerConnection): New function. (noMoreAnnounce): New function. * src/TrackerUpdateCommand.h (getTrackerResponse): int->size_t * src/TorrentMan.h (isStoppedAnnounceReady): New function. (isCompletedAnnounceReady): New function. (isDefaultAnnounceReady): New function. (announceInterval): New variable. (isAnnounceReady): New function. (getAnnounceUrl): New function. (announceStart): New function. (announceFailure): New function. (announceSuccess): New function. (isAllAnnounceFailed): New function. (resetAnnounce): New function. (processAnnounceResponse): New function. (needMorePeerConnection): New function. (noMoreAnnounce): New function. * src/TrackerWatcherCommand.cc (TrackerWatherCommand): Removed interval and checkPoint. (execute): Rewritten. (createCommand): New function. (createRequestCommand): Rewritten. * src/TrackerUpdateCommand.cc (MetaFileUtil.h): Removed. (DelegatingPeerListProcessor.h): Removed. (getTrackerResponse): int->size_t. Use torrentMan's new functions. |
|
Tatsuhiro Tsujikawa | c0fd1fff2a |
2006-10-18 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Request -> RequestHandle: * src/HttpResponseCommand.h: Request->RequestHandle * src/AbstractCommand.cc: Request->RequestHandle * src/HttpDownloadCommand.cc: Request->RequestHandle * src/HttpRequestCommand.cc: Request->RequestHandle * src/FtpInitiateConnectionCommand.h: Request->RequestHandle * src/AbstractCommand.h: Request->RequestHandle * src/HttpProxyRequestCommand.h: Request->RequestHandle * src/HttpResponseCommand.cc: Request->RequestHandle * src/HttpInitiateConnectionCommand.h: Request->RequestHandle * src/FtpNegotiateCommand.cc: Request->RequestHandle * src/FtpTunnelResponseCommand.h: Request->RequestHandle * src/HttpConnection.h: Request->RequestHandle * src/HttpProxyResponseCommand.cc: Request->RequestHandle * src/InitiateConnectionCommandFactory.h: Request->RequestHandle * src/FtpTunnelResponseCommand.cc: Request->RequestHandle * src/DownloadCommand.h: Request->RequestHandle * src/FtpDowndloadCommand.cc: Request->RequestHandle * src/HttpInitiateConnectionCommand.cc: Request->RequestHandle * src/HttpRequestCommand.h: Request->RequestHandle * src/FtpNegotiateCommand.h: Request->RequestHandle * src/FtpTunnelResponseCommand.cc: Request->RequestHandle * src/FtpInitiateConnectionCommand.cc: Request->RequestHandle * src/HttpDownloadCommand.h: Request->RequestHandle * src/FtpConnection.cc: Request->RequestHandle * src/InitiateConnectionCommandFactory.cc: Request->RequestHandle * src/UrlRequestInfo.cc: Request->RequestHandle * src/HttpProxyResponseCommand.h: Request->RequestHandle * src/HttpConnection.h: Request->RequestHandle * src/DownloadCommand.cc: Request->RequestHandle * src/FtpConnection.h: Request->RequestHandle * src/FtpDowndloadCommand.h: Request->RequestHandle * src/HttpProxyRequestCommand.cc: Request->RequestHandle * src/FtpTunnelRequestCommand.h: Request->RequestHandle * src/Request.h (SharedHandle.h): New include. (RequestHandle): New type definition. (Requests): Redefined. To add MULTITRACKER support: * src/TrackerWatcherCommand.h (createRequestCommand): New function. * src/DownloadEngineFactory.cc (newTorrentConsoleEngine): Removed req. * src/prefs.h (PREF_TRACKER_MAX_TRIES): New definition. * src/TorrentMan.cc (TorrentMan): Removed req. Added trackerNumTry. (~TorrentMan): Removed req. (setupInternal1): Added announceList. * src/TorrentRequestInfo.cc (execute): Set PREF_MAX_TIRES to 1. The max number of tries for announces is now specified by PREF_TRACKER_MAX_TRIES. * src/main.cc (main): Added PREF_TRACKER_MAX_TRIES. * src/TorrentMan.h (Request.h): Removed. (AnnounceList.h): New include. (trackerNumTry): New variable. (req): Removed. (announceList): New variable. * src/TrackerWatcherCommand.cc (execute): Rewritten. (createRequestCommand): New function. * src/TrackerUpdateCommand.cc (execute): Updated with the use of AnnounceList. * src/AnnounceList.cc: New class. * src/AnnounceList.h: New class. To fix typo: * src/prefs.h (PREF_MAX_TRIES): max_try->max_tries To not to decode "+" as space in URL decode: * src/Util.cc (urldecode): Removed "+"->space decoding rule. Test case was updated. |
|
Tatsuhiro Tsujikawa | 07e91896e1 |
2006-10-01 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To add timeout to async name resolution: * src/AbstractCommand.h (nameResolveFinished): New function. This is not elegant way. It needs to be more refined. (nameResolverCheck): New variable. * src/AbstractCommand.cc (AbstractCommand): Added nameResolverCheck. (execute): Added the check whether the name resolution has finished. (setNameResolverCheck): Set nameResolverCheck to true. (disableNameResolverCheck): Set nameResolverCheck to false. (nameResolverFinished): New function. * src/FtpInitiateConnectionCommand.h (nameResolverFinished): New function. * src/HttpInitiateConnectionCommand.h (nameResolverFinished): New function. To add the support for a non-compact response from a tracker: * src/PeerListProcessor.h: New class. * src/DefaultPeerListProcessor.h: New class. * src/DefaultPeerListProcessor.cc: New class. * src/CompactPeerListProcessor.h: New class. * src/CompactPeerListProcessor.cc: New class. * src/DelegatingPeerListProcessor.h: New class. * src/DelegatingPeerListProcessor.cc: New class. * src/TorrentMan.cc (addPeer): New function(overload). (addPeer): Delete unused peers only when new peer is added. * src/TorrentMan.h (PeerListProcessor.h): Included. (Peers): Removed. (addPeer): New function(overload). * src/TrackerUpdateCommand.cc (netinet/in.h): Removed. (DelegatingPeerListProcessor.h): Included. (execute): Updated to use DelegatingPeerListProcessor. To fix the memory leak in TorrentMan::peers: * src/PeerAbstractCommand.cc (onAbort): Added peer->resetStatus(). * src/Peer.h (resetStatus): Made public. To improve the precision of the speed calculation: * src/SpeedCalc.h (nextInterval): New variable. * src/SpeedCalc.cc (reset): Added nextInterval. (isIntervalOver): Use nextInterval instead of CHANGE_INTERVAL_SEC. (changeSw): Set nextInterval to 15 seconds relative to the current instant time. * src/main.cc (showVersion): Updated. |
|
Tatsuhiro Tsujikawa | 2fb9b5be97 |
2006-09-19 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To rewrite segment download mechanism for HTTP/FTP download. Use BitfieldMan to manage segment download. * src/HttpResponseCommand.h (executeInternal): Pass the reference of segment. * src/AbstractCommand.cc (prepareForRetry): Call segmentMan->cancelSegment here. (onAbort): Call segmentMan->cancelSegment here. * src/HttpDownloadCommand.cc (prepareForNextSegment): New function. * src/DownloadEngineFactory.cc (newConsoleEngine): Removed splitter. (newTorrentConsoleEngine): Removed splitter. * src/Request.h (segment): Renamed from seg. * src/FtpInitiateConnectionCommand.h (executeInternal): Pass the reference of segment. * src/AbstractCommand.h (executeInternal): Pass the reference of segment. * src/pref.h (PREF_SEGMENT_SIZE): New definition. * src/HttpProxyRequestCommand.h (executeInternal): Pass the reference of segment. * src/HttpResponseCommand.cc (checkResponse): Allowed status 206 when a request range starts 0. (handleDefaultEncoding): Rewritten the code related to Segment. (handleOtherEncoding): Rewritten the code related to Segment. * src/SegmentMan.h (SegmentEntry): New class. (SegmentEntries): New type definition. (bitfield): New variable. (usedSegmentEntries): New variable. (onNullBitfield): New function. (checkoutSegment): New function. (segments): Removed. (splitter): Removed. (unregisterId): Removed. (getSegment): New function(overload) (getDownloadedSize): Removed. (cancelSegment): New function. (completeSegment): New function. (initBitfield): New function. (hasSegment): New function. (getDownloadLength): New function. * src/BitfieldMan.h (getStartIndex): New function. (getEndIndex): New function. (getMissingUnusedIndex): New function(overload). (getSparseMissingUnusedIndex): New function. * src/BitfieldMan.cc (getMissingIndexRandomly): Handle the last byte of bitfield properly. (getMissingUnusedIndex): New function(overload). (Range): New class. (getStartIndex): New function. (getEndIndex): New function. (getSparseMissingUnusedIndex): New function. (isBitSetInternal): Return false if the given index is less than 0. * src/HttpInitiateConnectionCommand.h (executeInternal): Pass the reference of segment. * src/FtpNegotiateCommand.h (executeInternal): Pass the reference of segment. * src/FtpNegotiateCommand.cc (recvSize): Initialize bitfield here. * src/FtpTunnelResponseCommand.h (executeInternal): Pass the reference of segment. * src/HttpConnection.cc (createRequest): Rewritten range header processing. * src/DownloadCommand.h (executeInternal): Pass the reference of segment. (prepareForRetry): Removed. (prepareForNextSegment): Added an argument segment. Made it a virtual function. * src/main.cc (main): Set the initial value of PREF_SEGMENT_SIZE to 1MB. * src/SegmentMan.cc (SegmentMan): Added bitfield. Removed splitter. (~SegmentMan): Added bitfield. Removed splitter. (unregisterId): Removed. (getSegment): Rewritten. (updateSegment): Rewritten. (save): Rewritten. (read): Rewritten. (finished): Rewritten. (getDownloadedSize): Removed. (initBitfield): New function. (FindSegmentEntryByIndex): New function object. (FindSegmentEntryByCuid): New function object. (checkoutSegment): New function. (onNullBitfield): New function. (getSegment): New function(overload). (CancelSegment): New function object. (cancelSegment): New function. (completeSegment): New function. (hasSegment): New function. (getDownloadLength): New function. * src/FtpInitiateConnectionCommand.cc (executeInternal): Load .aria2 file after hostname resolution finishes. * src/Segment.h: Rewritten. * src/Segment.cc (operator<<): New function. * src/HttpDownloadCommand.h (prepareForNextSegment): New function. * src/Request.cc (resetUrl): Made segment null. * src/DownloadEngine.cc (~DownloadEngine): Call cleanQueue before deleting segmentMan. * src/HttpProxyRequestCommand.h (executeInternal): Pass the reference of segment. * src/DownloadCommand.cc (executeInternal): Rewritten the code related to Segment. (prepareForRetry): Removed. (prepareForNextSegment): Rewritten. * src/FtpTunnelResponseCommand.h (executeInternal): Pass the reference of segment. To add HTTP 1.1 persistent connection support(experimental) * src/HttpRequestCommand.cc (executeInternal): Disable keep alive if it is disabled by configuration. * src/Request.h (keepAlive): New variable. (isKeepAlive): New function. (setKeepAlive): New function. * src/pref.h (PREF_HTTP_KEEP_ALIVE): New definition. * src/HttpResponseCommand.cc (executeInternal): Check the remote server supports keep alive. * src/HttpConnection.cc (createRequest): Send "Connection: close" only if keep alive is disabled. * src/main.cc (main): Set the initial value(false) of PREF_KEEP_ALIVE to false. To add max download speed limit: * src/pref.h (PREF_MAX_SPEED_LIMIT): New definition. * src/PeerInteractionCommand.cc (executeInternal): Added max download speed limit. Not tested yet. * src/SegmentMan.h (PeerStats): New type definition. (peerStats): New variable. (registerPeerStat): New function. (FindPeerStat): New function object. (getPeerStat): New function. (calculateDownloadSpeed): New function. * src/SpeedCalc.h: New class. * src/SpeedCalc.cc: New class. * src/main.cc (main): Set the initial value of PREF_MAX_SPEED_LIMIT to 0(which means the download speed is not restricted). * src/PeerStat.h: New class. * src/SegmentMan.cc (registerPeerStat): New function. (calculateDownloadSpeed): New function. * src/DownloadCommand.cc (STARTUP_IDLE_TIME): New definition. (DownloadCommand): Register peerStat to segmentMan. Call peerStat-> downloadStart. (~DownloadCommand): Call peerStat->downloadStop. (executeInternal): Added download speed limitter. Rewritten lowest speed limitter. * src/HttpConnection.cc (receiveResponse): Fixed: eohIndex[headerBuf] -> headerBuf[eohIndex]. * src/AbstractCommand.cc (resolveHostname): Throw DlAbortEx if a name resolution failes. Added hostname to the error message. * src/ConsoleDownloadEngine.cc (calculateStatistics): Initialize psize with dlSize. * src/PieceMessage.cc (receivedAction): Do not call peerInteraction->abortPiece here. (onGotWrongPiece): Call peerInteraction->abortPiece here. * src/BitfieldMan.h (clearAllUseBit): New function. (setAllUseBit): New function. * src/BitfieldMan.cc (clearAllBit): Do not clear useBitfield here. (clearAllUseBit): New function. (setAllUseBit): New function. * src/Piece.cc (clearAllBlock): Call bitfield->clearAllUseBit(). |
|
Tatsuhiro Tsujikawa | 3b2a98393e |
2006-08-27 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To add --seed-time and --seed-ratio command-line option: * src/Option.h (getAsDouble): New function. * src/Option.cc (getAsDouble): New function. * src/SeedCheckCommand.h: New class. * src/SeedCheckCommand.cc: New class. * src/DownloadEngineFactory.cc (SeedCheckCommand.h): Included. (UnionSeedCriteria.h): Included. (TimeSeedCriteria.h): Included. (ShareRatioSeedCriteria.h): Included. (newTorrentConsoleEngine): Added the processing of seed option. * src/SeedCriteria.h: New class. * src/ShareRatioSeedCriteria.h: New class. * src/TimeSeedCriteria.h: New class. * src/UnionSeedCriteria.h: New class. * src/prefs.h (PREF_SEED_TIME): New definition. (PREF_SEED_RATIO): New definition. * src/main.cc (showUsage): Added --seed-time and --seed-ratio option. (main): Added --seed-time and --seed-ratio option. Made default log file name "/dev/null". * src/SharedHandle.h (SharedHandle): Copy constructor. Made it assignable from the SharedHandle of the subclasses. (operator=): Made it assignable from the SharedHandle of the subclasses. (getRefCount): New function. To add notice log level and the switch to write log to stdout. This switch is configurable per log level. * src/Logger.h (notice): New function. (LEVEL): Added NOTICE. Assigned an explicit value to each log level constant. * src/LogFactory.cc (getInstance): The use of NullLogger was removed. A log message with notice log level was made written to stdout along with log file. * src/NullLogger.h (notice): New function. * src/SimpleLogger.h (writeHeader): Added the 'file' argument. (writeLog): Added the 'file' argument. (writeFile): New function. (stdoutField): New variable. (SimpleLogger): Removed the default constructor. (SimpleLogger): Made the default value of logfile 0. (debug): Added 'virtual' keyword. (info): Added 'virtual' keyword. (warn): Added 'virtual' keyword. (error): Added 'virtual' keyword. (notice): New function. (setStdout): New function. * src/SimpleLogger.cc (WRITE_LOG): Replaced writeLog with writeFile. (WRITE_LOG_EX): Replaced writeLog with writeFile. (SimpleLogger): Removed the default constructor. (setStdout): New function. (writeLog): Added the handling of NOTICE log level. (writeFile): New function. (notice): New function. * src/TorrentMan.h: Updated doc. * src/BitfieldMan.h: Updated doc. * src/TrackerWatcherCommand.cc (execute): Return true if error occurred in the request to the tracker and halt is requested. * src/TrackerUpdateCommand.cc (execute): Return true if error occurred in the request to the tracker and halt is requested. * src/TorrentConsoleDownloadEngine.h (onSelectiveDownloadingCompletes): Removed. * src/TorrentConsoleDownloadEngine.cc (onSelectiveDownloadingCompletes): Removed. * src/TorrentDownloadEngine.h (onEndOfRun): Added 'virtual' keyword. (afterEachIteration): Removed. (onSelectiveDownloadingCompletes): Removed. * src/TorrentDownloadEngine.cc (onEndOfRun): Removed filenameFixed. (afterEachIteration): Removed. * src/TorrentMan.cc (completePiece): Call onDownloadComplete here. (onDownloadComplete): Added 2 log messages. |
|
Tatsuhiro Tsujikawa | 4def45feb2 |
2006-08-21 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To fix compilation problem on gcc4.1.1(patch#1542283 by tizianomueller) * src/NameResolver.h: Added the prototype declaration of callback(). To support c-ares library: * src/AbstractCommand.cc: Replaced HAVE_LIBARES with ENABLE_ASYNC_DNS * src/FeatureConfig.cc: Replaced HAVE_LIBARES with ENABLE_ASYNC_DNS * src/FtpInitiateConnectionCommand.h: Replaced HAVE_LIBARES with ENABLE_ASYNC_DNS * src/AbstractCommand.h: Replaced HAVE_LIBARES with ENABLE_ASYNC_DNS * src/HttpInitiateConnectionCommand.h: Replaced HAVE_LIBARES with ENABLE_ASYNC_DNS * src/NameResolver.cc: Replaced HAVE_LIBARES with ENABLE_ASYNC_DNS * src/HttpInitiateConnectionCommand.cc: Replaced HAVE_LIBARES with ENABLE_ASYNC_DNS * src/FtpInitiateConnectionCommand.cc: Replaced HAVE_LIBARES with ENABLE_ASYNC_DNS * src/DownloadEngine.h: Replaced HAVE_LIBARES with ENABLE_ASYNC_DNS * src/DownloadEngine.cc: Replaced HAVE_LIBARES with ENABLE_ASYNC_DNS |
|
Tatsuhiro Tsujikawa | f2d4faad08 |
2006-08-11 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To add asynchronous DNS support(libares): * src/AbstractCommand.h (setNameResolverCheck): New function. (disableNameResolverCheck): New function (resolveHostname): New function. * src/AbstractCommand.cc (setNameResolverCheck): New function. (disableNameResolverCheck): New function (resolveHostname): New function. * src/FtpInitiateConnectionCommand.h (nameResolver): New function. * src/FtpInitiateConnectionCommand.cc (Util.h): Included. (FtpInitiateConnectionCommand): Call disableReadCheckSocket, disableWriteCheckSocket. (~FtpInitiateConnectionCommand): Call disableNameResolverCheck. (executeInternal): Added async DNS support. * src/HttpInitiateConnectionCommand.h (nameResolver): New function. * src/HttpInitiateConnectionCommand.cc (DlRetryEx.h): Included. (HttpInitiateConnectionCommand): Call disableReadCheckSocket, disableWriteCheckSocket. (~HttpInitiateConnectionCommand): Call disableNameResolverCheck. (executeInternal): Added async DNS support. * src/NameResolver.h: New class. Note: #include <ares.h> is surrounded by extern "C" declaration. * src/NameResolver.cc: New class. * src/Util.h: (isNumberAndDotsNotation): New function * src/Util.cc (isNumberAndDotsNotation): New function. * src/DownloadEngine.h (NameResolver.h): Included. (NameResolverEntry): New class. (NameResolverEntries): New type definition. (addNameResolverCheck): New function. (deleteNameResolverCheck): New function. * src/DownloadEngine.cc (run): Initialize cp with 0. (SetDescriptor::operator()): Added for NameResolverEntry. (AccumulateActiveUuid::operator()): Added for NameResolverEntry. (waitData): Check nameResolver entries. (updateFdSet): Update fds in nameResolver entries. (addNameResolverCheck): New function. (deleteNameResolverCheck): new function. * src/PeerInteractionCommand.cc (executeInternal): Fixed wrong socket handling. * src/main.cc (main): Fixed the initial value of PREF_LOWEST_SPEED_LIMIT option to 0. * src/Util.cc (fileChecksum): Removed the call to ctx.digestReset(). |
|
Tatsuhiro Tsujikawa | 928465b7bc |
2006-07-30 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* src/TorrentMan.h: (advertisePiece): Updated doc. (getAdvertisedPieceIndexes): Updated doc. (removeAdvertisedPiece); New function. * src/TorrentMan.cc (FindElapsedHave): New function object. (removeAdvertisedPiece): New function. * src/HaveEraseCommand.h: New class. * src/HaveEraseCommand.cc: New class. * src/FeatureConfig.h: New class. * src/FeatureConfig.cc: New class. * src/Request.h (defaultPorts): Removed. * src/Request.cc (FeatureConfig.h): Included. (Request): Removed the statements related to defaultPorts. (parseUrl): Removed metalinkEnabled. Use FeatureConfig instead. A default port number is now retrieved from FeatureConfig. * src/main.cc (HaveEraseCommand.h): Included. (showVersion): Added the output of feature list. (main): Added HaveEraseCommand to command queue in BitTorrent downloading. * src/PeerInteractionCommand.h (chokeCheckPoint): Commented out. (periodicExecPoint): New variable. * src/PeerInteractionCommand.cc (executeInternal): Following methods are now called in at least every 0.5 seconds to reduce CPU usage: detectMessageFlooding(), peerInteraction->checkRequestSlot(), checkHave(), sendKeepAlive(). (checkLongTimePeerChoking): Commented out. * src/BitfieldMan.h (getNthBitIndex): Changed the method signature. (getMissingIndexRandomly): Changed the method signature. * src/BitfieldMan.cc (getNthBitIndex): Rewritten (getMissingIndexRandomly): Rewritten. (hasMissingPiece): Rewritten. (getMissingIndex): Refactored. (getMissingUnusedIndex); Refactored. (getMissingIndex): Refactored. |
|
Tatsuhiro Tsujikawa | 31cf446f6d |
2006-07-04 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To improve the conditional compilation: * src/MultiDiskWriter.h: Replaced ENABLE_SHA1DIGEST with ENABLE_MESSAGE_DIGEST. * src/MultiDiskWriter.cc: Replaced ENABLE_SHA1DIGEST with ENABLE_MESSAGE_DIGEST. * src/Util.h: Replaced ENABLE_SHA1DIGEST with ENABLE_MESSAGE_DIGEST. Added ENABLE_BITTORRENT around computeFastSet(). * src/Util.cc: Replaced ENABLE_SHA1DIGEST with ENABLE_MESSAGE_DIGEST. Added ENABLE_BITTORRENT around computeFastSet(). * src/messageDigest.h: Replaced ENABLE_BITTORRENT with ENABLE_SSL. * src/ShaVisitor.h: Replaced ENABLE_SHA1DIGEST with ENABLE_MESSAGE_DIGEST. * src/ShaVisitor.cc: Replaced ENABLE_SHA1DIGEST with ENABLE_MESSAGE_DIGEST. * src/main.cc: Added ENABLE_BITTORRENT around includes and blocks related to BitTorrent. * src/AbstractDiskWriter.h: Replaced ENABLE_SHA1DIGEST with ENABLE_MESSAGE_DIGEST. * src/AbstractDiskWriter.cc: Replaced ENABLE_SHA1DIGEST with ENABLE_MESSAGE_DIGEST. To add command-line options for Metalink: * src/main.cc: Added metalink-version, metalink-language, metalink-os, follow-metalink. To use EXIT_SUCCESS and EXIT_FAILURE with exit(): * src/main.cc: Use these definition. |
|
Tatsuhiro Tsujikawa | 78eff23254 |
2006-07-03 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To add Metalink support(http/ftp only): * src/AbstractCommand.h (tryReserved): New function. * src/AbstractCommand.cc (execute): Call tryReserved(). (tryReserved): New function. * src/Request.h (Requests): New type definition. * src/SegmentMan.h (reserved): New variable. * src/Util.h (fileChecksum): New function. (toUpper): New function. (toLower): New function. * src/Util.cc (messageDigest.h): Included. (trim): Trim \r\n\t. (fileChecksum): New function. (toUpper): New function. (toLower): New function. * src/main.cc (normalDownload): New function. (main): Added 2 command-line options: metalink-file, metalink-connection. Their usage has not been written yet. * src/MetalinkProcessor.h: New class. * src/Xml2MetalinkProcessor.h: New class. * src/Xml2MetalinkProcessor.cc: New class. * src/MetalinkEntry.h: New class. * src/MetalinkEntry.cc: New class. * src/MetalinkResource.h: New class. * src/MetalinkResource.cc: New class. To add md5 message digest checking: * src/messageDigest.h: Rewritten. * src/MultiDiskWriter.cc: Updated according to the changes in messageDigest.h. * src/ShaVisitor.cc: Updated according to the changes in messageDigest.h. * src/Util.cc: Updated according to the changes in messageDigest.h. * src/AbstractDiskWriter.cc: Updated according to the changes in messageDigest.h. To fix a bug that causes segfault when the payload length in peer message is less than 0: * src/PeerConnection.cc: (receiveMessage): Fixed the bug. * src/PeerMessageUtil.cc (checkLength): Throw an exception if length is less than or equals to 0. To add new interfaces to Base64 encoding/decoding: * src/Base64.h (part_encode): Changed the method signature. (encode): New function(overload). (decode): New function(overload). * src/Base64.cc (part_encode): Rewritten. (encode): Rewritten. (encode): New function(overload). To prevent a peer to download same piece if there is an error in checksum: * src/PieceMessage.cc (receivedAction): Call peerInteraction->abortPiece(). |
|
Tatsuhiro Tsujikawa | d018b3a609 |
2006-05-18 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To remove a wait from download loop: * src/DownloadEngine.cc (run): Comment out shortSleep. To rewrite the message handling: * src/CancelMessage.h: Derived from SimplePeerMessage. (msg): New variable. (create): New function. (send): Removed. (getMessage): New function. (getMessageLength): New function. * src/CancelMessage.cc (create): New function. (receivedAction): Replaced deleteRequestMessageInQueue with rejectPieceMessageInQueue. (send): Removed. (getMessage): New function. (getMessageLength): New function. * src/BitfieldMessage.h: Derived from SimplePeerMessage. (msg): New variable. (msgLength): New variable. (~BitfieldMessage): Deleted msg. (send): Removed. (getMessage): New function. (getMessageLength): New function. * src/BitfieldMessage.cc (create): New function. (send): Removed. (getMessage): New function. (getMessageLength): New function. * src/ChokeMessage.h: Derived from SimplePeerMessage. (msg): New variable. (sendPredicate): New function. (onSendComplete): New function. (send): Removed. (getMessage): New function. (getMessageLength): New function. (create): New function. * src/ChokeMessage.cc (create): New function. (send): Removed. (sendPredicate): New function. (getMessage): New function. (getMessageLength): New function. (onSendComplete): New function. * src/KeepAliveMessage.h: Derived from SimplePeerMessage. (msg): New variable. (send): Removed. (getMessage): New function. (getMessageLength): New function. * src/KeepAliveMessage.cc (send): Removed. (getMessage): New function. (getMessageLength): New function. * src/PortMessage.h (create): New function. (receivedAction): Updated log message. * src/PortMessage.cc: New file. * src/UnchokeMessage.h: Derived from SimplePeerMessage. (msg): New variable. (sendPredicate): New function. (onSendComplete): New function. (create): New function. (send): Removed. (getMessage): New function. (getMessageLength): New function. * src/UnchokeMessage.cc (create): New function. (send): Removed. (sendPredicate): New function. (getMessage): New function. (getMessageLength): New function. (onSendComplete): New function. * src/PieceMessage.h (leftPieceDataLength): Removed. (leftDataLength): New variable. (headerSend): New variable. (pendingCount): New variable. (msgHeader): New variable. (sendPieceData): New function. (incrementPendingCount): New function. (isPendingCountMax): New function. (create): New function. (getMessageHeader): New function. (getMessageHeaderLength): New function. * src/PieceMessage.cc (create): New function. (getMessageHeader): New function. (getMessageHeaderLength): New function. (send): Rewritten. (sendPieceData): New function. * src/HaveMessage.h: Derived from SimplePeerMessage. (msg): New variable. (create): New function. (getMessage): New function. (getMessageLength): New function. * src/HaveMessage.cc (create): New function. (send): Removed. (sendPieceData): New function. (getMessage): New function. (getMessageLength): New function. * src/RequestMessage.h: Derived from SimplePeerMessage. (msg): New variable. (create): New function. (send): Removed. (getMessage): New function. (getMessageLength): New function. * src/RequestMessage.cc (create): New function. (receivedAction): Added the handling of fast extension. Deleted torrentMan->addUploadLength, torrentMan->addDeltaUploadLength. (send): Removed. (getMessage): New function. (getMessageLength): New function. * src/InterestedMessage.h: Derived from SimplePeerMessage. (msg): New variable. (sendPredicate): New function. (onSendComplete): New function. (create): New function. (getMessage): New function. (getMessageLength): New function. * src/InterestedMessage.cc (create): New function. (send): Removed. (sendPieceData): New function. (getMessage): New function. (getMessageLength): New function. (onSendComplete): New function. * src/NotInterestedMessage.h: Derived from SimplePeerMessage. (msg): New variable. (sendPieceData): New function. (onSendComplete): New function. (create): New function. (send): Removed. (getMessage): New function. (getMessageLength): New function. * src/NotInterestedMessage.cc (create): New function. (send): Removed. (sendPredicate): New function. (getMessage): New function. (getMessageLength): New function. (onSendComplete): New function. * src/AllowedFastMessage.h: New class. * src/AllowedFastMessage.cc: New class. * src/RejectMessage.h: New class. * src/RejectMessage.cc: New class. * src/SuggestPieceMessage.h: New class. * src/SuggestPieceMessage.cc: New class. * src/HaveAllMessage.h: New class. * src/HaveAllMessage.cc: New class. * src/HaveNoneMessage.h: New class. * src/HaveNoneMessage.cc: New class. * src/HandshakeMessage.h: Derived from SimplePeerMessage. (msg): New variable. (reserved): New variable. (create): New function. (getId): New function. (receivedAction): New function. (getMessage): New function. (getMessageLength): New function. (isFastExtensionSupported): New function. * src/HandshakeMessage.cc (HandshakeMessage): Moved here from HandshakeMessage.h. (create): New function. (getMessage): New function. (getMessageLength): New function. (toString): Added the output of reserved field. (check): Added const qualifier. (isFastExtensionSupported): New function. * src/PeerMessageUtil.h (createChokeMessage): Removed. (createUnchokeMessage): Removed. (createInterestedMessage): Removed. (createNotInterestedMessage): Removed. (createHaveMessage): Removed. (createBitfieldMessage): Removed. (createRequestMessage): Removed. (createCancelMessage): Removed. (createPieceMessage): Removed. (createPortMessage): Removed. (createChokeMessage): Removed. (createUnchokeMessage): Removed. (createInterestedMessage): Removed. (createNotInterestedMessage): Removed. (createHaveMessage): Removed. (createBitfieldMessage): Removed. (createRequestMessage): Removed. (createCancelMessage): Removed. (createPieceMessage): Removed. (createKeepAliveMessage): Removed. (createHandshakeMessage): Removed. (setIntParam): New function. (createPeerMessageString): New function. * src/PeerMessageUtil.cc (createChokeMessage): Removed. (createUnchokeMessage): Removed. (createInterestedMessage): Removed. (createNotInterestedMessage): Removed. (createHaveMessage): Removed. (createBitfieldMessage): Removed. (createRequestMessage): Removed. (createCancelMessage): Removed. (createPieceMessage): Removed. (createPortMessage): Removed. (createRequestMessage): Removed. (createCancelMessage): Removed. (createPieceMessage): Removed. (createHaveMessage): Removed. (createChokeMessage): Removed. (createUnchokeMessage): Removed. (createInterestedMessage): Removed. (createNotInterestedMessage): Removed. (createBitfieldMessage): Removed. (createKeepAliveMessage): Removed. (createHandshakeMessage): Removed. (setIntParam): New function. (createPeerMessageString): New function. * src/PeerConnection.h (peer): Removed. (torrentMan): Removed. (createNLengthMessage): Removed. (setIntParam): Removed. (writeOutgoingMessageLog): Removed all overloaded functions. (PeerConnection): Deleted peer and torrentMan from its arguments. (sendMessage): New function. (sendHandshake): Removed. (sendKeepAlive): Removed. (sendChoke): Removed. (sendUnchoke): Removed. (sendInterested): Removed. (sendNotInterested): Removed. (sendHave): Removed. (sendBitfield): Removed. (sendRequest): Removed. (sendPiece): Removed. (sendPieceHeader): Removed. (sendPieceData): Removed. (sendCancel): Removed. (getPeer): Removed. * src/PeerConnection.cc (PeerConnection): Deleted peer and torrentMan from its arguments. (sendHandshake): Removed. (sendKeepAlive): Removed. (createNLengthMessage): Removed. (setIntParam): Removed. (writeOutgoingMessageLog): Removed all overloaded functions. (sendChoke): Removed. (sendUnchoke): Removed. (sendInterested): Removed. (sendNotInterested): Removed. (sendHave): Removed. (sendBitfield): Removed. (sendRequest): Removed. (sendPiece): Removed. (sendPieceHeader): Removed. (sendPieceData): Removed. (sendMessage): New function. (sendCancel): Removed. * src/PeerInteractionCommand.cc (PeerInteractionCommand): Call setUploadLimit. (executeInternal): Call setUploadLimit. Added the handling of "inProgress" state of handshake message. Call sendBitfield() or sendAllowdFast() instead of deprecated sendNow(). (keepAlive): Call addMessage and sendMessage instead of deprecated sendNow(). (beforeSocketCheck): Call addMessage instead of deprecated trySendNow() * src/TorrentMan.h (PEER_ID_LENGTH): New definition. (hasAllPieces): New function. * src/TorrentMan.cc (getMissingPiece): Added the handling of fast extension. (cancelPiece): Call updatePiece(). (hasAllPieces): New function. * src/PeerInteraction.h (fastSet): New variable. (getNewPieceAndSendInterest): Changed the return type to void. (send): Renamed as sendMessages. (deleteAllRequestSlot): Removed. (deleteRequestMessageInQueue): Renamed as rejectPieceMessageInQueue. (cancelAllRequest): Removed all overloaded functions. (deleteAllRequestSlot): Removed. (deletePieceMessageInQueue): Renamed as rejectAllPieceMessageInQueue. (rejectPieceMessageInQueue): New function. (rejectAllPieceMessageInQueue): New function. (onChoked): New function. (isSendingMessageInProgress): New function. (getCorrespondingRequestSlot): Changed its arguments. (isInFastSet): New function. (addFastSetIndex): New function. (addRequests): New function. (sendNow): Removed. (trySendNow): Removed. (sendBitfield): New function. (sendAllowdFast): New function. (createHaveAllMessage): New function. (createHaveNoneMessage): New function. (createRejectMessage): New function. (createAllowedFastMessage): New function. * src/PeerInteraction.cc (send): Renamed as sendMessages. (sendMessages): New function. (MsgPushBack): New class. (isSendingMessageInProgress): New function. (deletePieceMessageInQueue): Renamed as rejectAllPieceMessageInQueue. (rejectAllPieceMessageInQueue): New function. Added the handling of fast extension. (deleteRequestMessageInQueue): Renamed as rejectPieceMessageInQueue. (rejectPieceMessageInQueue): New function. Added the handling of fast extension. (deleteRequestSlot): Replaced for loop with std::find. (onChoked): New function. (deleteAllRequestSlot): Removed. (abortPiece): Rewirtten. (deleteTimeoutRequestSlot): Updated log messages. (getCorrespondingRequestSlot): Changed its arguments. (cancelAllRequest): Removed all overloaded functions. (receiveHandshake): Added the check to see whether an incoming peer supports fast extension. (createHandshakeMessage): Use HandshakeMessage::create instead of PeerMessageUtil. (createPeerMessage): Use create() of each message class instead of PeerMessageUtil. HaveAllMessage, HaveNoneMessage, RejectMessage, SuggestPieceMessage, AllowedFastMessage were added. (getNewPieceAndSendInterest): Changed its return value type to void. Added the handling of fast extension. (addRequests): New function. (sendNow): Removed. (sendHandshake): Rewritten. (trySendNow): Removed. (sendBitfield): New function. (sendAllowdFast): New function. (isInFastSet): New function. (addFastSetIndex): New function. (createRequestMessage): Use RequestMessage::create instead of PeerMessageUtil. (createCancelMessage): Use CancelMessage::create instead of PeerMessageUtil. (createPieceMessage): Use PieceMessage::create instead of PeerMessageUtil. (createHaveMessage): Use HaveMessage::create instead of PeerMessageUtil. (createChokeMessage): Use ChokeMessage::create instead of PeerMessageUtil. (createUnchokeMessage): Use UnchokeMessage::create instead of PeerMessageUtil. (createInterestedMessage): Use InterestedMessage::create instead of PeerMessageUtil. (createNotInterestedMessage): Use NotInterestedMessage::create instead of PeerMessageUtil. (createBitfieldMessage): Use BitfieldMessage::create instead of PeerMessageUtil. (createKeepAliveMessage): Use KeepAliveMessage::create instead of PeerMessageUtil. (createHaveAllMessage): New function. (createHaveNoneMessage): New function. (createRejectMessage): New function. (createAllowedFastMessage: New function. * src/Util.h (sha1Sum): New function. (computeFastSet): New function. * src/Util.cc (sha1Sum): New function. (computeFastSet): New function. * src/Peer.h (fastExtensionEnabled): New variable. (fastSet): New variable. (setAllBitfield): New function. (setFastExtensionEnabled): New function. (isFastExtensionEnabled): New function. (addFastSetIndex): New function. (getFastSet): New function. (isInFastSet): New function. (countFastSet): New function. * src/Peer.cc (isInFastSet): New function. (addFastSetIndex): New function. (setAllBitfield): New function. * src/AbstractCommand.cc (execute): Changed the procedure of checking sockets. * src/PeerAbstractCommand.cc (PeerAbstractCommand): Added the initialization for uploadLimitCheck and uploadLimit. (execute): Changed the procedure of checking sockets. The upload speed checking were added. (setUploadLimit): New function. (setUploadLimitCheck): New function. * src/PeerAbstractCommand.h (setUploadLimit): New function. (setUploadLimitCheck): New function. (uploadLimit): New variable. (uploadLimitCheck): New variable. To contact a tracker regularly: * src/TrackerWatcherCommand.h (interval): New variable. (checkPoint): New variable. (TrackerWatcherCommand): Added interval argument. * src/TrackerWatcherCommand.cc (TrackerWatcherCommand): Initialized checkPoint. (execute): Now a tracker is contacted in every specified period. If peer list is not needed, send request with numwant=0. * src/TrackerUpdateCommand.cc (execute): Updated log messages. * src/DownloadEngine.cc (~DownloadEngine): Removed two asserts. (waitData): Uncommented wfds. May be a bug fix. |
|
Tatsuhiro Tsujikawa | ba23d6061a | ||
Tatsuhiro Tsujikawa | 2f4b3f7d02 |
2006-04-12 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To add the ability to download multi torrent into respective files directly: * src/DiskWriter.h (openFile): New function. (seek): Removed. * src/MultiDiskWriter.h: New class. * src/MultiDiskWriter.cc: New class. * src/AbstractDiskWriter.h (seek): Changed its scope from public to protected. (openFile): New function. * src/AbstractDiskWriter.cc (openFile): New function. * src/prefs.h (V_FALSE): New definition. (PREF_DIRECT_FILE_MAPPING): New definition. * src/TorrentMan.h (setupDiskWriter): New function. (setAllMultiFileRequestedState): New function. (onDownloadComplete): New function. * src/TorrentMan.cc : Included MultiDiskWriter.h (setupDiskWriter): New function. (getFilePath): Updated. (getTempFilePath): Updated. (getSegmentFilePath): Updated. (fixFilename): Updated. (deleteTempFile): Updated. (setAllMultiFileRequestedState): New function. (setFileEntriesToDownload): Use setAllMultiFileRequestedState(). (finishPartialDownloadingMode): Reset requested flags. (onDownloadComplete): New function. * src/main.cc: Added --direct-file-mapping option. Use TorretMan::setupDiskWriter(). * src/TorrentDownloadEngine.cc (afterEachIteration): Use TorrentMan:: onDownloadComplete(). To fix ETA bug: * src/Util.h (difftvsec): New function. * src/Util.cc (difftvsec): New function. * src/TorrentConsoleDownloadEngine.cc (calculateSpeed): Use int for the type of "elapsed" instead of long long int. (calculateStatistics): Use Util::difftvsec instead of Util::difftv. The updates of statistics takes place every 1 seconds. * src/TorrentConsoleDownloadEngine.h (lastElapsed): Changed its type. (calculateSpeed): Changed its argument signature. * src/PeerMessage.cc (toString): Fixed message. |
|
Tatsuhiro Tsujikawa | 9a52be6a29 |
2006-04-06 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To print ETA: * src/TorrentDownloadEngine.cc (afterEachIteration): Added download completion handling when dealing with TorrentMan::isPartialDownloadingMode() == true. * src/TorrentDownloadEngine.h (onPartialDownloadingCompletes): New function. * src/TorrentConsoleDownloadEngine.h (startup): New variable. (sessionDownloadLength): New variable. (avgSpeed): New variable. (eta): New variable. * src/TorrentConsoleDownloadEngine.cc (initStatistics): Initialized new variables: eta, avgSpeed, startup. (calculateSpeed): Calculate average speed and ETA. (printStatistics): Added ETA. * src/Util.h (secfmt): New function. * src/Util.cc (secfmt): New function. 2006-04-05 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com> To detect "keep alive" flooding: * src/PeerInteractionCommand.h (keepAliveCount): New variable * src/PeerInteractionCommand.cc (Constructor): Initialized new variable: keepAliveCount. (detectMessageFlooding): Added "keep alive" flooding detection. (receiveMessage): Increase keepAliveCount when "keep alive" message received. To add the ability to download only specified files in multi-file torrent: * src/BitfieldMan.h (filterBitfield): New variable. (filterEnabled): New variable. (setFilterBit): New function. (enableFilter): New function. (disableFilter): New function. (isFilterEnabled): New function. (getFilteredTotalLength): New function. (getCompletedLength): New function. * src/BitfieldMan.cc (Constructor): Initialized new variable: filterBitfield, filterEnabled. (CopyConstructor): Added filterBitfield and filterEnabled. (operator==): Added filterBitfield and filterEnabled. (Destructor): Added filterBitfield. (getMissingIndex): Use filterBitfield. (getMissingUnusedIndex): Use filterBitfield. (getFirstMissingUnusedIndex): Use filterBitfield. (getFirstMissingUnusedIndex): Use filterBitfield. (getAllMissingIndexes): Use filterBitfield. (countMissingBlock): Use filterBitfield. (countBlock): Use filterBitfield. (setBitInternal): Added new argument on. (setUseBit): Use setBitInternal. (unsetUseBit): Use setBitInternal. (setBit): Use setBitInternal. (unsetBit): Use setBitInternal. (isAllBitSet): Use filterBitfield. (setFilterBit): New function. (addFilter): New function. (enableFilter): New function. (disableFilter): New function. (clearFilter): New function. (isFilterEnabled): New function. (getFilteredTotalLength): New function. (getCompletedLength): New function. * src/TorrentMan.h [FileEntry](Constructor): Updated signature. Initalized newly added variables. [FileEntry](offset): New variable. [FileEntry](extracted): New variable. [FileEntry](requested): New variable. (readFileEntry): New function. (option): New variable. (splitMultiFile): Removed const qualifier. (fixFilename): Removed const qualifier. (readFileEntryFromMetaInfoFile): New function. (finishPartialDownloadingMode): New function. (isPartialDownloadingMode): New function. (setFileEntriesToDownload): New function. (getCompletedLength): New function. (getPartialTotalLength): New function. * src/TorrentMan.cc (readFileEntry): New function. (setup): Use readFileEntry. If no-preallocation option is specified, use DefaultDiskWriter. (readFileEntryFromMetaInfoFile): New function. (fixFilename): Removed const qualifier. (splitMultiFile): Removed const qualifier. (setFileEntriesToDownload): New function. (isPartialDownloadingMode): New function. (finishPartialDownloadingMode): New function. (getCompletedLength): New function. (getPartialTotalLength): New function. * src/TorrentConsoleDownloadEngine.h (partialDownloadLengthDiff): New variable. (partialTotalLength): New variable. (downloadLength): New variable. (totalLength): New variable. * src/TorrentConsoleDownloadEngine.cc (onPartialDownloadingCompletes): Added log. (initStatistics): Initialized new variables: partialDownloadLengthDiff, partialTotalLength, downloadLength, totalLength. (calculate): Calculate downloadLength and totalLength. * src/prefs.h :New definition PREF_NO_PREALLOCATION * src/main.cc (addCommand): Changed argument signature. (main): Added new variable: args. Added new option "torrent-show-files" "no-preallocation". Usage is not updated yet. 2006-04-02 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com> * src/PeerMessage.cc (setBitfield): Fixed invalid memory de-allocation. |
|
Tatsuhiro Tsujikawa | 40cb1ca9ce |
2006-03-27 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* configure.in: Added gnutls support. Added several CPP macros. * m4/openssl.m4: Added. * src/SocketCore.{h,cc}: Drop const quarifier from writeData(), readData(), peekData(). Added gnutls support. * src/HttpDownloadCommand.cc: Removed SleepCommand.h * src/TrackerWatcherCommand.{h,cc}: Added. This command creates TrackerInitCommand periodicaly(TorrentMan::minInterval). * src/TorrentMan.cc: Remove downloadedSize == 0 check from save(). Instead, added a check for whether setup method has executed successfully. * src/TorrentMan.h: Added member vaiable setupComplete. Updated DEFAULT_ANNOUNCE_INTERVAL and DEFAULT_ANNOUNCE_MIN_INTERVAL to 300. * src/Makefile.am: Updated. * src/messageDigest.h: Added. This is a macro calculating SHA1 digest using whether OpenSSL or gcrypt, depending on the result of configure script. * src/ShaVisitor.{h,cc}: Removed direct dependency on OpenSSL by using messageDigest.h. * src/TorrentAutoSaveCommand.h: Removed unused variable cuid. * src/PeerListenCommand.cc: Added log about port binded successfully. Fixed memory leak. * src/main.cc: Added gnutls support. Replaced LIB_SSL with ENABLE_BITTORRENT where they are not related to OpenSSL but BitTorrent. Removed instantiation of TrackerInitCommand. Instead, TrackerWatcherCommand is instantiated and pushed to the command queue. * src/InitiateConnectionCommandFactory.cc: Replaced HAVE_LIBSSL with ENABLE_SSL. * src/Request.cc: Replaced HAVE_LIBSSL with ENABLE_SSL. * src/RequestSlotMan.cc: (deleteCompletedRequestSlot) If a piece is already acquired by another command, delete the request slots for the piece. * src/TrackerUpdateCommand.cc: (execute) Changed log level of MSG_TRACKER_WARNING_MESSAGE from info to warn. Added a check whether peer list is null. Fixed the bug that causes sending completed event to the tracker several times. * src/TrackerInitCommand.cc: (execute) Fixed the bug that causes sending completed event to the tracker several times. * src/AbstractDiskWriter.{h,cc}: Removed direct dependency on OpenSSL by using messageDigest.h. 2006-03-26 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com> * PeerConnection.cc: Replaced log message "keep-alive" with "keep alive". * PeerInteractionCommand.{h,cc}: Close connection if peer is choking localhost long time. * TorrentMan.cc: When adding new peer with duplicate = true, if the number of peer list is equal to or grater than MAX_PEER_LIST, delete at most 100 failure entry from the list. If with duplicate = false, MAX_PEER_LIST is not checked. * PeerListenCommand.cc: Fixed the argument order of log message. 2006-03-25 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com> * Logger.h: Moved enum LEVEL from SimpleLogger.h to here. Added warn(). * SimpleLogger.h: Moved enum LEVEL to Logger.h. Implemented warn(). Defined 2 macros(WRITE_LOG, WRITE_LOG_EX) to avoid duplicated code. |
|
Tatsuhiro Tsujikawa | 01118364a5 | ||
Tatsuhiro Tsujikawa | df6c7c0385 | added bittorrent support(experimental) | |
Tatsuhiro Tsujikawa | 46354b7c91 |
Added intl/*
Added src/alloca.c |
|
Tatsuhiro Tsujikawa | 8d980589e3 | ||
Tatsuhiro Tsujikawa | 0276b3bb37 |
* DownloadEngine.{h, cc}:
* ConsoleDownloadEngine.{h, cc}: Console output message(size, speed) is now generated by ConsoleDownloadEngine not by DownloadEngine. * main.cc: Download complete/abort message is now generated by main. * Makefile.am (SUBDIRS): Add m4. (ACLOCAL_AMFLAGS): New variable. (EXTRA_DIST): New variable. * configure.in (AC_CONFIG_FILES): Add po/Makefile.in, * gettext: added gettext functionality |
|
Tatsuhiro Tsujikawa | a8f0186af2 | ||
Tatsuhiro Tsujikawa | 4a5fa077b3 | * ChunkedEncoding.cc: Added #include directive for strings.h | |
Tatsuhiro Tsujikawa | 52634627bc | Initial import |