diff --git a/apps/caracal.cpp b/apps/caracal.cpp index c77fde2..1ddd7d6 100644 --- a/apps/caracal.cpp +++ b/apps/caracal.cpp @@ -131,7 +131,6 @@ int main(int argc, char** argv) { spdlog::set_default_logger(spdlog::stderr_color_st("")); spdlog::info("Reading from stdin, press CTRL+D to stop..."); - std::ios::sync_with_stdio(false); caracal::Prober::probe(config, std::cin); } catch (const std::exception& e) { auto type = caracal::Utilities::demangle(typeid(e).name()); diff --git a/src/sniffer.cpp b/src/sniffer.cpp index 2ad0026..899f27a 100644 --- a/src/sniffer.cpp +++ b/src/sniffer.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include namespace fs = std::filesystem; @@ -70,6 +71,7 @@ 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()); @@ -77,7 +79,7 @@ void Sniffer::start() noexcept { 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, ""));