mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +08:00
Fixes when dealing with refs #223 / https://dev.vatsim-germany.org/boards/22/topics/1691?r=1701#message-1701
* Wrong address split ip:port * Q_ASSERTs
This commit is contained in:
@@ -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");
|
||||
|
||||
@@ -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());
|
||||
|
||||
|
||||
@@ -6,8 +6,10 @@
|
||||
#include <QDebug>
|
||||
#include <QMetaClassInfo>
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user