diff --git a/samples/blackcore/main.cpp b/samples/blackcore/main.cpp index 7fdaab2d5..00f8de7ed 100644 --- a/samples/blackcore/main.cpp +++ b/samples/blackcore/main.cpp @@ -34,7 +34,8 @@ int main(int argc, char *argv[]) qDebug() << "3 + la/ra .. P2P DBus server"; qDebug() << "la .. local audio, audio runs in this core here (default)"; qDebug() << "ra .. remote audio, audio runs in the GUI or elsewhere"; - QString input = cin.readLine().toLower(); + qDebug() << "x .. exit"; + QString input = cin.readLine().toLower().trimmed(); // configure DBus server QString dBusAddress = BlackCore::CDBusServer::sessionDBusServer(); @@ -47,6 +48,10 @@ int main(int argc, char *argv[]) dBusAddress = cin.readLine().toLower(); dBusAddress = BlackCore::CDBusServer::p2pAddress(dBusAddress); } + else if (input.startsWith("x")) + { + return 0; + } // with remote audio bool remoteAudio = input.contains("ra"); diff --git a/src/blackcore/context_runtime.cpp b/src/blackcore/context_runtime.cpp index ae72b33b9..e7fb720f6 100644 --- a/src/blackcore/context_runtime.cpp +++ b/src/blackcore/context_runtime.cpp @@ -245,7 +245,14 @@ namespace BlackCore if (config.requiresDBusConnection()) { this->initDBusConnection(dbusAddress); - Q_ASSERT(this->m_dbusConnection.isConnected()); + if (!this->m_dbusConnection.isConnected()) + { + QString notConnected("DBus connection failed"); + QString e = this->m_dbusConnection.lastError().message(); + if (!e.isEmpty()) notConnected.append(" ").append(e); + Q_ASSERT_X(false, "CRuntime::init", notConnected.toUtf8().constData()); + qCritical() << notConnected; + } } times.insert("DBus", time.restart()); diff --git a/src/blackcore/dbus_server.cpp b/src/blackcore/dbus_server.cpp index d49d8defd..108786d93 100644 --- a/src/blackcore/dbus_server.cpp +++ b/src/blackcore/dbus_server.cpp @@ -6,8 +6,10 @@ #include #include +#include "blackmisc/networkutils.h" #include "dbus_server.h" + namespace BlackCore { @@ -198,21 +200,23 @@ namespace BlackCore */ QString CDBusServer::p2pAddress(const QString &host, const QString &port) { - QString h = host.isEmpty() ? "127.0.0.1" : host; + QString h = host.isEmpty() ? "127.0.0.1" : host.trimmed(); QString p = port; if (port.isEmpty()) { - if (host.contains(":")) + if (h.contains(":")) { - QStringList parts = host.split(host); - h = parts.at(0); - p = parts.at(1); + QStringList parts = h.split(":"); + Q_ASSERT_X(parts.length() == 2, "p2pAdress", "Wrong IP string split"); + h = parts.at(0).trimmed(); + p = parts.at(1).trimmed(); } else { p = "45000"; } } + Q_ASSERT_X(BlackMisc::CNetworkUtils::isValidIPv4Address(p), "p2pAdress", "Wrong IP in String"); QString p2p = QString("tcp:host=%1,port=%2").arg(h).arg(p); return p2p; }