From e46f7f09b8688a2fb39138f9e4e5038e050ffe83 Mon Sep 17 00:00:00 2001 From: Daniele Forsi Date: Sat, 20 Jul 2024 19:20:17 +0200 Subject: [PATCH] Fix API host address in About dialog and debug message The API server is listening on all interfaces. This is indicated by Qt with the address 0.0.0.0 even if it is listening on both IPv4 and IPv6 https://doc.qt.io/qt-6/qhostaddress.html#toString So the following addresses are valid http://127.0.0.1:8091/ http://[::1]:8091/ http://0.0.0.0:8091/ http://[::]:8091/ plus any other address assigned to wired, wireless or virtual interfaces. --- sdrbase/webapi/webapiserver.cpp | 4 ++-- sdrgui/gui/aboutdialog.cpp | 2 +- sdrgui/mainwindow.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sdrbase/webapi/webapiserver.cpp b/sdrbase/webapi/webapiserver.cpp index f38bded42..29e1cf4ab 100644 --- a/sdrbase/webapi/webapiserver.cpp +++ b/sdrbase/webapi/webapiserver.cpp @@ -44,7 +44,7 @@ void WebAPIServer::start() if (!m_listener) { m_listener = new qtwebapp::HttpListener(m_settings, m_requestMapper, qApp); - qInfo("WebAPIServer::start: starting web API server at http://%s:%d", qPrintable(m_settings.host), m_settings.port); + qInfo("WebAPIServer::start: starting web API server at http://%s:%d", qPrintable(m_settings.host.isEmpty() ? "0.0.0.0" : m_settings.host), m_settings.port); } } @@ -54,7 +54,7 @@ void WebAPIServer::stop() { delete m_listener; m_listener = 0; - qInfo("WebAPIServer::stop: stopped web API server at http://%s:%d", qPrintable(m_settings.host), m_settings.port); + qInfo("WebAPIServer::stop: stopped web API server at http://%s:%d", qPrintable(m_settings.host.isEmpty() ? "0.0.0.0" : m_settings.host), m_settings.port); } } diff --git a/sdrgui/gui/aboutdialog.cpp b/sdrgui/gui/aboutdialog.cpp index 3645a8953..65db99464 100644 --- a/sdrgui/gui/aboutdialog.cpp +++ b/sdrgui/gui/aboutdialog.cpp @@ -32,7 +32,7 @@ AboutDialog::AboutDialog(const QString& apiHost, int apiPort, const MainSettings ui->dspBits->setText(QString("DSP Rx %1 bits Tx %2 bits").arg(SDR_RX_SAMP_SZ).arg(SDR_TX_SAMP_SZ)); ui->pid->setText(QString("PID: %1").arg(qApp->applicationPid())); QString apiUrl = QString("http://%1:%2/").arg(apiHost).arg(apiPort); - ui->restApiUrl->setText(QString("REST API documentation: %2").arg(apiUrl).arg(apiUrl)); + ui->restApiUrl->setText(QString("REST API server and documentation: %2").arg(apiUrl).arg(apiUrl)); ui->restApiUrl->setOpenExternalLinks(true); ui->settingsFile->setText(QString("Settings: %1").arg(mainSettings.getFileLocation())); } diff --git a/sdrgui/mainwindow.cpp b/sdrgui/mainwindow.cpp index ac6c12044..3b905a7dd 100644 --- a/sdrgui/mainwindow.cpp +++ b/sdrgui/mainwindow.cpp @@ -3096,7 +3096,7 @@ void MainWindow::loadDefaultPreset(const QString& pluginId, SerializableInterfac void MainWindow::on_action_About_triggered() { - AboutDialog dlg(m_apiHost.isEmpty() ? "127.0.0.1" : m_apiHost, m_apiPort, m_mainCore->m_settings, this); + AboutDialog dlg(m_apiHost.isEmpty() ? "0.0.0.0" : m_apiHost, m_apiPort, m_mainCore->m_settings, this); dlg.exec(); }