fix upnp discovery request
This commit is contained in:
parent
25c50d4c8a
commit
b1136ba2a4
@ -75,16 +75,25 @@ GuhConfiguration::GuhConfiguration(QObject *parent) :
|
|||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
} else {
|
} else {
|
||||||
qCWarning(dcApplication) << "No WebServer configuration found. Generating default of 0.0.0.0:3333";
|
qCWarning(dcApplication) << "No WebServer configuration found. Generating default of 0.0.0.0:3333";
|
||||||
WebServerConfiguration config;
|
WebServerConfiguration insecureConfig;
|
||||||
config.id = "default";
|
insecureConfig.id = "insecure";
|
||||||
config.address = QHostAddress("0.0.0.0");
|
insecureConfig.address = QHostAddress("0.0.0.0");
|
||||||
config.port = 3333;
|
insecureConfig.port = 80;
|
||||||
// TODO enable encryption/authentication by default once the important clients are supporting it
|
insecureConfig.sslEnabled = false;
|
||||||
config.sslEnabled = false;
|
insecureConfig.authenticationEnabled = false;
|
||||||
config.authenticationEnabled = false;
|
insecureConfig.publicFolder = "/usr/share/guh-webinterface/public/";
|
||||||
config.publicFolder = "/usr/share/guh-webinterface/public/";
|
m_webServerConfigs[insecureConfig.id] = insecureConfig;
|
||||||
m_webServerConfigs[config.id] = config;
|
storeWebServerConfig(insecureConfig);
|
||||||
storeWebServerConfig(config);
|
|
||||||
|
WebServerConfiguration secureConfig;
|
||||||
|
secureConfig.id = "secure";
|
||||||
|
secureConfig.address = QHostAddress("0.0.0.0");
|
||||||
|
secureConfig.port = 443;
|
||||||
|
secureConfig.sslEnabled = true;
|
||||||
|
secureConfig.authenticationEnabled = false;
|
||||||
|
secureConfig.publicFolder = "/usr/share/guh-webinterface/public/";
|
||||||
|
m_webServerConfigs[secureConfig.id] = secureConfig;
|
||||||
|
storeWebServerConfig(secureConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
// WebSocket Server
|
// WebSocket Server
|
||||||
|
|||||||
@ -363,7 +363,7 @@ void WebServer::readClient()
|
|||||||
qCDebug(dcWebServer) << "server XML request call";
|
qCDebug(dcWebServer) << "server XML request call";
|
||||||
HttpReply *reply = RestResource::createSuccessReply();
|
HttpReply *reply = RestResource::createSuccessReply();
|
||||||
reply->setHeader(HttpReply::ContentTypeHeader, "text/xml");
|
reply->setHeader(HttpReply::ContentTypeHeader, "text/xml");
|
||||||
reply->setPayload(createServerXmlDocument(m_configuration.address));
|
reply->setPayload(createServerXmlDocument(socket->localAddress()));
|
||||||
reply->setClientId(clientId);
|
reply->setClientId(clientId);
|
||||||
sendHttpReply(reply);
|
sendHttpReply(reply);
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
@ -554,11 +554,6 @@ QByteArray WebServer::createServerXmlDocument(QHostAddress address)
|
|||||||
{
|
{
|
||||||
QByteArray uuid = GuhCore::instance()->configuration()->serverUuid().toByteArray();
|
QByteArray uuid = GuhCore::instance()->configuration()->serverUuid().toByteArray();
|
||||||
|
|
||||||
// TODO: support multiple (or none) configured servers here, let's just use the first valid config for now
|
|
||||||
Q_ASSERT_X(GuhCore::instance()->configuration()->webSocketServerConfigurations().count() > 0, "WebServer", "No WebSocket Server config found. This is not supported");
|
|
||||||
|
|
||||||
uint websocketPort = GuhCore::instance()->configuration()->webSocketServerConfigurations().values().first().port;
|
|
||||||
|
|
||||||
QByteArray data;
|
QByteArray data;
|
||||||
QXmlStreamWriter writer(&data);
|
QXmlStreamWriter writer(&data);
|
||||||
writer.setAutoFormatting(true);
|
writer.setAutoFormatting(true);
|
||||||
@ -577,10 +572,36 @@ QByteArray WebServer::createServerXmlDocument(QHostAddress address)
|
|||||||
writer.writeTextElement("URLBase", "http://" + address.toString() + ":" + QString::number(m_configuration.port));
|
writer.writeTextElement("URLBase", "http://" + address.toString() + ":" + QString::number(m_configuration.port));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_configuration.sslEnabled) {
|
ServerConfiguration websocketConfiguration;
|
||||||
writer.writeTextElement("websocketURL", "wss://" + address.toString() + ":" + QString::number(websocketPort));
|
bool webSocketServerFound = false;
|
||||||
} else {
|
foreach (const ServerConfiguration &config, GuhCore::instance()->configuration()->webSocketServerConfigurations()) {
|
||||||
writer.writeTextElement("websocketURL", "ws://" + address.toString() + ":" + QString::number(websocketPort));
|
if (config.address == QHostAddress("0.0.0.0") || config.address == address) {
|
||||||
|
websocketConfiguration = config;
|
||||||
|
webSocketServerFound = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (webSocketServerFound) {
|
||||||
|
if (websocketConfiguration.sslEnabled) {
|
||||||
|
writer.writeTextElement("websocketURL", "wss://" + address.toString() + ":" + QString::number(websocketConfiguration.port));
|
||||||
|
} else {
|
||||||
|
writer.writeTextElement("websocketURL", "ws://" + address.toString() + ":" + QString::number(websocketConfiguration.port));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ServerConfiguration tcpServerConfiguration;
|
||||||
|
bool tcpServerFound = false;
|
||||||
|
foreach (const ServerConfiguration &config, GuhCore::instance()->configuration()->tcpServerConfigurations()) {
|
||||||
|
if (config.address == QHostAddress("0.0.0.0") || config.address == address) {
|
||||||
|
tcpServerConfiguration = config;
|
||||||
|
tcpServerFound = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (tcpServerFound) {
|
||||||
|
if (tcpServerConfiguration.sslEnabled) {
|
||||||
|
writer.writeTextElement("guhRpcURL", "guh://" + address.toString() + ":" + QString::number(tcpServerConfiguration.port));
|
||||||
|
} else {
|
||||||
|
writer.writeTextElement("guhRpcURL", "guhs://" + address.toString() + ":" + QString::number(tcpServerConfiguration.port));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.writeTextElement("presentationURL", "/");
|
writer.writeTextElement("presentationURL", "/");
|
||||||
|
|||||||
Reference in New Issue
Block a user