mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-20 05:13:30 -07:00
- No longer ships GeoIP database since most distributions provide it in a separate package
- GeoIP database is no longer embedded in qBittorrent executable unless --with-geoip-database-embedded parameter is passed to configure (see src/geoip/REAME) - Dropped "CONFIG += x11 network" in project file since it does not seem to be required - Updated configure file to reflect Geoip changes
This commit is contained in:
parent
8df1708491
commit
968a5f3017
11 changed files with 147 additions and 88 deletions
42
src/geoip.h
42
src/geoip.h
|
@ -40,43 +40,27 @@
|
|||
|
||||
using namespace libtorrent;
|
||||
|
||||
// TODO: Update from Internet
|
||||
class GeoIP {
|
||||
protected:
|
||||
static QString geoipFolder(bool embedded=false) {
|
||||
#ifdef WITH_GEOIP_EMBEDDED
|
||||
if(embedded)
|
||||
return ":/geoip/";
|
||||
return misc::qBittorrentPath()+"geoip"+QDir::separator();
|
||||
#else
|
||||
if(QFile::exists("/usr/local/share/GeoIP/GeoIP.dat"))
|
||||
return "/usr/local/share/GeoIP/";
|
||||
return "/usr/share/GeoIP/";
|
||||
#endif
|
||||
}
|
||||
|
||||
static QString geoipDBpath(bool embedded=false) {
|
||||
return geoipFolder(embedded)+"GeoIP.dat";
|
||||
}
|
||||
|
||||
static QString geoipVersionPath(bool embedded=false) {
|
||||
return geoipFolder(embedded)+"VERSION";
|
||||
}
|
||||
|
||||
static int getDBVersion(bool embedded = false) {
|
||||
QFile vFile(geoipVersionPath(embedded));
|
||||
qDebug("Reading file at %s", geoipVersionPath(embedded).toLocal8Bit().data());
|
||||
if(vFile.exists() && vFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
qDebug("File exists and was opened");
|
||||
QByteArray v = vFile.readAll().trimmed();
|
||||
/*while(!v.isEmpty() && v[0] == '0') {
|
||||
v = v.mid(1);
|
||||
}*/
|
||||
qDebug("Read version: %s", v.data());
|
||||
bool ok = false;
|
||||
int version = v.toInt(&ok);
|
||||
qDebug("Read version %d (Error? %d)", version, (int) !ok);
|
||||
if(ok) return version;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void updateLocalDb() {
|
||||
if(getDBVersion(true) > getDBVersion(false)) { // Update required
|
||||
#ifdef WITH_GEOIP_EMBEDDED
|
||||
static void exportEmbeddedDb() {
|
||||
if(!QFile::exists(geoipDBpath(false)) || QFile(geoipDBpath(false)).size() != QFile(geoipDBpath(true)).size()) { // Export is required
|
||||
qDebug("A local Geoip database update is required, proceeding...");
|
||||
// Create geoip folder is necessary
|
||||
QDir gfolder(geoipFolder(false));
|
||||
|
@ -86,18 +70,18 @@ protected:
|
|||
// Remove destination files
|
||||
if(QFile::exists(geoipDBpath(false)))
|
||||
QFile::remove(geoipDBpath(false));
|
||||
if(QFile::exists(geoipVersionPath(false)))
|
||||
QFile::remove(geoipVersionPath(false));
|
||||
// Copy from executable to hard disk
|
||||
QFile::copy(geoipDBpath(true), geoipDBpath(false));
|
||||
QFile::copy(geoipVersionPath(true), geoipVersionPath(false));
|
||||
qDebug("Local Geoip database was updated");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
public:
|
||||
static void loadDatabase(session *s) {
|
||||
updateLocalDb();
|
||||
#ifdef WITH_GEOIP_EMBEDDED
|
||||
exportEmbeddedDb();
|
||||
#endif
|
||||
if(QFile::exists(geoipDBpath(false))) {
|
||||
qDebug("Loading GeoIP database from %s...", geoipDBpath(false).toLocal8Bit().data());
|
||||
if(!s->load_country_db(geoipDBpath(false).toLocal8Bit().data())) {
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
<!DOCTYPE RCC><RCC version="1.0">
|
||||
<qresource>
|
||||
<file>geoip/GeoIP.dat</file>
|
||||
<file>geoip/VERSION</file>
|
||||
</qresource>
|
||||
<RCC>
|
||||
<qresource prefix="/" >
|
||||
<file>geoip/GeoIP.dat</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
|
|
Binary file not shown.
|
@ -1,39 +0,0 @@
|
|||
There are two licenses, one for the C library software, and one for
|
||||
the database.
|
||||
|
||||
SOFTWARE LICENSE (C library)
|
||||
|
||||
The GeoIP C Library is licensed under the LGPL. For details see
|
||||
the COPYING file.
|
||||
|
||||
OPEN DATA LICENSE (GeoLite Country and GeoLite City databases)
|
||||
|
||||
Copyright (c) 2008 MaxMind, Inc. All Rights Reserved.
|
||||
|
||||
All advertising materials and documentation mentioning features or use of
|
||||
this database must display the following acknowledgment:
|
||||
"This product includes GeoLite data created by MaxMind, available from
|
||||
http://maxmind.com/"
|
||||
|
||||
Redistribution and use with or without modification, are permitted provided
|
||||
that the following conditions are met:
|
||||
1. Redistributions must retain the above copyright notice, this list of
|
||||
conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
2. All advertising materials and documentation mentioning features or use of
|
||||
this database must display the following acknowledgement:
|
||||
"This product includes GeoLite data created by MaxMind, available from
|
||||
http://maxmind.com/"
|
||||
3. "MaxMind" may not be used to endorse or promote products derived from this
|
||||
database without specific prior written permission.
|
||||
|
||||
THIS DATABASE IS PROVIDED BY MAXMIND, INC ``AS IS'' AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL MAXMIND BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
DATABASE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
12
src/geoip/README
Normal file
12
src/geoip/README
Normal file
|
@ -0,0 +1,12 @@
|
|||
If you wish to embed GeoIP database into qBittorrent executable, please download put GeoIP.dat in this folder.
|
||||
|
||||
GeoIP Database can be downloaded from here:
|
||||
* http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
|
||||
Note that the database should be uncompressed.
|
||||
|
||||
Embedding GeoIP database into qBittorrent executable is advised for:
|
||||
* Windows
|
||||
* Mac OS X
|
||||
* Linux distributions that don't provide GeoIP database in a separate package
|
||||
|
||||
On Linux operating system, since this is not the default behavior, you also need to pass --with-geoip-database-embedded parameter to the configure file.
|
|
@ -1 +0,0 @@
|
|||
0911
|
40
src/src.pro
40
src/src.pro
|
@ -9,12 +9,10 @@ DEBUG_MODE = 0
|
|||
TEMPLATE = app
|
||||
TARGET = qbittorrent
|
||||
CONFIG += qt \
|
||||
thread \
|
||||
x11 \
|
||||
network
|
||||
thread
|
||||
|
||||
# Update this VERSION for each release
|
||||
DEFINES += VERSION=\\\"v2.0.0rc5\\\"
|
||||
DEFINES += VERSION=\\\"v2.0.0rc6\\\"
|
||||
DEFINES += VERSION_MAJOR=2
|
||||
DEFINES += VERSION_MINOR=0
|
||||
DEFINES += VERSION_BUGFIX=0
|
||||
|
@ -105,11 +103,41 @@ win32:LIBS += -lssl32 \
|
|||
-lwsock32 \
|
||||
-ladvapi32 \
|
||||
-lwinmm
|
||||
|
||||
win32 {
|
||||
DEFINES += WITH_GEOIP_EMBEDDED
|
||||
message("On Windows, GeoIP database must be embedded.")
|
||||
}
|
||||
|
||||
macx {
|
||||
DEFINES += WITH_GEOIP_EMBEDDED
|
||||
message("On Mac OS X, GeoIP database must be embedded.")
|
||||
}
|
||||
|
||||
unix:!macx {
|
||||
contains(DEFINES, WITH_GEOIP_EMBEDDED) {
|
||||
message("You chose to embed GeoIP database in qBittorrent executable.")
|
||||
}
|
||||
}
|
||||
|
||||
RESOURCES = icons.qrc \
|
||||
lang.qrc \
|
||||
search.qrc \
|
||||
webui.qrc \
|
||||
geoip.qrc
|
||||
webui.qrc
|
||||
|
||||
# Add GeoIP resource file if the GeoIP database
|
||||
# should be embedded in qBittorrent executable
|
||||
contains(DEFINES, WITH_GEOIP_EMBEDDED) {
|
||||
exists("geoip/GeoIP.dat") {
|
||||
message("GeoIP.dat was found in src/geoip/.")
|
||||
RESOURCES += geoip.qrc
|
||||
} else {
|
||||
DEFINES -= WITH_GEOIP_EMBEDDED
|
||||
error("GeoIP.dat was not found in src/geoip/ folder, please follow instructions in src/geoip/README.")
|
||||
}
|
||||
} else {
|
||||
message("GeoIP database will not be embedded in qBittorrent executable.")
|
||||
}
|
||||
|
||||
# Translations
|
||||
TRANSLATIONS = $$LANG_PATH/qbittorrent_fr.ts \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue