Commit Graph

12 Commits (9bce4eb925794528b21b4cdb0f7777ac24ffd7c2)

Author SHA1 Message Date
Tatsuhiro Tsujikawa 318c804504 Use user-defined literal for k, m, and g (powers of 1024) 2015-06-21 19:29:54 +09:00
Tatsuhiro Tsujikawa 860f4dd06a Use int64_t instead of off_t
Using off_t, at least, in DiskAdaptor layer is problematic because
torrent can contain under 2GiB files but total sum of those files may
exceed 2GiB limit, which makes off_t overflow in 32 bit system without
large file support. So we use int64_t in API. We'll check the file
length before download so that it does not exceed max off_t.
2012-07-23 21:42:47 +09:00
Tatsuhiro Tsujikawa 12988e5282 Replaced uint64_t with off_t or int64_t.
Since off_t is int64_t with LFS, we cannot take advantage of extra
capacity of uint64_t.
2011-12-09 21:39:43 +09:00
Tatsuhiro Tsujikawa 3ee6784b76 Made `make distcheck' pass.
We added 2 macros A2_TEST_DIR and A2_TEST_OUT_DIR to pass tests in
`make distcheck`.  A2_TEST_DIR refers to test directory.  All output
files by unit tests are now created under A2_TEST_OUT_DIR directory.
2010-12-02 22:52:35 +09:00
Tatsuhiro Tsujikawa c1aef8e2d1 2009-05-04 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Now the constructor of AbstractDiskWriter takes filename as an
	argument and filename argument is removed from openFile(),
	initAndOpenFile(), openExistingFile() interface.  storeDir
	member and its accessor functions are removed from DiskAdaptor
	because it is not used anymore.  size() member function of
	DefaultDiskWriter, DirectDiskAdaptor and MultiDiskAdaptor now
	can be called without opening file.
	* src/AbstractDiskWriter.cc
	* src/AbstractDiskWriter.h
	* src/AbstractSingleDiskAdaptor.cc
	* src/AbstractSingleDiskAdaptor.h
	* src/ByteArrayDiskWriter.cc
	* src/ByteArrayDiskWriter.h
	* src/ByteArrayDiskWriterFactory.cc
	* src/ByteArrayDiskWriterFactory.h
	* src/DefaultDiskWriter.cc
	* src/DefaultDiskWriter.h
	* src/DefaultDiskWriterFactory.cc
	* src/DefaultDiskWriterFactory.h
	* src/DefaultPieceStorage.cc
	* src/DirectDiskAdaptor.cc
	* src/DirectDiskAdaptor.h
	* src/DiskAdaptor.h
	* src/DiskWriter.h
	* src/DiskWriterFactory.h
	* src/MessageDigestHelper.cc
	* src/MultiDiskAdaptor.cc
	* src/RequestGroup.cc
	* src/UnknownLengthPieceStorage.cc
	* src/Util.cc
	* test/DefaultDiskWriterTest.cc
	* test/DirectDiskAdaptorTest.cc
	* test/FallocFileAllocationIteratorTest.cc
	* test/MessageDigestHelperTest.cc
	* test/MetalinkProcessorTest.cc
	* test/MultiDiskAdaptorTest.cc
	* test/MultiFileAllocationIteratorTest.cc
	* test/SingleFileAllocationIteratorTest.cc
	* test/UtilTest.cc
2009-05-04 07:50:38 +00:00
Tatsuhiro Tsujikawa f7e3651d91 2008-07-31 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Applied tizianomueller's patch to fix compile error.
	* test/BitfieldManTest.cc
	* test/BtRequestMessageTest.cc
	* test/DefaultBtContextTest.cc
	* test/DefaultDiskWriterTest.cc
	* test/DefaultPieceStorageTest.cc
	* test/HttpHeaderProcessorTest.cc
	* test/HttpResponseTest.cc
	* test/Metalink2RequestGroupTest.cc
	* test/MetalinkParserControllerTest.cc
	* test/MetalinkProcessorTest.cc
	* test/PeerSessionResourceTest.cc
	* test/UtilTest.cc
2008-07-31 12:28:12 +00:00
Tatsuhiro Tsujikawa 032c7c2808 2008-03-09 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
type cleanup for allmost all remaining files.
2008-03-09 12:24:01 +00:00
Tatsuhiro Tsujikawa 1b7c198289 2008-02-08 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Removed "using namespace std;" from all sources. Appended std:: 
prefix to c++
	standard classes.
	Included string.h where mem* function are used.
2008-02-08 15:53:45 +00:00
Tatsuhiro Tsujikawa e85f9ccfd6 2007-08-08 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
MessageDigestHelper is introduced in order to simplify the use
	of message digest. Removed repeated code.
	The message digest algorithm is now specified by string, like 
"sha1",
	"md5".
	* src/messageDigest.{h, cc}
	* src/MessageDigestHelper.{h, cc}: New class.
	* src/DefaultPieceStorage.cc
	* src/DefaultBtContext.{h, cc}
	(computeFastSet): New function.
	(setInfoHash): Added for unit testing.
	(setNumPieces): Added for unit testing.
	* src/DefaultBtInteractive.cc
	* src/BtPieceMessage.cc
	* src/Peer.cc
	* src/Checksum.h
	* src/message.h
	* src/IteratableChecksumValidator.h
	* src/ChunkChecksumValidator.{h, cc}: Use 
IteratableChecksumValidator
	inside it.
	* src/SegmentMan.{h, cc}
	(checkIntegrity): Removed.
	* src/IteratableChunkChecksumValidator.{h, cc}
	* src/Util.h
	(sha1Sum): Removed.
	(simpleMessageDigest): Removed.
	(fileChecksum): Removed.
	(computeFastSet): Removed.
	* src/ShaVisitor.cc
	* src/ChunkChecksum.h
	* src/DownloadCommand.cc

	Removed messageDigest virtual functions.
	* src/MultiDiskAdaptor.{h, cc}
	* src/DiskAdaptor.h
	* src/ByteArrayDiskWriter.h
	* src/DiskWriter.h
	* src/DiskAdaptorWriter.h
	* src/AbstractSingleDiskAdaptor.{h, cc}
	* src/AbstractDiskWriter.{h, cc}
	
	Fixed comilation error when message digest is disabled.
	* src/MetalinkEntry.{h, cc}
	* src/MetalinkRequestInfo.cc
	
	Removed srandom and random.
	* src/SimpleRandomizer.h

	Added size() virtual function to DiskAdaptor
	* src/MultiDiskAdaptor.h

	Fixed the bug that causes that files are not opened correctly in
	multi-file torrent.
	* src/TorrentRequestInfo.cc
	* src/MultiDiskAdaptor.cc
	
	Added SHA256 support
	* src/messageDigest.cc
	* src/Xml2MetalinkProcessor.cc

	Show supported message digest algorithms
	* src/main.cc

	Updated contact info.
	* src/main.cc
2007-08-08 14:40:11 +00:00
Tatsuhiro Tsujikawa 19ef788023 Merged Ross's patch to test code. 2007-07-23 14:09:46 +00:00
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.
2007-01-24 15:55:34 +00:00
Tatsuhiro Tsujikawa df6c7c0385 added bittorrent support(experimental) 2006-03-21 14:12:51 +00:00