Fix: SSDP Server spec adjust (#599)

* Fix: SSDP Server spec adjust
- Fix: Windows 7 network overview no longer removes the Hyperion entry
- Fix: The general section should be marked as global
This commit is contained in:
brindosch
2019-08-14 21:19:05 +02:00
committed by GitHub
parent d190e6f294
commit 9d84cdea0c
5 changed files with 49 additions and 24 deletions

View File

@@ -19,8 +19,21 @@ SSDPHandler::SSDPHandler(WebServer* webserver, const quint16& flatBufPort, QObje
setFlatBufPort(_flatbufPort);
}
SSDPHandler::~SSDPHandler()
{
sendAnnounceList(false);
}
void SSDPHandler::initServer()
{
_uuid = AuthManager::getInstance()->getID();
SSDPServer::setUuid(_uuid);
// announce targets
_deviceList.push_back("upnp:rootdevice");
_deviceList.push_back("uuid:"+_uuid);
_deviceList.push_back("urn:hyperion-project.org:device:basic:1");
// prep server
SSDPServer::initServer();
@@ -65,15 +78,12 @@ void SSDPHandler::handleWebServerStateChange(const bool newState)
_webserver->setSSDPDescription(buildDesc());
setDescriptionAddress(getDescAddress());
if(start())
{
sendAlive("upnp:rootdevice");
sendAlive("urn:schemas-upnp-org:device:basic:1");
sendAlive("urn:hyperion-project.org:device:basic:1");
}
sendAnnounceList(true);
}
else
{
_webserver->setSSDPDescription("");
sendAnnounceList(false);
stop();
}
}
@@ -87,17 +97,13 @@ void SSDPHandler::handleNetworkConfigurationChanged(const QNetworkConfiguration
if(_localAddress != localAddress)
{
// revoke old ip
sendByeBye("upnp:rootdevice");
sendByeBye("urn:schemas-upnp-org:device:basic:1");
sendByeBye("urn:hyperion-project.org:device:basic:1");
sendAnnounceList(false);
// update desc & notify new ip
_localAddress = localAddress;
_webserver->setSSDPDescription(buildDesc());
setDescriptionAddress(getDescAddress());
sendAlive("upnp:rootdevice");
sendAlive("urn:schemas-upnp-org:device:basic:1");
sendAlive("urn:hyperion-project.org:device:basic:1");
sendAnnounceList(true);
}
}
}
@@ -141,5 +147,11 @@ const QString SSDPHandler::buildDesc()
/// %2 friendly name Hyperion 2.0.0 (192.168.0.177)
/// %3 modelNumber 2.0.0
/// %4 serialNumber / UDN (H ID) Fjsa723dD0....
return SSDP_DESCRIPTION.arg(getBaseAddress(), QString("Hyperion (%2)").arg(_localAddress), QString(HYPERION_VERSION), AuthManager::getInstance()->getID());
return SSDP_DESCRIPTION.arg(getBaseAddress(), QString("Hyperion (%2)").arg(_localAddress), QString(HYPERION_VERSION), _uuid);
}
void SSDPHandler::sendAnnounceList(const bool alive){
for(const auto & entry : _deviceList){
alive ? SSDPServer::sendAlive(entry) : SSDPServer::sendByeBye(entry);
}
}

View File

@@ -6,9 +6,6 @@
// Hyperion
#include <HyperionConfig.h>
// auth manager
#include <hyperion/AuthManager.h>
#include <QUdpSocket>
#include <QDateTime>
@@ -99,9 +96,6 @@ void SSDPServer::initServer()
// create SERVER String
_serverHeader = data.prettyName+"/"+data.productVersion+" UPnP/1.0 Hyperion/"+QString(HYPERION_VERSION);
// usn uuid
_uuid = AuthManager::getInstance()->getID();
connect(_udpSocket, &QUdpSocket::readyRead, this, &SSDPServer::readPendingDatagrams);
}
@@ -120,10 +114,6 @@ void SSDPServer::stop()
{
if(_running)
{
// send BYEBYE Msg
sendByeBye("upnp:rootdevice");
sendByeBye("urn:schemas-upnp-org:device:basic:1");
sendByeBye("urn:hyperion-project.org:device:basic:1");
_udpSocket->close();
_running = false;
}
@@ -202,11 +192,13 @@ void SSDPServer::sendByeBye(const QString& st)
void SSDPServer::sendAlive(const QString& st)
{
const QString tempUSN = (st == "upnp:rootdevice ") ? _uuid+"::"+st : _uuid;
QString message = UPNP_ALIVE_MESSAGE.arg(SSDP_MAX_AGE
, _descAddress
, st
, _serverHeader
, _uuid+"::"+st
, tempUSN
, _fbsPort);
// we repeat 3 times