zeroconf updates (#421)

* zeroconf:
add ip
make names more uniq

* tune dns name for webconfig
This commit is contained in:
redPanther 2017-03-22 23:08:01 +01:00 committed by GitHub
parent 0d996d6d10
commit a08e951762
7 changed files with 14 additions and 19 deletions

View File

@ -55,6 +55,7 @@ public:
QString registeredType; QString registeredType;
QString replyDomain; QString replyDomain;
QString hostName; QString hostName;
QString address;
int port; int port;
bool operator==(const BonjourRecord &other) const bool operator==(const BonjourRecord &other) const

View File

@ -90,7 +90,7 @@ void BonjourServiceBrowser::bonjourBrowseReply(DNSServiceRef , DNSServiceFlags f
else else
{ {
BonjourRecord bonjourRecord(serviceName, regType, replyDomain); BonjourRecord bonjourRecord(serviceName, regType, replyDomain);
if (flags & kDNSServiceFlagsAdd) if ((flags & kDNSServiceFlagsAdd) != 0)
{ {
if (!serviceBrowser->bonjourRecords.contains(bonjourRecord)) if (!serviceBrowser->bonjourRecords.contains(bonjourRecord))
{ {

View File

@ -505,6 +505,7 @@ void Hyperion::bonjourRecordResolved(const QHostInfo &hostInfo, int port)
} }
_hyperionSessions[_bonjourCurrentServiceToResolve].hostName = host; _hyperionSessions[_bonjourCurrentServiceToResolve].hostName = host;
_hyperionSessions[_bonjourCurrentServiceToResolve].port = port; _hyperionSessions[_bonjourCurrentServiceToResolve].port = port;
_hyperionSessions[_bonjourCurrentServiceToResolve].address = hostInfo.addresses().isEmpty() ? "" : hostInfo.addresses().first().toString();
Debug(_log, "found hyperion session: %s:%d",QSTRING_CSTR(hostInfo.hostName()), port); Debug(_log, "found hyperion session: %s:%d",QSTRING_CSTR(hostInfo.hostName()), port);
} }
} }

View File

@ -841,6 +841,7 @@ void JsonClientConnection::handleServerInfoCommand(const QJsonObject&, const QSt
item["type"] = session.registeredType; item["type"] = session.registeredType;
item["domain"] = session.replyDomain; item["domain"] = session.replyDomain;
item["host"] = session.hostName; item["host"] = session.hostName;
item["address"]= session.address;
item["port"] = session.port; item["port"] = session.port;
sessions.append(item); sessions.append(item);
} }

View File

@ -44,8 +44,8 @@ StaticFileServing::~StaticFileServing ()
void StaticFileServing::onServerStarted (quint16 port) void StaticFileServing::onServerStarted (quint16 port)
{ {
Info(_log, "started on port %d name '%s'", port ,_server->getServerName().toStdString().c_str()); Info(_log, "started on port %d name '%s'", port ,_server->getServerName().toStdString().c_str());
const QJsonObject & generalConfig = _hyperion->getQJsonConfig()["general"].toObject();
const QString mDNSDescr = _server->getServerName() + "@" + QHostInfo::localHostName(); const QString mDNSDescr = generalConfig["name"].toString("") + "@" + QHostInfo::localHostName() + ":" + QString::number(port);
BonjourServiceRegister *bonjourRegister_http = new BonjourServiceRegister(); BonjourServiceRegister *bonjourRegister_http = new BonjourServiceRegister();
bonjourRegister_http->registerService( bonjourRegister_http->registerService(

View File

@ -19,7 +19,7 @@ WebConfig::WebConfig(QObject * parent)
{ {
const QJsonObject webconfigConfig = config["webConfig"].toObject(); const QJsonObject webconfigConfig = config["webConfig"].toObject();
webconfigEnable = webconfigConfig["enable"].toBool(true); webconfigEnable = webconfigConfig["enable"].toBool(true);
_port = webconfigConfig["port"].toInt(_port); _port = webconfigConfig["port"].toInt(_port);
_baseUrl = webconfigConfig["document_root"].toString(_baseUrl); _baseUrl = webconfigConfig["document_root"].toString(_baseUrl);
} }

View File

@ -368,35 +368,27 @@ void HyperionDaemon::startNetworkServices()
// zeroconf description - $leddevicename@$hostname // zeroconf description - $leddevicename@$hostname
const QJsonObject & generalConfig = _qconfig["general"].toObject(); const QJsonObject & generalConfig = _qconfig["general"].toObject();
const std::string mDNSDescr = ( generalConfig["name"].toString("").toStdString() const QString mDNSDescr = generalConfig["name"].toString("") + "@" + QHostInfo::localHostName();
+ "@" +
QHostInfo::localHostName().toStdString()
);
// 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.c_str(), "_hyperiond-udp._udp", QString()), BonjourRecord(mDNSDescr + ":" + QString::number(_udpListener->getPort()), "_hyperiond-udp._udp", QString()), _udpListener->getPort() );
_udpListener->getPort()
);
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.c_str(), "_hyperiond-json._tcp", QString()), BonjourRecord(mDNSDescr + ":" + QString::number(_jsonServer->getPort()), "_hyperiond-json._tcp", QString()), _jsonServer->getPort());
_jsonServer->getPort()
);
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.c_str(), "_hyperiond-proto._tcp", QString()), BonjourRecord(mDNSDescr + ":" + QString::number(_jsonServer->getPort()), "_hyperiond-proto._tcp", QString()), _protoServer->getPort());
_protoServer->getPort()
);
Debug(_log, "Proto mDNS responder started"); Debug(_log, "Proto mDNS responder started");
} }