From e8a6a0a400a4dc1afd0bcb7d5c08ca4a1161ba8f Mon Sep 17 00:00:00 2001 From: study-faraphel Date: Thu, 2 Jan 2025 21:48:27 +0100 Subject: [PATCH] use docker for testing --- Dockerfile | 20 ++++++++--- docker-compose.yml | 37 +++++++++++++++++++++ source/behavior/events/info/InfoEvent.cpp | 1 + source/behavior/events/info/InfoEvent.hpp | 1 + source/behavior/tasks/server/ServerTask.cpp | 2 +- source/packets/audio/AudioPacketData.hpp | 1 + source/packets/search/SearchPacketData.hpp | 1 + source/utils/serialize/basics.hpp | 4 +-- 8 files changed, 59 insertions(+), 8 deletions(-) create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile index 079ee26..c96906f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,24 @@ -FROM alpine:latest +FROM debian:latest -RUN apk add gcc g++ cmake ninja -RUN apk add mpg123-dev openssl-dev alsa-lib alsa-utils portaudio-dev pulseaudio-alsa alsa-plugins-pulse pulseaudio pulseaudio-utils +# update repositories +RUN apt-get update -y +RUN apt-get upgrade -y -RUN echo "pcm.!default pulse\nctl.!default pulse" > /root/.asoundrc +# install build dependencies +RUN apt-get install -y cmake gcc g++ ninja-build +# install application dependencies +RUN apt-get install -y libmpg123-dev libssl-dev portaudio19-dev +# enable sound +# RUN echo "pcm.!default pulse\nctl.!default pulse" > /root/.asoundrc + +# copy the application WORKDIR /app COPY . /app +# build the application RUN cmake -S . -B build -G Ninja RUN cmake --build build -CMD ["build/M2-PT-DRP"] +# run the application +CMD ["build/M2-PT-DRP", "--host", "::1", "--port", "15650", "--ipv6"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..044ea56 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,37 @@ +services: + machine-1: + build: + context: ./ + dockerfile: ./Dockerfile + network: host + networks: + - machines + + machine-2: + build: + context: ./ + dockerfile: ./Dockerfile + network: host + networks: + - machines + + machine-3: + build: + context: ./ + dockerfile: ./Dockerfile + network: host + networks: + - machines + + machine-4: + build: + context: ./ + dockerfile: ./Dockerfile + network: host + networks: + - machines + +networks: + machines: + enable_ipv6: true + attachable: true diff --git a/source/behavior/events/info/InfoEvent.cpp b/source/behavior/events/info/InfoEvent.cpp index 3b02e48..370209f 100644 --- a/source/behavior/events/info/InfoEvent.cpp +++ b/source/behavior/events/info/InfoEvent.cpp @@ -1,6 +1,7 @@ #include "InfoEvent.hpp" #include +#include #include #include "packets/info/InfoPacketData.hpp" diff --git a/source/behavior/events/info/InfoEvent.hpp b/source/behavior/events/info/InfoEvent.hpp index a98eb29..85b159a 100644 --- a/source/behavior/events/info/InfoEvent.hpp +++ b/source/behavior/events/info/InfoEvent.hpp @@ -1,6 +1,7 @@ #pragma once #include "../base/BaseEvent.hpp" +#include namespace drp::event { diff --git a/source/behavior/tasks/server/ServerTask.cpp b/source/behavior/tasks/server/ServerTask.cpp index 87e74c6..5461118 100644 --- a/source/behavior/tasks/server/ServerTask.cpp +++ b/source/behavior/tasks/server/ServerTask.cpp @@ -109,7 +109,7 @@ void ServerTask::handle(Context& context) { packetContent.eventType = event::EventType::AUDIO; packetContent.data = audioPacket.serialize(); - packet.setContent(context, packet::base::SecurityMode::PLAIN, packetContent); + packet.setContent(context, packet::base::SecurityMode::AES, packetContent); const auto serializedPacket = packet.serialize(); diff --git a/source/packets/audio/AudioPacketData.hpp b/source/packets/audio/AudioPacketData.hpp index 65f0830..7a9d559 100644 --- a/source/packets/audio/AudioPacketData.hpp +++ b/source/packets/audio/AudioPacketData.hpp @@ -2,6 +2,7 @@ #include #include +#include namespace drp::packet::audio { diff --git a/source/packets/search/SearchPacketData.hpp b/source/packets/search/SearchPacketData.hpp index 216fecb..3239fea 100644 --- a/source/packets/search/SearchPacketData.hpp +++ b/source/packets/search/SearchPacketData.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include namespace drp::packet::search { diff --git a/source/utils/serialize/basics.hpp b/source/utils/serialize/basics.hpp index e38ca73..6d7d7a3 100644 --- a/source/utils/serialize/basics.hpp +++ b/source/utils/serialize/basics.hpp @@ -52,7 +52,7 @@ Type deserializeObject(std::vector& data) { * @param object the vector to serialize. * @return the vector data as a vector of bytes. */ -template +template std::vector serializeVector(const std::vector& object) { // create a vector with enough size for the size and the data of the vector std::vector buffer(sizeof(SizeType) + object.size() * sizeof(Type)); @@ -75,7 +75,7 @@ std::vector serializeVector(const std::vector& object) { * @param data the data in the vector * @return the vector of object */ -template +template std::vector deserializeVector(std::vector& data) { // get the size of the vector SizeType size;