Accept incoming connections if download rate is low.
* src/PeerListenCommand.h, src/PeerListenCommand.cc:
(_lowestSpeedLimit): New variable.
(setLowestSpeedLimit): New function.
(execute): Accept incoming connections if download rate is low.
MAX_PEERS is ignored in this case.
Disable PREF_OUT in multiple concurrent download:
* src/RequestGroup.h, src/RequestGroup.cc
(setUserDefinedFilename): New function.
* src/DownloadEngineFactory.cc
(newConsoleEngine): Do not set PREF_OUT to requestGroup in
multiple
concurrent download.
* src/DefaultSegmentManFactory.cc
(createNewInstance): Comment out the line: segmentMan->ufilename
= ...
Accept incoming connections if download rate is low.
* src/PeerListenCommand.h, src/PeerListenCommand.cc:
(_lowestSpeedLimit): New variable.
(setLowestSpeedLimit): New function.
(execute): Accept incoming connections if download rate is low.
MAX_PEERS is ignored in this case.
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.
Change file mode to 666:
* src/common.h (OPEN_MODE): New definition.
* src/File.cc
* src/Util.cc
* src/Directry.cc
* src/AbstractDiskWriter.cc
Change the level of log message "download aborted" to debug:
* src/PeerAbstractCommand.cc (execute)
* src/RequestGroup.h (RequestGroup): Initialized
_hintTotalLength to 0.
* src/TrackerWatcherCommand.cc
(createCommand): Sleep some seconds after request failed.
If tracker request fails more than value of
PREF_TRACKER_MAX_TRIES,
then abort tracker request.
* 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().
port
is 80 or 443:
* src/HttpRequest.cc (getHostText): Suppress port number in http
request header if port is 80 or 443.
(createProxyRequest): Allways send port number.
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.
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.
Use filename and size from Metalink file instead of sending HEAD
request:
* src/UrlRequestInfo.h
(_filename): New variable.
(_totalLength): New variable.
(setTotalLength): New variable.
(setFilename): New variable.
* src/MetalinkRequestInfo.cc
(execute): Set filename and size to UrlRequestInfo
* src/UrlRequestInfo.cc
(execute): Use filename and size from Metalink instead of seding
HEAD request to servers.
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
* 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.
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.
To reduce overhead to find commands whose socket is either
readable or writable in the download engine loop:
* src/Command.h, src/Command.cc
(STATUS): New enum.
(status): New variable.
(statusMatch): New function.
(setStatusActive): New function.
(setStatusInactive): New function.
* src/DownloadEngine.h, src/DownloadEngine.cc
(executeCommand): New function.
(run): Simplified.
(waitData): Call Command::setStatusActive() when command's
socket is
readable or writable.
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.
* src/HttpHeader.h
(Range.h): New include.
(status): New variable.
(HttpHeader): Initialized status with 0.
(getStatus): New function.
(setStatus): New function.
(getRange): New function.
(HttpHeaderHandle): New function.
* src/HttpHeader.cc
(getRange): New function.
* src/Request.h
(RequestWeakHandle): New definition.
* src/HttpConnection.h
(HttpConnectionHandle): New type definition.
* src/HttpConnection.cc
(receiveResponse): Set HTTP status to headers.
* src/main.cc
(showUsage): Fixed typo.
* src/Segment.h
(SegmentHandle): New type definition.
* src/BitfieldMan.h
(getMissingUnusedLength): New function.
* src/BitfieldMan.cc
(getMissingUnusedLength): New function.
To fix the bug that causes crash on Max OS X:
* src/SimpleRandomizer.h
(getInstance): Create new instance if the static variable is
null.
* src/SimpleRandomizer.cc
(randomizer): Initialized to 0.
* src/BitfieldManFactory.h
(getNewFactory): Removed the call to setRandomizer().
To fix the miscalculation of the range of checksum:
* src/BitfieldMan.h
(isBitSetOffsetRange): New function.
* src/BitfieldMan.cc
(isBitSetOffsetRange): New function.
* src/SegmentMan.cc
(tryChunkChecksumValidation): Use
BitfieldMan::isBitSetOffsetRange().
Use bitfield->getBlockLength() instead of segment.segmentLength.
To lower CPU usage in BitTorrent download when
--max-upload-limit
command-line option specified:
* src/DefaultBtMessageDispatcher.cc
(sendMessages): Calculate uploading speed only when current
message
is uploading data and is not sent yet.
* src/DefaultPeerStorage.h
(MAX_PEER_LIST_SIZE): 100 -> 60, because 60 is well enough.
* src/HttpResponseCommand.cc
(handleDefaultEncoding): Added the cast to int32_t to itos.
This fixes compile error in Soralis 10.
To fix segfault in Metalink download:
* src/UrlRequestInfo.h
(filename): Removed.
(totalLength): Removed.
(setTotalLength): Removed.
(setFilename): Removed.
* src/MetalinkRequestInfo.cc
(execute): Do not set filename and totalLength to reqInfo.
Set chunk checksum to reqInfo if it is not null.
* src/HttpResponseCommand.cc
(executeInternal): Fixed filename in log.
(handleDefaultEncoding): Removed the call to initBitfield() and
markAllPiecesDone().
(handleOtherEncoding): Added HEAD method handling.
* src/FtpNegotiateCommand.cc
(executeInternal): Added SEQ_HEAD_OK handling.
(recvSize): In HEAD handling, set sequence to SEQ_HEAD_OK and
return false.
* src/FtpNegotiateCommand.h
(SEQ_HEAD_OK): New definition.
* src/SegmentMan.cc
(initBitfield): Delete bitfield.
(isChunkChecksumValidationReady): Fixed the condition.
* src/UrlRequestInfo.cc: Fixed so that Metalink and Torrent
download
works fine.