Skip to content

Commit

Permalink
sniffer: fix mangled lines on stdout output
Browse files Browse the repository at this point in the history
  • Loading branch information
maxmouchet committed Jan 6, 2024
1 parent 4764ae4 commit 111dafb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
path: build/caracal-linux-amd64

macos:
runs-on: macos-latest
runs-on: macos-13
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
- uses: codecov/codecov-action@v3

macos:
runs-on: macos-latest
runs-on: macos-13
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
Expand Down
4 changes: 3 additions & 1 deletion src/sniffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <filesystem>
#include <iostream>
#include <optional>
#include <syncstream>
#include <thread>

namespace fs = std::filesystem;
Expand Down Expand Up @@ -70,14 +71,15 @@ void Sniffer::start() noexcept {
std::cout << (Reply::csv_header() + "\n");
auto handler = [this](Tins::Packet &packet) {
auto reply = Parser::parse(packet);
auto stdout = std::osyncstream(std::cout);

if (reply && (!integrity_check_ || reply->is_valid(caracal_id_))) {
spdlog::trace(reply.value());
statistics_.icmp_messages_all.insert(reply->reply_src_addr);
if (reply->is_time_exceeded()) {
statistics_.icmp_messages_path.insert(reply->reply_src_addr);
}
std::cout << (reply->to_csv(meta_round_.value_or("1")) + "\n");
stdout << (reply->to_csv(meta_round_.value_or("1")) + "\n");
} else {
auto data = packet.pdu()->serialize();
spdlog::trace("invalid_packet_hex={:02x}", fmt::join(data, ""));
Expand Down

0 comments on commit 111dafb

Please sign in to comment.