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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 49 additions and 24 deletions

View File

@ -114,7 +114,7 @@ public:
// capture
<< "framegrabber" << "grabberV4L2"
// other
<< "logger";
<< "logger" << "general";
return list.contains(type);
}

View File

@ -20,6 +20,7 @@ class SSDPHandler : public SSDPServer{
Q_OBJECT
public:
SSDPHandler(WebServer* webserver, const quint16& flatBufPort, QObject * parent = nullptr);
~SSDPHandler();
public slots:
///
@ -29,6 +30,7 @@ public slots:
///
/// @brief get state changes from webserver
/// @param newState true for started and false for stopped
///
void handleWebServerStateChange(const bool newState);
@ -61,6 +63,12 @@ private:
///
const QString getLocalAddress();
///
/// @brief Send alive/byebye message based on _deviceList
/// @param alive When true send alive, else byebye
///
void sendAnnounceList(const bool alive);
private slots:
///
/// @brief Handle the mSeach request from SSDPServer
@ -71,6 +79,10 @@ private slots:
///
void handleMSearchRequest(const QString& target, const QString& mx, const QString address, const quint16 & port);
///
/// @brief Handle changes in the network configuration
/// @param conig New config
///
void handleNetworkConfigurationChanged(const QNetworkConfiguration &config);
private:
@ -78,4 +90,7 @@ private:
QString _localAddress;
QNetworkConfigurationManager* _NCA;
quint16 _flatbufPort;
QString _uuid;
/// Targets for announcement
std::vector<QString> _deviceList;
};

View File

@ -67,6 +67,12 @@ public:
///
void setDescriptionAddress(const QString& addr) { _descAddress = addr; };
///
/// @brief Set uuid
/// @param uuid The uuid
///
void setUuid(const QString& uuid) { _uuid = uuid; };
///
/// @brief set new flatbuffer server port
///

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