1
mirror of https://github.com/qbittorrent/qBittorrent synced 2025-10-14 11:52:15 +02:00

Compare commits

...

99 Commits

Author SHA1 Message Date
Mike Tzou
d8cb552804 Merge pull request #12159 from thalieht/backportflags
Backport #12014: Use IP geolocation database by DB-IP instead of MaxMind
2020-03-13 18:38:35 +08:00
sledgehammer999
304e831b0c Use IP geolocation database by DB-IP instead of MaxMind 2020-03-12 01:05:44 +02:00
Mike Tzou
f16d219646 Merge pull request #11778 from FranciscoPombal/v4_1_x
WebUI: backport #11635 and #11756 to v4_1_x
2019-12-30 10:13:35 +08:00
FranciscoPombal
22b0160eaa WebUI: fix populating statistics window
Closes #11665
2019-12-29 14:19:57 +00:00
FranciscoPombal
d4f49c3666 WebUI: Prevent excessive sync requests
Don't sync main data if a request to do so is already in progress.

This prevents piling up of requests and bogging down slow/busy machines, since the current implementation of `/api/v2/sync/maindata` is very computationally intensive, especially with lots of torrents.

Everything gets updated on the next scheduled request anyway (via the timeout mechanism).
2019-12-29 14:19:27 +00:00
Mike Tzou
0b055d8fef Merge pull request #11472 from thalieht/backport_pausechecking
Backport
2019-11-19 12:05:31 +08:00
thalieht
21595fca9c Reallow to force recheck torrents that aren't fully started 2019-11-18 16:02:40 +02:00
thalieht
64ac48ee11 Reallow to pause checking torrents 2019-11-09 14:08:47 +02:00
Mike Tzou
5d98721593 Merge pull request #11437 from Chocobo1/backport
Fix integer narrowing on x86 (backport)
2019-11-02 11:58:50 +08:00
Chocobo1
598159552e Fix integer narrowing on x86
The f_type is an alias to `int` on 32-bit system and the switch cases
uses `unsigned int`.

Closes #11427.
2019-11-01 10:49:43 +08:00
sledgehammer999
eea38e7c9e Bump to 4.1.9.1 2019-10-31 22:12:08 +02:00
sledgehammer999
5c933c9734 Update Changelog 2019-10-31 22:05:05 +02:00
Mike Tzou
102b7fa78e Merge pull request #11417 from Chocobo1/dpi_v41x
Fix screen scaling factor calculation (backport to v4_1_x)
2019-10-29 15:56:11 +08:00
Chocobo1
b5ee908f6c Fix screen scaling factor calculation
For some users on Windows the physicalDotsPerInch() could return values
that are smaller than the normal 96 DPI which leads to big dialog sizes
taking the entire screen.
So we need to ensure it is at least 96 DPI.
Closes #11405, #11407.
2019-10-29 10:00:45 +08:00
sledgehammer999
7825d8627f Bump to 4.1.9 2019-10-27 17:26:03 +02:00
sledgehammer999
b798c591e7 Update Changelog 2019-10-27 17:13:26 +02:00
Chocobo1
9e7d21d7aa Update m4 scripts 2019-10-27 17:11:19 +02:00
Chocobo1
38a15b27f0 Regenerate build-aux scripts
It's been a while since the last update (26bf838a0b)
and there is a lot of changes in upstream.
2019-10-27 17:05:37 +02:00
sledgehammer999
cb31684a66 Merge pull request #11309 from sledgehammer999/webui_version
Bump Web API version
2019-10-20 23:07:49 +03:00
Mike Tzou
850cde19f7 Merge pull request #11328 from Chocobo1/backport
Use screen real physical DPI on Windows (backport)
2019-10-05 10:02:07 +08:00
Chocobo1
fc5b3b4f70 Use screen real physical DPI on Windows
Previously was using a hardcoded value which might lead to issues like #11234.
2019-10-04 12:05:13 +08:00
Mike Tzou
73fd4d83af Merge pull request #11319 from Chocobo1/backport
Preserve relative order when moving to top/bottom in queue (backport)
2019-10-04 12:01:33 +08:00
Chocobo1
811b525b1d Preserve relative order when moving to top/bottom in queue 2019-10-03 11:23:28 +08:00
sledgehammer999
0f8def9a49 Bump Web API version
Closes #11304
2019-10-01 17:31:55 +03:00
sledgehammer999
359b464958 Bump to 4.1.8 2019-09-23 21:56:30 +03:00
sledgehammer999
b5b0d68dd9 Update Changelog 2019-09-23 21:52:56 +03:00
Chocobo1
f48c49c248 Fix seeding failed after creating a new torrent
Closes #11252.
2019-09-23 21:47:37 +03:00
Chocobo1
11ca744548 Treat .magnet file extension as case insensitive
Closes #11200.
2019-09-23 21:47:35 +03:00
Chocobo1
82e6fc700e Fix filename validation on non-Windows OS
Closes #11191.
2019-09-23 21:47:34 +03:00
Mike Tzou
59fd70c638 Merge pull request #11240 from Chocobo1/backport
Revise HTML escaping in GUI (Backport)
2019-09-17 10:38:51 +08:00
Chocobo1
617bf767df Escape HTML in comment field 2019-09-16 23:48:12 +08:00
Chocobo1
55180e3598 Remove redundant HTML escaping
The text widget is already set to plaintext and doing HTML escaping will
not give us more security but only makes it harder to read.
2019-09-16 23:48:06 +08:00
Mike Tzou
56b62e6573 Merge pull request #11183 from Chocobo1/backport
Always save info dict when saving fastresume (backport to v4_1_x)
2019-09-04 12:09:14 +08:00
Chocobo1
b37e7b0340 Always save info dict when saving fastresume
Otherwise torrents loaded from fastresume won't have it and needs
to redownload it from elsewhere and slowing down the startup process.
This is also required for the future where we will drop loading the
`info` dict from .torrent files.
2019-09-03 14:37:45 +08:00
Mike Tzou
21aebaf16f Merge pull request #11074 from Chocobo1/backport
Fix translation issues (backport to v4_1_x)
2019-08-15 11:11:52 +08:00
Chocobo1
5792465317 Fix translation issues
By using disambiguation field instead of comment field to differentiate
translations.
2019-08-14 13:09:56 +08:00
Vladimir Golovnev
e98f44af63 Merge pull request #11067 from glassez/rss-api
Allow to refresh RSS item(s) via WebAPI
2019-08-13 19:52:10 +03:00
Vladimir Golovnev (Glassez)
40cf0203fb Allow to refresh RSS item(s) via WebAPI 2019-08-13 17:39:19 +03:00
sledgehammer999
05a82afeb6 Bump to 4.1.7 2019-08-04 14:17:20 +03:00
sledgehammer999
a456f1b0f9 Update Changelog 2019-08-04 14:14:21 +03:00
sledgehammer999
4acc44a5b0 Sync translations from Transifex and run lupdate/tstool.py 2019-08-04 13:50:34 +03:00
Mike Tzou
9c2a1146df Merge pull request #10991 from Chocobo1/backport
Backport to v4_1_x
2019-07-31 14:29:14 +08:00
Chocobo1
807abeae87 Fix messed up symbols in log 2019-07-31 14:28:05 +08:00
Chocobo1
dd2a0d0484 Fix incomplete file extension not applied for new torrents 2019-07-29 11:20:36 +08:00
Vladimir Golovnev
3f3400f43b Merge pull request #10967 from glassez/fastresume41
Save updated resume data for completed torrents (backport to v4.1.x)
2019-07-24 17:17:50 +03:00
Vladimir Golovnev (Glassez)
334b57a89a Save updated resume data for completed torrents
If fastresume data was rejected we need to save updated
resume data after torrent finishes rechecking.
2019-07-23 20:15:41 +03:00
Vladimir Golovnev (Glassez)
00d6c83ee5 Fix requested torrent resume data handling
Session should increase an appropriate counter each time
the torrent resume data is requested to save.
2019-07-23 20:15:23 +03:00
Mike Tzou
e8850c7a70 Merge pull request #10953 from Chocobo1/backport
Backport to v4_1_x
2019-07-21 21:19:05 +08:00
Chocobo1
2ef96eb218 Prevent command injection via "Run external program" function 2019-07-21 12:07:32 +08:00
Vladimir Golovnev
4682e31ab7 Merge pull request #10929 from glassez/backport
Fix torrent checking issues (backport to v4.1.x)
2019-07-17 17:50:35 +03:00
Vladimir Golovnev (Glassez)
988f7e2ef8 Don't break torrent checking 2019-07-15 20:02:08 +03:00
Vladimir Golovnev (Glassez)
6007913291 Ignore some actions on uninitialized torrents
Some actions can lead to an inconsistent state if applied
to an uninitialized torrent, so we just ignore them.
2019-07-15 20:02:04 +03:00
Vladimir Golovnev (Glassez)
cdcc7a210b Avoid race conditions when adding torrent 2019-07-15 20:01:59 +03:00
Vladimir Golovnev (Glassez)
a466ff5057 Fix torrent checking issues
Start all torrents auto-managed to prevent simultaneous checking
of multiple torrents.
Handle checking state of paused torrent to prevent it from being
resumed when qBittorrent is closed until checking isn't complete.
2019-07-15 20:01:43 +03:00
Mike Tzou
e954835579 Merge pull request #10869 from Chocobo1/backport
Backport to v4_1_x
2019-07-06 12:17:33 +08:00
Chocobo1
3e9be3a0e8 Use proper log message when there are no error 2019-07-06 12:16:43 +08:00
Chocobo1
4ab32a76f6 Fix torrent properties not saved for paused torrents 2019-07-06 12:16:23 +08:00
Chocobo1
bad60058df Restrict QLocalServer access
The default is world access which means even even unprivileged local
accounts can connect to it too.
2019-06-29 15:30:09 +08:00
Chocobo1
31a6ad1eb6 Drop suspiciously large data
This is to avoid exhausting system memory.
2019-06-29 15:30:04 +08:00
Mike Tzou
a8bfec081e Merge pull request #10848 from Chocobo1/backport
Backport to v4_1_x
2019-06-25 09:01:25 +08:00
Chocobo1
ae21d0f1e2 Remove limits of "Disk cache expiry interval" setting 2019-06-24 11:14:21 +08:00
Chocobo1
c599976b6f Remove upper limit of "Disk cache" setting 2019-06-24 11:13:50 +08:00
Mike Tzou
bcee784097 Merge pull request #10842 from Piccirello/v4_1_x
Backport to v4_1_x
2019-06-24 11:00:12 +08:00
Thomas Piccirello
697fc626cd Fix WebUI encoding of special characters 2019-06-22 15:52:19 -07:00
Mike Tzou
2f15ea9b54 Merge pull request #10829 from Chocobo1/backport
Backport to v4_1_x
2019-06-21 11:02:54 +08:00
Chocobo1
d03209a73d Fix crash when removing phantom tags
Normally a tag is stored in both session and torrent's fastresume.
A phantom tag is a tag that is stored in fastresume but not in
session.
This crash can occur when user resets his config file and choose
to remove tag from torrent.

Closes #10569.
2019-06-20 11:38:15 +08:00
Chocobo1
ac9ba255d8 Set wheel event to accepted only if we handle it 2019-06-20 11:38:02 +08:00
Chocobo1
9a7e79bd0e Improve handleFileErrorAlert error message 2019-06-20 11:37:40 +08:00
Mike Tzou
e8be3bf939 Merge pull request #10772 from Chocobo1/backport
Backport to v4_1_x
2019-06-17 01:00:35 +08:00
Chocobo1
74e52746b1 Reorder if conditions slightly 2019-06-16 12:37:16 +08:00
Chocobo1
8d26a221e0 Fix updated save path not saved for paused torrents 2019-06-16 12:37:16 +08:00
Chocobo1
3fdab88eb7 Log save_resume_data_failed_alert 2019-06-16 12:37:16 +08:00
Chocobo1
d376d912b3 Don't remove parent directories
QDir::rmpath removes *all* parent directories while QDir::rmdir removes
the specified directory.
2019-06-16 12:30:57 +08:00
Chocobo1
e329c41ef2 Properly remove empty leftover folders after rename
TorrentInfo::origFilePath will return the very original path from
.torrent file, not the most recent file path before the rename operation
and thus the code would not be working as we expected.
2019-06-16 12:30:42 +08:00
silverqx
01e4179555 Focus behavior row in Options dialog 2019-06-15 11:50:28 +08:00
Chocobo1
06f503b5df Fix unable to rename folder on Windows
The bug occurs when the new path and old path only differ by letter case.
2019-06-10 10:34:15 +08:00
Chocobo1
e2f3dad7b8 Move renameSelectedFile(BitTorrent::TorrentInfo &) 2019-06-10 10:34:10 +08:00
Chocobo1
377f31085c Move renameSelectedFile(BitTorrent::TorrentHandle *) 2019-06-10 10:34:03 +08:00
Chocobo1
ec13d195f8 Fix unable to control add torrent dialogs when opened simultaneously 2019-06-06 23:31:27 +08:00
Chocobo1
c01aed8d90 Remove redundant disconnect()
The dialog is going out-of-scope in these instance and the signal-slot connection will disconnect
automatically.
2019-06-06 23:29:53 +08:00
Vladimir Golovnev
ad7b8a9bfa Merge pull request #10757 from glassez/backport
Backport to v4.1.x
2019-06-04 17:59:10 +03:00
Vladimir Golovnev (Glassez)
5bba1ed208 Ignore RSS articles with non-unique identifiers 2019-06-04 15:08:35 +03:00
Vladimir Golovnev (Glassez)
fe94e14bcc Perform more RSS parsing in working thread 2019-06-04 15:06:29 +03:00
Vladimir Golovnev (Glassez)
b0af479ab9 Disable "Upload mode" when start preloaded torrent 2019-06-04 15:01:10 +03:00
Mike Tzou
24ff369f29 Merge pull request #10731 from Chocobo1/backport
Backport to v4_1_x
2019-06-01 10:07:23 +08:00
Vladimir Golovnev
979c9a7094 Merge pull request #10728 from glassez/fix-seqdl
Fix sequential downloading when redirected
2019-05-31 08:13:50 +03:00
Chocobo1
7b90ac52c1 Fix wrong comparison result
The QString::toInt() might overflow when the string is long.

Closes #10706.
2019-05-31 12:20:39 +08:00
Vladimir Golovnev (Glassez)
ecfbda78bc Fix sequential downloading when redirected 2019-05-30 16:06:18 +03:00
Mike Tzou
9ba7470815 Merge pull request #10615 from Chocobo1/backport
Backport to v4_1_x
2019-05-23 22:14:18 +08:00
Chocobo1
6394467cc7 Fix typos 2019-05-20 17:45:48 +08:00
Chocobo1
f6d72fa79f Fix assertion fail
When fileSize == 0, the second index could be smaller than the first index,
thus trigger the assert check in IndexInterval constructor.

Closes #10611.
2019-05-16 10:49:00 +08:00
dzmat
32ed5f1c8e Change number of time axis divisions from 5 to 6 for convenience 2019-05-15 20:36:00 +08:00
dzmat
5026da5773 Add 12 hour and 24 hour speed graphs 2019-05-15 20:35:50 +08:00
Evgeny Lensky
ef130e4438 Change "Add new torrent" dialog to horizontal layout 2019-05-15 10:19:37 +08:00
jerrymakesjelly
4fbd52c2d5 Change the speed unit from Bytes/s to KiB/s
Updated the adding torrent dialogs in WebUI. Closes #10017.
2019-05-12 13:51:35 +08:00
Matan Bareket
8f29b70c1e Download RSS enclosure element if no proper MIME type is found
In the case where an RSS feed doesn't have the "enclosure" element
with type "application/x-bittorrent", fallback to the last enclosure
element which has no "type" attribute.
2019-05-11 23:39:57 +08:00
Ekin Dursun
9a4dd3ea9d Don't turn screen blank when closed to system tray
Closes #9240 and possibly #9121, as @zeule suggested here: https://github.com/qbittorrent/qBittorrent/issues/9240#issuecomment-408025722.
2019-05-11 12:25:42 +08:00
Chocobo1
fcd3bb6918 Refactor HTTP query parsing 2019-05-10 09:20:03 +08:00
Chocobo1
9f69fd8750 Fix '+' char not decoded to space correctly
Closes #10606.
2019-05-10 09:19:56 +08:00
170 changed files with 17905 additions and 14654 deletions

View File

@@ -1,3 +1,54 @@
* Thu Oct 31 2019 - sledgehammer999 <sledgehammer999@qbittorrent.org> - v4.1.9.1
- WINDOWS: Fix a problem with bigger dialogs due to wrong DPI reported by the system (Chocobo1)
* Sun Oct 27 2019 - sledgehammer999 <sledgehammer999@qbittorrent.org> - v4.1.9
- BUGFIX: Preserve relative order when moving to top/bottom in queue (Chocobo1)
- WINDOWS: Use real physical screen DPI (Chocobo1)
- WEBUI: Bump Web API version
* Mon Sep 23 2019 - sledgehammer999 <sledgehammer999@qbittorrent.org> - v4.1.8
- BUGFIX: Fix filename validation on non-Windows OS (Chocobo1)
- BUGFIX: ScanFolders/FileSystemWatcher now detect magnet files with case insensitivity in filename (Chocobo1)
- BUGFIX: Fix failed seeding after creating a torrent and auto-adding it to the session (Chocobo1)
* Sun Aug 04 2019 - sledgehammer999 <sledgehammer999@qbittorrent.org> - v4.1.7
- FEATURE: Add 12 hour and 24 hour speed graphs (dzmat)
- FEATURE: Change "Add new torrent" dialog to horizontal layout (Evgeny Lensky)
- BUGFIX: Fix messed up symbols in log (Chocobo1)
- BUGFIX: Fix incomplete file extension not applied for new torrents (Chocobo1)
- BUGFIX: Save updated resume data for completed torrents (Vladimir Golovnev (Glassez))
- BUGFIX: Fix requested torrent resume data handling (Vladimir Golovnev (Glassez))
- BUGFIX: Prevent command injection via "Run external program" function (Chocobo1)
- BUGFIX: Avoid race conditions when adding torrent (Vladimir Golovnev (Glassez))
- BUGFIX: Fix torrent checking issues (Vladimir Golovnev (Glassez))
- BUGFIX: Use proper log message when there are no error (Chocobo1)
- BUGFIX: Fix torrent properties not saved for paused torrents (Chocobo1)
- BUGFIX: Some improvements on qtsingleapplication code (Chocobo1)
- BUGFIX: Remove limits of "Disk cache expiry interval" setting (Chocobo1)
- BUGFIX: Remove upper limit of "Disk cache" setting (Chocobo1)
- BUGFIX: Fix crash when removing phantom tags (Chocobo1)
- BUGFIX: Improve handleFileErrorAlert error message (Chocobo1)
- BUGFIX: Fix updated save path not saved for paused torrents (Chocobo1)
- BUGFIX: Log save_resume_data_failed_alert (Chocobo1)
- BUGFIX: Don't remove parent directories (Chocobo1)
- BUGFIX: Properly remove empty leftover folders after rename (Chocobo1)
- BUGFIX: Focus behavior row in Options dialog (silverqx)
- BUGFIX: Fix unable to rename folder on Windows when same is used in different case(Chocobo1)
- BUGFIX: Fix unable to control add torrent dialogs when opened simultaneously (Chocobo1)
- BUGFIX: Disable "Upload mode" when start preloaded torrent (Vladimir Golovnev (Glassez))
- BUGFIX: Fix wrong comparison result when sorting items(Chocobo1)
- BUGFIX: Fix sequential downloading when redirected (Vladimir Golovnev (Glassez))
- BUGFIX: Fix typos (Chocobo1)
- BUGFIX: Fix assertion fail (Chocobo1)
- BUGFIX: Change number of time axis divisions from 5 to 6 for convenience (dzmat)
- BUGFIX: Don't turn window blank when closed to system tray (Ekin Dursun)
- WEBUI: Fix WebUI encoding of special characters (Thomas Piccirello)
- WEBUI: Change the speed unit from Bytes/s to KiB/s for the rate limiter(jerrymakesjelly)
- WEBUI: Fix '+' char not decoded to space correctly (Chocobo1)
- RSS: Ignore RSS articles with non-unique identifiers (Vladimir Golovnev (Glassez))
- RSS: Perform more RSS parsing in working thread (Vladimir Golovnev (Glassez))
- RSS: Download RSS enclosure element if no proper MIME type is found (Matan Bareket)
* Sun May 05 2019 - sledgehammer999 <sledgehammer999@qbittorrent.org> - v4.1.6
- BUGFIX: Force recheck multiple torrents one by one in all possible cases. Closes #9120 (glassez)
- BUGFIX: Don't query Google for tracker favicons, for privacy reasons (sledgehammer999)

View File

@@ -13,8 +13,7 @@ It aims to be a good alternative to all other bittorrent clients
out there. qBittorrent is fast, stable and provides unicode
support as well as many features.
This product includes GeoLite data created by MaxMind, available from
https://www.maxmind.com/
The free [IP to Country Lite database](https://db-ip.com/db/download/ip-to-country-lite) by [DB-IP](https://db-ip.com/) is used for resolving the countries of peers. The database is licensed under the [Creative Commons Attribution 4.0 International License](https://creativecommons.org/licenses/by/4.0/).
### Installation:
For installation, follow the instructions from INSTALL file, but simple:

View File

@@ -1,9 +1,9 @@
#! /bin/sh
# Wrapper for compilers which do not understand '-c -o'.
scriptversion=2012-10-14.11; # UTC
scriptversion=2018-03-07.03; # UTC
# Copyright (C) 1999-2014 Free Software Foundation, Inc.
# Copyright (C) 1999-2018 Free Software Foundation, Inc.
# Written by Tom Tromey <tromey@cygnus.com>.
#
# This program is free software; you can redistribute it and/or modify
@@ -17,7 +17,7 @@ scriptversion=2012-10-14.11; # UTC
# 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, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
@@ -255,7 +255,8 @@ EOF
echo "compile $scriptversion"
exit $?
;;
cl | *[/\\]cl | cl.exe | *[/\\]cl.exe )
cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \
icl | *[/\\]icl | icl.exe | *[/\\]icl.exe )
func_cl_wrapper "$@" # Doesn't return...
;;
esac
@@ -339,9 +340,9 @@ exit $ret
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# eval: (add-hook 'before-save-hook 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC"
# End:

966
build-aux/config.guess vendored

File diff suppressed because it is too large Load Diff

2770
build-aux/config.sub vendored

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
#!/bin/sh
# install - install a program, script, or datafile
scriptversion=2013-12-25.23; # UTC
scriptversion=2018-03-11.20; # UTC
# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
@@ -271,15 +271,18 @@ do
fi
dst=$dst_arg
# If destination is a directory, append the input filename; won't work
# if double slashes aren't ignored.
# If destination is a directory, append the input filename.
if test -d "$dst"; then
if test "$is_target_a_directory" = never; then
echo "$0: $dst_arg: Is a directory" >&2
exit 1
fi
dstdir=$dst
dst=$dstdir/`basename "$src"`
dstbase=`basename "$src"`
case $dst in
*/) dst=$dst$dstbase;;
*) dst=$dst/$dstbase;;
esac
dstdir_status=0
else
dstdir=`dirname "$dst"`
@@ -288,6 +291,11 @@ do
fi
fi
case $dstdir in
*/) dstdirslash=$dstdir;;
*) dstdirslash=$dstdir/;;
esac
obsolete_mkdir_used=false
if test $dstdir_status != 0; then
@@ -324,34 +332,43 @@ do
# is incompatible with FreeBSD 'install' when (umask & 300) != 0.
;;
*)
# Note that $RANDOM variable is not portable (e.g. dash); Use it
# here however when possible just to lower collision chance.
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
trap 'ret=$?; rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null; exit $ret' 0
# Because "mkdir -p" follows existing symlinks and we likely work
# directly in world-writeable /tmp, make sure that the '$tmpdir'
# directory is successfully created first before we actually test
# 'mkdir -p' feature.
if (umask $mkdir_umask &&
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
$mkdirprog $mkdir_mode "$tmpdir" &&
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1
then
if test -z "$dir_arg" || {
# Check for POSIX incompatibilities with -m.
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
# other-writable bit of parent directory when it shouldn't.
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
ls_ld_tmpdir=`ls -ld "$tmpdir"`
test_tmpdir="$tmpdir/a"
ls_ld_tmpdir=`ls -ld "$test_tmpdir"`
case $ls_ld_tmpdir in
d????-?r-*) different_mode=700;;
d????-?--*) different_mode=755;;
*) false;;
esac &&
$mkdirprog -m$different_mode -p -- "$tmpdir" && {
ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
$mkdirprog -m$different_mode -p -- "$test_tmpdir" && {
ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"`
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
}
}
then posix_mkdir=:
fi
rmdir "$tmpdir/d" "$tmpdir"
rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir"
else
# Remove any dirs left behind by ancient mkdir implementations.
rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null
fi
trap '' 0;;
esac;;
@@ -427,8 +444,8 @@ do
else
# Make a couple of temp file names in the proper directory.
dsttmp=$dstdir/_inst.$$_
rmtmp=$dstdir/_rm.$$_
dsttmp=${dstdirslash}_inst.$$_
rmtmp=${dstdirslash}_rm.$$_
# Trap to clean up those temp files at exit.
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
@@ -493,9 +510,9 @@ do
done
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# eval: (add-hook 'before-save-hook 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC"
# End:

View File

@@ -1,9 +1,9 @@
#! /bin/sh
# Common wrapper for a few potentially missing GNU programs.
scriptversion=2013-10-28.13; # UTC
scriptversion=2018-03-07.03; # UTC
# Copyright (C) 1996-2014 Free Software Foundation, Inc.
# Copyright (C) 1996-2018 Free Software Foundation, Inc.
# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
# This program is free software; you can redistribute it and/or modify
@@ -17,7 +17,7 @@ scriptversion=2013-10-28.13; # UTC
# 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, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
@@ -101,9 +101,9 @@ else
exit $st
fi
perl_URL=http://www.perl.org/
flex_URL=http://flex.sourceforge.net/
gnu_software_URL=http://www.gnu.org/software
perl_URL=https://www.perl.org/
flex_URL=https://github.com/westes/flex
gnu_software_URL=https://www.gnu.org/software
program_details ()
{
@@ -207,9 +207,9 @@ give_advice "$1" | sed -e '1s/^/WARNING: /' \
exit $st
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# eval: (add-hook 'before-save-hook 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC"
# End:

31
configure vendored
View File

@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for qbittorrent v4.1.6.
# Generated by GNU Autoconf 2.69 for qbittorrent v4.1.9.1.
#
# Report bugs to <bugs.qbittorrent.org>.
#
@@ -580,8 +580,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='qbittorrent'
PACKAGE_TARNAME='qbittorrent'
PACKAGE_VERSION='v4.1.6'
PACKAGE_STRING='qbittorrent v4.1.6'
PACKAGE_VERSION='v4.1.9.1'
PACKAGE_STRING='qbittorrent v4.1.9.1'
PACKAGE_BUGREPORT='bugs.qbittorrent.org'
PACKAGE_URL='https://www.qbittorrent.org/'
@@ -1299,7 +1299,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 qbittorrent v4.1.6 to adapt to many kinds of systems.
\`configure' configures qbittorrent v4.1.9.1 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1370,7 +1370,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of qbittorrent v4.1.6:";;
short | recursive ) echo "Configuration of qbittorrent v4.1.9.1:";;
esac
cat <<\_ACEOF
@@ -1505,7 +1505,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
qbittorrent configure v4.1.6
qbittorrent configure v4.1.9.1
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1644,7 +1644,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 qbittorrent $as_me v4.1.6, which was
It was created by qbittorrent $as_me v4.1.9.1, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@@ -3822,7 +3822,7 @@ fi
# Define the identity of the package.
PACKAGE='qbittorrent'
VERSION='v4.1.6'
VERSION='v4.1.9.1'
cat >>confdefs.h <<_ACEOF
@@ -4178,7 +4178,6 @@ QBT_CXX="$CXX"
# Define --wth-* and --enable-* arguments
# Check whether --with-qtsingleapplication was given.
if test "${with_qtsingleapplication+set}" = set; then :
withval=$with_qtsingleapplication;
@@ -4749,7 +4748,9 @@ fi
case ${host_cpu} in #(
x86_64) :
libsubdirs="lib64 libx32 lib lib64" ;; #(
ppc64|s390x|sparc64|aarch64|ppc64le) :
mips*64*) :
libsubdirs="lib64 lib32 lib lib64" ;; #(
ppc64|powerpc64|s390x|sparc64|aarch64|ppc64le|powerpc64le|riscv64) :
libsubdirs="lib64 lib lib64" ;; #(
*) :
libsubdirs="lib"
@@ -5271,7 +5272,7 @@ fi
fi
if test "x$ax_lib" = "x"; then
as_fn_error $? "Could not find a version of the library!" "$LINENO" 5
as_fn_error $? "Could not find a version of the Boost::System library!" "$LINENO" 5
fi
if test "x$link_system" = "xno"; then
as_fn_error $? "Could not link against $ax_lib !" "$LINENO" 5
@@ -6274,7 +6275,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by qbittorrent $as_me v4.1.6, which was
This file was extended by qbittorrent $as_me v4.1.9.1, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -6332,7 +6333,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
qbittorrent config.status v4.1.6
qbittorrent config.status v4.1.9.1
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
@@ -7590,7 +7591,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by qbittorrent $as_me v4.1.6, which was
This file was extended by qbittorrent $as_me v4.1.9.1, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -7648,7 +7649,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
qbittorrent config.status v4.1.6
qbittorrent config.status v4.1.9.1
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"

View File

@@ -1,4 +1,4 @@
AC_INIT([qbittorrent], [v4.1.6], [bugs.qbittorrent.org], [], [https://www.qbittorrent.org/])
AC_INIT([qbittorrent], [v4.1.9.1], [bugs.qbittorrent.org], [], [https://www.qbittorrent.org/])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([m4])
AC_PROG_CC

2
dist/mac/Info.plist vendored
View File

@@ -55,7 +55,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>4.1.6</string>
<string>4.1.9</string>
<key>CFBundleExecutable</key>
<string>@EXECUTABLE@</string>
<key>CFBundleIdentifier</key>

View File

@@ -27,7 +27,7 @@ XPStyle on
!define CSIDL_LOCALAPPDATA '0x1C' ;Local Application Data path
; Program specific
!define PROG_VERSION "4.1.6"
!define PROG_VERSION "4.1.9.1"
!define MUI_FINISHPAGE_RUN
!define MUI_FINISHPAGE_RUN_FUNCTION PageFinishRun
@@ -54,7 +54,7 @@ VIAddVersionKey "LegalCopyright" "Copyright ©2006-2019 The qBittorrent project"
VIAddVersionKey "FileDescription" "qBittorrent - A Bittorrent Client"
VIAddVersionKey "FileVersion" "${PROG_VERSION}"
VIProductVersion "${PROG_VERSION}.0"
VIProductVersion "${PROG_VERSION}.1"
; The default installation directory. It changes depending if we install in the 64bit dir or not.
; A caveat of this is if a user has installed a 32bit version and then runs the 64bit installer

View File

@@ -33,7 +33,7 @@
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 42
#serial 47
# example boost program (need to pass version)
m4_define([_AX_BOOST_BASE_PROGRAM],
@@ -113,7 +113,8 @@ AC_DEFUN([_AX_BOOST_BASE_RUNDETECT],[
dnl are found, e.g. when only header-only libraries are installed!
AS_CASE([${host_cpu}],
[x86_64],[libsubdirs="lib64 libx32 lib lib64"],
[ppc64|s390x|sparc64|aarch64|ppc64le],[libsubdirs="lib64 lib lib64"],
[mips*64*],[libsubdirs="lib64 lib32 lib lib64"],
[ppc64|powerpc64|s390x|sparc64|aarch64|ppc64le|powerpc64le|riscv64],[libsubdirs="lib64 lib lib64"],
[libsubdirs="lib"]
)

View File

@@ -31,7 +31,7 @@
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 19
#serial 20
AC_DEFUN([AX_BOOST_SYSTEM],
[
@@ -108,7 +108,7 @@ AC_DEFUN([AX_BOOST_SYSTEM],
fi
if test "x$ax_lib" = "x"; then
AC_MSG_ERROR(Could not find a version of the library!)
AC_MSG_ERROR(Could not find a version of the Boost::System library!)
fi
if test "x$link_system" = "xno"; then
AC_MSG_ERROR(Could not link against $ax_lib !)

View File

@@ -332,7 +332,11 @@ void Application::runExternalProgram(const BitTorrent::TorrentHandle *torrent) c
::LocalFree(args);
#else
QProcess::startDetached(QLatin1String("/bin/sh"), {QLatin1String("-c"), program});
// Cannot give users shell environment by default, as doing so could
// enable command injection via torrent name and other arguments
// (especially when some automated download mechanism has been setup).
// See: https://github.com/qbittorrent/qBittorrent/issues/10925
QProcess::startDetached(program);
#endif
}

View File

@@ -101,6 +101,7 @@ QtLocalPeer::QtLocalPeer(QObject* parent, const QString &appId)
#endif
server = new QLocalServer(this);
server->setSocketOptions(QLocalServer::UserAccessOption);
QString lockName = QDir(QDir::tempPath()).absolutePath()
+ QLatin1Char('/') + socketName
+ QLatin1String("-lockfile");
@@ -191,6 +192,12 @@ void QtLocalPeer::receiveConnection()
QByteArray uMsg;
quint32 remaining;
ds >> remaining;
if (remaining > 65535) {
// drop suspiciously large data
delete socket;
return;
}
uMsg.resize(remaining);
int got = 0;
char* uMsgBuf = uMsg.data();

File diff suppressed because it is too large Load Diff

View File

@@ -482,6 +482,7 @@ namespace BitTorrent
void bottomTorrentsPriority(const QStringList &hashes);
// TorrentHandle interface
void handleTorrentSaveResumeDataRequested(TorrentHandle *const torrent);
void handleTorrentShareLimitChanged(TorrentHandle *const torrent);
void handleTorrentNameChanged(TorrentHandle *const torrent);
void handleTorrentSavePathChanged(TorrentHandle *const torrent);
@@ -608,13 +609,13 @@ namespace BitTorrent
void updateSeedingLimitTimer();
void exportTorrentFile(TorrentHandle *const torrent, TorrentExportFolder folder = TorrentExportFolder::Regular);
void saveTorrentResumeData(TorrentHandle *const torrent);
void handleAlert(libtorrent::alert *a);
void dispatchTorrentAlert(libtorrent::alert *a);
void handleAddTorrentAlert(libtorrent::add_torrent_alert *p);
void handleStateUpdateAlert(libtorrent::state_update_alert *p);
void handleMetadataReceivedAlert(libtorrent::metadata_received_alert *p);
void handleMetadataReceivedAlert(const libtorrent::metadata_received_alert *p);
void handleTorrentPausedAlert(const libtorrent::torrent_paused_alert *p);
void handleFileErrorAlert(libtorrent::file_error_alert *p);
void handleTorrentRemovedAlert(libtorrent::torrent_removed_alert *p);
void handleTorrentDeletedAlert(libtorrent::torrent_deleted_alert *p);

File diff suppressed because it is too large Load Diff

View File

@@ -385,6 +385,12 @@ namespace BitTorrent
private:
typedef boost::function<void ()> EventTrigger;
#if (LIBTORRENT_VERSION_NUM < 10200)
using LTFileIndex = int;
#else
using LTFileIndex = lt::file_index_t;
#endif
void updateStatus();
void updateStatus(const libtorrent::torrent_status &nativeStatus);
void updateState();
@@ -446,6 +452,10 @@ namespace BitTorrent
QQueue<EventTrigger> m_moveFinishedTriggers;
int m_renameCount;
// Until libtorrent provide an "old_name" field in `file_renamed_alert`
// we will rely on this workaround to remove empty leftover folders
QHash<LTFileIndex, QVector<QString>> m_oldPath;
bool m_useAutoTMM;
// Persistent data
@@ -457,6 +467,7 @@ namespace BitTorrent
qreal m_ratioLimit;
int m_seedingTimeLimit;
bool m_tempPathDisabled;
bool m_fastresumeDataRejected;
bool m_hasMissingFiles;
bool m_hasRootFolder;
bool m_needsToSetFirstLastPiecePriority;
@@ -466,12 +477,15 @@ namespace BitTorrent
enum StartupState
{
NotStarted,
Starting,
Started
Preparing, // torrent is preparing to start regular processing
Starting, // torrent is prepared and starting to perform regular processing
Started // torrent is performing regular processing
};
StartupState m_startupState = Preparing;
// Handle torrent state when it starts performing some service job
// being in Paused state so it might be unpaused internally and then paused again
bool m_pauseWhenReady;
StartupState m_startupState = NotStarted;
bool m_unchecked = false;
};
}

View File

@@ -340,8 +340,13 @@ TorrentInfo::PieceRange TorrentInfo::filePieces(int fileIndex) const
const libt::file_storage &files = nativeInfo()->files();
const auto fileSize = files.file_size(fileIndex);
const auto fileOffset = files.file_offset(fileIndex);
return makeInterval(static_cast<int>(fileOffset / pieceLength()),
static_cast<int>((fileOffset + fileSize - 1) / pieceLength()));
const int beginIdx = (fileOffset / pieceLength());
const int endIdx = ((fileOffset + fileSize - 1) / pieceLength());
if (fileSize <= 0)
return {beginIdx, 0};
return makeInterval(beginIdx, endIdx);
}
void TorrentInfo::renameFile(const int index, const QString &newPath)

View File

@@ -29,16 +29,11 @@
#include "tracker.h"
#include <vector>
#include <libtorrent/bencode.hpp>
#include <libtorrent/entry.hpp>
#include "base/global.h"
#include "base/http/server.h"
#include "base/preferences.h"
#include "base/utils/bytearray.h"
#include "base/utils/string.h"
// static limits
static const int MAX_TORRENTS = 100;
@@ -133,21 +128,7 @@ Http::Response Tracker::processRequest(const Http::Request &request, const Http:
void Tracker::respondToAnnounceRequest()
{
QMap<QString, QByteArray> queryParams;
// Parse GET parameters
using namespace Utils::ByteArray;
for (const QByteArray &param : asConst(splitToViews(m_request.query, "&"))) {
const int sepPos = param.indexOf('=');
if (sepPos <= 0) continue; // ignores params without name
const QByteArray nameComponent = midView(param, 0, sepPos);
const QByteArray valueComponent = midView(param, (sepPos + 1));
const QString paramName = QString::fromUtf8(QByteArray::fromPercentEncoding(nameComponent));
const QByteArray paramValue = QByteArray::fromPercentEncoding(valueComponent);
queryParams[paramName] = paramValue;
}
const QMap<QString, QByteArray> &queryParams = m_request.query;
TrackerAnnounceRequest announceReq;
// IP

View File

@@ -36,7 +36,6 @@
#include "base/http/irequesthandler.h"
#include "base/http/responsebuilder.h"
#include "base/http/types.h"
namespace libtorrent
{

View File

@@ -162,7 +162,7 @@ void FileSystemWatcher::processTorrentsInDir(const QDir &dir)
const QStringList files = dir.entryList({"*.torrent", "*.magnet"}, QDir::Files);
for (const QString &file : files) {
const QString fileAbsPath = dir.absoluteFilePath(file);
if (file.endsWith(".magnet"))
if (file.endsWith(".magnet", Qt::CaseInsensitive))
torrents << fileAbsPath;
else if (BitTorrent::TorrentInfo::loadFromFile(fileAbsPath).isValid())
torrents << fileAbsPath;

View File

@@ -36,6 +36,7 @@
#include <QUrl>
#include <QUrlQuery>
#include "base/global.h"
#include "base/utils/bytearray.h"
#include "base/utils/string.h"
@@ -180,14 +181,29 @@ bool RequestParser::parseRequestLine(const QString &line)
m_request.method = match.captured(1);
// Request Target
// URL components should be separated before percent-decoding
// [rfc3986] 2.4 When to Encode or Decode
const QByteArray url {match.captured(2).toLatin1()};
const int sepPos = url.indexOf('?');
const QByteArray pathComponent = ((sepPos == -1) ? url : Utils::ByteArray::midView(url, 0, sepPos));
const QByteArray pathComponent = ((sepPos == -1) ? url : midView(url, 0, sepPos));
m_request.path = QString::fromUtf8(QByteArray::fromPercentEncoding(pathComponent));
if (sepPos >= 0)
m_request.query = url.mid(sepPos + 1);
if (sepPos >= 0) {
const QByteArray query = midView(url, (sepPos + 1));
// [rfc3986] 2.4 When to Encode or Decode
// URL components should be separated before percent-decoding
for (const QByteArray &param : asConst(splitToViews(query, "&"))) {
const int eqCharPos = param.indexOf('=');
if (eqCharPos <= 0) continue; // ignores params without name
const QByteArray nameComponent = midView(param, 0, eqCharPos);
const QByteArray valueComponent = midView(param, (eqCharPos + 1));
const QString paramName = QString::fromUtf8(QByteArray::fromPercentEncoding(nameComponent).replace('+', ' '));
const QByteArray paramValue = QByteArray::fromPercentEncoding(valueComponent).replace('+', ' ');
m_request.query[paramName] = paramValue;
}
}
// HTTP-version
m_request.version = match.captured(3);

View File

@@ -97,8 +97,8 @@ namespace Http
QString version;
QString method;
QString path;
QByteArray query;
QStringMap headers;
QMap<QString, QByteArray> query;
QStringMap posts;
QVector<UploadedFile> files;
};

View File

@@ -245,7 +245,7 @@ void Net::DownloadManager::applyProxySettings()
void Net::DownloadManager::handleReplyFinished(QNetworkReply *reply)
{
const ServiceID id = ServiceID::fromURL(reply->url());
const ServiceID id = ServiceID::fromURL(reply->request().url());
auto waitingJobsIter = m_waitingJobs.find(id);
if ((waitingJobsIter == m_waitingJobs.end()) || waitingJobsIter.value().isEmpty()) {
m_busyServices.remove(id);

View File

@@ -44,10 +44,9 @@
#include "downloadmanager.h"
#include "private/geoipdatabase.h"
static const char DATABASE_URL[] = "https://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.mmdb.gz";
static const char GEOIP_FOLDER[] = "GeoIP";
static const char GEOIP_FILENAME[] = "GeoLite2-Country.mmdb";
static const int UPDATE_INTERVAL = 30; // Days between database updates
static const QString DATABASE_URL = QStringLiteral("https://download.db-ip.com/free/dbip-country-lite-%1.mmdb.gz");
static const char GEODB_FOLDER[] = "GeoDB";
static const char GEODB_FILENAME[] = "dbip-country-lite.mmdb";
using namespace Net;
@@ -96,29 +95,45 @@ void GeoIPManager::loadDatabase()
}
QString filepath = Utils::Fs::expandPathAbs(
QString("%1%2/%3").arg(specialFolderLocation(SpecialFolder::Data), GEOIP_FOLDER, GEOIP_FILENAME));
QString("%1%2/%3").arg(specialFolderLocation(SpecialFolder::Data), GEODB_FOLDER, GEODB_FILENAME));
QString error;
m_geoIPDatabase = GeoIPDatabase::load(filepath, error);
if (m_geoIPDatabase)
Logger::instance()->addMessage(tr("GeoIP database loaded. Type: %1. Build time: %2.")
Logger::instance()->addMessage(tr("IP geolocation database loaded. Type: %1. Build time: %2.")
.arg(m_geoIPDatabase->type(), m_geoIPDatabase->buildEpoch().toString()),
Log::INFO);
else
Logger::instance()->addMessage(tr("Couldn't load GeoIP database. Reason: %1").arg(error), Log::WARNING);
Logger::instance()->addMessage(tr("Couldn't load IP geolocation database. Reason: %1").arg(error), Log::WARNING);
manageDatabaseUpdate();
}
void GeoIPManager::manageDatabaseUpdate()
{
if (!m_geoIPDatabase || (m_geoIPDatabase->buildEpoch().daysTo(QDateTime::currentDateTimeUtc()) >= UPDATE_INTERVAL))
const auto expired = [](const QDateTime &testDateTime)
{
const QDate testDate = testDateTime.date();
const QDate curDate = QDateTime::currentDateTimeUtc().date();
if ((testDate.year() < curDate.year()) && (curDate.day() > 1))
return true;
if ((testDate.month() < curDate.month()) && (curDate.day() > 1))
return true;
return false;
};
if (!m_geoIPDatabase || expired(m_geoIPDatabase->buildEpoch()))
downloadDatabaseFile();
}
void GeoIPManager::downloadDatabaseFile()
{
DownloadHandler *handler = DownloadManager::instance()->download({DATABASE_URL});
const QDate curDate = QDateTime::currentDateTimeUtc().date();
const QString curUrl = DATABASE_URL.arg(curDate.toString("yyyy-MM"));
DownloadHandler *handler = DownloadManager::instance()->download({curUrl});
connect(handler, static_cast<void (Net::DownloadHandler::*)(const QString &, const QByteArray &)>(&Net::DownloadHandler::downloadFinished)
, this, &GeoIPManager::downloadFinished);
connect(handler, &Net::DownloadHandler::downloadFailed, this, &GeoIPManager::downloadFailed);
@@ -420,7 +435,7 @@ void GeoIPManager::downloadFinished(const QString &url, QByteArray data)
bool ok = false;
data = Utils::Gzip::decompress(data, &ok);
if (!ok) {
Logger::instance()->addMessage(tr("Could not decompress GeoIP database file."), Log::WARNING);
LogMsg(tr("Could not decompress IP geolocation database file."), Log::WARNING);
return;
}
@@ -431,28 +446,25 @@ void GeoIPManager::downloadFinished(const QString &url, QByteArray data)
if (m_geoIPDatabase)
delete m_geoIPDatabase;
m_geoIPDatabase = geoIPDatabase;
Logger::instance()->addMessage(tr("GeoIP database loaded. Type: %1. Build time: %2.")
LogMsg(tr("IP geolocation database loaded. Type: %1. Build time: %2.")
.arg(m_geoIPDatabase->type(), m_geoIPDatabase->buildEpoch().toString()),
Log::INFO);
QString targetPath = Utils::Fs::expandPathAbs(
specialFolderLocation(SpecialFolder::Data) + GEOIP_FOLDER);
const QString targetPath = Utils::Fs::expandPathAbs(
specialFolderLocation(SpecialFolder::Data) + GEODB_FOLDER);
if (!QDir(targetPath).exists())
QDir().mkpath(targetPath);
QFile targetFile(QString("%1/%2").arg(targetPath, GEOIP_FILENAME));
if (!targetFile.open(QFile::WriteOnly) || (targetFile.write(data) == -1)) {
Logger::instance()->addMessage(
tr("Couldn't save downloaded GeoIP database file."), Log::WARNING);
}
else {
Logger::instance()->addMessage(tr("Successfully updated GeoIP database."), Log::INFO);
}
QFile targetFile(QString("%1/%2").arg(targetPath, GEODB_FILENAME));
if (!targetFile.open(QFile::WriteOnly) || (targetFile.write(data) == -1))
LogMsg(tr("Couldn't save downloaded IP geolocation database file."), Log::WARNING);
else
LogMsg(tr("Successfully updated IP geolocation database."), Log::INFO);
}
else {
delete geoIPDatabase;
}
}
else {
Logger::instance()->addMessage(tr("Couldn't load GeoIP database. Reason: %1").arg(error), Log::WARNING);
LogMsg(tr("Couldn't load IP geolocation database. Reason: %1").arg(error), Log::WARNING);
}
}

View File

@@ -38,7 +38,6 @@
namespace
{
const qint32 MAX_FILE_SIZE = 67108864; // 64MB
const char DB_TYPE[] = "GeoLite2-Country";
const quint32 MAX_METADATA_SIZE = 131072; // 128KB
const char METADATA_BEGIN_MARK[] = "\xab\xcd\xefMaxMind.com";
const char DATA_SECTION_SEPARATOR[16] = {0};
@@ -144,7 +143,7 @@ GeoIPDatabase::~GeoIPDatabase()
QString GeoIPDatabase::type() const
{
return DB_TYPE;
return m_dbType;
}
quint16 GeoIPDatabase::ipVersion() const
@@ -255,11 +254,7 @@ bool GeoIPDatabase::parseMetadata(const QVariantHash &metadata, QString &error)
m_indexSize = m_nodeCount * m_nodeSize;
CHECK_METADATA_REQ(database_type, QString);
QString dbType = metadata.value("database_type").toString();
if (dbType != DB_TYPE) {
error = tr("Invalid database type: %1").arg(dbType);
return false;
}
m_dbType = metadata.value("database_type").toString();
CHECK_METADATA_REQ(build_epoch, ULongLong);
m_buildEpoch = QDateTime::fromTime_t(metadata.value("build_epoch").toULongLong());
@@ -272,7 +267,7 @@ bool GeoIPDatabase::parseMetadata(const QVariantHash &metadata, QString &error)
bool GeoIPDatabase::loadDB(QString &error) const
{
qDebug() << "Parsing MaxMindDB index tree...";
qDebug() << "Parsing IP geolocation database index tree...";
const int nodeSize = m_recordSize / 4; // in bytes
const int indexSize = m_nodeCount * nodeSize;

View File

@@ -93,6 +93,7 @@ private:
int m_indexSize;
int m_recordBytes;
QDateTime m_buildEpoch;
QString m_dbType;
// Search data
mutable QHash<quint32, QString> m_countries;
quint32 m_size;

View File

@@ -585,11 +585,13 @@ void Parser::parse_impl(const QByteArray &feedData)
emit finished(m_result);
m_result.articles.clear(); // clear articles only
m_articleIDs.clear();
}
void Parser::parseRssArticle(QXmlStreamReader &xml)
{
QVariantHash article;
QString altTorrentUrl;
while (!xml.atEnd()) {
xml.readNext();
@@ -605,6 +607,8 @@ void Parser::parseRssArticle(QXmlStreamReader &xml)
else if (name == QLatin1String("enclosure")) {
if (xml.attributes().value("type") == QLatin1String("application/x-bittorrent"))
article[Article::KeyTorrentURL] = xml.attributes().value(QLatin1String("url")).toString();
else if (xml.attributes().value("type").isEmpty())
altTorrentUrl = xml.attributes().value(QLatin1String("url")).toString();
}
else if (name == QLatin1String("link")) {
const QString text {xml.readElementText().trimmed()};
@@ -631,7 +635,10 @@ void Parser::parseRssArticle(QXmlStreamReader &xml)
}
}
m_result.articles.prepend(article);
if (article[Article::KeyTorrentURL].toString().isEmpty())
article[Article::KeyTorrentURL] = altTorrentUrl;
addArticle(article);
}
void Parser::parseRSSChannel(QXmlStreamReader &xml)
@@ -726,7 +733,7 @@ void Parser::parseAtomArticle(QXmlStreamReader &xml)
}
}
m_result.articles.prepend(article);
addArticle(article);
}
void Parser::parseAtomChannel(QXmlStreamReader &xml)
@@ -756,3 +763,34 @@ void Parser::parseAtomChannel(QXmlStreamReader &xml)
}
}
}
void Parser::addArticle(QVariantHash article)
{
QVariant &torrentURL = article[Article::KeyTorrentURL];
if (torrentURL.toString().isEmpty())
torrentURL = article[Article::KeyLink];
// If item does not have an ID, fall back to some other identifier.
QVariant &localId = article[Article::KeyId];
if (localId.toString().isEmpty())
localId = article.value(Article::KeyTorrentURL);
if (localId.toString().isEmpty())
localId = article.value(Article::KeyTitle);
if (localId.toString().isEmpty()) {
// The article could not be uniquely identified
// since it has no appropriate data.
// Just ignore it.
return;
}
if (m_articleIDs.contains(localId.toString())) {
// The article could not be uniquely identified
// since the Feed has duplicate identifiers.
// Just ignore it.
return;
}
m_articleIDs.insert(localId.toString());
m_result.articles.prepend(article);
}

View File

@@ -31,6 +31,7 @@
#include <QList>
#include <QObject>
#include <QSet>
#include <QString>
#include <QVariantHash>
@@ -65,9 +66,11 @@ namespace RSS
void parseRSSChannel(QXmlStreamReader &xml);
void parseAtomArticle(QXmlStreamReader &xml);
void parseAtomChannel(QXmlStreamReader &xml);
void addArticle(QVariantHash article);
QString m_baseUrl;
ParsingResult m_result;
QSet<QString> m_articleIDs;
};
}
}

View File

@@ -419,24 +419,10 @@ int Feed::updateArticles(const QList<QVariantHash> &loadedArticles)
QVector<QVariantHash> newArticles;
newArticles.reserve(loadedArticles.size());
for (QVariantHash article : loadedArticles) {
QVariant &torrentURL = article[Article::KeyTorrentURL];
if (torrentURL.toString().isEmpty())
torrentURL = article[Article::KeyLink];
// If item does not have an ID, fall back to some other identifier.
QVariant &localId = article[Article::KeyId];
if (localId.toString().isEmpty())
localId = article.value(Article::KeyTorrentURL);
if (localId.toString().isEmpty())
localId = article.value(Article::KeyTitle);
if (localId.toString().isEmpty())
continue;
// If article has no publication date we use feed update time as a fallback.
// To prevent processing of "out-of-limit" articles we must not assign dates
// that are earlier than the dates of existing articles.
const Article *existingArticle = articleByGUID(localId.toString());
const Article *existingArticle = articleByGUID(article[Article::KeyId].toString());
if (existingArticle) {
dummyPubDate = existingArticle->date().addMSecs(-1);
continue;

Some files were not shown because too many files have changed in this diff Show More