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>
|
||||
|
||||
* 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.
|
||||
* The ports aria2c uses are 6881-6999.
|
||||
* The maximum number of peers is 55.
|
||||
* After selective download completes, aria2 is going to download rest of the
|
||||
files.
|
||||
* As of release 0.10.0, aria2 stops sending request message after selective
|
||||
download completes,
|
||||
|
||||
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.
|
||||
|
||||
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
|
||||
* Add an ability of seeding
|
||||
* 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
|
||||
# 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,
|
||||
# 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
|
@ -574,9 +574,9 @@ SHELL=${CONFIG_SHELL-/bin/sh}
|
|||
# Identity of this package.
|
||||
PACKAGE_NAME='aria2c'
|
||||
PACKAGE_TARNAME='aria2c'
|
||||
PACKAGE_VERSION='0.9.0'
|
||||
PACKAGE_STRING='aria2c 0.9.0'
|
||||
PACKAGE_BUGREPORT='tujikawa@rednoah.com'
|
||||
PACKAGE_VERSION='0.10.0'
|
||||
PACKAGE_STRING='aria2c 0.10.0'
|
||||
PACKAGE_BUGREPORT='t-tujikawa@users.sourceforge.net'
|
||||
|
||||
ac_unique_file="src/Socket.h"
|
||||
# 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.
|
||||
# This message is too long to be a string in the A/UX 3.1 sh.
|
||||
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]...
|
||||
|
||||
|
@ -1345,7 +1345,7 @@ fi
|
|||
|
||||
if test -n "$ac_init_help"; then
|
||||
case $ac_init_help in
|
||||
short | recursive ) echo "Configuration of aria2c 0.9.0:";;
|
||||
short | recursive ) echo "Configuration of aria2c 0.10.0:";;
|
||||
esac
|
||||
cat <<\_ACEOF
|
||||
|
||||
|
@ -1405,7 +1405,7 @@ Some influential environment variables:
|
|||
Use these variables to override the choices made by `configure' or to help
|
||||
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
|
||||
ac_status=$?
|
||||
fi
|
||||
|
@ -1466,7 +1466,7 @@ fi
|
|||
test -n "$ac_init_help" && exit $ac_status
|
||||
if $ac_init_version; then
|
||||
cat <<\_ACEOF
|
||||
aria2c configure 0.9.0
|
||||
aria2c configure 0.10.0
|
||||
generated by GNU Autoconf 2.61
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
$ $0 $@
|
||||
|
@ -2150,7 +2150,7 @@ fi
|
|||
|
||||
# Define the identity of the package.
|
||||
PACKAGE='aria2c'
|
||||
VERSION='0.9.0'
|
||||
VERSION='0.10.0'
|
||||
|
||||
|
||||
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: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
|
||||
( cat <<\_ASBOX
|
||||
## ----------------------------------- ##
|
||||
## Report this to tujikawa@rednoah.com ##
|
||||
## ----------------------------------- ##
|
||||
## ----------------------------------------------- ##
|
||||
## Report this to t-tujikawa@users.sourceforge.net ##
|
||||
## ----------------------------------------------- ##
|
||||
_ASBOX
|
||||
) | 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: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
|
||||
( cat <<\_ASBOX
|
||||
## ----------------------------------- ##
|
||||
## Report this to tujikawa@rednoah.com ##
|
||||
## ----------------------------------- ##
|
||||
## ----------------------------------------------- ##
|
||||
## Report this to t-tujikawa@users.sourceforge.net ##
|
||||
## ----------------------------------------------- ##
|
||||
_ASBOX
|
||||
) | 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: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
|
||||
( cat <<\_ASBOX
|
||||
## ----------------------------------- ##
|
||||
## Report this to tujikawa@rednoah.com ##
|
||||
## ----------------------------------- ##
|
||||
## ----------------------------------------------- ##
|
||||
## Report this to t-tujikawa@users.sourceforge.net ##
|
||||
## ----------------------------------------------- ##
|
||||
_ASBOX
|
||||
) | 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: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
|
||||
( cat <<\_ASBOX
|
||||
## ----------------------------------- ##
|
||||
## Report this to tujikawa@rednoah.com ##
|
||||
## ----------------------------------- ##
|
||||
## ----------------------------------------------- ##
|
||||
## Report this to t-tujikawa@users.sourceforge.net ##
|
||||
## ----------------------------------------------- ##
|
||||
_ASBOX
|
||||
) | 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: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
|
||||
( cat <<\_ASBOX
|
||||
## ----------------------------------- ##
|
||||
## Report this to tujikawa@rednoah.com ##
|
||||
## ----------------------------------- ##
|
||||
## ----------------------------------------------- ##
|
||||
## Report this to t-tujikawa@users.sourceforge.net ##
|
||||
## ----------------------------------------------- ##
|
||||
_ASBOX
|
||||
) | 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: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
|
||||
( cat <<\_ASBOX
|
||||
## ----------------------------------- ##
|
||||
## Report this to tujikawa@rednoah.com ##
|
||||
## ----------------------------------- ##
|
||||
## ----------------------------------------------- ##
|
||||
## Report this to t-tujikawa@users.sourceforge.net ##
|
||||
## ----------------------------------------------- ##
|
||||
_ASBOX
|
||||
) | 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: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
|
||||
( cat <<\_ASBOX
|
||||
## ----------------------------------- ##
|
||||
## Report this to tujikawa@rednoah.com ##
|
||||
## ----------------------------------- ##
|
||||
## ----------------------------------------------- ##
|
||||
## Report this to t-tujikawa@users.sourceforge.net ##
|
||||
## ----------------------------------------------- ##
|
||||
_ASBOX
|
||||
) | sed "s/^/$as_me: WARNING: /" >&2
|
||||
;;
|
||||
|
@ -12941,7 +12941,7 @@ exec 6>&1
|
|||
# report actual input values of CONFIG_FILES etc. instead of their
|
||||
# values after options handling.
|
||||
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
|
||||
|
||||
CONFIG_FILES = $CONFIG_FILES
|
||||
|
@ -12994,7 +12994,7 @@ Report bugs to <bug-autoconf@gnu.org>."
|
|||
_ACEOF
|
||||
cat >>$CONFIG_STATUS <<_ACEOF
|
||||
ac_cs_version="\\
|
||||
aria2c config.status 0.9.0
|
||||
aria2c config.status 0.10.0
|
||||
configured by $0, generated by GNU Autoconf 2.61,
|
||||
with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# Process this file with autoconf to produce a configure script.
|
||||
#
|
||||
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_PATH_CPPUNIT(1.10.2)
|
||||
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"
|
||||
|
||||
.SH NAME
|
||||
.P
|
||||
.\" Title: aria2c
|
||||
.\" Author:
|
||||
.\" Generator: DocBook XSL Stylesheets v1.70.1 <http://docbook.sf.net/>
|
||||
.\" 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
|
||||
|
||||
.SH SYNOPSIS
|
||||
.TS
|
||||
tab(^); l.
|
||||
aria2c [\fIoptions\fR] \fIURL\fR ...
|
||||
aria2c [\fIoptions\fR] \fB\-T\fR \fITORRENT_FILE FILE\fR ...
|
||||
aria2c [\fIoptions\fR] \fB\-M\fR \fIMETALINK_FILE\fR
|
||||
.TE
|
||||
|
||||
.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.
|
||||
|
||||
.P
|
||||
Please visit the project web site at \fIhttp://aria2.sourceforge.net\fR.
|
||||
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
\fB\-d\fR, \fB\-\-dir\fR=\fIDIR\fR
|
||||
.SH "SYNOPSIS"
|
||||
.sp
|
||||
.RS 3n
|
||||
.nf
|
||||
aria2c [OPTIONS] URL ...
|
||||
aria2c [OPTIONS] \-T TORRENT_FILE FILE ...
|
||||
aria2c [OPTIONS] \-M METALINK_FILE
|
||||
.fi
|
||||
.RE
|
||||
.SH "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.
|
||||
.sp
|
||||
Please visit the project web site at http://aria2.sourceforge.net
|
||||
.sp
|
||||
.SH "OPTIONS"
|
||||
.TP 3n
|
||||
\-d, \-\-dir=DIR
|
||||
The directory to store downloaded file.
|
||||
|
||||
.TP
|
||||
\fB\-o\fR, \fB\-\-out\fR=\fIFILE\fR
|
||||
.TP 3n
|
||||
\-o, \-\-out=FILE
|
||||
The file name for downloaded file.
|
||||
|
||||
.TP
|
||||
\fB\-l\fR, \fB\-\-log\fR=\fILOG\fR
|
||||
The file path to store log. If '\-' is specified,
|
||||
log is written to stdout.
|
||||
|
||||
.TP
|
||||
\fB\-D\fR, \fB\-\-daemon\fR
|
||||
.TP 3n
|
||||
\-l, \-\-log=LOG
|
||||
The file path to store log. If
|
||||
\fI\-\fR
|
||||
is specified, log is written to stdout.
|
||||
.TP 3n
|
||||
\-D, \-\-daemon
|
||||
Run as daemon.
|
||||
|
||||
.TP
|
||||
\fB\-s\fR, \fB\-\-split\fR=\fIN\fR
|
||||
Download a file using \fIN\fR connections. \fIN\fR must be
|
||||
between 1 and 5. This option affects all URLs.
|
||||
Thus, aria2 connects to each URL with
|
||||
\fIN\fR connections.
|
||||
|
||||
.TP
|
||||
\fB\-\-retry\-wait\fR=\fISEC\fR
|
||||
Set amount of time in second between requests
|
||||
for errors. Specify a value between 0 and 60.
|
||||
Default: 5
|
||||
|
||||
.TP
|
||||
\fB\-t\fR, \fB\-\-timeout\fR=\fISEC\fR
|
||||
Set timeout in second. Default: 60
|
||||
|
||||
.TP
|
||||
\fB\-m\fR, \fB\-\-max\-tries\fR=\fIN\fR
|
||||
Set number of tries. 0 means unlimited.
|
||||
Default: 5
|
||||
|
||||
.TP
|
||||
\fB\-\-http\-proxy\fR=\fIHOST\fR:\fIPORT\fR
|
||||
Use HTTP proxy server. This affects to all
|
||||
URLs.
|
||||
|
||||
.TP
|
||||
\fB\-\-http\-user\fR=\fIUSER\fR
|
||||
.TP 3n
|
||||
\-s, \-\-split=N
|
||||
Download a file using
|
||||
\fIN\fR
|
||||
connections.
|
||||
\fIN\fR
|
||||
must be between
|
||||
\fI1\fR
|
||||
and
|
||||
\fI5\fR. This option affects all URLs. Thus, aria2 connects to each URL with
|
||||
\fIN\fR
|
||||
connections. Default:
|
||||
\fI1\fR
|
||||
.TP 3n
|
||||
\-\-retry\-wait=SEC
|
||||
Set amount of time in second between requests for errors. Specify a value between
|
||||
\fI0\fR
|
||||
and
|
||||
\fI60\fR. Default:
|
||||
\fI5\fR
|
||||
.TP 3n
|
||||
\-t, \-\-timeout=SEC
|
||||
Set timeout in second. Default:
|
||||
\fI60\fR
|
||||
.TP 3n
|
||||
\-m, \-\-max\-tries=N
|
||||
Set number of tries.
|
||||
\fI0\fR
|
||||
means unlimited. Default:
|
||||
\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.
|
||||
|
||||
.TP
|
||||
\fB\-\-http\-passwd\fR=\fIPASSWD\fR
|
||||
.TP 3n
|
||||
\-\-http\-passwd=PASSWD
|
||||
Set HTTP password. This affects to all URLs.
|
||||
|
||||
.TP
|
||||
\fB\-\-http\-proxy\-user\fR=\fIUSER\fR
|
||||
.TP 3n
|
||||
\-\-http\-proxy\-user=USER
|
||||
Set HTTP proxy user. This affects to all URLs
|
||||
|
||||
.TP
|
||||
\fB\-\-http\-proxy\-passwd\fR=\fIPASSWD\fR
|
||||
.TP 3n
|
||||
\-\-http\-proxy\-passwd=PASSWD
|
||||
Set HTTP proxy password. This affects to all URLs.
|
||||
|
||||
.TP
|
||||
\fB\-\-http\-proxy\-method\fR=\fIMETHOD\fR
|
||||
.TP 3n
|
||||
\-\-http\-proxy\-method=METHOD
|
||||
Set the method to use in proxy request.
|
||||
\fIMETHOD\fR is either 'get' or 'tunnel'.
|
||||
Default: tunnel
|
||||
|
||||
.TP
|
||||
\fB\-\-http\-auth\-scheme\fR=\fISCHEME\fR
|
||||
Set HTTP authentication scheme. Currently, basic
|
||||
is the only supported scheme.
|
||||
Default: basic
|
||||
|
||||
.TP
|
||||
\fB\-\-referer\fR=\fIREFERER\fR
|
||||
\fIMETHOD\fR
|
||||
is either
|
||||
\fIget\fR
|
||||
or
|
||||
\fItunnel\fR. Default:
|
||||
\fItunnel\fR
|
||||
.TP 3n
|
||||
\-\-http\-auth\-scheme=SCHEME
|
||||
Set HTTP authentication scheme. Currently,
|
||||
\fIbasic\fR
|
||||
is the only supported scheme. Default:
|
||||
\fIbasic\fR
|
||||
.TP 3n
|
||||
\-\-referer=REFERER
|
||||
Set Referer. This affects to all URLs.
|
||||
|
||||
.TP
|
||||
\fB\-\-ftp\-user\fR=\fIUSER\fR
|
||||
Set FTP user. This affects to all URLs.
|
||||
Default: anonymous
|
||||
.TP
|
||||
\fB\-\-ftp\-passwd\fR=\fIPASSWD\fR
|
||||
Set FTP password. This affects to all URLs.
|
||||
Default: ARIA2USER@
|
||||
|
||||
.TP
|
||||
\fB\-\-ftp\-type\fR=\fITYPE\fR
|
||||
Set FTP transfer type. TYPE is either 'binary'
|
||||
or 'ascii'.
|
||||
Default: binary
|
||||
|
||||
.TP
|
||||
\fB\-p\fR, \fB\-\-ftp\-pasv\fR
|
||||
.TP 3n
|
||||
\-\-ftp\-user=USER
|
||||
Set FTP user. This affects to all URLs. Default:
|
||||
\fIanonymous\fR
|
||||
.TP 3n
|
||||
\-\-ftp\-passwd=PASSWD
|
||||
Set FTP password. This affects to all URLs. Default:
|
||||
\fIARIA2USER@\fR
|
||||
.TP 3n
|
||||
\-\-ftp\-type=TYPE
|
||||
Set FTP transfer type. TYPE is either
|
||||
\fIbinary\fR
|
||||
or
|
||||
\fIascii\fR. Default:
|
||||
\fIbinary\fR
|
||||
.TP 3n
|
||||
\-p, \-\-ftp\-pasv
|
||||
Use passive mode in FTP.
|
||||
|
||||
.TP
|
||||
\fB\-\-ftp\-via\-http\-proxy\fR=\fIMETHOD\fR
|
||||
Use HTTP proxy in FTP. \fIMETHOD\fR is either 'get' or
|
||||
\&'tunnel'.
|
||||
Default: tunnel
|
||||
|
||||
.TP
|
||||
\fB\-\-lowest\-speed\-limit\fR=\fISPEED\fR
|
||||
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
|
||||
|
||||
.TP
|
||||
\fB\-\-max\-download\-limit\fR=\fISPEED\fR
|
||||
.TP 3n
|
||||
\-\-ftp\-via\-http\-proxy=METHOD
|
||||
Use HTTP proxy in
|
||||
\fIFTP\fR.
|
||||
\fIMETHOD\fR
|
||||
is either
|
||||
\fIget\fR
|
||||
or
|
||||
\fItunnel\fR. Default:
|
||||
\fItunnel\fR
|
||||
.TP 3n
|
||||
\-\-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
|
||||
\fIK\fR
|
||||
or
|
||||
\fIM\fR(1K = 1024, 1M = 1024K). This option does not affect BitTorrent download. Default:
|
||||
\fI0\fR
|
||||
.TP 3n
|
||||
\-\-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
|
||||
|
||||
.TP
|
||||
\fB\-T\fR, \fB\-\-torrent\-file\fR=\fITORRENT_FILE\fR
|
||||
\fI0\fR
|
||||
means unrestricted. You can append
|
||||
\fIK\fR
|
||||
or
|
||||
\fIM\fR(1K = 1024, 1M = 1024K). Default:
|
||||
\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.
|
||||
|
||||
.TP
|
||||
\fB\-\-follow\-torrent\fR=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
|
||||
|
||||
.TP
|
||||
\fB\-S\fR, \fB\-\-show\-files\fR
|
||||
.TP 3n
|
||||
\-\-follow\-torrent=true|false
|
||||
Setting this option to
|
||||
\fIfalse\fR
|
||||
prevents aria2 to enter BitTorrent mode even if the filename of downloaded file ends with .torrent. Default:
|
||||
\fItrue\fR
|
||||
.TP 3n
|
||||
\-S, \-\-show\-files
|
||||
Print file listing of .torrent file and exit.
|
||||
|
||||
.TP
|
||||
\fB\-\-direct\-file\-mapping\fR=true|false
|
||||
Directly read from and write to each file
|
||||
mentioned in .torrent file.
|
||||
Default: true
|
||||
|
||||
.TP
|
||||
\fB\-\-listen\-port\fR=\fIPORT\fR
|
||||
.TP 3n
|
||||
\-\-direct\-file\-mapping=true|false
|
||||
Directly read from and write to each file mentioned in .torrent file. Default:
|
||||
\fItrue\fR
|
||||
.TP 3n
|
||||
\-\-listen\-port=PORT
|
||||
Set port number to listen to for peer connection.
|
||||
|
||||
.TP
|
||||
\fB\-\-max\-upload\-limit\fR=\fISPEED\fR
|
||||
.TP 3n
|
||||
\-\-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
|
||||
|
||||
.TP
|
||||
\fB\-\-select\-file\fR=\fIINDEX\fR...
|
||||
Set file to download by specifing its index.
|
||||
You can know file index through \fB\-\-show\-files\fR
|
||||
\fI0\fR
|
||||
means unrestricted. You can append
|
||||
\fIK\fR
|
||||
or
|
||||
\fIM\fR(1K = 1024, 1M = 1024K). Default:
|
||||
\fI0\fR
|
||||
.TP 3n
|
||||
\-\-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
|
||||
\&',' like "3,6".
|
||||
You can also use '\-' to specify rangelike "1\-5".
|
||||
\&',' and '\-' can be used together.
|
||||
|
||||
.TP
|
||||
\fB\-\-seed\-time\fR=\fIMINUTES\fR
|
||||
\fI,\fR
|
||||
like "3,6". You can also use
|
||||
\fI\-\fR
|
||||
to specify rangelike "1\-5".
|
||||
\fI,\fR
|
||||
and
|
||||
\fI\-\fR
|
||||
can be used together.
|
||||
.TP 3n
|
||||
\-\-seed\-time=MINUTES
|
||||
Specify seeding time in minutes. See also
|
||||
\fB\-\-seed\-ratio\fR option.
|
||||
|
||||
.TP
|
||||
\fB\-\-seed\-ratio\fR=\fIRATIO\fR
|
||||
Specify share ratio. Seed completed torrents until
|
||||
share ratio reaches RATIO. 1.0 is encouraged.
|
||||
If \fB\-\-seed\-time\fR option is specified along with
|
||||
this option, seeding ends when at least one of
|
||||
the conditions is satisfied.
|
||||
|
||||
.TP
|
||||
\fB\-M\fR, \fB\-\-metalink\-file\fR=\fIMETALINK_FILE\fR
|
||||
\fI\-\-seed\-ratio\fR
|
||||
option.
|
||||
.TP 3n
|
||||
\-\-seed\-ratio=RATIO
|
||||
Specify share ratio. Seed completed torrents until share ratio reaches
|
||||
\fIRATIO\fR.
|
||||
\fI1.0\fR
|
||||
is encouraged. If
|
||||
\fI\-\-seed\-time\fR
|
||||
option is specified along with this option, seeding ends when at least one of the conditions is satisfied.
|
||||
.TP 3n
|
||||
\-M, \-\-metalink\-file=METALINK_FILE
|
||||
The file path to .metalink file.
|
||||
|
||||
.TP
|
||||
\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 \fB\-s\fR option.
|
||||
Default: 15
|
||||
|
||||
.TP
|
||||
\fB\-\-metalink\-version\fR=\fIVERSION\fR
|
||||
.TP 3n
|
||||
\-C, \-\-metalink\-servers=NUM_SERVERS
|
||||
The number of servers to connect to simultaneously. If more than one connection per server is required, use
|
||||
\fI\-s\fR
|
||||
option. Default:
|
||||
\fI15\fR
|
||||
.TP 3n
|
||||
\-\-metalink\-version=VERSION
|
||||
The version of file to download.
|
||||
|
||||
.TP
|
||||
\fB\-\-metalink\-language\fR=\fILANGUAGE\fR
|
||||
.TP 3n
|
||||
\-\-metalink\-language=LANGUAGE
|
||||
The language of file to download.
|
||||
|
||||
.TP
|
||||
\fB\-\-metalink\-os\fR=\fIOS\fR
|
||||
.TP 3n
|
||||
\-\-metalink\-os=OS
|
||||
The operating system the file is targeted.
|
||||
|
||||
.TP
|
||||
\fB\-\-follow\-metalink\fR=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
|
||||
|
||||
.TP
|
||||
\fB\-v\fR, \fB\-\-version\fR
|
||||
.TP 3n
|
||||
\-\-metalink\-location=LOCATION
|
||||
The location of the prefered server.
|
||||
.TP 3n
|
||||
\-\-follow\-metalink=true|false
|
||||
Setting this option to
|
||||
\fIfalse\fR
|
||||
prevents aria2 to enter Metalink mode even if the filename of downloaded file ends with .metalink. Default:
|
||||
\fItrue\fR
|
||||
.TP 3n
|
||||
\-v, \-\-version
|
||||
Print the version number and exit.
|
||||
|
||||
.TP
|
||||
\fB\-h\fR, \fB\-\-help\fR
|
||||
.TP 3n
|
||||
\-h, \-\-help
|
||||
Print this message and exit.
|
||||
|
||||
.TP
|
||||
\fIURL\fR
|
||||
You can specify multiple URLs. All URLs must point to the same file
|
||||
or downloading fails.
|
||||
|
||||
.TP
|
||||
\fIFILE\fR
|
||||
.TP 3n
|
||||
URL
|
||||
You can specify multiple URLs. All URLs must point to the same file or downloading fails.
|
||||
.TP 3n
|
||||
FILE
|
||||
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.
|
||||
|
||||
.SH REPORTING BUGS
|
||||
.P
|
||||
Report bugs to <tujikawa at users dot sourceforge dot net>
|
||||
|
||||
.SH COPYRIGHT
|
||||
.P
|
||||
Copyright (C) 2006 Tatsuhiro Tsujikawa
|
||||
|
||||
.P
|
||||
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.
|
||||
|
||||
.P
|
||||
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.
|
||||
|
||||
.P
|
||||
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
|
||||
|
||||
|
||||
.\" man code generated by txt2tags 2.3 (http://txt2tags.sf.net)
|
||||
.\" cmdline: txt2tags -t man aria2c.t2t
|
||||
|
||||
\fI\-T\fR
|
||||
option. This arguments are ignored if you specify
|
||||
\fI\-\-select\-file\fR
|
||||
option.
|
||||
.SH "EXAMPLES"
|
||||
.TP 3n
|
||||
Download a file by 1 connection
|
||||
aria2c http://AAA.BBB.CCC/file.zip
|
||||
.TP 3n
|
||||
Download a file by 2 connections
|
||||
aria2c \-s 2 http://AAA.BBB.CCC/file.zip
|
||||
.TP 3n
|
||||
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
|
||||
.TP 3n
|
||||
You can mix up different protocols
|
||||
aria2c http://AAA.BBB.CCC/file.zip ftp://DDD.EEE.FFF/GGG/file.zip
|
||||
.TP 3n
|
||||
Download a torrent
|
||||
aria2c \-o test.torrent http://AAA.BBB.CCC/file.torrent
|
||||
.TP 3n
|
||||
Download a torrent using local .torrent file
|
||||
aria2c \-T test.torrent
|
||||
.TP 3n
|
||||
Download only selected files
|
||||
aria2c \-T test.torrent dir/file1.zip dir/file2.zip
|
||||
.TP 3n
|
||||
Print file listing of .torrent file
|
||||
aria2c \-T test.torrent \-S
|
||||
.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.
|
||||
|
||||
PACKAGE = aria2c
|
||||
VERSION = 0.9.0
|
||||
VERSION = 0.10.0
|
||||
|
||||
SHELL = /bin/sh
|
||||
|
||||
|
|
|
@ -103,17 +103,16 @@ int32_t AbstractDiskWriter::readDataInternal(char* data, int32_t len) {
|
|||
return read(fd, data, len);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
string AbstractDiskWriter::messageDigest(int64_t offset, int64_t length,
|
||||
const MessageDigestContext::DigestAlgo& algo)
|
||||
{
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
MessageDigestContext ctx(algo);
|
||||
ctx.digestInit();
|
||||
|
||||
int32_t BUFSIZE = 16*1024;
|
||||
char buf[BUFSIZE];
|
||||
for(int64_t i = 0; i < length/BUFSIZE; i++) {
|
||||
int32_t rs = readData(buf, BUFSIZE, offset);
|
||||
if(BUFSIZE != readData(buf, BUFSIZE, offset)) {
|
||||
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;
|
||||
if(r > 0) {
|
||||
int32_t rs = readData(buf, r, offset);
|
||||
if(r != readData(buf, r, offset)) {
|
||||
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);
|
||||
|
||||
return Util::toHex(hashValue, 20);
|
||||
#else
|
||||
return "";
|
||||
#endif // ENABLE_MESSAGE_DIGEST
|
||||
}
|
||||
#endif // ENABLE_MESSAGE_DIGEST
|
||||
|
||||
void AbstractDiskWriter::seek(int64_t offset) {
|
||||
if(offset != lseek(fd, offset, SEEK_SET)) {
|
||||
|
|
|
@ -64,8 +64,10 @@ public:
|
|||
|
||||
virtual void openExistingFile(const string& filename);
|
||||
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
virtual string messageDigest(int64_t offset, int64_t length,
|
||||
const MessageDigestContext::DigestAlgo& algo);
|
||||
#endif // ENABLE_MESSAGE_DIGEST
|
||||
|
||||
virtual void writeData(const char* data, int32_t len, int64_t offset);
|
||||
|
||||
|
|
|
@ -444,7 +444,7 @@ bool BitfieldMan::unsetBit(int32_t index) {
|
|||
return b;
|
||||
}
|
||||
|
||||
bool BitfieldMan::isAllBitSet() const {
|
||||
bool BitfieldMan::isFilteredAllBitSet() const {
|
||||
if(filterEnabled) {
|
||||
for(int32_t i = 0; i < bitfieldLength; ++i) {
|
||||
if((bitfield[i]&filterBitfield[i]) != filterBitfield[i]) {
|
||||
|
@ -453,17 +453,21 @@ bool BitfieldMan::isAllBitSet() const {
|
|||
}
|
||||
return true;
|
||||
} else {
|
||||
for(int32_t i = 0; i < bitfieldLength-1; ++i) {
|
||||
if(bitfield[i] != 0xff) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
unsigned char b = ~((128 >> (blocks-1)%8)-1);
|
||||
if(bitfield[bitfieldLength-1] != b) {
|
||||
return isAllBitSet();
|
||||
}
|
||||
}
|
||||
|
||||
bool BitfieldMan::isAllBitSet() const {
|
||||
for(int32_t i = 0; i < bitfieldLength-1; ++i) {
|
||||
if(bitfield[i] != 0xff) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
unsigned char b = ~((128 >> (blocks-1)%8)-1);
|
||||
if(bitfield[bitfieldLength-1] != b) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BitfieldMan::isBitSetInternal(const unsigned char* bitfield, int32_t index) const {
|
||||
|
|
|
@ -184,6 +184,8 @@ public:
|
|||
/**
|
||||
* affected by filter
|
||||
*/
|
||||
bool isFilteredAllBitSet() const;
|
||||
|
||||
bool isAllBitSet() const;
|
||||
|
||||
const unsigned char* getBitfield() const { return bitfield; }
|
||||
|
|
|
@ -56,15 +56,15 @@ public:
|
|||
|
||||
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 getPieceHash(int index) const = 0;
|
||||
virtual string getPieceHash(int32_t index) 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;
|
||||
|
||||
|
@ -76,9 +76,9 @@ public:
|
|||
|
||||
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
|
||||
|
|
|
@ -60,9 +60,14 @@ public:
|
|||
// position is ignored
|
||||
virtual void writeData(const char* data, int32_t len, int64_t position = 0);
|
||||
virtual int readData(char* data, int32_t len, int64_t position);
|
||||
|
||||
// not implemented yet
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
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 {
|
||||
return buf;
|
||||
|
|
|
@ -36,9 +36,9 @@
|
|||
#define _D_CHECKSUM_H_
|
||||
|
||||
#include "common.h"
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
#include "messageDigest.h"
|
||||
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
class Checksum {
|
||||
private:
|
||||
string md;
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "TimeA2.h"
|
||||
#include "message.h"
|
||||
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
void ChunkChecksumValidator::validateSameLengthChecksum(BitfieldMan* bitfieldMan,
|
||||
int32_t index,
|
||||
const string& expectedChecksum,
|
||||
|
@ -118,3 +119,4 @@ void ChunkChecksumValidator::validate(BitfieldMan* bitfieldMan,
|
|||
fileAllocationMonitor->setCurrentValue(bitfieldMan->getTotalLength());
|
||||
fileAllocationMonitor->showProgress();
|
||||
}
|
||||
#endif // ENABLE_MESSAGE_DIGEST
|
||||
|
|
|
@ -38,12 +38,15 @@
|
|||
#include "common.h"
|
||||
#include "DiskWriter.h"
|
||||
#include "BitfieldMan.h"
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
#include "messageDigest.h"
|
||||
#endif // ENABLE_MESSAGE_DIGEST
|
||||
#include "LogFactory.h"
|
||||
#include "FileAllocationMonitor.h"
|
||||
#include "NullFileAllocationMonitor.h"
|
||||
|
||||
class ChunkChecksumValidator {
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
private:
|
||||
DiskWriterHandle diskWriter;
|
||||
|
||||
|
@ -89,6 +92,7 @@ public:
|
|||
void setFileAllocationMonitor(const FileAllocationMonitorHandle& monitor) {
|
||||
this->fileAllocationMonitor = monitor;
|
||||
}
|
||||
#endif // ENABLE_MESSAGE_DIGEST
|
||||
};
|
||||
|
||||
#endif // _D_CHUNK_CHECKSUM_VALIDATOR_H_
|
||||
|
|
|
@ -84,7 +84,7 @@ bool DefaultBtAnnounce::isStoppedAnnounceReady() {
|
|||
|
||||
bool DefaultBtAnnounce::isCompletedAnnounceReady() {
|
||||
return (trackers == 0 &&
|
||||
pieceStorage->downloadFinished() &&
|
||||
pieceStorage->allDownloadFinished() &&
|
||||
announceList.countCompletedAllowedTier());
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ string DefaultBtAnnounce::getAnnounceUrl() {
|
|||
// If download completed before "started" event is sent to a tracker,
|
||||
// we change the event to something else to prevent us from
|
||||
// sending "completed" event.
|
||||
if(pieceStorage->downloadFinished() &&
|
||||
if(pieceStorage->allDownloadFinished() &&
|
||||
announceList.getEvent() == AnnounceTier::STARTED) {
|
||||
announceList.setEvent(AnnounceTier::STARTED_AFTER_COMPLETION);
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ const unsigned char* DefaultBtContext::getInfoHash() const {
|
|||
return infoHash;
|
||||
}
|
||||
|
||||
int DefaultBtContext::getInfoHashLength() const {
|
||||
int32_t DefaultBtContext::getInfoHashLength() const {
|
||||
return INFO_HASH_LENGTH;
|
||||
}
|
||||
|
||||
|
@ -78,14 +78,14 @@ void DefaultBtContext::clear() {
|
|||
}
|
||||
|
||||
void DefaultBtContext::extractPieceHash(const unsigned char* hashData,
|
||||
int hashDataLength,
|
||||
int hashLength) {
|
||||
int32_t hashDataLength,
|
||||
int32_t hashLength) {
|
||||
assert(hashDataLength > 0);
|
||||
assert(hashLength > 0);
|
||||
int numPieces = hashDataLength/hashLength;
|
||||
int32_t numPieces = hashDataLength/hashLength;
|
||||
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],
|
||||
hashLength));
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ void DefaultBtContext::load(const string& torrentFile) {
|
|||
// retrieve infoHash
|
||||
ShaVisitor v;
|
||||
infoDic->accept(&v);
|
||||
int len;
|
||||
int32_t len;
|
||||
v.getHash(infoHash, len);
|
||||
infoHashString = Util::toHex(infoHash, INFO_HASH_LENGTH);
|
||||
// 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) {
|
||||
return "";
|
||||
}
|
||||
return pieceHashes.at(index);
|
||||
}
|
||||
|
||||
long long int DefaultBtContext::getTotalLength() const {
|
||||
int64_t DefaultBtContext::getTotalLength() const {
|
||||
return totalLength;
|
||||
}
|
||||
|
||||
|
@ -235,10 +235,10 @@ string DefaultBtContext::getName() const {
|
|||
return name;
|
||||
}
|
||||
|
||||
int DefaultBtContext::getPieceLength() const {
|
||||
int32_t DefaultBtContext::getPieceLength() const {
|
||||
return pieceLength;
|
||||
}
|
||||
|
||||
int DefaultBtContext::getNumPieces() const {
|
||||
int32_t DefaultBtContext::getNumPieces() const {
|
||||
return numPieces;
|
||||
}
|
||||
|
|
|
@ -51,17 +51,17 @@ private:
|
|||
PieceHashes pieceHashes;
|
||||
FileEntries fileEntries;
|
||||
FILE_MODE fileMode;
|
||||
long long int totalLength;
|
||||
int pieceLength;
|
||||
int64_t totalLength;
|
||||
int32_t pieceLength;
|
||||
string name;
|
||||
int numPieces;
|
||||
int32_t numPieces;
|
||||
string peerId;
|
||||
AnnounceTiers announceTiers;
|
||||
|
||||
void clear();
|
||||
void extractPieceHash(const unsigned char* hashData,
|
||||
int hashDataLength,
|
||||
int hashLength);
|
||||
int32_t hashDataLength,
|
||||
int32_t hashLength);
|
||||
void extractFileEntries(Dictionary* infoDic,
|
||||
const string& defaultName);
|
||||
void extractAnnounce(Data* announceData);
|
||||
|
@ -72,18 +72,18 @@ private:
|
|||
|
||||
virtual const unsigned char* getInfoHash() const;
|
||||
|
||||
virtual int getInfoHashLength() const;
|
||||
virtual int32_t getInfoHashLength() const;
|
||||
|
||||
virtual string getInfoHashAsString() const;
|
||||
|
||||
virtual string getPieceHash(int index) const;
|
||||
virtual string getPieceHash(int32_t index) const;
|
||||
|
||||
virtual const Strings& getPieceHashes() const
|
||||
{
|
||||
return pieceHashes;
|
||||
}
|
||||
|
||||
virtual long long int getTotalLength() const;
|
||||
virtual int64_t getTotalLength() const;
|
||||
|
||||
virtual FILE_MODE getFileMode() const;
|
||||
|
||||
|
@ -95,9 +95,9 @@ private:
|
|||
|
||||
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() {
|
||||
if(peerId == "") {
|
||||
|
|
|
@ -78,7 +78,7 @@ void DefaultBtInteractive::doPostHandshakeProcessing() {
|
|||
|
||||
void DefaultBtInteractive::addBitfieldMessageToQueue() {
|
||||
if(peer->isFastExtensionEnabled()) {
|
||||
if(pieceStorage->downloadFinished()) {
|
||||
if(pieceStorage->allDownloadFinished()) {
|
||||
dispatcher->addMessageToQueue(messageFactory->createHaveAllMessage());
|
||||
} else if(pieceStorage->getCompletedLength() > 0) {
|
||||
dispatcher->addMessageToQueue(messageFactory->createBitfieldMessage());
|
||||
|
@ -122,7 +122,7 @@ void DefaultBtInteractive::checkHave() {
|
|||
pieceStorage->getAdvertisedPieceIndexes(cuid, haveCheckPoint);
|
||||
haveCheckPoint.reset();
|
||||
if(indexes.size() >= 20) {
|
||||
if(peer->isFastExtensionEnabled() && pieceStorage->downloadFinished()) {
|
||||
if(peer->isFastExtensionEnabled() && pieceStorage->allDownloadFinished()) {
|
||||
dispatcher->addMessageToQueue(messageFactory->createHaveAllMessage());
|
||||
} else {
|
||||
dispatcher->addMessageToQueue(messageFactory->createBitfieldMessage());
|
||||
|
|
|
@ -68,9 +68,14 @@ public:
|
|||
peer(0),
|
||||
maxUploadSpeedLimit(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);
|
||||
|
||||
|
|
|
@ -231,7 +231,7 @@ void DefaultPieceStorage::completePiece(const PieceHandle& piece) {
|
|||
if(!isEndGame()) {
|
||||
reduceUsedPieces(100);
|
||||
}
|
||||
if(downloadFinished()) {
|
||||
if(allDownloadFinished()) {
|
||||
return;
|
||||
}
|
||||
bitfieldMan->setBit(piece->getIndex());
|
||||
|
@ -240,7 +240,9 @@ void DefaultPieceStorage::completePiece(const PieceHandle& piece) {
|
|||
diskAdaptor->onDownloadComplete();
|
||||
if(isSelectiveDownloadingMode()) {
|
||||
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 {
|
||||
logger->info(_("The download was complete."));
|
||||
}
|
||||
|
@ -326,6 +328,11 @@ void DefaultPieceStorage::clearFileFilter() {
|
|||
|
||||
// not unittested
|
||||
bool DefaultPieceStorage::downloadFinished() {
|
||||
return bitfieldMan->isFilteredAllBitSet();
|
||||
}
|
||||
|
||||
// not unittested
|
||||
bool DefaultPieceStorage::allDownloadFinished() {
|
||||
return bitfieldMan->isAllBitSet();
|
||||
}
|
||||
|
||||
|
|
|
@ -120,6 +120,8 @@ public:
|
|||
|
||||
virtual bool downloadFinished();
|
||||
|
||||
virtual bool allDownloadFinished();
|
||||
|
||||
virtual void setBitfield(const unsigned char* bitfield,
|
||||
int bitfieldLength);
|
||||
|
||||
|
|
|
@ -38,7 +38,9 @@
|
|||
#include "common.h"
|
||||
#include "FileEntry.h"
|
||||
#include "Logger.h"
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
#include "messageDigest.h"
|
||||
#endif // ENABLE_MESSAGE_DIGEST
|
||||
|
||||
class DiskAdaptor {
|
||||
protected:
|
||||
|
@ -61,8 +63,10 @@ public:
|
|||
|
||||
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,
|
||||
const MessageDigestContext::DigestAlgo& algo) = 0;
|
||||
#endif // ENABLE_MESSAGE_DIGEST
|
||||
|
||||
virtual void onDownloadComplete() = 0;
|
||||
|
||||
|
|
|
@ -91,9 +91,10 @@ public:
|
|||
virtual int readData(unsigned char* data, int32_t len, int64_t position) {
|
||||
return readData((char*)data, len, position);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
virtual string messageDigest(int64_t offset, int64_t length,
|
||||
const MessageDigestContext::DigestAlgo& algo) = 0;
|
||||
#endif // ENABLE_MESSAGE_DIGEST
|
||||
};
|
||||
|
||||
typedef SharedHandle<DiskWriter> DiskWriterHandle;
|
||||
|
|
|
@ -108,9 +108,11 @@ bool DownloadCommand::executeInternal(Segment& segment) {
|
|||
if(te != NULL) te->end();
|
||||
logger->info(MSG_DOWNLOAD_COMPLETED, cuid);
|
||||
e->segmentMan->completeSegment(cuid, segment);
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
if(e->option->get(PREF_REALTIME_CHUNK_CHECKSUM) == V_TRUE) {
|
||||
e->segmentMan->tryChunkChecksumValidation(segment);
|
||||
}
|
||||
#endif // ENABLE_MESSAGE_DIGEST
|
||||
// this unit is going to download another segment.
|
||||
return prepareForNextSegment(segment);
|
||||
} else {
|
||||
|
|
|
@ -182,7 +182,7 @@ bool FtpNegotiationCommand::recvSize() {
|
|||
if(status != 213) {
|
||||
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);
|
||||
}
|
||||
if(!e->segmentMan->downloadStarted) {
|
||||
|
|
|
@ -148,7 +148,7 @@ bool HttpResponseCommand::handleDefaultEncoding(const HttpHeader& headers) {
|
|||
}
|
||||
|
||||
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);
|
||||
}
|
||||
e->segmentMan->isSplittable = !(size == 0);
|
||||
|
|
|
@ -182,7 +182,8 @@ SRCS += Metalinker.cc Metalinker.h\
|
|||
MetalinkResource.cc MetalinkResource.h\
|
||||
MetalinkProcessor.h\
|
||||
Xml2MetalinkProcessor.cc Xml2MetalinkProcessor.h\
|
||||
MetalinkRequestInfo.cc MetalinkRequestInfo.h
|
||||
MetalinkRequestInfo.cc MetalinkRequestInfo.h\
|
||||
MetalinkChunkChecksum.h
|
||||
endif # ENABLE_METALINK
|
||||
|
||||
noinst_LIBRARIES = libaria2c.a
|
||||
|
@ -190,9 +191,9 @@ libaria2c_a_SOURCES = $(SRCS)
|
|||
aria2c_LDADD = libaria2c.a @LIBINTL@ @ALLOCA@ @LIBGNUTLS_LIBS@\
|
||||
@LIBGCRYPT_LIBS@ @OPENSSL_LIBS@ @XML_LIBS@ @LIBARES_LIBS@\
|
||||
@LIBCARES_LIBS@
|
||||
aria2c_LDFLAGS = -pg
|
||||
#aria2c_LDFLAGS = -pg
|
||||
AM_CPPFLAGS = -Wall\
|
||||
-I../lib -I../intl -I$(top_srcdir)/intl\
|
||||
@LIBGNUTLS_CFLAGS@ @LIBGCRYPT_CFLAGS@ @OPENSSL_CFLAGS@ @XML_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@ MetalinkProcessor.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
|
||||
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 \
|
||||
MetalinkResource.cc MetalinkResource.h MetalinkProcessor.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_BITTORRENT_TRUE@am__objects_2 = Data.$(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@\
|
||||
@LIBCARES_LIBS@
|
||||
|
||||
aria2c_LDFLAGS = -pg
|
||||
#aria2c_LDFLAGS = -pg
|
||||
AM_CPPFLAGS = -Wall\
|
||||
-I../lib -I../intl -I$(top_srcdir)/intl\
|
||||
@LIBGNUTLS_CFLAGS@ @LIBGCRYPT_CFLAGS@ @OPENSSL_CFLAGS@ @XML_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
|
||||
|
||||
|
|
|
@ -36,15 +36,19 @@
|
|||
#define _D_METALINK_CHUNK_CHECKSUM_H_
|
||||
|
||||
#include "common.h"
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
#include "messageDigest.h"
|
||||
#endif // ENABLE_MESSAGE_DIGEST
|
||||
|
||||
class MetalinkChunkChecksum {
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
public:
|
||||
MessageDigestContext::DigestAlgo digestAlgo;
|
||||
int32_t pieceLength;
|
||||
Strings pieceHashes;
|
||||
public:
|
||||
MetalinkChunkChecksum():pieceLength(0) {}
|
||||
#endif // ENABLE_MESSAGE_DIGEST
|
||||
};
|
||||
|
||||
typedef SharedHandle<MetalinkChunkChecksum> MetalinkChunkChecksumHandle;
|
||||
|
|
|
@ -36,7 +36,13 @@
|
|||
#include "Util.h"
|
||||
#include <algorithm>
|
||||
|
||||
MetalinkEntry::MetalinkEntry():chunkChecksum(0) {}
|
||||
MetalinkEntry::MetalinkEntry():
|
||||
size(0)
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
,
|
||||
chunkChecksum(0)
|
||||
#endif // ENABLE_MESSAGE_DIGEST
|
||||
{}
|
||||
|
||||
MetalinkEntry::~MetalinkEntry() {}
|
||||
|
||||
|
|
|
@ -51,7 +51,9 @@ public:
|
|||
Checksum checksum;
|
||||
public:
|
||||
MetalinkResources resources;
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
MetalinkChunkChecksumHandle chunkChecksum;
|
||||
#endif // ENABLE_MESSAGE_DIGEST
|
||||
public:
|
||||
MetalinkEntry();
|
||||
~MetalinkEntry();
|
||||
|
@ -64,6 +66,9 @@ public:
|
|||
this->os = metalinkEntry.os;
|
||||
this->size = metalinkEntry.size;
|
||||
this->checksum = metalinkEntry.checksum;
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
this->chunkChecksum = metalinkEntry.chunkChecksum;
|
||||
#endif // ENABLE_MESSAGE_DIGEST
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
|
|
@ -97,8 +97,8 @@ RequestInfos MetalinkRequestInfo::execute() {
|
|||
if(entry->resources.size() == 0) {
|
||||
continue;
|
||||
}
|
||||
logger->notice("Metalink: Queueing %s for download.",
|
||||
entry->filename.c_str());
|
||||
logger->info("Metalink: Queueing %s for download.",
|
||||
entry->filename.c_str());
|
||||
MetalinkResources::iterator itr =
|
||||
find_if(entry->resources.begin(),
|
||||
entry->resources.end(),
|
||||
|
@ -122,10 +122,14 @@ RequestInfos MetalinkRequestInfo::execute() {
|
|||
urls.push_back((*itr)->url);
|
||||
}
|
||||
UrlRequestInfoHandle reqInfo = new UrlRequestInfo(urls, maxConnection, op);
|
||||
reqInfo->setFilename(entry->filename);
|
||||
reqInfo->setTotalLength(entry->size);
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
reqInfo->setChecksum(checksum);
|
||||
reqInfo->setDigestAlgo(entry->chunkChecksum->digestAlgo);
|
||||
reqInfo->setChunkChecksumLength(entry->chunkChecksum->pieceLength);
|
||||
reqInfo->setChunkChecksums(entry->chunkChecksum->pieceHashes);
|
||||
#endif // ENABLE_MESSAGE_DIGEST
|
||||
nextReqInfos.push_front(reqInfo);
|
||||
}
|
||||
} catch(RecoverableException* ex) {
|
||||
|
|
|
@ -47,14 +47,18 @@ PeerConnection::PeerConnection(int32_t cuid,
|
|||
:cuid(cuid),
|
||||
socket(socket),
|
||||
option(op),
|
||||
logger(logger),
|
||||
logger(LogFactory::getInstance()),
|
||||
resbufLength(0),
|
||||
currentPayloadLength(0),
|
||||
lenbufLength(0) {
|
||||
logger = LogFactory::getInstance();
|
||||
lenbufLength(0)
|
||||
{
|
||||
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 writtenLength = 0;
|
||||
|
|
|
@ -101,9 +101,20 @@ public:
|
|||
virtual void setFileFilter(const Integers& fileIndexes) = 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;
|
||||
|
||||
/**
|
||||
* Returns true if all files have downloaded.
|
||||
* The file filter is ignored.
|
||||
*/
|
||||
virtual bool allDownloadFinished() = 0;
|
||||
|
||||
/**
|
||||
* Initializes DiskAdaptor.
|
||||
* TODO add better documentation here.
|
||||
|
|
|
@ -40,24 +40,28 @@
|
|||
#include "prefs.h"
|
||||
#include "LogFactory.h"
|
||||
#include "BitfieldManFactory.h"
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
#include "ChunkChecksumValidator.h"
|
||||
#endif // ENABLE_MESSAGE_DIGEST
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
SegmentMan::SegmentMan():bitfield(0),
|
||||
SegmentMan::SegmentMan():logger(LogFactory::getInstance()),
|
||||
bitfield(0),
|
||||
totalSize(0),
|
||||
isSplittable(true),
|
||||
downloadStarted(false),
|
||||
dir("."),
|
||||
errors(0),
|
||||
diskWriter(0),
|
||||
diskWriter(0)
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
,
|
||||
chunkHashLength(0),
|
||||
digestAlgo(DIGEST_ALGO_SHA1)
|
||||
{
|
||||
logger = LogFactory::getInstance();
|
||||
}
|
||||
#endif // ENABLE_MESSAGE_DIGEST
|
||||
{}
|
||||
|
||||
SegmentMan::~SegmentMan() {
|
||||
delete bitfield;
|
||||
|
@ -450,7 +454,7 @@ bool SegmentMan::fileExists() {
|
|||
|
||||
bool SegmentMan::shouldCancelDownloadForSafety() {
|
||||
return fileExists() && !segmentFileExists() &&
|
||||
option->get(PREF_FORCE_TRUNCATE) != V_TRUE;
|
||||
option->get(PREF_ALLOW_OVERWRITE) != V_TRUE;
|
||||
}
|
||||
|
||||
void SegmentMan::markAllPiecesDone()
|
||||
|
@ -460,6 +464,7 @@ void SegmentMan::markAllPiecesDone()
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
void SegmentMan::checkIntegrity()
|
||||
{
|
||||
logger->notice("Validating file %s",
|
||||
|
@ -470,12 +475,16 @@ void SegmentMan::checkIntegrity()
|
|||
v.setFileAllocationMonitor(FileAllocationMonitorFactory::getFactory()->createNewMonitor());
|
||||
v.validate(bitfield, pieceHashes, chunkHashLength);
|
||||
}
|
||||
#endif // ENABLE_MESSAGE_DIGEST
|
||||
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
bool SegmentMan::isChunkChecksumValidationReady() const {
|
||||
return bitfield &&
|
||||
((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)
|
||||
{
|
||||
if(!isChunkChecksumValidationReady()) {
|
||||
|
@ -527,3 +536,4 @@ void SegmentMan::tryChunkChecksumValidation(const Segment& segment)
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_MESSAGE_DIGEST
|
||||
|
|
|
@ -157,9 +157,11 @@ public:
|
|||
DiskWriterHandle diskWriter;
|
||||
Requests reserved;
|
||||
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
Strings pieceHashes;
|
||||
int32_t chunkHashLength;
|
||||
MessageDigestContext::DigestAlgo digestAlgo;
|
||||
#endif // ENABLE_MESSAGE_DIGEST
|
||||
|
||||
SegmentMan();
|
||||
~SegmentMan();
|
||||
|
@ -283,12 +285,13 @@ public:
|
|||
|
||||
void markAllPiecesDone();
|
||||
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
void checkIntegrity();
|
||||
|
||||
void tryChunkChecksumValidation(const Segment& segment);
|
||||
|
||||
bool isChunkChecksumValidationReady() const;
|
||||
|
||||
#endif // ENABLE_MESSAGE_DIGEST
|
||||
};
|
||||
|
||||
#endif // _D_SEGMENT_MAN_H_
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "SeedCriteria.h"
|
||||
#include "BtContext.h"
|
||||
#include "PeerStorage.h"
|
||||
#include "PieceStorage.h"
|
||||
#include "BtRuntime.h"
|
||||
#include "BtRegistry.h"
|
||||
|
||||
|
@ -46,12 +47,14 @@ private:
|
|||
double ratio;
|
||||
BtContextHandle btContext;
|
||||
PeerStorageHandle peerStorage;
|
||||
PieceStorageHandle pieceStorage;
|
||||
BtRuntimeHandle btRuntime;
|
||||
public:
|
||||
ShareRatioSeedCriteria(double ratio, const BtContextHandle& btContext)
|
||||
:ratio(ratio),
|
||||
btContext(btContext),
|
||||
peerStorage(PEER_STORAGE(btContext)),
|
||||
pieceStorage(PIECE_STORAGE(btContext)),
|
||||
btRuntime(BT_RUNTIME(btContext)) {}
|
||||
|
||||
virtual ~ShareRatioSeedCriteria() {}
|
||||
|
@ -66,7 +69,7 @@ public:
|
|||
long long int allTimeUploadLength =
|
||||
btRuntime->getUploadLengthAtStartup()+stat.getSessionUploadLength();
|
||||
return ratio <=
|
||||
((double)allTimeUploadLength)/btContext->getTotalLength();
|
||||
((double)allTimeUploadLength)/pieceStorage->getCompletedLength();
|
||||
}
|
||||
|
||||
void setRatio(double ratio) {
|
||||
|
|
|
@ -59,7 +59,7 @@ void TorrentDownloadEngine::setBtContext(const BtContextHandle& btContext) {
|
|||
|
||||
void TorrentDownloadEngine::onEndOfRun() {
|
||||
pieceStorage->getDiskAdaptor()->closeFile();
|
||||
if(pieceStorage->downloadFinished()) {
|
||||
if(pieceStorage->allDownloadFinished()) {
|
||||
btProgressInfoFile->removeFile();
|
||||
} else {
|
||||
btProgressInfoFile->save();
|
||||
|
|
|
@ -67,21 +67,25 @@ RequestInfos TorrentRequestInfo::execute() {
|
|||
// load .aria2 file if it exists.
|
||||
BT_PROGRESS_INFO_FILE(btContext)->load();
|
||||
PIECE_STORAGE(btContext)->getDiskAdaptor()->openExistingFile();
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
if(op->get(PREF_CHECK_INTEGRITY) == V_TRUE) {
|
||||
PIECE_STORAGE(btContext)->checkIntegrity();
|
||||
}
|
||||
#endif // ENABLE_MESSAGE_DIGEST
|
||||
} else {
|
||||
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,
|
||||
PIECE_STORAGE(btContext)->getDiskAdaptor()->getFilePath().c_str(),
|
||||
BT_PROGRESS_INFO_FILE(btContext)->getFilename().c_str());
|
||||
} else {
|
||||
PIECE_STORAGE(btContext)->getDiskAdaptor()->openExistingFile();
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
if(op->get(PREF_CHECK_INTEGRITY) == V_TRUE) {
|
||||
PIECE_STORAGE(btContext)->markAllPiecesDone();
|
||||
PIECE_STORAGE(btContext)->checkIntegrity();
|
||||
}
|
||||
#endif // ENABLE_MESSAGE_DIGEST
|
||||
}
|
||||
} else {
|
||||
PIECE_STORAGE(btContext)->getDiskAdaptor()->initAndOpenFile();
|
||||
|
|
|
@ -155,31 +155,39 @@ RequestInfos UrlRequestInfo::execute() {
|
|||
op->get(PREF_REFERER),
|
||||
op->getAsInt(PREF_SPLIT)));
|
||||
|
||||
HeadResult hr = getHeadResult();
|
||||
|
||||
if(fail) {
|
||||
return RequestInfos();
|
||||
HeadResult hr;
|
||||
if(filename.size() && totalLength > 0) {
|
||||
hr.filename = filename;
|
||||
hr.totalLength = totalLength;
|
||||
} else {
|
||||
hr = getHeadResult();
|
||||
if(fail) {
|
||||
return RequestInfos();
|
||||
}
|
||||
|
||||
logger->info("Head result: filename=%s, total length=%s",
|
||||
hr.filename.c_str(), Util::ullitos(hr.totalLength, true).c_str());
|
||||
}
|
||||
|
||||
logger->info("Head result: filename=%s, total length=%s",
|
||||
hr.filename.c_str(), Util::ullitos(hr.totalLength, true).c_str());
|
||||
|
||||
adjustRequestSize(requests, reserved, maxConnections);
|
||||
|
||||
SharedHandle<ConsoleDownloadEngine> e(DownloadEngineFactory::newConsoleEngine(op, requests, reserved));
|
||||
e->segmentMan->filename = hr.filename;
|
||||
e->segmentMan->totalSize = hr.totalLength;
|
||||
e->segmentMan->downloadStarted = true;
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
e->segmentMan->digestAlgo = digestAlgo;
|
||||
e->segmentMan->chunkHashLength = chunkChecksumLength;
|
||||
e->segmentMan->pieceHashes = chunkChecksums;
|
||||
#endif // ENABLE_MESSAGE_DIGEST
|
||||
|
||||
if(e->segmentMan->segmentFileExists()) {
|
||||
e->segmentMan->load();
|
||||
e->segmentMan->diskWriter->openExistingFile(e->segmentMan->getFilePath());
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
if(e->option->get(PREF_CHECK_INTEGRITY) == V_TRUE) {
|
||||
e->segmentMan->checkIntegrity();
|
||||
}
|
||||
#endif // ENABLE_MESSAGE_DIGEST
|
||||
} else {
|
||||
if(e->segmentMan->shouldCancelDownloadForSafety()) {
|
||||
throw new FatalException(EX_FILE_ALREADY_EXISTS,
|
||||
|
@ -190,8 +198,10 @@ RequestInfos UrlRequestInfo::execute() {
|
|||
e->segmentMan->totalSize);
|
||||
if(e->segmentMan->fileExists() && e->option->get(PREF_CHECK_INTEGRITY) == V_TRUE) {
|
||||
e->segmentMan->diskWriter->openExistingFile(e->segmentMan->getFilePath());
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
e->segmentMan->markAllPiecesDone();
|
||||
e->segmentMan->checkIntegrity();
|
||||
#endif // ENABLE_MESSAGE_DIGEST
|
||||
} else {
|
||||
e->segmentMan->diskWriter->initAndOpenFile(e->segmentMan->getFilePath(),
|
||||
e->segmentMan->totalSize);
|
||||
|
|
|
@ -50,9 +50,13 @@ class UrlRequestInfo : public RequestInfo {
|
|||
private:
|
||||
Strings urls;
|
||||
int maxConnections;
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
MessageDigestContext::DigestAlgo digestAlgo;
|
||||
int32_t chunkChecksumLength;
|
||||
Strings chunkChecksums;
|
||||
#endif // ENABLE_MESSAGE_DIGEST
|
||||
string filename;
|
||||
int64_t totalLength;
|
||||
|
||||
RequestInfo* createNextRequestInfo() const;
|
||||
void adjustRequestSize(Requests& requests,
|
||||
|
@ -65,24 +69,41 @@ public:
|
|||
RequestInfo(op),
|
||||
urls(urls),
|
||||
maxConnections(maxConnections),
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
digestAlgo(DIGEST_ALGO_SHA1),
|
||||
chunkChecksumLength(0) {}
|
||||
chunkChecksumLength(0),
|
||||
#endif // ENABLE_MESSAGE_DIGEST
|
||||
totalLength(0) {}
|
||||
|
||||
virtual ~UrlRequestInfo() {}
|
||||
|
||||
virtual RequestInfos execute();
|
||||
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
void setDigestAlgo(const MessageDigestContext::DigestAlgo& algo) {
|
||||
this->digestAlgo = algo;
|
||||
}
|
||||
#endif // ENABLE_MESSAGE_DIGEST
|
||||
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
void setChunkChecksumLength(int32_t chunkChecksumLength) {
|
||||
this->chunkChecksumLength = chunkChecksumLength;
|
||||
}
|
||||
#endif // ENABLE_MESSAGE_DIGEST
|
||||
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
void setChunkChecksums(const Strings& 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;
|
||||
|
|
|
@ -99,7 +99,12 @@ MetalinkEntryHandle Xml2MetalinkProcessor::getEntry(const string& xpath) {
|
|||
MetalinkEntryHandle entry(new MetalinkEntry());
|
||||
|
||||
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->language = Util::trim(xpathContent(xpath+"/m:language"));
|
||||
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->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
|
||||
for(int index = 1; 1; index++) {
|
||||
MetalinkResourceHandle resource(getResource(xpath+"/m:resources/m:url["+Util::itos(index)+"]"));
|
||||
|
@ -130,11 +141,11 @@ MetalinkEntryHandle Xml2MetalinkProcessor::getEntry(const string& xpath) {
|
|||
return entry;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
MetalinkChunkChecksumHandle Xml2MetalinkProcessor::getPieceHash(const string& xpath,
|
||||
int64_t totalSize)
|
||||
{
|
||||
MetalinkChunkChecksumHandle chunkChecksum = new MetalinkChunkChecksum();
|
||||
chunkChecksum->digestAlgo = DIGEST_ALGO_SHA1;
|
||||
|
||||
xmlXPathObjectPtr result = xpathEvaluation(xpath);
|
||||
if(!result) {
|
||||
|
@ -143,7 +154,17 @@ MetalinkChunkChecksumHandle Xml2MetalinkProcessor::getPieceHash(const string& xp
|
|||
xmlNodeSetPtr nodeSet = result->nodesetval;
|
||||
xmlNodePtr node = nodeSet->nodeTab[0];
|
||||
chunkChecksum->pieceLength = STRTOLL(Util::trim(xmlAttribute(node, "length")).c_str());
|
||||
string algo = Util::trim(xmlAttribute(node, "type"));
|
||||
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 =
|
||||
(totalSize+chunkChecksum->pieceLength-1)/chunkChecksum->pieceLength;
|
||||
|
@ -156,6 +177,7 @@ MetalinkChunkChecksumHandle Xml2MetalinkProcessor::getPieceHash(const string& xp
|
|||
}
|
||||
return chunkChecksum;
|
||||
}
|
||||
#endif // ENABLE_MESSAGE_DIGEST
|
||||
|
||||
MetalinkResourceHandle Xml2MetalinkProcessor::getResource(const string& xpath) {
|
||||
xmlXPathObjectPtr result = xpathEvaluation(xpath);
|
||||
|
@ -240,3 +262,13 @@ string Xml2MetalinkProcessor::xpathContent(const string& xpath) {
|
|||
xmlXPathFreeObject(result);
|
||||
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);
|
||||
MetalinkResourceHandle getResource(const string& xpath);
|
||||
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
MetalinkChunkChecksumHandle getPieceHash(const string& xpath,
|
||||
int64_t totalSize);
|
||||
#endif // ENABLE_MESSAGE_DIGEST
|
||||
|
||||
xmlXPathObjectPtr xpathEvaluation(const string& xpath);
|
||||
string xpathContent(const string& xpath);
|
||||
string xmlAttribute(xmlNodePtr node, const string& attrName);
|
||||
string xmlContent(xmlNodePtr node);
|
||||
bool xpathExists(const string& xpath);
|
||||
|
||||
void release();
|
||||
public:
|
||||
|
|
|
@ -52,11 +52,6 @@
|
|||
# define _(String) (String)
|
||||
#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 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"
|
||||
" This may take some time depending on the size of\n"
|
||||
" file.\n"
|
||||
" Default: 'none'") << endl;
|
||||
cout << _(" --force-truncate=true|false If this option set to false, aria2 doesn't download\n"
|
||||
" file which already exists in file system but\n"
|
||||
" its corresponding .aria2 file doesn't exist.\n"
|
||||
" Set this option to true if you want to download\n"
|
||||
" file all over again.\n"
|
||||
" Default: none") << endl;
|
||||
cout << _(" --allow-overwrite=true|false If this option set to false, aria2 doesn't\n"
|
||||
" download a file which already exists in the file\n"
|
||||
" system but its corresponding .aria2 file doesn't\n"
|
||||
" exist.\n"
|
||||
" 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
|
||||
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"
|
||||
|
@ -343,9 +354,9 @@ int main(int argc, char* argv[]) {
|
|||
op->put(PREF_STARTUP_IDLE_TIME, "10");
|
||||
op->put(PREF_TRACKER_MAX_TRIES, "10");
|
||||
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_CHECK_INTEGRITY, V_TRUE);
|
||||
op->put(PREF_CHECK_INTEGRITY, V_FALSE);
|
||||
while(1) {
|
||||
int optIndex = 0;
|
||||
int lopt;
|
||||
|
@ -375,7 +386,9 @@ int main(int argc, char* argv[]) {
|
|||
{ "lowest-speed-limit", required_argument, &lopt, 200 },
|
||||
{ "max-download-limit", required_argument, &lopt, 201 },
|
||||
{ "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
|
||||
{ "torrent-file", required_argument, NULL, 'T' },
|
||||
{ "listen-port", required_argument, &lopt, 15 },
|
||||
|
@ -384,7 +397,7 @@ int main(int argc, char* argv[]) {
|
|||
{ "no-preallocation", no_argument, &lopt, 18 },
|
||||
{ "direct-file-mapping", required_argument, &lopt, 19 },
|
||||
// TODO remove upload-limit.
|
||||
{ "upload-limit", required_argument, &lopt, 20 },
|
||||
//{ "upload-limit", required_argument, &lopt, 20 },
|
||||
{ "select-file", required_argument, &lopt, 21 },
|
||||
{ "seed-time", required_argument, &lopt, 22 },
|
||||
{ "seed-ratio", required_argument, &lopt, 23 },
|
||||
|
@ -417,7 +430,6 @@ int main(int argc, char* argv[]) {
|
|||
if(proxy.first.empty() || proxy.second.empty() ||
|
||||
!(0 < port && port <= 65535)) {
|
||||
cerr << _("unrecognized proxy format") << endl;
|
||||
showUsage();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
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);
|
||||
if(!(0 <= wait && wait <= 60)) {
|
||||
cerr << _("retry-wait must be between 0 and 60.") << endl;
|
||||
showUsage();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
op->put(PREF_RETRY_WAIT, Util::itos(wait));
|
||||
|
@ -470,7 +481,6 @@ int main(int argc, char* argv[]) {
|
|||
op->put(PREF_FTP_TYPE, optarg);
|
||||
} else {
|
||||
cerr << _("ftp-type must be either 'binary' or 'ascii'.") << endl;
|
||||
showUsage();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
break;
|
||||
|
@ -479,7 +489,6 @@ int main(int argc, char* argv[]) {
|
|||
op->put(PREF_FTP_VIA_HTTP_PROXY, optarg);
|
||||
} else {
|
||||
cerr << _("ftp-via-http-proxy must be either 'get' or 'tunnel'.") << endl;
|
||||
showUsage();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
break;
|
||||
|
@ -487,7 +496,6 @@ int main(int argc, char* argv[]) {
|
|||
long long int size = getRealSize(optarg);
|
||||
if(size < 1024) {
|
||||
cerr << _("min-segment-size invalid") << endl;
|
||||
showUsage();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
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);
|
||||
} else {
|
||||
cerr << _("http-proxy-method must be either 'get' or 'tunnel'.") << endl;
|
||||
showUsage();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
break;
|
||||
|
@ -506,7 +513,6 @@ int main(int argc, char* argv[]) {
|
|||
int listenPort = (int)strtol(optarg, NULL, 10);
|
||||
if(!(1024 <= listenPort && listenPort <= 65535)) {
|
||||
cerr << _("listen-port must be between 1024 and 65535.") << endl;
|
||||
showUsage();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
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);
|
||||
} else {
|
||||
cerr << _("follow-torrent must be either 'true' or 'false'.") << endl;
|
||||
showUsage();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
break;
|
||||
|
@ -533,23 +538,9 @@ int main(int argc, char* argv[]) {
|
|||
op->put(PREF_DIRECT_FILE_MAPPING, V_FALSE);
|
||||
} else {
|
||||
cerr << _("direct-file-mapping must be either 'true' or 'false'.") << endl;
|
||||
showUsage();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
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:
|
||||
op->put(PREF_SELECT_FILE, optarg);
|
||||
break;
|
||||
|
@ -557,7 +548,6 @@ int main(int argc, char* argv[]) {
|
|||
int seedTime = (int)strtol(optarg, NULL, 10);
|
||||
if(seedTime < 0) {
|
||||
cerr << _("seed-time must be greater than or equal to 0.") << endl;
|
||||
showUsage();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
op->put(PREF_SEED_TIME, Util::itos(seedTime));
|
||||
|
@ -567,7 +557,6 @@ int main(int argc, char* argv[]) {
|
|||
double ratio = (int)strtod(optarg, NULL);
|
||||
if(ratio < 0.0) {
|
||||
cerr << _("seed-ratio must be greater than or equal to 0.0.") << endl;
|
||||
showUsage();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
op->put(PREF_SEED_RATIO, optarg);
|
||||
|
@ -577,7 +566,6 @@ int main(int argc, char* argv[]) {
|
|||
int limit = getRealSize(optarg);
|
||||
if(limit < 0) {
|
||||
cerr << _("max-upload-limit must be greater than or equal to 0") << endl;
|
||||
showUsage();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
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);
|
||||
} else {
|
||||
cerr << _("follow-metalink must be either 'true' or 'false'.") << endl;
|
||||
showUsage();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
break;
|
||||
|
@ -610,7 +597,6 @@ int main(int argc, char* argv[]) {
|
|||
int limit = getRealSize(optarg);
|
||||
if(limit < 0) {
|
||||
cerr << _("lowest-speed-limit must be greater than or equal to 0") << endl;
|
||||
showUsage();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
op->put(PREF_LOWEST_SPEED_LIMIT, Util::itos(limit));
|
||||
|
@ -620,7 +606,6 @@ int main(int argc, char* argv[]) {
|
|||
int limit = getRealSize(optarg);
|
||||
if(limit < 0) {
|
||||
cerr << _("max-download-limit must be greater than or equal to 0") << endl;
|
||||
showUsage();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
op->put(PREF_MAX_DOWNLOAD_LIMIT, Util::itos(limit));
|
||||
|
@ -628,14 +613,36 @@ int main(int argc, char* argv[]) {
|
|||
}
|
||||
case 202: {
|
||||
if(string(optarg) == "true") {
|
||||
op->put(PREF_FORCE_TRUNCATE, V_TRUE);
|
||||
op->put(PREF_ALLOW_OVERWRITE, V_TRUE);
|
||||
} else if(string(optarg) == "false") {
|
||||
op->put(PREF_FORCE_TRUNCATE, V_FALSE);
|
||||
op->put(PREF_ALLOW_OVERWRITE, V_FALSE);
|
||||
} else {
|
||||
cerr << _("force-true must be either 'true' or 'false'.") << endl;
|
||||
showUsage();
|
||||
cerr << _("allow-overwrite must be either 'true' or 'false'.") << endl;
|
||||
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;
|
||||
|
@ -660,7 +667,6 @@ int main(int argc, char* argv[]) {
|
|||
int split = (int)strtol(optarg, NULL, 10);
|
||||
if(!(1 <= split && split <= 5)) {
|
||||
cerr << _("split must be between 1 and 5.") << endl;
|
||||
showUsage();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
op->put(PREF_SPLIT, Util::itos(split));
|
||||
|
@ -672,7 +678,6 @@ int main(int argc, char* argv[]) {
|
|||
op->put(PREF_TIMEOUT, Util::itos(timeout));
|
||||
} else {
|
||||
cerr << _("timeout must be between 1 and 600") << endl;
|
||||
showUsage();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
break;
|
||||
|
@ -681,7 +686,6 @@ int main(int argc, char* argv[]) {
|
|||
int retries = (int)strtol(optarg, NULL, 10);
|
||||
if(retries < 0) {
|
||||
cerr << _("max-tries invalid") << endl;
|
||||
showUsage();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
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);
|
||||
if(metalinkServers <= 0) {
|
||||
cerr << _("metalink-servers must be greater than 0.") << endl;
|
||||
showUsage();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
op->put(PREF_METALINK_SERVERS, Util::itos(metalinkServers));
|
||||
|
@ -715,7 +718,6 @@ int main(int argc, char* argv[]) {
|
|||
op->put(PREF_FILE_ALLOCATION, value);
|
||||
} else {
|
||||
cerr << _("file-allocation must be either 'none' or 'prealloc'.") << endl;
|
||||
showUsage();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
break;
|
||||
|
@ -727,14 +729,12 @@ int main(int argc, char* argv[]) {
|
|||
showUsage();
|
||||
exit(EXIT_SUCCESS);
|
||||
default:
|
||||
showUsage();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
if(!op->defined(PREF_TORRENT_FILE) && !op->defined(PREF_METALINK_FILE)) {
|
||||
if(optind == argc) {
|
||||
cerr << _("specify at least one URL") << endl;
|
||||
showUsage();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@
|
|||
#define EX_SOCKET_SEND _("Failed to send 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_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_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")
|
||||
|
|
|
@ -85,7 +85,7 @@
|
|||
#define PREF_FILE_ALLOCATION "file_allocation"
|
||||
# define V_PREALLOC "prealloc"
|
||||
// value: true | false
|
||||
#define PREF_FORCE_TRUNCATE "force_truncate"
|
||||
#define PREF_ALLOW_OVERWRITE "allow_overwrite"
|
||||
// value: true | false
|
||||
#define PREF_REALTIME_CHUNK_CHECKSUM "realtime_chunk_checksum"
|
||||
// value: true | false
|
||||
|
|
|
@ -42,12 +42,12 @@ CPPUNIT_TEST_SUITE_REGISTRATION( BitfieldManTest );
|
|||
|
||||
void BitfieldManTest::testGetBlockSize() {
|
||||
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);
|
||||
CPPUNIT_ASSERT_EQUAL((uint32_t)1024, bt2.getBlockLength(9));
|
||||
CPPUNIT_ASSERT_EQUAL((uint32_t)1, bt2.getBlockLength(10));
|
||||
CPPUNIT_ASSERT_EQUAL((uint32_t)0, bt2.getBlockLength(11));
|
||||
CPPUNIT_ASSERT_EQUAL(1024, bt2.getBlockLength(9));
|
||||
CPPUNIT_ASSERT_EQUAL(1, bt2.getBlockLength(10));
|
||||
CPPUNIT_ASSERT_EQUAL(0, bt2.getBlockLength(11));
|
||||
}
|
||||
|
||||
void BitfieldManTest::testGetFirstMissingUnusedIndex() {
|
||||
|
@ -84,7 +84,7 @@ void BitfieldManTest::testIsAllBitSet() {
|
|||
}
|
||||
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.isAllBitSet());
|
||||
|
@ -122,7 +122,7 @@ void BitfieldManTest::testFilter() {
|
|||
index = btman.getMissingUnusedIndex(peerBt, sizeof(peerBt));
|
||||
btman.setUseBit(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
|
||||
btman.clearAllBit();
|
||||
|
@ -141,13 +141,13 @@ void BitfieldManTest::testFilter() {
|
|||
index = btman.getMissingUnusedIndex(peerBt, sizeof(peerBt));
|
||||
btman.setUseBit(index);
|
||||
CPPUNIT_ASSERT_EQUAL(-1, index);
|
||||
CPPUNIT_ASSERT_EQUAL((uint64_t)4, btman.getFilteredTotalLength());
|
||||
CPPUNIT_ASSERT(btman.isAllBitSet());
|
||||
CPPUNIT_ASSERT_EQUAL((int64_t)4, btman.getFilteredTotalLength());
|
||||
CPPUNIT_ASSERT(btman.isFilteredAllBitSet());
|
||||
|
||||
BitfieldMan btman2(2, 31);
|
||||
btman2.addFilter(0, 31);
|
||||
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::setIntParam(&msg[5], 12345);
|
||||
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());
|
||||
|
||||
// case: payload size is wrong
|
||||
|
|
|
@ -35,9 +35,9 @@ void BtBitfieldMessageTest::testCreate() {
|
|||
memset(bitfield, 0xff, sizeof(bitfield));
|
||||
memcpy(&msg[5], bitfield, sizeof(bitfield));
|
||||
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_EQUAL((uint32_t)2, pm->getBitfieldLength());
|
||||
CPPUNIT_ASSERT_EQUAL(2, pm->getBitfieldLength());
|
||||
// case: payload size is wrong
|
||||
try {
|
||||
unsigned char msg[5];
|
||||
|
|
|
@ -39,13 +39,13 @@ public:
|
|||
public:
|
||||
int32_t index;
|
||||
int32_t begin;
|
||||
uint32_t length;
|
||||
int32_t length;
|
||||
public:
|
||||
MockBtMessageDispatcher2():index(0),
|
||||
begin(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->begin = begin;
|
||||
this->length = length;
|
||||
|
@ -65,10 +65,10 @@ void BtCancelMessageTest::testCreate() {
|
|||
PeerMessageUtil::setIntParam(&msg[9], 256);
|
||||
PeerMessageUtil::setIntParam(&msg[13], 1024);
|
||||
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(256, pm->getBegin());
|
||||
CPPUNIT_ASSERT_EQUAL((uint32_t)1024, pm->getLength());
|
||||
CPPUNIT_ASSERT_EQUAL(1024, pm->getLength());
|
||||
|
||||
// case: payload size is wrong
|
||||
try {
|
||||
|
|
|
@ -79,7 +79,7 @@ void BtChokeMessageTest::testCreate() {
|
|||
unsigned char msg[5];
|
||||
PeerMessageUtil::createPeerMessageString(msg, sizeof(msg), 1, 0);
|
||||
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
|
||||
try {
|
||||
|
|
|
@ -52,8 +52,8 @@ void BtHandshakeMessageTest::testCreate() {
|
|||
unsigned char msg[68];
|
||||
createHandshakeMessageData(msg);
|
||||
BtHandshakeMessageHandle message = BtHandshakeMessage::create(&msg[0], sizeof(msg));
|
||||
CPPUNIT_ASSERT_EQUAL((uint8_t)UINT8_MAX, message->getId());
|
||||
CPPUNIT_ASSERT_EQUAL((uint8_t)19, message->getPstrlen());
|
||||
CPPUNIT_ASSERT_EQUAL((int8_t)INT8_MAX, message->getId());
|
||||
CPPUNIT_ASSERT_EQUAL((int8_t)19, message->getPstrlen());
|
||||
CPPUNIT_ASSERT_EQUAL(Util::toHex((const unsigned char*)BTPSTR.c_str(), BTPSTR.size()),
|
||||
Util::toHex(message->getPstr(), BtHandshakeMessage::PSTR_LENGTH));
|
||||
CPPUNIT_ASSERT_EQUAL(string("0000000000000004"),
|
||||
|
|
|
@ -29,7 +29,7 @@ void BtHaveAllMessageTest::testCreate() {
|
|||
unsigned char msg[5];
|
||||
PeerMessageUtil::createPeerMessageString(msg, sizeof(msg), 1, 14);
|
||||
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
|
||||
try {
|
||||
|
|
|
@ -32,7 +32,7 @@ void BtHaveMessageTest::testCreate() {
|
|||
PeerMessageUtil::createPeerMessageString(msg, sizeof(msg), 5, 4);
|
||||
PeerMessageUtil::setIntParam(&msg[5], 12345);
|
||||
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());
|
||||
|
||||
// case: payload size is wrong
|
||||
|
|
|
@ -31,7 +31,7 @@ void BtHaveNoneMessageTest::testCreate() {
|
|||
unsigned char msg[5];
|
||||
PeerMessageUtil::createPeerMessageString(msg, sizeof(msg), 1, 15);
|
||||
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
|
||||
try {
|
||||
|
|
|
@ -33,7 +33,7 @@ void BtInterestedMessageTest::testCreate() {
|
|||
unsigned char msg[5];
|
||||
PeerMessageUtil::createPeerMessageString(msg, sizeof(msg), 1, 2);
|
||||
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
|
||||
try {
|
||||
|
|
|
@ -25,7 +25,8 @@ void BtKeepAliveMessageTest::testGetMessage() {
|
|||
char msg[4];
|
||||
memset(msg, 0, sizeof(msg));
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ void BtNotInterestedMessageTest::testCreate() {
|
|||
unsigned char msg[5];
|
||||
PeerMessageUtil::createPeerMessageString(msg, sizeof(msg), 1, 3);
|
||||
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
|
||||
try {
|
||||
|
|
|
@ -48,9 +48,9 @@ public:
|
|||
public:
|
||||
int32_t index;
|
||||
int32_t begin;
|
||||
uint32_t length;
|
||||
int32_t length;
|
||||
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:
|
||||
virtual BtMessageHandle createRejectMessage(int32_t index,
|
||||
int32_t begin,
|
||||
uint32_t length) {
|
||||
int32_t length) {
|
||||
MockBtMessage2Handle msg = new MockBtMessage2(index, begin, length);
|
||||
return msg;
|
||||
}
|
||||
|
@ -111,11 +111,11 @@ void BtPieceMessageTest::testCreate() {
|
|||
PeerMessageUtil::setIntParam(&msg[9], 256);
|
||||
memcpy(&msg[13], data, sizeof(data));
|
||||
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(256, pm->getBegin());
|
||||
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
|
||||
try {
|
||||
|
@ -174,7 +174,7 @@ void BtPieceMessageTest::testChokingEvent_allowedFastEnabled() {
|
|||
MockBtMessage2* rej = (MockBtMessage2*)btMessageDispatcher->messageQueue.front().get();
|
||||
CPPUNIT_ASSERT_EQUAL(1, rej->index);
|
||||
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() {
|
||||
|
@ -259,7 +259,7 @@ void BtPieceMessageTest::testCancelSendingPieceEvent_allowedFastEnabled() {
|
|||
MockBtMessage2* rej = (MockBtMessage2*)btMessageDispatcher->messageQueue.front().get();
|
||||
CPPUNIT_ASSERT_EQUAL(1, rej->index);
|
||||
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() {
|
||||
|
|
|
@ -29,8 +29,8 @@ void BtPortMessageTest::testCreate() {
|
|||
PeerMessageUtil::createPeerMessageString(msg, sizeof(msg), 3, 9);
|
||||
PeerMessageUtil::setShortIntParam(&msg[5], 12345);
|
||||
BtPortMessageHandle pm = BtPortMessage::create(&msg[4], 3);
|
||||
CPPUNIT_ASSERT_EQUAL((uint8_t)9, pm->getId());
|
||||
CPPUNIT_ASSERT_EQUAL((uint16_t)12345, pm->getPort());
|
||||
CPPUNIT_ASSERT_EQUAL((int8_t)9, pm->getId());
|
||||
CPPUNIT_ASSERT_EQUAL((int16_t)12345, pm->getPort());
|
||||
|
||||
// case: payload size is wrong
|
||||
try {
|
||||
|
|
|
@ -38,7 +38,7 @@ public:
|
|||
}
|
||||
|
||||
virtual RequestSlot getOutstandingRequest(int32_t index, int32_t begin,
|
||||
uint32_t length) {
|
||||
int32_t length) {
|
||||
if(slot.getIndex() == index && slot.getBegin() == begin &&
|
||||
slot.getLength() == length) {
|
||||
return slot;
|
||||
|
@ -97,10 +97,10 @@ void BtRejectMessageTest::testCreate() {
|
|||
PeerMessageUtil::setIntParam(&msg[9], 256);
|
||||
PeerMessageUtil::setIntParam(&msg[13], 1024);
|
||||
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(256, pm->getBegin());
|
||||
CPPUNIT_ASSERT_EQUAL((uint32_t)1024, pm->getLength());
|
||||
CPPUNIT_ASSERT_EQUAL(1024, pm->getLength());
|
||||
|
||||
// case: payload size is wrong
|
||||
try {
|
||||
|
|
|
@ -55,9 +55,9 @@ public:
|
|||
string type;
|
||||
int32_t index;
|
||||
int32_t begin;
|
||||
uint32_t length;
|
||||
int32_t length;
|
||||
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;
|
||||
|
@ -65,13 +65,13 @@ public:
|
|||
class MockBtMessageFactory2 : public MockBtMessageFactory {
|
||||
public:
|
||||
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);
|
||||
return btMsg;
|
||||
}
|
||||
|
||||
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);
|
||||
return btMsg;
|
||||
}
|
||||
|
@ -131,10 +131,10 @@ void BtRequestMessageTest::testCreate() {
|
|||
PeerMessageUtil::setIntParam(&msg[9], 256);
|
||||
PeerMessageUtil::setIntParam(&msg[13], 1024);
|
||||
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(256, pm->getBegin());
|
||||
CPPUNIT_ASSERT_EQUAL((uint32_t)1024, pm->getLength());
|
||||
CPPUNIT_ASSERT_EQUAL(1024, pm->getLength());
|
||||
|
||||
// case: payload size is wrong
|
||||
try {
|
||||
|
@ -176,7 +176,7 @@ void BtRequestMessageTest::testDoReceivedAction_hasPieceAndAmNotChoking() {
|
|||
CPPUNIT_ASSERT_EQUAL(string("piece"), pieceMsg->type);
|
||||
CPPUNIT_ASSERT_EQUAL(1, pieceMsg->index);
|
||||
CPPUNIT_ASSERT_EQUAL(16, pieceMsg->begin);
|
||||
CPPUNIT_ASSERT_EQUAL((uint32_t)32, pieceMsg->length);
|
||||
CPPUNIT_ASSERT_EQUAL(32, pieceMsg->length);
|
||||
}
|
||||
|
||||
void BtRequestMessageTest::testDoReceivedAction_hasPieceAndAmChokingAndFastExtensionEnabled() {
|
||||
|
@ -189,7 +189,7 @@ void BtRequestMessageTest::testDoReceivedAction_hasPieceAndAmChokingAndFastExten
|
|||
CPPUNIT_ASSERT_EQUAL(string("reject"), pieceMsg->type);
|
||||
CPPUNIT_ASSERT_EQUAL(1, pieceMsg->index);
|
||||
CPPUNIT_ASSERT_EQUAL(16, pieceMsg->begin);
|
||||
CPPUNIT_ASSERT_EQUAL((uint32_t)32, pieceMsg->length);
|
||||
CPPUNIT_ASSERT_EQUAL(32, pieceMsg->length);
|
||||
}
|
||||
|
||||
void BtRequestMessageTest::testDoReceivedAction_hasPieceAndAmChokingAndFastExtensionDisabled() {
|
||||
|
@ -210,7 +210,7 @@ void BtRequestMessageTest::testDoReceivedAction_doesntHavePieceAndFastExtensionE
|
|||
CPPUNIT_ASSERT_EQUAL(string("reject"), pieceMsg->type);
|
||||
CPPUNIT_ASSERT_EQUAL(2, pieceMsg->index);
|
||||
CPPUNIT_ASSERT_EQUAL(16, pieceMsg->begin);
|
||||
CPPUNIT_ASSERT_EQUAL((uint32_t)32, pieceMsg->length);
|
||||
CPPUNIT_ASSERT_EQUAL(32, pieceMsg->length);
|
||||
}
|
||||
|
||||
void BtRequestMessageTest::testDoReceivedAction_doesntHavePieceAndFastExtensionDisabled() {
|
||||
|
|
|
@ -30,7 +30,7 @@ void BtSuggestPieceMessageTest::testCreate() {
|
|||
PeerMessageUtil::createPeerMessageString(msg, sizeof(msg), 5, 13);
|
||||
PeerMessageUtil::setIntParam(&msg[5], 12345);
|
||||
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());
|
||||
|
||||
// case: payload size is wrong
|
||||
|
|
|
@ -32,7 +32,7 @@ void BtUnchokeMessageTest::testCreate() {
|
|||
unsigned char msg[5];
|
||||
PeerMessageUtil::createPeerMessageString(msg, sizeof(msg), 1, 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
|
||||
try {
|
||||
|
|
|
@ -28,7 +28,7 @@ void ConsoleFileAllocationMonitorTest::testShowProgress() {
|
|||
monitor.setCurrentValue(0);
|
||||
|
||||
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.showProgress();
|
||||
}
|
||||
|
|
|
@ -119,7 +119,7 @@ public:
|
|||
class MockBtMessageFactory2 : public MockBtMessageFactory {
|
||||
public:
|
||||
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();
|
||||
btMsg->type = "cancel";
|
||||
return btMsg;
|
||||
|
@ -370,7 +370,7 @@ void DefaultBtMessageDispatcherTest::testIsSendingInProgress() {
|
|||
void DefaultBtMessageDispatcherTest::testCountOutstandingRequest() {
|
||||
RequestSlot slot(0, 0, MY_PIECE_LENGTH, 0);
|
||||
btMessageDispatcher->addOutstandingRequest(slot);
|
||||
CPPUNIT_ASSERT_EQUAL((uint32_t)1, btMessageDispatcher->countOutstandingRequest());
|
||||
CPPUNIT_ASSERT_EQUAL(1, btMessageDispatcher->countOutstandingRequest());
|
||||
}
|
||||
|
||||
void DefaultBtMessageDispatcherTest::testIsOutstandingRequest() {
|
||||
|
|
|
@ -8,11 +8,11 @@ class MockBtContext : public BtContext {
|
|||
private:
|
||||
unsigned char infoHash[20];
|
||||
Strings pieceHashes;
|
||||
long long int totalLength;
|
||||
int64_t totalLength;
|
||||
FILE_MODE fileMode;
|
||||
string name;
|
||||
int pieceLength;
|
||||
int numPieces;
|
||||
int32_t pieceLength;
|
||||
int32_t numPieces;
|
||||
unsigned char peerId[20];
|
||||
FileEntries fileEntries;
|
||||
AnnounceTiers announceTiers;
|
||||
|
@ -31,7 +31,7 @@ public:
|
|||
memcpy(this->infoHash, infoHash, sizeof(this->infoHash));
|
||||
}
|
||||
|
||||
virtual int getInfoHashLength() const {
|
||||
virtual int32_t getInfoHashLength() const {
|
||||
return sizeof(infoHash);
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ public:
|
|||
return Util::toHex(infoHash, sizeof(infoHash));
|
||||
}
|
||||
|
||||
virtual string getPieceHash(int index) const {
|
||||
virtual string getPieceHash(int32_t index) const {
|
||||
return pieceHashes.at(index);
|
||||
}
|
||||
|
||||
|
@ -51,11 +51,11 @@ public:
|
|||
pieceHashes.push_back(pieceHash);
|
||||
}
|
||||
|
||||
virtual long long int getTotalLength() const {
|
||||
virtual int64_t getTotalLength() const {
|
||||
return totalLength;
|
||||
}
|
||||
|
||||
void setTotalLength(long long int length) {
|
||||
void setTotalLength(int64_t length) {
|
||||
this->totalLength = length;
|
||||
}
|
||||
|
||||
|
@ -93,19 +93,19 @@ public:
|
|||
this->name = name;
|
||||
}
|
||||
|
||||
virtual int getPieceLength() const {
|
||||
virtual int32_t getPieceLength() const {
|
||||
return pieceLength;
|
||||
}
|
||||
|
||||
void setPieceLength(int pieceLength) {
|
||||
void setPieceLength(int32_t pieceLength) {
|
||||
this->pieceLength = pieceLength;
|
||||
}
|
||||
|
||||
virtual int getNumPieces() const {
|
||||
virtual int32_t getNumPieces() const {
|
||||
return numPieces;
|
||||
}
|
||||
|
||||
void setNumPieces(int numPieces) {
|
||||
void setNumPieces(int32_t numPieces) {
|
||||
this->numPieces = numPieces;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ private:
|
|||
bool sendingInProgress;
|
||||
bool invalidate;
|
||||
bool uploading;
|
||||
uint8_t id;
|
||||
int8_t id;
|
||||
public:
|
||||
MockBtMessage() {}
|
||||
|
||||
|
@ -72,11 +72,11 @@ public:
|
|||
this->uploading = flag;
|
||||
}
|
||||
|
||||
virtual uint8_t getId() {
|
||||
virtual int8_t getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
void setId(uint8_t id) {
|
||||
void setId(int8_t id) {
|
||||
this->id = id;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ public:
|
|||
|
||||
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) {}
|
||||
|
||||
|
@ -35,11 +35,11 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
virtual uint32_t countMessageInQueue() {
|
||||
virtual int32_t countMessageInQueue() {
|
||||
return messageQueue.size();
|
||||
}
|
||||
|
||||
virtual uint32_t countOutstandingRequest() {
|
||||
virtual int32_t countOutstandingRequest() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ public:
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,12 +10,12 @@ public:
|
|||
virtual ~MockBtMessageFactory() {}
|
||||
|
||||
virtual BtMessageHandle
|
||||
createBtMessage(const unsigned char* msg, uint32_t msgLength) {
|
||||
createBtMessage(const unsigned char* msg, int32_t msgLength) {
|
||||
return BtMessageHandle(0);
|
||||
};
|
||||
|
||||
virtual BtMessageHandle
|
||||
createHandshakeMessage(const unsigned char* msg, uint32_t msgLength) {
|
||||
createHandshakeMessage(const unsigned char* msg, int32_t msgLength) {
|
||||
return BtMessageHandle(0);
|
||||
}
|
||||
|
||||
|
@ -31,12 +31,12 @@ public:
|
|||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ public:
|
|||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,9 +19,9 @@ public:
|
|||
|
||||
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;
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
|
||||
class MockPieceStorage : public PieceStorage {
|
||||
private:
|
||||
long long int totalLength;
|
||||
long long int filteredTotalLength;
|
||||
long long int completedLength;
|
||||
long long int filteredCompletedLength;
|
||||
int64_t totalLength;
|
||||
int64_t filteredTotalLength;
|
||||
int64_t completedLength;
|
||||
int64_t filteredCompletedLength;
|
||||
BitfieldMan* bitfieldMan;
|
||||
bool selectiveDownloadingMode;
|
||||
bool endGame;
|
||||
|
@ -43,35 +43,35 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
virtual long long int getTotalLength() {
|
||||
virtual int64_t getTotalLength() {
|
||||
return totalLength;
|
||||
}
|
||||
|
||||
void setTotalLength(long long int totalLength) {
|
||||
void setTotalLength(int64_t totalLength) {
|
||||
this->totalLength = totalLength;
|
||||
}
|
||||
|
||||
virtual long long int getFilteredTotalLength() {
|
||||
virtual int64_t getFilteredTotalLength() {
|
||||
return filteredTotalLength;
|
||||
}
|
||||
|
||||
void setFilteredTotalLength(long long int totalLength) {
|
||||
void setFilteredTotalLength(int64_t totalLength) {
|
||||
this->filteredTotalLength = totalLength;
|
||||
}
|
||||
|
||||
virtual long long int getCompletedLength() {
|
||||
virtual int64_t getCompletedLength() {
|
||||
return completedLength;
|
||||
}
|
||||
|
||||
void setCompletedLength(long long int completedLength) {
|
||||
void setCompletedLength(int64_t completedLength) {
|
||||
this->completedLength = completedLength;
|
||||
}
|
||||
|
||||
virtual long long int getFilteredCompletedLength() {
|
||||
virtual int64_t getFilteredCompletedLength() {
|
||||
return filteredCompletedLength;
|
||||
}
|
||||
|
||||
void setFilteredCompletedLength(long long int completedLength) {
|
||||
void setFilteredCompletedLength(int64_t completedLength) {
|
||||
this->filteredCompletedLength = completedLength;
|
||||
}
|
||||
|
||||
|
@ -85,6 +85,10 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
virtual bool allDownloadFinished() {
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual void initStorage() {}
|
||||
|
||||
virtual const unsigned char* getBitfield() {
|
||||
|
@ -92,11 +96,11 @@ public:
|
|||
}
|
||||
|
||||
virtual void setBitfield(const unsigned char* bitfield,
|
||||
int bitfieldLength) {
|
||||
int32_t bitfieldLength) {
|
||||
bitfieldMan->setBitfield(bitfield, bitfieldLength);
|
||||
}
|
||||
|
||||
virtual int getBitfieldLength() {
|
||||
virtual int32_t getBitfieldLength() {
|
||||
return bitfieldMan->getBitfieldLength();
|
||||
}
|
||||
|
||||
|
@ -130,22 +134,22 @@ public:
|
|||
this->diskAdaptor = adaptor;
|
||||
}
|
||||
|
||||
virtual int getPieceLength(int index) {
|
||||
virtual int32_t getPieceLength(int32_t index) {
|
||||
return pieceLengthList.at(index);
|
||||
}
|
||||
|
||||
void addPieceLengthList(int length) {
|
||||
void addPieceLengthList(int32_t 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) {
|
||||
return Integers();
|
||||
}
|
||||
|
||||
virtual void removeAdvertisedPiece(int elapsed) {}
|
||||
virtual void removeAdvertisedPiece(int32_t elapsed) {}
|
||||
|
||||
virtual void markAllPiecesDone() {}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "ShareRatioSeedCriteria.h"
|
||||
#include "MockBtContext.h"
|
||||
#include "MockPeerStorage.h"
|
||||
#include "MockPieceStorage.h"
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
class ShareRatioSeedCriteriaTest:public CppUnit::TestFixture {
|
||||
|
@ -36,6 +37,10 @@ void ShareRatioSeedCriteriaTest::testEvaluate() {
|
|||
PeerStorageHandle peerStorage(mockPeerStorage);
|
||||
BtRegistry::registerPeerStorage(infoHashString, peerStorage);
|
||||
|
||||
MockPieceStorage* mockPieceStorage = new MockPieceStorage();
|
||||
mockPieceStorage->setCompletedLength(1000000);
|
||||
BtRegistry::registerPieceStorage(infoHashString, PieceStorageHandle(mockPieceStorage));
|
||||
|
||||
ShareRatioSeedCriteria cri(1.0, btContext);
|
||||
CPPUNIT_ASSERT(cri.evaluate());
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ class UtilTest:public CppUnit::TestFixture {
|
|||
CPPUNIT_TEST(testToUpper);
|
||||
CPPUNIT_TEST(testToLower);
|
||||
CPPUNIT_TEST(testUrldecode);
|
||||
CPPUNIT_TEST(testCountBit);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
private:
|
||||
|
||||
|
@ -42,6 +43,7 @@ public:
|
|||
void testToUpper();
|
||||
void testToLower();
|
||||
void testUrldecode();
|
||||
void testCountBit();
|
||||
};
|
||||
|
||||
|
||||
|
@ -282,3 +284,8 @@ void UtilTest::testUrldecode() {
|
|||
string src6 = "%2f";
|
||||
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();
|
||||
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("en-US"), entry1->language);
|
||||
CPPUNIT_ASSERT_EQUAL(string("Linux-x86"), entry1->os);
|
||||
|
@ -57,14 +59,15 @@ void Xml2MetalinkProcessorTest::testParseFile() {
|
|||
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("ja-JP"), entry2->language);
|
||||
CPPUNIT_ASSERT_EQUAL(string("Linux-m68k"), entry2->os);
|
||||
CPPUNIT_ASSERT_EQUAL(string("4c255b0ed130f5ea880f0aa061c3da0487e251cc"),
|
||||
entry2->checksum.getMessageDigest());
|
||||
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"),
|
||||
entry2->chunkChecksum->pieceHashes.at(0));
|
||||
CPPUNIT_ASSERT_EQUAL(string("fecf8bc9a1647505fe16746f94e97a477597dbf3"),
|
||||
|
@ -72,7 +75,7 @@ void Xml2MetalinkProcessorTest::testParseFile() {
|
|||
|
||||
CPPUNIT_ASSERT(DIGEST_ALGO_SHA1 == entry2->checksum.getDigestAlgo());
|
||||
} catch(Exception* e) {
|
||||
cerr << e->getMsg() << endl;
|
||||
CPPUNIT_FAIL(e->getMsg());
|
||||
delete e;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,8 +28,8 @@
|
|||
<hash type="md5">92296e19c406d77d21bda0bb944eac46</hash>
|
||||
<hash type="sha1">4c255b0ed130f5ea880f0aa061c3da0487e251cc</hash>
|
||||
<pieces length="262144" type="sha1">
|
||||
<hash pieces="0">179463a88d79cbf0b1923991708aead914f26142</hash>
|
||||
<hash pieces="1">fecf8bc9a1647505fe16746f94e97a477597dbf3</hash>
|
||||
<hash piece="0">179463a88d79cbf0b1923991708aead914f26142</hash>
|
||||
<hash piece="1">fecf8bc9a1647505fe16746f94e97a477597dbf3</hash>
|
||||
</pieces>
|
||||
</verification>
|
||||
<resources>
|
||||
|
|
Loading…
Reference in New Issue