mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-22 04:24:23 +00:00
- FEATURE: Added support for PeerGuardian p2p filters
This commit is contained in:
parent
133007c451
commit
5c054223e8
@ -9,6 +9,7 @@
|
|||||||
- FEATURE: Display if UPnP/NAT-PMP was successful or not
|
- FEATURE: Display if UPnP/NAT-PMP was successful or not
|
||||||
- FEATURE: Threadified torrent creation
|
- FEATURE: Threadified torrent creation
|
||||||
- FEATURE: Improved eMule DAT ip filter parser
|
- FEATURE: Improved eMule DAT ip filter parser
|
||||||
|
- FEATURE: Added support for PeerGuardian p2p filters
|
||||||
- BUGFIX: Do not display seeds number in seeding list (always 0)
|
- BUGFIX: Do not display seeds number in seeding list (always 0)
|
||||||
- COSMETIC: Do not display progress bar in seeding list (always 100%)
|
- COSMETIC: Do not display progress bar in seeding list (always 100%)
|
||||||
- COSMETIC: Added a progress bar for torrent creation
|
- COSMETIC: Added a progress bar for torrent creation
|
||||||
|
@ -1083,6 +1083,10 @@ void options_imp::parseDATFilterFile(QString filePath) {
|
|||||||
if(firstPart.contains('-')) {
|
if(firstPart.contains('-')) {
|
||||||
// Range is splitted by a dash
|
// Range is splitted by a dash
|
||||||
QList<QByteArray> IPs = firstPart.split('-');
|
QList<QByteArray> IPs = firstPart.split('-');
|
||||||
|
if(IPs.size() != 2) {
|
||||||
|
qDebug("Ipfilter.dat: line %d is malformed.", nbLine);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
strStartIP = IPs.at(0).trimmed();
|
strStartIP = IPs.at(0).trimmed();
|
||||||
strEndIP = IPs.at(1).trimmed();
|
strEndIP = IPs.at(1).trimmed();
|
||||||
// Check if IPs are correct
|
// Check if IPs are correct
|
||||||
@ -1165,7 +1169,8 @@ void options_imp::parseDATFilterFile(QString filePath) {
|
|||||||
|
|
||||||
// Parser for PeerGuardian ip filter in p2p format
|
// Parser for PeerGuardian ip filter in p2p format
|
||||||
void options_imp::parseP2PFilterFile(QString filePath) {
|
void options_imp::parseP2PFilterFile(QString filePath) {
|
||||||
/* QFile file(filePath);
|
const QRegExp is_ipv4(QString::fromUtf8("^(([0-1]?[0-9]?[0-9])|(2[0-4][0-9])|(25[0-5]))(\\.(([0-1]?[0-9]?[0-9])|(2[0-4][0-9])|(25[0-5]))){3}$"), Qt::CaseInsensitive, QRegExp::RegExp);
|
||||||
|
QFile file(filePath);
|
||||||
QStringList IP;
|
QStringList IP;
|
||||||
if (file.exists()){
|
if (file.exists()){
|
||||||
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){
|
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){
|
||||||
@ -1182,55 +1187,35 @@ void options_imp::parseP2PFilterFile(QString filePath) {
|
|||||||
// Ignoring commented lines
|
// Ignoring commented lines
|
||||||
if(line.startsWith('#') || line.startsWith("//")) continue;
|
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();
|
if(partsList.size() < 2){
|
||||||
if(nbElem < 2){
|
qDebug("p2p file: line %d is malformed.", nbLine);
|
||||||
qDebug("Ipfilter.dat: line %d is malformed.", nbLine);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
bool ok;
|
// Get IP range
|
||||||
int nbAccess = partsList.at(1).trimmed().toInt(&ok);
|
QList<QByteArray> IPs = partsList.at(2).split('-');
|
||||||
if(!ok){
|
if(IPs.size() != 2) {
|
||||||
qDebug("Ipfilter.dat: line %d is malformed.", nbLine);
|
qDebug("p2p file: line %d is malformed.", nbLine);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(nbAccess <= 127){
|
QString strStartIP = IPs.at(0).trimmed();
|
||||||
QString strComment;
|
QString strEndIP = IPs.at(1).trimmed();
|
||||||
QString strStartIP = partsList.at(0).split('-').at(0).trimmed();
|
// Check IPs format (IPv4 only)
|
||||||
QString strEndIP = partsList.at(0).split('-').at(1).trimmed();
|
if(strStartIP.contains(is_ipv4) && strEndIP.contains(is_ipv4)) {
|
||||||
if(nbElem > 2){
|
// IPv4
|
||||||
strComment = partsList.at(2).trimmed();
|
IP = strStartIP.split('.');
|
||||||
}else{
|
address_v4 start((IP.at(0).toInt() << 24) + (IP.at(1).toInt() << 16) + (IP.at(2).toInt() << 8) + IP.at(3).toInt());
|
||||||
strComment = QString();
|
IP = strEndIP.split('.');
|
||||||
}
|
address_v4 last((IP.at(0).toInt() << 24) + (IP.at(1).toInt() << 16) + (IP.at(2).toInt() << 8) + IP.at(3).toInt());
|
||||||
// Split IP
|
// Apply to bittorrent session
|
||||||
QRegExp is_ipv6(QString::fromUtf8("^[0-9a-f]{4}(:[0-9a-f]{4}){7}$"), Qt::CaseInsensitive, QRegExp::RegExp);
|
filter.add_rule(start, last, ip_filter::blocked);
|
||||||
QRegExp is_ipv4(QString::fromUtf8("^(([0-1]?[0-9]?[0-9])|(2[0-4][0-9])|(25[0-5]))(\\.(([0-1]?[0-9]?[0-9])|(2[0-4][0-9])|(25[0-5]))){3}$"), Qt::CaseInsensitive, QRegExp::RegExp);
|
} else {
|
||||||
|
qDebug("p2p file: line %d is malformed.", nbLine);
|
||||||
if(strStartIP.contains(is_ipv4) && strEndIP.contains(is_ipv4)) {
|
continue;
|
||||||
// IPv4
|
|
||||||
IP = strStartIP.split('.');
|
|
||||||
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('.');
|
|
||||||
address_v4 last((IP.at(0).toInt() << 24) + (IP.at(1).toInt() << 16) + (IP.at(2).toInt() << 8) + IP.at(3).toInt());
|
|
||||||
// Apply to bittorrent session
|
|
||||||
filter.add_rule(start, last, ip_filter::blocked);
|
|
||||||
} else if(strStartIP.contains(is_ipv6) && strEndIP.contains(is_ipv6)) {
|
|
||||||
// IPv6, ex : 1fff:0000:0a88:85a3:0000:0000:ac1f:8001
|
|
||||||
IP = strStartIP.split(':');
|
|
||||||
address_v6 start = address_v6::from_string(strStartIP.remove(':', 0).toUtf8().data());
|
|
||||||
IP = strEndIP.split(':');
|
|
||||||
address_v6 last = address_v6::from_string(strEndIP.remove(':', 0).toUtf8().data());
|
|
||||||
// Apply to bittorrent session
|
|
||||||
filter.add_rule(start, last, ip_filter::blocked);
|
|
||||||
} else {
|
|
||||||
qDebug("Ipfilter.dat: line %d is malformed.", nbLine);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file.close();
|
file.close();
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process ip filter file
|
// Process ip filter file
|
||||||
|
Loading…
x
Reference in New Issue
Block a user