Fix for 1028 - allow API to bind to any address

pull/1029/head
Jon Beniston 2021-11-01 09:51:50 +00:00
rodzic f04741d692
commit c13943bfbb
2 zmienionych plików z 16 dodań i 14 usunięć

Wyświetl plik

@ -26,7 +26,7 @@ MainParser::MainParser() :
m_serverAddressOption(QStringList() << "a" << "api-address",
"Web API server address.",
"address",
"127.0.0.1"),
""),
m_serverPortOption(QStringList() << "p" << "api-port",
"Web API server port.",
"port",
@ -36,7 +36,7 @@ MainParser::MainParser() :
"file",
"")
{
m_serverAddress = "127.0.0.1";
m_serverAddress = ""; // Bind to any address
m_serverPort = 8091;
m_mimoSupport = false;
m_fftwfWindowFileName = "";
@ -63,7 +63,8 @@ void MainParser::parse(const QCoreApplication& app)
// server address
QString serverAddress = m_parser.value(m_serverAddressOption);
if (!serverAddress.isEmpty())
{
QString ipRange = "(?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])";
QRegExp ipRegex ("^" + ipRange
+ "\\." + ipRange
@ -74,7 +75,8 @@ void MainParser::parse(const QCoreApplication& app)
if (ipValidator.validate(serverAddress, pos) == QValidator::Acceptable) {
m_serverAddress = serverAddress;
} else {
qWarning() << "MainParser::parse: server address invalid. Defaulting to " << m_serverAddress;
qWarning() << "MainParser::parse: server address invalid. Defaulting to any address.";
}
}
// server port

Wyświetl plik

@ -2191,7 +2191,7 @@ void MainWindow::deleteFeature(int featureSetIndex, int featureIndex)
void MainWindow::on_action_About_triggered()
{
AboutDialog dlg(m_apiHost, m_apiPort, m_mainCore->m_settings, this);
AboutDialog dlg(m_apiHost.isEmpty() ? "127.0.0.1" : m_apiHost, m_apiPort, m_mainCore->m_settings, this);
dlg.exec();
}