mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-02-03 09:44:01 -05:00
Fix for 1028 - allow API to bind to any address
This commit is contained in:
parent
f04741d692
commit
c13943bfbb
@ -26,7 +26,7 @@ MainParser::MainParser() :
|
|||||||
m_serverAddressOption(QStringList() << "a" << "api-address",
|
m_serverAddressOption(QStringList() << "a" << "api-address",
|
||||||
"Web API server address.",
|
"Web API server address.",
|
||||||
"address",
|
"address",
|
||||||
"127.0.0.1"),
|
""),
|
||||||
m_serverPortOption(QStringList() << "p" << "api-port",
|
m_serverPortOption(QStringList() << "p" << "api-port",
|
||||||
"Web API server port.",
|
"Web API server port.",
|
||||||
"port",
|
"port",
|
||||||
@ -36,7 +36,7 @@ MainParser::MainParser() :
|
|||||||
"file",
|
"file",
|
||||||
"")
|
"")
|
||||||
{
|
{
|
||||||
m_serverAddress = "127.0.0.1";
|
m_serverAddress = ""; // Bind to any address
|
||||||
m_serverPort = 8091;
|
m_serverPort = 8091;
|
||||||
m_mimoSupport = false;
|
m_mimoSupport = false;
|
||||||
m_fftwfWindowFileName = "";
|
m_fftwfWindowFileName = "";
|
||||||
@ -63,18 +63,20 @@ void MainParser::parse(const QCoreApplication& app)
|
|||||||
// server address
|
// server address
|
||||||
|
|
||||||
QString serverAddress = m_parser.value(m_serverAddressOption);
|
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])";
|
if (ipValidator.validate(serverAddress, pos) == QValidator::Acceptable) {
|
||||||
QRegExp ipRegex ("^" + ipRange
|
m_serverAddress = serverAddress;
|
||||||
+ "\\." + ipRange
|
} else {
|
||||||
+ "\\." + ipRange
|
qWarning() << "MainParser::parse: server address invalid. Defaulting to any address.";
|
||||||
+ "\\." + 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// server port
|
// server port
|
||||||
|
@ -2191,7 +2191,7 @@ void MainWindow::deleteFeature(int featureSetIndex, int featureIndex)
|
|||||||
|
|
||||||
void MainWindow::on_action_About_triggered()
|
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();
|
dlg.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user