#include <geoipmanager.h>
|
QString | lookup (const QHostAddress &hostAddr) const |
|
Definition at line 43 of file geoipmanager.h.
◆ GeoIPManager()
GeoIPManager::GeoIPManager |
( |
| ) |
|
|
private |
◆ ~GeoIPManager()
GeoIPManager::~GeoIPManager |
( |
| ) |
|
|
overrideprivate |
◆ configure
void GeoIPManager::configure |
( |
| ) |
|
|
privateslot |
◆ CountryName()
QString GeoIPManager::CountryName |
( |
const QString & |
countryISOCode | ) |
|
|
static |
Definition at line 141 of file geoipmanager.cpp.
143 static const QHash<QString, QString> countries =
149 {
"AD", tr(
"Andorra")},
150 {
"AE", tr(
"United Arab Emirates")},
151 {
"AF", tr(
"Afghanistan")},
152 {
"AG", tr(
"Antigua and Barbuda")},
153 {
"AI", tr(
"Anguilla")},
154 {
"AL", tr(
"Albania")},
155 {
"AM", tr(
"Armenia")},
156 {
"AO", tr(
"Angola")},
157 {
"AQ", tr(
"Antarctica")},
158 {
"AR", tr(
"Argentina")},
159 {
"AS", tr(
"American Samoa")},
160 {
"AT", tr(
"Austria")},
161 {
"AU", tr(
"Australia")},
163 {
"AX", tr(
"Aland Islands")},
164 {
"AZ", tr(
"Azerbaijan")},
165 {
"BA", tr(
"Bosnia and Herzegovina")},
166 {
"BB", tr(
"Barbados")},
167 {
"BD", tr(
"Bangladesh")},
168 {
"BE", tr(
"Belgium")},
169 {
"BF", tr(
"Burkina Faso")},
170 {
"BG", tr(
"Bulgaria")},
171 {
"BH", tr(
"Bahrain")},
172 {
"BI", tr(
"Burundi")},
174 {
"BL", tr(
"Saint Barthelemy")},
175 {
"BM", tr(
"Bermuda")},
176 {
"BN", tr(
"Brunei Darussalam")},
177 {
"BO", tr(
"Bolivia, Plurinational State of")},
178 {
"BQ", tr(
"Bonaire, Sint Eustatius and Saba")},
179 {
"BR", tr(
"Brazil")},
180 {
"BS", tr(
"Bahamas")},
181 {
"BT", tr(
"Bhutan")},
182 {
"BV", tr(
"Bouvet Island")},
183 {
"BW", tr(
"Botswana")},
184 {
"BY", tr(
"Belarus")},
185 {
"BZ", tr(
"Belize")},
186 {
"CA", tr(
"Canada")},
187 {
"CC", tr(
"Cocos (Keeling) Islands")},
188 {
"CD", tr(
"Congo, The Democratic Republic of the")},
189 {
"CF", tr(
"Central African Republic")},
191 {
"CH", tr(
"Switzerland")},
192 {
"CI", tr(
"Cote d'Ivoire")},
193 {
"CK", tr(
"Cook Islands")},
195 {
"CM", tr(
"Cameroon")},
197 {
"CO", tr(
"Colombia")},
198 {
"CR", tr(
"Costa Rica")},
200 {
"CV", tr(
"Cape Verde")},
201 {
"CW", tr(
"Curacao")},
202 {
"CX", tr(
"Christmas Island")},
203 {
"CY", tr(
"Cyprus")},
204 {
"CZ", tr(
"Czech Republic")},
205 {
"DE", tr(
"Germany")},
206 {
"DJ", tr(
"Djibouti")},
207 {
"DK", tr(
"Denmark")},
208 {
"DM", tr(
"Dominica")},
209 {
"DO", tr(
"Dominican Republic")},
210 {
"DZ", tr(
"Algeria")},
211 {
"EC", tr(
"Ecuador")},
212 {
"EE", tr(
"Estonia")},
214 {
"EH", tr(
"Western Sahara")},
215 {
"ER", tr(
"Eritrea")},
217 {
"ET", tr(
"Ethiopia")},
218 {
"FI", tr(
"Finland")},
220 {
"FK", tr(
"Falkland Islands (Malvinas)")},
221 {
"FM", tr(
"Micronesia, Federated States of")},
222 {
"FO", tr(
"Faroe Islands")},
223 {
"FR", tr(
"France")},
225 {
"GB", tr(
"United Kingdom")},
226 {
"GD", tr(
"Grenada")},
227 {
"GE", tr(
"Georgia")},
228 {
"GF", tr(
"French Guiana")},
229 {
"GG", tr(
"Guernsey")},
231 {
"GI", tr(
"Gibraltar")},
232 {
"GL", tr(
"Greenland")},
233 {
"GM", tr(
"Gambia")},
234 {
"GN", tr(
"Guinea")},
235 {
"GP", tr(
"Guadeloupe")},
236 {
"GQ", tr(
"Equatorial Guinea")},
237 {
"GR", tr(
"Greece")},
238 {
"GS", tr(
"South Georgia and the South Sandwich Islands")},
239 {
"GT", tr(
"Guatemala")},
241 {
"GW", tr(
"Guinea-Bissau")},
242 {
"GY", tr(
"Guyana")},
243 {
"HK", tr(
"Hong Kong")},
244 {
"HM", tr(
"Heard Island and McDonald Islands")},
245 {
"HN", tr(
"Honduras")},
246 {
"HR", tr(
"Croatia")},
248 {
"HU", tr(
"Hungary")},
249 {
"ID", tr(
"Indonesia")},
250 {
"IE", tr(
"Ireland")},
251 {
"IL", tr(
"Israel")},
252 {
"IM", tr(
"Isle of Man")},
254 {
"IO", tr(
"British Indian Ocean Territory")},
256 {
"IR", tr(
"Iran, Islamic Republic of")},
257 {
"IS", tr(
"Iceland")},
259 {
"JE", tr(
"Jersey")},
260 {
"JM", tr(
"Jamaica")},
261 {
"JO", tr(
"Jordan")},
264 {
"KG", tr(
"Kyrgyzstan")},
265 {
"KH", tr(
"Cambodia")},
266 {
"KI", tr(
"Kiribati")},
267 {
"KM", tr(
"Comoros")},
268 {
"KN", tr(
"Saint Kitts and Nevis")},
269 {
"KP", tr(
"Korea, Democratic People's Republic of")},
270 {
"KR", tr(
"Korea, Republic of")},
271 {
"KW", tr(
"Kuwait")},
272 {
"KY", tr(
"Cayman Islands")},
273 {
"KZ", tr(
"Kazakhstan")},
274 {
"LA", tr(
"Lao People's Democratic Republic")},
275 {
"LB", tr(
"Lebanon")},
276 {
"LC", tr(
"Saint Lucia")},
277 {
"LI", tr(
"Liechtenstein")},
278 {
"LK", tr(
"Sri Lanka")},
279 {
"LR", tr(
"Liberia")},
280 {
"LS", tr(
"Lesotho")},
281 {
"LT", tr(
"Lithuania")},
282 {
"LU", tr(
"Luxembourg")},
283 {
"LV", tr(
"Latvia")},
285 {
"MA", tr(
"Morocco")},
286 {
"MC", tr(
"Monaco")},
287 {
"MD", tr(
"Moldova, Republic of")},
288 {
"ME", tr(
"Montenegro")},
289 {
"MF", tr(
"Saint Martin (French part)")},
290 {
"MG", tr(
"Madagascar")},
291 {
"MH", tr(
"Marshall Islands")},
292 {
"MK", tr(
"Macedonia, The Former Yugoslav Republic of")},
294 {
"MM", tr(
"Myanmar")},
295 {
"MN", tr(
"Mongolia")},
297 {
"MP", tr(
"Northern Mariana Islands")},
298 {
"MQ", tr(
"Martinique")},
299 {
"MR", tr(
"Mauritania")},
300 {
"MS", tr(
"Montserrat")},
302 {
"MU", tr(
"Mauritius")},
303 {
"MV", tr(
"Maldives")},
304 {
"MW", tr(
"Malawi")},
305 {
"MX", tr(
"Mexico")},
306 {
"MY", tr(
"Malaysia")},
307 {
"MZ", tr(
"Mozambique")},
308 {
"NA", tr(
"Namibia")},
309 {
"NC", tr(
"New Caledonia")},
311 {
"NF", tr(
"Norfolk Island")},
312 {
"NG", tr(
"Nigeria")},
313 {
"NI", tr(
"Nicaragua")},
314 {
"NL", tr(
"Netherlands")},
315 {
"NO", tr(
"Norway")},
319 {
"NZ", tr(
"New Zealand")},
321 {
"PA", tr(
"Panama")},
323 {
"PF", tr(
"French Polynesia")},
324 {
"PG", tr(
"Papua New Guinea")},
325 {
"PH", tr(
"Philippines")},
326 {
"PK", tr(
"Pakistan")},
327 {
"PL", tr(
"Poland")},
328 {
"PM", tr(
"Saint Pierre and Miquelon")},
329 {
"PN", tr(
"Pitcairn")},
330 {
"PR", tr(
"Puerto Rico")},
331 {
"PS", tr(
"Palestine, State of")},
332 {
"PT", tr(
"Portugal")},
334 {
"PY", tr(
"Paraguay")},
336 {
"RE", tr(
"Reunion")},
337 {
"RO", tr(
"Romania")},
338 {
"RS", tr(
"Serbia")},
339 {
"RU", tr(
"Russian Federation")},
340 {
"RW", tr(
"Rwanda")},
341 {
"SA", tr(
"Saudi Arabia")},
342 {
"SB", tr(
"Solomon Islands")},
343 {
"SC", tr(
"Seychelles")},
345 {
"SE", tr(
"Sweden")},
346 {
"SG", tr(
"Singapore")},
347 {
"SH", tr(
"Saint Helena, Ascension and Tristan da Cunha")},
348 {
"SI", tr(
"Slovenia")},
349 {
"SJ", tr(
"Svalbard and Jan Mayen")},
350 {
"SK", tr(
"Slovakia")},
351 {
"SL", tr(
"Sierra Leone")},
352 {
"SM", tr(
"San Marino")},
353 {
"SN", tr(
"Senegal")},
354 {
"SO", tr(
"Somalia")},
355 {
"SR", tr(
"Suriname")},
356 {
"SS", tr(
"South Sudan")},
357 {
"ST", tr(
"Sao Tome and Principe")},
358 {
"SV", tr(
"El Salvador")},
359 {
"SX", tr(
"Sint Maarten (Dutch part)")},
360 {
"SY", tr(
"Syrian Arab Republic")},
361 {
"SZ", tr(
"Swaziland")},
362 {
"TC", tr(
"Turks and Caicos Islands")},
364 {
"TF", tr(
"French Southern Territories")},
366 {
"TH", tr(
"Thailand")},
367 {
"TJ", tr(
"Tajikistan")},
368 {
"TK", tr(
"Tokelau")},
369 {
"TL", tr(
"Timor-Leste")},
370 {
"TM", tr(
"Turkmenistan")},
371 {
"TN", tr(
"Tunisia")},
373 {
"TR", tr(
"Turkey")},
374 {
"TT", tr(
"Trinidad and Tobago")},
375 {
"TV", tr(
"Tuvalu")},
376 {
"TW", tr(
"Taiwan")},
377 {
"TZ", tr(
"Tanzania, United Republic of")},
378 {
"UA", tr(
"Ukraine")},
379 {
"UG", tr(
"Uganda")},
380 {
"UM", tr(
"United States Minor Outlying Islands")},
381 {
"US", tr(
"United States")},
382 {
"UY", tr(
"Uruguay")},
383 {
"UZ", tr(
"Uzbekistan")},
384 {
"VA", tr(
"Holy See (Vatican City State)")},
385 {
"VC", tr(
"Saint Vincent and the Grenadines")},
386 {
"VE", tr(
"Venezuela, Bolivarian Republic of")},
387 {
"VG", tr(
"Virgin Islands, British")},
388 {
"VI", tr(
"Virgin Islands, U.S.")},
389 {
"VN", tr(
"Vietnam")},
390 {
"VU", tr(
"Vanuatu")},
391 {
"WF", tr(
"Wallis and Futuna")},
394 {
"YT", tr(
"Mayotte")},
395 {
"ZA", tr(
"South Africa")},
396 {
"ZM", tr(
"Zambia")},
397 {
"ZW", tr(
"Zimbabwe")},
402 return countries.value(countryISOCode, tr(
"N/A"));
Referenced by SyncController::torrentPeersAction(), and PeerListWidget::updatePeer().
◆ downloadDatabaseFile()
void GeoIPManager::downloadDatabaseFile |
( |
| ) |
|
|
private |
◆ downloadFinished
Definition at line 423 of file geoipmanager.cpp.
447 LogMsg(tr(
"IP geolocation database loaded. Type: %1. Build time: %2.")
452 if (!QDir(targetPath).exists())
453 QDir().mkpath(targetPath);
455 const auto path = QString::fromLatin1(
"%1/%2").arg(targetPath,
GEODB_FILENAME);
459 LogMsg(tr(
"Successfully updated IP geolocation database."),
Log::INFO);
463 LogMsg(tr(
"Couldn't save downloaded IP geolocation database file. Reason: %1")
469 delete geoIPDatabase;
474 LogMsg(tr(
"Couldn't load IP geolocation database. Reason: %1").arg(error),
Log::WARNING);
QDateTime buildEpoch() const
static GeoIPDatabase * load(const QString &filename, QString &error)
static const char GEODB_FOLDER[]
static const char GEODB_FILENAME[]
void LogMsg(const QString &message, const Log::MsgType &type)
QString expandPathAbs(const QString &path)
QByteArray decompress(const QByteArray &data, bool *ok=nullptr)
nonstd::expected< void, QString > saveToFile(const QString &path, const QByteArray &data)
QString specialFolderLocation(const SpecialFolder folder)
References GeoIPDatabase::buildEpoch(), Net::DownloadResult::data, Data, Utils::Gzip::decompress(), Net::DownloadResult::errorString, Utils::Fs::expandPathAbs(), GEODB_FILENAME, GEODB_FOLDER, Log::INFO, GeoIPDatabase::load(), LogMsg(), m_geoIPDatabase, Utils::IO::saveToFile(), specialFolderLocation(), Net::DownloadResult::status, Net::Success, GeoIPDatabase::type(), and Log::WARNING.
Referenced by downloadDatabaseFile().
◆ freeInstance()
void GeoIPManager::freeInstance |
( |
| ) |
|
|
static |
◆ initInstance()
void GeoIPManager::initInstance |
( |
| ) |
|
|
static |
◆ instance()
◆ loadDatabase()
void GeoIPManager::loadDatabase |
( |
| ) |
|
|
private |
Definition at line 86 of file geoipmanager.cpp.
void addMessage(const QString &message, const Log::MsgType &type=Log::NORMAL)
static Logger * instance()
void manageDatabaseUpdate()
References Logger::addMessage(), GeoIPDatabase::buildEpoch(), Data, Utils::Fs::expandPathAbs(), GEODB_FILENAME, GEODB_FOLDER, Log::INFO, Logger::instance(), GeoIPDatabase::load(), m_geoIPDatabase, manageDatabaseUpdate(), specialFolderLocation(), GeoIPDatabase::type(), and Log::WARNING.
Referenced by configure().
◆ lookup()
QString GeoIPManager::lookup |
( |
const QHostAddress & |
hostAddr | ) |
const |
◆ manageDatabaseUpdate()
void GeoIPManager::manageDatabaseUpdate |
( |
| ) |
|
|
private |
Definition at line 106 of file geoipmanager.cpp.
108 const auto expired = [](
const QDateTime &testDateTime)
110 const QDate testDate = testDateTime.date();
111 const QDate curDate = QDateTime::currentDateTimeUtc().date();
113 if ((testDate.year() < curDate.year()) && (curDate.day() > 1))
116 if ((testDate.month() < curDate.month()) && (curDate.day() > 1))
void downloadDatabaseFile()
References GeoIPDatabase::buildEpoch(), downloadDatabaseFile(), and m_geoIPDatabase.
Referenced by loadDatabase().
◆ m_enabled
bool Net::GeoIPManager::m_enabled |
|
private |
◆ m_geoIPDatabase
◆ m_instance
The documentation for this class was generated from the following files: