BUGFIX: Make listening on a particular interface more reliable

This commit is contained in:
Christophe Dumez
2010-10-30 21:51:06 +00:00
parent e302042520
commit 764e8a365b
2 changed files with 18 additions and 5 deletions

View File

@@ -6,6 +6,7 @@
- BUGFIX: Correctly display the hash of torrents with no metadata
- BUGFIX: Elide status bar text if it is too wide
- BUGFIX: Make sure the splash screen is displayed for 3 seconds
- BUGFIX: Make listening on a particular interface more reliable
* Sun Oct 24 2010 - Christophe Dumez <chris@qbittorrent.org> - v2.4.8
- BUGFIX: Fix possible crash on manual peer ban

View File

@@ -1824,15 +1824,27 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
}
QNetworkInterface network_iface = QNetworkInterface::interfaceFromName(iface_name);
if(!network_iface.isValid()) {
qDebug("Invalid network interface: %s", qPrintable(iface_name));
addConsoleMessage(tr("The network interface defined is invalid: %1").arg(iface_name), "red");
addConsoleMessage(tr("Trying any other network interface available instead."));
s->listen_on(ports);
return;
}
QString ip = "127.0.0.1";
if(!network_iface.addressEntries().isEmpty()) {
ip = network_iface.addressEntries().first().ip().toString();
QString ip;
qDebug("This network interface has %d IP addresses", network_iface.addressEntries().size());
foreach(const QNetworkAddressEntry &entry, network_iface.addressEntries()) {
qDebug("Trying to listen on IP %s (%s)", qPrintable(entry.ip().toString()), qPrintable(iface_name));
if(s->listen_on(ports, qPrintable(entry.ip().toString()))) {
ip = entry.ip().toString();
break;
}
}
if(s->is_listening()) {
addConsoleMessage(tr("Listening on IP address %1 on network interface %2...").arg(ip).arg(iface_name));
} else {
qDebug("Failed to listen on any of the IP addresses");
addConsoleMessage(tr("Failed to listen on network interface %1").arg(iface_name), "red");
}
qDebug("Listening on interface %s with ip %s", qPrintable(iface_name), qPrintable(ip));
s->listen_on(ports, ip.toLocal8Bit().constData());
}
// Set download rate limit