1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-24 17:08:36 -05:00

Merge pull request #1029 from srcejon/fix_1028

Fix for #1028 - allow API to bind to any address
This commit is contained in:
Edouard Griffiths 2021-11-01 21:04:35 +01:00 committed by GitHub
commit c4a886abe2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 14 deletions

View File

@ -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,18 +63,20 @@ 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
+ "\\." + ipRange
+ "\\." + ipRange + "$");
QRegExpValidator ipValidator(ipRegex);
QString ipRange = "(?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])";
QRegExp ipRegex ("^" + ipRange
+ "\\." + ipRange
+ "\\." + ipRange
+ "\\." + ipRange + "$");
QRegExpValidator ipValidator(ipRegex);
if (ipValidator.validate(serverAddress, pos) == QValidator::Acceptable) {
m_serverAddress = serverAddress;
} else {
qWarning() << "MainParser::parse: server address invalid. Defaulting to " << m_serverAddress;
if (ipValidator.validate(serverAddress, pos) == QValidator::Acceptable) {
m_serverAddress = serverAddress;
} else {
qWarning() << "MainParser::parse: server address invalid. Defaulting to any address.";
}
}
// server port

View File

@ -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();
}