mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
parent
c0336b640f
commit
e98122c9cb
@ -43,7 +43,7 @@ public:
|
|||||||
BonjourServiceRegister(QObject *parent = 0);
|
BonjourServiceRegister(QObject *parent = 0);
|
||||||
~BonjourServiceRegister();
|
~BonjourServiceRegister();
|
||||||
|
|
||||||
void registerService(const BonjourRecord &record, quint16 servicePort);
|
void registerService(const BonjourRecord &record, quint16 servicePort, std::vector<std::pair<std::string, std::string>> txt);
|
||||||
inline BonjourRecord registeredRecord() const {return finalRecord; }
|
inline BonjourRecord registeredRecord() const {return finalRecord; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
@ -48,7 +48,7 @@ BonjourServiceRegister::~BonjourServiceRegister()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BonjourServiceRegister::registerService(const BonjourRecord &record, quint16 servicePort)
|
void BonjourServiceRegister::registerService(const BonjourRecord &record, quint16 servicePort, std::vector<std::pair<std::string, std::string>> txt)
|
||||||
{
|
{
|
||||||
if (dnssref)
|
if (dnssref)
|
||||||
{
|
{
|
||||||
@ -62,10 +62,25 @@ void BonjourServiceRegister::registerService(const BonjourRecord &record, quint1
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// create txt record
|
||||||
|
TXTRecordRef txtRec;
|
||||||
|
TXTRecordCreate(&txtRec,0,NULL);
|
||||||
|
|
||||||
|
// add txt records
|
||||||
|
if(!txt.empty())
|
||||||
|
{
|
||||||
|
for(std::vector<std::pair<std::string, std::string> >::const_iterator it = txt.begin(); it != txt.end(); ++it)
|
||||||
|
{
|
||||||
|
//Debug(Logger::getInstance("BonJour"), "TXTRecord: key:%s, value:%s",it->first.c_str(),it->second.c_str());
|
||||||
|
uint8_t txtLen = (uint8_t)strlen(it->second.c_str());
|
||||||
|
TXTRecordSetValue(&txtRec, it->first.c_str(), txtLen, it->second.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DNSServiceErrorType err = DNSServiceRegister(&dnssref, 0, 0, record.serviceName.toUtf8().constData(),
|
DNSServiceErrorType err = DNSServiceRegister(&dnssref, 0, 0, record.serviceName.toUtf8().constData(),
|
||||||
record.registeredType.toUtf8().constData(),
|
record.registeredType.toUtf8().constData(),
|
||||||
(record.replyDomain.isEmpty() ? 0 : record.replyDomain.toUtf8().constData()),
|
(record.replyDomain.isEmpty() ? 0 : record.replyDomain.toUtf8().constData()),
|
||||||
0, bigEndianPort, 0, 0, bonjourRegisterService, this);
|
0, bigEndianPort, TXTRecordGetLength(&txtRec), TXTRecordGetBytesPtr(&txtRec), bonjourRegisterService, this);
|
||||||
if (err != kDNSServiceErr_NoError)
|
if (err != kDNSServiceErr_NoError)
|
||||||
{
|
{
|
||||||
emit error(err);
|
emit error(err);
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include <QHostInfo>
|
#include <QHostInfo>
|
||||||
#include <bonjour/bonjourserviceregister.h>
|
#include <bonjour/bonjourserviceregister.h>
|
||||||
#include <bonjour/bonjourrecord.h>
|
#include <bonjour/bonjourrecord.h>
|
||||||
|
#include <HyperionConfig.h>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
|
|
||||||
StaticFileServing::StaticFileServing (Hyperion *hyperion, QString baseUrl, quint16 port, QObject * parent)
|
StaticFileServing::StaticFileServing (Hyperion *hyperion, QString baseUrl, quint16 port, QObject * parent)
|
||||||
@ -47,10 +48,16 @@ void StaticFileServing::onServerStarted (quint16 port)
|
|||||||
const QJsonObject & generalConfig = _hyperion->getQJsonConfig()["general"].toObject();
|
const QJsonObject & generalConfig = _hyperion->getQJsonConfig()["general"].toObject();
|
||||||
const QString mDNSDescr = generalConfig["name"].toString("") + "@" + QHostInfo::localHostName() + ":" + QString::number(port);
|
const QString mDNSDescr = generalConfig["name"].toString("") + "@" + QHostInfo::localHostName() + ":" + QString::number(port);
|
||||||
|
|
||||||
|
// txt record for zeroconf
|
||||||
|
QString id = _hyperion->id;
|
||||||
|
std::string version = HYPERION_VERSION;
|
||||||
|
std::vector<std::pair<std::string, std::string> > txtRecord = {{"id",id.toStdString()},{"version",version}};
|
||||||
|
|
||||||
BonjourServiceRegister *bonjourRegister_http = new BonjourServiceRegister();
|
BonjourServiceRegister *bonjourRegister_http = new BonjourServiceRegister();
|
||||||
bonjourRegister_http->registerService(
|
bonjourRegister_http->registerService(
|
||||||
BonjourRecord(mDNSDescr, "_hyperiond-http._tcp", QString()),
|
BonjourRecord(mDNSDescr, "_hyperiond-http._tcp", QString()),
|
||||||
port
|
port,
|
||||||
|
txtRecord
|
||||||
);
|
);
|
||||||
Debug(_log, "Web Config mDNS responder started");
|
Debug(_log, "Web Config mDNS responder started");
|
||||||
}
|
}
|
||||||
|
@ -375,26 +375,30 @@ void HyperionDaemon::startNetworkServices()
|
|||||||
// zeroconf description - $leddevicename@$hostname
|
// zeroconf description - $leddevicename@$hostname
|
||||||
const QJsonObject & generalConfig = _qconfig["general"].toObject();
|
const QJsonObject & generalConfig = _qconfig["general"].toObject();
|
||||||
const QString mDNSDescr = generalConfig["name"].toString("") + "@" + QHostInfo::localHostName();
|
const QString mDNSDescr = generalConfig["name"].toString("") + "@" + QHostInfo::localHostName();
|
||||||
|
// txt record for zeroconf
|
||||||
|
QString id = _hyperion->id;
|
||||||
|
std::string version = HYPERION_VERSION;
|
||||||
|
std::vector<std::pair<std::string, std::string> > txtRecord = {{"id",id.toStdString()},{"version",version}};
|
||||||
|
|
||||||
// zeroconf udp listener
|
// zeroconf udp listener
|
||||||
if (_udpListener != nullptr)
|
if (_udpListener != nullptr)
|
||||||
{
|
{
|
||||||
BonjourServiceRegister *bonjourRegister_udp = new BonjourServiceRegister();
|
BonjourServiceRegister *bonjourRegister_udp = new BonjourServiceRegister();
|
||||||
bonjourRegister_udp->registerService(
|
bonjourRegister_udp->registerService(
|
||||||
BonjourRecord(mDNSDescr + ":" + QString::number(_udpListener->getPort()), "_hyperiond-udp._udp", QString()), _udpListener->getPort() );
|
BonjourRecord(mDNSDescr + ":" + QString::number(_udpListener->getPort()), "_hyperiond-udp._udp", QString()), _udpListener->getPort(), txtRecord);
|
||||||
Debug(_log, "UDP LIstener mDNS responder started");
|
Debug(_log, "UDP LIstener mDNS responder started");
|
||||||
}
|
}
|
||||||
|
|
||||||
// zeroconf json
|
// zeroconf json
|
||||||
BonjourServiceRegister *bonjourRegister_json = new BonjourServiceRegister();
|
BonjourServiceRegister *bonjourRegister_json = new BonjourServiceRegister();
|
||||||
bonjourRegister_json->registerService(
|
bonjourRegister_json->registerService(
|
||||||
BonjourRecord(mDNSDescr + ":" + QString::number(_jsonServer->getPort()), "_hyperiond-json._tcp", QString()), _jsonServer->getPort());
|
BonjourRecord(mDNSDescr + ":" + QString::number(_jsonServer->getPort()), "_hyperiond-json._tcp", QString()), _jsonServer->getPort(), txtRecord);
|
||||||
Debug(_log, "Json mDNS responder started");
|
Debug(_log, "Json mDNS responder started");
|
||||||
|
|
||||||
// zeroconf proto
|
// zeroconf proto
|
||||||
BonjourServiceRegister *bonjourRegister_proto = new BonjourServiceRegister();
|
BonjourServiceRegister *bonjourRegister_proto = new BonjourServiceRegister();
|
||||||
bonjourRegister_proto->registerService(
|
bonjourRegister_proto->registerService(
|
||||||
BonjourRecord(mDNSDescr + ":" + QString::number(_jsonServer->getPort()), "_hyperiond-proto._tcp", QString()), _protoServer->getPort());
|
BonjourRecord(mDNSDescr + ":" + QString::number(_jsonServer->getPort()), "_hyperiond-proto._tcp", QString()), _protoServer->getPort(), txtRecord);
|
||||||
Debug(_log, "Proto mDNS responder started");
|
Debug(_log, "Proto mDNS responder started");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user