mirror of https://github.com/aria2/aria2
Remove ENABLE_MESSAGE_DIGEST, since we got the internal md, always
parent
befd799d17
commit
010131161e
28
configure.ac
28
configure.ac
|
@ -531,15 +531,6 @@ AM_CONDITIONAL([HAVE_OPENSSL], [ test "x$have_openssl" = "xyes" ])
|
||||||
AM_CONDITIONAL([USE_OPENSSL_MD], [ test "x$use_md" = "xopenssl"])
|
AM_CONDITIONAL([USE_OPENSSL_MD], [ test "x$use_md" = "xopenssl"])
|
||||||
AM_CONDITIONAL([USE_INTERNAL_MD], [ test "x$use_md" = "xinternal"])
|
AM_CONDITIONAL([USE_INTERNAL_MD], [ test "x$use_md" = "xinternal"])
|
||||||
|
|
||||||
if test "x$use_md" != "x"; then
|
|
||||||
AC_DEFINE([ENABLE_MESSAGE_DIGEST], [1],
|
|
||||||
[Define to 1 if message digest support is enabled.])
|
|
||||||
AM_CONDITIONAL([ENABLE_MESSAGE_DIGEST], true)
|
|
||||||
enable_message_digest=yes
|
|
||||||
else
|
|
||||||
AM_CONDITIONAL([ENABLE_MESSAGE_DIGEST], false)
|
|
||||||
fi
|
|
||||||
|
|
||||||
if test "x$have_libgmp" = "xyes" ||
|
if test "x$have_libgmp" = "xyes" ||
|
||||||
test "x$have_libgcrypt" = "xyes" ||
|
test "x$have_libgcrypt" = "xyes" ||
|
||||||
test "x$have_openssl" = "xyes"; then
|
test "x$have_openssl" = "xyes"; then
|
||||||
|
@ -558,8 +549,7 @@ else
|
||||||
AM_CONDITIONAL([USE_INTERNAL_ARC4], true)
|
AM_CONDITIONAL([USE_INTERNAL_ARC4], true)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test "x$enable_bittorrent" = "xyes" &&
|
if test "x$enable_bittorrent" = "xyes"; then
|
||||||
test "x$enable_message_digest" = "xyes"; then
|
|
||||||
AC_DEFINE([ENABLE_BITTORRENT], [1],
|
AC_DEFINE([ENABLE_BITTORRENT], [1],
|
||||||
[Define to 1 if BitTorrent support is enabled.])
|
[Define to 1 if BitTorrent support is enabled.])
|
||||||
AM_CONDITIONAL([ENABLE_BITTORRENT], true)
|
AM_CONDITIONAL([ENABLE_BITTORRENT], true)
|
||||||
|
@ -940,15 +930,13 @@ if test "x$have_option_const_name" = "xyes"; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
AC_CONFIG_SUBDIRS([deps/wslay])
|
AC_CONFIG_SUBDIRS([deps/wslay])
|
||||||
if test "x$enable_message_digest" = "xyes"; then
|
enable_websocket=yes
|
||||||
enable_websocket=yes
|
AC_DEFINE([ENABLE_WEBSOCKET], [1],
|
||||||
AC_DEFINE([ENABLE_WEBSOCKET], [1],
|
[Define 1 if WebSocket support is enabled.])
|
||||||
[Define 1 if WebSocket support is enabled.])
|
WSLAY_LIBS="\$(top_builddir)/deps/wslay/lib/libwslay.la"
|
||||||
WSLAY_LIBS="\$(top_builddir)/deps/wslay/lib/libwslay.la"
|
AC_SUBST([WSLAY_LIBS])
|
||||||
AC_SUBST([WSLAY_LIBS])
|
# $(top_srcdir) for `make distcheck`
|
||||||
# $(top_srcdir) for `make distcheck`
|
CPPFLAGS="-I\$(top_builddir)/deps/wslay/lib/includes -I\$(top_srcdir)/deps/wslay/lib/includes $CPPFLAGS"
|
||||||
CPPFLAGS="-I\$(top_builddir)/deps/wslay/lib/includes -I\$(top_srcdir)/deps/wslay/lib/includes $CPPFLAGS"
|
|
||||||
fi
|
|
||||||
AM_CONDITIONAL([ENABLE_WEBSOCKET], [test "x$enable_websocket" = "xyes"])
|
AM_CONDITIONAL([ENABLE_WEBSOCKET], [test "x$enable_websocket" = "xyes"])
|
||||||
|
|
||||||
AM_CONDITIONAL([ENABLE_LIBARIA2], [test "x$enable_libaria2" = "xyes"])
|
AM_CONDITIONAL([ENABLE_LIBARIA2], [test "x$enable_libaria2" = "xyes"])
|
||||||
|
|
|
@ -66,13 +66,11 @@
|
||||||
#include "FileEntry.h"
|
#include "FileEntry.h"
|
||||||
#include "error_code.h"
|
#include "error_code.h"
|
||||||
#include "SocketRecvBuffer.h"
|
#include "SocketRecvBuffer.h"
|
||||||
|
#include "ChecksumCheckIntegrityEntry.h"
|
||||||
#ifdef ENABLE_ASYNC_DNS
|
#ifdef ENABLE_ASYNC_DNS
|
||||||
#include "AsyncNameResolver.h"
|
#include "AsyncNameResolver.h"
|
||||||
#include "AsyncNameResolverMan.h"
|
#include "AsyncNameResolverMan.h"
|
||||||
#endif // ENABLE_ASYNC_DNS
|
#endif // ENABLE_ASYNC_DNS
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
# include "ChecksumCheckIntegrityEntry.h"
|
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
|
|
@ -359,7 +359,6 @@ ConsoleStatCalc::calculateStat(const DownloadEngine* e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
{
|
{
|
||||||
auto& entry = e->getCheckIntegrityMan()->getPickedEntry();
|
auto& entry = e->getCheckIntegrityMan()->getPickedEntry();
|
||||||
if(entry) {
|
if(entry) {
|
||||||
|
@ -378,7 +377,6 @@ ConsoleStatCalc::calculateStat(const DownloadEngine* e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
if(isTTY_) {
|
if(isTTY_) {
|
||||||
if (truncate_) {
|
if (truncate_) {
|
||||||
auto str = o.str(color, cols);
|
auto str = o.str(color, cols);
|
||||||
|
|
|
@ -66,6 +66,7 @@
|
||||||
#include "fmt.h"
|
#include "fmt.h"
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "UriListParser.h"
|
#include "UriListParser.h"
|
||||||
|
#include "message_digest_helper.h"
|
||||||
#ifdef ENABLE_BITTORRENT
|
#ifdef ENABLE_BITTORRENT
|
||||||
# include "bittorrent_helper.h"
|
# include "bittorrent_helper.h"
|
||||||
#endif // ENABLE_BITTORRENT
|
#endif // ENABLE_BITTORRENT
|
||||||
|
@ -73,9 +74,6 @@
|
||||||
# include "metalink_helper.h"
|
# include "metalink_helper.h"
|
||||||
# include "MetalinkEntry.h"
|
# include "MetalinkEntry.h"
|
||||||
#endif // ENABLE_METALINK
|
#endif // ENABLE_METALINK
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
# include "message_digest_helper.h"
|
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
extern char* optarg;
|
extern char* optarg;
|
||||||
extern int optind, opterr, optopt;
|
extern int optind, opterr, optopt;
|
||||||
|
|
|
@ -347,13 +347,8 @@ void DefaultBtProgressInfoFile::load()
|
||||||
((size_t)bitfieldLength);
|
((size_t)bitfieldLength);
|
||||||
READ_CHECK(fp, pieceBitfield.get(), bitfieldLength);
|
READ_CHECK(fp, pieceBitfield.get(), bitfieldLength);
|
||||||
piece->setBitfield(pieceBitfield.get(), bitfieldLength);
|
piece->setBitfield(pieceBitfield.get(), bitfieldLength);
|
||||||
|
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
piece->setHashType(dctx_->getPieceHashType());
|
piece->setHashType(dctx_->getPieceHashType());
|
||||||
|
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
inFlightPieces.push_back(piece);
|
inFlightPieces.push_back(piece);
|
||||||
}
|
}
|
||||||
pieceStorage_->addInFlightPiece(inFlightPieces);
|
pieceStorage_->addInFlightPiece(inFlightPieces);
|
||||||
|
|
|
@ -113,12 +113,8 @@ std::shared_ptr<Piece> DefaultPieceStorage::checkOutPiece
|
||||||
std::shared_ptr<Piece> piece = findUsedPiece(index);
|
std::shared_ptr<Piece> piece = findUsedPiece(index);
|
||||||
if(!piece) {
|
if(!piece) {
|
||||||
piece.reset(new Piece(index, bitfieldMan_->getBlockLength(index)));
|
piece.reset(new Piece(index, bitfieldMan_->getBlockLength(index)));
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
piece->setHashType(downloadContext_->getPieceHashType());
|
piece->setHashType(downloadContext_->getPieceHashType());
|
||||||
|
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
addUsedPiece(piece);
|
addUsedPiece(piece);
|
||||||
}
|
}
|
||||||
piece->addUser(cuid);
|
piece->addUser(cuid);
|
||||||
|
@ -780,12 +776,8 @@ void DefaultPieceStorage::markPiecesDone(int64_t length)
|
||||||
p->completeBlock(i);
|
p->completeBlock(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
p->setHashType(downloadContext_->getPieceHashType());
|
p->setHashType(downloadContext_->getPieceHashType());
|
||||||
|
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
addUsedPiece(p);
|
addUsedPiece(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,10 +65,8 @@
|
||||||
#include "Piece.h"
|
#include "Piece.h"
|
||||||
#include "WrDiskCacheEntry.h"
|
#include "WrDiskCacheEntry.h"
|
||||||
#include "DownloadFailureException.h"
|
#include "DownloadFailureException.h"
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
#include "MessageDigest.h"
|
||||||
# include "MessageDigest.h"
|
#include "message_digest_helper.h"
|
||||||
# include "message_digest_helper.h"
|
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
#ifdef ENABLE_BITTORRENT
|
#ifdef ENABLE_BITTORRENT
|
||||||
# include "bittorrent_helper.h"
|
# include "bittorrent_helper.h"
|
||||||
#endif // ENABLE_BITTORRENT
|
#endif // ENABLE_BITTORRENT
|
||||||
|
@ -86,7 +84,6 @@ DownloadCommand::DownloadCommand(cuid_t cuid,
|
||||||
lowestDownloadSpeedLimit_(0),
|
lowestDownloadSpeedLimit_(0),
|
||||||
pieceHashValidationEnabled_(false)
|
pieceHashValidationEnabled_(false)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
{
|
{
|
||||||
if(getOption()->getAsBool(PREF_REALTIME_CHUNK_CHECKSUM)) {
|
if(getOption()->getAsBool(PREF_REALTIME_CHUNK_CHECKSUM)) {
|
||||||
const std::string& algo = getDownloadContext()->getPieceHashType();
|
const std::string& algo = getDownloadContext()->getPieceHashType();
|
||||||
|
@ -96,7 +93,6 @@ DownloadCommand::DownloadCommand(cuid_t cuid,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
peerStat_ = req->initPeerStat();
|
peerStat_ = req->initPeerStat();
|
||||||
peerStat_->downloadStart();
|
peerStat_->downloadStart();
|
||||||
|
@ -236,8 +232,6 @@ bool DownloadCommand::executeInternal() {
|
||||||
A2_LOG_INFO(fmt(MSG_SEGMENT_DOWNLOAD_COMPLETED,
|
A2_LOG_INFO(fmt(MSG_SEGMENT_DOWNLOAD_COMPLETED,
|
||||||
getCuid()));
|
getCuid()));
|
||||||
|
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
{
|
{
|
||||||
const std::string& expectedPieceHash =
|
const std::string& expectedPieceHash =
|
||||||
getDownloadContext()->getPieceHash(segment->getIndex());
|
getDownloadContext()->getPieceHash(segment->getIndex());
|
||||||
|
@ -270,9 +264,6 @@ bool DownloadCommand::executeInternal() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#else // !ENABLE_MESSAGE_DIGEST
|
|
||||||
completeSegment(getCuid(), segment);
|
|
||||||
#endif // !ENABLE_MESSAGE_DIGEST
|
|
||||||
} else {
|
} else {
|
||||||
// If segment is not canceled here, in the next pipelining
|
// If segment is not canceled here, in the next pipelining
|
||||||
// request, aria2 requests bad range
|
// request, aria2 requests bad range
|
||||||
|
@ -319,7 +310,6 @@ bool DownloadCommand::prepareForNextSegment() {
|
||||||
getFileEntry()->setLength(getPieceStorage()->getCompletedLength());
|
getFileEntry()->setLength(getPieceStorage()->getCompletedLength());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
if(getDownloadContext()->getPieceHashType().empty()) {
|
if(getDownloadContext()->getPieceHashType().empty()) {
|
||||||
auto entry = make_unique<ChecksumCheckIntegrityEntry>(getRequestGroup());
|
auto entry = make_unique<ChecksumCheckIntegrityEntry>(getRequestGroup());
|
||||||
if(entry->isValidationReady()) {
|
if(entry->isValidationReady()) {
|
||||||
|
@ -329,7 +319,6 @@ bool DownloadCommand::prepareForNextSegment() {
|
||||||
(std::move(entry));
|
(std::move(entry));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
// Following 2lines are needed for DownloadEngine to detect
|
// Following 2lines are needed for DownloadEngine to detect
|
||||||
// completed RequestGroups without 1sec delay.
|
// completed RequestGroups without 1sec delay.
|
||||||
getDownloadEngine()->setNoWait(true);
|
getDownloadEngine()->setNoWait(true);
|
||||||
|
@ -370,8 +359,6 @@ bool DownloadCommand::prepareForNextSegment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
void DownloadCommand::validatePieceHash(const std::shared_ptr<Segment>& segment,
|
void DownloadCommand::validatePieceHash(const std::shared_ptr<Segment>& segment,
|
||||||
const std::string& expectedHash,
|
const std::string& expectedHash,
|
||||||
const std::string& actualHash)
|
const std::string& actualHash)
|
||||||
|
@ -393,8 +380,6 @@ void DownloadCommand::validatePieceHash(const std::shared_ptr<Segment>& segment,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
void DownloadCommand::completeSegment(cuid_t cuid,
|
void DownloadCommand::completeSegment(cuid_t cuid,
|
||||||
const std::shared_ptr<Segment>& segment)
|
const std::shared_ptr<Segment>& segment)
|
||||||
{
|
{
|
||||||
|
|
|
@ -43,9 +43,7 @@ namespace aria2 {
|
||||||
|
|
||||||
class PeerStat;
|
class PeerStat;
|
||||||
class StreamFilter;
|
class StreamFilter;
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
class MessageDigest;
|
class MessageDigest;
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
class DownloadCommand : public AbstractCommand {
|
class DownloadCommand : public AbstractCommand {
|
||||||
private:
|
private:
|
||||||
|
@ -53,9 +51,7 @@ private:
|
||||||
|
|
||||||
std::unique_ptr<StreamFilter> streamFilter_;
|
std::unique_ptr<StreamFilter> streamFilter_;
|
||||||
|
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
std::unique_ptr<MessageDigest> messageDigest_;
|
std::unique_ptr<MessageDigest> messageDigest_;
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
time_t startupIdleTime_;
|
time_t startupIdleTime_;
|
||||||
|
|
||||||
|
|
|
@ -43,9 +43,7 @@
|
||||||
#include "FileAllocationMan.h"
|
#include "FileAllocationMan.h"
|
||||||
#include "CheckIntegrityMan.h"
|
#include "CheckIntegrityMan.h"
|
||||||
#include "CheckIntegrityEntry.h"
|
#include "CheckIntegrityEntry.h"
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
#include "CheckIntegrityDispatcherCommand.h"
|
||||||
# include "CheckIntegrityDispatcherCommand.h"
|
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
#include "prefs.h"
|
#include "prefs.h"
|
||||||
#include "FillRequestGroupCommand.h"
|
#include "FillRequestGroupCommand.h"
|
||||||
#include "FileAllocationDispatcherCommand.h"
|
#include "FileAllocationDispatcherCommand.h"
|
||||||
|
@ -157,19 +155,15 @@ DownloadEngineFactory::newDownloadEngine
|
||||||
e->setRequestGroupMan(std::move(requestGroupMan));
|
e->setRequestGroupMan(std::move(requestGroupMan));
|
||||||
}
|
}
|
||||||
e->setFileAllocationMan(make_unique<FileAllocationMan>());
|
e->setFileAllocationMan(make_unique<FileAllocationMan>());
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
e->setCheckIntegrityMan(make_unique<CheckIntegrityMan>());
|
e->setCheckIntegrityMan(make_unique<CheckIntegrityMan>());
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
e->addRoutineCommand(make_unique<FillRequestGroupCommand>
|
e->addRoutineCommand(make_unique<FillRequestGroupCommand>
|
||||||
(e->newCUID(), e.get()));
|
(e->newCUID(), e.get()));
|
||||||
e->addRoutineCommand(make_unique<FileAllocationDispatcherCommand>
|
e->addRoutineCommand(make_unique<FileAllocationDispatcherCommand>
|
||||||
(e->newCUID(), e->getFileAllocationMan().get(),
|
(e->newCUID(), e->getFileAllocationMan().get(),
|
||||||
e.get()));
|
e.get()));
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
e->addRoutineCommand(make_unique<CheckIntegrityDispatcherCommand>
|
e->addRoutineCommand(make_unique<CheckIntegrityDispatcherCommand>
|
||||||
(e->newCUID(), e->getCheckIntegrityMan().get(),
|
(e->newCUID(), e->getCheckIntegrityMan().get(),
|
||||||
e.get()));
|
e.get()));
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
if(op->getAsInt(PREF_AUTO_SAVE_INTERVAL) > 0) {
|
if(op->getAsInt(PREF_AUTO_SAVE_INTERVAL) > 0) {
|
||||||
e->addRoutineCommand
|
e->addRoutineCommand
|
||||||
|
|
|
@ -141,11 +141,7 @@ const char* strSupportedFeature(int feature)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case(FEATURE_MESSAGE_DIGEST):
|
case(FEATURE_MESSAGE_DIGEST):
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
return "Message Digest";
|
return "Message Digest";
|
||||||
#else // !ENABLE_MESSAGE_DIGEST
|
|
||||||
return 0;
|
|
||||||
#endif // !ENABLE_MESSAGE_DIGEST
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case(FEATURE_METALINK):
|
case(FEATURE_METALINK):
|
||||||
|
|
|
@ -75,9 +75,7 @@
|
||||||
#include "error_code.h"
|
#include "error_code.h"
|
||||||
#include "SocketRecvBuffer.h"
|
#include "SocketRecvBuffer.h"
|
||||||
#include "NullProgressInfoFile.h"
|
#include "NullProgressInfoFile.h"
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
#include "ChecksumCheckIntegrityEntry.h"
|
||||||
# include "ChecksumCheckIntegrityEntry.h"
|
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -386,7 +384,6 @@ bool FtpNegotiationCommand::onFileSizeDetermined(int64_t totalLength)
|
||||||
|
|
||||||
if(getDownloadContext()->knowsTotalLength() &&
|
if(getDownloadContext()->knowsTotalLength() &&
|
||||||
getRequestGroup()->downloadFinishedByFileLength()) {
|
getRequestGroup()->downloadFinishedByFileLength()) {
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
// TODO Known issue: if .aria2 file exists, it will not be
|
// TODO Known issue: if .aria2 file exists, it will not be
|
||||||
// deleted on successful verification, because .aria2 file is
|
// deleted on successful verification, because .aria2 file is
|
||||||
// not loaded. See also
|
// not loaded. See also
|
||||||
|
@ -401,9 +398,8 @@ bool FtpNegotiationCommand::onFileSizeDetermined(int64_t totalLength)
|
||||||
getDownloadEngine()->getCheckIntegrityMan()->pushEntry
|
getDownloadEngine()->getCheckIntegrityMan()->pushEntry
|
||||||
(std::move(entry));
|
(std::move(entry));
|
||||||
sequence_ = SEQ_EXIT;
|
sequence_ = SEQ_EXIT;
|
||||||
} else
|
}
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
else {
|
||||||
{
|
|
||||||
getPieceStorage()->markAllPiecesDone();
|
getPieceStorage()->markAllPiecesDone();
|
||||||
getDownloadContext()->setChecksumVerified(true);
|
getDownloadContext()->setChecksumVerified(true);
|
||||||
sequence_ = SEQ_DOWNLOAD_ALREADY_COMPLETED;
|
sequence_ = SEQ_DOWNLOAD_ALREADY_COMPLETED;
|
||||||
|
@ -423,7 +419,6 @@ bool FtpNegotiationCommand::onFileSizeDetermined(int64_t totalLength)
|
||||||
|
|
||||||
if(getDownloadContext()->knowsTotalLength()) {
|
if(getDownloadContext()->knowsTotalLength()) {
|
||||||
A2_LOG_DEBUG("File length becomes zero and it means download completed.");
|
A2_LOG_DEBUG("File length becomes zero and it means download completed.");
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
// TODO Known issue: if .aria2 file exists, it will not be
|
// TODO Known issue: if .aria2 file exists, it will not be
|
||||||
// deleted on successful verification, because .aria2 file is
|
// deleted on successful verification, because .aria2 file is
|
||||||
// not loaded. See also
|
// not loaded. See also
|
||||||
|
@ -437,7 +432,6 @@ bool FtpNegotiationCommand::onFileSizeDetermined(int64_t totalLength)
|
||||||
(std::move(entry));
|
(std::move(entry));
|
||||||
sequence_ = SEQ_EXIT;
|
sequence_ = SEQ_EXIT;
|
||||||
} else
|
} else
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
{
|
{
|
||||||
sequence_ = SEQ_DOWNLOAD_ALREADY_COMPLETED;
|
sequence_ = SEQ_DOWNLOAD_ALREADY_COMPLETED;
|
||||||
getPieceStorage()->markAllPiecesDone();
|
getPieceStorage()->markAllPiecesDone();
|
||||||
|
|
|
@ -50,15 +50,11 @@ void GrowSegment::updateWrittenLength(int32_t bytes)
|
||||||
piece_->setAllBlock();
|
piece_->setAllBlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
std::string GrowSegment::getDigest()
|
std::string GrowSegment::getDigest()
|
||||||
{
|
{
|
||||||
return A2STR::NIL;
|
return A2STR::NIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
void GrowSegment::clear(WrDiskCache* diskCache)
|
void GrowSegment::clear(WrDiskCache* diskCache)
|
||||||
{
|
{
|
||||||
writtenLength_ = 0;
|
writtenLength_ = 0;
|
||||||
|
|
|
@ -85,8 +85,6 @@ public:
|
||||||
|
|
||||||
virtual void updateWrittenLength(int32_t bytes) CXX11_OVERRIDE;
|
virtual void updateWrittenLength(int32_t bytes) CXX11_OVERRIDE;
|
||||||
|
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
virtual bool updateHash
|
virtual bool updateHash
|
||||||
(int32_t begin,
|
(int32_t begin,
|
||||||
const unsigned char* data,
|
const unsigned char* data,
|
||||||
|
@ -102,8 +100,6 @@ public:
|
||||||
|
|
||||||
virtual std::string getDigest() CXX11_OVERRIDE;
|
virtual std::string getDigest() CXX11_OVERRIDE;
|
||||||
|
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
virtual void clear(WrDiskCache* diskCache) CXX11_OVERRIDE;
|
virtual void clear(WrDiskCache* diskCache) CXX11_OVERRIDE;
|
||||||
|
|
||||||
virtual std::shared_ptr<Piece> getPiece() const CXX11_OVERRIDE;
|
virtual std::shared_ptr<Piece> getPiece() const CXX11_OVERRIDE;
|
||||||
|
|
|
@ -59,9 +59,7 @@
|
||||||
#include "MetalinkHttpEntry.h"
|
#include "MetalinkHttpEntry.h"
|
||||||
#include "base64.h"
|
#include "base64.h"
|
||||||
#include "array_fun.h"
|
#include "array_fun.h"
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
#include "MessageDigest.h"
|
#include "MessageDigest.h"
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
#ifdef HAVE_ZLIB
|
#ifdef HAVE_ZLIB
|
||||||
# include "GZipDecodingStreamFilter.h"
|
# include "GZipDecodingStreamFilter.h"
|
||||||
#endif // HAVE_ZLIB
|
#endif // HAVE_ZLIB
|
||||||
|
@ -395,7 +393,6 @@ void HttpResponse::getMetalinKHttpEntries(
|
||||||
std::sort(result.begin(), result.end());
|
std::sort(result.begin(), result.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
// Digest header field is defined by
|
// Digest header field is defined by
|
||||||
// http://tools.ietf.org/html/rfc3230.
|
// http://tools.ietf.org/html/rfc3230.
|
||||||
void HttpResponse::getDigest(std::vector<Checksum>& result) const
|
void HttpResponse::getDigest(std::vector<Checksum>& result) const
|
||||||
|
@ -445,6 +442,5 @@ void HttpResponse::getDigest(std::vector<Checksum>& result) const
|
||||||
}
|
}
|
||||||
std::swap(temp, result);
|
std::swap(temp, result);
|
||||||
}
|
}
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -125,13 +125,11 @@ public:
|
||||||
void getMetalinKHttpEntries(std::vector<MetalinkHttpEntry>& result,
|
void getMetalinKHttpEntries(std::vector<MetalinkHttpEntry>& result,
|
||||||
const std::shared_ptr<Option>& option) const;
|
const std::shared_ptr<Option>& option) const;
|
||||||
|
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
// Returns all digests specified in Digest header field. Sort
|
// Returns all digests specified in Digest header field. Sort
|
||||||
// strong algorithm first. Strength is defined in MessageDigest. If
|
// strong algorithm first. Strength is defined in MessageDigest. If
|
||||||
// several same digest algorithms are available, but they have
|
// several same digest algorithms are available, but they have
|
||||||
// different value, they are all ignored.
|
// different value, they are all ignored.
|
||||||
void getDigest(std::vector<Checksum>& result) const;
|
void getDigest(std::vector<Checksum>& result) const;
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -75,10 +75,8 @@
|
||||||
#include "SocketRecvBuffer.h"
|
#include "SocketRecvBuffer.h"
|
||||||
#include "MetalinkHttpEntry.h"
|
#include "MetalinkHttpEntry.h"
|
||||||
#include "NullProgressInfoFile.h"
|
#include "NullProgressInfoFile.h"
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
#include "Checksum.h"
|
||||||
# include "Checksum.h"
|
#include "ChecksumCheckIntegrityEntry.h"
|
||||||
# include "ChecksumCheckIntegrityEntry.h"
|
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
#ifdef HAVE_ZLIB
|
#ifdef HAVE_ZLIB
|
||||||
# include "GZipDecodingStreamFilter.h"
|
# include "GZipDecodingStreamFilter.h"
|
||||||
#endif // HAVE_ZLIB
|
#endif // HAVE_ZLIB
|
||||||
|
@ -210,7 +208,6 @@ bool HttpResponseCommand::executeInternal()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
if (httpHeader->defined(HttpHeader::DIGEST)) {
|
if (httpHeader->defined(HttpHeader::DIGEST)) {
|
||||||
std::vector<Checksum> checksums;
|
std::vector<Checksum> checksums;
|
||||||
httpResponse->getDigest(checksums);
|
httpResponse->getDigest(checksums);
|
||||||
|
@ -228,7 +225,6 @@ bool HttpResponseCommand::executeInternal()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(statusCode >= 300) {
|
if(statusCode >= 300) {
|
||||||
|
@ -280,7 +276,6 @@ bool HttpResponseCommand::executeInternal()
|
||||||
return handleDefaultEncoding(std::move(httpResponse));
|
return handleDefaultEncoding(std::move(httpResponse));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
if (!ctx->getHashType().empty() && httpHeader->defined(HttpHeader::DIGEST)) {
|
if (!ctx->getHashType().empty() && httpHeader->defined(HttpHeader::DIGEST)) {
|
||||||
std::vector<Checksum> checksums;
|
std::vector<Checksum> checksums;
|
||||||
httpResponse->getDigest(checksums);
|
httpResponse->getDigest(checksums);
|
||||||
|
@ -290,7 +285,6 @@ bool HttpResponseCommand::executeInternal()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
// validate totalsize
|
// validate totalsize
|
||||||
grp->validateTotalLength(fe->getLength(), httpResponse->getEntityLength());
|
grp->validateTotalLength(fe->getLength(), httpResponse->getEntityLength());
|
||||||
|
@ -424,7 +418,6 @@ bool HttpResponseCommand::handleOtherEncoding(
|
||||||
getRequestGroup()->downloadFinishedByFileLength()) {
|
getRequestGroup()->downloadFinishedByFileLength()) {
|
||||||
getRequestGroup()->initPieceStorage();
|
getRequestGroup()->initPieceStorage();
|
||||||
|
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
// TODO Known issue: if .aria2 file exists, it will not be deleted
|
// TODO Known issue: if .aria2 file exists, it will not be deleted
|
||||||
// on successful verification, because .aria2 file is not loaded.
|
// on successful verification, because .aria2 file is not loaded.
|
||||||
// See also FtpNegotiationCommand::onFileSizeDetermined()
|
// See also FtpNegotiationCommand::onFileSizeDetermined()
|
||||||
|
@ -434,9 +427,8 @@ bool HttpResponseCommand::handleOtherEncoding(
|
||||||
entry->initValidator();
|
entry->initValidator();
|
||||||
getPieceStorage()->getDiskAdaptor()->openExistingFile();
|
getPieceStorage()->getDiskAdaptor()->openExistingFile();
|
||||||
getDownloadEngine()->getCheckIntegrityMan()->pushEntry(std::move(entry));
|
getDownloadEngine()->getCheckIntegrityMan()->pushEntry(std::move(entry));
|
||||||
} else
|
}
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
else {
|
||||||
{
|
|
||||||
getPieceStorage()->markAllPiecesDone();
|
getPieceStorage()->markAllPiecesDone();
|
||||||
getDownloadContext()->setChecksumVerified(true);
|
getDownloadContext()->setChecksumVerified(true);
|
||||||
A2_LOG_NOTICE(fmt(MSG_DOWNLOAD_ALREADY_COMPLETED,
|
A2_LOG_NOTICE(fmt(MSG_DOWNLOAD_ALREADY_COMPLETED,
|
||||||
|
@ -459,14 +451,12 @@ bool HttpResponseCommand::handleOtherEncoding(
|
||||||
// TODO Known issue: if .aria2 file exists, it will not be deleted
|
// TODO Known issue: if .aria2 file exists, it will not be deleted
|
||||||
// on successful verification, because .aria2 file is not loaded.
|
// on successful verification, because .aria2 file is not loaded.
|
||||||
// See also FtpNegotiationCommand::onFileSizeDetermined()
|
// See also FtpNegotiationCommand::onFileSizeDetermined()
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
if (getDownloadContext()->isChecksumVerificationNeeded()) {
|
if (getDownloadContext()->isChecksumVerificationNeeded()) {
|
||||||
A2_LOG_DEBUG("Verify checksum for zero-length file");
|
A2_LOG_DEBUG("Verify checksum for zero-length file");
|
||||||
auto entry = make_unique<ChecksumCheckIntegrityEntry>(getRequestGroup());
|
auto entry = make_unique<ChecksumCheckIntegrityEntry>(getRequestGroup());
|
||||||
entry->initValidator();
|
entry->initValidator();
|
||||||
getDownloadEngine()->getCheckIntegrityMan()->pushEntry(std::move(entry));
|
getDownloadEngine()->getCheckIntegrityMan()->pushEntry(std::move(entry));
|
||||||
} else
|
} else
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
{
|
{
|
||||||
getRequestGroup()->getPieceStorage()->markAllPiecesDone();
|
getRequestGroup()->getPieceStorage()->markAllPiecesDone();
|
||||||
}
|
}
|
||||||
|
@ -572,7 +562,6 @@ void HttpResponseCommand::onDryRunFileFound()
|
||||||
poolConnection();
|
poolConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
bool HttpResponseCommand::checkChecksum(
|
bool HttpResponseCommand::checkChecksum(
|
||||||
const std::shared_ptr<DownloadContext>& dctx, const Checksum& checksum)
|
const std::shared_ptr<DownloadContext>& dctx, const Checksum& checksum)
|
||||||
{
|
{
|
||||||
|
@ -586,6 +575,5 @@ bool HttpResponseCommand::checkChecksum(
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -45,9 +45,7 @@ class HttpDownloadCommand;
|
||||||
class HttpResponse;
|
class HttpResponse;
|
||||||
class SocketCore;
|
class SocketCore;
|
||||||
class StreamFilter;
|
class StreamFilter;
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
class Checksum;
|
class Checksum;
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
// HttpResponseCommand receives HTTP response header from remote
|
// HttpResponseCommand receives HTTP response header from remote
|
||||||
// server. Because network I/O is non-blocking, execute() returns
|
// server. Because network I/O is non-blocking, execute() returns
|
||||||
|
@ -76,13 +74,11 @@ private:
|
||||||
void poolConnection();
|
void poolConnection();
|
||||||
|
|
||||||
void onDryRunFileFound();
|
void onDryRunFileFound();
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
// Returns true if dctx and checksum has same hash type and hash
|
// Returns true if dctx and checksum has same hash type and hash
|
||||||
// value. If they have same hash type but different hash value,
|
// value. If they have same hash type but different hash value,
|
||||||
// throws exception. Otherwise returns false.
|
// throws exception. Otherwise returns false.
|
||||||
bool checkChecksum(const std::shared_ptr<DownloadContext>& dctx,
|
bool checkChecksum(const std::shared_ptr<DownloadContext>& dctx,
|
||||||
const Checksum& checksum);
|
const Checksum& checksum);
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool executeInternal() CXX11_OVERRIDE;
|
bool executeInternal() CXX11_OVERRIDE;
|
||||||
|
|
|
@ -51,10 +51,8 @@
|
||||||
#include "fmt.h"
|
#include "fmt.h"
|
||||||
#include "SocketRecvBuffer.h"
|
#include "SocketRecvBuffer.h"
|
||||||
#include "base64.h"
|
#include "base64.h"
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
#include "MessageDigest.h"
|
||||||
# include "MessageDigest.h"
|
#include "message_digest_helper.h"
|
||||||
# include "message_digest_helper.h"
|
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
#ifdef ENABLE_WEBSOCKET
|
#ifdef ENABLE_WEBSOCKET
|
||||||
# include "WebSocketResponseCommand.h"
|
# include "WebSocketResponseCommand.h"
|
||||||
#endif // ENABLE_WEBSOCKET
|
#endif // ENABLE_WEBSOCKET
|
||||||
|
|
|
@ -251,7 +251,18 @@ SRCS = option_processing.cc\
|
||||||
HttpProxyRequestConnectChain.h\
|
HttpProxyRequestConnectChain.h\
|
||||||
FtpNegotiationConnectChain.h\
|
FtpNegotiationConnectChain.h\
|
||||||
FtpTunnelRequestConnectChain.h\
|
FtpTunnelRequestConnectChain.h\
|
||||||
Lock.h
|
Lock.h \
|
||||||
|
IteratableChunkChecksumValidator.cc IteratableChunkChecksumValidator.h\
|
||||||
|
IteratableChecksumValidator.cc IteratableChecksumValidator.h\
|
||||||
|
CheckIntegrityDispatcherCommand.cc CheckIntegrityDispatcherCommand.h\
|
||||||
|
CheckIntegrityCommand.cc CheckIntegrityCommand.h\
|
||||||
|
ChecksumCheckIntegrityEntry.cc ChecksumCheckIntegrityEntry.h\
|
||||||
|
message_digest_helper.cc message_digest_helper.h\
|
||||||
|
Checksum.cc Checksum.h\
|
||||||
|
ChunkChecksum.cc ChunkChecksum.h\
|
||||||
|
MessageDigest.cc MessageDigest.h\
|
||||||
|
MessageDigestImpl.h\
|
||||||
|
HashFuncEntry.h
|
||||||
|
|
||||||
if ANDROID
|
if ANDROID
|
||||||
SRCS += android/android.c
|
SRCS += android/android.c
|
||||||
|
@ -403,20 +414,6 @@ SRCS += AsyncNameResolver.cc AsyncNameResolver.h\
|
||||||
AsyncNameResolverMan.cc AsyncNameResolverMan.h
|
AsyncNameResolverMan.cc AsyncNameResolverMan.h
|
||||||
endif # ENABLE_ASYNC_DNS
|
endif # ENABLE_ASYNC_DNS
|
||||||
|
|
||||||
if ENABLE_MESSAGE_DIGEST
|
|
||||||
SRCS += IteratableChunkChecksumValidator.cc IteratableChunkChecksumValidator.h\
|
|
||||||
IteratableChecksumValidator.cc IteratableChecksumValidator.h\
|
|
||||||
CheckIntegrityDispatcherCommand.cc CheckIntegrityDispatcherCommand.h\
|
|
||||||
CheckIntegrityCommand.cc CheckIntegrityCommand.h\
|
|
||||||
ChecksumCheckIntegrityEntry.cc ChecksumCheckIntegrityEntry.h\
|
|
||||||
message_digest_helper.cc message_digest_helper.h\
|
|
||||||
Checksum.cc Checksum.h\
|
|
||||||
ChunkChecksum.cc ChunkChecksum.h\
|
|
||||||
MessageDigest.cc MessageDigest.h\
|
|
||||||
MessageDigestImpl.h\
|
|
||||||
HashFuncEntry.h
|
|
||||||
endif # ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
if ENABLE_BITTORRENT
|
if ENABLE_BITTORRENT
|
||||||
SRCS += PeerAbstractCommand.cc PeerAbstractCommand.h\
|
SRCS += PeerAbstractCommand.cc PeerAbstractCommand.h\
|
||||||
PeerInitiateConnectionCommand.cc PeerInitiateConnectionCommand.h\
|
PeerInitiateConnectionCommand.cc PeerInitiateConnectionCommand.h\
|
||||||
|
|
|
@ -64,10 +64,8 @@
|
||||||
# include "BtDependency.h"
|
# include "BtDependency.h"
|
||||||
# include "download_helper.h"
|
# include "download_helper.h"
|
||||||
#endif // ENABLE_BITTORRENT
|
#endif // ENABLE_BITTORRENT
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
#include "Checksum.h"
|
||||||
# include "Checksum.h"
|
#include "ChunkChecksum.h"
|
||||||
# include "ChunkChecksum.h"
|
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -255,15 +253,11 @@ Metalink2RequestGroup::createRequestGroup
|
||||||
// If piece hash is specified in the metalink,
|
// If piece hash is specified in the metalink,
|
||||||
// make segment size equal to piece hash size.
|
// make segment size equal to piece hash size.
|
||||||
int32_t pieceLength;
|
int32_t pieceLength;
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
if(!entry->chunkChecksum) {
|
if(!entry->chunkChecksum) {
|
||||||
pieceLength = option->getAsInt(PREF_PIECE_LENGTH);
|
pieceLength = option->getAsInt(PREF_PIECE_LENGTH);
|
||||||
} else {
|
} else {
|
||||||
pieceLength = entry->chunkChecksum->getPieceLength();
|
pieceLength = entry->chunkChecksum->getPieceLength();
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
pieceLength = option->getAsInt(PREF_PIECE_LENGTH);
|
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
dctx = std::make_shared<DownloadContext>
|
dctx = std::make_shared<DownloadContext>
|
||||||
(pieceLength,
|
(pieceLength,
|
||||||
entry->getLength(),
|
entry->getLength(),
|
||||||
|
@ -274,7 +268,6 @@ Metalink2RequestGroup::createRequestGroup
|
||||||
if(option->getAsBool(PREF_METALINK_ENABLE_UNIQUE_PROTOCOL)) {
|
if(option->getAsBool(PREF_METALINK_ENABLE_UNIQUE_PROTOCOL)) {
|
||||||
dctx->getFirstFileEntry()->setUniqueProtocol(true);
|
dctx->getFirstFileEntry()->setUniqueProtocol(true);
|
||||||
}
|
}
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
if(entry->checksum) {
|
if(entry->checksum) {
|
||||||
dctx->setDigest(entry->checksum->getHashType(),
|
dctx->setDigest(entry->checksum->getHashType(),
|
||||||
entry->checksum->getDigest());
|
entry->checksum->getDigest());
|
||||||
|
@ -285,7 +278,6 @@ Metalink2RequestGroup::createRequestGroup
|
||||||
std::begin(entry->chunkChecksum->getPieceHashes()),
|
std::begin(entry->chunkChecksum->getPieceHashes()),
|
||||||
std::end(entry->chunkChecksum->getPieceHashes()));
|
std::end(entry->chunkChecksum->getPieceHashes()));
|
||||||
}
|
}
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
dctx->setSignature(entry->popSignature());
|
dctx->setSignature(entry->popSignature());
|
||||||
rg->setNumConcurrentCommand
|
rg->setNumConcurrentCommand
|
||||||
(entry->maxConnections < 0 ?
|
(entry->maxConnections < 0 ?
|
||||||
|
|
|
@ -41,10 +41,8 @@
|
||||||
#include "FileEntry.h"
|
#include "FileEntry.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "a2functional.h"
|
#include "a2functional.h"
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
#include "Checksum.h"
|
||||||
# include "Checksum.h"
|
#include "ChunkChecksum.h"
|
||||||
# include "ChunkChecksum.h"
|
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
#include "Signature.h"
|
#include "Signature.h"
|
||||||
#include "SimpleRandomizer.h"
|
#include "SimpleRandomizer.h"
|
||||||
|
|
||||||
|
|
|
@ -46,10 +46,8 @@ namespace aria2 {
|
||||||
class MetalinkResource;
|
class MetalinkResource;
|
||||||
class MetalinkMetaurl;
|
class MetalinkMetaurl;
|
||||||
class FileEntry;
|
class FileEntry;
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
class Checksum;
|
class Checksum;
|
||||||
class ChunkChecksum;
|
class ChunkChecksum;
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
class Signature;
|
class Signature;
|
||||||
|
|
||||||
class MetalinkEntry {
|
class MetalinkEntry {
|
||||||
|
@ -63,10 +61,9 @@ public:
|
||||||
std::vector<std::unique_ptr<MetalinkResource>> resources;
|
std::vector<std::unique_ptr<MetalinkResource>> resources;
|
||||||
std::vector<std::unique_ptr<MetalinkMetaurl>> metaurls;
|
std::vector<std::unique_ptr<MetalinkMetaurl>> metaurls;
|
||||||
int maxConnections; // Metalink3Spec
|
int maxConnections; // Metalink3Spec
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
std::unique_ptr<Checksum> checksum;
|
std::unique_ptr<Checksum> checksum;
|
||||||
std::unique_ptr<ChunkChecksum> chunkChecksum;
|
std::unique_ptr<ChunkChecksum> chunkChecksum;
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<Signature> signature_;
|
std::unique_ptr<Signature> signature_;
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -46,11 +46,9 @@
|
||||||
#include "uri.h"
|
#include "uri.h"
|
||||||
#include "Signature.h"
|
#include "Signature.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
#include "Checksum.h"
|
||||||
# include "Checksum.h"
|
#include "ChunkChecksum.h"
|
||||||
# include "ChunkChecksum.h"
|
#include "MessageDigest.h"
|
||||||
# include "MessageDigest.h"
|
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
#ifdef ENABLE_BITTORRENT
|
#ifdef ENABLE_BITTORRENT
|
||||||
# include "magnet.h"
|
# include "magnet.h"
|
||||||
#endif // ENABLE_BITTORRENT
|
#endif // ENABLE_BITTORRENT
|
||||||
|
@ -78,11 +76,9 @@ void MetalinkParserController::newEntryTransaction()
|
||||||
tEntry_ = make_unique<MetalinkEntry>();
|
tEntry_ = make_unique<MetalinkEntry>();
|
||||||
tResource_.reset();
|
tResource_.reset();
|
||||||
tMetaurl_.reset();
|
tMetaurl_.reset();
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
tChecksum_.reset();
|
tChecksum_.reset();
|
||||||
tChunkChecksumV4_.reset();
|
tChunkChecksumV4_.reset();
|
||||||
tChunkChecksum_.reset();
|
tChunkChecksum_.reset();
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetalinkParserController::setFileNameOfEntry(std::string filename)
|
void MetalinkParserController::setFileNameOfEntry(std::string filename)
|
||||||
|
@ -263,17 +259,14 @@ void MetalinkParserController::cancelResourceTransaction()
|
||||||
|
|
||||||
void MetalinkParserController::newChecksumTransaction()
|
void MetalinkParserController::newChecksumTransaction()
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
if(!tEntry_) {
|
if(!tEntry_) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
tChecksum_ = make_unique<Checksum>();
|
tChecksum_ = make_unique<Checksum>();
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetalinkParserController::setTypeOfChecksum(std::string type)
|
void MetalinkParserController::setTypeOfChecksum(std::string type)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
if(!tChecksum_) {
|
if(!tChecksum_) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -283,12 +276,10 @@ void MetalinkParserController::setTypeOfChecksum(std::string type)
|
||||||
} else {
|
} else {
|
||||||
cancelChecksumTransaction();
|
cancelChecksumTransaction();
|
||||||
}
|
}
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetalinkParserController::setHashOfChecksum(std::string md)
|
void MetalinkParserController::setHashOfChecksum(std::string md)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
if(!tChecksum_) {
|
if(!tChecksum_) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -297,12 +288,10 @@ void MetalinkParserController::setHashOfChecksum(std::string md)
|
||||||
} else {
|
} else {
|
||||||
cancelChecksumTransaction();
|
cancelChecksumTransaction();
|
||||||
}
|
}
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetalinkParserController::commitChecksumTransaction()
|
void MetalinkParserController::commitChecksumTransaction()
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
if(!tChecksum_) {
|
if(!tChecksum_) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -312,30 +301,24 @@ void MetalinkParserController::commitChecksumTransaction()
|
||||||
tEntry_->checksum = std::move(tChecksum_);
|
tEntry_->checksum = std::move(tChecksum_);
|
||||||
}
|
}
|
||||||
tChecksum_.reset();
|
tChecksum_.reset();
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetalinkParserController::cancelChecksumTransaction()
|
void MetalinkParserController::cancelChecksumTransaction()
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
tChecksum_.reset();
|
tChecksum_.reset();
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetalinkParserController::newChunkChecksumTransactionV4()
|
void MetalinkParserController::newChunkChecksumTransactionV4()
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
if(!tEntry_) {
|
if(!tEntry_) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
tChunkChecksumV4_ = make_unique<ChunkChecksum>();
|
tChunkChecksumV4_ = make_unique<ChunkChecksum>();
|
||||||
tempChunkChecksumsV4_.clear();
|
tempChunkChecksumsV4_.clear();
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetalinkParserController::setTypeOfChunkChecksumV4(std::string type)
|
void MetalinkParserController::setTypeOfChunkChecksumV4(std::string type)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
if(!tChunkChecksumV4_) {
|
if(!tChunkChecksumV4_) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -345,12 +328,10 @@ void MetalinkParserController::setTypeOfChunkChecksumV4(std::string type)
|
||||||
} else {
|
} else {
|
||||||
cancelChunkChecksumTransactionV4();
|
cancelChunkChecksumTransactionV4();
|
||||||
}
|
}
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetalinkParserController::setLengthOfChunkChecksumV4(size_t length)
|
void MetalinkParserController::setLengthOfChunkChecksumV4(size_t length)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
if(!tChunkChecksumV4_) {
|
if(!tChunkChecksumV4_) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -359,12 +340,10 @@ void MetalinkParserController::setLengthOfChunkChecksumV4(size_t length)
|
||||||
} else {
|
} else {
|
||||||
cancelChunkChecksumTransactionV4();
|
cancelChunkChecksumTransactionV4();
|
||||||
}
|
}
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetalinkParserController::addHashOfChunkChecksumV4(std::string md)
|
void MetalinkParserController::addHashOfChunkChecksumV4(std::string md)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
if(!tChunkChecksumV4_) {
|
if(!tChunkChecksumV4_) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -373,12 +352,10 @@ void MetalinkParserController::addHashOfChunkChecksumV4(std::string md)
|
||||||
} else {
|
} else {
|
||||||
cancelChunkChecksumTransactionV4();
|
cancelChunkChecksumTransactionV4();
|
||||||
}
|
}
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetalinkParserController::commitChunkChecksumTransactionV4()
|
void MetalinkParserController::commitChunkChecksumTransactionV4()
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
if(!tChunkChecksumV4_) {
|
if(!tChunkChecksumV4_) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -389,30 +366,24 @@ void MetalinkParserController::commitChunkChecksumTransactionV4()
|
||||||
tEntry_->chunkChecksum = std::move(tChunkChecksumV4_);
|
tEntry_->chunkChecksum = std::move(tChunkChecksumV4_);
|
||||||
}
|
}
|
||||||
tChunkChecksumV4_.reset();
|
tChunkChecksumV4_.reset();
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetalinkParserController::cancelChunkChecksumTransactionV4()
|
void MetalinkParserController::cancelChunkChecksumTransactionV4()
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
tChunkChecksumV4_.reset();
|
tChunkChecksumV4_.reset();
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetalinkParserController::newChunkChecksumTransaction()
|
void MetalinkParserController::newChunkChecksumTransaction()
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
if(!tEntry_) {
|
if(!tEntry_) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
tChunkChecksum_ = make_unique<ChunkChecksum>();
|
tChunkChecksum_ = make_unique<ChunkChecksum>();
|
||||||
tempChunkChecksums_.clear();
|
tempChunkChecksums_.clear();
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetalinkParserController::setTypeOfChunkChecksum(std::string type)
|
void MetalinkParserController::setTypeOfChunkChecksum(std::string type)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
if(!tChunkChecksum_) {
|
if(!tChunkChecksum_) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -422,12 +393,10 @@ void MetalinkParserController::setTypeOfChunkChecksum(std::string type)
|
||||||
} else {
|
} else {
|
||||||
cancelChunkChecksumTransaction();
|
cancelChunkChecksumTransaction();
|
||||||
}
|
}
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetalinkParserController::setLengthOfChunkChecksum(size_t length)
|
void MetalinkParserController::setLengthOfChunkChecksum(size_t length)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
if(!tChunkChecksum_) {
|
if(!tChunkChecksum_) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -436,13 +405,11 @@ void MetalinkParserController::setLengthOfChunkChecksum(size_t length)
|
||||||
} else {
|
} else {
|
||||||
cancelChunkChecksumTransaction();
|
cancelChunkChecksumTransaction();
|
||||||
}
|
}
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetalinkParserController::addHashOfChunkChecksum(size_t order,
|
void MetalinkParserController::addHashOfChunkChecksum(size_t order,
|
||||||
std::string md)
|
std::string md)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
if(!tChunkChecksum_) {
|
if(!tChunkChecksum_) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -451,22 +418,18 @@ void MetalinkParserController::addHashOfChunkChecksum(size_t order,
|
||||||
} else {
|
} else {
|
||||||
cancelChunkChecksumTransaction();
|
cancelChunkChecksumTransaction();
|
||||||
}
|
}
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetalinkParserController::createNewHashOfChunkChecksum(size_t order)
|
void MetalinkParserController::createNewHashOfChunkChecksum(size_t order)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
if(!tChunkChecksum_) {
|
if(!tChunkChecksum_) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
tempHashPair_.first = order;
|
tempHashPair_.first = order;
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetalinkParserController::setMessageDigestOfChunkChecksum(std::string md)
|
void MetalinkParserController::setMessageDigestOfChunkChecksum(std::string md)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
if(!tChunkChecksum_) {
|
if(!tChunkChecksum_) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -475,22 +438,18 @@ void MetalinkParserController::setMessageDigestOfChunkChecksum(std::string md)
|
||||||
} else {
|
} else {
|
||||||
cancelChunkChecksumTransaction();
|
cancelChunkChecksumTransaction();
|
||||||
}
|
}
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetalinkParserController::addHashOfChunkChecksum()
|
void MetalinkParserController::addHashOfChunkChecksum()
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
if(!tChunkChecksum_) {
|
if(!tChunkChecksum_) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
tempChunkChecksums_.push_back(tempHashPair_);
|
tempChunkChecksums_.push_back(tempHashPair_);
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetalinkParserController::commitChunkChecksumTransaction()
|
void MetalinkParserController::commitChunkChecksumTransaction()
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
if(!tChunkChecksum_) {
|
if(!tChunkChecksum_) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -508,14 +467,11 @@ void MetalinkParserController::commitChunkChecksumTransaction()
|
||||||
tEntry_->chunkChecksum = std::move(tChunkChecksum_);
|
tEntry_->chunkChecksum = std::move(tChunkChecksum_);
|
||||||
}
|
}
|
||||||
tChunkChecksum_.reset();
|
tChunkChecksum_.reset();
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetalinkParserController::cancelChunkChecksumTransaction()
|
void MetalinkParserController::cancelChunkChecksumTransaction()
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
tChunkChecksum_.reset();
|
tChunkChecksum_.reset();
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetalinkParserController::newSignatureTransaction()
|
void MetalinkParserController::newSignatureTransaction()
|
||||||
|
|
|
@ -50,10 +50,8 @@ class MetalinkResource;
|
||||||
class MetalinkMetaurl;
|
class MetalinkMetaurl;
|
||||||
class Signature;
|
class Signature;
|
||||||
|
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
class Checksum;
|
class Checksum;
|
||||||
class ChunkChecksum;
|
class ChunkChecksum;
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
class MetalinkParserController {
|
class MetalinkParserController {
|
||||||
private:
|
private:
|
||||||
|
@ -64,7 +62,7 @@ private:
|
||||||
std::unique_ptr<MetalinkResource> tResource_;
|
std::unique_ptr<MetalinkResource> tResource_;
|
||||||
|
|
||||||
std::unique_ptr<MetalinkMetaurl> tMetaurl_;
|
std::unique_ptr<MetalinkMetaurl> tMetaurl_;
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
std::unique_ptr<Checksum> tChecksum_;
|
std::unique_ptr<Checksum> tChecksum_;
|
||||||
|
|
||||||
std::unique_ptr<ChunkChecksum> tChunkChecksumV4_; // Metalink4Spec
|
std::unique_ptr<ChunkChecksum> tChunkChecksumV4_; // Metalink4Spec
|
||||||
|
@ -77,8 +75,6 @@ private:
|
||||||
|
|
||||||
std::pair<size_t, std::string> tempHashPair_; // Metalink3Spec
|
std::pair<size_t, std::string> tempHashPair_; // Metalink3Spec
|
||||||
|
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
std::unique_ptr<Signature> tSignature_;
|
std::unique_ptr<Signature> tSignature_;
|
||||||
std::string baseUri_;
|
std::string baseUri_;
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -194,7 +194,6 @@ void VerificationMetalinkParserState::beginElement
|
||||||
if(!checkNsUri(nsUri)) {
|
if(!checkNsUri(nsUri)) {
|
||||||
psm->setSkipTagState();
|
psm->setSkipTagState();
|
||||||
} else
|
} else
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
if(strcmp(localname, "hash") == 0) {
|
if(strcmp(localname, "hash") == 0) {
|
||||||
psm->setHashState();
|
psm->setHashState();
|
||||||
auto itr = findAttr(attrs, "type", METALINK3_NAMESPACE_URI);
|
auto itr = findAttr(attrs, "type", METALINK3_NAMESPACE_URI);
|
||||||
|
@ -231,7 +230,6 @@ void VerificationMetalinkParserState::beginElement
|
||||||
psm->setLengthOfChunkChecksum(length);
|
psm->setLengthOfChunkChecksum(length);
|
||||||
psm->setTypeOfChunkChecksum(type);
|
psm->setTypeOfChunkChecksum(type);
|
||||||
} else
|
} else
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
if(strcmp(localname, "signature") == 0) {
|
if(strcmp(localname, "signature") == 0) {
|
||||||
psm->setSignatureState();
|
psm->setSignatureState();
|
||||||
auto itr = findAttr(attrs, "type", METALINK3_NAMESPACE_URI);
|
auto itr = findAttr(attrs, "type", METALINK3_NAMESPACE_URI);
|
||||||
|
|
|
@ -166,7 +166,6 @@ void FileMetalinkParserStateV4::beginElement
|
||||||
psm->setLocationOfResource(location);
|
psm->setLocationOfResource(location);
|
||||||
psm->setPriorityOfResource(priority);
|
psm->setPriorityOfResource(priority);
|
||||||
}
|
}
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
else if(strcmp(localname, "hash") == 0) {
|
else if(strcmp(localname, "hash") == 0) {
|
||||||
psm->setHashStateV4();
|
psm->setHashStateV4();
|
||||||
auto itr = findAttr(attrs, "type", METALINK4_NAMESPACE_URI);
|
auto itr = findAttr(attrs, "type", METALINK4_NAMESPACE_URI);
|
||||||
|
@ -203,7 +202,6 @@ void FileMetalinkParserStateV4::beginElement
|
||||||
psm->setLengthOfChunkChecksumV4(length);
|
psm->setLengthOfChunkChecksumV4(length);
|
||||||
psm->setTypeOfChunkChecksumV4(type);
|
psm->setTypeOfChunkChecksumV4(type);
|
||||||
}
|
}
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
else if(strcmp(localname, "signature") == 0) {
|
else if(strcmp(localname, "signature") == 0) {
|
||||||
psm->setSignatureStateV4();
|
psm->setSignatureStateV4();
|
||||||
auto itr = findAttr(attrs, "mediatype", METALINK4_NAMESPACE_URI);
|
auto itr = findAttr(attrs, "mediatype", METALINK4_NAMESPACE_URI);
|
||||||
|
|
|
@ -140,7 +140,6 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()
|
||||||
op->addTag(TAG_ADVANCED);
|
op->addTag(TAG_ADVANCED);
|
||||||
handlers.push_back(op);
|
handlers.push_back(op);
|
||||||
}
|
}
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
{
|
{
|
||||||
OptionHandler* op(new BooleanOptionHandler
|
OptionHandler* op(new BooleanOptionHandler
|
||||||
(PREF_CHECK_INTEGRITY,
|
(PREF_CHECK_INTEGRITY,
|
||||||
|
@ -158,7 +157,6 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()
|
||||||
op->setChangeOptionForReserved(true);
|
op->setChangeOptionForReserved(true);
|
||||||
handlers.push_back(op);
|
handlers.push_back(op);
|
||||||
}
|
}
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
{
|
{
|
||||||
OptionHandler* op(new BooleanOptionHandler
|
OptionHandler* op(new BooleanOptionHandler
|
||||||
(PREF_CONDITIONAL_GET,
|
(PREF_CONDITIONAL_GET,
|
||||||
|
@ -426,7 +424,6 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()
|
||||||
op->setInitialOption(true);
|
op->setInitialOption(true);
|
||||||
handlers.push_back(op);
|
handlers.push_back(op);
|
||||||
}
|
}
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
{
|
{
|
||||||
OptionHandler* op(new BooleanOptionHandler
|
OptionHandler* op(new BooleanOptionHandler
|
||||||
(PREF_HASH_CHECK_ONLY,
|
(PREF_HASH_CHECK_ONLY,
|
||||||
|
@ -443,7 +440,6 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()
|
||||||
op->setChangeOptionForReserved(true);
|
op->setChangeOptionForReserved(true);
|
||||||
handlers.push_back(op);
|
handlers.push_back(op);
|
||||||
}
|
}
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
{
|
{
|
||||||
OptionHandler* op(new BooleanOptionHandler
|
OptionHandler* op(new BooleanOptionHandler
|
||||||
(PREF_HUMAN_READABLE,
|
(PREF_HUMAN_READABLE,
|
||||||
|
@ -693,7 +689,6 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()
|
||||||
op->addTag(TAG_ADVANCED);
|
op->addTag(TAG_ADVANCED);
|
||||||
handlers.push_back(op);
|
handlers.push_back(op);
|
||||||
}
|
}
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
{
|
{
|
||||||
OptionHandler* op(new BooleanOptionHandler
|
OptionHandler* op(new BooleanOptionHandler
|
||||||
(PREF_REALTIME_CHUNK_CHECKSUM,
|
(PREF_REALTIME_CHUNK_CHECKSUM,
|
||||||
|
@ -707,7 +702,6 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()
|
||||||
op->setChangeOptionForReserved(true);
|
op->setChangeOptionForReserved(true);
|
||||||
handlers.push_back(op);
|
handlers.push_back(op);
|
||||||
}
|
}
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
{
|
{
|
||||||
OptionHandler* op(new BooleanOptionHandler
|
OptionHandler* op(new BooleanOptionHandler
|
||||||
(PREF_REMOVE_CONTROL_FILE,
|
(PREF_REMOVE_CONTROL_FILE,
|
||||||
|
@ -914,7 +908,6 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()
|
||||||
handlers.push_back(op);
|
handlers.push_back(op);
|
||||||
}
|
}
|
||||||
// HTTP/FTP options
|
// HTTP/FTP options
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
{
|
{
|
||||||
OptionHandler* op(new ChecksumOptionHandler
|
OptionHandler* op(new ChecksumOptionHandler
|
||||||
(PREF_CHECKSUM,
|
(PREF_CHECKSUM,
|
||||||
|
@ -926,7 +919,6 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()
|
||||||
op->setChangeOptionForReserved(true);
|
op->setChangeOptionForReserved(true);
|
||||||
handlers.push_back(op);
|
handlers.push_back(op);
|
||||||
}
|
}
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
{
|
{
|
||||||
OptionHandler* op(new NumberOptionHandler
|
OptionHandler* op(new NumberOptionHandler
|
||||||
(PREF_CONNECT_TIMEOUT,
|
(PREF_CONNECT_TIMEOUT,
|
||||||
|
|
|
@ -61,9 +61,7 @@
|
||||||
#include "SegList.h"
|
#include "SegList.h"
|
||||||
#include "array_fun.h"
|
#include "array_fun.h"
|
||||||
#include "help_tags.h"
|
#include "help_tags.h"
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
#include "MessageDigest.h"
|
||||||
# include "MessageDigest.h"
|
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -368,7 +366,6 @@ std::string IndexOutOptionHandler::createPossibleValuesString() const
|
||||||
return "INDEX=PATH";
|
return "INDEX=PATH";
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
ChecksumOptionHandler::ChecksumOptionHandler
|
ChecksumOptionHandler::ChecksumOptionHandler
|
||||||
(PrefPtr pref,
|
(PrefPtr pref,
|
||||||
const char* description,
|
const char* description,
|
||||||
|
@ -397,7 +394,6 @@ std::string ChecksumOptionHandler::createPossibleValuesString() const
|
||||||
{
|
{
|
||||||
return "HASH_TYPE=HEX_DIGEST";
|
return "HASH_TYPE=HEX_DIGEST";
|
||||||
}
|
}
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
ParameterOptionHandler::ParameterOptionHandler
|
ParameterOptionHandler::ParameterOptionHandler
|
||||||
(PrefPtr pref,
|
(PrefPtr pref,
|
||||||
|
|
|
@ -172,7 +172,6 @@ public:
|
||||||
virtual std::string createPossibleValuesString() const CXX11_OVERRIDE;
|
virtual std::string createPossibleValuesString() const CXX11_OVERRIDE;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
class ChecksumOptionHandler : public AbstractOptionHandler {
|
class ChecksumOptionHandler : public AbstractOptionHandler {
|
||||||
public:
|
public:
|
||||||
ChecksumOptionHandler(PrefPtr pref,
|
ChecksumOptionHandler(PrefPtr pref,
|
||||||
|
@ -183,7 +182,6 @@ public:
|
||||||
CXX11_OVERRIDE;
|
CXX11_OVERRIDE;
|
||||||
virtual std::string createPossibleValuesString() const CXX11_OVERRIDE;
|
virtual std::string createPossibleValuesString() const CXX11_OVERRIDE;
|
||||||
};
|
};
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
class ParameterOptionHandler : public AbstractOptionHandler {
|
class ParameterOptionHandler : public AbstractOptionHandler {
|
||||||
private:
|
private:
|
||||||
|
|
14
src/Piece.cc
14
src/Piece.cc
|
@ -46,9 +46,7 @@
|
||||||
#include "LogFactory.h"
|
#include "LogFactory.h"
|
||||||
#include "fmt.h"
|
#include "fmt.h"
|
||||||
#include "DiskAdaptor.h"
|
#include "DiskAdaptor.h"
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
#include "MessageDigest.h"
|
||||||
# include "MessageDigest.h"
|
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -58,9 +56,7 @@ Piece::Piece()
|
||||||
index_(0),
|
index_(0),
|
||||||
length_(0),
|
length_(0),
|
||||||
blockLength_(BLOCK_LENGTH),
|
blockLength_(BLOCK_LENGTH),
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
nextBegin_(0),
|
nextBegin_(0),
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
usedBySegment_(false)
|
usedBySegment_(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
@ -70,9 +66,7 @@ Piece::Piece(size_t index, int32_t length, int32_t blockLength)
|
||||||
index_(index),
|
index_(index),
|
||||||
length_(length),
|
length_(length),
|
||||||
blockLength_(blockLength),
|
blockLength_(blockLength),
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
nextBegin_(0),
|
||||||
nextBegin_(0),
|
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
usedBySegment_(false)
|
usedBySegment_(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
@ -208,8 +202,6 @@ int32_t Piece::getCompletedLength()
|
||||||
return bitfield_->getCompletedLength();
|
return bitfield_->getCompletedLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
void Piece::setHashType(const std::string& hashType)
|
void Piece::setHashType(const std::string& hashType)
|
||||||
{
|
{
|
||||||
hashType_ = hashType;
|
hashType_ = hashType;
|
||||||
|
@ -304,8 +296,6 @@ void Piece::destroyHashContext()
|
||||||
nextBegin_ = 0;
|
nextBegin_ = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
bool Piece::usedBy(cuid_t cuid) const
|
bool Piece::usedBy(cuid_t cuid) const
|
||||||
{
|
{
|
||||||
return std::find(users_.begin(), users_.end(), cuid) != users_.end();
|
return std::find(users_.begin(), users_.end(), cuid) != users_.end();
|
||||||
|
|
15
src/Piece.h
15
src/Piece.h
|
@ -50,32 +50,21 @@ class BitfieldMan;
|
||||||
class WrDiskCache;
|
class WrDiskCache;
|
||||||
class WrDiskCacheEntry;
|
class WrDiskCacheEntry;
|
||||||
class DiskAdaptor;
|
class DiskAdaptor;
|
||||||
|
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
class MessageDigest;
|
class MessageDigest;
|
||||||
|
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
class Piece {
|
class Piece {
|
||||||
private:
|
private:
|
||||||
BitfieldMan* bitfield_;
|
BitfieldMan* bitfield_;
|
||||||
WrDiskCacheEntry* wrCache_;
|
WrDiskCacheEntry* wrCache_;
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
std::unique_ptr<MessageDigest> mdctx_;
|
std::unique_ptr<MessageDigest> mdctx_;
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
std::vector<cuid_t> users_;
|
std::vector<cuid_t> users_;
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
std::string hashType_;
|
std::string hashType_;
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
size_t index_;
|
size_t index_;
|
||||||
|
|
||||||
int32_t length_;
|
int32_t length_;
|
||||||
int32_t blockLength_;
|
int32_t blockLength_;
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
int32_t nextBegin_;
|
int32_t nextBegin_;
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
bool usedBySegment_;
|
bool usedBySegment_;
|
||||||
|
|
||||||
|
@ -158,8 +147,6 @@ public:
|
||||||
// Calculates completed length
|
// Calculates completed length
|
||||||
int32_t getCompletedLength();
|
int32_t getCompletedLength();
|
||||||
|
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
void setHashType(const std::string& hashType);
|
void setHashType(const std::string& hashType);
|
||||||
|
|
||||||
// Updates hash value. This function compares begin and private variable
|
// Updates hash value. This function compares begin and private variable
|
||||||
|
@ -181,8 +168,6 @@ public:
|
||||||
// cached data and data on disk.
|
// cached data and data on disk.
|
||||||
std::string getDigestWithWrCache(size_t pieceLength,
|
std::string getDigestWithWrCache(size_t pieceLength,
|
||||||
const std::shared_ptr<DiskAdaptor>& adaptor);
|
const std::shared_ptr<DiskAdaptor>& adaptor);
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loses current bitfield state.
|
* Loses current bitfield state.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -58,13 +58,11 @@ bool PieceHashCheckIntegrityEntry::isValidationReady()
|
||||||
|
|
||||||
void PieceHashCheckIntegrityEntry::initValidator()
|
void PieceHashCheckIntegrityEntry::initValidator()
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
auto validator = make_unique<IteratableChunkChecksumValidator>
|
auto validator = make_unique<IteratableChunkChecksumValidator>
|
||||||
(getRequestGroup()->getDownloadContext(),
|
(getRequestGroup()->getDownloadContext(),
|
||||||
getRequestGroup()->getPieceStorage());
|
getRequestGroup()->getPieceStorage());
|
||||||
validator->init();
|
validator->init();
|
||||||
setValidator(std::move(validator));
|
setValidator(std::move(validator));
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -90,8 +90,6 @@ void PiecedSegment::updateWrittenLength(int32_t bytes)
|
||||||
writtenLength_ = newWrittenLength;
|
writtenLength_ = newWrittenLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
bool PiecedSegment::updateHash
|
bool PiecedSegment::updateHash
|
||||||
(int32_t begin,
|
(int32_t begin,
|
||||||
const unsigned char* data,
|
const unsigned char* data,
|
||||||
|
@ -110,18 +108,12 @@ std::string PiecedSegment::getDigest()
|
||||||
return piece_->getDigest();
|
return piece_->getDigest();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
void PiecedSegment::clear(WrDiskCache* diskCache)
|
void PiecedSegment::clear(WrDiskCache* diskCache)
|
||||||
{
|
{
|
||||||
writtenLength_ = 0;
|
writtenLength_ = 0;
|
||||||
piece_->clearAllBlock(diskCache);
|
piece_->clearAllBlock(diskCache);
|
||||||
|
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
piece_->destroyHashContext();
|
piece_->destroyHashContext();
|
||||||
|
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Piece> PiecedSegment::getPiece() const
|
std::shared_ptr<Piece> PiecedSegment::getPiece() const
|
||||||
|
|
|
@ -76,8 +76,6 @@ public:
|
||||||
|
|
||||||
virtual void updateWrittenLength(int32_t bytes) CXX11_OVERRIDE;
|
virtual void updateWrittenLength(int32_t bytes) CXX11_OVERRIDE;
|
||||||
|
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
// `begin' is a offset inside this segment.
|
// `begin' is a offset inside this segment.
|
||||||
virtual bool updateHash
|
virtual bool updateHash
|
||||||
(int32_t begin,
|
(int32_t begin,
|
||||||
|
@ -88,8 +86,6 @@ public:
|
||||||
|
|
||||||
virtual std::string getDigest() CXX11_OVERRIDE;
|
virtual std::string getDigest() CXX11_OVERRIDE;
|
||||||
|
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
virtual void clear(WrDiskCache* diskCache) CXX11_OVERRIDE;
|
virtual void clear(WrDiskCache* diskCache) CXX11_OVERRIDE;
|
||||||
|
|
||||||
virtual std::shared_ptr<Piece> getPiece() const CXX11_OVERRIDE;
|
virtual std::shared_ptr<Piece> getPiece() const CXX11_OVERRIDE;
|
||||||
|
|
|
@ -79,10 +79,8 @@
|
||||||
#include "Segment.h"
|
#include "Segment.h"
|
||||||
#include "SocketRecvBuffer.h"
|
#include "SocketRecvBuffer.h"
|
||||||
#include "RequestGroupCriteria.h"
|
#include "RequestGroupCriteria.h"
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
#include "CheckIntegrityCommand.h"
|
||||||
# include "CheckIntegrityCommand.h"
|
#include "ChecksumCheckIntegrityEntry.h"
|
||||||
# include "ChecksumCheckIntegrityEntry.h"
|
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
#ifdef ENABLE_BITTORRENT
|
#ifdef ENABLE_BITTORRENT
|
||||||
# include "bittorrent_helper.h"
|
# include "bittorrent_helper.h"
|
||||||
# include "BtRegistry.h"
|
# include "BtRegistry.h"
|
||||||
|
@ -240,14 +238,12 @@ std::unique_ptr<CheckIntegrityEntry> RequestGroup::createCheckIntegrityEntry()
|
||||||
// issue checksum verification and download fails without it.
|
// issue checksum verification and download fails without it.
|
||||||
loadAndOpenFile(infoFile);
|
loadAndOpenFile(infoFile);
|
||||||
if(downloadFinished()) {
|
if(downloadFinished()) {
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
if(downloadContext_->isChecksumVerificationNeeded()) {
|
if(downloadContext_->isChecksumVerificationNeeded()) {
|
||||||
A2_LOG_INFO(MSG_HASH_CHECK_NOT_DONE);
|
A2_LOG_INFO(MSG_HASH_CHECK_NOT_DONE);
|
||||||
auto tempEntry = make_unique<ChecksumCheckIntegrityEntry>(this);
|
auto tempEntry = make_unique<ChecksumCheckIntegrityEntry>(this);
|
||||||
tempEntry->setRedownload(true);
|
tempEntry->setRedownload(true);
|
||||||
return std::move(tempEntry);
|
return std::move(tempEntry);
|
||||||
}
|
}
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
downloadContext_->setChecksumVerified(true);
|
downloadContext_->setChecksumVerified(true);
|
||||||
A2_LOG_NOTICE(fmt(MSG_DOWNLOAD_ALREADY_COMPLETED,
|
A2_LOG_NOTICE(fmt(MSG_DOWNLOAD_ALREADY_COMPLETED,
|
||||||
gid_->toHex().c_str(),
|
gid_->toHex().c_str(),
|
||||||
|
@ -257,7 +253,6 @@ std::unique_ptr<CheckIntegrityEntry> RequestGroup::createCheckIntegrityEntry()
|
||||||
return make_unique<StreamCheckIntegrityEntry>(this);
|
return make_unique<StreamCheckIntegrityEntry>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
if (downloadFinishedByFileLength() &&
|
if (downloadFinishedByFileLength() &&
|
||||||
downloadContext_->isChecksumVerificationAvailable()) {
|
downloadContext_->isChecksumVerificationAvailable()) {
|
||||||
pieceStorage_->markAllPiecesDone();
|
pieceStorage_->markAllPiecesDone();
|
||||||
|
@ -266,7 +261,6 @@ std::unique_ptr<CheckIntegrityEntry> RequestGroup::createCheckIntegrityEntry()
|
||||||
tempEntry->setRedownload(true);
|
tempEntry->setRedownload(true);
|
||||||
return std::move(tempEntry);
|
return std::move(tempEntry);
|
||||||
}
|
}
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
loadAndOpenFile(infoFile);
|
loadAndOpenFile(infoFile);
|
||||||
return make_unique<StreamCheckIntegrityEntry>(this);
|
return make_unique<StreamCheckIntegrityEntry>(this);
|
||||||
|
@ -520,7 +514,6 @@ void RequestGroup::processCheckIntegrityEntry(
|
||||||
if(actualFileSize > downloadContext_->getTotalLength()) {
|
if(actualFileSize > downloadContext_->getTotalLength()) {
|
||||||
entry->cutTrailingGarbage();
|
entry->cutTrailingGarbage();
|
||||||
}
|
}
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
if((option_->getAsBool(PREF_CHECK_INTEGRITY) ||
|
if((option_->getAsBool(PREF_CHECK_INTEGRITY) ||
|
||||||
downloadContext_->isChecksumVerificationNeeded()) &&
|
downloadContext_->isChecksumVerificationNeeded()) &&
|
||||||
entry->isValidationReady()) {
|
entry->isValidationReady()) {
|
||||||
|
@ -535,7 +528,6 @@ void RequestGroup::processCheckIntegrityEntry(
|
||||||
e->getCheckIntegrityMan()->pushEntry(std::move(entry));
|
e->getCheckIntegrityMan()->pushEntry(std::move(entry));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
entry->onDownloadIncomplete(commands, e);
|
entry->onDownloadIncomplete(commands, e);
|
||||||
}
|
}
|
||||||
|
@ -664,16 +656,12 @@ void RequestGroup::adjustFilename(
|
||||||
outfile.size() <= downloadContext_->getTotalLength()) {
|
outfile.size() <= downloadContext_->getTotalLength()) {
|
||||||
// File exists but user decided to resume it.
|
// File exists but user decided to resume it.
|
||||||
}
|
}
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
else if(outfile.exists() && isCheckIntegrityReady()) {
|
else if(outfile.exists() && isCheckIntegrityReady()) {
|
||||||
// check-integrity existing file
|
// check-integrity existing file
|
||||||
}
|
}
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
else {
|
else {
|
||||||
shouldCancelDownloadForSafety();
|
shouldCancelDownloadForSafety();
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
}
|
}
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RequestGroup::removeDefunctControlFile(
|
void RequestGroup::removeDefunctControlFile(
|
||||||
|
@ -709,11 +697,9 @@ void RequestGroup::loadAndOpenFile(
|
||||||
pieceStorage_->getDiskAdaptor()->openExistingFile();
|
pieceStorage_->getDiskAdaptor()->openExistingFile();
|
||||||
pieceStorage_->markPiecesDone(outfile.size());
|
pieceStorage_->markPiecesDone(outfile.size());
|
||||||
}
|
}
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
else if (outfile.exists() && isCheckIntegrityReady()) {
|
else if (outfile.exists() && isCheckIntegrityReady()) {
|
||||||
pieceStorage_->getDiskAdaptor()->openExistingFile();
|
pieceStorage_->getDiskAdaptor()->openExistingFile();
|
||||||
}
|
}
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
else {
|
else {
|
||||||
pieceStorage_->getDiskAdaptor()->initAndOpenFile();
|
pieceStorage_->getDiskAdaptor()->initAndOpenFile();
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,10 +66,8 @@
|
||||||
#include "base64.h"
|
#include "base64.h"
|
||||||
#include "BitfieldMan.h"
|
#include "BitfieldMan.h"
|
||||||
#include "SessionSerializer.h"
|
#include "SessionSerializer.h"
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
#include "MessageDigest.h"
|
||||||
# include "MessageDigest.h"
|
#include "message_digest_helper.h"
|
||||||
# include "message_digest_helper.h"
|
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
#ifdef ENABLE_BITTORRENT
|
#ifdef ENABLE_BITTORRENT
|
||||||
# include "bittorrent_helper.h"
|
# include "bittorrent_helper.h"
|
||||||
# include "BtRegistry.h"
|
# include "BtRegistry.h"
|
||||||
|
@ -254,7 +252,6 @@ std::unique_ptr<ValueBase> AddUriRpcMethod::process
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
namespace {
|
namespace {
|
||||||
std::string getHexSha1(const std::string& s)
|
std::string getHexSha1(const std::string& s)
|
||||||
{
|
{
|
||||||
|
@ -264,7 +261,6 @@ std::string getHexSha1(const std::string& s)
|
||||||
return util::toHex(hash, sizeof(hash));
|
return util::toHex(hash, sizeof(hash));
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
#ifdef ENABLE_BITTORRENT
|
#ifdef ENABLE_BITTORRENT
|
||||||
std::unique_ptr<ValueBase> AddTorrentRpcMethod::process
|
std::unique_ptr<ValueBase> AddTorrentRpcMethod::process
|
||||||
|
@ -341,7 +337,6 @@ std::unique_ptr<ValueBase> AddMetalinkRpcMethod::process
|
||||||
size_t pos = posGiven ? posParam->i() : 0;
|
size_t pos = posGiven ? posParam->i() : 0;
|
||||||
|
|
||||||
std::vector<std::shared_ptr<RequestGroup>> result;
|
std::vector<std::shared_ptr<RequestGroup>> result;
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
std::string filename;
|
std::string filename;
|
||||||
if(requestOption->getAsBool(PREF_RPC_SAVE_UPLOAD_METADATA)) {
|
if(requestOption->getAsBool(PREF_RPC_SAVE_UPLOAD_METADATA)) {
|
||||||
// TODO RFC5854 Metalink has the extension .meta4 and Metalink
|
// TODO RFC5854 Metalink has the extension .meta4 and Metalink
|
||||||
|
@ -365,9 +360,6 @@ std::unique_ptr<ValueBase> AddMetalinkRpcMethod::process
|
||||||
} else {
|
} else {
|
||||||
createRequestGroupForMetalink(result, requestOption, metalinkParam->s());
|
createRequestGroupForMetalink(result, requestOption, metalinkParam->s());
|
||||||
}
|
}
|
||||||
#else // !ENABLE_MESSAGE_DIGEST
|
|
||||||
createRequestGroupForMetalink(result, requestOption, metalinkParam->s());
|
|
||||||
#endif // !ENABLE_MESSAGE_DIGEST
|
|
||||||
auto gids = List::g();
|
auto gids = List::g();
|
||||||
if(!result.empty()) {
|
if(!result.empty()) {
|
||||||
if(posGiven) {
|
if(posGiven) {
|
||||||
|
|
|
@ -66,8 +66,6 @@ public:
|
||||||
|
|
||||||
virtual void updateWrittenLength(int32_t bytes) = 0;
|
virtual void updateWrittenLength(int32_t bytes) = 0;
|
||||||
|
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
// `begin' is a offset inside this segment.
|
// `begin' is a offset inside this segment.
|
||||||
virtual bool updateHash
|
virtual bool updateHash
|
||||||
(int32_t begin,
|
(int32_t begin,
|
||||||
|
@ -78,8 +76,6 @@ public:
|
||||||
|
|
||||||
virtual std::string getDigest() = 0;
|
virtual std::string getDigest() = 0;
|
||||||
|
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
virtual void clear(WrDiskCache* diskCache) = 0;
|
virtual void clear(WrDiskCache* diskCache) = 0;
|
||||||
|
|
||||||
virtual std::shared_ptr<Piece> getPiece() const = 0;
|
virtual std::shared_ptr<Piece> getPiece() const = 0;
|
||||||
|
|
|
@ -88,11 +88,9 @@ ssize_t SinkStreamFilter::transform
|
||||||
} else {
|
} else {
|
||||||
out->writeData(inbuf, wlen, segment->getPositionToWrite());
|
out->writeData(inbuf, wlen, segment->getPositionToWrite());
|
||||||
}
|
}
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
if(hashUpdate_) {
|
if(hashUpdate_) {
|
||||||
segment->updateHash(segment->getWrittenLength(), inbuf, wlen);
|
segment->updateHash(segment->getWrittenLength(), inbuf, wlen);
|
||||||
}
|
}
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
segment->updateWrittenLength(wlen);
|
segment->updateWrittenLength(wlen);
|
||||||
} else {
|
} else {
|
||||||
wlen = 0;
|
wlen = 0;
|
||||||
|
|
|
@ -143,7 +143,6 @@ std::shared_ptr<RequestGroup> createRequestGroup
|
||||||
dctx->getFirstFileEntry()->setUris(uris);
|
dctx->getFirstFileEntry()->setUris(uris);
|
||||||
dctx->getFirstFileEntry()->setMaxConnectionPerServer
|
dctx->getFirstFileEntry()->setMaxConnectionPerServer
|
||||||
(option->getAsInt(PREF_MAX_CONNECTION_PER_SERVER));
|
(option->getAsInt(PREF_MAX_CONNECTION_PER_SERVER));
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
const std::string& checksum = option->get(PREF_CHECKSUM);
|
const std::string& checksum = option->get(PREF_CHECKSUM);
|
||||||
if(!checksum.empty()) {
|
if(!checksum.empty()) {
|
||||||
auto p = util::divide(std::begin(checksum), std::end(checksum), '=');
|
auto p = util::divide(std::begin(checksum), std::end(checksum), '=');
|
||||||
|
@ -153,7 +152,6 @@ std::shared_ptr<RequestGroup> createRequestGroup
|
||||||
dctx->setDigest(hashType,
|
dctx->setDigest(hashType,
|
||||||
util::fromHex(std::begin(hexDigest), std::end(hexDigest)));
|
util::fromHex(std::begin(hexDigest), std::end(hexDigest)));
|
||||||
}
|
}
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
rg->setDownloadContext(dctx);
|
rg->setDownloadContext(dctx);
|
||||||
rg->setPauseRequested(option->getAsBool(PREF_PAUSE));
|
rg->setPauseRequested(option->getAsBool(PREF_PAUSE));
|
||||||
removeOneshotOption(option);
|
removeOneshotOption(option);
|
||||||
|
|
10
src/util.cc
10
src/util.cc
|
@ -85,10 +85,8 @@
|
||||||
#include "SocketCore.h"
|
#include "SocketCore.h"
|
||||||
#include "Lock.h"
|
#include "Lock.h"
|
||||||
|
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
#include "MessageDigest.h"
|
||||||
# include "MessageDigest.h"
|
#include "message_digest_helper.h"
|
||||||
# include "message_digest_helper.h"
|
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
// For libc6 which doesn't define ULLONG_MAX properly because of broken limits.h
|
// For libc6 which doesn't define ULLONG_MAX properly because of broken limits.h
|
||||||
#ifndef ULLONG_MAX
|
#ifndef ULLONG_MAX
|
||||||
|
@ -1641,14 +1639,10 @@ std::string fixTaintedBasename(const std::string& src)
|
||||||
|
|
||||||
void generateRandomKey(unsigned char* key)
|
void generateRandomKey(unsigned char* key)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
unsigned char bytes[40];
|
unsigned char bytes[40];
|
||||||
generateRandomData(bytes, sizeof(bytes));
|
generateRandomData(bytes, sizeof(bytes));
|
||||||
message_digest::digest(key, 20, MessageDigest::sha1().get(), bytes,
|
message_digest::digest(key, 20, MessageDigest::sha1().get(), bytes,
|
||||||
sizeof(bytes));
|
sizeof(bytes));
|
||||||
#else // !ENABLE_MESSAGE_DIGEST
|
|
||||||
generateRandomData(key, 20);
|
|
||||||
#endif // !ENABLE_MESSAGE_DIGEST
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true is given numeric ipv4addr is in Private Address Space.
|
// Returns true is given numeric ipv4addr is in Private Address Space.
|
||||||
|
|
|
@ -40,9 +40,7 @@
|
||||||
|
|
||||||
#include "a2io.h"
|
#include "a2io.h"
|
||||||
#include "FeatureConfig.h"
|
#include "FeatureConfig.h"
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
#include "MessageDigest.h"
|
||||||
# include "MessageDigest.h"
|
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
#include "help_tags.h"
|
#include "help_tags.h"
|
||||||
#include "prefs.h"
|
#include "prefs.h"
|
||||||
#include "fmt.h"
|
#include "fmt.h"
|
||||||
|
@ -70,10 +68,8 @@ void showVersion() {
|
||||||
<< _("** Configuration **") << "\n"
|
<< _("** Configuration **") << "\n"
|
||||||
<< _("Enabled Features") << ": "
|
<< _("Enabled Features") << ": "
|
||||||
<< featureSummary() << "\n"
|
<< featureSummary() << "\n"
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
<< _("Hash Algorithms") << ": "
|
<< _("Hash Algorithms") << ": "
|
||||||
<< MessageDigest::getSupportedHashTypeString() << "\n"
|
<< MessageDigest::getSupportedHashTypeString() << "\n"
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
<< _("Libraries") << ": "
|
<< _("Libraries") << ": "
|
||||||
<< usedLibs() << "\n"
|
<< usedLibs() << "\n"
|
||||||
<< "\n"
|
<< "\n"
|
||||||
|
|
|
@ -65,9 +65,7 @@ void FeatureConfigTest::testFeatureSummary() {
|
||||||
"HTTPS",
|
"HTTPS",
|
||||||
#endif // ENABLE_SSL
|
#endif // ENABLE_SSL
|
||||||
|
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
"Message Digest",
|
"Message Digest",
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
#ifdef ENABLE_METALINK
|
#ifdef ENABLE_METALINK
|
||||||
"Metalink",
|
"Metalink",
|
||||||
|
|
|
@ -8,9 +8,7 @@
|
||||||
#include "TestUtil.h"
|
#include "TestUtil.h"
|
||||||
#include "Exception.h"
|
#include "Exception.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
#include "MessageDigest.h"
|
||||||
# include "MessageDigest.h"
|
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -53,10 +51,8 @@ void GZipDecoderTest::testDecode()
|
||||||
|
|
||||||
out.close();
|
out.close();
|
||||||
|
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("8b577b33c0411b2be9d4fa74c7402d54a8d21f96"),
|
CPPUNIT_ASSERT_EQUAL(std::string("8b577b33c0411b2be9d4fa74c7402d54a8d21f96"),
|
||||||
fileHexDigest(MessageDigest::sha1().get(), outfile));
|
fileHexDigest(MessageDigest::sha1().get(), outfile));
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -12,9 +12,7 @@
|
||||||
#include "ByteArrayDiskWriter.h"
|
#include "ByteArrayDiskWriter.h"
|
||||||
#include "SinkStreamFilter.h"
|
#include "SinkStreamFilter.h"
|
||||||
#include "MockSegment.h"
|
#include "MockSegment.h"
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
#include "MessageDigest.h"
|
||||||
# include "MessageDigest.h"
|
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -70,13 +68,11 @@ void GZipDecodingStreamFilterTest::testTransform()
|
||||||
filter_->transform(writer_, segment_, buf, in.gcount());
|
filter_->transform(writer_, segment_, buf, in.gcount());
|
||||||
}
|
}
|
||||||
CPPUNIT_ASSERT(filter_->finished());
|
CPPUNIT_ASSERT(filter_->finished());
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
std::string data = writer_->getString();
|
std::string data = writer_->getString();
|
||||||
std::shared_ptr<MessageDigest> sha1(MessageDigest::sha1());
|
std::shared_ptr<MessageDigest> sha1(MessageDigest::sha1());
|
||||||
sha1->update(data.data(), data.size());
|
sha1->update(data.data(), data.size());
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("8b577b33c0411b2be9d4fa74c7402d54a8d21f96"),
|
CPPUNIT_ASSERT_EQUAL(std::string("8b577b33c0411b2be9d4fa74c7402d54a8d21f96"),
|
||||||
util::toHex(sha1->digest()));
|
util::toHex(sha1->digest()));
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -53,9 +53,7 @@ class HttpResponseTest : public CppUnit::TestFixture {
|
||||||
CPPUNIT_TEST(testRetrieveCookie);
|
CPPUNIT_TEST(testRetrieveCookie);
|
||||||
CPPUNIT_TEST(testSupportsPersistentConnection);
|
CPPUNIT_TEST(testSupportsPersistentConnection);
|
||||||
CPPUNIT_TEST(testGetMetalinKHttpEntries);
|
CPPUNIT_TEST(testGetMetalinKHttpEntries);
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
CPPUNIT_TEST(testGetDigest);
|
CPPUNIT_TEST(testGetDigest);
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
CPPUNIT_TEST_SUITE_END();
|
CPPUNIT_TEST_SUITE_END();
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -88,9 +86,7 @@ public:
|
||||||
void testRetrieveCookie();
|
void testRetrieveCookie();
|
||||||
void testSupportsPersistentConnection();
|
void testSupportsPersistentConnection();
|
||||||
void testGetMetalinKHttpEntries();
|
void testGetMetalinKHttpEntries();
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
void testGetDigest();
|
void testGetDigest();
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -667,7 +663,6 @@ void HttpResponseTest::testGetMetalinKHttpEntries()
|
||||||
CPPUNIT_ASSERT(e.geo.empty());
|
CPPUNIT_ASSERT(e.geo.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
void HttpResponseTest::testGetDigest()
|
void HttpResponseTest::testGetDigest()
|
||||||
{
|
{
|
||||||
HttpResponse httpResponse;
|
HttpResponse httpResponse;
|
||||||
|
@ -692,9 +687,9 @@ void HttpResponseTest::testGetDigest()
|
||||||
httpResponse.getDigest(result);
|
httpResponse.getDigest(result);
|
||||||
#ifdef USE_INTERNAL_MD
|
#ifdef USE_INTERNAL_MD
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)2, result.size());
|
CPPUNIT_ASSERT_EQUAL((size_t)2, result.size());
|
||||||
#else
|
#else // USE_INTERNAL_MD
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)3, result.size());
|
CPPUNIT_ASSERT_EQUAL((size_t)3, result.size());
|
||||||
#endif
|
#endif // USE_INTERNAL_MD
|
||||||
|
|
||||||
Checksum c = result[0];
|
Checksum c = result[0];
|
||||||
#ifndef USE_INTERNAL_MD
|
#ifndef USE_INTERNAL_MD
|
||||||
|
@ -708,6 +703,5 @@ void HttpResponseTest::testGetDigest()
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("f36003f22b462ffa184390533c500d8989e9f681"),
|
CPPUNIT_ASSERT_EQUAL(std::string("f36003f22b462ffa184390533c500d8989e9f681"),
|
||||||
util::toHex(c.getDigest()));
|
util::toHex(c.getDigest()));
|
||||||
}
|
}
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -108,12 +108,10 @@ if HAVE_SQLITE3
|
||||||
aria2c_SOURCES += Sqlite3CookieParserTest.cc
|
aria2c_SOURCES += Sqlite3CookieParserTest.cc
|
||||||
endif # HAVE_SQLITE3
|
endif # HAVE_SQLITE3
|
||||||
|
|
||||||
if ENABLE_MESSAGE_DIGEST
|
|
||||||
aria2c_SOURCES += MessageDigestHelperTest.cc\
|
aria2c_SOURCES += MessageDigestHelperTest.cc\
|
||||||
IteratableChunkChecksumValidatorTest.cc\
|
IteratableChunkChecksumValidatorTest.cc\
|
||||||
IteratableChecksumValidatorTest.cc\
|
IteratableChecksumValidatorTest.cc\
|
||||||
MessageDigestTest.cc
|
MessageDigestTest.cc
|
||||||
endif # ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
if ENABLE_BITTORRENT
|
if ENABLE_BITTORRENT
|
||||||
aria2c_SOURCES += BtAllowedFastMessageTest.cc\
|
aria2c_SOURCES += BtAllowedFastMessageTest.cc\
|
||||||
|
|
|
@ -61,12 +61,10 @@ void Metalink2RequestGroupTest::testGenerate()
|
||||||
|
|
||||||
CPPUNIT_ASSERT(dctx);
|
CPPUNIT_ASSERT(dctx);
|
||||||
CPPUNIT_ASSERT_EQUAL((int64_t)0LL, dctx->getTotalLength());
|
CPPUNIT_ASSERT_EQUAL((int64_t)0LL, dctx->getTotalLength());
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("sha-1"), dctx->getHashType());
|
CPPUNIT_ASSERT_EQUAL(std::string("sha-1"), dctx->getHashType());
|
||||||
CPPUNIT_ASSERT_EQUAL
|
CPPUNIT_ASSERT_EQUAL
|
||||||
(std::string("a96cf3f0266b91d87d5124cf94326422800b627d"),
|
(std::string("a96cf3f0266b91d87d5124cf94326422800b627d"),
|
||||||
util::toHex(dctx->getDigest()));
|
util::toHex(dctx->getDigest()));
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
CPPUNIT_ASSERT(dctx->getSignature());
|
CPPUNIT_ASSERT(dctx->getSignature());
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("pgp"), dctx->getSignature()->getType());
|
CPPUNIT_ASSERT_EQUAL(std::string("pgp"), dctx->getSignature()->getType());
|
||||||
}
|
}
|
||||||
|
@ -80,7 +78,6 @@ void Metalink2RequestGroupTest::testGenerate()
|
||||||
const std::shared_ptr<DownloadContext>& dctx = rg->getDownloadContext();
|
const std::shared_ptr<DownloadContext>& dctx = rg->getDownloadContext();
|
||||||
|
|
||||||
CPPUNIT_ASSERT(dctx);
|
CPPUNIT_ASSERT(dctx);
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("sha-1"), dctx->getPieceHashType());
|
CPPUNIT_ASSERT_EQUAL(std::string("sha-1"), dctx->getPieceHashType());
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)2, dctx->getPieceHashes().size());
|
CPPUNIT_ASSERT_EQUAL((size_t)2, dctx->getPieceHashes().size());
|
||||||
CPPUNIT_ASSERT_EQUAL(262144, dctx->getPieceLength());
|
CPPUNIT_ASSERT_EQUAL(262144, dctx->getPieceLength());
|
||||||
|
@ -88,7 +85,6 @@ void Metalink2RequestGroupTest::testGenerate()
|
||||||
CPPUNIT_ASSERT_EQUAL
|
CPPUNIT_ASSERT_EQUAL
|
||||||
(std::string("4c255b0ed130f5ea880f0aa061c3da0487e251cc"),
|
(std::string("4c255b0ed130f5ea880f0aa061c3da0487e251cc"),
|
||||||
util::toHex(dctx->getDigest()));
|
util::toHex(dctx->getDigest()));
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
CPPUNIT_ASSERT(!dctx->getSignature());
|
CPPUNIT_ASSERT(!dctx->getSignature());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,9 +78,9 @@ void MetalinkEntryTest::testDropUnsupportedResource()
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)4, entry->resources.size());
|
CPPUNIT_ASSERT_EQUAL((size_t)4, entry->resources.size());
|
||||||
#elif defined(ENABLE_SSL) || defined(ENABLE_BITTORRENT)
|
#elif defined(ENABLE_SSL) || defined(ENABLE_BITTORRENT)
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)3, entry->resources.size());
|
CPPUNIT_ASSERT_EQUAL((size_t)3, entry->resources.size());
|
||||||
#else
|
#else // defined(ENABLE_SSL) || defined(ENABLE_BITTORRENT)
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)2, entry->resources.size());
|
CPPUNIT_ASSERT_EQUAL((size_t)2, entry->resources.size());
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
#endif // defined(ENABLE_SSL) || defined(ENABLE_BITTORRENT)
|
||||||
|
|
||||||
auto itr = std::begin(entry->resources);
|
auto itr = std::begin(entry->resources);
|
||||||
CPPUNIT_ASSERT_EQUAL(MetalinkResource::TYPE_FTP,
|
CPPUNIT_ASSERT_EQUAL(MetalinkResource::TYPE_FTP,
|
||||||
|
|
|
@ -7,10 +7,8 @@
|
||||||
#include "MetalinkResource.h"
|
#include "MetalinkResource.h"
|
||||||
#include "MetalinkMetaurl.h"
|
#include "MetalinkMetaurl.h"
|
||||||
#include "FileEntry.h"
|
#include "FileEntry.h"
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
#include "Checksum.h"
|
||||||
# include "Checksum.h"
|
#include "ChunkChecksum.h"
|
||||||
# include "ChunkChecksum.h"
|
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
#include "Signature.h"
|
#include "Signature.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
@ -22,11 +20,9 @@ class MetalinkParserControllerTest:public CppUnit::TestFixture {
|
||||||
CPPUNIT_TEST(testResourceTransaction);
|
CPPUNIT_TEST(testResourceTransaction);
|
||||||
CPPUNIT_TEST(testResourceTransaction_withBaseUri);
|
CPPUNIT_TEST(testResourceTransaction_withBaseUri);
|
||||||
CPPUNIT_TEST(testMetaurlTransaction);
|
CPPUNIT_TEST(testMetaurlTransaction);
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
CPPUNIT_TEST(testChecksumTransaction);
|
CPPUNIT_TEST(testChecksumTransaction);
|
||||||
CPPUNIT_TEST(testChunkChecksumTransaction);
|
CPPUNIT_TEST(testChunkChecksumTransaction);
|
||||||
CPPUNIT_TEST(testChunkChecksumTransactionV4);
|
CPPUNIT_TEST(testChunkChecksumTransactionV4);
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
CPPUNIT_TEST(testSignatureTransaction);
|
CPPUNIT_TEST(testSignatureTransaction);
|
||||||
|
|
||||||
CPPUNIT_TEST_SUITE_END();
|
CPPUNIT_TEST_SUITE_END();
|
||||||
|
@ -41,11 +37,9 @@ public:
|
||||||
void testResourceTransaction();
|
void testResourceTransaction();
|
||||||
void testResourceTransaction_withBaseUri();
|
void testResourceTransaction_withBaseUri();
|
||||||
void testMetaurlTransaction();
|
void testMetaurlTransaction();
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
void testChecksumTransaction();
|
void testChecksumTransaction();
|
||||||
void testChunkChecksumTransaction();
|
void testChunkChecksumTransaction();
|
||||||
void testChunkChecksumTransactionV4();
|
void testChunkChecksumTransactionV4();
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
void testSignatureTransaction();
|
void testSignatureTransaction();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -183,7 +177,6 @@ void MetalinkParserControllerTest::testMetaurlTransaction()
|
||||||
#endif // !ENABLE_BITTORRENT
|
#endif // !ENABLE_BITTORRENT
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
void MetalinkParserControllerTest::testChecksumTransaction()
|
void MetalinkParserControllerTest::testChecksumTransaction()
|
||||||
{
|
{
|
||||||
MetalinkParserController ctrl;
|
MetalinkParserController ctrl;
|
||||||
|
@ -310,7 +303,6 @@ void MetalinkParserControllerTest::testChunkChecksumTransactionV4()
|
||||||
CPPUNIT_ASSERT(!m->getEntries()[2]->chunkChecksum);
|
CPPUNIT_ASSERT(!m->getEntries()[2]->chunkChecksum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
void MetalinkParserControllerTest::testSignatureTransaction()
|
void MetalinkParserControllerTest::testSignatureTransaction()
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,11 +12,9 @@
|
||||||
#include "MetalinkEntry.h"
|
#include "MetalinkEntry.h"
|
||||||
#include "MetalinkResource.h"
|
#include "MetalinkResource.h"
|
||||||
#include "MetalinkMetaurl.h"
|
#include "MetalinkMetaurl.h"
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
#include "MessageDigest.h"
|
||||||
# include "MessageDigest.h"
|
#include "ChunkChecksum.h"
|
||||||
# include "ChunkChecksum.h"
|
#include "Checksum.h"
|
||||||
# include "Checksum.h"
|
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
#include "Signature.h"
|
#include "Signature.h"
|
||||||
#include "fmt.h"
|
#include "fmt.h"
|
||||||
#include "RecoverableException.h"
|
#include "RecoverableException.h"
|
||||||
|
@ -40,13 +38,11 @@ class MetalinkProcessorTest:public CppUnit::TestFixture {
|
||||||
CPPUNIT_TEST(testNoName);
|
CPPUNIT_TEST(testNoName);
|
||||||
CPPUNIT_TEST(testBadURLPrefs);
|
CPPUNIT_TEST(testBadURLPrefs);
|
||||||
CPPUNIT_TEST(testBadURLMaxConn);
|
CPPUNIT_TEST(testBadURLMaxConn);
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
CPPUNIT_TEST(testUnsupportedType);
|
CPPUNIT_TEST(testUnsupportedType);
|
||||||
CPPUNIT_TEST(testMultiplePieces);
|
CPPUNIT_TEST(testMultiplePieces);
|
||||||
CPPUNIT_TEST(testBadPieceNo);
|
CPPUNIT_TEST(testBadPieceNo);
|
||||||
CPPUNIT_TEST(testBadPieceLength);
|
CPPUNIT_TEST(testBadPieceLength);
|
||||||
CPPUNIT_TEST(testUnsupportedType_piece);
|
CPPUNIT_TEST(testUnsupportedType_piece);
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
CPPUNIT_TEST(testLargeFileSize);
|
CPPUNIT_TEST(testLargeFileSize);
|
||||||
CPPUNIT_TEST(testXmlPrefixV3);
|
CPPUNIT_TEST(testXmlPrefixV3);
|
||||||
CPPUNIT_TEST_SUITE_END();
|
CPPUNIT_TEST_SUITE_END();
|
||||||
|
@ -66,13 +62,11 @@ public:
|
||||||
void testNoName();
|
void testNoName();
|
||||||
void testBadURLPrefs();
|
void testBadURLPrefs();
|
||||||
void testBadURLMaxConn();
|
void testBadURLMaxConn();
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
void testUnsupportedType();
|
void testUnsupportedType();
|
||||||
void testMultiplePieces();
|
void testMultiplePieces();
|
||||||
void testBadPieceNo();
|
void testBadPieceNo();
|
||||||
void testBadPieceLength();
|
void testBadPieceLength();
|
||||||
void testUnsupportedType_piece();
|
void testUnsupportedType_piece();
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
void testLargeFileSize();
|
void testLargeFileSize();
|
||||||
void testXmlPrefixV3();
|
void testXmlPrefixV3();
|
||||||
};
|
};
|
||||||
|
@ -88,7 +82,6 @@ void MetalinkProcessorTest::testParseFileV4()
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("example.ext"), e->getPath());
|
CPPUNIT_ASSERT_EQUAL(std::string("example.ext"), e->getPath());
|
||||||
CPPUNIT_ASSERT_EQUAL((int64_t)786430LL, e->getLength());
|
CPPUNIT_ASSERT_EQUAL((int64_t)786430LL, e->getLength());
|
||||||
CPPUNIT_ASSERT_EQUAL(-1, e->maxConnections);
|
CPPUNIT_ASSERT_EQUAL(-1, e->maxConnections);
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33"),
|
CPPUNIT_ASSERT_EQUAL(std::string("0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33"),
|
||||||
util::toHex(e->checksum->getDigest()));
|
util::toHex(e->checksum->getDigest()));
|
||||||
CPPUNIT_ASSERT(e->checksum);
|
CPPUNIT_ASSERT(e->checksum);
|
||||||
|
@ -118,7 +111,6 @@ void MetalinkProcessorTest::testParseFileV4()
|
||||||
(std::string("44213f9f4d59b557314fadcd233232eebcac8012"),
|
(std::string("44213f9f4d59b557314fadcd233232eebcac8012"),
|
||||||
util::toHex(e->chunkChecksum->getPieceHash(2)));
|
util::toHex(e->chunkChecksum->getPieceHash(2)));
|
||||||
}
|
}
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
CPPUNIT_ASSERT(e->getSignature());
|
CPPUNIT_ASSERT(e->getSignature());
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("application/pgp-signature"),
|
CPPUNIT_ASSERT_EQUAL(std::string("application/pgp-signature"),
|
||||||
e->getSignature()->getType());
|
e->getSignature()->getType());
|
||||||
|
@ -332,7 +324,6 @@ void MetalinkProcessorTest::testParseFileV4_attrs()
|
||||||
// success
|
// success
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
{
|
{
|
||||||
// Testing pieces@length
|
// Testing pieces@length
|
||||||
// No pieces@length
|
// No pieces@length
|
||||||
|
@ -449,7 +440,6 @@ void MetalinkProcessorTest::testParseFileV4_attrs()
|
||||||
CPPUNIT_FAIL("exception must be thrown.");
|
CPPUNIT_FAIL("exception must be thrown.");
|
||||||
} catch(RecoverableException& e) {}
|
} catch(RecoverableException& e) {}
|
||||||
}
|
}
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
{
|
{
|
||||||
// Testing signature@mediatype
|
// Testing signature@mediatype
|
||||||
// No hash@type
|
// No hash@type
|
||||||
|
@ -499,11 +489,9 @@ void MetalinkProcessorTest::testParseFile()
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("en-US"), entry1->languages[0]);
|
CPPUNIT_ASSERT_EQUAL(std::string("en-US"), entry1->languages[0]);
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("Linux-x86"), entry1->oses[0]);
|
CPPUNIT_ASSERT_EQUAL(std::string("Linux-x86"), entry1->oses[0]);
|
||||||
CPPUNIT_ASSERT_EQUAL(1, entry1->maxConnections);
|
CPPUNIT_ASSERT_EQUAL(1, entry1->maxConnections);
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("a96cf3f0266b91d87d5124cf94326422800b627d"),
|
CPPUNIT_ASSERT_EQUAL(std::string("a96cf3f0266b91d87d5124cf94326422800b627d"),
|
||||||
util::toHex(entry1->checksum->getDigest()));
|
util::toHex(entry1->checksum->getDigest()));
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("sha-1"), entry1->checksum->getHashType());
|
CPPUNIT_ASSERT_EQUAL(std::string("sha-1"), entry1->checksum->getHashType());
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
CPPUNIT_ASSERT(entry1->getSignature());
|
CPPUNIT_ASSERT(entry1->getSignature());
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("pgp"), entry1->getSignature()->getType());
|
CPPUNIT_ASSERT_EQUAL(std::string("pgp"), entry1->getSignature()->getType());
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("aria2-0.5.2.tar.bz2.sig"),
|
CPPUNIT_ASSERT_EQUAL(std::string("aria2-0.5.2.tar.bz2.sig"),
|
||||||
|
@ -548,7 +536,6 @@ void MetalinkProcessorTest::testParseFile()
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("ja-JP"), entry2->languages[0]);
|
CPPUNIT_ASSERT_EQUAL(std::string("ja-JP"), entry2->languages[0]);
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("Linux-m68k"), entry2->oses[0]);
|
CPPUNIT_ASSERT_EQUAL(std::string("Linux-m68k"), entry2->oses[0]);
|
||||||
CPPUNIT_ASSERT_EQUAL(-1, entry2->maxConnections);
|
CPPUNIT_ASSERT_EQUAL(-1, entry2->maxConnections);
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("4c255b0ed130f5ea880f0aa061c3da0487e251cc"),
|
CPPUNIT_ASSERT_EQUAL(std::string("4c255b0ed130f5ea880f0aa061c3da0487e251cc"),
|
||||||
util::toHex(entry2->checksum->getDigest()));
|
util::toHex(entry2->checksum->getDigest()));
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)2, entry2->chunkChecksum->countPieceHash());
|
CPPUNIT_ASSERT_EQUAL((size_t)2, entry2->chunkChecksum->countPieceHash());
|
||||||
|
@ -558,7 +545,6 @@ void MetalinkProcessorTest::testParseFile()
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("fecf8bc9a1647505fe16746f94e97a477597dbf3"),
|
CPPUNIT_ASSERT_EQUAL(std::string("fecf8bc9a1647505fe16746f94e97a477597dbf3"),
|
||||||
util::toHex(entry2->chunkChecksum->getPieceHash(1)));
|
util::toHex(entry2->chunkChecksum->getPieceHash(1)));
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("sha-1"), entry2->checksum->getHashType());
|
CPPUNIT_ASSERT_EQUAL(std::string("sha-1"), entry2->checksum->getHashType());
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
// See that signature is null
|
// See that signature is null
|
||||||
CPPUNIT_ASSERT(!entry2->getSignature());
|
CPPUNIT_ASSERT(!entry2->getSignature());
|
||||||
|
|
||||||
|
@ -567,22 +553,18 @@ void MetalinkProcessorTest::testParseFile()
|
||||||
// test case: verification hash is not provided
|
// test case: verification hash is not provided
|
||||||
auto& entry3 = *entryItr;
|
auto& entry3 = *entryItr;
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("NoVerificationHash"), entry3->getPath());
|
CPPUNIT_ASSERT_EQUAL(std::string("NoVerificationHash"), entry3->getPath());
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
CPPUNIT_ASSERT(!entry3->checksum);
|
CPPUNIT_ASSERT(!entry3->checksum);
|
||||||
CPPUNIT_ASSERT(!entry3->chunkChecksum);
|
CPPUNIT_ASSERT(!entry3->chunkChecksum);
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
++entryItr;
|
++entryItr;
|
||||||
|
|
||||||
// test case: unsupported verification hash is included
|
// test case: unsupported verification hash is included
|
||||||
auto& entry4 = *entryItr;
|
auto& entry4 = *entryItr;
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("UnsupportedVerificationHashTypeIncluded"), entry4->getPath());
|
CPPUNIT_ASSERT_EQUAL(std::string("UnsupportedVerificationHashTypeIncluded"), entry4->getPath());
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("sha-1"), entry4->checksum->getHashType());
|
CPPUNIT_ASSERT_EQUAL(std::string("sha-1"), entry4->checksum->getHashType());
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("4c255b0ed130f5ea880f0aa061c3da0487e251cc"),
|
CPPUNIT_ASSERT_EQUAL(std::string("4c255b0ed130f5ea880f0aa061c3da0487e251cc"),
|
||||||
util::toHex(entry4->checksum->getDigest()));
|
util::toHex(entry4->checksum->getDigest()));
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("sha-1"),entry4->chunkChecksum->getHashType());
|
CPPUNIT_ASSERT_EQUAL(std::string("sha-1"),entry4->chunkChecksum->getHashType());
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
|
|
||||||
} catch(Exception& e) {
|
} catch(Exception& e) {
|
||||||
|
@ -809,7 +791,6 @@ void MetalinkProcessorTest::testBadURLMaxConn()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
void MetalinkProcessorTest::testUnsupportedType()
|
void MetalinkProcessorTest::testUnsupportedType()
|
||||||
{
|
{
|
||||||
ByteArrayDiskWriter dw;
|
ByteArrayDiskWriter dw;
|
||||||
|
@ -966,7 +947,6 @@ void MetalinkProcessorTest::testUnsupportedType_piece()
|
||||||
CPPUNIT_FAIL(e.stackTrace());
|
CPPUNIT_FAIL(e.stackTrace());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
void MetalinkProcessorTest::testLargeFileSize()
|
void MetalinkProcessorTest::testLargeFileSize()
|
||||||
{
|
{
|
||||||
|
|
|
@ -46,8 +46,6 @@ public:
|
||||||
|
|
||||||
virtual void updateWrittenLength(int32_t bytes) CXX11_OVERRIDE {}
|
virtual void updateWrittenLength(int32_t bytes) CXX11_OVERRIDE {}
|
||||||
|
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
// `begin' is a offset inside this segment.
|
// `begin' is a offset inside this segment.
|
||||||
virtual bool updateHash
|
virtual bool updateHash
|
||||||
(int32_t begin, const unsigned char* data, size_t dataLength) CXX11_OVERRIDE
|
(int32_t begin, const unsigned char* data, size_t dataLength) CXX11_OVERRIDE
|
||||||
|
@ -65,8 +63,6 @@ public:
|
||||||
return A2STR::NIL;
|
return A2STR::NIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
virtual void clear(WrDiskCache* diskCache) CXX11_OVERRIDE {}
|
virtual void clear(WrDiskCache* diskCache) CXX11_OVERRIDE {}
|
||||||
|
|
||||||
virtual std::shared_ptr<Piece> getPiece() const CXX11_OVERRIDE
|
virtual std::shared_ptr<Piece> getPiece() const CXX11_OVERRIDE
|
||||||
|
|
|
@ -18,13 +18,10 @@ class PieceTest:public CppUnit::TestFixture {
|
||||||
CPPUNIT_TEST(testGetCompletedLength);
|
CPPUNIT_TEST(testGetCompletedLength);
|
||||||
CPPUNIT_TEST(testFlushWrCache);
|
CPPUNIT_TEST(testFlushWrCache);
|
||||||
CPPUNIT_TEST(testAppendWrCache);
|
CPPUNIT_TEST(testAppendWrCache);
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
CPPUNIT_TEST(testGetDigestWithWrCache);
|
CPPUNIT_TEST(testGetDigestWithWrCache);
|
||||||
CPPUNIT_TEST(testUpdateHash);
|
CPPUNIT_TEST(testUpdateHash);
|
||||||
|
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
CPPUNIT_TEST_SUITE_END();
|
CPPUNIT_TEST_SUITE_END();
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<DirectDiskAdaptor> adaptor_;
|
std::shared_ptr<DirectDiskAdaptor> adaptor_;
|
||||||
|
@ -43,12 +40,8 @@ public:
|
||||||
void testFlushWrCache();
|
void testFlushWrCache();
|
||||||
void testAppendWrCache();
|
void testAppendWrCache();
|
||||||
|
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
void testGetDigestWithWrCache();
|
void testGetDigestWithWrCache();
|
||||||
void testUpdateHash();
|
void testUpdateHash();
|
||||||
|
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -120,8 +113,6 @@ void PieceTest::testAppendWrCache()
|
||||||
CPPUNIT_ASSERT_EQUAL(std::string("foobar"), writer_->getString());
|
CPPUNIT_ASSERT_EQUAL(std::string("foobar"), writer_->getString());
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
void PieceTest::testGetDigestWithWrCache()
|
void PieceTest::testGetDigestWithWrCache()
|
||||||
{
|
{
|
||||||
unsigned char* data;
|
unsigned char* data;
|
||||||
|
@ -168,6 +159,4 @@ void PieceTest::testUpdateHash()
|
||||||
util::toHex(p.getDigest()));
|
util::toHex(p.getDigest()));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -470,11 +470,9 @@ void RpcMethodTest::testAddMetalink()
|
||||||
CPPUNIT_ASSERT_EQUAL
|
CPPUNIT_ASSERT_EQUAL
|
||||||
(0, GroupId::toNumericId
|
(0, GroupId::toNumericId
|
||||||
(gid4, downcast<String>(resParams->get(1))->s().c_str()));
|
(gid4, downcast<String>(resParams->get(1))->s().c_str()));
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
CPPUNIT_ASSERT
|
CPPUNIT_ASSERT
|
||||||
(File(e_->getOption()->get(PREF_DIR)+
|
(File(e_->getOption()->get(PREF_DIR)+
|
||||||
"/c908634fbc257fd56f0114912c2772aeeb4064f4.meta4").exists());
|
"/c908634fbc257fd56f0114912c2772aeeb4064f4.meta4").exists());
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
auto tar = findReservedGroup(e_->getRequestGroupMan().get(), gid3);
|
auto tar = findReservedGroup(e_->getRequestGroupMan().get(), gid3);
|
||||||
CPPUNIT_ASSERT(tar);
|
CPPUNIT_ASSERT(tar);
|
||||||
|
@ -507,10 +505,8 @@ void RpcMethodTest::testAddMetalink()
|
||||||
findReservedGroup
|
findReservedGroup
|
||||||
(e_->getRequestGroupMan().get(), gid5)->
|
(e_->getRequestGroupMan().get(), gid5)->
|
||||||
getFirstFilePath());
|
getFirstFilePath());
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
CPPUNIT_ASSERT
|
CPPUNIT_ASSERT
|
||||||
(File(dir+"/c908634fbc257fd56f0114912c2772aeeb4064f4.meta4").exists());
|
(File(dir+"/c908634fbc257fd56f0114912c2772aeeb4064f4.meta4").exists());
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,9 +21,7 @@
|
||||||
#include "Option.h"
|
#include "Option.h"
|
||||||
#include "FileEntry.h"
|
#include "FileEntry.h"
|
||||||
#include "DownloadResult.h"
|
#include "DownloadResult.h"
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
#include "message_digest_helper.h"
|
||||||
# include "message_digest_helper.h"
|
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -80,14 +78,12 @@ std::string fromHex(const std::string& s)
|
||||||
return util::fromHex(s.begin(), s.end());
|
return util::fromHex(s.begin(), s.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
std::string fileHexDigest(MessageDigest* ctx, const std::string& filename)
|
std::string fileHexDigest(MessageDigest* ctx, const std::string& filename)
|
||||||
{
|
{
|
||||||
std::shared_ptr<DiskWriter> writer(new DefaultDiskWriter(filename));
|
std::shared_ptr<DiskWriter> writer(new DefaultDiskWriter(filename));
|
||||||
writer->openExistingFile();
|
writer->openExistingFile();
|
||||||
return util::toHex(message_digest::digest(ctx, writer, 0, writer->size()));
|
return util::toHex(message_digest::digest(ctx, writer, 0, writer->size()));
|
||||||
}
|
}
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
WrDiskCacheEntry::DataCell* createDataCell(int64_t goff,
|
WrDiskCacheEntry::DataCell* createDataCell(int64_t goff,
|
||||||
const char* data,
|
const char* data,
|
||||||
|
|
|
@ -50,10 +50,8 @@ std::unique_ptr<Cookie> createCookie
|
||||||
|
|
||||||
std::string fromHex(const std::string& s);
|
std::string fromHex(const std::string& s);
|
||||||
|
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
// Returns hex digest of contents of file denoted by filename.
|
// Returns hex digest of contents of file denoted by filename.
|
||||||
std::string fileHexDigest(MessageDigest* ctx, const std::string& filename);
|
std::string fileHexDigest(MessageDigest* ctx, const std::string& filename);
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
|
|
||||||
WrDiskCacheEntry::DataCell* createDataCell(int64_t goff,
|
WrDiskCacheEntry::DataCell* createDataCell(int64_t goff,
|
||||||
const char* data,
|
const char* data,
|
||||||
|
|
Loading…
Reference in New Issue