summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJesus Fernandez <jesus.fernandez@qt.io>2018-01-05 17:43:11 +0100
committerJesus Fernandez <Jesus.Fernandez@qt.io>2018-03-21 12:51:37 +0000
commit788c45bf8460ab6c882508a4c2c7c4bae187c3a4 (patch)
treed1d2776edd6ab7a3d1606f0376c8e7fef95bb9e5 /src
parenta4e460a01f1962317093a5fb2170c869aead954a (diff)
Add an environment variable to set the WebSocket Server address
Using the QT_WEBGL_WEBSOCKETSERVER environment variable the WebSocket Server listen address and port can be configured. [ChangeLog][QtWebGL] QT_WEBGL_WEBSOCKETSERVER environment variable can be used to configure the WebSocket Server address and port. Task-number: QTBUG-65241 Change-Id: I3035aa7cc18d469293a4d55bc36e91cfae5ec03a Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io> Reviewed-by: Jason Hihn <jhihn@gmx.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/platforms/webgl/qwebglwebsocketserver.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/plugins/platforms/webgl/qwebglwebsocketserver.cpp b/src/plugins/platforms/webgl/qwebglwebsocketserver.cpp
index 959287d..ed7a4d6 100644
--- a/src/plugins/platforms/webgl/qwebglwebsocketserver.cpp
+++ b/src/plugins/platforms/webgl/qwebglwebsocketserver.cpp
@@ -107,8 +107,20 @@ QVariant QWebGLWebSocketServer::queryValue(int id)
void QWebGLWebSocketServer::create()
{
Q_D(QWebGLWebSocketServer);
- d->server = new QWebSocketServer(QLatin1String("qtwebgl"), QWebSocketServer::NonSecureMode);
- if (d->server->listen(QHostAddress::Any)) {
+ const QString serverName = QLatin1String("qtwebgl");
+ const QUrl url(QString::fromUtf8(qgetenv("QT_WEBGL_WEBSOCKETSERVER")));
+ QHostAddress hostAddress(url.host());
+ if (!url.isValid() || url.isEmpty() || !(url.scheme() == "ws" || url.scheme() == "wss")) {
+ d->server = new QWebSocketServer(serverName, QWebSocketServer::NonSecureMode);
+ hostAddress = QHostAddress::Any;
+ } else {
+ d->server = new QWebSocketServer(serverName,
+#if QT_CONFIG(ssl)
+ url.scheme() == "wss" ? QWebSocketServer::SecureMode :
+#endif
+ QWebSocketServer::NonSecureMode);
+ }
+ if (d->server->listen(hostAddress, url.port(0))) {
connect(d->server, &QWebSocketServer::newConnection,
this, &QWebGLWebSocketServer::onNewConnection);
} else {