From 317c5e7ea75e16e4be951f0d01ae981759b7cde7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Sun, 21 Feb 2016 11:22:17 +0100 Subject: [PATCH] improove UPnP --- libguh/network/upnpdiscovery/upnpdiscovery.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/libguh/network/upnpdiscovery/upnpdiscovery.cpp b/libguh/network/upnpdiscovery/upnpdiscovery.cpp index c39d1fd1..3f80e09d 100644 --- a/libguh/network/upnpdiscovery/upnpdiscovery.cpp +++ b/libguh/network/upnpdiscovery/upnpdiscovery.cpp @@ -46,7 +46,6 @@ \sa DevicePlugin::upnpNotifyReceived() */ - #include "upnpdiscovery.h" #include "loggingcategories.h" #include "guhsettings.h" @@ -113,6 +112,8 @@ bool UpnpDiscovery::discoverDevices(const QString &searchTarget, const QString & return false; } + qCDebug(dcHardware) << "UPnP: discover" << searchTarget << userAgent; + // create a new request UpnpDiscoveryRequest *request = new UpnpDiscoveryRequest(this, pluginId, searchTarget, userAgent); connect(request, &UpnpDiscoveryRequest::discoveryTimeout, this, &UpnpDiscovery::discoverTimeout); @@ -204,14 +205,12 @@ void UpnpDiscovery::readData() readDatagram(data.data(), data.size(), &hostAddress, &port); } - if (data.contains("M-SEARCH")) { - //qCDebug(dcHardware) << "--------------------------------------"; - //qCDebug(dcHardware) << QString("UPnP data: %1:%2 \n").arg(hostAddress.toString()).arg(QString::number(port)) << data; + if (data.contains("M-SEARCH") && !QNetworkInterface::allAddresses().contains(hostAddress)) { respondToSearchRequest(hostAddress, port); return; } - if (data.contains("NOTIFY")) { + if (data.contains("NOTIFY") && !QNetworkInterface::allAddresses().contains(hostAddress)) { emit upnpNotify(data); return; } @@ -225,7 +224,7 @@ void UpnpDiscovery::readData() QString value = line.mid(separatorIndex+1).trimmed(); // get location - if (key.contains("LOCATION")) { + if (key.contains("LOCATION") || key.contains("location") || key.contains("Location")) { location = QUrl(value); } }