mirror of https://github.com/aria2/aria2
2007-01-28 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* src/Xml2MetalinkProcessor.h (xpathExists): New function. * src/Xml2MetalinkProcessor.cc (xpathExists): New function. Not to send HEAD request if filename and size are available in Metalink file: * src/UrlRequestInfo.h (filename): New variable. (totalLength): New variable. (setTotalLength): New function. (setFilename): New function. * src/MetalinkRequestInfo.cc (execute): Set filename and size to UrlRequestInfo. * src/MetalinkEntry.cc (MetalinkEntry): Initialize size with 0. * src/UrlRequestInfo.cc (execute): Set filename and size to SegmentMan. Not to download rest of the files after selected files are downloaded in BitTorrent: * src/PieceStorage.h (allDownloadFinished): New function. * src/DefaultBtAnnounce.cc (isCompleteAnnounceReady): Use allDownloadFinished instead of downloadFinished. (getAnnounceUrl): Use allDownloadFinished instead of downloadFinished. * src/DefaultPieceStorage.cc (completePiece): Use allDownloadFinished instead of downloadFinished. Commented out the call to finishSelectiveDownloadingMode(). (downloadFinished): Call isFilteredAllBitSet() instead of isAllBitSet(). (allDownloadFinished): New function. * src/DefaultBtInteractive.cc (addBitfieldMessageToQueue): Call allDownloadFinished() instead of downloadFinished(). (checkHave): Call allDownloadFinished() instead of downloadFinished(). * src/TorrentDownloadEngine.cc (onEndOfRun): Call allDownloadFinished() instead of downloadFinished(). * src/BitfieldMan.h (isFilteredAllBitSet): New function. * src/ShareRatioSeedCriteria.h (PieceStorage.h): New include. (pieceStorage): New variable. (evaluate): btContext->getTotalLength() -> pieceStorage->getCompletedLength() * src/BitfieldMan.cc (isFilteredAllBitSet): New function. (isAllBitSet): Filter is not took into account. Rename --force-truncate as --allow-overwrite: * src/TorrentRequestInfo.cc (execute): PREF_FORCE_TRUNCATE -> PREF_ALLOW_OVERWRITE * src/main.cc (showUsage): --force-truncate -> --allow-overwrite * src/message.h (EX_FILE_ALREADY_EXISTS): --force-truncate -> --allow-overwrite * src/prefs.h (PREF_FORCE_TRUNCATE): Removed. (PREF_ALLOW_OVERWRITE): New definition. * src/SegmentMan.cc (shouldCancelDownloadForSafety): --force-truncate -> --allow-overwrite * src/MetalinkRequestInfo.cc (execute): Queueing message are now logged in info level. * src/common.h (LONG_LONG_MAX): Removed. (LONG_LONG_MIN): Removed. * src/HttpResponseCommand.cc (handleDefaultEncoding): LONG_LONG_MAX -> INT64_MAX * src/FtpNegotiateCommand.cc (recvSize): LONG_LONG_MAX -> INT64_MAX * src/main.cc (showUsage): Added --check-integiry and --realtime-chunk-checksum command-line option. (main): Added --check-integiry and --realtime-chunk-checksum command-line option. --force-truncate -> --allow-overwrite Set initial value of --check-integrity option to false. Don't show usage when error occurs while persing command-line options. Removed deprecated --upload-limit option.pull/1/head
parent
cd9e35bc63
commit
cd91e2ea4f
86
ChangeLog
86
ChangeLog
|
@ -1,3 +1,89 @@
|
||||||
|
2007-01-28 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
|
* src/Xml2MetalinkProcessor.h
|
||||||
|
(xpathExists): New function.
|
||||||
|
* src/Xml2MetalinkProcessor.cc
|
||||||
|
(xpathExists): New function.
|
||||||
|
|
||||||
|
Not to send HEAD request if filename and size are available in Metalink
|
||||||
|
file:
|
||||||
|
* src/UrlRequestInfo.h
|
||||||
|
(filename): New variable.
|
||||||
|
(totalLength): New variable.
|
||||||
|
(setTotalLength): New function.
|
||||||
|
(setFilename): New function.
|
||||||
|
* src/MetalinkRequestInfo.cc
|
||||||
|
(execute): Set filename and size to UrlRequestInfo.
|
||||||
|
* src/MetalinkEntry.cc
|
||||||
|
(MetalinkEntry): Initialize size with 0.
|
||||||
|
* src/UrlRequestInfo.cc
|
||||||
|
(execute): Set filename and size to SegmentMan.
|
||||||
|
|
||||||
|
Not to download rest of the files after selected files are downloaded
|
||||||
|
in BitTorrent:
|
||||||
|
* src/PieceStorage.h
|
||||||
|
(allDownloadFinished): New function.
|
||||||
|
* src/DefaultBtAnnounce.cc
|
||||||
|
(isCompleteAnnounceReady): Use allDownloadFinished instead of
|
||||||
|
downloadFinished.
|
||||||
|
(getAnnounceUrl): Use allDownloadFinished instead of downloadFinished.
|
||||||
|
* src/DefaultPieceStorage.cc
|
||||||
|
(completePiece): Use allDownloadFinished instead of downloadFinished.
|
||||||
|
Commented out the call to finishSelectiveDownloadingMode().
|
||||||
|
(downloadFinished): Call isFilteredAllBitSet() instead of
|
||||||
|
isAllBitSet().
|
||||||
|
(allDownloadFinished): New function.
|
||||||
|
* src/DefaultBtInteractive.cc
|
||||||
|
(addBitfieldMessageToQueue): Call allDownloadFinished() instead of
|
||||||
|
downloadFinished().
|
||||||
|
(checkHave): Call allDownloadFinished() instead of downloadFinished().
|
||||||
|
* src/TorrentDownloadEngine.cc
|
||||||
|
(onEndOfRun): Call allDownloadFinished() instead of downloadFinished().
|
||||||
|
* src/BitfieldMan.h
|
||||||
|
(isFilteredAllBitSet): New function.
|
||||||
|
* src/ShareRatioSeedCriteria.h
|
||||||
|
(PieceStorage.h): New include.
|
||||||
|
(pieceStorage): New variable.
|
||||||
|
(evaluate):
|
||||||
|
btContext->getTotalLength() -> pieceStorage->getCompletedLength()
|
||||||
|
* src/BitfieldMan.cc
|
||||||
|
(isFilteredAllBitSet): New function.
|
||||||
|
(isAllBitSet): Filter is not took into account.
|
||||||
|
|
||||||
|
Rename --force-truncate as --allow-overwrite:
|
||||||
|
* src/TorrentRequestInfo.cc
|
||||||
|
(execute): PREF_FORCE_TRUNCATE -> PREF_ALLOW_OVERWRITE
|
||||||
|
* src/main.cc
|
||||||
|
(showUsage): --force-truncate -> --allow-overwrite
|
||||||
|
* src/message.h
|
||||||
|
(EX_FILE_ALREADY_EXISTS): --force-truncate -> --allow-overwrite
|
||||||
|
* src/prefs.h
|
||||||
|
(PREF_FORCE_TRUNCATE): Removed.
|
||||||
|
(PREF_ALLOW_OVERWRITE): New definition.
|
||||||
|
* src/SegmentMan.cc
|
||||||
|
(shouldCancelDownloadForSafety): --force-truncate -> --allow-overwrite
|
||||||
|
|
||||||
|
* src/MetalinkRequestInfo.cc
|
||||||
|
(execute): Queueing message are now logged in info level.
|
||||||
|
|
||||||
|
* src/common.h
|
||||||
|
(LONG_LONG_MAX): Removed.
|
||||||
|
(LONG_LONG_MIN): Removed.
|
||||||
|
* src/HttpResponseCommand.cc
|
||||||
|
(handleDefaultEncoding): LONG_LONG_MAX -> INT64_MAX
|
||||||
|
* src/FtpNegotiateCommand.cc
|
||||||
|
(recvSize): LONG_LONG_MAX -> INT64_MAX
|
||||||
|
|
||||||
|
* src/main.cc
|
||||||
|
(showUsage): Added --check-integiry and --realtime-chunk-checksum
|
||||||
|
command-line option.
|
||||||
|
(main): Added --check-integiry and --realtime-chunk-checksum
|
||||||
|
command-line option.
|
||||||
|
--force-truncate -> --allow-overwrite
|
||||||
|
Set initial value of --check-integrity option to false.
|
||||||
|
Don't show usage when error occurs while persing command-line options.
|
||||||
|
Removed deprecated --upload-limit option.
|
||||||
|
|
||||||
2007-01-26 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
2007-01-26 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
* src/message.h: Added EX_INVALID_PAYLOAD_SIZE and
|
* src/message.h: Added EX_INVALID_PAYLOAD_SIZE and
|
||||||
|
|
8
README
8
README
|
@ -82,8 +82,8 @@ Note:
|
||||||
* This version only supports compact peers list format.
|
* This version only supports compact peers list format.
|
||||||
* The ports aria2c uses are 6881-6999.
|
* The ports aria2c uses are 6881-6999.
|
||||||
* The maximum number of peers is 55.
|
* The maximum number of peers is 55.
|
||||||
* After selective download completes, aria2 is going to download rest of the
|
* As of release 0.10.0, aria2 stops sending request message after selective
|
||||||
files.
|
download completes,
|
||||||
|
|
||||||
6. Metalink
|
6. Metalink
|
||||||
-----------
|
-----------
|
||||||
|
@ -96,3 +96,7 @@ provided, then aria2 uses SHA1. If checksum checking is failed, aria2 doesn't
|
||||||
retry the download and just exits with non-zero return code.
|
retry the download and just exits with non-zero return code.
|
||||||
|
|
||||||
The supported user preferences are version, language and os.
|
The supported user preferences are version, language and os.
|
||||||
|
|
||||||
|
If chunk checksums are provided in Metalink file, aria2 automatically validate
|
||||||
|
a chunk of file while downloading it. This behavior can be turned off by
|
||||||
|
a command-line option.
|
||||||
|
|
4
TODO
4
TODO
|
@ -24,7 +24,3 @@
|
||||||
* remove blockIndex
|
* remove blockIndex
|
||||||
* Add an ability of seeding
|
* Add an ability of seeding
|
||||||
* Continue file allocation with existing file
|
* Continue file allocation with existing file
|
||||||
|
|
||||||
* Stopping while piece hash checking and file allocation
|
|
||||||
* Stop download after selective download completes
|
|
||||||
* Remove -pg option in Makefile.am
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
# Guess values for system-dependent variables and create Makefiles.
|
# Guess values for system-dependent variables and create Makefiles.
|
||||||
# Generated by GNU Autoconf 2.61 for aria2c 0.9.0.
|
# Generated by GNU Autoconf 2.61 for aria2c 0.10.0.
|
||||||
#
|
#
|
||||||
# Report bugs to <tujikawa@rednoah.com>.
|
# Report bugs to <t-tujikawa@users.sourceforge.net>.
|
||||||
#
|
#
|
||||||
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
|
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
|
||||||
# 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
|
# 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||||
|
@ -574,9 +574,9 @@ SHELL=${CONFIG_SHELL-/bin/sh}
|
||||||
# Identity of this package.
|
# Identity of this package.
|
||||||
PACKAGE_NAME='aria2c'
|
PACKAGE_NAME='aria2c'
|
||||||
PACKAGE_TARNAME='aria2c'
|
PACKAGE_TARNAME='aria2c'
|
||||||
PACKAGE_VERSION='0.9.0'
|
PACKAGE_VERSION='0.10.0'
|
||||||
PACKAGE_STRING='aria2c 0.9.0'
|
PACKAGE_STRING='aria2c 0.10.0'
|
||||||
PACKAGE_BUGREPORT='tujikawa@rednoah.com'
|
PACKAGE_BUGREPORT='t-tujikawa@users.sourceforge.net'
|
||||||
|
|
||||||
ac_unique_file="src/Socket.h"
|
ac_unique_file="src/Socket.h"
|
||||||
# Factoring default headers for most tests.
|
# Factoring default headers for most tests.
|
||||||
|
@ -1275,7 +1275,7 @@ if test "$ac_init_help" = "long"; then
|
||||||
# Omit some internal or obsolete options to make the list less imposing.
|
# Omit some internal or obsolete options to make the list less imposing.
|
||||||
# This message is too long to be a string in the A/UX 3.1 sh.
|
# This message is too long to be a string in the A/UX 3.1 sh.
|
||||||
cat <<_ACEOF
|
cat <<_ACEOF
|
||||||
\`configure' configures aria2c 0.9.0 to adapt to many kinds of systems.
|
\`configure' configures aria2c 0.10.0 to adapt to many kinds of systems.
|
||||||
|
|
||||||
Usage: $0 [OPTION]... [VAR=VALUE]...
|
Usage: $0 [OPTION]... [VAR=VALUE]...
|
||||||
|
|
||||||
|
@ -1345,7 +1345,7 @@ fi
|
||||||
|
|
||||||
if test -n "$ac_init_help"; then
|
if test -n "$ac_init_help"; then
|
||||||
case $ac_init_help in
|
case $ac_init_help in
|
||||||
short | recursive ) echo "Configuration of aria2c 0.9.0:";;
|
short | recursive ) echo "Configuration of aria2c 0.10.0:";;
|
||||||
esac
|
esac
|
||||||
cat <<\_ACEOF
|
cat <<\_ACEOF
|
||||||
|
|
||||||
|
@ -1405,7 +1405,7 @@ Some influential environment variables:
|
||||||
Use these variables to override the choices made by `configure' or to help
|
Use these variables to override the choices made by `configure' or to help
|
||||||
it to find libraries and programs with nonstandard names/locations.
|
it to find libraries and programs with nonstandard names/locations.
|
||||||
|
|
||||||
Report bugs to <tujikawa@rednoah.com>.
|
Report bugs to <t-tujikawa@users.sourceforge.net>.
|
||||||
_ACEOF
|
_ACEOF
|
||||||
ac_status=$?
|
ac_status=$?
|
||||||
fi
|
fi
|
||||||
|
@ -1466,7 +1466,7 @@ fi
|
||||||
test -n "$ac_init_help" && exit $ac_status
|
test -n "$ac_init_help" && exit $ac_status
|
||||||
if $ac_init_version; then
|
if $ac_init_version; then
|
||||||
cat <<\_ACEOF
|
cat <<\_ACEOF
|
||||||
aria2c configure 0.9.0
|
aria2c configure 0.10.0
|
||||||
generated by GNU Autoconf 2.61
|
generated by GNU Autoconf 2.61
|
||||||
|
|
||||||
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
|
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
|
||||||
|
@ -1480,7 +1480,7 @@ cat >config.log <<_ACEOF
|
||||||
This file contains any messages produced by compilers while
|
This file contains any messages produced by compilers while
|
||||||
running configure, to aid debugging if configure makes a mistake.
|
running configure, to aid debugging if configure makes a mistake.
|
||||||
|
|
||||||
It was created by aria2c $as_me 0.9.0, which was
|
It was created by aria2c $as_me 0.10.0, which was
|
||||||
generated by GNU Autoconf 2.61. Invocation command line was
|
generated by GNU Autoconf 2.61. Invocation command line was
|
||||||
|
|
||||||
$ $0 $@
|
$ $0 $@
|
||||||
|
@ -2150,7 +2150,7 @@ fi
|
||||||
|
|
||||||
# Define the identity of the package.
|
# Define the identity of the package.
|
||||||
PACKAGE='aria2c'
|
PACKAGE='aria2c'
|
||||||
VERSION='0.9.0'
|
VERSION='0.10.0'
|
||||||
|
|
||||||
|
|
||||||
cat >>confdefs.h <<_ACEOF
|
cat >>confdefs.h <<_ACEOF
|
||||||
|
@ -6663,9 +6663,9 @@ echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&
|
||||||
{ echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
|
{ echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
|
||||||
echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
|
echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
|
||||||
( cat <<\_ASBOX
|
( cat <<\_ASBOX
|
||||||
## ----------------------------------- ##
|
## ----------------------------------------------- ##
|
||||||
## Report this to tujikawa@rednoah.com ##
|
## Report this to t-tujikawa@users.sourceforge.net ##
|
||||||
## ----------------------------------- ##
|
## ----------------------------------------------- ##
|
||||||
_ASBOX
|
_ASBOX
|
||||||
) | sed "s/^/$as_me: WARNING: /" >&2
|
) | sed "s/^/$as_me: WARNING: /" >&2
|
||||||
;;
|
;;
|
||||||
|
@ -7941,9 +7941,9 @@ echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&
|
||||||
{ echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
|
{ echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
|
||||||
echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
|
echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
|
||||||
( cat <<\_ASBOX
|
( cat <<\_ASBOX
|
||||||
## ----------------------------------- ##
|
## ----------------------------------------------- ##
|
||||||
## Report this to tujikawa@rednoah.com ##
|
## Report this to t-tujikawa@users.sourceforge.net ##
|
||||||
## ----------------------------------- ##
|
## ----------------------------------------------- ##
|
||||||
_ASBOX
|
_ASBOX
|
||||||
) | sed "s/^/$as_me: WARNING: /" >&2
|
) | sed "s/^/$as_me: WARNING: /" >&2
|
||||||
;;
|
;;
|
||||||
|
@ -9397,9 +9397,9 @@ echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&
|
||||||
{ echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
|
{ echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
|
||||||
echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
|
echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
|
||||||
( cat <<\_ASBOX
|
( cat <<\_ASBOX
|
||||||
## ----------------------------------- ##
|
## ----------------------------------------------- ##
|
||||||
## Report this to tujikawa@rednoah.com ##
|
## Report this to t-tujikawa@users.sourceforge.net ##
|
||||||
## ----------------------------------- ##
|
## ----------------------------------------------- ##
|
||||||
_ASBOX
|
_ASBOX
|
||||||
) | sed "s/^/$as_me: WARNING: /" >&2
|
) | sed "s/^/$as_me: WARNING: /" >&2
|
||||||
;;
|
;;
|
||||||
|
@ -10909,9 +10909,9 @@ echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&
|
||||||
{ echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
|
{ echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
|
||||||
echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
|
echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
|
||||||
( cat <<\_ASBOX
|
( cat <<\_ASBOX
|
||||||
## ----------------------------------- ##
|
## ----------------------------------------------- ##
|
||||||
## Report this to tujikawa@rednoah.com ##
|
## Report this to t-tujikawa@users.sourceforge.net ##
|
||||||
## ----------------------------------- ##
|
## ----------------------------------------------- ##
|
||||||
_ASBOX
|
_ASBOX
|
||||||
) | sed "s/^/$as_me: WARNING: /" >&2
|
) | sed "s/^/$as_me: WARNING: /" >&2
|
||||||
;;
|
;;
|
||||||
|
@ -11235,9 +11235,9 @@ echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&
|
||||||
{ echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
|
{ echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
|
||||||
echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
|
echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
|
||||||
( cat <<\_ASBOX
|
( cat <<\_ASBOX
|
||||||
## ----------------------------------- ##
|
## ----------------------------------------------- ##
|
||||||
## Report this to tujikawa@rednoah.com ##
|
## Report this to t-tujikawa@users.sourceforge.net ##
|
||||||
## ----------------------------------- ##
|
## ----------------------------------------------- ##
|
||||||
_ASBOX
|
_ASBOX
|
||||||
) | sed "s/^/$as_me: WARNING: /" >&2
|
) | sed "s/^/$as_me: WARNING: /" >&2
|
||||||
;;
|
;;
|
||||||
|
@ -11660,9 +11660,9 @@ echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&
|
||||||
{ echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
|
{ echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
|
||||||
echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
|
echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
|
||||||
( cat <<\_ASBOX
|
( cat <<\_ASBOX
|
||||||
## ----------------------------------- ##
|
## ----------------------------------------------- ##
|
||||||
## Report this to tujikawa@rednoah.com ##
|
## Report this to t-tujikawa@users.sourceforge.net ##
|
||||||
## ----------------------------------- ##
|
## ----------------------------------------------- ##
|
||||||
_ASBOX
|
_ASBOX
|
||||||
) | sed "s/^/$as_me: WARNING: /" >&2
|
) | sed "s/^/$as_me: WARNING: /" >&2
|
||||||
;;
|
;;
|
||||||
|
@ -11896,9 +11896,9 @@ echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&
|
||||||
{ echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
|
{ echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
|
||||||
echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
|
echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
|
||||||
( cat <<\_ASBOX
|
( cat <<\_ASBOX
|
||||||
## ----------------------------------- ##
|
## ----------------------------------------------- ##
|
||||||
## Report this to tujikawa@rednoah.com ##
|
## Report this to t-tujikawa@users.sourceforge.net ##
|
||||||
## ----------------------------------- ##
|
## ----------------------------------------------- ##
|
||||||
_ASBOX
|
_ASBOX
|
||||||
) | sed "s/^/$as_me: WARNING: /" >&2
|
) | sed "s/^/$as_me: WARNING: /" >&2
|
||||||
;;
|
;;
|
||||||
|
@ -12941,7 +12941,7 @@ exec 6>&1
|
||||||
# report actual input values of CONFIG_FILES etc. instead of their
|
# report actual input values of CONFIG_FILES etc. instead of their
|
||||||
# values after options handling.
|
# values after options handling.
|
||||||
ac_log="
|
ac_log="
|
||||||
This file was extended by aria2c $as_me 0.9.0, which was
|
This file was extended by aria2c $as_me 0.10.0, which was
|
||||||
generated by GNU Autoconf 2.61. Invocation command line was
|
generated by GNU Autoconf 2.61. Invocation command line was
|
||||||
|
|
||||||
CONFIG_FILES = $CONFIG_FILES
|
CONFIG_FILES = $CONFIG_FILES
|
||||||
|
@ -12994,7 +12994,7 @@ Report bugs to <bug-autoconf@gnu.org>."
|
||||||
_ACEOF
|
_ACEOF
|
||||||
cat >>$CONFIG_STATUS <<_ACEOF
|
cat >>$CONFIG_STATUS <<_ACEOF
|
||||||
ac_cs_version="\\
|
ac_cs_version="\\
|
||||||
aria2c config.status 0.9.0
|
aria2c config.status 0.10.0
|
||||||
configured by $0, generated by GNU Autoconf 2.61,
|
configured by $0, generated by GNU Autoconf 2.61,
|
||||||
with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
|
with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# Process this file with autoconf to produce a configure script.
|
# Process this file with autoconf to produce a configure script.
|
||||||
#
|
#
|
||||||
AC_PREREQ(2.59)
|
AC_PREREQ(2.59)
|
||||||
AC_INIT(aria2c, 0.9.0, tujikawa@rednoah.com)
|
AC_INIT(aria2c, 0.10.0, t-tujikawa@users.sourceforge.net)
|
||||||
AM_INIT_AUTOMAKE()
|
AM_INIT_AUTOMAKE()
|
||||||
AM_PATH_CPPUNIT(1.10.2)
|
AM_PATH_CPPUNIT(1.10.2)
|
||||||
AC_CONFIG_SRCDIR([src/Socket.h])
|
AC_CONFIG_SRCDIR([src/Socket.h])
|
||||||
|
|
545
doc/aria2c.1
545
doc/aria2c.1
|
@ -1,277 +1,318 @@
|
||||||
.TH "ARIA2C" 1 "October 2006" "aria2 0.8.1"
|
.\" Title: aria2c
|
||||||
|
.\" Author:
|
||||||
.SH NAME
|
.\" Generator: DocBook XSL Stylesheets v1.70.1 <http://docbook.sf.net/>
|
||||||
.P
|
.\" Date: 01/28/2007
|
||||||
|
.\" Manual:
|
||||||
|
.\" Source:
|
||||||
|
.\"
|
||||||
|
.TH "ARIA2C" "1" "01/28/2007" "" ""
|
||||||
|
.\" disable hyphenation
|
||||||
|
.nh
|
||||||
|
.\" disable justification (adjust text to left margin only)
|
||||||
|
.ad l
|
||||||
|
.SH "NAME"
|
||||||
aria2c \- The high speed download utility
|
aria2c \- The high speed download utility
|
||||||
|
.SH "SYNOPSIS"
|
||||||
.SH SYNOPSIS
|
.sp
|
||||||
.TS
|
.RS 3n
|
||||||
tab(^); l.
|
.nf
|
||||||
aria2c [\fIoptions\fR] \fIURL\fR ...
|
aria2c [OPTIONS] URL ...
|
||||||
aria2c [\fIoptions\fR] \fB\-T\fR \fITORRENT_FILE FILE\fR ...
|
aria2c [OPTIONS] \-T TORRENT_FILE FILE ...
|
||||||
aria2c [\fIoptions\fR] \fB\-M\fR \fIMETALINK_FILE\fR
|
aria2c [OPTIONS] \-M METALINK_FILE
|
||||||
.TE
|
.fi
|
||||||
|
.RE
|
||||||
.SH DESCRIPTION
|
.SH "DESCRIPTION"
|
||||||
.P
|
aria2 is a utility for downloading files. It has completely new design concept from its predecessor, Aria, and is written from scratch. aria2 has a segmented downloading engine in its core. It can download one file from multiple URLs or multiple connections from one URL. This results in very high speed downloading, much faster than ordinary browsers. This engine in was implemented in a single\-thread model. The architecture is clean and easy to extend. aria2 currently supports HTTP, FTP, and BitTorrent. It also supports Metalink version 3.0.
|
||||||
aria2 is a utility for downloading files. It has completely new design
|
.sp
|
||||||
concept from its predecessor, Aria, and is written from scratch.
|
Please visit the project web site at http://aria2.sourceforge.net
|
||||||
aria2 has a segmented downloading engine in its core.
|
.sp
|
||||||
It can download one file from multiple URLs or multiple connections from one
|
.SH "OPTIONS"
|
||||||
URL. This results in very high speed downloading, much faster than ordinary
|
.TP 3n
|
||||||
browsers. This engine in was implemented in a single\-thread model.
|
\-d, \-\-dir=DIR
|
||||||
The architecture is clean and easy to extend. aria2 currently supports HTTP,
|
|
||||||
FTP, and BitTorrent. It also supports Metalink version 3.0.
|
|
||||||
|
|
||||||
.P
|
|
||||||
Please visit the project web site at \fIhttp://aria2.sourceforge.net\fR.
|
|
||||||
|
|
||||||
.SH OPTIONS
|
|
||||||
.TP
|
|
||||||
\fB\-d\fR, \fB\-\-dir\fR=\fIDIR\fR
|
|
||||||
The directory to store downloaded file.
|
The directory to store downloaded file.
|
||||||
|
.TP 3n
|
||||||
.TP
|
\-o, \-\-out=FILE
|
||||||
\fB\-o\fR, \fB\-\-out\fR=\fIFILE\fR
|
|
||||||
The file name for downloaded file.
|
The file name for downloaded file.
|
||||||
|
.TP 3n
|
||||||
.TP
|
\-l, \-\-log=LOG
|
||||||
\fB\-l\fR, \fB\-\-log\fR=\fILOG\fR
|
The file path to store log. If
|
||||||
The file path to store log. If '\-' is specified,
|
\fI\-\fR
|
||||||
log is written to stdout.
|
is specified, log is written to stdout.
|
||||||
|
.TP 3n
|
||||||
.TP
|
\-D, \-\-daemon
|
||||||
\fB\-D\fR, \fB\-\-daemon\fR
|
|
||||||
Run as daemon.
|
Run as daemon.
|
||||||
|
.TP 3n
|
||||||
.TP
|
\-s, \-\-split=N
|
||||||
\fB\-s\fR, \fB\-\-split\fR=\fIN\fR
|
Download a file using
|
||||||
Download a file using \fIN\fR connections. \fIN\fR must be
|
\fIN\fR
|
||||||
between 1 and 5. This option affects all URLs.
|
connections.
|
||||||
Thus, aria2 connects to each URL with
|
\fIN\fR
|
||||||
\fIN\fR connections.
|
must be between
|
||||||
|
\fI1\fR
|
||||||
.TP
|
and
|
||||||
\fB\-\-retry\-wait\fR=\fISEC\fR
|
\fI5\fR. This option affects all URLs. Thus, aria2 connects to each URL with
|
||||||
Set amount of time in second between requests
|
\fIN\fR
|
||||||
for errors. Specify a value between 0 and 60.
|
connections. Default:
|
||||||
Default: 5
|
\fI1\fR
|
||||||
|
.TP 3n
|
||||||
.TP
|
\-\-retry\-wait=SEC
|
||||||
\fB\-t\fR, \fB\-\-timeout\fR=\fISEC\fR
|
Set amount of time in second between requests for errors. Specify a value between
|
||||||
Set timeout in second. Default: 60
|
\fI0\fR
|
||||||
|
and
|
||||||
.TP
|
\fI60\fR. Default:
|
||||||
\fB\-m\fR, \fB\-\-max\-tries\fR=\fIN\fR
|
\fI5\fR
|
||||||
Set number of tries. 0 means unlimited.
|
.TP 3n
|
||||||
Default: 5
|
\-t, \-\-timeout=SEC
|
||||||
|
Set timeout in second. Default:
|
||||||
.TP
|
\fI60\fR
|
||||||
\fB\-\-http\-proxy\fR=\fIHOST\fR:\fIPORT\fR
|
.TP 3n
|
||||||
Use HTTP proxy server. This affects to all
|
\-m, \-\-max\-tries=N
|
||||||
URLs.
|
Set number of tries.
|
||||||
|
\fI0\fR
|
||||||
.TP
|
means unlimited. Default:
|
||||||
\fB\-\-http\-user\fR=\fIUSER\fR
|
\fI5\fR
|
||||||
|
.TP 3n
|
||||||
|
\-\-http\-proxy=HOST:PORT
|
||||||
|
Use HTTP proxy server. This affects to all URLs.
|
||||||
|
.TP 3n
|
||||||
|
\-\-http\-user=USER
|
||||||
Set HTTP user. This affects to all URLs.
|
Set HTTP user. This affects to all URLs.
|
||||||
|
.TP 3n
|
||||||
.TP
|
\-\-http\-passwd=PASSWD
|
||||||
\fB\-\-http\-passwd\fR=\fIPASSWD\fR
|
|
||||||
Set HTTP password. This affects to all URLs.
|
Set HTTP password. This affects to all URLs.
|
||||||
|
.TP 3n
|
||||||
.TP
|
\-\-http\-proxy\-user=USER
|
||||||
\fB\-\-http\-proxy\-user\fR=\fIUSER\fR
|
|
||||||
Set HTTP proxy user. This affects to all URLs
|
Set HTTP proxy user. This affects to all URLs
|
||||||
|
.TP 3n
|
||||||
.TP
|
\-\-http\-proxy\-passwd=PASSWD
|
||||||
\fB\-\-http\-proxy\-passwd\fR=\fIPASSWD\fR
|
|
||||||
Set HTTP proxy password. This affects to all URLs.
|
Set HTTP proxy password. This affects to all URLs.
|
||||||
|
.TP 3n
|
||||||
.TP
|
\-\-http\-proxy\-method=METHOD
|
||||||
\fB\-\-http\-proxy\-method\fR=\fIMETHOD\fR
|
|
||||||
Set the method to use in proxy request.
|
Set the method to use in proxy request.
|
||||||
\fIMETHOD\fR is either 'get' or 'tunnel'.
|
\fIMETHOD\fR
|
||||||
Default: tunnel
|
is either
|
||||||
|
\fIget\fR
|
||||||
.TP
|
or
|
||||||
\fB\-\-http\-auth\-scheme\fR=\fISCHEME\fR
|
\fItunnel\fR. Default:
|
||||||
Set HTTP authentication scheme. Currently, basic
|
\fItunnel\fR
|
||||||
is the only supported scheme.
|
.TP 3n
|
||||||
Default: basic
|
\-\-http\-auth\-scheme=SCHEME
|
||||||
|
Set HTTP authentication scheme. Currently,
|
||||||
.TP
|
\fIbasic\fR
|
||||||
\fB\-\-referer\fR=\fIREFERER\fR
|
is the only supported scheme. Default:
|
||||||
|
\fIbasic\fR
|
||||||
|
.TP 3n
|
||||||
|
\-\-referer=REFERER
|
||||||
Set Referer. This affects to all URLs.
|
Set Referer. This affects to all URLs.
|
||||||
|
.TP 3n
|
||||||
.TP
|
\-\-ftp\-user=USER
|
||||||
\fB\-\-ftp\-user\fR=\fIUSER\fR
|
Set FTP user. This affects to all URLs. Default:
|
||||||
Set FTP user. This affects to all URLs.
|
\fIanonymous\fR
|
||||||
Default: anonymous
|
.TP 3n
|
||||||
.TP
|
\-\-ftp\-passwd=PASSWD
|
||||||
\fB\-\-ftp\-passwd\fR=\fIPASSWD\fR
|
Set FTP password. This affects to all URLs. Default:
|
||||||
Set FTP password. This affects to all URLs.
|
\fIARIA2USER@\fR
|
||||||
Default: ARIA2USER@
|
.TP 3n
|
||||||
|
\-\-ftp\-type=TYPE
|
||||||
.TP
|
Set FTP transfer type. TYPE is either
|
||||||
\fB\-\-ftp\-type\fR=\fITYPE\fR
|
\fIbinary\fR
|
||||||
Set FTP transfer type. TYPE is either 'binary'
|
or
|
||||||
or 'ascii'.
|
\fIascii\fR. Default:
|
||||||
Default: binary
|
\fIbinary\fR
|
||||||
|
.TP 3n
|
||||||
.TP
|
\-p, \-\-ftp\-pasv
|
||||||
\fB\-p\fR, \fB\-\-ftp\-pasv\fR
|
|
||||||
Use passive mode in FTP.
|
Use passive mode in FTP.
|
||||||
|
.TP 3n
|
||||||
.TP
|
\-\-ftp\-via\-http\-proxy=METHOD
|
||||||
\fB\-\-ftp\-via\-http\-proxy\fR=\fIMETHOD\fR
|
Use HTTP proxy in
|
||||||
Use HTTP proxy in FTP. \fIMETHOD\fR is either 'get' or
|
\fIFTP\fR.
|
||||||
\&'tunnel'.
|
\fIMETHOD\fR
|
||||||
Default: tunnel
|
is either
|
||||||
|
\fIget\fR
|
||||||
.TP
|
or
|
||||||
\fB\-\-lowest\-speed\-limit\fR=\fISPEED\fR
|
\fItunnel\fR. Default:
|
||||||
Close connection if download speed is lower than
|
\fItunnel\fR
|
||||||
or equal to this value(bytes per sec).
|
.TP 3n
|
||||||
0 means aria2 does not care lowest speed limit.
|
\-\-lowest\-speed\-limit=SPEED
|
||||||
You can append K or M(1K = 1024, 1M = 1024K).
|
Close connection if download speed is lower than or equal to this value(bytes per sec). 0 means aria2 does not care lowest speed limit. You can append
|
||||||
This option does not affect BitTorrent download.
|
\fIK\fR
|
||||||
Default: 0
|
or
|
||||||
|
\fIM\fR(1K = 1024, 1M = 1024K). This option does not affect BitTorrent download. Default:
|
||||||
.TP
|
\fI0\fR
|
||||||
\fB\-\-max\-download\-limit\fR=\fISPEED\fR
|
.TP 3n
|
||||||
|
\-\-max\-download\-limit=SPEED
|
||||||
Set max download speed in bytes per sec.
|
Set max download speed in bytes per sec.
|
||||||
0 means unrestricted.
|
\fI0\fR
|
||||||
You can append K or M(1K = 1024, 1M = 1024K).
|
means unrestricted. You can append
|
||||||
Default: 0
|
\fIK\fR
|
||||||
|
or
|
||||||
.TP
|
\fIM\fR(1K = 1024, 1M = 1024K). Default:
|
||||||
\fB\-T\fR, \fB\-\-torrent\-file\fR=\fITORRENT_FILE\fR
|
\fI0\fR
|
||||||
|
.TP 3n
|
||||||
|
\-\-file\-allocation=METHOD
|
||||||
|
Specify file allocation method.
|
||||||
|
\fIMETHOD\fR
|
||||||
|
is either
|
||||||
|
\fInone\fR
|
||||||
|
or
|
||||||
|
\fIprealloc\fR.
|
||||||
|
\fInone\fR
|
||||||
|
doesn't pre\-allocate file space.
|
||||||
|
\fIprealloc\fR
|
||||||
|
pre\-allocates file space before download begins. This may take some time depending on the size of file. Default:
|
||||||
|
\fInone\fR
|
||||||
|
.TP 3n
|
||||||
|
\-\-allow\-overwrite=true|false
|
||||||
|
If this option set to
|
||||||
|
\fIfalse\fR, aria2 doesn't download a file which already exists in the file system but its corresponding .aria2 file doesn't exist. Default:
|
||||||
|
\fIfalse\fR
|
||||||
|
.TP 3n
|
||||||
|
\-\-check\-integiry=true|false
|
||||||
|
Check file integiry by validating piece hash. This option makes effect in BitTorrent download and Metalink with chunk checksums. Use this option to redownload a damaged portion of file. You may need to specify
|
||||||
|
\fI\-\-allow\-overwrite=true\fR
|
||||||
|
option if .aria2 file doesn't exist. Default:
|
||||||
|
\fIfalse\fR
|
||||||
|
.TP 3n
|
||||||
|
\-\-realtime\-chunk\-checksum=true|false
|
||||||
|
Validate chunk checksum while downloading a file in Metalink mode. This option makes effect in Metalink with chunk checksums. Default:
|
||||||
|
\fItrue\fR
|
||||||
|
.TP 3n
|
||||||
|
\-T, \-\-torrent\-file=TORRENT_FILE
|
||||||
The file path to .torrent file.
|
The file path to .torrent file.
|
||||||
|
.TP 3n
|
||||||
.TP
|
\-\-follow\-torrent=true|false
|
||||||
\fB\-\-follow\-torrent\fR=true|false
|
Setting this option to
|
||||||
Setting this option to false prevents aria2 to
|
\fIfalse\fR
|
||||||
enter BitTorrent mode even if the filename of
|
prevents aria2 to enter BitTorrent mode even if the filename of downloaded file ends with .torrent. Default:
|
||||||
downloaded file ends with .torrent.
|
\fItrue\fR
|
||||||
Default: true
|
.TP 3n
|
||||||
|
\-S, \-\-show\-files
|
||||||
.TP
|
|
||||||
\fB\-S\fR, \fB\-\-show\-files\fR
|
|
||||||
Print file listing of .torrent file and exit.
|
Print file listing of .torrent file and exit.
|
||||||
|
.TP 3n
|
||||||
.TP
|
\-\-direct\-file\-mapping=true|false
|
||||||
\fB\-\-direct\-file\-mapping\fR=true|false
|
Directly read from and write to each file mentioned in .torrent file. Default:
|
||||||
Directly read from and write to each file
|
\fItrue\fR
|
||||||
mentioned in .torrent file.
|
.TP 3n
|
||||||
Default: true
|
\-\-listen\-port=PORT
|
||||||
|
|
||||||
.TP
|
|
||||||
\fB\-\-listen\-port\fR=\fIPORT\fR
|
|
||||||
Set port number to listen to for peer connection.
|
Set port number to listen to for peer connection.
|
||||||
|
.TP 3n
|
||||||
.TP
|
\-\-max\-upload\-limit=SPEED
|
||||||
\fB\-\-max\-upload\-limit\fR=\fISPEED\fR
|
|
||||||
Set max upload speed in bytes per sec.
|
Set max upload speed in bytes per sec.
|
||||||
0 means unrestricted.
|
\fI0\fR
|
||||||
You can append K or M(1K = 1024, 1M = 1024K).
|
means unrestricted. You can append
|
||||||
Default: 0
|
\fIK\fR
|
||||||
|
or
|
||||||
.TP
|
\fIM\fR(1K = 1024, 1M = 1024K). Default:
|
||||||
\fB\-\-select\-file\fR=\fIINDEX\fR...
|
\fI0\fR
|
||||||
Set file to download by specifing its index.
|
.TP 3n
|
||||||
You can know file index through \fB\-\-show\-files\fR
|
\-\-select\-file=INDEX\&...
|
||||||
|
Set file to download by specifing its index. You can know file index through
|
||||||
|
\fI\-\-show\-files\fR
|
||||||
option. Multiple indexes can be specified by using
|
option. Multiple indexes can be specified by using
|
||||||
\&',' like "3,6".
|
\fI,\fR
|
||||||
You can also use '\-' to specify rangelike "1\-5".
|
like "3,6". You can also use
|
||||||
\&',' and '\-' can be used together.
|
\fI\-\fR
|
||||||
|
to specify rangelike "1\-5".
|
||||||
.TP
|
\fI,\fR
|
||||||
\fB\-\-seed\-time\fR=\fIMINUTES\fR
|
and
|
||||||
|
\fI\-\fR
|
||||||
|
can be used together.
|
||||||
|
.TP 3n
|
||||||
|
\-\-seed\-time=MINUTES
|
||||||
Specify seeding time in minutes. See also
|
Specify seeding time in minutes. See also
|
||||||
\fB\-\-seed\-ratio\fR option.
|
\fI\-\-seed\-ratio\fR
|
||||||
|
option.
|
||||||
.TP
|
.TP 3n
|
||||||
\fB\-\-seed\-ratio\fR=\fIRATIO\fR
|
\-\-seed\-ratio=RATIO
|
||||||
Specify share ratio. Seed completed torrents until
|
Specify share ratio. Seed completed torrents until share ratio reaches
|
||||||
share ratio reaches RATIO. 1.0 is encouraged.
|
\fIRATIO\fR.
|
||||||
If \fB\-\-seed\-time\fR option is specified along with
|
\fI1.0\fR
|
||||||
this option, seeding ends when at least one of
|
is encouraged. If
|
||||||
the conditions is satisfied.
|
\fI\-\-seed\-time\fR
|
||||||
|
option is specified along with this option, seeding ends when at least one of the conditions is satisfied.
|
||||||
.TP
|
.TP 3n
|
||||||
\fB\-M\fR, \fB\-\-metalink\-file\fR=\fIMETALINK_FILE\fR
|
\-M, \-\-metalink\-file=METALINK_FILE
|
||||||
The file path to .metalink file.
|
The file path to .metalink file.
|
||||||
|
.TP 3n
|
||||||
.TP
|
\-C, \-\-metalink\-servers=NUM_SERVERS
|
||||||
\fB\-C\fR, \fB\-\-metalink\-servers\fR=\fINUM_SERVERS\fR
|
The number of servers to connect to simultaneously. If more than one connection per server is required, use
|
||||||
The number of servers to connect to
|
\fI\-s\fR
|
||||||
simultaneously. If more than one connection per
|
option. Default:
|
||||||
server is required, use \fB\-s\fR option.
|
\fI15\fR
|
||||||
Default: 15
|
.TP 3n
|
||||||
|
\-\-metalink\-version=VERSION
|
||||||
.TP
|
|
||||||
\fB\-\-metalink\-version\fR=\fIVERSION\fR
|
|
||||||
The version of file to download.
|
The version of file to download.
|
||||||
|
.TP 3n
|
||||||
.TP
|
\-\-metalink\-language=LANGUAGE
|
||||||
\fB\-\-metalink\-language\fR=\fILANGUAGE\fR
|
|
||||||
The language of file to download.
|
The language of file to download.
|
||||||
|
.TP 3n
|
||||||
.TP
|
\-\-metalink\-os=OS
|
||||||
\fB\-\-metalink\-os\fR=\fIOS\fR
|
|
||||||
The operating system the file is targeted.
|
The operating system the file is targeted.
|
||||||
|
.TP 3n
|
||||||
.TP
|
\-\-metalink\-location=LOCATION
|
||||||
\fB\-\-follow\-metalink\fR=true|false
|
The location of the prefered server.
|
||||||
Setting this option to false prevents aria2 to
|
.TP 3n
|
||||||
enter Metalink mode even if the filename of
|
\-\-follow\-metalink=true|false
|
||||||
downloaded file ends with .metalink.
|
Setting this option to
|
||||||
Default: true
|
\fIfalse\fR
|
||||||
|
prevents aria2 to enter Metalink mode even if the filename of downloaded file ends with .metalink. Default:
|
||||||
.TP
|
\fItrue\fR
|
||||||
\fB\-v\fR, \fB\-\-version\fR
|
.TP 3n
|
||||||
|
\-v, \-\-version
|
||||||
Print the version number and exit.
|
Print the version number and exit.
|
||||||
|
.TP 3n
|
||||||
.TP
|
\-h, \-\-help
|
||||||
\fB\-h\fR, \fB\-\-help\fR
|
|
||||||
Print this message and exit.
|
Print this message and exit.
|
||||||
|
.TP 3n
|
||||||
.TP
|
URL
|
||||||
\fIURL\fR
|
You can specify multiple URLs. All URLs must point to the same file or downloading fails.
|
||||||
You can specify multiple URLs. All URLs must point to the same file
|
.TP 3n
|
||||||
or downloading fails.
|
FILE
|
||||||
|
|
||||||
.TP
|
|
||||||
\fIFILE\fR
|
|
||||||
Specify files in multi\-file torrent to download. Use conjunction with
|
Specify files in multi\-file torrent to download. Use conjunction with
|
||||||
\fB\-T\fR option. This arguments are ignored if you specify \fB\-\-select\-file\fR option.
|
\fI\-T\fR
|
||||||
|
option. This arguments are ignored if you specify
|
||||||
.SH REPORTING BUGS
|
\fI\-\-select\-file\fR
|
||||||
.P
|
option.
|
||||||
Report bugs to <tujikawa at users dot sourceforge dot net>
|
.SH "EXAMPLES"
|
||||||
|
.TP 3n
|
||||||
.SH COPYRIGHT
|
Download a file by 1 connection
|
||||||
.P
|
aria2c http://AAA.BBB.CCC/file.zip
|
||||||
Copyright (C) 2006 Tatsuhiro Tsujikawa
|
.TP 3n
|
||||||
|
Download a file by 2 connections
|
||||||
.P
|
aria2c \-s 2 http://AAA.BBB.CCC/file.zip
|
||||||
This program is free software; you can redistribute it and/or modify
|
.TP 3n
|
||||||
it under the terms of the GNU General Public License as published by
|
Download a file by 2 connections, each connects to a different server
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
aria2c http://AAA.BBB.CCC/file.zip http://DDD.EEE.FFF/GGG/file.zip
|
||||||
(at your option) any later version.
|
.TP 3n
|
||||||
|
You can mix up different protocols
|
||||||
.P
|
aria2c http://AAA.BBB.CCC/file.zip ftp://DDD.EEE.FFF/GGG/file.zip
|
||||||
This program is distributed in the hope that it will be useful,
|
.TP 3n
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
Download a torrent
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
aria2c \-o test.torrent http://AAA.BBB.CCC/file.torrent
|
||||||
GNU General Public License for more details.
|
.TP 3n
|
||||||
|
Download a torrent using local .torrent file
|
||||||
.P
|
aria2c \-T test.torrent
|
||||||
You should have received a copy of the GNU General Public License
|
.TP 3n
|
||||||
along with this program; if not, write to the Free Software
|
Download only selected files
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110\-1301 USA
|
aria2c \-T test.torrent dir/file1.zip dir/file2.zip
|
||||||
|
.TP 3n
|
||||||
|
Print file listing of .torrent file
|
||||||
.\" man code generated by txt2tags 2.3 (http://txt2tags.sf.net)
|
aria2c \-T test.torrent \-S
|
||||||
.\" cmdline: txt2tags -t man aria2c.t2t
|
.TP 3n
|
||||||
|
Metalink downloading
|
||||||
|
aria2c \-\-lowest\-speed\-limit 10K http://AAA.BBB.CCC/file.metalink
|
||||||
|
.TP 3n
|
||||||
|
Download a file using local .metalink file
|
||||||
|
aria2c \-M test.metalink
|
||||||
|
.TP 3n
|
||||||
|
Metalink downloading with preferences
|
||||||
|
aria2c \-M test.metalink \-\-metalink\-version=1.1.1 \-\-metalink\-language=en\-US
|
||||||
|
.SH "REPORTING BUGS"
|
||||||
|
Report bugs to Tatsuhiro Tsujikawa <t\-tujikawa@users.sourceforge.net>
|
||||||
|
.sp
|
||||||
|
.SH "AUTHOR"
|
||||||
|
Tatsuhiro Tsujikawa <t\-tujikawa@users.sourceforge.net>
|
||||||
|
.sp
|
||||||
|
.SH "COPYRIGHT"
|
||||||
|
Copyright \(co 2006, 2007 Tatsuhiro Tsujikawa
|
||||||
|
.sp
|
||||||
|
|
|
@ -0,0 +1,283 @@
|
||||||
|
ARIA2C(1)
|
||||||
|
=========
|
||||||
|
Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
|
NAME
|
||||||
|
----
|
||||||
|
aria2c - The high speed download utility
|
||||||
|
|
||||||
|
SYNOPSIS
|
||||||
|
--------
|
||||||
|
-----------------------------------------
|
||||||
|
aria2c [OPTIONS] URL ...
|
||||||
|
aria2c [OPTIONS] -T TORRENT_FILE FILE ...
|
||||||
|
aria2c [OPTIONS] -M METALINK_FILE
|
||||||
|
-----------------------------------------
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
-----------
|
||||||
|
aria2 is a utility for downloading files. It has completely new design
|
||||||
|
concept from its predecessor, Aria, and is written from scratch.
|
||||||
|
aria2 has a segmented downloading engine in its core.
|
||||||
|
It can download one file from multiple URLs or multiple connections from one
|
||||||
|
URL. This results in very high speed downloading, much faster than ordinary
|
||||||
|
browsers. This engine in was implemented in a single-thread model.
|
||||||
|
The architecture is clean and easy to extend. aria2 currently supports HTTP,
|
||||||
|
FTP, and BitTorrent. It also supports Metalink version 3.0.
|
||||||
|
|
||||||
|
Please visit the project web site at http://aria2.sourceforge.net
|
||||||
|
|
||||||
|
OPTIONS
|
||||||
|
-------
|
||||||
|
-d, --dir=DIR::
|
||||||
|
The directory to store downloaded file.
|
||||||
|
|
||||||
|
-o, --out=FILE::
|
||||||
|
The file name for downloaded file.
|
||||||
|
|
||||||
|
-l, --log=LOG::
|
||||||
|
The file path to store log. If '-' is specified, log is written to
|
||||||
|
stdout.
|
||||||
|
|
||||||
|
-D, --daemon::
|
||||||
|
Run as daemon.
|
||||||
|
|
||||||
|
-s, --split=N::
|
||||||
|
Download a file using 'N' connections. 'N' must be between '1' and '5'.
|
||||||
|
This option affects all URLs. Thus, aria2 connects to each URL with 'N'
|
||||||
|
connections.
|
||||||
|
Default: '1'
|
||||||
|
|
||||||
|
--retry-wait=SEC::
|
||||||
|
Set amount of time in second between requests for errors. Specify a
|
||||||
|
value between '0' and '60'.
|
||||||
|
Default: '5'
|
||||||
|
|
||||||
|
-t, --timeout=SEC::
|
||||||
|
Set timeout in second.
|
||||||
|
Default: '60'
|
||||||
|
|
||||||
|
-m, --max-tries=N::
|
||||||
|
Set number of tries. '0' means unlimited.
|
||||||
|
Default: '5'
|
||||||
|
|
||||||
|
--http-proxy=HOST:PORT::
|
||||||
|
Use HTTP proxy server. This affects to all URLs.
|
||||||
|
|
||||||
|
--http-user=USER::
|
||||||
|
Set HTTP user. This affects to all URLs.
|
||||||
|
|
||||||
|
--http-passwd=PASSWD::
|
||||||
|
Set HTTP password. This affects to all URLs.
|
||||||
|
|
||||||
|
--http-proxy-user=USER::
|
||||||
|
Set HTTP proxy user. This affects to all URLs
|
||||||
|
|
||||||
|
--http-proxy-passwd=PASSWD::
|
||||||
|
Set HTTP proxy password. This affects to all URLs.
|
||||||
|
|
||||||
|
--http-proxy-method=METHOD::
|
||||||
|
Set the method to use in proxy request.
|
||||||
|
'METHOD' is either 'get' or 'tunnel'.
|
||||||
|
Default: 'tunnel'
|
||||||
|
|
||||||
|
--http-auth-scheme=SCHEME::
|
||||||
|
Set HTTP authentication scheme. Currently, 'basic'
|
||||||
|
is the only supported scheme.
|
||||||
|
Default: 'basic'
|
||||||
|
|
||||||
|
--referer=REFERER::
|
||||||
|
Set Referer. This affects to all URLs.
|
||||||
|
|
||||||
|
--ftp-user=USER::
|
||||||
|
Set FTP user. This affects to all URLs.
|
||||||
|
Default: 'anonymous'
|
||||||
|
|
||||||
|
--ftp-passwd=PASSWD::
|
||||||
|
Set FTP password. This affects to all URLs.
|
||||||
|
Default: 'ARIA2USER@'
|
||||||
|
|
||||||
|
--ftp-type=TYPE::
|
||||||
|
Set FTP transfer type. TYPE is either 'binary'
|
||||||
|
or 'ascii'.
|
||||||
|
Default: 'binary'
|
||||||
|
|
||||||
|
-p, --ftp-pasv::
|
||||||
|
Use passive mode in FTP.
|
||||||
|
|
||||||
|
--ftp-via-http-proxy=METHOD::
|
||||||
|
Use HTTP proxy in 'FTP'. 'METHOD' is either 'get' or
|
||||||
|
'tunnel'.
|
||||||
|
Default: 'tunnel'
|
||||||
|
|
||||||
|
--lowest-speed-limit=SPEED::
|
||||||
|
Close connection if download speed is lower than
|
||||||
|
or equal to this value(bytes per sec).
|
||||||
|
0 means aria2 does not care lowest speed limit.
|
||||||
|
You can append 'K' or 'M'(1K = 1024, 1M = 1024K).
|
||||||
|
This option does not affect BitTorrent download.
|
||||||
|
Default: '0'
|
||||||
|
|
||||||
|
--max-download-limit=SPEED::
|
||||||
|
Set max download speed in bytes per sec.
|
||||||
|
'0' means unrestricted.
|
||||||
|
You can append 'K' or 'M'(1K = 1024, 1M = 1024K).
|
||||||
|
Default: '0'
|
||||||
|
|
||||||
|
--file-allocation=METHOD::
|
||||||
|
Specify file allocation method. 'METHOD' is either
|
||||||
|
'none' or 'prealloc'.
|
||||||
|
'none' doesn't pre-allocate file space. 'prealloc'
|
||||||
|
pre-allocates file space before download begins.
|
||||||
|
This may take some time depending on the size of
|
||||||
|
file.
|
||||||
|
Default: 'none'
|
||||||
|
|
||||||
|
--allow-overwrite=true|false::
|
||||||
|
If this option set to 'false', aria2 doesn't
|
||||||
|
download a file which already exists in the file
|
||||||
|
system but its corresponding .aria2 file doesn't
|
||||||
|
exist.
|
||||||
|
Default: 'false'
|
||||||
|
|
||||||
|
--check-integiry=true|false::
|
||||||
|
Check file integiry by validating piece hash.
|
||||||
|
This option makes effect in BitTorrent download
|
||||||
|
and Metalink with chunk checksums.
|
||||||
|
Use this option to redownload a damaged portion of
|
||||||
|
file.
|
||||||
|
You may need to specify '--allow-overwrite=true'
|
||||||
|
option if .aria2 file doesn't exist.
|
||||||
|
Default: 'false'
|
||||||
|
|
||||||
|
--realtime-chunk-checksum=true|false::
|
||||||
|
Validate chunk checksum while downloading
|
||||||
|
a file in Metalink mode. This option makes effect
|
||||||
|
in Metalink with chunk checksums.
|
||||||
|
Default: 'true'
|
||||||
|
|
||||||
|
-T, --torrent-file=TORRENT_FILE::
|
||||||
|
The file path to .torrent file.
|
||||||
|
|
||||||
|
--follow-torrent=true|false::
|
||||||
|
Setting this option to 'false' prevents aria2 to
|
||||||
|
enter BitTorrent mode even if the filename of
|
||||||
|
downloaded file ends with .torrent.
|
||||||
|
Default: 'true'
|
||||||
|
|
||||||
|
-S, --show-files::
|
||||||
|
Print file listing of .torrent file and exit.
|
||||||
|
|
||||||
|
--direct-file-mapping=true|false::
|
||||||
|
Directly read from and write to each file
|
||||||
|
mentioned in .torrent file.
|
||||||
|
Default: 'true'
|
||||||
|
|
||||||
|
--listen-port=PORT::
|
||||||
|
Set port number to listen to for peer connection.
|
||||||
|
|
||||||
|
--max-upload-limit=SPEED::
|
||||||
|
Set max upload speed in bytes per sec.
|
||||||
|
'0' means unrestricted.
|
||||||
|
You can append 'K' or 'M'(1K = 1024, 1M = 1024K).
|
||||||
|
Default: '0'
|
||||||
|
|
||||||
|
--select-file=INDEX...::
|
||||||
|
Set file to download by specifing its index.
|
||||||
|
You can know file index through '--show-files'
|
||||||
|
option. Multiple indexes can be specified by using
|
||||||
|
',' like "3,6".
|
||||||
|
You can also use '-' to specify rangelike "1-5".
|
||||||
|
',' and '-' can be used together.
|
||||||
|
|
||||||
|
--seed-time=MINUTES::
|
||||||
|
Specify seeding time in minutes. See also
|
||||||
|
'--seed-ratio' option.
|
||||||
|
|
||||||
|
--seed-ratio=RATIO::
|
||||||
|
Specify share ratio. Seed completed torrents until
|
||||||
|
share ratio reaches 'RATIO'. '1.0' is encouraged.
|
||||||
|
If '--seed-time' option is specified along with
|
||||||
|
this option, seeding ends when at least one of
|
||||||
|
the conditions is satisfied.
|
||||||
|
|
||||||
|
-M, --metalink-file=METALINK_FILE::
|
||||||
|
The file path to .metalink file.
|
||||||
|
|
||||||
|
-C, --metalink-servers=NUM_SERVERS::
|
||||||
|
The number of servers to connect to
|
||||||
|
simultaneously. If more than one connection per
|
||||||
|
server is required, use '-s' option.
|
||||||
|
Default: '15'
|
||||||
|
|
||||||
|
--metalink-version=VERSION::
|
||||||
|
The version of file to download.
|
||||||
|
|
||||||
|
--metalink-language=LANGUAGE::
|
||||||
|
The language of file to download.
|
||||||
|
|
||||||
|
--metalink-os=OS::
|
||||||
|
The operating system the file is targeted.
|
||||||
|
|
||||||
|
--metalink-location=LOCATION::
|
||||||
|
The location of the prefered server.
|
||||||
|
|
||||||
|
--follow-metalink=true|false::
|
||||||
|
Setting this option to 'false' prevents aria2 to
|
||||||
|
enter Metalink mode even if the filename of
|
||||||
|
downloaded file ends with .metalink.
|
||||||
|
Default: 'true'
|
||||||
|
|
||||||
|
-v, --version::
|
||||||
|
Print the version number and exit.
|
||||||
|
|
||||||
|
-h, --help::
|
||||||
|
Print this message and exit.
|
||||||
|
|
||||||
|
URL::
|
||||||
|
You can specify multiple URLs. All URLs must point to the same file
|
||||||
|
or downloading fails.
|
||||||
|
|
||||||
|
FILE::
|
||||||
|
Specify files in multi-file torrent to download. Use conjunction with
|
||||||
|
'-T' option. This arguments are ignored if you specify '--select-file' option.
|
||||||
|
|
||||||
|
EXAMPLES
|
||||||
|
--------
|
||||||
|
|
||||||
|
Download a file by 1 connection::
|
||||||
|
aria2c http://AAA.BBB.CCC/file.zip
|
||||||
|
Download a file by 2 connections::
|
||||||
|
aria2c -s 2 http://AAA.BBB.CCC/file.zip
|
||||||
|
Download a file by 2 connections, each connects to a different server::
|
||||||
|
aria2c http://AAA.BBB.CCC/file.zip http://DDD.EEE.FFF/GGG/file.zip
|
||||||
|
You can mix up different protocols::
|
||||||
|
aria2c http://AAA.BBB.CCC/file.zip ftp://DDD.EEE.FFF/GGG/file.zip
|
||||||
|
|
||||||
|
Download a torrent::
|
||||||
|
aria2c -o test.torrent http://AAA.BBB.CCC/file.torrent
|
||||||
|
Download a torrent using local .torrent file::
|
||||||
|
aria2c -T test.torrent
|
||||||
|
Download only selected files::
|
||||||
|
aria2c -T test.torrent dir/file1.zip dir/file2.zip
|
||||||
|
Print file listing of .torrent file::
|
||||||
|
aria2c -T test.torrent -S
|
||||||
|
|
||||||
|
Metalink downloading::
|
||||||
|
aria2c --lowest-speed-limit 10K http://AAA.BBB.CCC/file.metalink
|
||||||
|
Download a file using local .metalink file::
|
||||||
|
aria2c -M test.metalink
|
||||||
|
Metalink downloading with preferences::
|
||||||
|
aria2c -M test.metalink --metalink-version=1.1.1 --metalink-language=en-US
|
||||||
|
|
||||||
|
REPORTING BUGS
|
||||||
|
--------------
|
||||||
|
Report bugs to Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
|
AUTHOR
|
||||||
|
------
|
||||||
|
Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
|
COPYRIGHT
|
||||||
|
---------
|
||||||
|
Copyright (C) 2006, 2007 Tatsuhiro Tsujikawa
|
222
doc/aria2c.t2t
222
doc/aria2c.t2t
|
@ -1,222 +0,0 @@
|
||||||
ARIA2C
|
|
||||||
aria2 0.8.1
|
|
||||||
October 2006
|
|
||||||
|
|
||||||
= NAME =
|
|
||||||
aria2c - The high speed download utility
|
|
||||||
|
|
||||||
= SYNOPSIS =
|
|
||||||
|
|
||||||
| aria2c [//options//] //URL// ...
|
|
||||||
| aria2c [//options//] **-T** //TORRENT_FILE FILE// ...
|
|
||||||
| aria2c [//options//] **-M** //METALINK_FILE//
|
|
||||||
= DESCRIPTION =
|
|
||||||
aria2 is a utility for downloading files. It has completely new design
|
|
||||||
concept from its predecessor, Aria, and is written from scratch.
|
|
||||||
aria2 has a segmented downloading engine in its core.
|
|
||||||
It can download one file from multiple URLs or multiple connections from one
|
|
||||||
URL. This results in very high speed downloading, much faster than ordinary
|
|
||||||
browsers. This engine in was implemented in a single-thread model.
|
|
||||||
The architecture is clean and easy to extend. aria2 currently supports HTTP,
|
|
||||||
FTP, and BitTorrent. It also supports Metalink version 3.0.
|
|
||||||
|
|
||||||
Please visit the project web site at //""http://aria2.sourceforge.net""//.
|
|
||||||
|
|
||||||
= OPTIONS =
|
|
||||||
: **-d**, **--dir**=//DIR//
|
|
||||||
The directory to store downloaded file.
|
|
||||||
|
|
||||||
: **-o**, **--out**=//FILE//
|
|
||||||
The file name for downloaded file.
|
|
||||||
|
|
||||||
: **-l**, **--log**=//LOG//
|
|
||||||
The file path to store log. If '-' is specified,
|
|
||||||
log is written to stdout.
|
|
||||||
|
|
||||||
: **-D**, **--daemon**
|
|
||||||
Run as daemon.
|
|
||||||
|
|
||||||
: **-s**, **--split**=//N//
|
|
||||||
Download a file using //N// connections. //N// must be
|
|
||||||
between 1 and 5. This option affects all URLs.
|
|
||||||
Thus, aria2 connects to each URL with
|
|
||||||
//N// connections.
|
|
||||||
|
|
||||||
: **--retry-wait**=//SEC//
|
|
||||||
Set amount of time in second between requests
|
|
||||||
for errors. Specify a value between 0 and 60.
|
|
||||||
Default: 5
|
|
||||||
|
|
||||||
: **-t**, **--timeout**=//SEC//
|
|
||||||
Set timeout in second. Default: 60
|
|
||||||
|
|
||||||
: **-m**, **--max-tries**=//N//
|
|
||||||
Set number of tries. 0 means unlimited.
|
|
||||||
Default: 5
|
|
||||||
|
|
||||||
: **--http-proxy**=//HOST//://PORT//
|
|
||||||
Use HTTP proxy server. This affects to all
|
|
||||||
URLs.
|
|
||||||
|
|
||||||
: **--http-user**=//USER//
|
|
||||||
Set HTTP user. This affects to all URLs.
|
|
||||||
|
|
||||||
: **--http-passwd**=//PASSWD//
|
|
||||||
Set HTTP password. This affects to all URLs.
|
|
||||||
|
|
||||||
: **--http-proxy-user**=//USER//
|
|
||||||
Set HTTP proxy user. This affects to all URLs
|
|
||||||
|
|
||||||
: **--http-proxy-passwd**=//PASSWD//
|
|
||||||
Set HTTP proxy password. This affects to all URLs.
|
|
||||||
|
|
||||||
: **--http-proxy-method**=//METHOD//
|
|
||||||
Set the method to use in proxy request.
|
|
||||||
//METHOD// is either 'get' or 'tunnel'.
|
|
||||||
Default: tunnel
|
|
||||||
|
|
||||||
: **--http-auth-scheme**=//SCHEME//
|
|
||||||
Set HTTP authentication scheme. Currently, basic
|
|
||||||
is the only supported scheme.
|
|
||||||
Default: basic
|
|
||||||
|
|
||||||
: **--referer**=//REFERER//
|
|
||||||
Set Referer. This affects to all URLs.
|
|
||||||
|
|
||||||
: **--ftp-user**=//USER//
|
|
||||||
Set FTP user. This affects to all URLs.
|
|
||||||
Default: anonymous
|
|
||||||
: **--ftp-passwd**=//PASSWD//
|
|
||||||
Set FTP password. This affects to all URLs.
|
|
||||||
Default: ARIA2USER@
|
|
||||||
|
|
||||||
: **--ftp-type**=//TYPE//
|
|
||||||
Set FTP transfer type. TYPE is either 'binary'
|
|
||||||
or 'ascii'.
|
|
||||||
Default: binary
|
|
||||||
|
|
||||||
: **-p**, **--ftp-pasv**
|
|
||||||
Use passive mode in FTP.
|
|
||||||
|
|
||||||
: **--ftp-via-http-proxy**=//METHOD//
|
|
||||||
Use HTTP proxy in FTP. //METHOD// is either 'get' or
|
|
||||||
'tunnel'.
|
|
||||||
Default: tunnel
|
|
||||||
|
|
||||||
: **--lowest-speed-limit**=//SPEED//
|
|
||||||
Close connection if download speed is lower than
|
|
||||||
or equal to this value(bytes per sec).
|
|
||||||
0 means aria2 does not care lowest speed limit.
|
|
||||||
You can append K or M(1K = 1024, 1M = 1024K).
|
|
||||||
This option does not affect BitTorrent download.
|
|
||||||
Default: 0
|
|
||||||
|
|
||||||
: **--max-download-limit**=//SPEED//
|
|
||||||
Set max download speed in bytes per sec.
|
|
||||||
0 means unrestricted.
|
|
||||||
You can append K or M(1K = 1024, 1M = 1024K).
|
|
||||||
Default: 0
|
|
||||||
|
|
||||||
: **-T**, **--torrent-file**=//TORRENT_FILE//
|
|
||||||
The file path to .torrent file.
|
|
||||||
|
|
||||||
: **--follow-torrent**=true|false
|
|
||||||
Setting this option to false prevents aria2 to
|
|
||||||
enter BitTorrent mode even if the filename of
|
|
||||||
downloaded file ends with .torrent.
|
|
||||||
Default: true
|
|
||||||
|
|
||||||
: **-S**, **--show-files**
|
|
||||||
Print file listing of .torrent file and exit.
|
|
||||||
|
|
||||||
: **--direct-file-mapping**=true|false
|
|
||||||
Directly read from and write to each file
|
|
||||||
mentioned in .torrent file.
|
|
||||||
Default: true
|
|
||||||
|
|
||||||
: **--listen-port**=//PORT//
|
|
||||||
Set port number to listen to for peer connection.
|
|
||||||
|
|
||||||
: **--max-upload-limit**=//SPEED//
|
|
||||||
Set max upload speed in bytes per sec.
|
|
||||||
0 means unrestricted.
|
|
||||||
You can append K or M(1K = 1024, 1M = 1024K).
|
|
||||||
Default: 0
|
|
||||||
|
|
||||||
: **--select-file**=//INDEX//...
|
|
||||||
Set file to download by specifing its index.
|
|
||||||
You can know file index through **--show-files**
|
|
||||||
option. Multiple indexes can be specified by using
|
|
||||||
',' like "3,6".
|
|
||||||
You can also use '-' to specify rangelike "1-5".
|
|
||||||
',' and '-' can be used together.
|
|
||||||
|
|
||||||
: **--seed-time**=//MINUTES//
|
|
||||||
Specify seeding time in minutes. See also
|
|
||||||
**--seed-ratio** option.
|
|
||||||
|
|
||||||
: **--seed-ratio**=//RATIO//
|
|
||||||
Specify share ratio. Seed completed torrents until
|
|
||||||
share ratio reaches RATIO. 1.0 is encouraged.
|
|
||||||
If **--seed-time** option is specified along with
|
|
||||||
this option, seeding ends when at least one of
|
|
||||||
the conditions is satisfied.
|
|
||||||
|
|
||||||
: **-M**, **--metalink-file**=//METALINK_FILE//
|
|
||||||
The file path to .metalink file.
|
|
||||||
|
|
||||||
: **-C**, **--metalink-servers**=//NUM_SERVERS//
|
|
||||||
The number of servers to connect to
|
|
||||||
simultaneously. If more than one connection per
|
|
||||||
server is required, use **-s** option.
|
|
||||||
Default: 15
|
|
||||||
|
|
||||||
: **--metalink-version**=//VERSION//
|
|
||||||
The version of file to download.
|
|
||||||
|
|
||||||
: **--metalink-language**=//LANGUAGE//
|
|
||||||
The language of file to download.
|
|
||||||
|
|
||||||
: **--metalink-os**=//OS//
|
|
||||||
The operating system the file is targeted.
|
|
||||||
|
|
||||||
: **--follow-metalink**=true|false
|
|
||||||
Setting this option to false prevents aria2 to
|
|
||||||
enter Metalink mode even if the filename of
|
|
||||||
downloaded file ends with .metalink.
|
|
||||||
Default: true
|
|
||||||
|
|
||||||
: **-v**, **--version**
|
|
||||||
Print the version number and exit.
|
|
||||||
|
|
||||||
: **-h**, **--help**
|
|
||||||
Print this message and exit.
|
|
||||||
|
|
||||||
: //URL//
|
|
||||||
You can specify multiple URLs. All URLs must point to the same file
|
|
||||||
or downloading fails.
|
|
||||||
|
|
||||||
: //FILE//
|
|
||||||
Specify files in multi-file torrent to download. Use conjunction with
|
|
||||||
**-T** option. This arguments are ignored if you specify **--select-file** option.
|
|
||||||
|
|
||||||
|
|
||||||
= REPORTING BUGS =
|
|
||||||
Report bugs to <tujikawa at users dot sourceforge dot net>
|
|
||||||
|
|
||||||
= COPYRIGHT =
|
|
||||||
Copyright (C) 2006 Tatsuhiro Tsujikawa
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
@ -9,7 +9,7 @@
|
||||||
# General Public License and is *not* in the public domain.
|
# General Public License and is *not* in the public domain.
|
||||||
|
|
||||||
PACKAGE = aria2c
|
PACKAGE = aria2c
|
||||||
VERSION = 0.9.0
|
VERSION = 0.10.0
|
||||||
|
|
||||||
SHELL = /bin/sh
|
SHELL = /bin/sh
|
||||||
|
|
||||||
|
|
|
@ -103,17 +103,16 @@ int32_t AbstractDiskWriter::readDataInternal(char* data, int32_t len) {
|
||||||
return read(fd, data, len);
|
return read(fd, data, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
string AbstractDiskWriter::messageDigest(int64_t offset, int64_t length,
|
string AbstractDiskWriter::messageDigest(int64_t offset, int64_t length,
|
||||||
const MessageDigestContext::DigestAlgo& algo)
|
const MessageDigestContext::DigestAlgo& algo)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
MessageDigestContext ctx(algo);
|
MessageDigestContext ctx(algo);
|
||||||
ctx.digestInit();
|
ctx.digestInit();
|
||||||
|
|
||||||
int32_t BUFSIZE = 16*1024;
|
int32_t BUFSIZE = 16*1024;
|
||||||
char buf[BUFSIZE];
|
char buf[BUFSIZE];
|
||||||
for(int64_t i = 0; i < length/BUFSIZE; i++) {
|
for(int64_t i = 0; i < length/BUFSIZE; i++) {
|
||||||
int32_t rs = readData(buf, BUFSIZE, offset);
|
|
||||||
if(BUFSIZE != readData(buf, BUFSIZE, offset)) {
|
if(BUFSIZE != readData(buf, BUFSIZE, offset)) {
|
||||||
throw new DlAbortEx(EX_FILE_SHA1SUM, filename.c_str(), strerror(errno));
|
throw new DlAbortEx(EX_FILE_SHA1SUM, filename.c_str(), strerror(errno));
|
||||||
}
|
}
|
||||||
|
@ -122,7 +121,6 @@ string AbstractDiskWriter::messageDigest(int64_t offset, int64_t length,
|
||||||
}
|
}
|
||||||
int32_t r = length%BUFSIZE;
|
int32_t r = length%BUFSIZE;
|
||||||
if(r > 0) {
|
if(r > 0) {
|
||||||
int32_t rs = readData(buf, r, offset);
|
|
||||||
if(r != readData(buf, r, offset)) {
|
if(r != readData(buf, r, offset)) {
|
||||||
throw new DlAbortEx(EX_FILE_SHA1SUM, filename.c_str(), strerror(errno));
|
throw new DlAbortEx(EX_FILE_SHA1SUM, filename.c_str(), strerror(errno));
|
||||||
}
|
}
|
||||||
|
@ -132,10 +130,8 @@ string AbstractDiskWriter::messageDigest(int64_t offset, int64_t length,
|
||||||
ctx.digestFinal(hashValue);
|
ctx.digestFinal(hashValue);
|
||||||
|
|
||||||
return Util::toHex(hashValue, 20);
|
return Util::toHex(hashValue, 20);
|
||||||
#else
|
|
||||||
return "";
|
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
|
||||||
}
|
}
|
||||||
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
|
|
||||||
void AbstractDiskWriter::seek(int64_t offset) {
|
void AbstractDiskWriter::seek(int64_t offset) {
|
||||||
if(offset != lseek(fd, offset, SEEK_SET)) {
|
if(offset != lseek(fd, offset, SEEK_SET)) {
|
||||||
|
|
|
@ -64,8 +64,10 @@ public:
|
||||||
|
|
||||||
virtual void openExistingFile(const string& filename);
|
virtual void openExistingFile(const string& filename);
|
||||||
|
|
||||||
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
virtual string messageDigest(int64_t offset, int64_t length,
|
virtual string messageDigest(int64_t offset, int64_t length,
|
||||||
const MessageDigestContext::DigestAlgo& algo);
|
const MessageDigestContext::DigestAlgo& algo);
|
||||||
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
|
|
||||||
virtual void writeData(const char* data, int32_t len, int64_t offset);
|
virtual void writeData(const char* data, int32_t len, int64_t offset);
|
||||||
|
|
||||||
|
|
|
@ -444,7 +444,7 @@ bool BitfieldMan::unsetBit(int32_t index) {
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BitfieldMan::isAllBitSet() const {
|
bool BitfieldMan::isFilteredAllBitSet() const {
|
||||||
if(filterEnabled) {
|
if(filterEnabled) {
|
||||||
for(int32_t i = 0; i < bitfieldLength; ++i) {
|
for(int32_t i = 0; i < bitfieldLength; ++i) {
|
||||||
if((bitfield[i]&filterBitfield[i]) != filterBitfield[i]) {
|
if((bitfield[i]&filterBitfield[i]) != filterBitfield[i]) {
|
||||||
|
@ -453,6 +453,11 @@ bool BitfieldMan::isAllBitSet() const {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
return isAllBitSet();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BitfieldMan::isAllBitSet() const {
|
||||||
for(int32_t i = 0; i < bitfieldLength-1; ++i) {
|
for(int32_t i = 0; i < bitfieldLength-1; ++i) {
|
||||||
if(bitfield[i] != 0xff) {
|
if(bitfield[i] != 0xff) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -463,7 +468,6 @@ bool BitfieldMan::isAllBitSet() const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BitfieldMan::isBitSetInternal(const unsigned char* bitfield, int32_t index) const {
|
bool BitfieldMan::isBitSetInternal(const unsigned char* bitfield, int32_t index) const {
|
||||||
|
|
|
@ -184,6 +184,8 @@ public:
|
||||||
/**
|
/**
|
||||||
* affected by filter
|
* affected by filter
|
||||||
*/
|
*/
|
||||||
|
bool isFilteredAllBitSet() const;
|
||||||
|
|
||||||
bool isAllBitSet() const;
|
bool isAllBitSet() const;
|
||||||
|
|
||||||
const unsigned char* getBitfield() const { return bitfield; }
|
const unsigned char* getBitfield() const { return bitfield; }
|
||||||
|
|
|
@ -56,15 +56,15 @@ public:
|
||||||
|
|
||||||
virtual const unsigned char* getInfoHash() const = 0;
|
virtual const unsigned char* getInfoHash() const = 0;
|
||||||
|
|
||||||
virtual int getInfoHashLength() const = 0;
|
virtual int32_t getInfoHashLength() const = 0;
|
||||||
|
|
||||||
virtual string getInfoHashAsString() const = 0;
|
virtual string getInfoHashAsString() const = 0;
|
||||||
|
|
||||||
virtual string getPieceHash(int index) const = 0;
|
virtual string getPieceHash(int32_t index) const = 0;
|
||||||
|
|
||||||
virtual const Strings& getPieceHashes() const = 0;
|
virtual const Strings& getPieceHashes() const = 0;
|
||||||
|
|
||||||
virtual long long int getTotalLength() const = 0;
|
virtual int64_t getTotalLength() const = 0;
|
||||||
|
|
||||||
virtual FILE_MODE getFileMode() const = 0;
|
virtual FILE_MODE getFileMode() const = 0;
|
||||||
|
|
||||||
|
@ -76,9 +76,9 @@ public:
|
||||||
|
|
||||||
virtual string getName() const = 0;
|
virtual string getName() const = 0;
|
||||||
|
|
||||||
virtual int getPieceLength() const = 0;
|
virtual int32_t getPieceLength() const = 0;
|
||||||
|
|
||||||
virtual int getNumPieces() const = 0;
|
virtual int32_t getNumPieces() const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the peer id of localhost, 20 byte length
|
* Returns the peer id of localhost, 20 byte length
|
||||||
|
|
|
@ -60,9 +60,14 @@ public:
|
||||||
// position is ignored
|
// position is ignored
|
||||||
virtual void writeData(const char* data, int32_t len, int64_t position = 0);
|
virtual void writeData(const char* data, int32_t len, int64_t position = 0);
|
||||||
virtual int readData(char* data, int32_t len, int64_t position);
|
virtual int readData(char* data, int32_t len, int64_t position);
|
||||||
|
|
||||||
// not implemented yet
|
// not implemented yet
|
||||||
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
virtual string messageDigest(int64_t offset, int64_t length,
|
virtual string messageDigest(int64_t offset, int64_t length,
|
||||||
const MessageDigestContext::DigestAlgo& algo) { return ""; }
|
const MessageDigestContext::DigestAlgo& algo) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
|
|
||||||
const char* getByteArray() const {
|
const char* getByteArray() const {
|
||||||
return buf;
|
return buf;
|
||||||
|
|
|
@ -36,9 +36,9 @@
|
||||||
#define _D_CHECKSUM_H_
|
#define _D_CHECKSUM_H_
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
#include "messageDigest.h"
|
#include "messageDigest.h"
|
||||||
|
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
|
||||||
class Checksum {
|
class Checksum {
|
||||||
private:
|
private:
|
||||||
string md;
|
string md;
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
#include "TimeA2.h"
|
#include "TimeA2.h"
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
|
|
||||||
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
void ChunkChecksumValidator::validateSameLengthChecksum(BitfieldMan* bitfieldMan,
|
void ChunkChecksumValidator::validateSameLengthChecksum(BitfieldMan* bitfieldMan,
|
||||||
int32_t index,
|
int32_t index,
|
||||||
const string& expectedChecksum,
|
const string& expectedChecksum,
|
||||||
|
@ -118,3 +119,4 @@ void ChunkChecksumValidator::validate(BitfieldMan* bitfieldMan,
|
||||||
fileAllocationMonitor->setCurrentValue(bitfieldMan->getTotalLength());
|
fileAllocationMonitor->setCurrentValue(bitfieldMan->getTotalLength());
|
||||||
fileAllocationMonitor->showProgress();
|
fileAllocationMonitor->showProgress();
|
||||||
}
|
}
|
||||||
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
|
|
|
@ -38,12 +38,15 @@
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "DiskWriter.h"
|
#include "DiskWriter.h"
|
||||||
#include "BitfieldMan.h"
|
#include "BitfieldMan.h"
|
||||||
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
#include "messageDigest.h"
|
#include "messageDigest.h"
|
||||||
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
#include "LogFactory.h"
|
#include "LogFactory.h"
|
||||||
#include "FileAllocationMonitor.h"
|
#include "FileAllocationMonitor.h"
|
||||||
#include "NullFileAllocationMonitor.h"
|
#include "NullFileAllocationMonitor.h"
|
||||||
|
|
||||||
class ChunkChecksumValidator {
|
class ChunkChecksumValidator {
|
||||||
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
private:
|
private:
|
||||||
DiskWriterHandle diskWriter;
|
DiskWriterHandle diskWriter;
|
||||||
|
|
||||||
|
@ -89,6 +92,7 @@ public:
|
||||||
void setFileAllocationMonitor(const FileAllocationMonitorHandle& monitor) {
|
void setFileAllocationMonitor(const FileAllocationMonitorHandle& monitor) {
|
||||||
this->fileAllocationMonitor = monitor;
|
this->fileAllocationMonitor = monitor;
|
||||||
}
|
}
|
||||||
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _D_CHUNK_CHECKSUM_VALIDATOR_H_
|
#endif // _D_CHUNK_CHECKSUM_VALIDATOR_H_
|
||||||
|
|
|
@ -84,7 +84,7 @@ bool DefaultBtAnnounce::isStoppedAnnounceReady() {
|
||||||
|
|
||||||
bool DefaultBtAnnounce::isCompletedAnnounceReady() {
|
bool DefaultBtAnnounce::isCompletedAnnounceReady() {
|
||||||
return (trackers == 0 &&
|
return (trackers == 0 &&
|
||||||
pieceStorage->downloadFinished() &&
|
pieceStorage->allDownloadFinished() &&
|
||||||
announceList.countCompletedAllowedTier());
|
announceList.countCompletedAllowedTier());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ string DefaultBtAnnounce::getAnnounceUrl() {
|
||||||
// If download completed before "started" event is sent to a tracker,
|
// If download completed before "started" event is sent to a tracker,
|
||||||
// we change the event to something else to prevent us from
|
// we change the event to something else to prevent us from
|
||||||
// sending "completed" event.
|
// sending "completed" event.
|
||||||
if(pieceStorage->downloadFinished() &&
|
if(pieceStorage->allDownloadFinished() &&
|
||||||
announceList.getEvent() == AnnounceTier::STARTED) {
|
announceList.getEvent() == AnnounceTier::STARTED) {
|
||||||
announceList.setEvent(AnnounceTier::STARTED_AFTER_COMPLETION);
|
announceList.setEvent(AnnounceTier::STARTED_AFTER_COMPLETION);
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ const unsigned char* DefaultBtContext::getInfoHash() const {
|
||||||
return infoHash;
|
return infoHash;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DefaultBtContext::getInfoHashLength() const {
|
int32_t DefaultBtContext::getInfoHashLength() const {
|
||||||
return INFO_HASH_LENGTH;
|
return INFO_HASH_LENGTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,14 +78,14 @@ void DefaultBtContext::clear() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefaultBtContext::extractPieceHash(const unsigned char* hashData,
|
void DefaultBtContext::extractPieceHash(const unsigned char* hashData,
|
||||||
int hashDataLength,
|
int32_t hashDataLength,
|
||||||
int hashLength) {
|
int32_t hashLength) {
|
||||||
assert(hashDataLength > 0);
|
assert(hashDataLength > 0);
|
||||||
assert(hashLength > 0);
|
assert(hashLength > 0);
|
||||||
int numPieces = hashDataLength/hashLength;
|
int32_t numPieces = hashDataLength/hashLength;
|
||||||
assert(numPieces > 0);
|
assert(numPieces > 0);
|
||||||
|
|
||||||
for(int i = 0; i < numPieces; i++) {
|
for(int32_t i = 0; i < numPieces; i++) {
|
||||||
pieceHashes.push_back(Util::toHex(&hashData[i*hashLength],
|
pieceHashes.push_back(Util::toHex(&hashData[i*hashLength],
|
||||||
hashLength));
|
hashLength));
|
||||||
}
|
}
|
||||||
|
@ -180,7 +180,7 @@ void DefaultBtContext::load(const string& torrentFile) {
|
||||||
// retrieve infoHash
|
// retrieve infoHash
|
||||||
ShaVisitor v;
|
ShaVisitor v;
|
||||||
infoDic->accept(&v);
|
infoDic->accept(&v);
|
||||||
int len;
|
int32_t len;
|
||||||
v.getHash(infoHash, len);
|
v.getHash(infoHash, len);
|
||||||
infoHashString = Util::toHex(infoHash, INFO_HASH_LENGTH);
|
infoHashString = Util::toHex(infoHash, INFO_HASH_LENGTH);
|
||||||
// calculate the number of pieces
|
// calculate the number of pieces
|
||||||
|
@ -208,14 +208,14 @@ void DefaultBtContext::load(const string& torrentFile) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string DefaultBtContext::getPieceHash(int index) const {
|
string DefaultBtContext::getPieceHash(int32_t index) const {
|
||||||
if(index < 0 || numPieces <= index) {
|
if(index < 0 || numPieces <= index) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return pieceHashes.at(index);
|
return pieceHashes.at(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
long long int DefaultBtContext::getTotalLength() const {
|
int64_t DefaultBtContext::getTotalLength() const {
|
||||||
return totalLength;
|
return totalLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,10 +235,10 @@ string DefaultBtContext::getName() const {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DefaultBtContext::getPieceLength() const {
|
int32_t DefaultBtContext::getPieceLength() const {
|
||||||
return pieceLength;
|
return pieceLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DefaultBtContext::getNumPieces() const {
|
int32_t DefaultBtContext::getNumPieces() const {
|
||||||
return numPieces;
|
return numPieces;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,17 +51,17 @@ private:
|
||||||
PieceHashes pieceHashes;
|
PieceHashes pieceHashes;
|
||||||
FileEntries fileEntries;
|
FileEntries fileEntries;
|
||||||
FILE_MODE fileMode;
|
FILE_MODE fileMode;
|
||||||
long long int totalLength;
|
int64_t totalLength;
|
||||||
int pieceLength;
|
int32_t pieceLength;
|
||||||
string name;
|
string name;
|
||||||
int numPieces;
|
int32_t numPieces;
|
||||||
string peerId;
|
string peerId;
|
||||||
AnnounceTiers announceTiers;
|
AnnounceTiers announceTiers;
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
void extractPieceHash(const unsigned char* hashData,
|
void extractPieceHash(const unsigned char* hashData,
|
||||||
int hashDataLength,
|
int32_t hashDataLength,
|
||||||
int hashLength);
|
int32_t hashLength);
|
||||||
void extractFileEntries(Dictionary* infoDic,
|
void extractFileEntries(Dictionary* infoDic,
|
||||||
const string& defaultName);
|
const string& defaultName);
|
||||||
void extractAnnounce(Data* announceData);
|
void extractAnnounce(Data* announceData);
|
||||||
|
@ -72,18 +72,18 @@ private:
|
||||||
|
|
||||||
virtual const unsigned char* getInfoHash() const;
|
virtual const unsigned char* getInfoHash() const;
|
||||||
|
|
||||||
virtual int getInfoHashLength() const;
|
virtual int32_t getInfoHashLength() const;
|
||||||
|
|
||||||
virtual string getInfoHashAsString() const;
|
virtual string getInfoHashAsString() const;
|
||||||
|
|
||||||
virtual string getPieceHash(int index) const;
|
virtual string getPieceHash(int32_t index) const;
|
||||||
|
|
||||||
virtual const Strings& getPieceHashes() const
|
virtual const Strings& getPieceHashes() const
|
||||||
{
|
{
|
||||||
return pieceHashes;
|
return pieceHashes;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual long long int getTotalLength() const;
|
virtual int64_t getTotalLength() const;
|
||||||
|
|
||||||
virtual FILE_MODE getFileMode() const;
|
virtual FILE_MODE getFileMode() const;
|
||||||
|
|
||||||
|
@ -95,9 +95,9 @@ private:
|
||||||
|
|
||||||
virtual string getName() const;
|
virtual string getName() const;
|
||||||
|
|
||||||
virtual int getPieceLength() const;
|
virtual int32_t getPieceLength() const;
|
||||||
|
|
||||||
virtual int getNumPieces() const;
|
virtual int32_t getNumPieces() const;
|
||||||
|
|
||||||
virtual const unsigned char* getPeerId() {
|
virtual const unsigned char* getPeerId() {
|
||||||
if(peerId == "") {
|
if(peerId == "") {
|
||||||
|
|
|
@ -78,7 +78,7 @@ void DefaultBtInteractive::doPostHandshakeProcessing() {
|
||||||
|
|
||||||
void DefaultBtInteractive::addBitfieldMessageToQueue() {
|
void DefaultBtInteractive::addBitfieldMessageToQueue() {
|
||||||
if(peer->isFastExtensionEnabled()) {
|
if(peer->isFastExtensionEnabled()) {
|
||||||
if(pieceStorage->downloadFinished()) {
|
if(pieceStorage->allDownloadFinished()) {
|
||||||
dispatcher->addMessageToQueue(messageFactory->createHaveAllMessage());
|
dispatcher->addMessageToQueue(messageFactory->createHaveAllMessage());
|
||||||
} else if(pieceStorage->getCompletedLength() > 0) {
|
} else if(pieceStorage->getCompletedLength() > 0) {
|
||||||
dispatcher->addMessageToQueue(messageFactory->createBitfieldMessage());
|
dispatcher->addMessageToQueue(messageFactory->createBitfieldMessage());
|
||||||
|
@ -122,7 +122,7 @@ void DefaultBtInteractive::checkHave() {
|
||||||
pieceStorage->getAdvertisedPieceIndexes(cuid, haveCheckPoint);
|
pieceStorage->getAdvertisedPieceIndexes(cuid, haveCheckPoint);
|
||||||
haveCheckPoint.reset();
|
haveCheckPoint.reset();
|
||||||
if(indexes.size() >= 20) {
|
if(indexes.size() >= 20) {
|
||||||
if(peer->isFastExtensionEnabled() && pieceStorage->downloadFinished()) {
|
if(peer->isFastExtensionEnabled() && pieceStorage->allDownloadFinished()) {
|
||||||
dispatcher->addMessageToQueue(messageFactory->createHaveAllMessage());
|
dispatcher->addMessageToQueue(messageFactory->createHaveAllMessage());
|
||||||
} else {
|
} else {
|
||||||
dispatcher->addMessageToQueue(messageFactory->createBitfieldMessage());
|
dispatcher->addMessageToQueue(messageFactory->createBitfieldMessage());
|
||||||
|
|
|
@ -68,9 +68,14 @@ public:
|
||||||
peer(0),
|
peer(0),
|
||||||
maxUploadSpeedLimit(0),
|
maxUploadSpeedLimit(0),
|
||||||
requestTimeout(0),
|
requestTimeout(0),
|
||||||
logger(LogFactory::getInstance()) {}
|
logger(LogFactory::getInstance())
|
||||||
|
{
|
||||||
|
logger->debug("DefaultBtMessageDispatcher::instantiated");
|
||||||
|
}
|
||||||
|
|
||||||
virtual ~DefaultBtMessageDispatcher() {}
|
virtual ~DefaultBtMessageDispatcher() {
|
||||||
|
logger->debug("DefaultBtMessageDispatcher::deleted");
|
||||||
|
}
|
||||||
|
|
||||||
virtual void addMessageToQueue(const BtMessageHandle& btMessage);
|
virtual void addMessageToQueue(const BtMessageHandle& btMessage);
|
||||||
|
|
||||||
|
|
|
@ -231,7 +231,7 @@ void DefaultPieceStorage::completePiece(const PieceHandle& piece) {
|
||||||
if(!isEndGame()) {
|
if(!isEndGame()) {
|
||||||
reduceUsedPieces(100);
|
reduceUsedPieces(100);
|
||||||
}
|
}
|
||||||
if(downloadFinished()) {
|
if(allDownloadFinished()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bitfieldMan->setBit(piece->getIndex());
|
bitfieldMan->setBit(piece->getIndex());
|
||||||
|
@ -240,7 +240,9 @@ void DefaultPieceStorage::completePiece(const PieceHandle& piece) {
|
||||||
diskAdaptor->onDownloadComplete();
|
diskAdaptor->onDownloadComplete();
|
||||||
if(isSelectiveDownloadingMode()) {
|
if(isSelectiveDownloadingMode()) {
|
||||||
logger->notice(_("Download of selected files was complete."));
|
logger->notice(_("Download of selected files was complete."));
|
||||||
finishSelectiveDownloadingMode();
|
// following line was commented out in order to stop sending request
|
||||||
|
// message after user-specified files were downloaded.
|
||||||
|
//finishSelectiveDownloadingMode();
|
||||||
} else {
|
} else {
|
||||||
logger->info(_("The download was complete."));
|
logger->info(_("The download was complete."));
|
||||||
}
|
}
|
||||||
|
@ -326,6 +328,11 @@ void DefaultPieceStorage::clearFileFilter() {
|
||||||
|
|
||||||
// not unittested
|
// not unittested
|
||||||
bool DefaultPieceStorage::downloadFinished() {
|
bool DefaultPieceStorage::downloadFinished() {
|
||||||
|
return bitfieldMan->isFilteredAllBitSet();
|
||||||
|
}
|
||||||
|
|
||||||
|
// not unittested
|
||||||
|
bool DefaultPieceStorage::allDownloadFinished() {
|
||||||
return bitfieldMan->isAllBitSet();
|
return bitfieldMan->isAllBitSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -120,6 +120,8 @@ public:
|
||||||
|
|
||||||
virtual bool downloadFinished();
|
virtual bool downloadFinished();
|
||||||
|
|
||||||
|
virtual bool allDownloadFinished();
|
||||||
|
|
||||||
virtual void setBitfield(const unsigned char* bitfield,
|
virtual void setBitfield(const unsigned char* bitfield,
|
||||||
int bitfieldLength);
|
int bitfieldLength);
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,9 @@
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "FileEntry.h"
|
#include "FileEntry.h"
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
#include "messageDigest.h"
|
#include "messageDigest.h"
|
||||||
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
|
|
||||||
class DiskAdaptor {
|
class DiskAdaptor {
|
||||||
protected:
|
protected:
|
||||||
|
@ -61,8 +63,10 @@ public:
|
||||||
|
|
||||||
virtual int32_t readData(unsigned char* data, int32_t len, int64_t offset) = 0;
|
virtual int32_t readData(unsigned char* data, int32_t len, int64_t offset) = 0;
|
||||||
|
|
||||||
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
virtual string messageDigest(int64_t offset, int64_t length,
|
virtual string messageDigest(int64_t offset, int64_t length,
|
||||||
const MessageDigestContext::DigestAlgo& algo) = 0;
|
const MessageDigestContext::DigestAlgo& algo) = 0;
|
||||||
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
|
|
||||||
virtual void onDownloadComplete() = 0;
|
virtual void onDownloadComplete() = 0;
|
||||||
|
|
||||||
|
|
|
@ -91,9 +91,10 @@ public:
|
||||||
virtual int readData(unsigned char* data, int32_t len, int64_t position) {
|
virtual int readData(unsigned char* data, int32_t len, int64_t position) {
|
||||||
return readData((char*)data, len, position);
|
return readData((char*)data, len, position);
|
||||||
}
|
}
|
||||||
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
virtual string messageDigest(int64_t offset, int64_t length,
|
virtual string messageDigest(int64_t offset, int64_t length,
|
||||||
const MessageDigestContext::DigestAlgo& algo) = 0;
|
const MessageDigestContext::DigestAlgo& algo) = 0;
|
||||||
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef SharedHandle<DiskWriter> DiskWriterHandle;
|
typedef SharedHandle<DiskWriter> DiskWriterHandle;
|
||||||
|
|
|
@ -108,9 +108,11 @@ bool DownloadCommand::executeInternal(Segment& segment) {
|
||||||
if(te != NULL) te->end();
|
if(te != NULL) te->end();
|
||||||
logger->info(MSG_DOWNLOAD_COMPLETED, cuid);
|
logger->info(MSG_DOWNLOAD_COMPLETED, cuid);
|
||||||
e->segmentMan->completeSegment(cuid, segment);
|
e->segmentMan->completeSegment(cuid, segment);
|
||||||
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
if(e->option->get(PREF_REALTIME_CHUNK_CHECKSUM) == V_TRUE) {
|
if(e->option->get(PREF_REALTIME_CHUNK_CHECKSUM) == V_TRUE) {
|
||||||
e->segmentMan->tryChunkChecksumValidation(segment);
|
e->segmentMan->tryChunkChecksumValidation(segment);
|
||||||
}
|
}
|
||||||
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
// this unit is going to download another segment.
|
// this unit is going to download another segment.
|
||||||
return prepareForNextSegment(segment);
|
return prepareForNextSegment(segment);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -182,7 +182,7 @@ bool FtpNegotiationCommand::recvSize() {
|
||||||
if(status != 213) {
|
if(status != 213) {
|
||||||
throw new DlRetryEx(EX_BAD_STATUS, status);
|
throw new DlRetryEx(EX_BAD_STATUS, status);
|
||||||
}
|
}
|
||||||
if(size == LONG_LONG_MAX || size < 0) {
|
if(size == INT64_MAX || size < 0) {
|
||||||
throw new DlAbortEx(EX_TOO_LARGE_FILE, size);
|
throw new DlAbortEx(EX_TOO_LARGE_FILE, size);
|
||||||
}
|
}
|
||||||
if(!e->segmentMan->downloadStarted) {
|
if(!e->segmentMan->downloadStarted) {
|
||||||
|
|
|
@ -148,7 +148,7 @@ bool HttpResponseCommand::handleDefaultEncoding(const HttpHeader& headers) {
|
||||||
}
|
}
|
||||||
|
|
||||||
long long int size = headers.getFirstAsLLInt("Content-Length");
|
long long int size = headers.getFirstAsLLInt("Content-Length");
|
||||||
if(size == LONG_LONG_MAX || size < 0) {
|
if(size == INT64_MAX || size < 0) {
|
||||||
throw new DlAbortEx(EX_TOO_LARGE_FILE, size);
|
throw new DlAbortEx(EX_TOO_LARGE_FILE, size);
|
||||||
}
|
}
|
||||||
e->segmentMan->isSplittable = !(size == 0);
|
e->segmentMan->isSplittable = !(size == 0);
|
||||||
|
|
|
@ -182,7 +182,8 @@ SRCS += Metalinker.cc Metalinker.h\
|
||||||
MetalinkResource.cc MetalinkResource.h\
|
MetalinkResource.cc MetalinkResource.h\
|
||||||
MetalinkProcessor.h\
|
MetalinkProcessor.h\
|
||||||
Xml2MetalinkProcessor.cc Xml2MetalinkProcessor.h\
|
Xml2MetalinkProcessor.cc Xml2MetalinkProcessor.h\
|
||||||
MetalinkRequestInfo.cc MetalinkRequestInfo.h
|
MetalinkRequestInfo.cc MetalinkRequestInfo.h\
|
||||||
|
MetalinkChunkChecksum.h
|
||||||
endif # ENABLE_METALINK
|
endif # ENABLE_METALINK
|
||||||
|
|
||||||
noinst_LIBRARIES = libaria2c.a
|
noinst_LIBRARIES = libaria2c.a
|
||||||
|
@ -190,9 +191,9 @@ libaria2c_a_SOURCES = $(SRCS)
|
||||||
aria2c_LDADD = libaria2c.a @LIBINTL@ @ALLOCA@ @LIBGNUTLS_LIBS@\
|
aria2c_LDADD = libaria2c.a @LIBINTL@ @ALLOCA@ @LIBGNUTLS_LIBS@\
|
||||||
@LIBGCRYPT_LIBS@ @OPENSSL_LIBS@ @XML_LIBS@ @LIBARES_LIBS@\
|
@LIBGCRYPT_LIBS@ @OPENSSL_LIBS@ @XML_LIBS@ @LIBARES_LIBS@\
|
||||||
@LIBCARES_LIBS@
|
@LIBCARES_LIBS@
|
||||||
aria2c_LDFLAGS = -pg
|
#aria2c_LDFLAGS = -pg
|
||||||
AM_CPPFLAGS = -Wall\
|
AM_CPPFLAGS = -Wall\
|
||||||
-I../lib -I../intl -I$(top_srcdir)/intl\
|
-I../lib -I../intl -I$(top_srcdir)/intl\
|
||||||
@LIBGNUTLS_CFLAGS@ @LIBGCRYPT_CFLAGS@ @OPENSSL_CFLAGS@ @XML_CPPFLAGS@\
|
@LIBGNUTLS_CFLAGS@ @LIBGCRYPT_CFLAGS@ @OPENSSL_CFLAGS@ @XML_CPPFLAGS@\
|
||||||
@LIBARES_CPPFLAGS@ @LIBCARES_CPPFLAGS@\
|
@LIBARES_CPPFLAGS@ @LIBCARES_CPPFLAGS@\
|
||||||
-D_FILE_OFFSET_BITS=64 -DLOCALEDIR=\"$(localedir)\" @DEFS@ -pg
|
-D_FILE_OFFSET_BITS=64 -DLOCALEDIR=\"$(localedir)\" @DEFS@# -pg
|
|
@ -148,7 +148,8 @@ bin_PROGRAMS = aria2c$(EXEEXT)
|
||||||
@ENABLE_METALINK_TRUE@ MetalinkResource.cc MetalinkResource.h\
|
@ENABLE_METALINK_TRUE@ MetalinkResource.cc MetalinkResource.h\
|
||||||
@ENABLE_METALINK_TRUE@ MetalinkProcessor.h\
|
@ENABLE_METALINK_TRUE@ MetalinkProcessor.h\
|
||||||
@ENABLE_METALINK_TRUE@ Xml2MetalinkProcessor.cc Xml2MetalinkProcessor.h\
|
@ENABLE_METALINK_TRUE@ Xml2MetalinkProcessor.cc Xml2MetalinkProcessor.h\
|
||||||
@ENABLE_METALINK_TRUE@ MetalinkRequestInfo.cc MetalinkRequestInfo.h
|
@ENABLE_METALINK_TRUE@ MetalinkRequestInfo.cc MetalinkRequestInfo.h\
|
||||||
|
@ENABLE_METALINK_TRUE@ MetalinkChunkChecksum.h
|
||||||
|
|
||||||
subdir = src
|
subdir = src
|
||||||
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in alloca.c
|
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in alloca.c
|
||||||
|
@ -281,7 +282,8 @@ am__libaria2c_a_SOURCES_DIST = Socket.h SocketCore.cc SocketCore.h \
|
||||||
Metalinker.cc Metalinker.h MetalinkEntry.cc MetalinkEntry.h \
|
Metalinker.cc Metalinker.h MetalinkEntry.cc MetalinkEntry.h \
|
||||||
MetalinkResource.cc MetalinkResource.h MetalinkProcessor.h \
|
MetalinkResource.cc MetalinkResource.h MetalinkProcessor.h \
|
||||||
Xml2MetalinkProcessor.cc Xml2MetalinkProcessor.h \
|
Xml2MetalinkProcessor.cc Xml2MetalinkProcessor.h \
|
||||||
MetalinkRequestInfo.cc MetalinkRequestInfo.h
|
MetalinkRequestInfo.cc MetalinkRequestInfo.h \
|
||||||
|
MetalinkChunkChecksum.h
|
||||||
@ENABLE_ASYNC_DNS_TRUE@am__objects_1 = NameResolver.$(OBJEXT)
|
@ENABLE_ASYNC_DNS_TRUE@am__objects_1 = NameResolver.$(OBJEXT)
|
||||||
@ENABLE_BITTORRENT_TRUE@am__objects_2 = Data.$(OBJEXT) \
|
@ENABLE_BITTORRENT_TRUE@am__objects_2 = Data.$(OBJEXT) \
|
||||||
@ENABLE_BITTORRENT_TRUE@ Dictionary.$(OBJEXT) List.$(OBJEXT) \
|
@ENABLE_BITTORRENT_TRUE@ Dictionary.$(OBJEXT) List.$(OBJEXT) \
|
||||||
|
@ -592,12 +594,12 @@ aria2c_LDADD = libaria2c.a @LIBINTL@ @ALLOCA@ @LIBGNUTLS_LIBS@\
|
||||||
@LIBGCRYPT_LIBS@ @OPENSSL_LIBS@ @XML_LIBS@ @LIBARES_LIBS@\
|
@LIBGCRYPT_LIBS@ @OPENSSL_LIBS@ @XML_LIBS@ @LIBARES_LIBS@\
|
||||||
@LIBCARES_LIBS@
|
@LIBCARES_LIBS@
|
||||||
|
|
||||||
aria2c_LDFLAGS = -pg
|
#aria2c_LDFLAGS = -pg
|
||||||
AM_CPPFLAGS = -Wall\
|
AM_CPPFLAGS = -Wall\
|
||||||
-I../lib -I../intl -I$(top_srcdir)/intl\
|
-I../lib -I../intl -I$(top_srcdir)/intl\
|
||||||
@LIBGNUTLS_CFLAGS@ @LIBGCRYPT_CFLAGS@ @OPENSSL_CFLAGS@ @XML_CPPFLAGS@\
|
@LIBGNUTLS_CFLAGS@ @LIBGCRYPT_CFLAGS@ @OPENSSL_CFLAGS@ @XML_CPPFLAGS@\
|
||||||
@LIBARES_CPPFLAGS@ @LIBCARES_CPPFLAGS@\
|
@LIBARES_CPPFLAGS@ @LIBCARES_CPPFLAGS@\
|
||||||
-D_FILE_OFFSET_BITS=64 -DLOCALEDIR=\"$(localedir)\" @DEFS@ -pg
|
-D_FILE_OFFSET_BITS=64 -DLOCALEDIR=\"$(localedir)\" @DEFS@# -pg
|
||||||
|
|
||||||
all: all-am
|
all: all-am
|
||||||
|
|
||||||
|
|
|
@ -36,15 +36,19 @@
|
||||||
#define _D_METALINK_CHUNK_CHECKSUM_H_
|
#define _D_METALINK_CHUNK_CHECKSUM_H_
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
#include "messageDigest.h"
|
#include "messageDigest.h"
|
||||||
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
|
|
||||||
class MetalinkChunkChecksum {
|
class MetalinkChunkChecksum {
|
||||||
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
public:
|
public:
|
||||||
MessageDigestContext::DigestAlgo digestAlgo;
|
MessageDigestContext::DigestAlgo digestAlgo;
|
||||||
int32_t pieceLength;
|
int32_t pieceLength;
|
||||||
Strings pieceHashes;
|
Strings pieceHashes;
|
||||||
public:
|
public:
|
||||||
MetalinkChunkChecksum():pieceLength(0) {}
|
MetalinkChunkChecksum():pieceLength(0) {}
|
||||||
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef SharedHandle<MetalinkChunkChecksum> MetalinkChunkChecksumHandle;
|
typedef SharedHandle<MetalinkChunkChecksum> MetalinkChunkChecksumHandle;
|
||||||
|
|
|
@ -36,7 +36,13 @@
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
MetalinkEntry::MetalinkEntry():chunkChecksum(0) {}
|
MetalinkEntry::MetalinkEntry():
|
||||||
|
size(0)
|
||||||
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
|
,
|
||||||
|
chunkChecksum(0)
|
||||||
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
|
{}
|
||||||
|
|
||||||
MetalinkEntry::~MetalinkEntry() {}
|
MetalinkEntry::~MetalinkEntry() {}
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,9 @@ public:
|
||||||
Checksum checksum;
|
Checksum checksum;
|
||||||
public:
|
public:
|
||||||
MetalinkResources resources;
|
MetalinkResources resources;
|
||||||
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
MetalinkChunkChecksumHandle chunkChecksum;
|
MetalinkChunkChecksumHandle chunkChecksum;
|
||||||
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
public:
|
public:
|
||||||
MetalinkEntry();
|
MetalinkEntry();
|
||||||
~MetalinkEntry();
|
~MetalinkEntry();
|
||||||
|
@ -64,6 +66,9 @@ public:
|
||||||
this->os = metalinkEntry.os;
|
this->os = metalinkEntry.os;
|
||||||
this->size = metalinkEntry.size;
|
this->size = metalinkEntry.size;
|
||||||
this->checksum = metalinkEntry.checksum;
|
this->checksum = metalinkEntry.checksum;
|
||||||
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
|
this->chunkChecksum = metalinkEntry.chunkChecksum;
|
||||||
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,7 +97,7 @@ RequestInfos MetalinkRequestInfo::execute() {
|
||||||
if(entry->resources.size() == 0) {
|
if(entry->resources.size() == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
logger->notice("Metalink: Queueing %s for download.",
|
logger->info("Metalink: Queueing %s for download.",
|
||||||
entry->filename.c_str());
|
entry->filename.c_str());
|
||||||
MetalinkResources::iterator itr =
|
MetalinkResources::iterator itr =
|
||||||
find_if(entry->resources.begin(),
|
find_if(entry->resources.begin(),
|
||||||
|
@ -122,10 +122,14 @@ RequestInfos MetalinkRequestInfo::execute() {
|
||||||
urls.push_back((*itr)->url);
|
urls.push_back((*itr)->url);
|
||||||
}
|
}
|
||||||
UrlRequestInfoHandle reqInfo = new UrlRequestInfo(urls, maxConnection, op);
|
UrlRequestInfoHandle reqInfo = new UrlRequestInfo(urls, maxConnection, op);
|
||||||
|
reqInfo->setFilename(entry->filename);
|
||||||
|
reqInfo->setTotalLength(entry->size);
|
||||||
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
reqInfo->setChecksum(checksum);
|
reqInfo->setChecksum(checksum);
|
||||||
reqInfo->setDigestAlgo(entry->chunkChecksum->digestAlgo);
|
reqInfo->setDigestAlgo(entry->chunkChecksum->digestAlgo);
|
||||||
reqInfo->setChunkChecksumLength(entry->chunkChecksum->pieceLength);
|
reqInfo->setChunkChecksumLength(entry->chunkChecksum->pieceLength);
|
||||||
reqInfo->setChunkChecksums(entry->chunkChecksum->pieceHashes);
|
reqInfo->setChunkChecksums(entry->chunkChecksum->pieceHashes);
|
||||||
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
nextReqInfos.push_front(reqInfo);
|
nextReqInfos.push_front(reqInfo);
|
||||||
}
|
}
|
||||||
} catch(RecoverableException* ex) {
|
} catch(RecoverableException* ex) {
|
||||||
|
|
|
@ -47,14 +47,18 @@ PeerConnection::PeerConnection(int32_t cuid,
|
||||||
:cuid(cuid),
|
:cuid(cuid),
|
||||||
socket(socket),
|
socket(socket),
|
||||||
option(op),
|
option(op),
|
||||||
logger(logger),
|
logger(LogFactory::getInstance()),
|
||||||
resbufLength(0),
|
resbufLength(0),
|
||||||
currentPayloadLength(0),
|
currentPayloadLength(0),
|
||||||
lenbufLength(0) {
|
lenbufLength(0)
|
||||||
logger = LogFactory::getInstance();
|
{
|
||||||
|
logger->debug("PeerConnection::instantiated");
|
||||||
}
|
}
|
||||||
|
|
||||||
PeerConnection::~PeerConnection() {}
|
PeerConnection::~PeerConnection()
|
||||||
|
{
|
||||||
|
logger->debug("PeerConnection::deleted");
|
||||||
|
}
|
||||||
|
|
||||||
int32_t PeerConnection::sendMessage(const unsigned char* data, int32_t dataLength) {
|
int32_t PeerConnection::sendMessage(const unsigned char* data, int32_t dataLength) {
|
||||||
int32_t writtenLength = 0;
|
int32_t writtenLength = 0;
|
||||||
|
|
|
@ -102,8 +102,19 @@ public:
|
||||||
|
|
||||||
virtual void clearFileFilter() = 0;
|
virtual void clearFileFilter() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if download has completed.
|
||||||
|
* If file filter is enabled, then returns true if those files have
|
||||||
|
* downloaded.
|
||||||
|
*/
|
||||||
virtual bool downloadFinished() = 0;
|
virtual bool downloadFinished() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if all files have downloaded.
|
||||||
|
* The file filter is ignored.
|
||||||
|
*/
|
||||||
|
virtual bool allDownloadFinished() = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes DiskAdaptor.
|
* Initializes DiskAdaptor.
|
||||||
* TODO add better documentation here.
|
* TODO add better documentation here.
|
||||||
|
|
|
@ -40,24 +40,28 @@
|
||||||
#include "prefs.h"
|
#include "prefs.h"
|
||||||
#include "LogFactory.h"
|
#include "LogFactory.h"
|
||||||
#include "BitfieldManFactory.h"
|
#include "BitfieldManFactory.h"
|
||||||
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
#include "ChunkChecksumValidator.h"
|
#include "ChunkChecksumValidator.h"
|
||||||
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
SegmentMan::SegmentMan():bitfield(0),
|
SegmentMan::SegmentMan():logger(LogFactory::getInstance()),
|
||||||
|
bitfield(0),
|
||||||
totalSize(0),
|
totalSize(0),
|
||||||
isSplittable(true),
|
isSplittable(true),
|
||||||
downloadStarted(false),
|
downloadStarted(false),
|
||||||
dir("."),
|
dir("."),
|
||||||
errors(0),
|
errors(0),
|
||||||
diskWriter(0),
|
diskWriter(0)
|
||||||
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
|
,
|
||||||
chunkHashLength(0),
|
chunkHashLength(0),
|
||||||
digestAlgo(DIGEST_ALGO_SHA1)
|
digestAlgo(DIGEST_ALGO_SHA1)
|
||||||
{
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
logger = LogFactory::getInstance();
|
{}
|
||||||
}
|
|
||||||
|
|
||||||
SegmentMan::~SegmentMan() {
|
SegmentMan::~SegmentMan() {
|
||||||
delete bitfield;
|
delete bitfield;
|
||||||
|
@ -450,7 +454,7 @@ bool SegmentMan::fileExists() {
|
||||||
|
|
||||||
bool SegmentMan::shouldCancelDownloadForSafety() {
|
bool SegmentMan::shouldCancelDownloadForSafety() {
|
||||||
return fileExists() && !segmentFileExists() &&
|
return fileExists() && !segmentFileExists() &&
|
||||||
option->get(PREF_FORCE_TRUNCATE) != V_TRUE;
|
option->get(PREF_ALLOW_OVERWRITE) != V_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SegmentMan::markAllPiecesDone()
|
void SegmentMan::markAllPiecesDone()
|
||||||
|
@ -460,6 +464,7 @@ void SegmentMan::markAllPiecesDone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
void SegmentMan::checkIntegrity()
|
void SegmentMan::checkIntegrity()
|
||||||
{
|
{
|
||||||
logger->notice("Validating file %s",
|
logger->notice("Validating file %s",
|
||||||
|
@ -470,12 +475,16 @@ void SegmentMan::checkIntegrity()
|
||||||
v.setFileAllocationMonitor(FileAllocationMonitorFactory::getFactory()->createNewMonitor());
|
v.setFileAllocationMonitor(FileAllocationMonitorFactory::getFactory()->createNewMonitor());
|
||||||
v.validate(bitfield, pieceHashes, chunkHashLength);
|
v.validate(bitfield, pieceHashes, chunkHashLength);
|
||||||
}
|
}
|
||||||
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
|
|
||||||
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
bool SegmentMan::isChunkChecksumValidationReady() const {
|
bool SegmentMan::isChunkChecksumValidationReady() const {
|
||||||
return bitfield &&
|
return bitfield &&
|
||||||
((int64_t)pieceHashes.size())*chunkHashLength == ((int64_t)bitfield->getBlockLength())*(bitfield->getMaxIndex()+1);
|
((int64_t)pieceHashes.size())*chunkHashLength == ((int64_t)bitfield->getBlockLength())*(bitfield->getMaxIndex()+1);
|
||||||
}
|
}
|
||||||
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
|
|
||||||
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
void SegmentMan::tryChunkChecksumValidation(const Segment& segment)
|
void SegmentMan::tryChunkChecksumValidation(const Segment& segment)
|
||||||
{
|
{
|
||||||
if(!isChunkChecksumValidationReady()) {
|
if(!isChunkChecksumValidationReady()) {
|
||||||
|
@ -527,3 +536,4 @@ void SegmentMan::tryChunkChecksumValidation(const Segment& segment)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
|
|
|
@ -157,9 +157,11 @@ public:
|
||||||
DiskWriterHandle diskWriter;
|
DiskWriterHandle diskWriter;
|
||||||
Requests reserved;
|
Requests reserved;
|
||||||
|
|
||||||
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
Strings pieceHashes;
|
Strings pieceHashes;
|
||||||
int32_t chunkHashLength;
|
int32_t chunkHashLength;
|
||||||
MessageDigestContext::DigestAlgo digestAlgo;
|
MessageDigestContext::DigestAlgo digestAlgo;
|
||||||
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
|
|
||||||
SegmentMan();
|
SegmentMan();
|
||||||
~SegmentMan();
|
~SegmentMan();
|
||||||
|
@ -283,12 +285,13 @@ public:
|
||||||
|
|
||||||
void markAllPiecesDone();
|
void markAllPiecesDone();
|
||||||
|
|
||||||
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
void checkIntegrity();
|
void checkIntegrity();
|
||||||
|
|
||||||
void tryChunkChecksumValidation(const Segment& segment);
|
void tryChunkChecksumValidation(const Segment& segment);
|
||||||
|
|
||||||
bool isChunkChecksumValidationReady() const;
|
bool isChunkChecksumValidationReady() const;
|
||||||
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _D_SEGMENT_MAN_H_
|
#endif // _D_SEGMENT_MAN_H_
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
#include "SeedCriteria.h"
|
#include "SeedCriteria.h"
|
||||||
#include "BtContext.h"
|
#include "BtContext.h"
|
||||||
#include "PeerStorage.h"
|
#include "PeerStorage.h"
|
||||||
|
#include "PieceStorage.h"
|
||||||
#include "BtRuntime.h"
|
#include "BtRuntime.h"
|
||||||
#include "BtRegistry.h"
|
#include "BtRegistry.h"
|
||||||
|
|
||||||
|
@ -46,12 +47,14 @@ private:
|
||||||
double ratio;
|
double ratio;
|
||||||
BtContextHandle btContext;
|
BtContextHandle btContext;
|
||||||
PeerStorageHandle peerStorage;
|
PeerStorageHandle peerStorage;
|
||||||
|
PieceStorageHandle pieceStorage;
|
||||||
BtRuntimeHandle btRuntime;
|
BtRuntimeHandle btRuntime;
|
||||||
public:
|
public:
|
||||||
ShareRatioSeedCriteria(double ratio, const BtContextHandle& btContext)
|
ShareRatioSeedCriteria(double ratio, const BtContextHandle& btContext)
|
||||||
:ratio(ratio),
|
:ratio(ratio),
|
||||||
btContext(btContext),
|
btContext(btContext),
|
||||||
peerStorage(PEER_STORAGE(btContext)),
|
peerStorage(PEER_STORAGE(btContext)),
|
||||||
|
pieceStorage(PIECE_STORAGE(btContext)),
|
||||||
btRuntime(BT_RUNTIME(btContext)) {}
|
btRuntime(BT_RUNTIME(btContext)) {}
|
||||||
|
|
||||||
virtual ~ShareRatioSeedCriteria() {}
|
virtual ~ShareRatioSeedCriteria() {}
|
||||||
|
@ -66,7 +69,7 @@ public:
|
||||||
long long int allTimeUploadLength =
|
long long int allTimeUploadLength =
|
||||||
btRuntime->getUploadLengthAtStartup()+stat.getSessionUploadLength();
|
btRuntime->getUploadLengthAtStartup()+stat.getSessionUploadLength();
|
||||||
return ratio <=
|
return ratio <=
|
||||||
((double)allTimeUploadLength)/btContext->getTotalLength();
|
((double)allTimeUploadLength)/pieceStorage->getCompletedLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setRatio(double ratio) {
|
void setRatio(double ratio) {
|
||||||
|
|
|
@ -59,7 +59,7 @@ void TorrentDownloadEngine::setBtContext(const BtContextHandle& btContext) {
|
||||||
|
|
||||||
void TorrentDownloadEngine::onEndOfRun() {
|
void TorrentDownloadEngine::onEndOfRun() {
|
||||||
pieceStorage->getDiskAdaptor()->closeFile();
|
pieceStorage->getDiskAdaptor()->closeFile();
|
||||||
if(pieceStorage->downloadFinished()) {
|
if(pieceStorage->allDownloadFinished()) {
|
||||||
btProgressInfoFile->removeFile();
|
btProgressInfoFile->removeFile();
|
||||||
} else {
|
} else {
|
||||||
btProgressInfoFile->save();
|
btProgressInfoFile->save();
|
||||||
|
|
|
@ -67,21 +67,25 @@ RequestInfos TorrentRequestInfo::execute() {
|
||||||
// load .aria2 file if it exists.
|
// load .aria2 file if it exists.
|
||||||
BT_PROGRESS_INFO_FILE(btContext)->load();
|
BT_PROGRESS_INFO_FILE(btContext)->load();
|
||||||
PIECE_STORAGE(btContext)->getDiskAdaptor()->openExistingFile();
|
PIECE_STORAGE(btContext)->getDiskAdaptor()->openExistingFile();
|
||||||
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
if(op->get(PREF_CHECK_INTEGRITY) == V_TRUE) {
|
if(op->get(PREF_CHECK_INTEGRITY) == V_TRUE) {
|
||||||
PIECE_STORAGE(btContext)->checkIntegrity();
|
PIECE_STORAGE(btContext)->checkIntegrity();
|
||||||
}
|
}
|
||||||
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
} else {
|
} else {
|
||||||
if(PIECE_STORAGE(btContext)->getDiskAdaptor()->fileExists()) {
|
if(PIECE_STORAGE(btContext)->getDiskAdaptor()->fileExists()) {
|
||||||
if(op->get(PREF_FORCE_TRUNCATE) != V_TRUE) {
|
if(op->get(PREF_ALLOW_OVERWRITE) != V_TRUE) {
|
||||||
throw new FatalException(EX_FILE_ALREADY_EXISTS,
|
throw new FatalException(EX_FILE_ALREADY_EXISTS,
|
||||||
PIECE_STORAGE(btContext)->getDiskAdaptor()->getFilePath().c_str(),
|
PIECE_STORAGE(btContext)->getDiskAdaptor()->getFilePath().c_str(),
|
||||||
BT_PROGRESS_INFO_FILE(btContext)->getFilename().c_str());
|
BT_PROGRESS_INFO_FILE(btContext)->getFilename().c_str());
|
||||||
} else {
|
} else {
|
||||||
PIECE_STORAGE(btContext)->getDiskAdaptor()->openExistingFile();
|
PIECE_STORAGE(btContext)->getDiskAdaptor()->openExistingFile();
|
||||||
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
if(op->get(PREF_CHECK_INTEGRITY) == V_TRUE) {
|
if(op->get(PREF_CHECK_INTEGRITY) == V_TRUE) {
|
||||||
PIECE_STORAGE(btContext)->markAllPiecesDone();
|
PIECE_STORAGE(btContext)->markAllPiecesDone();
|
||||||
PIECE_STORAGE(btContext)->checkIntegrity();
|
PIECE_STORAGE(btContext)->checkIntegrity();
|
||||||
}
|
}
|
||||||
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
PIECE_STORAGE(btContext)->getDiskAdaptor()->initAndOpenFile();
|
PIECE_STORAGE(btContext)->getDiskAdaptor()->initAndOpenFile();
|
||||||
|
|
|
@ -155,31 +155,39 @@ RequestInfos UrlRequestInfo::execute() {
|
||||||
op->get(PREF_REFERER),
|
op->get(PREF_REFERER),
|
||||||
op->getAsInt(PREF_SPLIT)));
|
op->getAsInt(PREF_SPLIT)));
|
||||||
|
|
||||||
HeadResult hr = getHeadResult();
|
HeadResult hr;
|
||||||
|
if(filename.size() && totalLength > 0) {
|
||||||
|
hr.filename = filename;
|
||||||
|
hr.totalLength = totalLength;
|
||||||
|
} else {
|
||||||
|
hr = getHeadResult();
|
||||||
if(fail) {
|
if(fail) {
|
||||||
return RequestInfos();
|
return RequestInfos();
|
||||||
}
|
}
|
||||||
|
|
||||||
logger->info("Head result: filename=%s, total length=%s",
|
logger->info("Head result: filename=%s, total length=%s",
|
||||||
hr.filename.c_str(), Util::ullitos(hr.totalLength, true).c_str());
|
hr.filename.c_str(), Util::ullitos(hr.totalLength, true).c_str());
|
||||||
|
}
|
||||||
adjustRequestSize(requests, reserved, maxConnections);
|
adjustRequestSize(requests, reserved, maxConnections);
|
||||||
|
|
||||||
SharedHandle<ConsoleDownloadEngine> e(DownloadEngineFactory::newConsoleEngine(op, requests, reserved));
|
SharedHandle<ConsoleDownloadEngine> e(DownloadEngineFactory::newConsoleEngine(op, requests, reserved));
|
||||||
e->segmentMan->filename = hr.filename;
|
e->segmentMan->filename = hr.filename;
|
||||||
e->segmentMan->totalSize = hr.totalLength;
|
e->segmentMan->totalSize = hr.totalLength;
|
||||||
e->segmentMan->downloadStarted = true;
|
e->segmentMan->downloadStarted = true;
|
||||||
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
e->segmentMan->digestAlgo = digestAlgo;
|
e->segmentMan->digestAlgo = digestAlgo;
|
||||||
e->segmentMan->chunkHashLength = chunkChecksumLength;
|
e->segmentMan->chunkHashLength = chunkChecksumLength;
|
||||||
e->segmentMan->pieceHashes = chunkChecksums;
|
e->segmentMan->pieceHashes = chunkChecksums;
|
||||||
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
|
|
||||||
if(e->segmentMan->segmentFileExists()) {
|
if(e->segmentMan->segmentFileExists()) {
|
||||||
e->segmentMan->load();
|
e->segmentMan->load();
|
||||||
e->segmentMan->diskWriter->openExistingFile(e->segmentMan->getFilePath());
|
e->segmentMan->diskWriter->openExistingFile(e->segmentMan->getFilePath());
|
||||||
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
if(e->option->get(PREF_CHECK_INTEGRITY) == V_TRUE) {
|
if(e->option->get(PREF_CHECK_INTEGRITY) == V_TRUE) {
|
||||||
e->segmentMan->checkIntegrity();
|
e->segmentMan->checkIntegrity();
|
||||||
}
|
}
|
||||||
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
} else {
|
} else {
|
||||||
if(e->segmentMan->shouldCancelDownloadForSafety()) {
|
if(e->segmentMan->shouldCancelDownloadForSafety()) {
|
||||||
throw new FatalException(EX_FILE_ALREADY_EXISTS,
|
throw new FatalException(EX_FILE_ALREADY_EXISTS,
|
||||||
|
@ -190,8 +198,10 @@ RequestInfos UrlRequestInfo::execute() {
|
||||||
e->segmentMan->totalSize);
|
e->segmentMan->totalSize);
|
||||||
if(e->segmentMan->fileExists() && e->option->get(PREF_CHECK_INTEGRITY) == V_TRUE) {
|
if(e->segmentMan->fileExists() && e->option->get(PREF_CHECK_INTEGRITY) == V_TRUE) {
|
||||||
e->segmentMan->diskWriter->openExistingFile(e->segmentMan->getFilePath());
|
e->segmentMan->diskWriter->openExistingFile(e->segmentMan->getFilePath());
|
||||||
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
e->segmentMan->markAllPiecesDone();
|
e->segmentMan->markAllPiecesDone();
|
||||||
e->segmentMan->checkIntegrity();
|
e->segmentMan->checkIntegrity();
|
||||||
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
} else {
|
} else {
|
||||||
e->segmentMan->diskWriter->initAndOpenFile(e->segmentMan->getFilePath(),
|
e->segmentMan->diskWriter->initAndOpenFile(e->segmentMan->getFilePath(),
|
||||||
e->segmentMan->totalSize);
|
e->segmentMan->totalSize);
|
||||||
|
|
|
@ -50,9 +50,13 @@ class UrlRequestInfo : public RequestInfo {
|
||||||
private:
|
private:
|
||||||
Strings urls;
|
Strings urls;
|
||||||
int maxConnections;
|
int maxConnections;
|
||||||
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
MessageDigestContext::DigestAlgo digestAlgo;
|
MessageDigestContext::DigestAlgo digestAlgo;
|
||||||
int32_t chunkChecksumLength;
|
int32_t chunkChecksumLength;
|
||||||
Strings chunkChecksums;
|
Strings chunkChecksums;
|
||||||
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
|
string filename;
|
||||||
|
int64_t totalLength;
|
||||||
|
|
||||||
RequestInfo* createNextRequestInfo() const;
|
RequestInfo* createNextRequestInfo() const;
|
||||||
void adjustRequestSize(Requests& requests,
|
void adjustRequestSize(Requests& requests,
|
||||||
|
@ -65,24 +69,41 @@ public:
|
||||||
RequestInfo(op),
|
RequestInfo(op),
|
||||||
urls(urls),
|
urls(urls),
|
||||||
maxConnections(maxConnections),
|
maxConnections(maxConnections),
|
||||||
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
digestAlgo(DIGEST_ALGO_SHA1),
|
digestAlgo(DIGEST_ALGO_SHA1),
|
||||||
chunkChecksumLength(0) {}
|
chunkChecksumLength(0),
|
||||||
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
|
totalLength(0) {}
|
||||||
|
|
||||||
virtual ~UrlRequestInfo() {}
|
virtual ~UrlRequestInfo() {}
|
||||||
|
|
||||||
virtual RequestInfos execute();
|
virtual RequestInfos execute();
|
||||||
|
|
||||||
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
void setDigestAlgo(const MessageDigestContext::DigestAlgo& algo) {
|
void setDigestAlgo(const MessageDigestContext::DigestAlgo& algo) {
|
||||||
this->digestAlgo = algo;
|
this->digestAlgo = algo;
|
||||||
}
|
}
|
||||||
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
|
|
||||||
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
void setChunkChecksumLength(int32_t chunkChecksumLength) {
|
void setChunkChecksumLength(int32_t chunkChecksumLength) {
|
||||||
this->chunkChecksumLength = chunkChecksumLength;
|
this->chunkChecksumLength = chunkChecksumLength;
|
||||||
}
|
}
|
||||||
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
|
|
||||||
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
void setChunkChecksums(const Strings& chunkChecksums) {
|
void setChunkChecksums(const Strings& chunkChecksums) {
|
||||||
this->chunkChecksums = chunkChecksums;
|
this->chunkChecksums = chunkChecksums;
|
||||||
}
|
}
|
||||||
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
|
|
||||||
|
void setTotalLength(int64_t totalLength) {
|
||||||
|
this->totalLength = totalLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setFilename(const string& filename) {
|
||||||
|
this->filename = filename;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef SharedHandle<UrlRequestInfo> UrlRequestInfoHandle;
|
typedef SharedHandle<UrlRequestInfo> UrlRequestInfoHandle;
|
||||||
|
|
|
@ -99,7 +99,12 @@ MetalinkEntryHandle Xml2MetalinkProcessor::getEntry(const string& xpath) {
|
||||||
MetalinkEntryHandle entry(new MetalinkEntry());
|
MetalinkEntryHandle entry(new MetalinkEntry());
|
||||||
|
|
||||||
entry->filename = filename;
|
entry->filename = filename;
|
||||||
entry->size = STRTOLL(xpathContent(xpath+"/m:size").c_str());
|
string sizeStr = Util::trim(xpathContent(xpath+"/m:size"));
|
||||||
|
if(sizeStr == "") {
|
||||||
|
entry->size = 0;
|
||||||
|
} else {
|
||||||
|
entry->size = STRTOLL(sizeStr.c_str());
|
||||||
|
}
|
||||||
entry->version = Util::trim(xpathContent(xpath+"/m:version"));
|
entry->version = Util::trim(xpathContent(xpath+"/m:version"));
|
||||||
entry->language = Util::trim(xpathContent(xpath+"/m:language"));
|
entry->language = Util::trim(xpathContent(xpath+"/m:language"));
|
||||||
entry->os = Util::trim(xpathContent(xpath+"/m:os"));
|
entry->os = Util::trim(xpathContent(xpath+"/m:os"));
|
||||||
|
@ -116,8 +121,14 @@ MetalinkEntryHandle Xml2MetalinkProcessor::getEntry(const string& xpath) {
|
||||||
entry->checksum.setDigestAlgo(DIGEST_ALGO_MD5);
|
entry->checksum.setDigestAlgo(DIGEST_ALGO_MD5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
entry->chunkChecksum = getPieceHash(xpath+"/m:verification/m:pieces[@type=\"sha1\"]", entry->size);
|
string piecesPath = xpath+"/m:verification/m:pieces";
|
||||||
|
string sha1PiecesPath = piecesPath+"[@type=\"sha1\"]";
|
||||||
|
string md5PiecesPath = piecesPath+"[@type=\"md5\"]";
|
||||||
|
if(xpathExists(sha1PiecesPath)) {
|
||||||
|
entry->chunkChecksum = getPieceHash(sha1PiecesPath, entry->size);
|
||||||
|
} else if(xpathExists(md5PiecesPath)) {
|
||||||
|
entry->chunkChecksum = getPieceHash(md5PiecesPath, entry->size);
|
||||||
|
}
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
for(int index = 1; 1; index++) {
|
for(int index = 1; 1; index++) {
|
||||||
MetalinkResourceHandle resource(getResource(xpath+"/m:resources/m:url["+Util::itos(index)+"]"));
|
MetalinkResourceHandle resource(getResource(xpath+"/m:resources/m:url["+Util::itos(index)+"]"));
|
||||||
|
@ -130,11 +141,11 @@ MetalinkEntryHandle Xml2MetalinkProcessor::getEntry(const string& xpath) {
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
MetalinkChunkChecksumHandle Xml2MetalinkProcessor::getPieceHash(const string& xpath,
|
MetalinkChunkChecksumHandle Xml2MetalinkProcessor::getPieceHash(const string& xpath,
|
||||||
int64_t totalSize)
|
int64_t totalSize)
|
||||||
{
|
{
|
||||||
MetalinkChunkChecksumHandle chunkChecksum = new MetalinkChunkChecksum();
|
MetalinkChunkChecksumHandle chunkChecksum = new MetalinkChunkChecksum();
|
||||||
chunkChecksum->digestAlgo = DIGEST_ALGO_SHA1;
|
|
||||||
|
|
||||||
xmlXPathObjectPtr result = xpathEvaluation(xpath);
|
xmlXPathObjectPtr result = xpathEvaluation(xpath);
|
||||||
if(!result) {
|
if(!result) {
|
||||||
|
@ -143,7 +154,17 @@ MetalinkChunkChecksumHandle Xml2MetalinkProcessor::getPieceHash(const string& xp
|
||||||
xmlNodeSetPtr nodeSet = result->nodesetval;
|
xmlNodeSetPtr nodeSet = result->nodesetval;
|
||||||
xmlNodePtr node = nodeSet->nodeTab[0];
|
xmlNodePtr node = nodeSet->nodeTab[0];
|
||||||
chunkChecksum->pieceLength = STRTOLL(Util::trim(xmlAttribute(node, "length")).c_str());
|
chunkChecksum->pieceLength = STRTOLL(Util::trim(xmlAttribute(node, "length")).c_str());
|
||||||
|
string algo = Util::trim(xmlAttribute(node, "type"));
|
||||||
xmlXPathFreeObject(result);
|
xmlXPathFreeObject(result);
|
||||||
|
if(algo == "sha1") {
|
||||||
|
chunkChecksum->digestAlgo = DIGEST_ALGO_SHA1;
|
||||||
|
} else if(algo == "md5") {
|
||||||
|
chunkChecksum->digestAlgo = DIGEST_ALGO_MD5;
|
||||||
|
} else {
|
||||||
|
// unknown checksum type
|
||||||
|
chunkChecksum->pieceLength = 0;
|
||||||
|
return chunkChecksum;
|
||||||
|
}
|
||||||
|
|
||||||
int64_t numPiece =
|
int64_t numPiece =
|
||||||
(totalSize+chunkChecksum->pieceLength-1)/chunkChecksum->pieceLength;
|
(totalSize+chunkChecksum->pieceLength-1)/chunkChecksum->pieceLength;
|
||||||
|
@ -156,6 +177,7 @@ MetalinkChunkChecksumHandle Xml2MetalinkProcessor::getPieceHash(const string& xp
|
||||||
}
|
}
|
||||||
return chunkChecksum;
|
return chunkChecksum;
|
||||||
}
|
}
|
||||||
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
|
|
||||||
MetalinkResourceHandle Xml2MetalinkProcessor::getResource(const string& xpath) {
|
MetalinkResourceHandle Xml2MetalinkProcessor::getResource(const string& xpath) {
|
||||||
xmlXPathObjectPtr result = xpathEvaluation(xpath);
|
xmlXPathObjectPtr result = xpathEvaluation(xpath);
|
||||||
|
@ -240,3 +262,13 @@ string Xml2MetalinkProcessor::xpathContent(const string& xpath) {
|
||||||
xmlXPathFreeObject(result);
|
xmlXPathFreeObject(result);
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Xml2MetalinkProcessor::xpathExists(const string& xpath) {
|
||||||
|
xmlXPathObjectPtr result = xpathEvaluation(xpath);
|
||||||
|
bool retval = true;
|
||||||
|
if(!result) {
|
||||||
|
retval = false;
|
||||||
|
}
|
||||||
|
xmlXPathFreeObject(result);
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
|
@ -46,13 +46,17 @@ private:
|
||||||
|
|
||||||
MetalinkEntryHandle getEntry(const string& xpath);
|
MetalinkEntryHandle getEntry(const string& xpath);
|
||||||
MetalinkResourceHandle getResource(const string& xpath);
|
MetalinkResourceHandle getResource(const string& xpath);
|
||||||
|
|
||||||
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
MetalinkChunkChecksumHandle getPieceHash(const string& xpath,
|
MetalinkChunkChecksumHandle getPieceHash(const string& xpath,
|
||||||
int64_t totalSize);
|
int64_t totalSize);
|
||||||
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
|
|
||||||
xmlXPathObjectPtr xpathEvaluation(const string& xpath);
|
xmlXPathObjectPtr xpathEvaluation(const string& xpath);
|
||||||
string xpathContent(const string& xpath);
|
string xpathContent(const string& xpath);
|
||||||
string xmlAttribute(xmlNodePtr node, const string& attrName);
|
string xmlAttribute(xmlNodePtr node, const string& attrName);
|
||||||
string xmlContent(xmlNodePtr node);
|
string xmlContent(xmlNodePtr node);
|
||||||
|
bool xpathExists(const string& xpath);
|
||||||
|
|
||||||
void release();
|
void release();
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -52,11 +52,6 @@
|
||||||
# define _(String) (String)
|
# define _(String) (String)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef LONG_LONG_MAX
|
|
||||||
# define LONG_LONG_MAX 9223372036854775807LL
|
|
||||||
# define LONG_LONG_MIN (-LONG_LONG_MAX - 1LL)
|
|
||||||
#endif // LONG_LONG_MAX
|
|
||||||
|
|
||||||
#define USER_AGENT "aria2"
|
#define USER_AGENT "aria2"
|
||||||
|
|
||||||
#define BITFIELD_LEN_FROM_PIECES(X) ((X)/8+((X)%8? 1 : 0))
|
#define BITFIELD_LEN_FROM_PIECES(X) ((X)/8+((X)%8? 1 : 0))
|
||||||
|
|
98
src/main.cc
98
src/main.cc
|
@ -175,13 +175,24 @@ void showUsage() {
|
||||||
" pre-allocates file space before download begins.\n"
|
" pre-allocates file space before download begins.\n"
|
||||||
" This may take some time depending on the size of\n"
|
" This may take some time depending on the size of\n"
|
||||||
" file.\n"
|
" file.\n"
|
||||||
" Default: 'none'") << endl;
|
" Default: none") << endl;
|
||||||
cout << _(" --force-truncate=true|false If this option set to false, aria2 doesn't download\n"
|
cout << _(" --allow-overwrite=true|false If this option set to false, aria2 doesn't\n"
|
||||||
" file which already exists in file system but\n"
|
" download a file which already exists in the file\n"
|
||||||
" its corresponding .aria2 file doesn't exist.\n"
|
" system but its corresponding .aria2 file doesn't\n"
|
||||||
" Set this option to true if you want to download\n"
|
" exist.\n"
|
||||||
" file all over again.\n"
|
|
||||||
" Default: false") << endl;
|
" Default: false") << endl;
|
||||||
|
cout << _(" --check-integiry=true|false Check file integiry by validating piece hash.\n"
|
||||||
|
" This option makes effect in BitTorrent download\n"
|
||||||
|
" and Metalink with chunk checksums.\n"
|
||||||
|
" Use this option to redownload a damaged portion of\n"
|
||||||
|
" file.\n"
|
||||||
|
" You may need to specify --allow-overwrite=true\n"
|
||||||
|
" option if .aria2 file doesn't exist.\n"
|
||||||
|
" Default: false") << endl;
|
||||||
|
cout << _(" --realtime-chunk-checksum=true|false Validate chunk checksum while downloading\n"
|
||||||
|
" a file in Metalink mode. This option makes effect\n"
|
||||||
|
" in Metalink with chunk checksums.\n"
|
||||||
|
" Default: true") << endl;
|
||||||
#ifdef ENABLE_BITTORRENT
|
#ifdef ENABLE_BITTORRENT
|
||||||
cout << _(" -T, --torrent-file=TORRENT_FILE The file path to .torrent file.") << endl;
|
cout << _(" -T, --torrent-file=TORRENT_FILE The file path to .torrent file.") << endl;
|
||||||
cout << _(" --follow-torrent=true|false Setting this option to false prevents aria2 to\n"
|
cout << _(" --follow-torrent=true|false Setting this option to false prevents aria2 to\n"
|
||||||
|
@ -343,9 +354,9 @@ int main(int argc, char* argv[]) {
|
||||||
op->put(PREF_STARTUP_IDLE_TIME, "10");
|
op->put(PREF_STARTUP_IDLE_TIME, "10");
|
||||||
op->put(PREF_TRACKER_MAX_TRIES, "10");
|
op->put(PREF_TRACKER_MAX_TRIES, "10");
|
||||||
op->put(PREF_FILE_ALLOCATION, V_NONE);
|
op->put(PREF_FILE_ALLOCATION, V_NONE);
|
||||||
op->put(PREF_FORCE_TRUNCATE, V_FALSE);
|
op->put(PREF_ALLOW_OVERWRITE, V_FALSE);
|
||||||
op->put(PREF_REALTIME_CHUNK_CHECKSUM, V_TRUE);
|
op->put(PREF_REALTIME_CHUNK_CHECKSUM, V_TRUE);
|
||||||
op->put(PREF_CHECK_INTEGRITY, V_TRUE);
|
op->put(PREF_CHECK_INTEGRITY, V_FALSE);
|
||||||
while(1) {
|
while(1) {
|
||||||
int optIndex = 0;
|
int optIndex = 0;
|
||||||
int lopt;
|
int lopt;
|
||||||
|
@ -375,7 +386,9 @@ int main(int argc, char* argv[]) {
|
||||||
{ "lowest-speed-limit", required_argument, &lopt, 200 },
|
{ "lowest-speed-limit", required_argument, &lopt, 200 },
|
||||||
{ "max-download-limit", required_argument, &lopt, 201 },
|
{ "max-download-limit", required_argument, &lopt, 201 },
|
||||||
{ "file-allocation", required_argument, 0, 'a' },
|
{ "file-allocation", required_argument, 0, 'a' },
|
||||||
{ "force-truncate", required_argument, &lopt, 202 },
|
{ "allow-overwrite", required_argument, &lopt, 202 },
|
||||||
|
{ "check-integrity", required_argument, &lopt, 203 },
|
||||||
|
{" realtime-chunk-checksum", required_argument, &lopt, 204 },
|
||||||
#ifdef ENABLE_BITTORRENT
|
#ifdef ENABLE_BITTORRENT
|
||||||
{ "torrent-file", required_argument, NULL, 'T' },
|
{ "torrent-file", required_argument, NULL, 'T' },
|
||||||
{ "listen-port", required_argument, &lopt, 15 },
|
{ "listen-port", required_argument, &lopt, 15 },
|
||||||
|
@ -384,7 +397,7 @@ int main(int argc, char* argv[]) {
|
||||||
{ "no-preallocation", no_argument, &lopt, 18 },
|
{ "no-preallocation", no_argument, &lopt, 18 },
|
||||||
{ "direct-file-mapping", required_argument, &lopt, 19 },
|
{ "direct-file-mapping", required_argument, &lopt, 19 },
|
||||||
// TODO remove upload-limit.
|
// TODO remove upload-limit.
|
||||||
{ "upload-limit", required_argument, &lopt, 20 },
|
//{ "upload-limit", required_argument, &lopt, 20 },
|
||||||
{ "select-file", required_argument, &lopt, 21 },
|
{ "select-file", required_argument, &lopt, 21 },
|
||||||
{ "seed-time", required_argument, &lopt, 22 },
|
{ "seed-time", required_argument, &lopt, 22 },
|
||||||
{ "seed-ratio", required_argument, &lopt, 23 },
|
{ "seed-ratio", required_argument, &lopt, 23 },
|
||||||
|
@ -417,7 +430,6 @@ int main(int argc, char* argv[]) {
|
||||||
if(proxy.first.empty() || proxy.second.empty() ||
|
if(proxy.first.empty() || proxy.second.empty() ||
|
||||||
!(0 < port && port <= 65535)) {
|
!(0 < port && port <= 65535)) {
|
||||||
cerr << _("unrecognized proxy format") << endl;
|
cerr << _("unrecognized proxy format") << endl;
|
||||||
showUsage();
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
op->put(PREF_HTTP_PROXY_HOST, proxy.first);
|
op->put(PREF_HTTP_PROXY_HOST, proxy.first);
|
||||||
|
@ -453,7 +465,6 @@ int main(int argc, char* argv[]) {
|
||||||
int wait = (int)strtol(optarg, NULL, 10);
|
int wait = (int)strtol(optarg, NULL, 10);
|
||||||
if(!(0 <= wait && wait <= 60)) {
|
if(!(0 <= wait && wait <= 60)) {
|
||||||
cerr << _("retry-wait must be between 0 and 60.") << endl;
|
cerr << _("retry-wait must be between 0 and 60.") << endl;
|
||||||
showUsage();
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
op->put(PREF_RETRY_WAIT, Util::itos(wait));
|
op->put(PREF_RETRY_WAIT, Util::itos(wait));
|
||||||
|
@ -470,7 +481,6 @@ int main(int argc, char* argv[]) {
|
||||||
op->put(PREF_FTP_TYPE, optarg);
|
op->put(PREF_FTP_TYPE, optarg);
|
||||||
} else {
|
} else {
|
||||||
cerr << _("ftp-type must be either 'binary' or 'ascii'.") << endl;
|
cerr << _("ftp-type must be either 'binary' or 'ascii'.") << endl;
|
||||||
showUsage();
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -479,7 +489,6 @@ int main(int argc, char* argv[]) {
|
||||||
op->put(PREF_FTP_VIA_HTTP_PROXY, optarg);
|
op->put(PREF_FTP_VIA_HTTP_PROXY, optarg);
|
||||||
} else {
|
} else {
|
||||||
cerr << _("ftp-via-http-proxy must be either 'get' or 'tunnel'.") << endl;
|
cerr << _("ftp-via-http-proxy must be either 'get' or 'tunnel'.") << endl;
|
||||||
showUsage();
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -487,7 +496,6 @@ int main(int argc, char* argv[]) {
|
||||||
long long int size = getRealSize(optarg);
|
long long int size = getRealSize(optarg);
|
||||||
if(size < 1024) {
|
if(size < 1024) {
|
||||||
cerr << _("min-segment-size invalid") << endl;
|
cerr << _("min-segment-size invalid") << endl;
|
||||||
showUsage();
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
op->put(PREF_MIN_SEGMENT_SIZE, Util::llitos(size));
|
op->put(PREF_MIN_SEGMENT_SIZE, Util::llitos(size));
|
||||||
|
@ -498,7 +506,6 @@ int main(int argc, char* argv[]) {
|
||||||
op->put(PREF_HTTP_PROXY_METHOD, optarg);
|
op->put(PREF_HTTP_PROXY_METHOD, optarg);
|
||||||
} else {
|
} else {
|
||||||
cerr << _("http-proxy-method must be either 'get' or 'tunnel'.") << endl;
|
cerr << _("http-proxy-method must be either 'get' or 'tunnel'.") << endl;
|
||||||
showUsage();
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -506,7 +513,6 @@ int main(int argc, char* argv[]) {
|
||||||
int listenPort = (int)strtol(optarg, NULL, 10);
|
int listenPort = (int)strtol(optarg, NULL, 10);
|
||||||
if(!(1024 <= listenPort && listenPort <= 65535)) {
|
if(!(1024 <= listenPort && listenPort <= 65535)) {
|
||||||
cerr << _("listen-port must be between 1024 and 65535.") << endl;
|
cerr << _("listen-port must be between 1024 and 65535.") << endl;
|
||||||
showUsage();
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
op->put(PREF_LISTEN_PORT, Util::itos(listenPort));
|
op->put(PREF_LISTEN_PORT, Util::itos(listenPort));
|
||||||
|
@ -519,7 +525,6 @@ int main(int argc, char* argv[]) {
|
||||||
op->put(PREF_FOLLOW_TORRENT, V_FALSE);
|
op->put(PREF_FOLLOW_TORRENT, V_FALSE);
|
||||||
} else {
|
} else {
|
||||||
cerr << _("follow-torrent must be either 'true' or 'false'.") << endl;
|
cerr << _("follow-torrent must be either 'true' or 'false'.") << endl;
|
||||||
showUsage();
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -533,23 +538,9 @@ int main(int argc, char* argv[]) {
|
||||||
op->put(PREF_DIRECT_FILE_MAPPING, V_FALSE);
|
op->put(PREF_DIRECT_FILE_MAPPING, V_FALSE);
|
||||||
} else {
|
} else {
|
||||||
cerr << _("direct-file-mapping must be either 'true' or 'false'.") << endl;
|
cerr << _("direct-file-mapping must be either 'true' or 'false'.") << endl;
|
||||||
showUsage();
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 20: {
|
|
||||||
cerr << "Warning: upload-limit will be deprecated in the future release.\n"
|
|
||||||
"Use max-upload-limit instead. Because there is a difference between them,\n"
|
|
||||||
"take a look at the description of max-upload-limit option." << endl;
|
|
||||||
int uploadSpeed = strtol(optarg, NULL, 10)*1024;
|
|
||||||
if(0 > uploadSpeed) {
|
|
||||||
cerr << _("upload-limit must be greater than or equal to 0.") << endl;
|
|
||||||
showUsage();
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
op->put(PREF_MAX_UPLOAD_LIMIT, Util::itos(uploadSpeed));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 21:
|
case 21:
|
||||||
op->put(PREF_SELECT_FILE, optarg);
|
op->put(PREF_SELECT_FILE, optarg);
|
||||||
break;
|
break;
|
||||||
|
@ -557,7 +548,6 @@ int main(int argc, char* argv[]) {
|
||||||
int seedTime = (int)strtol(optarg, NULL, 10);
|
int seedTime = (int)strtol(optarg, NULL, 10);
|
||||||
if(seedTime < 0) {
|
if(seedTime < 0) {
|
||||||
cerr << _("seed-time must be greater than or equal to 0.") << endl;
|
cerr << _("seed-time must be greater than or equal to 0.") << endl;
|
||||||
showUsage();
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
op->put(PREF_SEED_TIME, Util::itos(seedTime));
|
op->put(PREF_SEED_TIME, Util::itos(seedTime));
|
||||||
|
@ -567,7 +557,6 @@ int main(int argc, char* argv[]) {
|
||||||
double ratio = (int)strtod(optarg, NULL);
|
double ratio = (int)strtod(optarg, NULL);
|
||||||
if(ratio < 0.0) {
|
if(ratio < 0.0) {
|
||||||
cerr << _("seed-ratio must be greater than or equal to 0.0.") << endl;
|
cerr << _("seed-ratio must be greater than or equal to 0.0.") << endl;
|
||||||
showUsage();
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
op->put(PREF_SEED_RATIO, optarg);
|
op->put(PREF_SEED_RATIO, optarg);
|
||||||
|
@ -577,7 +566,6 @@ int main(int argc, char* argv[]) {
|
||||||
int limit = getRealSize(optarg);
|
int limit = getRealSize(optarg);
|
||||||
if(limit < 0) {
|
if(limit < 0) {
|
||||||
cerr << _("max-upload-limit must be greater than or equal to 0") << endl;
|
cerr << _("max-upload-limit must be greater than or equal to 0") << endl;
|
||||||
showUsage();
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
op->put(PREF_MAX_UPLOAD_LIMIT, Util::itos(limit));
|
op->put(PREF_MAX_UPLOAD_LIMIT, Util::itos(limit));
|
||||||
|
@ -599,7 +587,6 @@ int main(int argc, char* argv[]) {
|
||||||
op->put(PREF_FOLLOW_METALINK, V_FALSE);
|
op->put(PREF_FOLLOW_METALINK, V_FALSE);
|
||||||
} else {
|
} else {
|
||||||
cerr << _("follow-metalink must be either 'true' or 'false'.") << endl;
|
cerr << _("follow-metalink must be either 'true' or 'false'.") << endl;
|
||||||
showUsage();
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -610,7 +597,6 @@ int main(int argc, char* argv[]) {
|
||||||
int limit = getRealSize(optarg);
|
int limit = getRealSize(optarg);
|
||||||
if(limit < 0) {
|
if(limit < 0) {
|
||||||
cerr << _("lowest-speed-limit must be greater than or equal to 0") << endl;
|
cerr << _("lowest-speed-limit must be greater than or equal to 0") << endl;
|
||||||
showUsage();
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
op->put(PREF_LOWEST_SPEED_LIMIT, Util::itos(limit));
|
op->put(PREF_LOWEST_SPEED_LIMIT, Util::itos(limit));
|
||||||
|
@ -620,7 +606,6 @@ int main(int argc, char* argv[]) {
|
||||||
int limit = getRealSize(optarg);
|
int limit = getRealSize(optarg);
|
||||||
if(limit < 0) {
|
if(limit < 0) {
|
||||||
cerr << _("max-download-limit must be greater than or equal to 0") << endl;
|
cerr << _("max-download-limit must be greater than or equal to 0") << endl;
|
||||||
showUsage();
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
op->put(PREF_MAX_DOWNLOAD_LIMIT, Util::itos(limit));
|
op->put(PREF_MAX_DOWNLOAD_LIMIT, Util::itos(limit));
|
||||||
|
@ -628,14 +613,36 @@ int main(int argc, char* argv[]) {
|
||||||
}
|
}
|
||||||
case 202: {
|
case 202: {
|
||||||
if(string(optarg) == "true") {
|
if(string(optarg) == "true") {
|
||||||
op->put(PREF_FORCE_TRUNCATE, V_TRUE);
|
op->put(PREF_ALLOW_OVERWRITE, V_TRUE);
|
||||||
} else if(string(optarg) == "false") {
|
} else if(string(optarg) == "false") {
|
||||||
op->put(PREF_FORCE_TRUNCATE, V_FALSE);
|
op->put(PREF_ALLOW_OVERWRITE, V_FALSE);
|
||||||
} else {
|
} else {
|
||||||
cerr << _("force-true must be either 'true' or 'false'.") << endl;
|
cerr << _("allow-overwrite must be either 'true' or 'false'.") << endl;
|
||||||
showUsage();
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 203: {
|
||||||
|
if(string(optarg) == "true") {
|
||||||
|
op->put(PREF_CHECK_INTEGRITY, V_TRUE);
|
||||||
|
} else if(string(optarg) == "false") {
|
||||||
|
op->put(PREF_CHECK_INTEGRITY, V_FALSE);
|
||||||
|
} else {
|
||||||
|
cerr << _("check-integrity must be be either 'true' or 'false'.") << endl;
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 204: {
|
||||||
|
if(string(optarg) == "true") {
|
||||||
|
op->put(PREF_REALTIME_CHUNK_CHECKSUM, V_TRUE);
|
||||||
|
} else if(string(optarg) == "false") {
|
||||||
|
op->put(PREF_REALTIME_CHUNK_CHECKSUM, V_FALSE);
|
||||||
|
} else {
|
||||||
|
cerr << _("realtime-chunk-checksum must be either 'true' or 'false'.") << endl;
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -660,7 +667,6 @@ int main(int argc, char* argv[]) {
|
||||||
int split = (int)strtol(optarg, NULL, 10);
|
int split = (int)strtol(optarg, NULL, 10);
|
||||||
if(!(1 <= split && split <= 5)) {
|
if(!(1 <= split && split <= 5)) {
|
||||||
cerr << _("split must be between 1 and 5.") << endl;
|
cerr << _("split must be between 1 and 5.") << endl;
|
||||||
showUsage();
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
op->put(PREF_SPLIT, Util::itos(split));
|
op->put(PREF_SPLIT, Util::itos(split));
|
||||||
|
@ -672,7 +678,6 @@ int main(int argc, char* argv[]) {
|
||||||
op->put(PREF_TIMEOUT, Util::itos(timeout));
|
op->put(PREF_TIMEOUT, Util::itos(timeout));
|
||||||
} else {
|
} else {
|
||||||
cerr << _("timeout must be between 1 and 600") << endl;
|
cerr << _("timeout must be between 1 and 600") << endl;
|
||||||
showUsage();
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -681,7 +686,6 @@ int main(int argc, char* argv[]) {
|
||||||
int retries = (int)strtol(optarg, NULL, 10);
|
int retries = (int)strtol(optarg, NULL, 10);
|
||||||
if(retries < 0) {
|
if(retries < 0) {
|
||||||
cerr << _("max-tries invalid") << endl;
|
cerr << _("max-tries invalid") << endl;
|
||||||
showUsage();
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
op->put(PREF_MAX_TRIES, Util::itos(retries));
|
op->put(PREF_MAX_TRIES, Util::itos(retries));
|
||||||
|
@ -703,7 +707,6 @@ int main(int argc, char* argv[]) {
|
||||||
int metalinkServers = (int)strtol(optarg, NULL, 10);
|
int metalinkServers = (int)strtol(optarg, NULL, 10);
|
||||||
if(metalinkServers <= 0) {
|
if(metalinkServers <= 0) {
|
||||||
cerr << _("metalink-servers must be greater than 0.") << endl;
|
cerr << _("metalink-servers must be greater than 0.") << endl;
|
||||||
showUsage();
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
op->put(PREF_METALINK_SERVERS, Util::itos(metalinkServers));
|
op->put(PREF_METALINK_SERVERS, Util::itos(metalinkServers));
|
||||||
|
@ -715,7 +718,6 @@ int main(int argc, char* argv[]) {
|
||||||
op->put(PREF_FILE_ALLOCATION, value);
|
op->put(PREF_FILE_ALLOCATION, value);
|
||||||
} else {
|
} else {
|
||||||
cerr << _("file-allocation must be either 'none' or 'prealloc'.") << endl;
|
cerr << _("file-allocation must be either 'none' or 'prealloc'.") << endl;
|
||||||
showUsage();
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -727,14 +729,12 @@ int main(int argc, char* argv[]) {
|
||||||
showUsage();
|
showUsage();
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
default:
|
default:
|
||||||
showUsage();
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!op->defined(PREF_TORRENT_FILE) && !op->defined(PREF_METALINK_FILE)) {
|
if(!op->defined(PREF_TORRENT_FILE) && !op->defined(PREF_METALINK_FILE)) {
|
||||||
if(optind == argc) {
|
if(optind == argc) {
|
||||||
cerr << _("specify at least one URL") << endl;
|
cerr << _("specify at least one URL") << endl;
|
||||||
showUsage();
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,7 +111,7 @@
|
||||||
#define EX_SOCKET_SEND _("Failed to send data, cause: %s")
|
#define EX_SOCKET_SEND _("Failed to send data, cause: %s")
|
||||||
#define EX_SOCKET_RECV _("Failed to receive data, cause: %s")
|
#define EX_SOCKET_RECV _("Failed to receive data, cause: %s")
|
||||||
#define EX_SOCKET_PEEK _("Failed to peek data, cause: %s")
|
#define EX_SOCKET_PEEK _("Failed to peek data, cause: %s")
|
||||||
#define EX_FILE_ALREADY_EXISTS _("File %s exists, but %s does not exist. The download was canceled in order to prevent your file from being truncated to 0. If you are sure to download file all over again, then delete it or add --force-truncate=true option and restart aria2.")
|
#define EX_FILE_ALREADY_EXISTS _("File %s exists, but %s does not exist. The download was canceled in order to prevent your file from being truncated to 0. If you are sure to download file all over again, then delete it or add --allow-overwrite=true option and restart aria2.")
|
||||||
#define EX_INVALID_PAYLOAD_SIZE _("Invalid payload size for %s, size=%d. It should be %d.")
|
#define EX_INVALID_PAYLOAD_SIZE _("Invalid payload size for %s, size=%d. It should be %d.")
|
||||||
#define EX_INVALID_BT_MESSAGE_ID _("Invalid ID=%d for %s. It should be %d.")
|
#define EX_INVALID_BT_MESSAGE_ID _("Invalid ID=%d for %s. It should be %d.")
|
||||||
#define EX_INVALID_CHUNK_CHECKSUM _("Chunk checksum validation failed. checksumIndex=%d, offset=%lld, length=%d, expectedHash=%s, actualHash=%s")
|
#define EX_INVALID_CHUNK_CHECKSUM _("Chunk checksum validation failed. checksumIndex=%d, offset=%lld, length=%d, expectedHash=%s, actualHash=%s")
|
||||||
|
|
|
@ -85,7 +85,7 @@
|
||||||
#define PREF_FILE_ALLOCATION "file_allocation"
|
#define PREF_FILE_ALLOCATION "file_allocation"
|
||||||
# define V_PREALLOC "prealloc"
|
# define V_PREALLOC "prealloc"
|
||||||
// value: true | false
|
// value: true | false
|
||||||
#define PREF_FORCE_TRUNCATE "force_truncate"
|
#define PREF_ALLOW_OVERWRITE "allow_overwrite"
|
||||||
// value: true | false
|
// value: true | false
|
||||||
#define PREF_REALTIME_CHUNK_CHECKSUM "realtime_chunk_checksum"
|
#define PREF_REALTIME_CHUNK_CHECKSUM "realtime_chunk_checksum"
|
||||||
// value: true | false
|
// value: true | false
|
||||||
|
|
|
@ -42,12 +42,12 @@ CPPUNIT_TEST_SUITE_REGISTRATION( BitfieldManTest );
|
||||||
|
|
||||||
void BitfieldManTest::testGetBlockSize() {
|
void BitfieldManTest::testGetBlockSize() {
|
||||||
BitfieldMan bt1(1024, 1024*10);
|
BitfieldMan bt1(1024, 1024*10);
|
||||||
CPPUNIT_ASSERT_EQUAL((uint32_t)1024, bt1.getBlockLength(9));
|
CPPUNIT_ASSERT_EQUAL(1024, bt1.getBlockLength(9));
|
||||||
|
|
||||||
BitfieldMan bt2(1024, 1024*10+1);
|
BitfieldMan bt2(1024, 1024*10+1);
|
||||||
CPPUNIT_ASSERT_EQUAL((uint32_t)1024, bt2.getBlockLength(9));
|
CPPUNIT_ASSERT_EQUAL(1024, bt2.getBlockLength(9));
|
||||||
CPPUNIT_ASSERT_EQUAL((uint32_t)1, bt2.getBlockLength(10));
|
CPPUNIT_ASSERT_EQUAL(1, bt2.getBlockLength(10));
|
||||||
CPPUNIT_ASSERT_EQUAL((uint32_t)0, bt2.getBlockLength(11));
|
CPPUNIT_ASSERT_EQUAL(0, bt2.getBlockLength(11));
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitfieldManTest::testGetFirstMissingUnusedIndex() {
|
void BitfieldManTest::testGetFirstMissingUnusedIndex() {
|
||||||
|
@ -84,7 +84,7 @@ void BitfieldManTest::testIsAllBitSet() {
|
||||||
}
|
}
|
||||||
CPPUNIT_ASSERT(!bt1.isAllBitSet());
|
CPPUNIT_ASSERT(!bt1.isAllBitSet());
|
||||||
|
|
||||||
for(uint32_t i = 0; i < bt1.countBlock(); i++) {
|
for(int32_t i = 0; i < bt1.countBlock(); i++) {
|
||||||
CPPUNIT_ASSERT(bt1.setBit(i));
|
CPPUNIT_ASSERT(bt1.setBit(i));
|
||||||
}
|
}
|
||||||
CPPUNIT_ASSERT(bt1.isAllBitSet());
|
CPPUNIT_ASSERT(bt1.isAllBitSet());
|
||||||
|
@ -122,7 +122,7 @@ void BitfieldManTest::testFilter() {
|
||||||
index = btman.getMissingUnusedIndex(peerBt, sizeof(peerBt));
|
index = btman.getMissingUnusedIndex(peerBt, sizeof(peerBt));
|
||||||
btman.setUseBit(index);
|
btman.setUseBit(index);
|
||||||
CPPUNIT_ASSERT_EQUAL(-1, index);
|
CPPUNIT_ASSERT_EQUAL(-1, index);
|
||||||
CPPUNIT_ASSERT_EQUAL((uint64_t)12, btman.getFilteredTotalLength());
|
CPPUNIT_ASSERT_EQUAL((int64_t)12, btman.getFilteredTotalLength());
|
||||||
|
|
||||||
// test offset=5, length=2
|
// test offset=5, length=2
|
||||||
btman.clearAllBit();
|
btman.clearAllBit();
|
||||||
|
@ -141,13 +141,13 @@ void BitfieldManTest::testFilter() {
|
||||||
index = btman.getMissingUnusedIndex(peerBt, sizeof(peerBt));
|
index = btman.getMissingUnusedIndex(peerBt, sizeof(peerBt));
|
||||||
btman.setUseBit(index);
|
btman.setUseBit(index);
|
||||||
CPPUNIT_ASSERT_EQUAL(-1, index);
|
CPPUNIT_ASSERT_EQUAL(-1, index);
|
||||||
CPPUNIT_ASSERT_EQUAL((uint64_t)4, btman.getFilteredTotalLength());
|
CPPUNIT_ASSERT_EQUAL((int64_t)4, btman.getFilteredTotalLength());
|
||||||
CPPUNIT_ASSERT(btman.isAllBitSet());
|
CPPUNIT_ASSERT(btman.isFilteredAllBitSet());
|
||||||
|
|
||||||
BitfieldMan btman2(2, 31);
|
BitfieldMan btman2(2, 31);
|
||||||
btman2.addFilter(0, 31);
|
btman2.addFilter(0, 31);
|
||||||
btman2.enableFilter();
|
btman2.enableFilter();
|
||||||
CPPUNIT_ASSERT_EQUAL((uint64_t)31, btman2.getFilteredTotalLength());
|
CPPUNIT_ASSERT_EQUAL((int64_t)31, btman2.getFilteredTotalLength());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ void BtAllowedFastMessageTest::testCreate() {
|
||||||
PeerMessageUtil::createPeerMessageString(msg, sizeof(msg), 5, 17);
|
PeerMessageUtil::createPeerMessageString(msg, sizeof(msg), 5, 17);
|
||||||
PeerMessageUtil::setIntParam(&msg[5], 12345);
|
PeerMessageUtil::setIntParam(&msg[5], 12345);
|
||||||
BtAllowedFastMessageHandle pm = BtAllowedFastMessage::create(&msg[4], 5);
|
BtAllowedFastMessageHandle pm = BtAllowedFastMessage::create(&msg[4], 5);
|
||||||
CPPUNIT_ASSERT_EQUAL((uint8_t)17, pm->getId());
|
CPPUNIT_ASSERT_EQUAL((int8_t)17, pm->getId());
|
||||||
CPPUNIT_ASSERT_EQUAL(12345, pm->getIndex());
|
CPPUNIT_ASSERT_EQUAL(12345, pm->getIndex());
|
||||||
|
|
||||||
// case: payload size is wrong
|
// case: payload size is wrong
|
||||||
|
|
|
@ -35,9 +35,9 @@ void BtBitfieldMessageTest::testCreate() {
|
||||||
memset(bitfield, 0xff, sizeof(bitfield));
|
memset(bitfield, 0xff, sizeof(bitfield));
|
||||||
memcpy(&msg[5], bitfield, sizeof(bitfield));
|
memcpy(&msg[5], bitfield, sizeof(bitfield));
|
||||||
BtBitfieldMessageHandle pm = BtBitfieldMessage::create(&msg[4], 3);
|
BtBitfieldMessageHandle pm = BtBitfieldMessage::create(&msg[4], 3);
|
||||||
CPPUNIT_ASSERT_EQUAL((uint8_t)5, pm->getId());
|
CPPUNIT_ASSERT_EQUAL((int8_t)5, pm->getId());
|
||||||
CPPUNIT_ASSERT(memcmp(bitfield, pm->getBitfield(), sizeof(bitfield)) == 0);
|
CPPUNIT_ASSERT(memcmp(bitfield, pm->getBitfield(), sizeof(bitfield)) == 0);
|
||||||
CPPUNIT_ASSERT_EQUAL((uint32_t)2, pm->getBitfieldLength());
|
CPPUNIT_ASSERT_EQUAL(2, pm->getBitfieldLength());
|
||||||
// case: payload size is wrong
|
// case: payload size is wrong
|
||||||
try {
|
try {
|
||||||
unsigned char msg[5];
|
unsigned char msg[5];
|
||||||
|
|
|
@ -39,13 +39,13 @@ public:
|
||||||
public:
|
public:
|
||||||
int32_t index;
|
int32_t index;
|
||||||
int32_t begin;
|
int32_t begin;
|
||||||
uint32_t length;
|
int32_t length;
|
||||||
public:
|
public:
|
||||||
MockBtMessageDispatcher2():index(0),
|
MockBtMessageDispatcher2():index(0),
|
||||||
begin(0),
|
begin(0),
|
||||||
length(0) {}
|
length(0) {}
|
||||||
|
|
||||||
virtual void doCancelSendingPieceAction(int32_t index, int32_t begin, uint32_t length) {
|
virtual void doCancelSendingPieceAction(int32_t index, int32_t begin, int32_t length) {
|
||||||
this->index = index;
|
this->index = index;
|
||||||
this->begin = begin;
|
this->begin = begin;
|
||||||
this->length = length;
|
this->length = length;
|
||||||
|
@ -65,10 +65,10 @@ void BtCancelMessageTest::testCreate() {
|
||||||
PeerMessageUtil::setIntParam(&msg[9], 256);
|
PeerMessageUtil::setIntParam(&msg[9], 256);
|
||||||
PeerMessageUtil::setIntParam(&msg[13], 1024);
|
PeerMessageUtil::setIntParam(&msg[13], 1024);
|
||||||
BtCancelMessageHandle pm = BtCancelMessage::create(&msg[4], 13);
|
BtCancelMessageHandle pm = BtCancelMessage::create(&msg[4], 13);
|
||||||
CPPUNIT_ASSERT_EQUAL((uint8_t)8, pm->getId());
|
CPPUNIT_ASSERT_EQUAL((int8_t)8, pm->getId());
|
||||||
CPPUNIT_ASSERT_EQUAL(12345, pm->getIndex());
|
CPPUNIT_ASSERT_EQUAL(12345, pm->getIndex());
|
||||||
CPPUNIT_ASSERT_EQUAL(256, pm->getBegin());
|
CPPUNIT_ASSERT_EQUAL(256, pm->getBegin());
|
||||||
CPPUNIT_ASSERT_EQUAL((uint32_t)1024, pm->getLength());
|
CPPUNIT_ASSERT_EQUAL(1024, pm->getLength());
|
||||||
|
|
||||||
// case: payload size is wrong
|
// case: payload size is wrong
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -79,7 +79,7 @@ void BtChokeMessageTest::testCreate() {
|
||||||
unsigned char msg[5];
|
unsigned char msg[5];
|
||||||
PeerMessageUtil::createPeerMessageString(msg, sizeof(msg), 1, 0);
|
PeerMessageUtil::createPeerMessageString(msg, sizeof(msg), 1, 0);
|
||||||
BtChokeMessageHandle pm = BtChokeMessage::create(&msg[4], 1);
|
BtChokeMessageHandle pm = BtChokeMessage::create(&msg[4], 1);
|
||||||
CPPUNIT_ASSERT_EQUAL((uint8_t)0, pm->getId());
|
CPPUNIT_ASSERT_EQUAL((int8_t)0, pm->getId());
|
||||||
|
|
||||||
// case: payload size is wrong
|
// case: payload size is wrong
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -52,8 +52,8 @@ void BtHandshakeMessageTest::testCreate() {
|
||||||
unsigned char msg[68];
|
unsigned char msg[68];
|
||||||
createHandshakeMessageData(msg);
|
createHandshakeMessageData(msg);
|
||||||
BtHandshakeMessageHandle message = BtHandshakeMessage::create(&msg[0], sizeof(msg));
|
BtHandshakeMessageHandle message = BtHandshakeMessage::create(&msg[0], sizeof(msg));
|
||||||
CPPUNIT_ASSERT_EQUAL((uint8_t)UINT8_MAX, message->getId());
|
CPPUNIT_ASSERT_EQUAL((int8_t)INT8_MAX, message->getId());
|
||||||
CPPUNIT_ASSERT_EQUAL((uint8_t)19, message->getPstrlen());
|
CPPUNIT_ASSERT_EQUAL((int8_t)19, message->getPstrlen());
|
||||||
CPPUNIT_ASSERT_EQUAL(Util::toHex((const unsigned char*)BTPSTR.c_str(), BTPSTR.size()),
|
CPPUNIT_ASSERT_EQUAL(Util::toHex((const unsigned char*)BTPSTR.c_str(), BTPSTR.size()),
|
||||||
Util::toHex(message->getPstr(), BtHandshakeMessage::PSTR_LENGTH));
|
Util::toHex(message->getPstr(), BtHandshakeMessage::PSTR_LENGTH));
|
||||||
CPPUNIT_ASSERT_EQUAL(string("0000000000000004"),
|
CPPUNIT_ASSERT_EQUAL(string("0000000000000004"),
|
||||||
|
|
|
@ -29,7 +29,7 @@ void BtHaveAllMessageTest::testCreate() {
|
||||||
unsigned char msg[5];
|
unsigned char msg[5];
|
||||||
PeerMessageUtil::createPeerMessageString(msg, sizeof(msg), 1, 14);
|
PeerMessageUtil::createPeerMessageString(msg, sizeof(msg), 1, 14);
|
||||||
BtHaveAllMessageHandle pm = BtHaveAllMessage::create(&msg[4], 1);
|
BtHaveAllMessageHandle pm = BtHaveAllMessage::create(&msg[4], 1);
|
||||||
CPPUNIT_ASSERT_EQUAL((uint8_t)14, pm->getId());
|
CPPUNIT_ASSERT_EQUAL((int8_t)14, pm->getId());
|
||||||
|
|
||||||
// case: payload size is wrong
|
// case: payload size is wrong
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -32,7 +32,7 @@ void BtHaveMessageTest::testCreate() {
|
||||||
PeerMessageUtil::createPeerMessageString(msg, sizeof(msg), 5, 4);
|
PeerMessageUtil::createPeerMessageString(msg, sizeof(msg), 5, 4);
|
||||||
PeerMessageUtil::setIntParam(&msg[5], 12345);
|
PeerMessageUtil::setIntParam(&msg[5], 12345);
|
||||||
BtHaveMessageHandle pm = BtHaveMessage::create(&msg[4], 5);
|
BtHaveMessageHandle pm = BtHaveMessage::create(&msg[4], 5);
|
||||||
CPPUNIT_ASSERT_EQUAL((uint8_t)4, pm->getId());
|
CPPUNIT_ASSERT_EQUAL((int8_t)4, pm->getId());
|
||||||
CPPUNIT_ASSERT_EQUAL(12345, pm->getIndex());
|
CPPUNIT_ASSERT_EQUAL(12345, pm->getIndex());
|
||||||
|
|
||||||
// case: payload size is wrong
|
// case: payload size is wrong
|
||||||
|
|
|
@ -31,7 +31,7 @@ void BtHaveNoneMessageTest::testCreate() {
|
||||||
unsigned char msg[5];
|
unsigned char msg[5];
|
||||||
PeerMessageUtil::createPeerMessageString(msg, sizeof(msg), 1, 15);
|
PeerMessageUtil::createPeerMessageString(msg, sizeof(msg), 1, 15);
|
||||||
BtHaveNoneMessageHandle pm = BtHaveNoneMessage::create(&msg[4], 1);
|
BtHaveNoneMessageHandle pm = BtHaveNoneMessage::create(&msg[4], 1);
|
||||||
CPPUNIT_ASSERT_EQUAL((uint8_t)15, pm->getId());
|
CPPUNIT_ASSERT_EQUAL((int8_t)15, pm->getId());
|
||||||
|
|
||||||
// case: payload size is wrong
|
// case: payload size is wrong
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -33,7 +33,7 @@ void BtInterestedMessageTest::testCreate() {
|
||||||
unsigned char msg[5];
|
unsigned char msg[5];
|
||||||
PeerMessageUtil::createPeerMessageString(msg, sizeof(msg), 1, 2);
|
PeerMessageUtil::createPeerMessageString(msg, sizeof(msg), 1, 2);
|
||||||
BtInterestedMessageHandle pm = BtInterestedMessage::create(&msg[4], 1);
|
BtInterestedMessageHandle pm = BtInterestedMessage::create(&msg[4], 1);
|
||||||
CPPUNIT_ASSERT_EQUAL((uint8_t)2, pm->getId());
|
CPPUNIT_ASSERT_EQUAL((int8_t)2, pm->getId());
|
||||||
|
|
||||||
// case: payload size is wrong
|
// case: payload size is wrong
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -25,7 +25,8 @@ void BtKeepAliveMessageTest::testGetMessage() {
|
||||||
char msg[4];
|
char msg[4];
|
||||||
memset(msg, 0, sizeof(msg));
|
memset(msg, 0, sizeof(msg));
|
||||||
BtKeepAliveMessage message;
|
BtKeepAliveMessage message;
|
||||||
CPPUNIT_ASSERT_EQUAL((uint32_t)4, message.getMessageLength());
|
CPPUNIT_ASSERT_EQUAL((int8_t)99, message.getId());
|
||||||
|
CPPUNIT_ASSERT_EQUAL(4, message.getMessageLength());
|
||||||
CPPUNIT_ASSERT(memcmp(msg, message.getMessage(), 4) == 0);
|
CPPUNIT_ASSERT(memcmp(msg, message.getMessage(), 4) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ void BtNotInterestedMessageTest::testCreate() {
|
||||||
unsigned char msg[5];
|
unsigned char msg[5];
|
||||||
PeerMessageUtil::createPeerMessageString(msg, sizeof(msg), 1, 3);
|
PeerMessageUtil::createPeerMessageString(msg, sizeof(msg), 1, 3);
|
||||||
BtNotInterestedMessageHandle pm = BtNotInterestedMessage::create(&msg[4], 1);
|
BtNotInterestedMessageHandle pm = BtNotInterestedMessage::create(&msg[4], 1);
|
||||||
CPPUNIT_ASSERT_EQUAL((uint8_t)3, pm->getId());
|
CPPUNIT_ASSERT_EQUAL((int8_t)3, pm->getId());
|
||||||
|
|
||||||
// case: payload size is wrong
|
// case: payload size is wrong
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -48,9 +48,9 @@ public:
|
||||||
public:
|
public:
|
||||||
int32_t index;
|
int32_t index;
|
||||||
int32_t begin;
|
int32_t begin;
|
||||||
uint32_t length;
|
int32_t length;
|
||||||
public:
|
public:
|
||||||
MockBtMessage2(int32_t index, int32_t begin, uint32_t length):index(index), begin(begin), length(length) {}
|
MockBtMessage2(int32_t index, int32_t begin, int32_t length):index(index), begin(begin), length(length) {}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual BtMessageHandle createRejectMessage(int32_t index,
|
virtual BtMessageHandle createRejectMessage(int32_t index,
|
||||||
int32_t begin,
|
int32_t begin,
|
||||||
uint32_t length) {
|
int32_t length) {
|
||||||
MockBtMessage2Handle msg = new MockBtMessage2(index, begin, length);
|
MockBtMessage2Handle msg = new MockBtMessage2(index, begin, length);
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
@ -111,11 +111,11 @@ void BtPieceMessageTest::testCreate() {
|
||||||
PeerMessageUtil::setIntParam(&msg[9], 256);
|
PeerMessageUtil::setIntParam(&msg[9], 256);
|
||||||
memcpy(&msg[13], data, sizeof(data));
|
memcpy(&msg[13], data, sizeof(data));
|
||||||
BtPieceMessageHandle pm = BtPieceMessage::create(&msg[4], 11);
|
BtPieceMessageHandle pm = BtPieceMessage::create(&msg[4], 11);
|
||||||
CPPUNIT_ASSERT_EQUAL((uint8_t)7, pm->getId());
|
CPPUNIT_ASSERT_EQUAL((int8_t)7, pm->getId());
|
||||||
CPPUNIT_ASSERT_EQUAL(12345, pm->getIndex());
|
CPPUNIT_ASSERT_EQUAL(12345, pm->getIndex());
|
||||||
CPPUNIT_ASSERT_EQUAL(256, pm->getBegin());
|
CPPUNIT_ASSERT_EQUAL(256, pm->getBegin());
|
||||||
CPPUNIT_ASSERT(memcmp(data, pm->getBlock(), sizeof(data)) == 0);
|
CPPUNIT_ASSERT(memcmp(data, pm->getBlock(), sizeof(data)) == 0);
|
||||||
CPPUNIT_ASSERT_EQUAL((uint32_t)2, pm->getBlockLength());
|
CPPUNIT_ASSERT_EQUAL(2, pm->getBlockLength());
|
||||||
|
|
||||||
// case: payload size is wrong
|
// case: payload size is wrong
|
||||||
try {
|
try {
|
||||||
|
@ -174,7 +174,7 @@ void BtPieceMessageTest::testChokingEvent_allowedFastEnabled() {
|
||||||
MockBtMessage2* rej = (MockBtMessage2*)btMessageDispatcher->messageQueue.front().get();
|
MockBtMessage2* rej = (MockBtMessage2*)btMessageDispatcher->messageQueue.front().get();
|
||||||
CPPUNIT_ASSERT_EQUAL(1, rej->index);
|
CPPUNIT_ASSERT_EQUAL(1, rej->index);
|
||||||
CPPUNIT_ASSERT_EQUAL(1024, rej->begin);
|
CPPUNIT_ASSERT_EQUAL(1024, rej->begin);
|
||||||
CPPUNIT_ASSERT_EQUAL((uint32_t)16*1024, rej->length);
|
CPPUNIT_ASSERT_EQUAL(16*1024, rej->length);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BtPieceMessageTest::testChokingEvent_inAmAllowedIndexSet() {
|
void BtPieceMessageTest::testChokingEvent_inAmAllowedIndexSet() {
|
||||||
|
@ -259,7 +259,7 @@ void BtPieceMessageTest::testCancelSendingPieceEvent_allowedFastEnabled() {
|
||||||
MockBtMessage2* rej = (MockBtMessage2*)btMessageDispatcher->messageQueue.front().get();
|
MockBtMessage2* rej = (MockBtMessage2*)btMessageDispatcher->messageQueue.front().get();
|
||||||
CPPUNIT_ASSERT_EQUAL(1, rej->index);
|
CPPUNIT_ASSERT_EQUAL(1, rej->index);
|
||||||
CPPUNIT_ASSERT_EQUAL(1024, rej->begin);
|
CPPUNIT_ASSERT_EQUAL(1024, rej->begin);
|
||||||
CPPUNIT_ASSERT_EQUAL((uint32_t)16*1024, rej->length);
|
CPPUNIT_ASSERT_EQUAL(16*1024, rej->length);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BtPieceMessageTest::testCancelSendingPieceEvent_invalidate() {
|
void BtPieceMessageTest::testCancelSendingPieceEvent_invalidate() {
|
||||||
|
|
|
@ -29,8 +29,8 @@ void BtPortMessageTest::testCreate() {
|
||||||
PeerMessageUtil::createPeerMessageString(msg, sizeof(msg), 3, 9);
|
PeerMessageUtil::createPeerMessageString(msg, sizeof(msg), 3, 9);
|
||||||
PeerMessageUtil::setShortIntParam(&msg[5], 12345);
|
PeerMessageUtil::setShortIntParam(&msg[5], 12345);
|
||||||
BtPortMessageHandle pm = BtPortMessage::create(&msg[4], 3);
|
BtPortMessageHandle pm = BtPortMessage::create(&msg[4], 3);
|
||||||
CPPUNIT_ASSERT_EQUAL((uint8_t)9, pm->getId());
|
CPPUNIT_ASSERT_EQUAL((int8_t)9, pm->getId());
|
||||||
CPPUNIT_ASSERT_EQUAL((uint16_t)12345, pm->getPort());
|
CPPUNIT_ASSERT_EQUAL((int16_t)12345, pm->getPort());
|
||||||
|
|
||||||
// case: payload size is wrong
|
// case: payload size is wrong
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -38,7 +38,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual RequestSlot getOutstandingRequest(int32_t index, int32_t begin,
|
virtual RequestSlot getOutstandingRequest(int32_t index, int32_t begin,
|
||||||
uint32_t length) {
|
int32_t length) {
|
||||||
if(slot.getIndex() == index && slot.getBegin() == begin &&
|
if(slot.getIndex() == index && slot.getBegin() == begin &&
|
||||||
slot.getLength() == length) {
|
slot.getLength() == length) {
|
||||||
return slot;
|
return slot;
|
||||||
|
@ -97,10 +97,10 @@ void BtRejectMessageTest::testCreate() {
|
||||||
PeerMessageUtil::setIntParam(&msg[9], 256);
|
PeerMessageUtil::setIntParam(&msg[9], 256);
|
||||||
PeerMessageUtil::setIntParam(&msg[13], 1024);
|
PeerMessageUtil::setIntParam(&msg[13], 1024);
|
||||||
BtRejectMessageHandle pm = BtRejectMessage::create(&msg[4], 13);
|
BtRejectMessageHandle pm = BtRejectMessage::create(&msg[4], 13);
|
||||||
CPPUNIT_ASSERT_EQUAL((uint8_t)16, pm->getId());
|
CPPUNIT_ASSERT_EQUAL((int8_t)16, pm->getId());
|
||||||
CPPUNIT_ASSERT_EQUAL(12345, pm->getIndex());
|
CPPUNIT_ASSERT_EQUAL(12345, pm->getIndex());
|
||||||
CPPUNIT_ASSERT_EQUAL(256, pm->getBegin());
|
CPPUNIT_ASSERT_EQUAL(256, pm->getBegin());
|
||||||
CPPUNIT_ASSERT_EQUAL((uint32_t)1024, pm->getLength());
|
CPPUNIT_ASSERT_EQUAL(1024, pm->getLength());
|
||||||
|
|
||||||
// case: payload size is wrong
|
// case: payload size is wrong
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -55,9 +55,9 @@ public:
|
||||||
string type;
|
string type;
|
||||||
int32_t index;
|
int32_t index;
|
||||||
int32_t begin;
|
int32_t begin;
|
||||||
uint32_t length;
|
int32_t length;
|
||||||
public:
|
public:
|
||||||
MockBtMessage2(string type, int32_t index, int32_t begin, uint32_t length):type(type), index(index), begin(begin), length(length) {}
|
MockBtMessage2(string type, int32_t index, int32_t begin, int32_t length):type(type), index(index), begin(begin), length(length) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef SharedHandle<MockBtMessage2> MockBtMessage2Handle;
|
typedef SharedHandle<MockBtMessage2> MockBtMessage2Handle;
|
||||||
|
@ -65,13 +65,13 @@ public:
|
||||||
class MockBtMessageFactory2 : public MockBtMessageFactory {
|
class MockBtMessageFactory2 : public MockBtMessageFactory {
|
||||||
public:
|
public:
|
||||||
virtual BtMessageHandle
|
virtual BtMessageHandle
|
||||||
createPieceMessage(int32_t index, int32_t begin, uint32_t length) {
|
createPieceMessage(int32_t index, int32_t begin, int32_t length) {
|
||||||
MockBtMessage2Handle btMsg = new MockBtMessage2("piece", index, begin, length);
|
MockBtMessage2Handle btMsg = new MockBtMessage2("piece", index, begin, length);
|
||||||
return btMsg;
|
return btMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual BtMessageHandle
|
virtual BtMessageHandle
|
||||||
createRejectMessage(int32_t index, int32_t begin, uint32_t length) {
|
createRejectMessage(int32_t index, int32_t begin, int32_t length) {
|
||||||
MockBtMessage2Handle btMsg = new MockBtMessage2("reject", index, begin, length);
|
MockBtMessage2Handle btMsg = new MockBtMessage2("reject", index, begin, length);
|
||||||
return btMsg;
|
return btMsg;
|
||||||
}
|
}
|
||||||
|
@ -131,10 +131,10 @@ void BtRequestMessageTest::testCreate() {
|
||||||
PeerMessageUtil::setIntParam(&msg[9], 256);
|
PeerMessageUtil::setIntParam(&msg[9], 256);
|
||||||
PeerMessageUtil::setIntParam(&msg[13], 1024);
|
PeerMessageUtil::setIntParam(&msg[13], 1024);
|
||||||
BtRequestMessageHandle pm = BtRequestMessage::create(&msg[4], 13);
|
BtRequestMessageHandle pm = BtRequestMessage::create(&msg[4], 13);
|
||||||
CPPUNIT_ASSERT_EQUAL((uint8_t)6, pm->getId());
|
CPPUNIT_ASSERT_EQUAL((int8_t)6, pm->getId());
|
||||||
CPPUNIT_ASSERT_EQUAL(12345, pm->getIndex());
|
CPPUNIT_ASSERT_EQUAL(12345, pm->getIndex());
|
||||||
CPPUNIT_ASSERT_EQUAL(256, pm->getBegin());
|
CPPUNIT_ASSERT_EQUAL(256, pm->getBegin());
|
||||||
CPPUNIT_ASSERT_EQUAL((uint32_t)1024, pm->getLength());
|
CPPUNIT_ASSERT_EQUAL(1024, pm->getLength());
|
||||||
|
|
||||||
// case: payload size is wrong
|
// case: payload size is wrong
|
||||||
try {
|
try {
|
||||||
|
@ -176,7 +176,7 @@ void BtRequestMessageTest::testDoReceivedAction_hasPieceAndAmNotChoking() {
|
||||||
CPPUNIT_ASSERT_EQUAL(string("piece"), pieceMsg->type);
|
CPPUNIT_ASSERT_EQUAL(string("piece"), pieceMsg->type);
|
||||||
CPPUNIT_ASSERT_EQUAL(1, pieceMsg->index);
|
CPPUNIT_ASSERT_EQUAL(1, pieceMsg->index);
|
||||||
CPPUNIT_ASSERT_EQUAL(16, pieceMsg->begin);
|
CPPUNIT_ASSERT_EQUAL(16, pieceMsg->begin);
|
||||||
CPPUNIT_ASSERT_EQUAL((uint32_t)32, pieceMsg->length);
|
CPPUNIT_ASSERT_EQUAL(32, pieceMsg->length);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BtRequestMessageTest::testDoReceivedAction_hasPieceAndAmChokingAndFastExtensionEnabled() {
|
void BtRequestMessageTest::testDoReceivedAction_hasPieceAndAmChokingAndFastExtensionEnabled() {
|
||||||
|
@ -189,7 +189,7 @@ void BtRequestMessageTest::testDoReceivedAction_hasPieceAndAmChokingAndFastExten
|
||||||
CPPUNIT_ASSERT_EQUAL(string("reject"), pieceMsg->type);
|
CPPUNIT_ASSERT_EQUAL(string("reject"), pieceMsg->type);
|
||||||
CPPUNIT_ASSERT_EQUAL(1, pieceMsg->index);
|
CPPUNIT_ASSERT_EQUAL(1, pieceMsg->index);
|
||||||
CPPUNIT_ASSERT_EQUAL(16, pieceMsg->begin);
|
CPPUNIT_ASSERT_EQUAL(16, pieceMsg->begin);
|
||||||
CPPUNIT_ASSERT_EQUAL((uint32_t)32, pieceMsg->length);
|
CPPUNIT_ASSERT_EQUAL(32, pieceMsg->length);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BtRequestMessageTest::testDoReceivedAction_hasPieceAndAmChokingAndFastExtensionDisabled() {
|
void BtRequestMessageTest::testDoReceivedAction_hasPieceAndAmChokingAndFastExtensionDisabled() {
|
||||||
|
@ -210,7 +210,7 @@ void BtRequestMessageTest::testDoReceivedAction_doesntHavePieceAndFastExtensionE
|
||||||
CPPUNIT_ASSERT_EQUAL(string("reject"), pieceMsg->type);
|
CPPUNIT_ASSERT_EQUAL(string("reject"), pieceMsg->type);
|
||||||
CPPUNIT_ASSERT_EQUAL(2, pieceMsg->index);
|
CPPUNIT_ASSERT_EQUAL(2, pieceMsg->index);
|
||||||
CPPUNIT_ASSERT_EQUAL(16, pieceMsg->begin);
|
CPPUNIT_ASSERT_EQUAL(16, pieceMsg->begin);
|
||||||
CPPUNIT_ASSERT_EQUAL((uint32_t)32, pieceMsg->length);
|
CPPUNIT_ASSERT_EQUAL(32, pieceMsg->length);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BtRequestMessageTest::testDoReceivedAction_doesntHavePieceAndFastExtensionDisabled() {
|
void BtRequestMessageTest::testDoReceivedAction_doesntHavePieceAndFastExtensionDisabled() {
|
||||||
|
|
|
@ -30,7 +30,7 @@ void BtSuggestPieceMessageTest::testCreate() {
|
||||||
PeerMessageUtil::createPeerMessageString(msg, sizeof(msg), 5, 13);
|
PeerMessageUtil::createPeerMessageString(msg, sizeof(msg), 5, 13);
|
||||||
PeerMessageUtil::setIntParam(&msg[5], 12345);
|
PeerMessageUtil::setIntParam(&msg[5], 12345);
|
||||||
BtSuggestPieceMessageHandle pm = BtSuggestPieceMessage::create(&msg[4], 5);
|
BtSuggestPieceMessageHandle pm = BtSuggestPieceMessage::create(&msg[4], 5);
|
||||||
CPPUNIT_ASSERT_EQUAL((uint8_t)13, pm->getId());
|
CPPUNIT_ASSERT_EQUAL((int8_t)13, pm->getId());
|
||||||
CPPUNIT_ASSERT_EQUAL(12345, pm->getIndex());
|
CPPUNIT_ASSERT_EQUAL(12345, pm->getIndex());
|
||||||
|
|
||||||
// case: payload size is wrong
|
// case: payload size is wrong
|
||||||
|
|
|
@ -32,7 +32,7 @@ void BtUnchokeMessageTest::testCreate() {
|
||||||
unsigned char msg[5];
|
unsigned char msg[5];
|
||||||
PeerMessageUtil::createPeerMessageString(msg, sizeof(msg), 1, 1);
|
PeerMessageUtil::createPeerMessageString(msg, sizeof(msg), 1, 1);
|
||||||
BtUnchokeMessageHandle pm = BtUnchokeMessage::create(&msg[4], 1);
|
BtUnchokeMessageHandle pm = BtUnchokeMessage::create(&msg[4], 1);
|
||||||
CPPUNIT_ASSERT_EQUAL((uint8_t)1, pm->getId());
|
CPPUNIT_ASSERT_EQUAL((int8_t)1, pm->getId());
|
||||||
|
|
||||||
// case: payload size is wrong
|
// case: payload size is wrong
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -28,7 +28,7 @@ void ConsoleFileAllocationMonitorTest::testShowProgress() {
|
||||||
monitor.setCurrentValue(0);
|
monitor.setCurrentValue(0);
|
||||||
|
|
||||||
cout << endl;
|
cout << endl;
|
||||||
for(uint64_t i = monitor.getMinValue(); i <= monitor.getMaxValue(); i += 1234343) {
|
for(int64_t i = monitor.getMinValue(); i <= monitor.getMaxValue(); i += 1234343) {
|
||||||
monitor.setCurrentValue(i);
|
monitor.setCurrentValue(i);
|
||||||
monitor.showProgress();
|
monitor.showProgress();
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,7 +119,7 @@ public:
|
||||||
class MockBtMessageFactory2 : public MockBtMessageFactory {
|
class MockBtMessageFactory2 : public MockBtMessageFactory {
|
||||||
public:
|
public:
|
||||||
virtual BtMessageHandle
|
virtual BtMessageHandle
|
||||||
createCancelMessage(int32_t index, int32_t begin, uint32_t length) {
|
createCancelMessage(int32_t index, int32_t begin, int32_t length) {
|
||||||
MockBtMessage2Handle btMsg = new MockBtMessage2();
|
MockBtMessage2Handle btMsg = new MockBtMessage2();
|
||||||
btMsg->type = "cancel";
|
btMsg->type = "cancel";
|
||||||
return btMsg;
|
return btMsg;
|
||||||
|
@ -370,7 +370,7 @@ void DefaultBtMessageDispatcherTest::testIsSendingInProgress() {
|
||||||
void DefaultBtMessageDispatcherTest::testCountOutstandingRequest() {
|
void DefaultBtMessageDispatcherTest::testCountOutstandingRequest() {
|
||||||
RequestSlot slot(0, 0, MY_PIECE_LENGTH, 0);
|
RequestSlot slot(0, 0, MY_PIECE_LENGTH, 0);
|
||||||
btMessageDispatcher->addOutstandingRequest(slot);
|
btMessageDispatcher->addOutstandingRequest(slot);
|
||||||
CPPUNIT_ASSERT_EQUAL((uint32_t)1, btMessageDispatcher->countOutstandingRequest());
|
CPPUNIT_ASSERT_EQUAL(1, btMessageDispatcher->countOutstandingRequest());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefaultBtMessageDispatcherTest::testIsOutstandingRequest() {
|
void DefaultBtMessageDispatcherTest::testIsOutstandingRequest() {
|
||||||
|
|
|
@ -8,11 +8,11 @@ class MockBtContext : public BtContext {
|
||||||
private:
|
private:
|
||||||
unsigned char infoHash[20];
|
unsigned char infoHash[20];
|
||||||
Strings pieceHashes;
|
Strings pieceHashes;
|
||||||
long long int totalLength;
|
int64_t totalLength;
|
||||||
FILE_MODE fileMode;
|
FILE_MODE fileMode;
|
||||||
string name;
|
string name;
|
||||||
int pieceLength;
|
int32_t pieceLength;
|
||||||
int numPieces;
|
int32_t numPieces;
|
||||||
unsigned char peerId[20];
|
unsigned char peerId[20];
|
||||||
FileEntries fileEntries;
|
FileEntries fileEntries;
|
||||||
AnnounceTiers announceTiers;
|
AnnounceTiers announceTiers;
|
||||||
|
@ -31,7 +31,7 @@ public:
|
||||||
memcpy(this->infoHash, infoHash, sizeof(this->infoHash));
|
memcpy(this->infoHash, infoHash, sizeof(this->infoHash));
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int getInfoHashLength() const {
|
virtual int32_t getInfoHashLength() const {
|
||||||
return sizeof(infoHash);
|
return sizeof(infoHash);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ public:
|
||||||
return Util::toHex(infoHash, sizeof(infoHash));
|
return Util::toHex(infoHash, sizeof(infoHash));
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual string getPieceHash(int index) const {
|
virtual string getPieceHash(int32_t index) const {
|
||||||
return pieceHashes.at(index);
|
return pieceHashes.at(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,11 +51,11 @@ public:
|
||||||
pieceHashes.push_back(pieceHash);
|
pieceHashes.push_back(pieceHash);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual long long int getTotalLength() const {
|
virtual int64_t getTotalLength() const {
|
||||||
return totalLength;
|
return totalLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setTotalLength(long long int length) {
|
void setTotalLength(int64_t length) {
|
||||||
this->totalLength = length;
|
this->totalLength = length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,19 +93,19 @@ public:
|
||||||
this->name = name;
|
this->name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int getPieceLength() const {
|
virtual int32_t getPieceLength() const {
|
||||||
return pieceLength;
|
return pieceLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setPieceLength(int pieceLength) {
|
void setPieceLength(int32_t pieceLength) {
|
||||||
this->pieceLength = pieceLength;
|
this->pieceLength = pieceLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int getNumPieces() const {
|
virtual int32_t getNumPieces() const {
|
||||||
return numPieces;
|
return numPieces;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setNumPieces(int numPieces) {
|
void setNumPieces(int32_t numPieces) {
|
||||||
this->numPieces = numPieces;
|
this->numPieces = numPieces;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ private:
|
||||||
bool sendingInProgress;
|
bool sendingInProgress;
|
||||||
bool invalidate;
|
bool invalidate;
|
||||||
bool uploading;
|
bool uploading;
|
||||||
uint8_t id;
|
int8_t id;
|
||||||
public:
|
public:
|
||||||
MockBtMessage() {}
|
MockBtMessage() {}
|
||||||
|
|
||||||
|
@ -72,11 +72,11 @@ public:
|
||||||
this->uploading = flag;
|
this->uploading = flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual uint8_t getId() {
|
virtual int8_t getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setId(uint8_t id) {
|
void setId(int8_t id) {
|
||||||
this->id = id;
|
this->id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ public:
|
||||||
|
|
||||||
virtual void sendMessages() {}
|
virtual void sendMessages() {}
|
||||||
|
|
||||||
virtual void doCancelSendingPieceAction(int32_t index, int32_t begin, uint32_t length) {}
|
virtual void doCancelSendingPieceAction(int32_t index, int32_t begin, int32_t length) {}
|
||||||
|
|
||||||
virtual void doCancelSendingPieceAction(const PieceHandle& piece) {}
|
virtual void doCancelSendingPieceAction(const PieceHandle& piece) {}
|
||||||
|
|
||||||
|
@ -35,11 +35,11 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual uint32_t countMessageInQueue() {
|
virtual int32_t countMessageInQueue() {
|
||||||
return messageQueue.size();
|
return messageQueue.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual uint32_t countOutstandingRequest() {
|
virtual int32_t countOutstandingRequest() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual RequestSlot getOutstandingRequest(int32_t index, int32_t begin, uint32_t length) {
|
virtual RequestSlot getOutstandingRequest(int32_t index, int32_t begin, int32_t length) {
|
||||||
return RequestSlot::nullSlot;
|
return RequestSlot::nullSlot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,12 +10,12 @@ public:
|
||||||
virtual ~MockBtMessageFactory() {}
|
virtual ~MockBtMessageFactory() {}
|
||||||
|
|
||||||
virtual BtMessageHandle
|
virtual BtMessageHandle
|
||||||
createBtMessage(const unsigned char* msg, uint32_t msgLength) {
|
createBtMessage(const unsigned char* msg, int32_t msgLength) {
|
||||||
return BtMessageHandle(0);
|
return BtMessageHandle(0);
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual BtMessageHandle
|
virtual BtMessageHandle
|
||||||
createHandshakeMessage(const unsigned char* msg, uint32_t msgLength) {
|
createHandshakeMessage(const unsigned char* msg, int32_t msgLength) {
|
||||||
return BtMessageHandle(0);
|
return BtMessageHandle(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,12 +31,12 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual BtMessageHandle
|
virtual BtMessageHandle
|
||||||
createCancelMessage(int32_t index, int32_t begin, uint32_t length) {
|
createCancelMessage(int32_t index, int32_t begin, int32_t length) {
|
||||||
return BtMessageHandle(0);
|
return BtMessageHandle(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual BtMessageHandle
|
virtual BtMessageHandle
|
||||||
createPieceMessage(int32_t index, int32_t begin, uint32_t length) {
|
createPieceMessage(int32_t index, int32_t begin, int32_t length) {
|
||||||
return BtMessageHandle(0);
|
return BtMessageHandle(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual BtMessageHandle
|
virtual BtMessageHandle
|
||||||
createRejectMessage(int32_t index, int32_t begin, uint32_t length) {
|
createRejectMessage(int32_t index, int32_t begin, int32_t length) {
|
||||||
return BtMessageHandle(0);
|
return BtMessageHandle(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,9 +19,9 @@ public:
|
||||||
|
|
||||||
virtual void doChokedAction() {}
|
virtual void doChokedAction() {}
|
||||||
|
|
||||||
virtual BtMessages createRequestMessages(uint32_t max) { return BtMessages(); }
|
virtual BtMessages createRequestMessages(int32_t max) { return BtMessages(); }
|
||||||
|
|
||||||
virtual BtMessages createRequestMessagesOnEndGame(uint32_t max) { return BtMessages(); }
|
virtual BtMessages createRequestMessagesOnEndGame(int32_t max) { return BtMessages(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef SharedHandle<MockBtRequestFactory> MockBtRequestFactoryHandle;
|
typedef SharedHandle<MockBtRequestFactory> MockBtRequestFactoryHandle;
|
||||||
|
|
|
@ -6,10 +6,10 @@
|
||||||
|
|
||||||
class MockPieceStorage : public PieceStorage {
|
class MockPieceStorage : public PieceStorage {
|
||||||
private:
|
private:
|
||||||
long long int totalLength;
|
int64_t totalLength;
|
||||||
long long int filteredTotalLength;
|
int64_t filteredTotalLength;
|
||||||
long long int completedLength;
|
int64_t completedLength;
|
||||||
long long int filteredCompletedLength;
|
int64_t filteredCompletedLength;
|
||||||
BitfieldMan* bitfieldMan;
|
BitfieldMan* bitfieldMan;
|
||||||
bool selectiveDownloadingMode;
|
bool selectiveDownloadingMode;
|
||||||
bool endGame;
|
bool endGame;
|
||||||
|
@ -43,35 +43,35 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual long long int getTotalLength() {
|
virtual int64_t getTotalLength() {
|
||||||
return totalLength;
|
return totalLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setTotalLength(long long int totalLength) {
|
void setTotalLength(int64_t totalLength) {
|
||||||
this->totalLength = totalLength;
|
this->totalLength = totalLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual long long int getFilteredTotalLength() {
|
virtual int64_t getFilteredTotalLength() {
|
||||||
return filteredTotalLength;
|
return filteredTotalLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setFilteredTotalLength(long long int totalLength) {
|
void setFilteredTotalLength(int64_t totalLength) {
|
||||||
this->filteredTotalLength = totalLength;
|
this->filteredTotalLength = totalLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual long long int getCompletedLength() {
|
virtual int64_t getCompletedLength() {
|
||||||
return completedLength;
|
return completedLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setCompletedLength(long long int completedLength) {
|
void setCompletedLength(int64_t completedLength) {
|
||||||
this->completedLength = completedLength;
|
this->completedLength = completedLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual long long int getFilteredCompletedLength() {
|
virtual int64_t getFilteredCompletedLength() {
|
||||||
return filteredCompletedLength;
|
return filteredCompletedLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setFilteredCompletedLength(long long int completedLength) {
|
void setFilteredCompletedLength(int64_t completedLength) {
|
||||||
this->filteredCompletedLength = completedLength;
|
this->filteredCompletedLength = completedLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,6 +85,10 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual bool allDownloadFinished() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
virtual void initStorage() {}
|
virtual void initStorage() {}
|
||||||
|
|
||||||
virtual const unsigned char* getBitfield() {
|
virtual const unsigned char* getBitfield() {
|
||||||
|
@ -92,11 +96,11 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void setBitfield(const unsigned char* bitfield,
|
virtual void setBitfield(const unsigned char* bitfield,
|
||||||
int bitfieldLength) {
|
int32_t bitfieldLength) {
|
||||||
bitfieldMan->setBitfield(bitfield, bitfieldLength);
|
bitfieldMan->setBitfield(bitfield, bitfieldLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int getBitfieldLength() {
|
virtual int32_t getBitfieldLength() {
|
||||||
return bitfieldMan->getBitfieldLength();
|
return bitfieldMan->getBitfieldLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,22 +134,22 @@ public:
|
||||||
this->diskAdaptor = adaptor;
|
this->diskAdaptor = adaptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int getPieceLength(int index) {
|
virtual int32_t getPieceLength(int32_t index) {
|
||||||
return pieceLengthList.at(index);
|
return pieceLengthList.at(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void addPieceLengthList(int length) {
|
void addPieceLengthList(int32_t length) {
|
||||||
pieceLengthList.push_back(length);
|
pieceLengthList.push_back(length);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void advertisePiece(int cuid, int index) {}
|
virtual void advertisePiece(int32_t cuid, int32_t index) {}
|
||||||
|
|
||||||
virtual Integers getAdvertisedPieceIndexes(int myCuid,
|
virtual Integers getAdvertisedPieceIndexes(int32_t myCuid,
|
||||||
const Time& lastCheckTime) {
|
const Time& lastCheckTime) {
|
||||||
return Integers();
|
return Integers();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void removeAdvertisedPiece(int elapsed) {}
|
virtual void removeAdvertisedPiece(int32_t elapsed) {}
|
||||||
|
|
||||||
virtual void markAllPiecesDone() {}
|
virtual void markAllPiecesDone() {}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "ShareRatioSeedCriteria.h"
|
#include "ShareRatioSeedCriteria.h"
|
||||||
#include "MockBtContext.h"
|
#include "MockBtContext.h"
|
||||||
#include "MockPeerStorage.h"
|
#include "MockPeerStorage.h"
|
||||||
|
#include "MockPieceStorage.h"
|
||||||
#include <cppunit/extensions/HelperMacros.h>
|
#include <cppunit/extensions/HelperMacros.h>
|
||||||
|
|
||||||
class ShareRatioSeedCriteriaTest:public CppUnit::TestFixture {
|
class ShareRatioSeedCriteriaTest:public CppUnit::TestFixture {
|
||||||
|
@ -36,6 +37,10 @@ void ShareRatioSeedCriteriaTest::testEvaluate() {
|
||||||
PeerStorageHandle peerStorage(mockPeerStorage);
|
PeerStorageHandle peerStorage(mockPeerStorage);
|
||||||
BtRegistry::registerPeerStorage(infoHashString, peerStorage);
|
BtRegistry::registerPeerStorage(infoHashString, peerStorage);
|
||||||
|
|
||||||
|
MockPieceStorage* mockPieceStorage = new MockPieceStorage();
|
||||||
|
mockPieceStorage->setCompletedLength(1000000);
|
||||||
|
BtRegistry::registerPieceStorage(infoHashString, PieceStorageHandle(mockPieceStorage));
|
||||||
|
|
||||||
ShareRatioSeedCriteria cri(1.0, btContext);
|
ShareRatioSeedCriteria cri(1.0, btContext);
|
||||||
CPPUNIT_ASSERT(cri.evaluate());
|
CPPUNIT_ASSERT(cri.evaluate());
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ class UtilTest:public CppUnit::TestFixture {
|
||||||
CPPUNIT_TEST(testToUpper);
|
CPPUNIT_TEST(testToUpper);
|
||||||
CPPUNIT_TEST(testToLower);
|
CPPUNIT_TEST(testToLower);
|
||||||
CPPUNIT_TEST(testUrldecode);
|
CPPUNIT_TEST(testUrldecode);
|
||||||
|
CPPUNIT_TEST(testCountBit);
|
||||||
CPPUNIT_TEST_SUITE_END();
|
CPPUNIT_TEST_SUITE_END();
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -42,6 +43,7 @@ public:
|
||||||
void testToUpper();
|
void testToUpper();
|
||||||
void testToLower();
|
void testToLower();
|
||||||
void testUrldecode();
|
void testUrldecode();
|
||||||
|
void testCountBit();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -282,3 +284,8 @@ void UtilTest::testUrldecode() {
|
||||||
string src6 = "%2f";
|
string src6 = "%2f";
|
||||||
CPPUNIT_ASSERT_EQUAL(string("/"), Util::urldecode(src6));
|
CPPUNIT_ASSERT_EQUAL(string("/"), Util::urldecode(src6));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UtilTest::testCountBit() {
|
||||||
|
CPPUNIT_ASSERT_EQUAL(32, Util::countBit(UINT32_MAX));
|
||||||
|
CPPUNIT_ASSERT_EQUAL(8, Util::countBit(255));
|
||||||
|
}
|
||||||
|
|
|
@ -32,6 +32,8 @@ void Xml2MetalinkProcessorTest::testParseFile() {
|
||||||
|
|
||||||
MetalinkEntries::iterator entryItr = metalinker->entries.begin();
|
MetalinkEntries::iterator entryItr = metalinker->entries.begin();
|
||||||
MetalinkEntryHandle entry1 = *entryItr;
|
MetalinkEntryHandle entry1 = *entryItr;
|
||||||
|
CPPUNIT_ASSERT_EQUAL(string("aria2-0.5.2.tar.bz2"), entry1->filename);
|
||||||
|
CPPUNIT_ASSERT_EQUAL((int64_t)0, entry1->size);
|
||||||
CPPUNIT_ASSERT_EQUAL(string("0.5.2"), entry1->version);
|
CPPUNIT_ASSERT_EQUAL(string("0.5.2"), entry1->version);
|
||||||
CPPUNIT_ASSERT_EQUAL(string("en-US"), entry1->language);
|
CPPUNIT_ASSERT_EQUAL(string("en-US"), entry1->language);
|
||||||
CPPUNIT_ASSERT_EQUAL(string("Linux-x86"), entry1->os);
|
CPPUNIT_ASSERT_EQUAL(string("Linux-x86"), entry1->os);
|
||||||
|
@ -57,14 +59,15 @@ void Xml2MetalinkProcessorTest::testParseFile() {
|
||||||
entryItr++;
|
entryItr++;
|
||||||
|
|
||||||
MetalinkEntryHandle entry2 = *entryItr;
|
MetalinkEntryHandle entry2 = *entryItr;
|
||||||
CPPUNIT_ASSERT_EQUAL((uint64_t)345689, entry2->size);
|
CPPUNIT_ASSERT_EQUAL(string("aria2-0.5.1.tar.bz2"), entry2->filename);
|
||||||
|
CPPUNIT_ASSERT_EQUAL((int64_t)345689, entry2->size);
|
||||||
CPPUNIT_ASSERT_EQUAL(string("0.5.1"), entry2->version);
|
CPPUNIT_ASSERT_EQUAL(string("0.5.1"), entry2->version);
|
||||||
CPPUNIT_ASSERT_EQUAL(string("ja-JP"), entry2->language);
|
CPPUNIT_ASSERT_EQUAL(string("ja-JP"), entry2->language);
|
||||||
CPPUNIT_ASSERT_EQUAL(string("Linux-m68k"), entry2->os);
|
CPPUNIT_ASSERT_EQUAL(string("Linux-m68k"), entry2->os);
|
||||||
CPPUNIT_ASSERT_EQUAL(string("4c255b0ed130f5ea880f0aa061c3da0487e251cc"),
|
CPPUNIT_ASSERT_EQUAL(string("4c255b0ed130f5ea880f0aa061c3da0487e251cc"),
|
||||||
entry2->checksum.getMessageDigest());
|
entry2->checksum.getMessageDigest());
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)2, entry2->chunkChecksum->pieceHashes.size());
|
CPPUNIT_ASSERT_EQUAL((size_t)2, entry2->chunkChecksum->pieceHashes.size());
|
||||||
CPPUNIT_ASSERT_EQUAL((uint32_t)266144, entry2->chunkChecksum->pieceLength);
|
CPPUNIT_ASSERT_EQUAL(262144, entry2->chunkChecksum->pieceLength);
|
||||||
CPPUNIT_ASSERT_EQUAL(string("179463a88d79cbf0b1923991708aead914f26142"),
|
CPPUNIT_ASSERT_EQUAL(string("179463a88d79cbf0b1923991708aead914f26142"),
|
||||||
entry2->chunkChecksum->pieceHashes.at(0));
|
entry2->chunkChecksum->pieceHashes.at(0));
|
||||||
CPPUNIT_ASSERT_EQUAL(string("fecf8bc9a1647505fe16746f94e97a477597dbf3"),
|
CPPUNIT_ASSERT_EQUAL(string("fecf8bc9a1647505fe16746f94e97a477597dbf3"),
|
||||||
|
@ -72,7 +75,7 @@ void Xml2MetalinkProcessorTest::testParseFile() {
|
||||||
|
|
||||||
CPPUNIT_ASSERT(DIGEST_ALGO_SHA1 == entry2->checksum.getDigestAlgo());
|
CPPUNIT_ASSERT(DIGEST_ALGO_SHA1 == entry2->checksum.getDigestAlgo());
|
||||||
} catch(Exception* e) {
|
} catch(Exception* e) {
|
||||||
cerr << e->getMsg() << endl;
|
CPPUNIT_FAIL(e->getMsg());
|
||||||
delete e;
|
delete e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,8 +28,8 @@
|
||||||
<hash type="md5">92296e19c406d77d21bda0bb944eac46</hash>
|
<hash type="md5">92296e19c406d77d21bda0bb944eac46</hash>
|
||||||
<hash type="sha1">4c255b0ed130f5ea880f0aa061c3da0487e251cc</hash>
|
<hash type="sha1">4c255b0ed130f5ea880f0aa061c3da0487e251cc</hash>
|
||||||
<pieces length="262144" type="sha1">
|
<pieces length="262144" type="sha1">
|
||||||
<hash pieces="0">179463a88d79cbf0b1923991708aead914f26142</hash>
|
<hash piece="0">179463a88d79cbf0b1923991708aead914f26142</hash>
|
||||||
<hash pieces="1">fecf8bc9a1647505fe16746f94e97a477597dbf3</hash>
|
<hash piece="1">fecf8bc9a1647505fe16746f94e97a477597dbf3</hash>
|
||||||
</pieces>
|
</pieces>
|
||||||
</verification>
|
</verification>
|
||||||
<resources>
|
<resources>
|
||||||
|
|
Loading…
Reference in New Issue