mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-22 06:13:36 -07:00
- Made ipfilter.dat parser less sensitive to errors
This commit is contained in:
parent
22eead5f9a
commit
82d9e19e96
2 changed files with 46 additions and 41 deletions
|
@ -26,6 +26,7 @@
|
||||||
- BUGFIX: Create Options object only when necessary (to save memory)
|
- BUGFIX: Create Options object only when necessary (to save memory)
|
||||||
- BUGFIX: Let libtorrent store the torrent handles (save memory)
|
- BUGFIX: Let libtorrent store the torrent handles (save memory)
|
||||||
- BUGFIX: Set DHT Port only when DHT is enabled
|
- BUGFIX: Set DHT Port only when DHT is enabled
|
||||||
|
- BUGFIX: Made ipfilter.dat parser less sensitive to errors
|
||||||
- I18N: Added Danish translation
|
- I18N: Added Danish translation
|
||||||
- I18N: Better internationalization thanks to dynamic text support
|
- I18N: Better internationalization thanks to dynamic text support
|
||||||
- COSMETIC: Replaced OSD messages by Qt4.2 systray messages
|
- COSMETIC: Replaced OSD messages by Qt4.2 systray messages
|
||||||
|
|
|
@ -790,15 +790,20 @@ void options_imp::processFilterFile(const QString& filePath){
|
||||||
while (!file.atEnd()) {
|
while (!file.atEnd()) {
|
||||||
++nbLine;
|
++nbLine;
|
||||||
QByteArray line = file.readLine();
|
QByteArray line = file.readLine();
|
||||||
if(!line.startsWith('#') && !line.startsWith("//")){
|
if(line.startsWith('#') || line.startsWith("//")) continue;
|
||||||
// Line is not commented
|
// Line is not commented
|
||||||
QList<QByteArray> partsList = line.split(',');
|
QList<QByteArray> partsList = line.split(',');
|
||||||
unsigned int nbElem = partsList.size();
|
unsigned int nbElem = partsList.size();
|
||||||
if(nbElem < 2){
|
if(nbElem < 2){
|
||||||
std::cerr << "Ipfilter.dat: line " << nbLine << " is malformed.\n";
|
qDebug("Ipfilter.dat: line %d is malformed.", nbLine);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
bool ok;
|
||||||
|
int nbAccess = partsList.at(1).trimmed().toInt(&ok);
|
||||||
|
if(!ok){
|
||||||
|
qDebug("Ipfilter.dat: line %d is malformed.", nbLine);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int nbAccess = partsList.at(1).trimmed().toInt();
|
|
||||||
if(nbAccess <= 127){
|
if(nbAccess <= 127){
|
||||||
QString strComment;
|
QString strComment;
|
||||||
QString strStartIP = partsList.at(0).split('-').at(0).trimmed();
|
QString strStartIP = partsList.at(0).split('-').at(0).trimmed();
|
||||||
|
@ -811,13 +816,13 @@ void options_imp::processFilterFile(const QString& filePath){
|
||||||
// Split IP
|
// Split IP
|
||||||
IP = strStartIP.split('.');
|
IP = strStartIP.split('.');
|
||||||
if(IP.size() != 4){
|
if(IP.size() != 4){
|
||||||
std::cerr << "Ipfilter.dat: line " << nbLine << ", first IP is malformed.\n";
|
qDebug("Ipfilter.dat: line %d is malformed.", nbLine);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
address_v4 start((IP.at(0).toInt() << 24) + (IP.at(1).toInt() << 16) + (IP.at(2).toInt() << 8) + IP.at(3).toInt());
|
address_v4 start((IP.at(0).toInt() << 24) + (IP.at(1).toInt() << 16) + (IP.at(2).toInt() << 8) + IP.at(3).toInt());
|
||||||
IP = strEndIP.split('.');
|
IP = strEndIP.split('.');
|
||||||
if(IP.size() != 4){
|
if(IP.size() != 4){
|
||||||
std::cerr << "Ipfilter.dat: line " << nbLine << ", second IP is malformed.\n";
|
qDebug("Ipfilter.dat: line %d is malformed.", nbLine);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
address_v4 last((IP.at(0).toInt() << 24) + (IP.at(1).toInt() << 16) + (IP.at(2).toInt() << 8) + IP.at(3).toInt());
|
address_v4 last((IP.at(0).toInt() << 24) + (IP.at(1).toInt() << 16) + (IP.at(2).toInt() << 8) + IP.at(3).toInt());
|
||||||
|
@ -835,7 +840,6 @@ void options_imp::processFilterFile(const QString& filePath){
|
||||||
filter.add_rule(start, last, ip_filter::blocked);
|
filter.add_rule(start, last, ip_filter::blocked);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue