mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 01:05:34 +08:00
[AFV] Guard against "missing" crypto channel (=> ASSERT)
This commit is contained in:
committed by
Mat Sutcliffe
parent
481833b003
commit
34817a83d5
@@ -58,7 +58,6 @@ namespace BlackCore
|
||||
{
|
||||
// callback when connection has been established
|
||||
if (!myself) { return; }
|
||||
m_connection.setConnected(authenticated);
|
||||
|
||||
if (authenticated)
|
||||
{
|
||||
@@ -72,6 +71,9 @@ namespace BlackCore
|
||||
CLogMessage(this).info(u"Connected: '%1' to voice server, socket open: %2") << callsign << boolToYesNo(m_udpSocket->isOpen());
|
||||
}
|
||||
|
||||
// Make sure crypto channels etc. are created
|
||||
m_connection.setConnected(authenticated);
|
||||
|
||||
// callback of the calling parent
|
||||
if (callback) { callback(authenticated); }
|
||||
}
|
||||
@@ -146,6 +148,12 @@ namespace BlackCore
|
||||
|
||||
void CClientConnection::processMessage(const QByteArray &messageDdata, bool loopback)
|
||||
{
|
||||
if (!m_connection.m_voiceCryptoChannel)
|
||||
{
|
||||
BLACK_VERIFY_X(false, Q_FUNC_INFO, "processMessage used without crypto channel");
|
||||
return;
|
||||
}
|
||||
|
||||
CryptoDtoSerializer::Deserializer deserializer = CryptoDtoSerializer::deserialize(*m_connection.m_voiceCryptoChannel, messageDdata, loopback);
|
||||
|
||||
if (deserializer.dtoNameBuffer == AudioRxOnTransceiversDto::getShortDtoName())
|
||||
@@ -176,6 +184,12 @@ namespace BlackCore
|
||||
|
||||
void CClientConnection::voiceServerHeartbeat()
|
||||
{
|
||||
if (!m_connection.m_voiceCryptoChannel || !m_udpSocket)
|
||||
{
|
||||
BLACK_VERIFY_X(false, Q_FUNC_INFO, "voiceServerHeartbeat used without crypto channel or socket");
|
||||
return;
|
||||
}
|
||||
|
||||
const QUrl voiceServerUrl("udp://" + m_connection.getTokens().VoiceServer.addressIpV4);
|
||||
if (CBuildConfig::isLocalDeveloperDebugBuild()) { CLogMessage(this).debug(u"Sending voice server heartbeat to '%1'") << voiceServerUrl.host(); }
|
||||
HeartbeatDto keepAlive;
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "blackcore/afv/connection/clientconnectiondata.h"
|
||||
#include "blackcore/afv/connection/apiserverconnection.h"
|
||||
#include "blackcore/afv/dto.h"
|
||||
#include "blackmisc/verify.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
@@ -69,6 +70,11 @@ namespace BlackCore
|
||||
template<typename T>
|
||||
void sendToVoiceServer(const T &dto)
|
||||
{
|
||||
if (!m_connection.m_voiceCryptoChannel || !m_udpSocket)
|
||||
{
|
||||
BLACK_VERIFY_X(false, Q_FUNC_INFO, "sendVoice used without crypto channel or socket");
|
||||
return;
|
||||
}
|
||||
const QUrl voiceServerUrl("udp://" + m_connection.getTokens().VoiceServer.addressIpV4);
|
||||
const QByteArray dataBytes = Crypto::CryptoDtoSerializer::serialize(*m_connection.m_voiceCryptoChannel, Crypto::CryptoDtoMode::AEAD_ChaCha20Poly1305, dto);
|
||||
m_udpSocket->writeDatagram(dataBytes, QHostAddress(voiceServerUrl.host()), static_cast<quint16>(voiceServerUrl.port()));
|
||||
|
||||
@@ -43,7 +43,6 @@ namespace BlackCore
|
||||
return;
|
||||
}
|
||||
m_voiceCryptoChannel.reset(new CCryptoDtoChannel(m_tokens.VoiceServer.channelConfig));
|
||||
// dataCryptoChannel.reset(new CryptoDtoChannel(m_tokens.DataServer.channelConfig));
|
||||
}
|
||||
|
||||
void CClientConnectionData::setTsAuthenticatedToNow()
|
||||
|
||||
Reference in New Issue
Block a user