Commit Graph

3276 Commits (226d28fcd7b7491c97e480d166f5872580914082)

Author SHA1 Message Date
Nils Maier 70a80b1455 Remove request pre-authorization again 2014-07-22 21:58:30 +02:00
Nils Maier 8f2af33b6d Delay auth failures instead of PBKDF2
Closes GH-256
2014-07-22 21:58:30 +02:00
diadistis 9b1667fe81 Fixed segfault unsupported encodings 2014-07-20 18:06:09 +03:00
Tatsuhiro Tsujikawa d69764879e Fix regression 100% CPU utility when -V is used and download is multi-file BT
This is regression of a3426821c8
2014-07-20 18:36:52 +09:00
Tatsuhiro Tsujikawa b611cd2bdc UnknownLengthPieceStorage: Use std::make_shared 2014-07-15 23:48:32 +09:00
Tatsuhiro Tsujikawa a6b7bd0342 Show bitfield for unknown length download in aria2.tellStatus RPC method
Generally, bitfield is not available for download whose total length
is unknown.  We create bitfield when download is completed (usually
connection EOF) so that we can use it to show additional info in RPC
aria2.tellStatus response.  Specifically, bitfield is now shown.  And
completedLength under files key (or completedLength in
aria2.getFiles() response) is correctly shown.
2014-07-15 23:36:10 +09:00
Tatsuhiro Tsujikawa 98681552fc Fix compile error on big endian platform 2014-07-14 21:32:48 +09:00
Tatsuhiro Tsujikawa 04caefa406 Fix test failure with --enable-libaria2 2014-07-14 00:06:32 +09:00
Tatsuhiro Tsujikawa 7fbd8a50ef Fix compile error and warning with clang 2014-07-12 17:44:43 +09:00
Tatsuhiro Tsujikawa 3aaa5a7344 Fix file length information in RPC response when length > 2GB is unknown
This commit fixes the bug that aria2.tellStopped RPC method returns
total length and completedLength as 0 when file size is unknown in
advance and turns out > 2GB in the end.  This commit and addresses the
performance degradation in this case.
2014-07-12 17:01:46 +09:00
Nils Maier 84bd18b9a1 Merge crypto_* from upstream
Revert "Fix typo"
This reverts commit 4dfd8b8847.
Revert "MinGW: Fix compiler warning with -Wstrict-aliasing"
This reverts commit 897f0e87f4.
2014-07-11 04:11:03 +02:00
Tatsuhiro Tsujikawa 897f0e87f4 MinGW: Fix compiler warning with -Wstrict-aliasing
The error message is:

warning: dereferencing type-punned pointer will break strict-aliasing
rules [-Wstrict-aliasing]
2014-07-10 00:28:16 +09:00
Tatsuhiro Tsujikawa 4dfd8b8847 Fix typo 2014-07-10 00:28:06 +09:00
Tatsuhiro Tsujikawa 852f2fb99a MinGW: Fix compiler warning about winsock2.h and windows.h
This commit fixes following compiler warning with mingw compiler:

In file included from common.h:63:0,
                 from util_security.h:42,
                 from util_security.cc:36:
/usr/share/mingw-w64/include/winsock2.h:15:2: warning: #warning
 Please include winsock2.h before windows.h [-Wcpp]
 #warning Please include winsock2.h before windows.h
2014-07-10 00:04:28 +09:00
Tatsuhiro Tsujikawa a3426821c8 MultiDiskAdaptor: Handle short read 2014-07-02 00:05:44 +09:00
Tatsuhiro Tsujikawa 8750d7be99 Disard cache when checking checksum
This will slow down checksum checking but does not thrash cache.
2014-07-02 00:05:43 +09:00
Nils Maier 0b6501043a Compat with libuv 0.11 (Unstable)
Fixes #241
2014-07-01 13:48:19 +02:00
Nils Maier 0c8a2659ea Drop WinMessageDigestImpl.
The algorithms the `CryptProv` on Windows supports does not currently
include SHA-224, so there is a "dark spot" in this implementation. Also
on Win XP < SP3, most of the SHA-2 family is not actually supported.
All other implementation provide support for MD5, SHA-1 and all of the
SHA-2 family, hence drop the incomplete WinMessageDigest implementation
in favor of any other supported implementation (at least the internal
implementation is always available at compile-time).
2014-06-24 20:45:12 +02:00
Nils Maier 8587669995 Fix big endianess support in InternalMessageDigest and PBKDF2
- Replace sha1/md5 implementation by ones from https://github.com/nmaier/crypto
- Add endianess functionality fro https://github.com/nmaier/crypto

Closes GH-239
2014-06-24 20:45:05 +02:00
Tatsuhiro Tsujikawa 06a8bf6e0a Pause download only when RPC is enabled 2014-06-21 00:58:21 +09:00
Tatsuhiro Tsujikawa e2932608fc Add --pause-metadata option
This option pauses downloads created as a result of metadata
download. There are 3 types of metadata downloads in aria2: (1)
downloading .torrent file. (2) downloading torrent metadata using
magnet link. (3) downloading metalink file.  These metadata downloads
will generate downloads using their metadata. This option pauses these
subsequent downloads.
2014-06-21 00:58:21 +09:00
Nils Maier 2b02fac2d5 Improve compiler/platform/libs information in logs
Add and use usedCompilerAndPlatform().  This adds compiler information to
INFO logs and the --version output, and may be helpful when trying to
diagnose/reproduce user-reported problems.

Also make INFO logs include usedLibs() output.

Closes #235
2014-06-10 11:28:34 +02:00
Tatsuhiro Tsujikawa 570bc24fb9 Fix use-after-free on exit with multi-file torrent download + DHT
DefaultPieceStorage may be referenced by one of DHT task (e.g.,
DHTPeerLookupTask), after RequestGroup was deleted, and even after
RequestGroupMan was deleted.  DefaultPieceStorage has a reference to
MultiDiskAdaptor which calls RequestGroupMan object on destruction.
So when DHT task is destroyed, DefaultPieceStorage is destroyed, which
in turn destroys MultiDiskAdaptor.  DHT task is destroyed after
RequestGroupMan was destroyed, MultiDiskAdaptor will use now freed
RequestGroupMan object, this is use-after-free.
2014-06-08 17:03:34 +09:00
Tatsuhiro Tsujikawa 442e460055 Fix bug that zero length file is not opened when flushing cache
This bug was only seen when MultiDiskAdaptor was used.
2014-06-08 16:43:22 +09:00
Tatsuhiro Tsujikawa e2ff45f326 AnnounceList, AnnounceTier: Code cleanup using C++11 features 2014-06-06 00:04:37 +09:00
Tatsuhiro Tsujikawa aff92b5115 SocketRecvBuffer: Cleanup with C++11 features 2014-06-05 23:40:19 +09:00
Tatsuhiro Tsujikawa 0ee8104953 Small code cleanup for SocketBuffer 2014-06-05 23:33:58 +09:00
Tatsuhiro Tsujikawa c0e4381780 util::parseIntSegments: Return SegList<int> 2014-06-04 23:21:01 +09:00
Tatsuhiro Tsujikawa 007b890fe4 bittorrent::computeFastSet: Return std::vector 2014-06-04 22:50:39 +09:00
Tatsuhiro Tsujikawa d1d5ea5b21 DownloadContext, FileEntry: Use move semantics to path parameter in ctor 2014-06-04 22:43:29 +09:00
Tatsuhiro Tsujikawa 9b54272190 FileEntry::getUris: Return std::vector<std::string> 2014-06-04 22:33:46 +09:00
Tatsuhiro Tsujikawa 4f3c526dcd Support PREF_DIR change for Metalink files
Reworked previous commit adeead6f03, and
now support changing PREF_DIR for Metalink downloads.
2014-06-04 21:45:12 +09:00
Tatsuhiro Tsujikawa adeead6f03 Revert to existing "proper" coding style
The rule is simple: don't try to change the coding style of the
existing codebase.
2014-06-03 23:41:30 +09:00
Tatsuhiro Tsujikawa 83f4bced07 Fix assertion failure when dir option of paused HTTP/FTP download is changed
When the directory is changed via aria2.changeOption RPC method, we
directly change first FileEntry's path using FileEntry::setPath().  If
there is no PREF_OUT option is given, basically file name is unknown,
so we just set empty string and let the next run determine the correct
file name and new directory is applied there.  But previous code does
not reset length property of FileEntry, so the unexpected code path is
taken when unpaused and its path expects path is not empty string.
This commit fixes this issue by setting length to 0 using
FileEntry::setLength().
2014-06-03 23:09:28 +09:00
Tatsuhiro Tsujikawa 631f37433a Save session only when there is change since the last serialization
This is a slight optimization not to cause useless disk access.  This
only applies to saving session automatically (see
--save-session-interval).  aria2.saveSession and serialization at the
end of the session are always performed as before.

When serialization, we first check that whether there is any change
since the last serialization.  To do this, we first calculate hash
value of serialized content without writing into file.  Then compare
this value to the value of last serialization.  If they do not match,
perform serialization.
2014-05-31 16:19:57 +09:00
Tatsuhiro Tsujikawa 998fba3264 Revert "Save session only when there is change since the last serialization"
This reverts commit 1944d8db58.
2014-05-31 15:28:26 +09:00
Tatsuhiro Tsujikawa 1944d8db58 Save session only when there is change since the last serialization
This is a slight optimization not to cause useless disk access.  This
only applies to saving session automatically (see
--save-session-interval).  aria2.saveSession and serialization at the
end of the session are always performed as before.
2014-05-30 23:20:13 +09:00
Nils Maier d2e38aab36 Use _setmode to set binary mode in mingw
The _CRT_fmode stuff was never working correctly anyway, and is entirely
unsupported in mingw-w64 these days, it seems.
2014-05-29 19:38:34 +02:00
Nils Maier 3c55400d23 Silence deprecation warning about daemon() on OSX 2014-05-29 19:38:34 +02:00
Nils Maier b9fe4119c0 New round of clang-modernize 2014-05-29 19:38:34 +02:00
Nils Maier c8ccb43428 Consistent style in util_security 2014-05-29 19:38:34 +02:00
Nils Maier 77f0f1395c Consistent style in the platform TLS implementations 2014-05-29 19:38:33 +02:00
Nils Maier 8cada49765 Cleanup AbstractCommand take 2
Decided to keep the 'if(' -> 'if (' stuff, as I formatted the whole file
and so it is internally consistent within the file. Also, too much
hassle.
2014-05-29 18:39:53 +02:00
Nils Maier e57d330111 Cleanup HttpHeaderProcessor take 2
Decided to keep the 'if(' -> 'if (' stuff, as I formatted the whole file
and so it is internally consistent within the file. Also, too much
hassle.
2014-05-29 18:29:37 +02:00
Nils Maier 48ec56a64d Revert "Cleanup HttpHeaderProcessor::parse"
This reverts commit 047b49b7a0.
2014-05-29 18:29:37 +02:00
Nils Maier 6240345fd5 Revert "Cleanup AbstractCommand"
This reverts commit 0465aa5455.
2014-05-29 18:29:37 +02:00
Nils Maier 0465aa5455 Cleanup AbstractCommand
In my quest to explore the code and understand it, why not clean it up
in the progress. Most formatting provided by clang-format. ;)
Aside from formatting, also extracted some method and unnested some
control structs.
2014-05-27 21:37:15 +02:00
Nils Maier 6e546245e4 Sort and cleanup src/Makefile.am 2014-05-27 21:35:42 +02:00
Nils Maier 047b49b7a0 Cleanup HttpHeaderProcessor::parse 2014-05-27 19:46:54 +02:00
Nils Maier d72df551ba Document setUri() in FileEntry does not need to check the return value. 2014-05-27 19:10:14 +02:00
Nils Maier 15cb9e12b2 Remove unused variable in LibgcryptMessageDigestImpl 2014-05-27 19:10:14 +02:00
Nils Maier fd8dc921fe Initialize DownloadEngine::tokenAverageDuration_ to something. 2014-05-27 19:10:14 +02:00
Nils Maier f8db60e54e OSX: Use F_NOCACHE instead of F_GLOBAL_NOCACHE
The latter persists for the lifetime of the file, while the former
affects only the current descriptor.
2014-05-26 21:34:49 +02:00
Nils Maier dd8e4b0ad0 Remove spurious CXX11_OVERRIDE to make cov-build happy. 2014-05-26 01:34:26 +02:00
Nils Maier a82f08765e Fix (unknown length) downloads larger than 2GiB
Closes #215
2014-05-25 14:49:29 +02:00
Nils Maier 64b1fefb78 Add missing include in util_security.h
Fixes #231
2014-05-23 18:44:10 +02:00
Nils Maier f7cc24d6cf Internally use HMAC in http auth
To at least get constant time compare.
Also fix incorrect parsing of the creds (were incorrectly stripped).
Also add unit tests.
2014-05-22 15:24:20 +02:00
Nils Maier d02ee723bd Improve aria2.rst and usage texts a bit.
(Keep in mind that I'm not a native speaker either)
- Fix some typos.
- Fix some grammar stuff.
- Clarify some things.
- Add a new paragraph or two...
2014-05-20 18:02:47 +02:00
Nils Maier 855dfa0e2f Authorize RPC multicalls only once.
Cache the auth status afterwards and just assume the token still matches
(within the same request, of course).
2014-05-20 12:53:39 +02:00
Nils Maier 88b61f2eb9 Adjust RPC token processing time
Make it consume a bit less time.
2014-05-20 12:53:38 +02:00
Nils Maier bb50de1336 Improve write cache failures error reporting 2014-05-20 12:52:26 +02:00
Nils Maier 5c07f0109e Fix F_PREALLOC based allocation on some OSX versions 2014-05-08 16:40:09 +02:00
Nils Maier 1dd7409c4e Fix unused function warning about generateRandomDataUrandom in mingw-w64 2014-05-08 16:38:32 +02:00
Nils Maier a0f275a9f1 Remove unused function getWin32Handle 2014-05-08 16:38:32 +02:00
Tatsuhiro Tsujikawa f60e55cece Use index.html as filename for conditional-get when file is missing in URI
Previously we disabled conditional-get if file part is missing in URI.
But we use constant string "index.html" in this case, so we can do the
same to determine the modification time.  In this patch, if we have
file part in URI, we are not going to set absolute file path in
FileEntry, since it prevents content-disposition from working.
2014-05-08 21:49:04 +09:00
Tatsuhiro Tsujikawa 84f1a15e10 Check negative number from Integer::i() where it is not allowed 2014-05-01 11:34:27 +09:00
Tatsuhiro Tsujikawa 4c2ad69a75 Ignore negative metadata size in extended handshake 2014-04-30 23:46:27 +09:00
Nils Maier 82dad90ff3 Validate token using PBKDF2-HMAC-SHA1.
This change should make token validation more resilient to:
 - timing attacks (constant time array compare)
 - brute-force/dictionary attacks (PBKDF2)

 Closes #220
2014-04-19 19:10:06 +02:00
Nils Maier 98ba096951 Add util::security (compare, HMAC, PBKDF2)
See #220
2014-04-19 19:07:38 +02:00
Nils Maier 010131161e Remove ENABLE_MESSAGE_DIGEST, since we got the internal md, always 2014-04-17 18:02:42 +02:00
Nils Maier aa02545fba Use mpz_pown_sec where available 2014-04-13 18:51:06 +02:00
Nils Maier c694a05797 Fix some warnings 2014-04-13 18:51:05 +02:00
Nils Maier 18c35f56b8 AppleTLS: Enable BEAST mitigations in ST
Only available in 10.9+, but since we might be building on a previous
version but running on 10.9+, always try to set the option.
2014-04-13 18:51:05 +02:00
Nils Maier e195dc5f00 AppleTLS: Update cipher suites
Also make the suite selection more sane.
2014-04-13 18:51:05 +02:00
Nils Maier 39d66bd560 WinTLS: Improve error reporting 2014-04-13 18:51:05 +02:00
Nils Maier 51beb4bfa7 WinTLS: Move some defines out of the header 2014-04-13 18:51:04 +02:00
Nils Maier 219fd5b4b7 WinTLS: Make ca-file rejection a warning 2014-04-13 18:51:04 +02:00
Nils Maier 8d55e30561 WinTLS: Use SCH_USE_STRONG_CRYPTO
See: #217
2014-04-13 18:50:54 +02:00
Nils Maier 0a51b8d172 WinTLS: Accept chains with no revocation information.
This is kind what browser do anyway (IE, Firefox, Chrome tested), what
AppleTLS does, what GnuTLS does and what OpenSSL does. Actually, most
browsers will also be OK with the CRL/OCSP provider being offline.
WinTLS will still fail in that case.

Should revocation information be available in the trust chain (CRL or
OCSP) the certificate still will be checked!

"Real" CAs, aka. those provided by the OS or system CA bundle, usually
provide revocation information and are thus still checked.
It should be mostly (only?) custom (organization) CAs that lack
revocation information, but those users might want to use aria2 in their
intranets and VPNs anyway ;)

See #217
2014-04-13 18:50:38 +02:00
Nils Maier 13a202df07 Fix GnuTLS 2.x compatiblity
Closes GH-216
2014-04-12 02:55:31 +02:00
Nils Maier 2d9bf0f374 AppleTLS: Use newer, non-deprecated API in 10.8+ 2014-04-12 02:55:31 +02:00
Nils Maier 7600886d3d Implement falloc equivalent in OSX 2014-04-12 02:55:31 +02:00
Tatsuhiro Tsujikawa f0473dc34d Ignore error when setting DSCP value
Setting DSCP is additional feature and failure to enable it should not
abort download entirely.  This change fixes the bug that windows build
does not perform bittorrent downloads.
2014-03-30 14:14:28 +09:00
Tatsuhiro Tsujikawa 551adc5133 mingw: Undef localtime_r and asctime_r 2014-03-24 01:11:30 +09:00
Tatsuhiro Tsujikawa 1188e4f1a2 Fix mingw32 build with gcc 4.8.2
Now mingw-w64 C++ compiler defines __USE_MINGW_ANSI_STDIO to 1, we
have to follow it as well.  We hope that mingw version of stdio
function behaves like Linux ones.  We have not tested them thoroughly
yet.  pthread for windows defines its own HAVE_STRUCT_TIMESPEC macro.
To avoid warning, we rename our version of it as
HAVE_A2_STRUCT_TIMESPEC.
2014-03-24 00:37:30 +09:00
Alexander Amanuel dccd8192a4 Added DSCP support for IPv6 sockets 2014-03-12 15:22:46 +04:00
Tatsuhiro Tsujikawa a8319a8b78 Add aria2.saveSession RPC method
This method saves the current session to a file specified by
--save-session option. This method returns "OK" if it succeeds.
2014-02-19 22:02:50 +09:00
Tatsuhiro Tsujikawa 1a24020e63 Don't allow empty string for --rpc-secret option 2014-02-19 21:46:06 +09:00
Tatsuhiro Tsujikawa de4cd8b59b Warn if neither --rpc-secret nor a combination of --rpc-user/rpc-passwd is set 2014-02-19 21:37:11 +09:00
Nils Maier 00e690a4d1 Add some missing includes to AnnounceList.h 2014-02-19 03:09:59 +01:00
Tatsuhiro Tsujikawa 1462d6536a Add numStoppedTotal key to aria2.getGlobalStat() RPC method response
It shows the number of stopped downloads in the current session and
not capped by --max-download-result option. On the other hand, the
existing numStopped key also shows the number of stopped downloads,
but it is capped by --max-download-result option.
2014-02-15 19:10:48 +09:00
Tatsuhiro Tsujikawa b18e62dba7 Treat 30X response without Location header field as error
This is required to make segmented download work.
2014-02-05 21:20:09 +09:00
Tatsuhiro Tsujikawa ec4b729704 Better handling of 30X HTTP status codes
Reference: http://greenbytes.de/tech/tc/httpredirects/
2014-02-05 00:32:43 +09:00
Tatsuhiro Tsujikawa 06bb6d1ac0 Fix longer line in --dscp option help 2014-02-04 21:52:28 +09:00
Tatsuhiro Tsujikawa 1438933c97 Merge branch 'dscp-support' of https://github.com/iavael/aria2 into iavael-dscp-support
Conflicts:
	src/prefs.cc
	src/prefs.h
	src/usage_text.h
2014-02-04 21:42:00 +09:00
Alexander Amanuel a7182b9ee4 Improved dscp parameter description 2014-02-03 17:53:07 +04:00
Tatsuhiro Tsujikawa 7d1aa887ee Add future deprecation warning to --rpc-user and --rpc-passwd 2014-02-02 17:58:56 +09:00
Tatsuhiro Tsujikawa 7f6987a4b4 Implement new RPC authorization using --rpc-secret option 2014-02-02 17:34:07 +09:00
Alexander Amanuel 96a77e42d1 Minor DSCP-related improvements
- Improved usage annotation
- Shifted DSCP value to set not whole DS field, but only it's DSCP part
2014-01-29 20:17:22 +04:00
Tatsuhiro Tsujikawa 30e4077440 Add --enable-color option to enable/disable terminal color output 2014-01-30 00:15:05 +09:00