Add size header to information packet

This commit is contained in:
Tixx 2025-01-12 16:55:38 +01:00
parent cd29f25435
commit a7eeda0569
No known key found for this signature in database
GPG Key ID: EC6E7A2BAABF0B8C

View File

@ -258,8 +258,16 @@ void TNetwork::Identify(TConnection&& RawConnection) {
write(RawConnection.Socket, buffer("P"), ec);
return;
} else if (Code == 'I') {
const std::string Data = Application::Settings.getAsBool(Settings::Key::General_InformationPacket) ? THeartbeatThread::lastCall : "";
const auto Size = static_cast<int32_t>(Data.size());
std::vector<uint8_t> ToSend;
ToSend.resize(Data.size() + sizeof(Size));
std::memcpy(ToSend.data(), &Size, sizeof(Size));
std::memcpy(ToSend.data() + sizeof(Size), Data.data(), Data.size());
boost::system::error_code ec;
write(RawConnection.Socket, buffer(Application::Settings.getAsBool(Settings::Key::General_InformationPacket) ? THeartbeatThread::lastCall : ""), ec);
write(RawConnection.Socket, buffer(ToSend), ec);
} else {
beammp_errorf("Invalid code got in Identify: '{}'", Code);
}