mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-19 03:45:30 +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() << "3 + la/ra .. P2P DBus server";
|
||||||
qDebug() << "la .. local audio, audio runs in this core here (default)";
|
qDebug() << "la .. local audio, audio runs in this core here (default)";
|
||||||
qDebug() << "ra .. remote audio, audio runs in the GUI or elsewhere";
|
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
|
// configure DBus server
|
||||||
QString dBusAddress = BlackCore::CDBusServer::sessionDBusServer();
|
QString dBusAddress = BlackCore::CDBusServer::sessionDBusServer();
|
||||||
@@ -47,6 +48,10 @@ int main(int argc, char *argv[])
|
|||||||
dBusAddress = cin.readLine().toLower();
|
dBusAddress = cin.readLine().toLower();
|
||||||
dBusAddress = BlackCore::CDBusServer::p2pAddress(dBusAddress);
|
dBusAddress = BlackCore::CDBusServer::p2pAddress(dBusAddress);
|
||||||
}
|
}
|
||||||
|
else if (input.startsWith("x"))
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// with remote audio
|
// with remote audio
|
||||||
bool remoteAudio = input.contains("ra");
|
bool remoteAudio = input.contains("ra");
|
||||||
|
|||||||
@@ -245,7 +245,14 @@ namespace BlackCore
|
|||||||
if (config.requiresDBusConnection())
|
if (config.requiresDBusConnection())
|
||||||
{
|
{
|
||||||
this->initDBusConnection(dbusAddress);
|
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());
|
times.insert("DBus", time.restart());
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,10 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QMetaClassInfo>
|
#include <QMetaClassInfo>
|
||||||
|
|
||||||
|
#include "blackmisc/networkutils.h"
|
||||||
#include "dbus_server.h"
|
#include "dbus_server.h"
|
||||||
|
|
||||||
|
|
||||||
namespace BlackCore
|
namespace BlackCore
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -198,21 +200,23 @@ namespace BlackCore
|
|||||||
*/
|
*/
|
||||||
QString CDBusServer::p2pAddress(const QString &host, const QString &port)
|
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;
|
QString p = port;
|
||||||
if (port.isEmpty())
|
if (port.isEmpty())
|
||||||
{
|
{
|
||||||
if (host.contains(":"))
|
if (h.contains(":"))
|
||||||
{
|
{
|
||||||
QStringList parts = host.split(host);
|
QStringList parts = h.split(":");
|
||||||
h = parts.at(0);
|
Q_ASSERT_X(parts.length() == 2, "p2pAdress", "Wrong IP string split");
|
||||||
p = parts.at(1);
|
h = parts.at(0).trimmed();
|
||||||
|
p = parts.at(1).trimmed();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
p = "45000";
|
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);
|
QString p2p = QString("tcp:host=%1,port=%2").arg(h).arg(p);
|
||||||
return p2p;
|
return p2p;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user